LCOV - code coverage report
Current view: top level - dbaccess/source/core/dataaccess - documentcontainer.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 15 393 3.8 %
Date: 2012-08-25 Functions: 9 45 20.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 21 987 2.1 %

           Branch data     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 "documentcontainer.hxx"
      22                 :            : #include "dbastrings.hrc"
      23                 :            : #include "documentdefinition.hxx"
      24                 :            : #include <com/sun/star/ucb/OpenCommandArgument2.hpp>
      25                 :            : #include <com/sun/star/ucb/OpenMode.hpp>
      26                 :            : #include <tools/debug.hxx>
      27                 :            : #include <connectivity/dbtools.hxx>
      28                 :            : #include "myucp_resultset.hxx"
      29                 :            : #include <ucbhelper/cancelcommandexecution.hxx>
      30                 :            : #include <com/sun/star/ucb/UnsupportedOpenModeException.hpp>
      31                 :            : #include <com/sun/star/ucb/InsertCommandArgument.hpp>
      32                 :            : #include <com/sun/star/beans/PropertyAttribute.hpp>
      33                 :            : #include <com/sun/star/sdb/ErrorCondition.hpp>
      34                 :            : #include "datasource.hxx"
      35                 :            : #include <comphelper/classids.hxx>
      36                 :            : #include <comphelper/mimeconfighelper.hxx>
      37                 :            : #include <connectivity/sqlerror.hxx>
      38                 :            : #include "core_resource.hxx"
      39                 :            : #include "core_resource.hrc"
      40                 :            : #include <comphelper/namedvaluecollection.hxx>
      41                 :            : 
      42                 :            : #include <vcl/svapp.hxx>
      43                 :            : #include <osl/mutex.hxx>
      44                 :            : 
      45                 :            : using namespace ::com::sun::star::uno;
      46                 :            : using namespace ::com::sun::star::lang;
      47                 :            : using namespace ::com::sun::star::embed;
      48                 :            : using namespace ::com::sun::star::beans;
      49                 :            : using namespace ::com::sun::star::container;
      50                 :            : using namespace ::com::sun::star::ucb;
      51                 :            : using namespace ::com::sun::star::sdbc;
      52                 :            : using namespace ::com::sun::star::sdb;
      53                 :            : using namespace ::com::sun::star::io;
      54                 :            : using namespace ::osl;
      55                 :            : using namespace ::comphelper;
      56                 :            : using namespace ::cppu;
      57                 :            : 
      58                 :            : namespace dbaccess
      59                 :            : {
      60                 :            : 
      61                 :            : //==========================================================================
      62                 :            : //= LocalNameApproval
      63                 :            : //==========================================================================
      64                 :            : class LocalNameApproval : public IContainerApprove
      65                 :            : {
      66                 :            :     ::connectivity::SQLError    m_aErrors;
      67                 :            : 
      68                 :            : public:
      69                 :        348 :     LocalNameApproval( const Reference< XMultiServiceFactory >& _rxFactory )
      70 [ +  - ][ +  - ]:        348 :         :m_aErrors( ::comphelper::ComponentContext( _rxFactory ) )
                 [ +  - ]
      71                 :            :     {
      72                 :        348 :     }
      73                 :        696 :     virtual ~LocalNameApproval()
      74         [ +  - ]:        348 :     {
      75         [ -  + ]:        696 :     }
      76                 :            : 
      77                 :            :     void SAL_CALL   approveElement( const ::rtl::OUString& _rName, const Reference< XInterface >& _rxElement );
      78                 :            : };
      79                 :            : 
      80                 :          0 : void SAL_CALL LocalNameApproval::approveElement( const ::rtl::OUString& _rName, const Reference< XInterface >& /*_rxElement*/ )
      81                 :            : {
      82         [ #  # ]:          0 :     if ( _rName.indexOf( '/' ) != -1 )
      83                 :            :         throw IllegalArgumentException(
      84                 :            :             m_aErrors.getErrorMessage( ErrorCondition::DB_OBJECT_NAME_WITH_SLASHES ),
      85                 :            :             NULL,
      86                 :            :             0
      87 [ #  # ][ #  # ]:          0 :         );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
      88                 :          0 : }
      89                 :            : 
      90                 :            : //==========================================================================
      91                 :            : //= ODocumentContainer
      92                 :            : //==========================================================================
      93                 :            : DBG_NAME(ODocumentContainer)
      94                 :            : 
      95                 :        348 : ODocumentContainer::ODocumentContainer(const Reference< XMultiServiceFactory >& _xORB
      96                 :            :                                     ,const Reference< XInterface >& _xParentContainer
      97                 :            :                                     ,const TContentPtr& _pImpl
      98                 :            :                                     , sal_Bool _bFormsContainer
      99                 :            :                                     )
     100                 :            :     :ODefinitionContainer(_xORB,_xParentContainer,_pImpl)
     101                 :            :     ,OPropertyStateContainer(OContentHelper::rBHelper)
     102 [ +  - ][ +  - ]:        348 :     ,m_bFormsContainer(_bFormsContainer)
     103                 :            : {
     104                 :            :     DBG_CTOR(ODocumentContainer, NULL);
     105                 :            :     registerProperty(PROPERTY_NAME, PROPERTY_ID_NAME, PropertyAttribute::BOUND | PropertyAttribute::READONLY | PropertyAttribute::CONSTRAINED,
     106 [ +  - ][ +  - ]:        348 :                     &m_pImpl->m_aProps.aTitle, ::getCppuType(&m_pImpl->m_aProps.aTitle));
                 [ +  - ]
     107                 :            : 
     108 [ +  - ][ +  - ]:        348 :     setElementApproval( PContainerApprove( new LocalNameApproval ( _xORB ) ) );
         [ +  - ][ +  - ]
                 [ +  - ]
     109                 :        348 : }
     110                 :            : 
     111 [ +  - ][ +  - ]:        348 : ODocumentContainer::~ODocumentContainer()
     112                 :            : {
     113                 :            :     DBG_DTOR(ODocumentContainer, NULL);
     114                 :            : 
     115 [ +  - ][ -  + ]:        348 :     if ( !OContentHelper::rBHelper.bInDispose && !OContentHelper::rBHelper.bDisposed )
     116                 :            :     {
     117                 :          0 :         acquire();
     118         [ #  # ]:          0 :         dispose();
     119                 :            :     }
     120         [ -  + ]:        696 : }
     121                 :            : 
     122 [ -  + ][ #  # ]:       9396 : IMPLEMENT_FORWARD_XINTERFACE3( ODocumentContainer,ODefinitionContainer,ODocumentContainer_Base,OPropertyStateContainer)
         [ #  # ][ #  # ]
     123 [ #  # ][ #  # ]:          0 : IMPLEMENT_TYPEPROVIDER3(ODocumentContainer,ODefinitionContainer,OPropertyStateContainer,ODocumentContainer_Base);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     124                 :          0 : IMPLEMENT_SERVICE_INFO_IMPLNAME(ODocumentContainer, "com.sun.star.comp.dba.ODocumentContainer");
     125 [ #  # ][ #  # ]:          0 : IMPLEMENT_SERVICE_INFO_SUPPORTS(ODocumentContainer);
         [ #  # ][ #  # ]
     126 [ #  # ][ #  # ]:          0 : IMPLEMENT_PROPERTYCONTAINER_DEFAULTS(ODocumentContainer)
         [ #  # ][ #  # ]
     127                 :            : 
     128                 :          0 : Sequence< ::rtl::OUString > SAL_CALL ODocumentContainer::getSupportedServiceNames(  ) throw(RuntimeException)
     129                 :            : {
     130                 :          0 :     Sequence< ::rtl::OUString > aSupported(1);
     131 [ #  # ][ #  # ]:          0 :     aSupported[0] = m_bFormsContainer ? SERVICE_NAME_FORM_COLLECTION : SERVICE_NAME_REPORT_COLLECTION;
                 [ #  # ]
     132                 :          0 :     return aSupported;
     133                 :            : }
     134                 :            : 
     135                 :          0 : ::rtl::OUString ODocumentContainer::determineContentType() const
     136                 :            : {
     137                 :          0 :     return ::rtl::OUString();
     138                 :            : }
     139                 :            : 
     140                 :          0 : Reference< XContent > ODocumentContainer::createObject( const ::rtl::OUString& _rName)
     141                 :            : {
     142         [ #  # ]:          0 :     const ODefinitionContainer_Impl& rDefinitions( getDefinitions() );
     143         [ #  # ]:          0 :     ODefinitionContainer_Impl::const_iterator aFind = rDefinitions.find( _rName );
     144                 :            :     OSL_ENSURE( aFind != rDefinitions.end(), "ODocumentContainer::createObject:Invalid entry in map!" );
     145         [ #  # ]:          0 :     if ( aFind->second->m_aProps.bIsFolder )
     146 [ #  # ][ #  # ]:          0 :         return new ODocumentContainer( m_aContext.getLegacyServiceFactory(), *this, aFind->second, m_bFormsContainer );
         [ #  # ][ #  # ]
                 [ #  # ]
     147 [ #  # ][ #  # ]:          0 :     return new ODocumentDefinition( *this, m_aContext.getLegacyServiceFactory(), aFind->second, m_bFormsContainer );
         [ #  # ][ #  # ]
                 [ #  # ]
     148                 :            : }
     149                 :            : 
     150                 :          0 : Reference< XInterface > SAL_CALL ODocumentContainer::createInstance( const ::rtl::OUString& aServiceSpecifier ) throw (Exception, RuntimeException)
     151                 :            : {
     152         [ #  # ]:          0 :     return createInstanceWithArguments( aServiceSpecifier, Sequence< Any >() );
     153                 :            : }
     154                 :            : 
     155                 :            : namespace
     156                 :            : {
     157                 :            :     template< class TYPE >
     158                 :          0 :     void lcl_extractAndRemove( ::comphelper::NamedValueCollection& io_rArguments, const ::rtl::OUString& i_rName, TYPE& o_rValue )
     159                 :            :     {
     160 [ #  # ][ #  # ]:          0 :         if ( io_rArguments.has( i_rName ) )
         [ #  # ][ #  # ]
     161                 :            :         {
     162                 :          0 :             io_rArguments.get_ensureType( i_rName, o_rValue );
     163                 :          0 :             io_rArguments.remove( i_rName );
     164                 :            :         }
     165                 :          0 :     }
     166                 :            : }
     167                 :            : 
     168                 :          0 : Reference< XInterface > SAL_CALL ODocumentContainer::createInstanceWithArguments( const ::rtl::OUString& ServiceSpecifier, const Sequence< Any >& _aArguments ) throw (Exception, RuntimeException)
     169                 :            : {
     170                 :          0 :     Reference< XInterface > xRet;
     171                 :          0 :     Reference< XContent > xContent;
     172 [ #  # ][ #  # ]:          0 :     if ( ServiceSpecifier == SERVICE_SDB_DOCUMENTDEFINITION )
     173                 :            :     {
     174         [ #  # ]:          0 :         MutexGuard aGuard(m_aMutex);
     175                 :            : 
     176                 :            :         // extract known arguments
     177                 :          0 :         ::rtl::OUString sName, sPersistentName, sURL, sMediaType, sDocServiceName;
     178                 :          0 :         Reference< XCommandProcessor > xCopyFrom;
     179                 :          0 :         Reference< XConnection > xConnection;
     180                 :          0 :         sal_Bool bAsTemplate( sal_False );
     181         [ #  # ]:          0 :         Sequence< sal_Int8 > aClassID;
     182                 :            : 
     183         [ #  # ]:          0 :         ::comphelper::NamedValueCollection aArgs( _aArguments );
     184 [ #  # ][ #  # ]:          0 :         lcl_extractAndRemove( aArgs, PROPERTY_NAME, sName );
     185 [ #  # ][ #  # ]:          0 :         lcl_extractAndRemove( aArgs, PROPERTY_PERSISTENT_NAME, sPersistentName );
     186 [ #  # ][ #  # ]:          0 :         lcl_extractAndRemove( aArgs, PROPERTY_URL, sURL );
     187 [ #  # ][ #  # ]:          0 :         lcl_extractAndRemove( aArgs, PROPERTY_EMBEDDEDOBJECT, xCopyFrom );
     188 [ #  # ][ #  # ]:          0 :         lcl_extractAndRemove( aArgs, PROPERTY_ACTIVE_CONNECTION, xConnection );
     189 [ #  # ][ #  # ]:          0 :         lcl_extractAndRemove( aArgs, PROPERTY_AS_TEMPLATE, bAsTemplate );
     190 [ #  # ][ #  # ]:          0 :         lcl_extractAndRemove( aArgs, INFO_MEDIATYPE, sMediaType );
     191 [ #  # ][ #  # ]:          0 :         lcl_extractAndRemove( aArgs, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DocumentServiceName" ) ), sDocServiceName );
     192                 :            : 
     193                 :            :         // ClassID has two allowed types, so a special treatment here
     194         [ #  # ]:          0 :         Any aClassIDArg = aArgs.get( "ClassID" );
     195         [ #  # ]:          0 :         if ( aClassIDArg.hasValue() )
     196                 :            :         {
     197 [ #  # ][ #  # ]:          0 :             if ( !( aClassIDArg >>= aClassID ) )
     198                 :            :             {
     199                 :            :                 // Extended for usage also with a string
     200                 :          0 :                 ::rtl::OUString sClassIDString;
     201         [ #  # ]:          0 :                 if ( !( aClassIDArg >>= sClassIDString ) )
     202 [ #  # ][ #  # ]:          0 :                     throw IllegalArgumentException( ::rtl::OUString(), *this, 2 );
     203                 :            : 
     204 [ #  # ][ #  # ]:          0 :                 aClassID = ::comphelper::MimeConfigurationHelper::GetSequenceClassIDRepresentation( sClassIDString );
                 [ #  # ]
     205                 :            :             }
     206                 :            : 
     207                 :            : #if OSL_DEBUG_LEVEL > 0
     208                 :            :             ::rtl::OUString sClassIDString = ::comphelper::MimeConfigurationHelper::GetStringClassIDRepresentation( aClassID );
     209                 :            :             (void)sClassIDString;
     210                 :            : #endif
     211         [ #  # ]:          0 :             aArgs.remove( "ClassID" );
     212                 :            :         }
     213                 :            :         // Everything which now is still present in the arguments is passed to the embedded object
     214         [ #  # ]:          0 :         const Sequence< PropertyValue > aCreationArgs( aArgs.getPropertyValues() );
     215                 :            : 
     216         [ #  # ]:          0 :         const ODefinitionContainer_Impl& rDefinitions( getDefinitions() );
     217                 :          0 :         sal_Bool bNew = sPersistentName.isEmpty();
     218         [ #  # ]:          0 :         if ( bNew )
     219                 :            :         {
     220 [ #  # ][ #  # ]:          0 :             const static ::rtl::OUString sBaseName(RTL_CONSTASCII_USTRINGPARAM("Obj"));
         [ #  # ][ #  # ]
     221                 :            : 
     222                 :          0 :             sPersistentName = sBaseName;
     223                 :          0 :             sPersistentName += ::rtl::OUString::valueOf(sal_Int32(rDefinitions.size() + 1));
     224 [ #  # ][ #  # ]:          0 :             Reference<XNameAccess> xElements(getContainerStorage(),UNO_QUERY);
     225         [ #  # ]:          0 :             if ( xElements.is() )
     226         [ #  # ]:          0 :                 sPersistentName = ::dbtools::createUniqueName(xElements,sPersistentName);
     227                 :            : 
     228 [ #  # ][ #  # ]:          0 :             const bool bNeedClassID = (0 == aClassID.getLength()) && sURL.isEmpty() ;
     229         [ #  # ]:          0 :             if ( xCopyFrom.is() )
     230                 :            :             {
     231         [ #  # ]:          0 :                 Sequence<Any> aIni(2);
     232 [ #  # ][ #  # ]:          0 :                 aIni[0] <<= getContainerStorage();
                 [ #  # ]
     233 [ #  # ][ #  # ]:          0 :                 aIni[1] <<= sPersistentName;
     234                 :          0 :                 Command aCommand;
     235         [ #  # ]:          0 :                 aCommand.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("copyTo"));
     236         [ #  # ]:          0 :                 aCommand.Argument <<= aIni;
     237                 :            : 
     238 [ #  # ][ #  # ]:          0 :                 xCopyFrom->execute(aCommand,-1,Reference< XCommandEnvironment >());
     239         [ #  # ]:          0 :                 Reference<XPropertySet> xProp(xCopyFrom,UNO_QUERY);
     240 [ #  # ][ #  # ]:          0 :                 if ( xProp.is() && xProp->getPropertySetInfo().is() && xProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_AS_TEMPLATE) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  #  
          #  #  #  #  #  
                      # ]
     241 [ #  # ][ #  # ]:          0 :                     xProp->getPropertyValue(PROPERTY_AS_TEMPLATE) >>= bAsTemplate;
                 [ #  # ]
     242                 :            : 
     243                 :            :                 // if we do not have an own class ID, see if we can determine one from the copy we just created
     244         [ #  # ]:          0 :                 if ( bNeedClassID )
     245 [ #  # ][ #  # ]:          0 :                     ODocumentDefinition::GetDocumentServiceFromMediaType( getContainerStorage(), sPersistentName, m_aContext, aClassID );
                 [ #  # ]
     246                 :            :             }
     247                 :            :             else
     248                 :            :             {
     249         [ #  # ]:          0 :                 if ( bNeedClassID )
     250                 :            :                 {
     251         [ #  # ]:          0 :                     if ( !sMediaType.isEmpty() )
     252         [ #  # ]:          0 :                         ODocumentDefinition::GetDocumentServiceFromMediaType( sMediaType, m_aContext, aClassID );
     253         [ #  # ]:          0 :                     else if ( !sDocServiceName.isEmpty() )
     254                 :            :                     {
     255 [ #  # ][ #  # ]:          0 :                         ::comphelper::MimeConfigurationHelper aConfigHelper( m_aContext.getLegacyServiceFactory() );
     256         [ #  # ]:          0 :                         const Sequence< NamedValue > aProps( aConfigHelper.GetObjectPropsByDocumentName( sDocServiceName ) );
     257         [ #  # ]:          0 :                         const ::comphelper::NamedValueCollection aMediaTypeProps( aProps );
     258 [ #  # ][ #  # ]:          0 :                         aClassID = aMediaTypeProps.getOrDefault( "ClassID", Sequence< sal_Int8 >() );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     259                 :            :                     }
     260                 :            :                 }
     261                 :          0 :             }
     262                 :            :         }
     263                 :            : 
     264         [ #  # ]:          0 :         ODefinitionContainer_Impl::const_iterator aFind = rDefinitions.find( sName );
     265         [ #  # ]:          0 :         TContentPtr pElementImpl;
     266 [ #  # ][ #  # ]:          0 :         if ( bNew || ( aFind == rDefinitions.end() ) )
         [ #  # ][ #  # ]
     267                 :            :         {
     268 [ #  # ][ #  # ]:          0 :             pElementImpl.reset( new OContentHelper_Impl );
                 [ #  # ]
     269         [ #  # ]:          0 :             if ( !bNew )
     270                 :          0 :                 pElementImpl->m_aProps.aTitle = sName;
     271                 :            : 
     272                 :          0 :             pElementImpl->m_aProps.sPersistentName = sPersistentName;
     273                 :          0 :             pElementImpl->m_aProps.bAsTemplate = bAsTemplate;
     274                 :          0 :             pElementImpl->m_pDataSource = m_pImpl->m_pDataSource;
     275                 :            :         }
     276                 :            :         else
     277         [ #  # ]:          0 :             pElementImpl = aFind->second;
     278                 :            : 
     279 [ #  # ][ #  # ]:          0 :         ::rtl::Reference< ODocumentDefinition > pDocDef = new ODocumentDefinition( *this, m_aContext.getLegacyServiceFactory(), pElementImpl, m_bFormsContainer );
                 [ #  # ]
     280         [ #  # ]:          0 :         if ( aClassID.getLength() )
     281                 :            :         {
     282         [ #  # ]:          0 :             pDocDef->initialLoad( aClassID, aCreationArgs, xConnection );
     283                 :            :         }
     284                 :            :         else
     285                 :            :         {
     286                 :            :             OSL_ENSURE( aCreationArgs.getLength() == 0, "ODocumentContainer::createInstance: additional creation args are lost, if you do not provide a class ID." );
     287                 :            :         }
     288 [ #  # ][ #  # ]:          0 :         xContent = pDocDef.get();
     289                 :            : 
     290         [ #  # ]:          0 :         if ( !sURL.isEmpty() )
     291                 :            :         {
     292         [ #  # ]:          0 :             Sequence<Any> aIni(2);
     293 [ #  # ][ #  # ]:          0 :             aIni[0] <<= sURL;
     294                 :          0 :             Command aCommand;
     295         [ #  # ]:          0 :             aCommand.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("insert"));
     296         [ #  # ]:          0 :             aCommand.Argument <<= aIni;
     297         [ #  # ]:          0 :             Reference< XCommandProcessor > xCommandProcessor(xContent,UNO_QUERY);
     298         [ #  # ]:          0 :             if ( xContent.is() )
     299                 :            :             {
     300 [ #  # ][ #  # ]:          0 :                 xCommandProcessor->execute(aCommand,-1,Reference< XCommandEnvironment >());
     301         [ #  # ]:          0 :             }
     302 [ #  # ][ #  # ]:          0 :         }
         [ #  # ][ #  # ]
                 [ #  # ]
     303                 :            :     }
     304 [ #  # ][ #  # ]:          0 :     else if ( ServiceSpecifier == SERVICE_NAME_FORM_COLLECTION || SERVICE_NAME_REPORT_COLLECTION == ServiceSpecifier )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  #  
                   #  # ]
     305                 :            :     {
     306                 :          0 :         const Any* pBegin = _aArguments.getConstArray();
     307                 :          0 :         const Any* pEnd = pBegin + _aArguments.getLength();
     308                 :          0 :         PropertyValue aValue;
     309                 :          0 :         ::rtl::OUString sName;
     310                 :          0 :         Reference<XNameAccess> xCopyFrom;
     311         [ #  # ]:          0 :         for(;pBegin != pEnd;++pBegin)
     312                 :            :         {
     313         [ #  # ]:          0 :             *pBegin >>= aValue;
     314         [ #  # ]:          0 :             if ( aValue.Name.equalsAsciiL(PROPERTY_NAME.ascii, PROPERTY_NAME.length) )
     315                 :            :             {
     316                 :          0 :                 aValue.Value >>= sName;
     317                 :            :             }
     318         [ #  # ]:          0 :             else if ( aValue.Name.equalsAsciiL(PROPERTY_EMBEDDEDOBJECT.ascii, PROPERTY_EMBEDDEDOBJECT.length) )
     319                 :            :             {
     320         [ #  # ]:          0 :                 xCopyFrom.set(aValue.Value,UNO_QUERY);
     321                 :            :             }
     322                 :            :         }
     323                 :            :         OSL_ENSURE(!sName.isEmpty(),"Invalid name for a document container!");
     324         [ #  # ]:          0 :         const ODefinitionContainer_Impl& rDefinitions( getDefinitions() );
     325         [ #  # ]:          0 :         ODefinitionContainer_Impl::const_iterator aFind = rDefinitions.find( sName );
     326         [ #  # ]:          0 :         TContentPtr pElementImpl;
     327         [ #  # ]:          0 :         if ( aFind == rDefinitions.end() )
     328                 :            :         {
     329 [ #  # ][ #  # ]:          0 :             pElementImpl.reset(new ODefinitionContainer_Impl);
                 [ #  # ]
     330                 :          0 :             pElementImpl->m_aProps.aTitle = sName;
     331                 :          0 :             pElementImpl->m_pDataSource = m_pImpl->m_pDataSource;
     332                 :            :         }
     333                 :            :         else
     334         [ #  # ]:          0 :             pElementImpl = aFind->second;
     335                 :            :         OSL_ENSURE( pElementImpl ," Invalid entry in map!");
     336 [ #  # ][ #  # ]:          0 :         xContent = new ODocumentContainer( m_aContext.getLegacyServiceFactory(), *this, pElementImpl, ServiceSpecifier == SERVICE_NAME_FORM_COLLECTION );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     337                 :            : 
     338                 :            :         // copy children
     339         [ #  # ]:          0 :         if ( xCopyFrom.is() )
     340                 :            :         {
     341 [ #  # ][ #  # ]:          0 :             Sequence< ::rtl::OUString> aSeq = xCopyFrom->getElementNames();
     342                 :          0 :             const ::rtl::OUString* elements = aSeq.getConstArray();
     343                 :          0 :             const ::rtl::OUString* elementsEnd = elements + aSeq.getLength();
     344                 :          0 :             Reference<XContent> xObjectToCopy;
     345                 :            : 
     346         [ #  # ]:          0 :             Reference<XMultiServiceFactory> xORB(xContent,UNO_QUERY);
     347                 :            :             OSL_ENSURE(xORB.is(),"No service factory given");
     348         [ #  # ]:          0 :             if ( xORB.is() )
     349                 :            :             {
     350         [ #  # ]:          0 :                 for(;elements != elementsEnd;++elements)
     351                 :            :                 {
     352 [ #  # ][ #  # ]:          0 :                     xCopyFrom->getByName(*elements) >>= xObjectToCopy;
                 [ #  # ]
     353         [ #  # ]:          0 :                     Sequence< Any > aArguments(3);
     354                 :          0 :                     PropertyValue aArgument;
     355                 :            :                     // set as folder
     356         [ #  # ]:          0 :                     aArgument.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Name"));
     357         [ #  # ]:          0 :                     aArgument.Value <<= *elements;
     358 [ #  # ][ #  # ]:          0 :                     aArguments[0] <<= aArgument;
     359                 :            :                     //parent
     360         [ #  # ]:          0 :                     aArgument.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Parent"));
     361         [ #  # ]:          0 :                     aArgument.Value <<= xContent;
     362 [ #  # ][ #  # ]:          0 :                     aArguments[1] <<= aArgument;
     363                 :            : 
     364         [ #  # ]:          0 :                     aArgument.Name = PROPERTY_EMBEDDEDOBJECT;
     365         [ #  # ]:          0 :                     aArgument.Value <<= xObjectToCopy;
     366 [ #  # ][ #  # ]:          0 :                     aArguments[2] <<= aArgument;
     367                 :            : 
     368                 :          0 :                     ::rtl::OUString sServiceName;
     369 [ #  # ][ #  # ]:          0 :                     if ( Reference< XNameAccess >( xObjectToCopy, UNO_QUERY ).is() )
     370                 :            :                     {
     371         [ #  # ]:          0 :                         if ( m_bFormsContainer )
     372         [ #  # ]:          0 :                             sServiceName = SERVICE_NAME_FORM_COLLECTION;
     373                 :            :                         else
     374         [ #  # ]:          0 :                             sServiceName = SERVICE_NAME_REPORT_COLLECTION;
     375                 :            :                     }
     376                 :            :                     else
     377         [ #  # ]:          0 :                         sServiceName = SERVICE_SDB_DOCUMENTDEFINITION;
     378                 :            : 
     379 [ #  # ][ #  # ]:          0 :                     Reference<XContent > xNew(xORB->createInstanceWithArguments(sServiceName,aArguments),UNO_QUERY);
                 [ #  # ]
     380         [ #  # ]:          0 :                     Reference<XNameContainer> xNameContainer(xContent,UNO_QUERY);
     381         [ #  # ]:          0 :                     if ( xNameContainer.is() )
     382 [ #  # ][ #  # ]:          0 :                         xNameContainer->insertByName(*elements,makeAny(xNew));
                 [ #  # ]
     383         [ #  # ]:          0 :                 }
     384         [ #  # ]:          0 :             }
     385         [ #  # ]:          0 :         }
     386                 :            :     }
     387         [ #  # ]:          0 :     xRet = xContent;
     388                 :          0 :     return xRet;
     389                 :            : }
     390                 :            : 
     391                 :          0 : Sequence< ::rtl::OUString > SAL_CALL ODocumentContainer::getAvailableServiceNames(  ) throw (RuntimeException)
     392                 :            : {
     393                 :          0 :     Sequence< ::rtl::OUString > aSe(3);
     394 [ #  # ][ #  # ]:          0 :     aSe[0] = SERVICE_SDB_DOCUMENTDEFINITION;
     395 [ #  # ][ #  # ]:          0 :     aSe[1] = SERVICE_NAME_FORM_COLLECTION;
     396 [ #  # ][ #  # ]:          0 :     aSe[2] = SERVICE_NAME_REPORT_COLLECTION;
     397                 :          0 :     return aSe;
     398                 :            : }
     399                 :            : 
     400                 :          0 : Any SAL_CALL ODocumentContainer::execute( const Command& aCommand, sal_Int32 CommandId, const Reference< XCommandEnvironment >& Environment ) throw (Exception, CommandAbortedException, RuntimeException)
     401                 :            : {
     402                 :          0 :     Any aRet;
     403         [ #  # ]:          0 :     if ( aCommand.Name.compareToAscii( "open" ) == 0 )
     404                 :            :     {
     405                 :            :         //////////////////////////////////////////////////////////////////
     406                 :            :         // open command for a folder content
     407                 :            :         //////////////////////////////////////////////////////////////////
     408         [ #  # ]:          0 :         OpenCommandArgument2 aOpenCommand;
     409 [ #  # ][ #  # ]:          0 :           if ( !( aCommand.Argument >>= aOpenCommand ) )
     410                 :            :         {
     411                 :            :             OSL_FAIL( "Wrong argument type!" );
     412                 :            :             ucbhelper::cancelCommandExecution(
     413                 :            :                 makeAny( IllegalArgumentException(
     414                 :            :                                     rtl::OUString(),
     415                 :            :                                     static_cast< cppu::OWeakObject * >( this ),
     416                 :            :                                     -1 ) ),
     417 [ #  # ][ #  # ]:          0 :                 Environment );
         [ #  # ][ #  # ]
                 [ #  # ]
     418                 :            :             // Unreachable
     419                 :            :         }
     420                 :            :         sal_Bool bOpenFolder =
     421                 :            :             ( ( aOpenCommand.Mode == OpenMode::ALL ) ||
     422                 :            :               ( aOpenCommand.Mode == OpenMode::FOLDERS ) ||
     423 [ #  # ][ #  # ]:          0 :               ( aOpenCommand.Mode == OpenMode::DOCUMENTS ) );
                 [ #  # ]
     424                 :            : 
     425         [ #  # ]:          0 :         if ( bOpenFolder )
     426                 :            :         {
     427                 :            :             // open as folder - return result set
     428                 :            : 
     429                 :            :             Reference< XDynamicResultSet > xSet
     430                 :            :                             = new DynamicResultSet( m_aContext.getLegacyServiceFactory(),
     431                 :            :                                                     this,
     432                 :            :                                                     aOpenCommand,
     433 [ #  # ][ #  # ]:          0 :                                                     Environment );
         [ #  # ][ #  # ]
     434         [ #  # ]:          0 :             aRet <<= xSet;
     435                 :            :           }
     436                 :            :         else
     437                 :            :         {
     438                 :            :             // Unsupported.
     439                 :            :             ucbhelper::cancelCommandExecution(
     440                 :            :                 makeAny( UnsupportedOpenModeException(
     441                 :            :                                 rtl::OUString(),
     442                 :            :                                 static_cast< cppu::OWeakObject * >( this ),
     443                 :            :                                 sal_Int16( aOpenCommand.Mode ) ) ),
     444 [ #  # ][ #  # ]:          0 :                 Environment );
         [ #  # ][ #  # ]
                 [ #  # ]
     445                 :            :                 // Unreachable
     446         [ #  # ]:          0 :         }
     447                 :            :     }
     448         [ #  # ]:          0 :     else if ( aCommand.Name == "insert" )
     449                 :            :     {
     450                 :            :         //////////////////////////////////////////////////////////////////
     451                 :            :         // insert
     452                 :            :         //////////////////////////////////////////////////////////////////
     453                 :            : 
     454         [ #  # ]:          0 :         InsertCommandArgument arg;
     455 [ #  # ][ #  # ]:          0 :           if ( !( aCommand.Argument >>= arg ) )
     456                 :            :         {
     457                 :            :               OSL_FAIL( "Wrong argument type!" );
     458                 :            :             ucbhelper::cancelCommandExecution(
     459                 :            :                 makeAny( IllegalArgumentException(
     460                 :            :                                     rtl::OUString(),
     461                 :            :                                     static_cast< cppu::OWeakObject * >( this ),
     462                 :            :                                     -1 ) ),
     463 [ #  # ][ #  # ]:          0 :                 Environment );
         [ #  # ][ #  # ]
                 [ #  # ]
     464                 :            :             // Unreachable
     465         [ #  # ]:          0 :         }
     466                 :            :     }
     467         [ #  # ]:          0 :     else if ( aCommand.Name == "delete" )
     468                 :            :     {
     469                 :            :         //////////////////////////////////////////////////////////////////
     470                 :            :         // delete
     471                 :            :         //////////////////////////////////////////////////////////////////
     472         [ #  # ]:          0 :         Sequence< ::rtl::OUString> aSeq = getElementNames();
     473                 :          0 :         const ::rtl::OUString* pIter = aSeq.getConstArray();
     474                 :          0 :         const ::rtl::OUString* pEnd   = pIter + aSeq.getLength();
     475         [ #  # ]:          0 :         for(;pIter != pEnd;++pIter)
     476         [ #  # ]:          0 :             removeByName(*pIter);
     477                 :            : 
     478 [ #  # ][ #  # ]:          0 :         dispose();
     479                 :            :     }
     480                 :            :     else
     481         [ #  # ]:          0 :         aRet = OContentHelper::execute(aCommand,CommandId,Environment);
     482                 :          0 :     return aRet;
     483                 :            : }
     484                 :            : 
     485                 :            : namespace
     486                 :            : {
     487                 :          0 :     sal_Bool lcl_queryContent(const ::rtl::OUString& _sName,Reference< XNameContainer >& _xNameContainer,Any& _rRet,::rtl::OUString& _sSimpleName)
     488                 :            :     {
     489                 :          0 :         sal_Bool bRet = sal_False;
     490                 :          0 :         sal_Int32 nIndex = 0;
     491                 :          0 :         ::rtl::OUString sName = _sName.getToken(0,'/',nIndex);
     492 [ #  # ][ #  # ]:          0 :         bRet = _xNameContainer->hasByName(sName);
     493         [ #  # ]:          0 :         if ( bRet )
     494                 :            :         {
     495 [ #  # ][ #  # ]:          0 :             _rRet = _xNameContainer->getByName(_sSimpleName = sName);
     496 [ #  # ][ #  # ]:          0 :             while ( nIndex != -1 && bRet )
                 [ #  # ]
     497                 :            :             {
     498                 :          0 :                 sName = _sName.getToken(0,'/',nIndex);
     499         [ #  # ]:          0 :                 _xNameContainer.set(_rRet,UNO_QUERY);
     500                 :          0 :                 bRet = _xNameContainer.is();
     501         [ #  # ]:          0 :                 if ( bRet )
     502                 :            :                 {
     503 [ #  # ][ #  # ]:          0 :                     bRet = _xNameContainer->hasByName(sName);
     504                 :          0 :                     _sSimpleName = sName;
     505         [ #  # ]:          0 :                     if ( bRet )
     506 [ #  # ][ #  # ]:          0 :                         _rRet = _xNameContainer->getByName(sName);
     507                 :            :                 }
     508                 :            :             }
     509                 :            :         }
     510         [ #  # ]:          0 :         if ( nIndex == -1 )
     511                 :          0 :             _sSimpleName = sName; // a content
     512                 :            :         else
     513                 :          0 :             _xNameContainer.clear(); // a sub folder doesn't exist
     514                 :          0 :         return bRet;
     515                 :            :     }
     516                 :            : }
     517                 :            : 
     518                 :          0 : Reference< XComponent > SAL_CALL ODocumentContainer::loadComponentFromURL( const ::rtl::OUString& _sURL
     519                 :            :                                                                        , const ::rtl::OUString& /*TargetFrameName*/
     520                 :            :                                                                        , sal_Int32 /*SearchFlags*/
     521                 :            :                                                                        , const Sequence< PropertyValue >& Arguments ) throw (IOException, IllegalArgumentException, RuntimeException)
     522                 :            : {
     523         [ #  # ]:          0 :     ::SolarMutexGuard aSolarGuard;
     524                 :            : 
     525         [ #  # ]:          0 :     MutexGuard aGuard(m_aMutex);
     526                 :          0 :     Reference< XComponent > xComp;
     527                 :            :     try
     528                 :            :     {
     529                 :          0 :         Any aContent;
     530         [ #  # ]:          0 :         Reference< XNameContainer > xNameContainer(this);
     531                 :          0 :         ::rtl::OUString sName;
     532 [ #  # ][ #  # ]:          0 :         if ( !lcl_queryContent(_sURL,xNameContainer,aContent,sName) )
     533                 :            :         {
     534                 :            :             ::rtl::OUString sMessage(
     535         [ #  # ]:          0 :                 DBA_RES(RID_STR_NAME_NOT_FOUND).replaceFirst("$name$", _sURL));
     536 [ #  # ][ #  # ]:          0 :             throw IllegalArgumentException( sMessage, *this, 1 );
     537                 :            :         }
     538                 :            : 
     539         [ #  # ]:          0 :         Reference< XCommandProcessor > xContent(aContent,UNO_QUERY);
     540         [ #  # ]:          0 :         if ( xContent.is() )
     541                 :            :         {
     542                 :          0 :             Command aCommand;
     543                 :            : 
     544         [ #  # ]:          0 :             ::comphelper::NamedValueCollection aArgs( Arguments );
     545 [ #  # ][ #  # ]:          0 :             aCommand.Name = aArgs.getOrDefault( "OpenMode", ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "open" ) ) );
     546         [ #  # ]:          0 :             aArgs.remove( "OpenMode" );
     547                 :            : 
     548         [ #  # ]:          0 :             OpenCommandArgument2 aOpenCommand;
     549                 :          0 :             aOpenCommand.Mode = OpenMode::DOCUMENT;
     550         [ #  # ]:          0 :             aArgs.put( "OpenCommandArgument", aOpenCommand );
     551                 :            : 
     552 [ #  # ][ #  # ]:          0 :             aCommand.Argument <<= aArgs.getPropertyValues();
                 [ #  # ]
     553 [ #  # ][ #  # ]:          0 :             xComp.set(xContent->execute(aCommand,xContent->createCommandIdentifier(),Reference< XCommandEnvironment >()),UNO_QUERY);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     554                 :          0 :         }
     555                 :            :     }
     556                 :          0 :     catch(const NoSuchElementException&)
     557                 :            :     {
     558         [ #  # ]:          0 :         throw IllegalArgumentException();
     559                 :            :     }
     560      [ #  #  # ]:          0 :     catch(const WrappedTargetException&)
     561                 :            :     {
     562                 :          0 :         throw;
     563                 :            :     }
     564 [ #  # ][ #  # ]:          0 :     return xComp;
     565                 :            : }
     566                 :            : 
     567                 :          0 : Any SAL_CALL ODocumentContainer::getByHierarchicalName( const ::rtl::OUString& _sName ) throw (NoSuchElementException, RuntimeException)
     568                 :            : {
     569         [ #  # ]:          0 :     MutexGuard aGuard(m_aMutex);
     570                 :          0 :     Any aContent;
     571         [ #  # ]:          0 :     Reference< XNameContainer > xNameContainer(this);
     572                 :          0 :     ::rtl::OUString sName;
     573 [ #  # ][ #  # ]:          0 :     if ( lcl_queryContent(_sName,xNameContainer,aContent,sName) )
     574                 :          0 :         return aContent;
     575 [ #  # ][ #  # ]:          0 :     throw NoSuchElementException(_sName,*this);
                 [ #  # ]
     576                 :            : }
     577                 :            : 
     578                 :          0 : sal_Bool SAL_CALL ODocumentContainer::hasByHierarchicalName( const ::rtl::OUString& _sName ) throw (RuntimeException)
     579                 :            : {
     580         [ #  # ]:          0 :     MutexGuard aGuard(m_aMutex);
     581                 :          0 :     Any aContent;
     582         [ #  # ]:          0 :     Reference< XNameContainer > xNameContainer(this);
     583                 :          0 :     ::rtl::OUString sName;
     584 [ #  # ][ #  # ]:          0 :     return lcl_queryContent(_sName,xNameContainer,aContent,sName);
     585                 :            : }
     586                 :            : 
     587                 :            : // XHierarchicalNameContainer
     588                 :          0 : void SAL_CALL ODocumentContainer::insertByHierarchicalName( const ::rtl::OUString& _sName, const Any& _aElement ) throw (IllegalArgumentException, ElementExistException, WrappedTargetException, RuntimeException)
     589                 :            : {
     590         [ #  # ]:          0 :     Reference< XContent > xContent(_aElement,UNO_QUERY);
     591         [ #  # ]:          0 :     if ( !xContent.is() )
     592         [ #  # ]:          0 :         throw IllegalArgumentException();
     593                 :            : 
     594         [ #  # ]:          0 :     ClearableMutexGuard aGuard(m_aMutex);
     595                 :          0 :     Any aContent;
     596         [ #  # ]:          0 :     Reference< XNameContainer > xNameContainer(this);
     597                 :          0 :     ::rtl::OUString sName;
     598 [ #  # ][ #  # ]:          0 :     if ( lcl_queryContent(_sName,xNameContainer,aContent,sName) )
     599 [ #  # ][ #  # ]:          0 :         throw ElementExistException(_sName,*this);
     600                 :            : 
     601         [ #  # ]:          0 :     if ( !xNameContainer.is() )
     602                 :            :     {
     603                 :          0 :         sal_Int32 index = sName.getLength();
     604                 :            :         ::rtl::OUString sMessage(
     605                 :            :             DBA_RES(RID_STR_NO_SUB_FOLDER).replaceFirst("$folder$",
     606         [ #  # ]:          0 :                 _sName.getToken(0,'/',index)));
     607 [ #  # ][ #  # ]:          0 :         throw IllegalArgumentException( sMessage, *this, 1 );
     608                 :            :     }
     609                 :            : 
     610 [ #  # ][ #  # ]:          0 :     xNameContainer->insertByName(sName,_aElement);
                 [ #  # ]
     611                 :          0 : }
     612                 :            : 
     613                 :          0 : void SAL_CALL ODocumentContainer::removeByHierarchicalName( const ::rtl::OUString& _sName ) throw (NoSuchElementException, WrappedTargetException, RuntimeException)
     614                 :            : {
     615         [ #  # ]:          0 :     if ( _sName.isEmpty() )
     616 [ #  # ][ #  # ]:          0 :         throw NoSuchElementException(_sName,*this);
     617                 :            : 
     618         [ #  # ]:          0 :     ClearableMutexGuard aGuard(m_aMutex);
     619                 :          0 :     Any aContent;
     620                 :          0 :     ::rtl::OUString sName;
     621         [ #  # ]:          0 :     Reference< XNameContainer > xNameContainer(this);
     622 [ #  # ][ #  # ]:          0 :     if ( !lcl_queryContent(_sName,xNameContainer,aContent,sName) )
     623 [ #  # ][ #  # ]:          0 :         throw NoSuchElementException(_sName,*this);
     624                 :            : 
     625 [ #  # ][ #  # ]:          0 :     xNameContainer->removeByName(sName);
                 [ #  # ]
     626                 :          0 : }
     627                 :            : 
     628                 :            : // XHierarchicalNameReplace
     629                 :          0 : void SAL_CALL ODocumentContainer::replaceByHierarchicalName( const ::rtl::OUString& _sName, const Any& _aElement ) throw (IllegalArgumentException, NoSuchElementException, WrappedTargetException, RuntimeException)
     630                 :            : {
     631         [ #  # ]:          0 :     Reference< XContent > xContent(_aElement,UNO_QUERY);
     632         [ #  # ]:          0 :     if ( !xContent.is() )
     633         [ #  # ]:          0 :         throw IllegalArgumentException();
     634                 :            : 
     635         [ #  # ]:          0 :     ClearableMutexGuard aGuard(m_aMutex);
     636                 :          0 :     Any aContent;
     637                 :          0 :     ::rtl::OUString sName;
     638         [ #  # ]:          0 :     Reference< XNameContainer > xNameContainer(this);
     639 [ #  # ][ #  # ]:          0 :     if ( !lcl_queryContent(_sName,xNameContainer,aContent,sName) )
     640 [ #  # ][ #  # ]:          0 :         throw NoSuchElementException(_sName,*this);
     641                 :            : 
     642 [ #  # ][ #  # ]:          0 :     xNameContainer->replaceByName(sName,_aElement);
                 [ #  # ]
     643                 :          0 : }
     644                 :            : 
     645                 :          0 : ::rtl::OUString SAL_CALL ODocumentContainer::getHierarchicalName() throw (RuntimeException)
     646                 :            : {
     647         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_aMutex );
     648 [ #  # ][ #  # ]:          0 :     return impl_getHierarchicalName( false );
     649                 :            : }
     650                 :            : 
     651                 :          0 : ::rtl::OUString SAL_CALL ODocumentContainer::composeHierarchicalName( const ::rtl::OUString& i_rRelativeName ) throw (IllegalArgumentException, NoSupportException, RuntimeException)
     652                 :            : {
     653                 :          0 :     ::rtl::OUStringBuffer aBuffer;
     654 [ #  # ][ #  # ]:          0 :     aBuffer.append( getHierarchicalName() );
     655         [ #  # ]:          0 :     aBuffer.append( sal_Unicode( '/' ) );
     656         [ #  # ]:          0 :     aBuffer.append( i_rRelativeName );
     657         [ #  # ]:          0 :     return aBuffer.makeStringAndClear();
     658                 :            : }
     659                 :            : 
     660                 :          0 : ::rtl::Reference<OContentHelper> ODocumentContainer::getContent(const ::rtl::OUString& _sName) const
     661                 :            : {
     662                 :          0 :     ::rtl::Reference<OContentHelper> pContent = NULL;
     663                 :            :     try
     664                 :            :     {
     665 [ #  # ][ #  # ]:          0 :         Reference<XUnoTunnel> xUnoTunnel(const_cast<ODocumentContainer*>(this)->implGetByName( _sName, sal_True ), UNO_QUERY );
     666         [ #  # ]:          0 :         if ( xUnoTunnel.is() )
     667 [ #  # ][ #  # ]:          0 :             pContent = reinterpret_cast<OContentHelper*>(xUnoTunnel->getSomething(OContentHelper::getUnoTunnelImplementationId()));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     668                 :            :     }
     669         [ #  # ]:          0 :     catch(const Exception&)
     670                 :            :     {
     671                 :            :     }
     672                 :          0 :     return pContent;
     673                 :            : }
     674                 :            : 
     675                 :          0 : void ODocumentContainer::getPropertyDefaultByHandle( sal_Int32 /*_nHandle*/, Any& _rDefault ) const
     676                 :            : {
     677                 :          0 :     _rDefault.clear();
     678                 :          0 : }
     679                 :            : 
     680                 :          0 : void SAL_CALL ODocumentContainer::commit(  ) throw (::com::sun::star::io::IOException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
     681                 :            : {
     682         [ #  # ]:          0 :     MutexGuard aGuard(m_aMutex);
     683                 :          0 :     Documents::iterator aIter = m_aDocumentMap.begin();
     684                 :          0 :     Documents::iterator aEnd = m_aDocumentMap.end();
     685         [ #  # ]:          0 :     for (; aIter != aEnd ; ++aIter)
     686                 :            :     {
     687 [ #  # ][ #  # ]:          0 :         Reference<XTransactedObject> xTrans(aIter->second.get(),UNO_QUERY);
     688         [ #  # ]:          0 :         if ( xTrans.is() )
     689 [ #  # ][ #  # ]:          0 :             xTrans->commit();
     690                 :          0 :     }
     691 [ #  # ][ #  # ]:          0 :     Reference<XTransactedObject> xTrans(getContainerStorage(),UNO_QUERY);
     692         [ #  # ]:          0 :     if ( xTrans.is() )
     693 [ #  # ][ #  # ]:          0 :         xTrans->commit();
                 [ #  # ]
     694                 :          0 : }
     695                 :            : 
     696                 :          0 : void SAL_CALL ODocumentContainer::revert(  ) throw (::com::sun::star::io::IOException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
     697                 :            : {
     698         [ #  # ]:          0 :     MutexGuard aGuard(m_aMutex);
     699                 :          0 :     Documents::iterator aIter = m_aDocumentMap.begin();
     700                 :          0 :     Documents::iterator aEnd = m_aDocumentMap.end();
     701         [ #  # ]:          0 :     for (; aIter != aEnd ; ++aIter)
     702                 :            :     {
     703 [ #  # ][ #  # ]:          0 :         Reference<XTransactedObject> xTrans(aIter->second.get(),UNO_QUERY);
     704         [ #  # ]:          0 :         if ( xTrans.is() )
     705 [ #  # ][ #  # ]:          0 :             xTrans->revert();
     706                 :          0 :     }
     707 [ #  # ][ #  # ]:          0 :     Reference<XTransactedObject> xTrans(getContainerStorage(),UNO_QUERY);
     708         [ #  # ]:          0 :     if ( xTrans.is() )
     709 [ #  # ][ #  # ]:          0 :         xTrans->revert();
                 [ #  # ]
     710                 :          0 : }
     711                 :            : 
     712                 :          0 : Reference< XStorage> ODocumentContainer::getContainerStorage() const
     713                 :            : {
     714                 :          0 :     return  m_pImpl->m_pDataSource
     715                 :          0 :         ?   m_pImpl->m_pDataSource->getStorage( m_bFormsContainer ? ODatabaseModelImpl::E_FORM : ODatabaseModelImpl::E_REPORT )
     716         [ #  # ]:          0 :         :   Reference< XStorage>();
     717                 :            : }
     718                 :            : 
     719                 :          0 : void SAL_CALL ODocumentContainer::removeByName( const ::rtl::OUString& _rName ) throw(NoSuchElementException, WrappedTargetException, RuntimeException)
     720                 :            : {
     721         [ #  # ]:          0 :     ResettableMutexGuard aGuard(m_aMutex);
     722                 :            : 
     723                 :            :     // check the arguments
     724         [ #  # ]:          0 :     if (_rName.isEmpty())
     725         [ #  # ]:          0 :         throw IllegalArgumentException();
     726                 :            : 
     727 [ #  # ][ #  # ]:          0 :     if (!checkExistence(_rName))
     728 [ #  # ][ #  # ]:          0 :         throw NoSuchElementException(_rName,*this);
     729                 :            : 
     730 [ #  # ][ #  # ]:          0 :     Reference< XCommandProcessor > xContent( implGetByName( _rName, sal_True ), UNO_QUERY );
     731         [ #  # ]:          0 :     if ( xContent.is() )
     732                 :            :     {
     733                 :          0 :         Command aCommand;
     734                 :            : 
     735         [ #  # ]:          0 :         aCommand.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("delete"));
     736 [ #  # ][ #  # ]:          0 :         xContent->execute(aCommand,xContent->createCommandIdentifier(),Reference< XCommandEnvironment >());
         [ #  # ][ #  # ]
     737                 :            :     }
     738                 :            : 
     739                 :            :     // do the removal
     740         [ #  # ]:          0 :     implRemove(_rName);
     741                 :            : 
     742 [ #  # ][ #  # ]:          0 :     notifyByName( aGuard, _rName, NULL, NULL, E_REMOVED, ContainerListemers );
         [ #  # ][ #  # ]
     743                 :          0 : }
     744                 :            : 
     745                 :          0 : void SAL_CALL ODocumentContainer::rename( const ::rtl::OUString& newName ) throw (SQLException, ElementExistException, RuntimeException)
     746                 :            : {
     747                 :            :     try
     748                 :            :     {
     749         [ #  # ]:          0 :         osl::ClearableGuard< osl::Mutex > aGuard(m_aMutex);
     750         [ #  # ]:          0 :         if ( newName.equals( m_pImpl->m_aProps.aTitle ) )
     751                 :          0 :             return;
     752                 :            : 
     753                 :          0 :         sal_Int32 nHandle = PROPERTY_ID_NAME;
     754         [ #  # ]:          0 :         Any aOld = makeAny(m_pImpl->m_aProps.aTitle);
     755         [ #  # ]:          0 :         Any aNew = makeAny(newName);
     756                 :            : 
     757         [ #  # ]:          0 :         aGuard.clear();
     758         [ #  # ]:          0 :         fire(&nHandle, &aNew, &aOld, 1, sal_True );
     759                 :          0 :         m_pImpl->m_aProps.aTitle = newName;
     760 [ #  # ][ #  # ]:          0 :         fire(&nHandle, &aNew, &aOld, 1, sal_False );
                 [ #  # ]
     761                 :            :     }
     762         [ #  # ]:          0 :     catch(const PropertyVetoException&)
     763                 :            :     {
     764   [ #  #  #  # ]:          0 :         throw ElementExistException(newName,*this);
     765                 :            :     }
     766                 :            : }
     767                 :            : 
     768                 :            : }   // namespace dbaccess
     769                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10