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

Generated by: LCOV version 1.11