LCOV - code coverage report
Current view: top level - forms/source/xforms - model.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 242 0.0 %
Date: 2014-04-14 Functions: 0 51 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             : 
      21             : #include "model.hxx"
      22             : 
      23             : #include "model_helper.hxx"
      24             : #include "unohelper.hxx"
      25             : #include "binding.hxx"
      26             : #include "submission.hxx"
      27             : #include "mip.hxx"
      28             : #include "evaluationcontext.hxx"
      29             : #include "xmlhelper.hxx"
      30             : #include "datatyperepository.hxx"
      31             : #include "NameContainer.hxx"
      32             : 
      33             : #include <rtl/ustring.hxx>
      34             : #include <rtl/ustrbuf.hxx>
      35             : #include <tools/debug.hxx>
      36             : 
      37             : #include <comphelper/propertysetinfo.hxx>
      38             : #include <comphelper/processfactory.hxx>
      39             : #include <cppuhelper/typeprovider.hxx>
      40             : 
      41             : #include <algorithm>
      42             : 
      43             : // UNO classes
      44             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      45             : #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
      46             : #include <com/sun/star/lang/IllegalArgumentException.hpp>
      47             : #include <com/sun/star/xml/dom/XDocument.hpp>
      48             : #include <com/sun/star/xml/dom/XCharacterData.hpp>
      49             : #include <com/sun/star/xml/dom/NodeType.hpp>
      50             : #include <com/sun/star/xml/dom/XDocumentBuilder.hpp>
      51             : #include <com/sun/star/uno/Sequence.hxx>
      52             : #include <com/sun/star/beans/PropertyValue.hpp>
      53             : #include <com/sun/star/ucb/SimpleFileAccess.hpp>
      54             : #include <com/sun/star/io/XInputStream.hpp>
      55             : 
      56             : 
      57             : using com::sun::star::lang::XMultiServiceFactory;
      58             : using com::sun::star::lang::XUnoTunnel;
      59             : using com::sun::star::beans::XPropertySet;
      60             : using com::sun::star::beans::PropertyValue;
      61             : using com::sun::star::beans::PropertyVetoException;
      62             : using com::sun::star::beans::UnknownPropertyException;
      63             : using com::sun::star::util::VetoException;
      64             : using com::sun::star::lang::WrappedTargetException;
      65             : using com::sun::star::lang::IllegalArgumentException;
      66             : using com::sun::star::ucb::XSimpleFileAccess3;
      67             : using com::sun::star::ucb::SimpleFileAccess;
      68             : using com::sun::star::io::XInputStream;
      69             : 
      70             : using namespace com::sun::star::uno;
      71             : using namespace com::sun::star::xml::dom;
      72             : using namespace xforms;
      73             : 
      74             : 
      75             : #if OSL_DEBUG_LEVEL > 1
      76             : #define DBG_INVARIANT_TYPE(TYPE) class DBG_##TYPE { const TYPE* mpT; void check() { mpT->dbg_assertInvariant(); } public: DBG_##TYPE(const TYPE* pT) : mpT(pT) { check(); } ~DBG_##TYPE() { check(); } } _DBG_##TYPE(this);
      77             : 
      78             : #define DBG_INVARIANT() DBG_INVARIANT_TYPE(Model)
      79             : #else
      80             : #define DBG_INVARIANT()
      81             : #endif
      82             : 
      83             : 
      84             : 
      85             : 
      86             : // The Model
      87             : 
      88             : 
      89           0 : void Model::ensureAtLeastOneInstance()
      90             : {
      91           0 :     if( ! mpInstances->hasItems() )
      92             :     {
      93             :         // create a default instance
      94           0 :         newInstance( OUString(), OUString(), true );
      95             :     }
      96           0 : }
      97             : 
      98             : 
      99             : 
     100             : /** Model default constructor; create empty model */
     101           0 : Model::Model() :
     102             :     msID(),
     103             :     mpBindings( NULL ),
     104             :     mpSubmissions( NULL ),
     105           0 :     mpInstances( new InstanceCollection ),
     106           0 :     mxNamespaces( new NameContainer<OUString>() ),
     107             :     mxBindings( mpBindings ),
     108             :     mxSubmissions( mpSubmissions ),
     109             :     mxInstances( mpInstances ),
     110             :     mbInitialized( false ),
     111           0 :     mbExternalData( true )
     112             : {
     113           0 :     initializePropertySet();
     114             : 
     115             :     // initialize bindings collections
     116             :     // (not in initializer list to avoid use of incomplete 'this')
     117           0 :     mpBindings = new BindingCollection( this );
     118           0 :     mxBindings = mpBindings;
     119             : 
     120           0 :     mpSubmissions = new SubmissionCollection( this );
     121           0 :     mxSubmissions = mpSubmissions;
     122             : 
     123             :     // invariant only holds after construction
     124             :     DBG_INVARIANT();
     125           0 : }
     126             : 
     127           0 : Model::~Model() throw()
     128             : {
     129             :     // give up bindings & submissions; the mxBindings/mxSubmissions
     130             :     // references will then delete them
     131           0 :     mpBindings = NULL;
     132           0 :     mpSubmissions = NULL;
     133           0 : }
     134             : 
     135           0 : static Model* lcl_getModel( const Reference<XUnoTunnel>& xTunnel )
     136             : {
     137           0 :     Model* pModel = NULL;
     138           0 :     if( xTunnel.is() )
     139             :         pModel = reinterpret_cast<Model*>(
     140           0 :             xTunnel->getSomething( Model::getUnoTunnelID() ) );
     141           0 :     return pModel;
     142             : }
     143             : 
     144           0 : Model* Model::getModel( const Reference<XModel>& xModel )
     145             : {
     146           0 :     return lcl_getModel( Reference<XUnoTunnel>( xModel, UNO_QUERY ) );
     147             : }
     148             : 
     149           0 : EvaluationContext Model::getEvaluationContext()
     150             : {
     151             :     // the default context is the top-level element node. A default
     152             :     // node (instanceData' is inserted when there is no default node
     153           0 :     Reference<XDocument> xInstance = getDefaultInstance();
     154           0 :     Reference<XNode> xElement( xInstance->getDocumentElement(), UNO_QUERY );
     155             : 
     156             :     // no element found? Then insert default element 'instanceData'
     157           0 :     if( ! xElement.is() )
     158             :     {
     159           0 :         xElement = Reference<XNode>(
     160           0 :                        xInstance->createElement( "instanceData" ),
     161           0 :                        UNO_QUERY_THROW );
     162           0 :         xInstance->appendChild( xElement );
     163             :     }
     164             : 
     165             :     OSL_ENSURE( xElement.is() &&
     166             :                 xElement->getNodeType() == NodeType_ELEMENT_NODE,
     167             :                 "no element in evaluation context" );
     168             : 
     169           0 :     return EvaluationContext( xElement, this, mxNamespaces, 0, 1 );
     170             : }
     171             : 
     172             : 
     173           0 : Model::IntSequence_t Model::getUnoTunnelID()
     174             : {
     175           0 :     static cppu::OImplementationId aImplementationId;
     176           0 :     return aImplementationId.getImplementationId();
     177             : }
     178             : 
     179           0 : Model::XDocument_t Model::getForeignSchema() const
     180             : {
     181           0 :     return mxForeignSchema;
     182             : }
     183             : 
     184           0 : void Model::setForeignSchema( const XDocument_t& rDocument )
     185             : {
     186           0 :     mxForeignSchema = rDocument;
     187           0 : }
     188             : 
     189           0 : OUString Model::getSchemaRef() const
     190             : {
     191           0 :     return msSchemaRef;
     192             : }
     193             : 
     194           0 : void Model::setSchemaRef( const OUString& rSchemaRef )
     195             : {
     196           0 :     msSchemaRef = rSchemaRef;
     197           0 : }
     198             : 
     199           0 : Model::XNameContainer_t Model::getNamespaces() const
     200             : {
     201           0 :     return mxNamespaces;
     202             : }
     203             : 
     204           0 : void Model::setNamespaces( const XNameContainer_t& rNamespaces )
     205             : {
     206           0 :     if( rNamespaces.is() )
     207           0 :         mxNamespaces = rNamespaces;
     208           0 : }
     209             : 
     210           0 : bool Model::getExternalData() const
     211             : {
     212           0 :     return mbExternalData;
     213             : }
     214             : 
     215           0 : void Model::setExternalData( bool _bData )
     216             : {
     217           0 :     mbExternalData = _bData;
     218           0 : }
     219             : 
     220             : #if OSL_DEBUG_LEVEL > 1
     221             : void Model::dbg_assertInvariant() const
     222             : {
     223             :     OSL_ENSURE( mpInstances != NULL, "no instances found" );
     224             :     OSL_ENSURE( mxInstances.is(), "No instance container!" );
     225             : 
     226             :     OSL_ENSURE( mpBindings != NULL, "no bindings element" );
     227             :     OSL_ENSURE( mxBindings.is(), "No Bindings container" );
     228             : 
     229             :     OSL_ENSURE( mpSubmissions != NULL, "no submissions element" );
     230             :     OSL_ENSURE( mxSubmissions.is(), "No Submission container" );
     231             : }
     232             : #endif
     233             : 
     234             : 
     235             : 
     236             : // MIP management
     237             : 
     238             : 
     239           0 : void Model::addMIP( void* pTag, const XNode_t& xNode, const MIP& rMIP )
     240             : {
     241             :     OSL_ENSURE( pTag != NULL, "empty tag?" );
     242             :     OSL_ENSURE( xNode.is(), "no node" );
     243             : 
     244           0 :     MIPs_t::value_type aValue( xNode, ::std::pair<void*,MIP>( pTag, rMIP ) );
     245           0 :     maMIPs.insert( aValue );
     246           0 : }
     247             : 
     248           0 : void Model::removeMIPs( void* pTag )
     249             : {
     250             :     OSL_ENSURE( pTag != NULL, "empty tag?" );
     251             : 
     252           0 :     for( MIPs_t::iterator aIter = maMIPs.begin();
     253           0 :          aIter != maMIPs.end(); )
     254             :     {
     255           0 :         if( aIter->second.first == pTag )
     256             :         {
     257           0 :             MIPs_t::iterator next( aIter ); ++next;
     258           0 :             maMIPs.erase( aIter );
     259           0 :             aIter = next;
     260             :         }
     261             :         else
     262           0 :             ++aIter;
     263             :     }
     264           0 : }
     265             : 
     266           0 : MIP Model::queryMIP( const XNode_t& xNode ) const
     267             : {
     268             :     // travel up inheritance chain and inherit MIPs
     269           0 :     MIP aRet;
     270           0 :     for( XNode_t xCurrent = xNode;
     271             :          xCurrent.is();
     272           0 :          xCurrent = xCurrent->getParentNode() )
     273             :     {
     274             :         // iterate over all MIPs for this node, and join MIPs
     275           0 :         MIP aMIP;
     276           0 :         MIPs_t::const_iterator aEnd = maMIPs.upper_bound( xCurrent );
     277           0 :         MIPs_t::const_iterator aIter = maMIPs.lower_bound( xCurrent );
     278           0 :         for( ; aIter != aEnd; ++aIter )
     279           0 :           aMIP.join( aIter->second.second );
     280             : 
     281             :         // inherit from current node (or set if we are at the start node)
     282           0 :         if( xCurrent == xNode )
     283           0 :             aRet = aMIP;
     284             :         else
     285           0 :             aRet.inherit( aMIP );
     286           0 :     }
     287             : 
     288           0 :     return aRet;
     289             : }
     290             : 
     291             : 
     292             : 
     293           0 : void Model::rebind()
     294             : {
     295             :     OSL_ENSURE( mpBindings != NULL, "bindings?" );
     296             : 
     297             :     // iterate over all bindings and call update
     298           0 :     sal_Int32 nCount = mpBindings->countItems();
     299           0 :     for( sal_Int32 i = 0; i < nCount; i++ )
     300             :     {
     301           0 :         Binding* pBind = Binding::getBinding( mpBindings->Collection<XPropertySet_t>::getItem( i ) );
     302             :         OSL_ENSURE( pBind != NULL, "binding?" );
     303           0 :         pBind->update();
     304             :     }
     305           0 : }
     306             : 
     307             : 
     308             : 
     309           0 : void Model::deferNotifications( bool bDefer )
     310             : {
     311             :     // iterate over all bindings and defer notifications
     312           0 :     sal_Int32 nCount = mpBindings->countItems();
     313           0 :     for( sal_Int32 i = 0; i < nCount; i++ )
     314             :     {
     315           0 :         Binding* pBind = Binding::getBinding( mpBindings->Collection<XPropertySet_t>::getItem( i ) );
     316             :         OSL_ENSURE( pBind != NULL, "binding?" );
     317           0 :         pBind->deferNotifications( bDefer );
     318             :     }
     319           0 : }
     320             : 
     321             : 
     322           0 : bool Model::setSimpleContent( const XNode_t& xConstNode,
     323             :                               const OUString& sValue )
     324             : {
     325             :     OSL_ENSURE( xConstNode.is(), "need node to set data" );
     326             : 
     327           0 :     bool bRet = false;
     328           0 :     if( xConstNode.is() )
     329             :     {
     330             :         // non-const node reference so we can assign children (if necessary)
     331           0 :         XNode_t xNode( xConstNode );
     332             : 
     333           0 :         switch( xNode->getNodeType() )
     334             :         {
     335             :         case NodeType_ELEMENT_NODE:
     336             :         {
     337             :             // find first text node child
     338           0 :             Reference<XNode> xChild;
     339           0 :             for( xChild = xNode->getFirstChild();
     340           0 :                  xChild.is() && xChild->getNodeType() != NodeType_TEXT_NODE;
     341           0 :                  xChild = xChild->getNextSibling() )
     342             :                 ; // empty loop; only find first text node child
     343             : 
     344             :             // create text node, if none is found
     345           0 :             if( ! xChild.is() )
     346             :             {
     347           0 :                 xChild = Reference<XNode>(
     348           0 :                     xNode->getOwnerDocument()->createTextNode( OUString() ),
     349           0 :                     UNO_QUERY_THROW );
     350           0 :                 xNode->appendChild( xChild );
     351             :             }
     352           0 :             xNode = xChild;
     353             : 
     354             :             OSL_ENSURE( xNode.is() &&
     355             :                         xNode->getNodeType() == NodeType_TEXT_NODE,
     356           0 :                         "text node creation failed?" );
     357             :         }
     358             :         // no break; continue as with text node:
     359             : 
     360             :         case NodeType_TEXT_NODE:
     361             :         case NodeType_ATTRIBUTE_NODE:
     362             :         {
     363             :             // set the node value (defer notifications)
     364           0 :             if( xNode->getNodeValue() != sValue )
     365             :             {
     366           0 :                 deferNotifications( true );
     367           0 :                 xNode->setNodeValue( sValue );
     368           0 :                 deferNotifications( false );
     369             :             }
     370           0 :             bRet = true;
     371             :         }
     372           0 :         break;
     373             : 
     374             :         default:
     375             :         {
     376             :             OSL_FAIL( "bound to unknown node type?" );
     377             :         }
     378           0 :         break;
     379             : 
     380           0 :         }
     381             :     }
     382           0 :     return bRet;
     383             : }
     384             : 
     385           0 : void Model::loadInstance( sal_Int32 nInstance )
     386             : {
     387           0 :     Sequence<PropertyValue> aSequence = mpInstances->getItem( nInstance );
     388             : 
     389             :     // find URL from instance
     390           0 :     OUString sURL;
     391           0 :     bool bOnce = false;
     392           0 :     getInstanceData( aSequence, NULL, NULL, &sURL, &bOnce );
     393             : 
     394             :     // if we have a URL, load the document and set it into the instance
     395           0 :     if( !sURL.isEmpty() )
     396             :     {
     397             :         try
     398             :         {
     399             :             Reference<XInputStream> xInput =
     400           0 :                 Reference<XSimpleFileAccess3>( SimpleFileAccess::create( ::comphelper::getProcessComponentContext() ) )->openFileRead( sURL );
     401           0 :             if( xInput.is() )
     402             :             {
     403             :                 Reference<XDocument> xInstance =
     404           0 :                     getDocumentBuilder()->parse( xInput );
     405           0 :                 if( xInstance.is() )
     406             :                 {
     407           0 :                     OUString sEmpty;
     408             :                     setInstanceData( aSequence, NULL, &xInstance,
     409           0 :                                      bOnce ? &sEmpty : &sURL, NULL);
     410           0 :                     mpInstances->setItem( nInstance, aSequence );
     411           0 :                 }
     412           0 :             }
     413             :         }
     414           0 :         catch( const Exception& )
     415             :         {
     416             :             // couldn't load the instance -> ignore!
     417             :         }
     418           0 :     }
     419           0 : }
     420             : 
     421           0 : void Model::loadInstances()
     422             : {
     423             :     // iterate over instance array to get PropertyValue-Sequence
     424           0 :     const sal_Int32 nInstances = mpInstances->countItems();
     425           0 :     for( sal_Int32 nInstance = 0; nInstance < nInstances; nInstance++ )
     426             :     {
     427           0 :         loadInstance( nInstance );
     428             :     }
     429           0 : }
     430             : 
     431           0 : bool Model::isInitialized() const
     432             : {
     433           0 :     return mbInitialized;
     434             : }
     435             : 
     436           0 : bool Model::isValid() const
     437             : {
     438           0 :     bool bValid = true;
     439           0 :     sal_Int32 nCount = mpBindings->countItems();
     440           0 :     for( sal_Int32 i = 0; bValid && i < nCount; i++ )
     441             :     {
     442           0 :         Binding* pBind = Binding::getBinding( mpBindings->Collection<XPropertySet_t>::getItem( i ) );
     443             :         OSL_ENSURE( pBind != NULL, "binding?" );
     444           0 :         bValid = pBind->isValid();
     445             :     }
     446           0 :     return bValid;
     447             : }
     448             : 
     449             : 
     450             : 
     451             : 
     452             : // implement xforms::XModel
     453             : 
     454             : 
     455           0 : OUString Model::getID()
     456             :     throw( RuntimeException, std::exception )
     457             : {
     458             :     DBG_INVARIANT();
     459           0 :     return msID;
     460             : }
     461             : 
     462           0 : void Model::setID( const OUString& sID )
     463             :     throw( RuntimeException, std::exception )
     464             : {
     465             :     DBG_INVARIANT();
     466           0 :     msID = sID;
     467           0 : }
     468             : 
     469           0 : void Model::initialize()
     470             :     throw( RuntimeException, std::exception )
     471             : {
     472             :     DBG_ASSERT( ! mbInitialized, "model already initialized" );
     473             : 
     474             :     // load instances
     475           0 :     loadInstances();
     476             : 
     477             :     // let's pretend we're initialized and rebind all bindings
     478           0 :     mbInitialized = true;
     479           0 :     rebind();
     480           0 : }
     481             : 
     482           0 : void Model::rebuild()
     483             :     throw( RuntimeException, std::exception )
     484             : {
     485           0 :     if( ! mbInitialized )
     486           0 :         initialize();
     487             :     else
     488           0 :         rebind();
     489           0 : }
     490             : 
     491           0 : void Model::recalculate()
     492             :     throw( RuntimeException, std::exception )
     493             : {
     494           0 :     rebind();
     495           0 : }
     496             : 
     497           0 : void Model::revalidate()
     498             :     throw( RuntimeException, std::exception )
     499             : {
     500             :     // do nothing. We don't validate anyways!
     501           0 : }
     502             : 
     503           0 : void Model::refresh()
     504             :     throw( RuntimeException, std::exception )
     505             : {
     506           0 :     rebind();
     507           0 : }
     508             : 
     509             : 
     510           0 : void SAL_CALL Model::submitWithInteraction(
     511             :     const OUString& sID,
     512             :     const XInteractionHandler_t& _rxHandler )
     513             :     throw( VetoException,
     514             :            WrappedTargetException,
     515             :            RuntimeException, std::exception )
     516             : {
     517             :     DBG_INVARIANT();
     518             : 
     519           0 :     if( mpSubmissions->hasItem( sID ) )
     520             :     {
     521             :         Submission* pSubmission =
     522           0 :             Submission::getSubmission( mpSubmissions->getItem( sID ) );
     523             :         OSL_ENSURE( pSubmission != NULL, "no submission?" );
     524             :         OSL_ENSURE( pSubmission->getModel() == Reference<XModel>( this ),
     525             :                     "wrong model" );
     526             : 
     527             :         // submit. All exceptions are allowed to leave.
     528           0 :         pSubmission->submitWithInteraction( _rxHandler );
     529             :     }
     530           0 : }
     531             : 
     532           0 : void Model::submit( const OUString& sID )
     533             :     throw( VetoException, WrappedTargetException, RuntimeException, std::exception )
     534             : {
     535           0 :     submitWithInteraction( sID, NULL );
     536           0 : }
     537             : 
     538           0 : Model::XDataTypeRepository_t SAL_CALL Model::getDataTypeRepository(  )
     539             :     throw( RuntimeException, std::exception )
     540             : {
     541           0 :     if ( !mxDataTypes.is() )
     542           0 :         mxDataTypes = new ODataTypeRepository;
     543             : 
     544           0 :     return mxDataTypes;
     545             : }
     546             : 
     547             : 
     548             : // instance management
     549             : 
     550             : 
     551           0 : Model::XSet_t Model::getInstances()
     552             :     throw( RuntimeException, std::exception )
     553             : {
     554           0 :     return mxInstances;
     555             : }
     556             : 
     557           0 : Model::XDocument_t Model::getInstanceDocument( const OUString& rName )
     558             :     throw( RuntimeException, std::exception )
     559             : {
     560           0 :     ensureAtLeastOneInstance();
     561           0 :     Reference<XDocument> aInstance;
     562           0 :     sal_Int32 nInstance = lcl_findInstance( mpInstances, rName );
     563           0 :     if( nInstance != -1 )
     564           0 :         getInstanceData( mpInstances->getItem( nInstance ),
     565           0 :                          NULL, &aInstance, NULL, NULL );
     566           0 :     return aInstance;
     567             : }
     568             : 
     569           0 : Model::XDocument_t SAL_CALL Model::getDefaultInstance()
     570             :     throw( RuntimeException, std::exception )
     571             : {
     572           0 :     ensureAtLeastOneInstance();
     573             :     DBG_ASSERT( mpInstances->countItems() > 0, "no instance?" );
     574           0 :     Reference<XDocument> aInstance;
     575           0 :     getInstanceData( mpInstances->getItem( 0 ), NULL, &aInstance, NULL, NULL );
     576           0 :     return aInstance;
     577             : }
     578             : 
     579             : 
     580             : 
     581             : 
     582             : // bindings management
     583             : 
     584             : 
     585           0 : Model::XPropertySet_t SAL_CALL Model::createBinding()
     586             :     throw( RuntimeException, std::exception )
     587             : {
     588             :     DBG_INVARIANT();
     589           0 :     return new Binding();
     590             : }
     591             : 
     592           0 : Model::XPropertySet_t Model::cloneBinding( const XPropertySet_t& xBinding )
     593             :     throw( RuntimeException, std::exception )
     594             : {
     595             :     DBG_INVARIANT();
     596           0 :     XPropertySet_t xNewBinding = createBinding();
     597           0 :     copy( xBinding, xNewBinding );
     598           0 :     return xNewBinding;
     599             : }
     600             : 
     601           0 : Model::XPropertySet_t Model::getBinding( const OUString& sId )
     602             :     throw( RuntimeException, std::exception )
     603             : {
     604             :     DBG_INVARIANT();
     605           0 :     return mpBindings->hasItem( sId ) ? mpBindings->getItem( sId ) : NULL;
     606             : }
     607             : 
     608           0 : Model::XSet_t Model::getBindings()
     609             :     throw( RuntimeException, std::exception )
     610             : {
     611             :     DBG_INVARIANT();
     612           0 :     return mxBindings;
     613             : }
     614             : 
     615             : 
     616             : 
     617             : 
     618             : // submission management
     619             : 
     620             : 
     621           0 : Model::XSubmission_t Model::createSubmission()
     622             :     throw( RuntimeException, std::exception )
     623             : {
     624             :     DBG_INVARIANT();
     625           0 :     return new Submission();
     626             : }
     627             : 
     628           0 : Model::XSubmission_t Model::cloneSubmission(const XPropertySet_t& xSubmission)
     629             :     throw( RuntimeException, std::exception )
     630             : {
     631             :     DBG_INVARIANT();
     632           0 :     XSubmission_t xNewSubmission = createSubmission();
     633           0 :     XPropertySet_t xAsPropertySet( xNewSubmission.get() );
     634           0 :     copy( xSubmission.get(), xAsPropertySet );
     635           0 :     return xNewSubmission;
     636             : }
     637             : 
     638           0 : Model::XSubmission_t Model::getSubmission( const OUString& sId )
     639             :     throw( RuntimeException, std::exception )
     640             : {
     641             :     DBG_INVARIANT();
     642           0 :     XSubmission_t xSubmission;
     643           0 :     if ( mpSubmissions->hasItem( sId ) )
     644           0 :         xSubmission = xSubmission.query( mpSubmissions->getItem( sId ) );
     645           0 :     return xSubmission;
     646             : }
     647             : 
     648           0 : Model::XSet_t Model::getSubmissions()
     649             :     throw( RuntimeException, std::exception )
     650             : {
     651             :     DBG_INVARIANT();
     652           0 :     return mxSubmissions;
     653             : }
     654             : 
     655             : 
     656             : // implement XPropertySet & friends
     657             : 
     658             : 
     659             : #define HANDLE_ID 0
     660             : #define HANDLE_ForeignSchema 3
     661             : #define HANDLE_SchemaRef 4
     662             : #define HANDLE_Namespaces 5
     663             : #define HANDLE_ExternalData 6
     664             : 
     665             : #define REGISTER_PROPERTY( property, type )   \
     666             :     registerProperty( PROPERTY( property, type ), \
     667             :     new DirectPropertyAccessor< Model, type >( this, &Model::set##property, &Model::get##property ) );
     668             : 
     669             : #define REGISTER_PROPERTY_API( property, type )   \
     670             :     registerProperty( PROPERTY( property, type ), \
     671             :     new APIPropertyAccessor< Model, type >( this, &Model::set##property, &Model::get##property ) );
     672             : 
     673             : #define REGISTER_BOOL_PROPERTY( property )   \
     674             :     registerProperty( PROPERTY( property, sal_Bool ), \
     675             :     new BooleanPropertyAccessor< Model, bool >( this, &Model::set##property, &Model::get##property ) );
     676             : 
     677           0 : void Model::initializePropertySet()
     678             : {
     679           0 :     REGISTER_PROPERTY_API ( ID,            OUString );
     680           0 :     REGISTER_PROPERTY     ( ForeignSchema, XDocument_t );
     681           0 :     REGISTER_PROPERTY     ( SchemaRef,     OUString );
     682           0 :     REGISTER_PROPERTY     ( Namespaces,    XNameContainer_t );
     683           0 :     REGISTER_BOOL_PROPERTY( ExternalData );
     684           0 : }
     685             : 
     686           0 : void Model::update()
     687             :     throw( RuntimeException, std::exception )
     688             : {
     689           0 :     rebuild();
     690           0 : }
     691             : 
     692             : 
     693           0 : sal_Int64 Model::getSomething( const IntSequence_t& xId )
     694             :     throw( RuntimeException, std::exception )
     695             : {
     696           0 :     return reinterpret_cast<sal_Int64>( ( xId == getUnoTunnelID() ) ? this : NULL );
     697             : }
     698             : 
     699           0 : Sequence<sal_Int8> Model::getImplementationId()
     700             :     throw( RuntimeException )
     701             : {
     702           0 :     return css::uno::Sequence<sal_Int8>();
     703             : }
     704             : 
     705             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10