LCOV - code coverage report
Current view: top level - forms/source/xforms - model.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 19 0.0 %
Date: 2014-11-03 Functions: 0 12 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #ifndef INCLUDED_FORMS_SOURCE_XFORMS_MODEL_HXX
      21             : #define INCLUDED_FORMS_SOURCE_XFORMS_MODEL_HXX
      22             : 
      23             : #include <cppuhelper/implbase4.hxx>
      24             : #include <propertysetbase.hxx>
      25             : #include <com/sun/star/xforms/XModel2.hpp>
      26             : #include <com/sun/star/xforms/XFormsUIHelper1.hpp>
      27             : #include <com/sun/star/util/XUpdatable.hpp>
      28             : #include <com/sun/star/lang/XUnoTunnel.hpp>
      29             : 
      30             : #include <com/sun/star/uno/Reference.hxx>
      31             : #include "mip.hxx"
      32             : #include <map>
      33             : 
      34             : 
      35             : // forward declaractions
      36             : namespace com { namespace sun { namespace star
      37             : {
      38             :     namespace xml { namespace dom { class XDocument; } }
      39             :     namespace xml { namespace dom { class XNode; } }
      40             :     namespace uno { template<typename T> class Sequence; }
      41             :     namespace lang { class IndexOutOfBoundsException; }
      42             :     namespace lang { class IllegalArgumentException; }
      43             :     namespace beans { class XPropertySet; }
      44             :     namespace container { class XSet; }
      45             :     namespace container { class XNameContainer; }
      46             :     namespace frame { class XModel; }
      47             : } } }
      48             : namespace xforms
      49             : {
      50             :     class BindingCollection;
      51             :     class SubmissionCollection;
      52             :     class InstanceCollection;
      53             :     class EvaluationContext;
      54             : }
      55             : 
      56             : 
      57             : namespace xforms
      58             : {
      59             : 
      60             : /** An XForms Model. Contains:
      61             :  *  # (set of) instance data (XML DOM tree)
      62             :  *  # (set of) bindings
      63             :  *  # (set of) submissions
      64             :  *  # (NOT YET IMPLEMENTED) actions (set of)
      65             :  *
      66             :  * See http://www.w3.org/TR/xforms/ for more information.
      67             :  */
      68             : typedef cppu::ImplInheritanceHelper4<
      69             :     PropertySetBase,
      70             :     com::sun::star::xforms::XModel2,
      71             :     com::sun::star::xforms::XFormsUIHelper1,
      72             :     com::sun::star::util::XUpdatable,
      73             :     com::sun::star::lang::XUnoTunnel
      74             : > Model_t;
      75             : class Model : public Model_t
      76             : {
      77             :     // a number of local typedefs, to make the remaining header readable
      78             :     typedef com::sun::star::uno::Reference<com::sun::star::xml::dom::XDocument> XDocument_t;
      79             :     typedef com::sun::star::uno::Reference<com::sun::star::xml::dom::XNode> XNode_t;
      80             :     typedef com::sun::star::lang::IndexOutOfBoundsException IndexOutOfBoundsException_t;
      81             :     typedef com::sun::star::lang::IllegalArgumentException IllegalArgumentException_t;
      82             :     typedef com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> XPropertySet_t;
      83             :     typedef com::sun::star::uno::Reference<com::sun::star::xforms::XDataTypeRepository> XDataTypeRepository_t;
      84             :     typedef com::sun::star::uno::Reference<com::sun::star::container::XNameContainer> XNameContainer_t;
      85             :     typedef com::sun::star::uno::Reference<com::sun::star::xforms::XSubmission> XSubmission_t;
      86             :     typedef com::sun::star::uno::Reference<com::sun::star::frame::XModel> Frame_XModel_t;
      87             :     typedef com::sun::star::uno::Reference<com::sun::star::xforms::XModel> XModel_t;
      88             :     typedef com::sun::star::uno::Reference<com::sun::star::task::XInteractionHandler> XInteractionHandler_t;
      89             : 
      90             :     typedef com::sun::star::uno::Reference<com::sun::star::container::XSet> XSet_t;
      91             :     typedef com::sun::star::beans::PropertyVetoException PropertyVetoException_t;
      92             :     typedef com::sun::star::beans::UnknownPropertyException UnknownPropertyException_t;
      93             :     typedef com::sun::star::util::VetoException VetoException_t;
      94             :     typedef com::sun::star::lang::WrappedTargetException WrappedTargetException_t;
      95             :     typedef com::sun::star::uno::RuntimeException RuntimeException_t;
      96             :     typedef com::sun::star::uno::Any Any_t;
      97             :     typedef com::sun::star::uno::Sequence<sal_Int8> IntSequence_t;
      98             :     typedef std::multimap<XNode_t,std::pair<void*,MIP> > MIPs_t;
      99             : 
     100             : 
     101             : private:
     102             : 
     103             :     OUString msID;                     /// the model ID
     104             :     BindingCollection* mpBindings;          /// the bindings
     105             :     SubmissionCollection* mpSubmissions;    /// the submissions
     106             :     InstanceCollection* mpInstances;        /// the instance(s)
     107             : 
     108             :     XDataTypeRepository_t mxDataTypes;      /// the XSD data-types used
     109             :     XDocument_t mxForeignSchema;            /// the XSD-schema part we cannot
     110             :                                             /// map onto data types
     111             :     OUString msSchemaRef;              /// xforms:model/@schema attribute
     112             : 
     113             :     XNameContainer_t mxNamespaces;          /// namespaces for entire model
     114             : 
     115             : 
     116             :     // references to mpBindings/mpSubmissions, for UNO reference counting
     117             :     XSet_t mxBindings;
     118             :     XSet_t mxSubmissions;
     119             :     XSet_t mxInstances;
     120             : 
     121             :     MIPs_t maMIPs;                          /// map nodes to their MIPs
     122             : 
     123             :     bool mbInitialized;                     /// has model been initialized ?
     124             :     bool mbExternalData;                    /// is the data of this model to be considered an ingegral part of the document?
     125             : 
     126             :     void initializePropertySet();
     127             : 
     128             :     void ensureAtLeastOneInstance();
     129             : 
     130             : 
     131             : public:
     132             : 
     133             :     /// create a new model with an empty, default instance
     134             :     Model();
     135             :     virtual ~Model() throw();
     136             : 
     137             :     // get Model implementation from API object
     138             :     static Model* getModel( const com::sun::star::uno::Reference<com::sun::star::xforms::XModel>& );
     139             : 
     140             :     xforms::EvaluationContext getEvaluationContext();
     141             : 
     142             : 
     143             :     static IntSequence_t getUnoTunnelID();
     144             : 
     145             : 
     146             :     // get/set that part of the schema, that we can't interpret as data types
     147           0 :     XDocument_t getForeignSchema() const { return mxForeignSchema;}
     148             :     void setForeignSchema( const XDocument_t& );
     149             : 
     150             :     // get/set the xforms:model/@schema attribute
     151           0 :     OUString getSchemaRef() const { return msSchemaRef;}
     152             :     void setSchemaRef( const OUString& );
     153             : 
     154             :     // get/set namespaces for entire model
     155           0 :     XNameContainer_t getNamespaces() const { return mxNamespaces;}
     156             :     void setNamespaces( const XNameContainer_t& );
     157             : 
     158             :     // get/set the ExternalData property
     159           0 :     bool getExternalData() const { return mbExternalData;}
     160             :     void setExternalData( bool _bData );
     161             : 
     162             : 
     163             : #if OSL_DEBUG_LEVEL > 1
     164             :     void dbg_assertInvariant() const;
     165             : #endif
     166             : 
     167             : 
     168             : 
     169             :     // MIP (model item property) management
     170             : 
     171             : 
     172             :     // register MIPs which apply to a given node; only to be called by bindings
     173             :     // (The pTag parameter serves only to be able to remove the MIPs
     174             :     // that were added using the same tag. No functions will be
     175             :     // performed on it; hence the void* type.)
     176             :     void addMIP( void* pTag, const XNode_t&, const MIP& );
     177             :     void removeMIPs( void* pTag );
     178             : 
     179             :     /// query which MIPs appy to the given node
     180             :     MIP queryMIP( const XNode_t& xNode ) const;
     181             : 
     182             :     /// re-bind all bindings
     183             :     void rebind();
     184             : 
     185             :     /// call defer notifications on all bindings
     186             :     void deferNotifications( bool );
     187             : 
     188             :     /// set a data value in the instance
     189             :     /// (also defers notifications)
     190             :     bool setSimpleContent( const XNode_t&, const OUString& );
     191             : 
     192             :     /// load instance data
     193             :     void loadInstance( sal_Int32 nInstance );
     194             :     void loadInstances();
     195             : 
     196             :     /// has model been initialized?
     197           0 :     bool isInitialized() const { return mbInitialized;}
     198             : 
     199             :     /// is model currently valid (for submission)?
     200             :     bool isValid() const;
     201             : 
     202             : 
     203             : 
     204             : 
     205             :     // XModel
     206             :     //    implement the xforms::XModel implementation
     207             : 
     208             : 
     209             : 
     210             :     virtual OUString SAL_CALL getID()
     211             :         throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
     212             : 
     213             :     virtual void SAL_CALL setID( const OUString& sID )
     214             :         throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
     215             : 
     216             :     virtual void SAL_CALL initialize()
     217             :         throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
     218             : 
     219             :     virtual void SAL_CALL rebuild()
     220             :         throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
     221             : 
     222             :     virtual void SAL_CALL recalculate()
     223             :         throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
     224             : 
     225             :     virtual void SAL_CALL revalidate()
     226             :         throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
     227             : 
     228             :     virtual void SAL_CALL refresh()
     229             :         throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
     230             : 
     231             :     virtual void SAL_CALL submit( const OUString& sID )
     232             :         throw( VetoException_t, WrappedTargetException_t, RuntimeException_t, std::exception ) SAL_OVERRIDE;
     233             : 
     234             :     virtual void SAL_CALL submitWithInteraction( const OUString& id, const XInteractionHandler_t& _rxHandler )
     235             :         throw( VetoException_t, WrappedTargetException_t, RuntimeException_t, std::exception ) SAL_OVERRIDE;
     236             : 
     237             :     virtual XDataTypeRepository_t SAL_CALL getDataTypeRepository(  )
     238             :         throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
     239             : 
     240             : 
     241             :     // XModel: instance management
     242             : 
     243             :     virtual XSet_t SAL_CALL getInstances()
     244             :         throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
     245             : 
     246             :     virtual XDocument_t SAL_CALL getInstanceDocument( const OUString& )
     247             :         throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
     248             : 
     249             :     virtual XDocument_t SAL_CALL getDefaultInstance()
     250             :         throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
     251             : 
     252             : 
     253             : 
     254             :     // XModel: binding management
     255             : 
     256             :     virtual XPropertySet_t SAL_CALL createBinding()
     257             :         throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
     258             : 
     259             :     virtual XPropertySet_t SAL_CALL cloneBinding( const XPropertySet_t& )
     260             :         throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
     261             : 
     262             :     virtual XPropertySet_t SAL_CALL getBinding( const OUString& )
     263             :         throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
     264             : 
     265             :     virtual XSet_t SAL_CALL getBindings()
     266             :         throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
     267             : 
     268             : 
     269             :     // XModel: submission management
     270             : 
     271             :     virtual XSubmission_t SAL_CALL createSubmission()
     272             :         throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
     273             : 
     274             :     virtual XSubmission_t SAL_CALL cloneSubmission( const XPropertySet_t& )
     275             :         throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
     276             : 
     277             :     virtual XSubmission_t SAL_CALL getSubmission( const OUString& )
     278             :         throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
     279             : 
     280             :     virtual XSet_t SAL_CALL getSubmissions()
     281             :         throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
     282             : 
     283             :     // XPropertySet
     284             : 
     285           0 :     virtual css::uno::Any SAL_CALL getPropertyValue(const OUString& p)
     286             :         throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE
     287           0 :         { return PropertySetBase::getPropertyValue(p); }
     288             : 
     289           0 :     virtual void SAL_CALL addPropertyChangeListener(const OUString& p1, const css::uno::Reference<css::beans::XPropertyChangeListener>& p2)
     290             :         throw (css::beans::UnknownPropertyException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE
     291           0 :         { PropertySetBase::addPropertyChangeListener(p1, p2); }
     292             : 
     293           0 :     virtual void SAL_CALL removePropertyChangeListener(const OUString& p1, const css::uno::Reference<css::beans::XPropertyChangeListener>& p2)
     294             :         throw (css::beans::UnknownPropertyException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE
     295           0 :         { PropertySetBase::removePropertyChangeListener(p1, p2); }
     296             : 
     297           0 :     virtual void SAL_CALL addVetoableChangeListener(const OUString& p1, const css::uno::Reference<css::beans::XVetoableChangeListener>& p2)
     298             :         throw (css::beans::UnknownPropertyException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE
     299           0 :         { PropertySetBase::addVetoableChangeListener(p1, p2); }
     300             : 
     301           0 :     virtual void SAL_CALL removeVetoableChangeListener(const OUString& p1, const css::uno::Reference<css::beans::XVetoableChangeListener>& p2)
     302             :         throw( css::beans::UnknownPropertyException,  css::uno::RuntimeException, std::exception ) SAL_OVERRIDE
     303           0 :         { PropertySetBase::removeVetoableChangeListener(p1, p2); }
     304             : 
     305           0 :     virtual css::uno::Reference<css::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo()
     306             :         throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE
     307           0 :         { return PropertySetBase::getPropertySetInfo(); }
     308             : 
     309           0 :    virtual void SAL_CALL setPropertyValue(const OUString& p1, const com::sun::star::uno::Any& p2)
     310             :         throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE
     311           0 :         { PropertySetBase::setPropertyValue(p1, p2); }
     312             : 
     313             : 
     314             :     // XFormsUIHelper1 & friends:
     315             :     //   (implementation in model_ui.cxx)
     316             : 
     317             : 
     318             :     /// determine a reasonable control service for a given node
     319             :     /// (based on data type MIP assigned to the node)
     320             :     virtual OUString SAL_CALL getDefaultServiceNameForNode( const XNode_t& xNode ) throw (RuntimeException_t, std::exception) SAL_OVERRIDE;
     321             : 
     322             :     /// call getDefaultBindingExpressionForNode with default evaluation context
     323             :     virtual OUString SAL_CALL getDefaultBindingExpressionForNode( const XNode_t& xNode ) throw (RuntimeException_t, std::exception) SAL_OVERRIDE;
     324             : 
     325             :     /// determine a reasonable default binding expression for a given node
     326             :     /// and a given evaluation context
     327             :     /// @returns expression, or empty string if no expression could be derived
     328             :     OUString getDefaultBindingExpressionForNode(
     329             :         const XNode_t&,
     330             :         const EvaluationContext& );
     331             : 
     332             :     virtual OUString SAL_CALL getNodeDisplayName( const XNode_t&,
     333             :                                                        sal_Bool bDetail )
     334             :         throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
     335             : 
     336             :     virtual OUString SAL_CALL getNodeName( const XNode_t& )
     337             :         throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
     338             : 
     339             :     virtual OUString SAL_CALL getBindingName( const XPropertySet_t&,
     340             :                                                    sal_Bool bDetail )
     341             :         throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
     342             : 
     343             :     virtual OUString SAL_CALL getSubmissionName( const XPropertySet_t&,
     344             :                                                       sal_Bool bDetail )
     345             :         throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
     346             : 
     347             :     virtual XPropertySet_t SAL_CALL cloneBindingAsGhost( const XPropertySet_t& )
     348             :         throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
     349             : 
     350             :     virtual void SAL_CALL removeBindingIfUseless( const XPropertySet_t& )
     351             :         throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
     352             : 
     353             :     virtual XDocument_t SAL_CALL newInstance( const OUString& sName,
     354             :                                               const OUString& sURL,
     355             :                                               sal_Bool bURLOnce )
     356             :         throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
     357             : 
     358             :     virtual void SAL_CALL renameInstance( const OUString& sFrom,
     359             :                                           const OUString& sTo,
     360             :                                           const OUString& sURL,
     361             :                                           sal_Bool bURLOnce )
     362             :         throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
     363             : 
     364             :     virtual void SAL_CALL removeInstance( const OUString& sName )
     365             :         throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
     366             : 
     367             : 
     368             :     virtual XModel_t SAL_CALL newModel( const Frame_XModel_t& xComponent,
     369             :                                         const OUString& sName )
     370             :         throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
     371             :     virtual void SAL_CALL renameModel( const Frame_XModel_t& xComponent,
     372             :                                        const OUString& sFrom,
     373             :                                        const OUString& sTo )
     374             :         throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
     375             : 
     376             :     virtual void SAL_CALL removeModel( const Frame_XModel_t& xComponent,
     377             :                                        const OUString& sName )
     378             :         throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
     379             : 
     380             : 
     381             :     virtual XNode_t SAL_CALL createElement( const XNode_t& xParent,
     382             :                                             const OUString& sName )
     383             :         throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
     384             : 
     385             :     virtual XNode_t SAL_CALL createAttribute( const XNode_t& xParent,
     386             :                                               const OUString& sName )
     387             :         throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
     388             : 
     389             :     virtual XNode_t SAL_CALL renameNode( const XNode_t& xNode,
     390             :                                          const OUString& sName )
     391             :         throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
     392             : 
     393             :     virtual XPropertySet_t SAL_CALL getBindingForNode( const XNode_t&,
     394             :                                                        sal_Bool bCreate )
     395             :         throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
     396             : 
     397             :     virtual void SAL_CALL removeBindingForNode( const XNode_t& )
     398             :         throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
     399             : 
     400             :     virtual OUString SAL_CALL getResultForExpression(
     401             :         const XPropertySet_t& xBinding,
     402             :         sal_Bool bIsBindingExpression,
     403             :         const OUString& sExpression )
     404             :         throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
     405             : 
     406             :     virtual sal_Bool SAL_CALL isValidXMLName( const OUString& sName )
     407             :         throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
     408             : 
     409             :     virtual sal_Bool SAL_CALL isValidPrefixName( const OUString& sName )
     410             :         throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
     411             : 
     412             :     virtual void SAL_CALL setNodeValue(
     413             :         const XNode_t& xNode,
     414             :         const OUString& sValue )
     415             :         throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
     416             : 
     417             : 
     418             : 
     419             :     // XUpdatable
     420             : 
     421             : 
     422             : public:
     423             :     virtual void SAL_CALL update()
     424             :         throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
     425             : 
     426             : 
     427             :     // XUnoTunnel
     428             : 
     429             : 
     430             : public:
     431             :     virtual sal_Int64 SAL_CALL getSomething( const IntSequence_t& )
     432             :         throw( RuntimeException_t, std::exception ) SAL_OVERRIDE;
     433             : 
     434             : 
     435             :     // XTypeProvider::getImplementationId
     436             : 
     437             : 
     438             : public:
     439             :     virtual IntSequence_t SAL_CALL getImplementationId()
     440             :         throw( RuntimeException_t ) SAL_OVERRIDE;
     441             : 
     442             : };
     443             : 
     444             : } // namespace
     445             : #endif
     446             : 
     447             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10