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

Generated by: LCOV version 1.10