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

Generated by: LCOV version 1.10