LCOV - code coverage report
Current view: top level - package/source/xstor - xstorage.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1058 2949 35.9 %
Date: 2012-08-25 Functions: 82 129 63.6 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 1287 7184 17.9 %

           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                 :            : #include <com/sun/star/beans/PropertyValue.hpp>
      21                 :            : #include <com/sun/star/embed/ElementModes.hpp>
      22                 :            : #include <com/sun/star/embed/UseBackupException.hpp>
      23                 :            : #include <com/sun/star/embed/StorageFormats.hpp>
      24                 :            : #include <com/sun/star/ucb/XProgressHandler.hpp>
      25                 :            : #include <com/sun/star/ucb/SimpleFileAccess.hpp>
      26                 :            : #include <com/sun/star/ucb/XSimpleFileAccess2.hpp>
      27                 :            : #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
      28                 :            : #include <com/sun/star/container/XEnumerationAccess.hpp>
      29                 :            : #include <com/sun/star/container/XNamed.hpp>
      30                 :            : #include <com/sun/star/util/XChangesBatch.hpp>
      31                 :            : #include <com/sun/star/util/XCloneable.hpp>
      32                 :            : 
      33                 :            : 
      34                 :            : #include <com/sun/star/lang/XUnoTunnel.hpp>
      35                 :            : #include <com/sun/star/lang/XComponent.hpp>
      36                 :            : #include <com/sun/star/lang/DisposedException.hpp>
      37                 :            : #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
      38                 :            : #include <com/sun/star/beans/NamedValue.hpp>
      39                 :            : 
      40                 :            : #include <PackageConstants.hxx>
      41                 :            : 
      42                 :            : #include <cppuhelper/typeprovider.hxx>
      43                 :            : #include <cppuhelper/exc_hlp.hxx>
      44                 :            : #include <rtl/logfile.hxx>
      45                 :            : #include <rtl/instance.hxx>
      46                 :            : 
      47                 :            : #include <comphelper/processfactory.hxx>
      48                 :            : #include <comphelper/componentcontext.hxx>
      49                 :            : #include <comphelper/storagehelper.hxx>
      50                 :            : #include <comphelper/ofopxmlhelper.hxx>
      51                 :            : 
      52                 :            : #include "xstorage.hxx"
      53                 :            : #include "owriteablestream.hxx"
      54                 :            : #include "disposelistener.hxx"
      55                 :            : #include "switchpersistencestream.hxx"
      56                 :            : #include "ohierarchyholder.hxx"
      57                 :            : 
      58                 :            : using namespace ::com::sun::star;
      59                 :            : 
      60                 :            : //=========================================================
      61                 :            : 
      62                 :            : typedef ::std::list< uno::WeakReference< lang::XComponent > > WeakComponentList;
      63                 :            : 
      64                 :            : struct StorInternalData_Impl
      65                 :            : {
      66                 :            :     SotMutexHolderRef m_rSharedMutexRef;
      67                 :            :     ::cppu::OMultiTypeInterfaceContainerHelper m_aListenersContainer; // list of listeners
      68                 :            :     ::cppu::OTypeCollection* m_pTypeCollection;
      69                 :            :     sal_Bool m_bIsRoot;
      70                 :            :     sal_Int32 m_nStorageType; // the mode in wich the storage is used
      71                 :            :     sal_Bool m_bReadOnlyWrap;
      72                 :            : 
      73                 :            :     OChildDispListener_Impl* m_pSubElDispListener;
      74                 :            : 
      75                 :            :     WeakComponentList m_aOpenSubComponentsList;
      76                 :            : 
      77                 :            :     ::rtl::Reference< OHierarchyHolder_Impl > m_rHierarchyHolder;
      78                 :            : 
      79                 :            :     // the mutex reference MUST NOT be empty
      80                 :      35422 :     StorInternalData_Impl( const SotMutexHolderRef& rMutexRef, sal_Bool bRoot, sal_Int32 nStorageType, sal_Bool bReadOnlyWrap )
      81                 :            :     : m_rSharedMutexRef( rMutexRef )
      82                 :      35422 :     , m_aListenersContainer( rMutexRef->GetMutex() )
      83                 :            :     , m_pTypeCollection( NULL )
      84                 :            :     , m_bIsRoot( bRoot )
      85                 :            :     , m_nStorageType( nStorageType )
      86                 :            :     , m_bReadOnlyWrap( bReadOnlyWrap )
      87 [ +  - ][ +  - ]:      70844 :     , m_pSubElDispListener( NULL )
      88                 :      35422 :     {}
      89                 :            : 
      90                 :            :     ~StorInternalData_Impl();
      91                 :            : };
      92                 :            : 
      93                 :            : //=========================================================
      94                 :            : ::rtl::OUString GetNewTempFileURL( const uno::Reference< lang::XMultiServiceFactory > xFactory );
      95                 :            : 
      96                 :            : // static
      97                 :         65 : void OStorage_Impl::completeStorageStreamCopy_Impl(
      98                 :            :                             const uno::Reference< io::XStream >& xSource,
      99                 :            :                             const uno::Reference< io::XStream >& xDest,
     100                 :            :                             sal_Int32 nStorageType,
     101                 :            :                             const uno::Sequence< uno::Sequence< beans::StringPair > >& aRelInfo )
     102                 :            : {
     103         [ +  - ]:         65 :         uno::Reference< beans::XPropertySet > xSourceProps( xSource, uno::UNO_QUERY );
     104         [ +  - ]:         65 :         uno::Reference< beans::XPropertySet > xDestProps( xDest, uno::UNO_QUERY );
     105 [ +  - ][ -  + ]:         65 :         if ( !xSourceProps.is() || !xDestProps.is() )
                 [ -  + ]
     106 [ #  # ][ #  # ]:          0 :             throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
     107                 :            : 
     108 [ +  - ][ +  - ]:         65 :         uno::Reference< io::XOutputStream > xDestOutStream = xDest->getOutputStream();
     109         [ -  + ]:         65 :         if ( !xDestOutStream.is() )
     110 [ #  # ][ #  # ]:          0 :             throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
     111                 :            : 
     112 [ +  - ][ +  - ]:         65 :         uno::Reference< io::XInputStream > xSourceInStream = xSource->getInputStream();
     113         [ -  + ]:         65 :         if ( !xSourceInStream.is() )
     114 [ #  # ][ #  # ]:          0 :             throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
     115                 :            : 
     116                 :            :         // TODO: headers of encripted streams should be copied also
     117         [ +  - ]:         65 :         ::comphelper::OStorageHelper::CopyInputToOutput( xSourceInStream, xDestOutStream );
     118                 :            : 
     119         [ +  - ]:         65 :         uno::Sequence< ::rtl::OUString > aPropNames( 1 );
     120 [ +  - ][ +  - ]:         65 :         aPropNames[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Compressed" ) );
     121                 :            : 
     122         [ +  - ]:         65 :         if ( nStorageType == embed::StorageFormats::PACKAGE )
     123                 :            :         {
     124         [ +  - ]:         65 :             aPropNames.realloc( 3 );
     125 [ +  - ][ +  - ]:         65 :             aPropNames[1] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MediaType" ) );
     126 [ +  - ][ +  - ]:         65 :             aPropNames[2] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "UseCommonStoragePasswordEncryption" ) );
     127                 :            :         }
     128         [ #  # ]:          0 :         else if ( nStorageType == embed::StorageFormats::OFOPXML )
     129                 :            :         {
     130                 :            :             // TODO/LATER: in future it might make sence to provide the stream if there is one
     131         [ #  # ]:          0 :             uno::Reference< embed::XRelationshipAccess > xRelAccess( xDest, uno::UNO_QUERY_THROW );
     132 [ #  # ][ #  # ]:          0 :             xRelAccess->clearRelationships();
     133 [ #  # ][ #  # ]:          0 :             xRelAccess->insertRelationships( aRelInfo, sal_False );
     134                 :            : 
     135         [ #  # ]:          0 :             aPropNames.realloc( 2 );
     136 [ #  # ][ #  # ]:          0 :             aPropNames[1] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MediaType" ) );
     137                 :            :         }
     138                 :            : 
     139         [ +  + ]:        260 :         for ( int ind = 0; ind < aPropNames.getLength(); ind++ )
     140 [ +  - ][ +  - ]:        260 :             xDestProps->setPropertyValue( aPropNames[ind], xSourceProps->getPropertyValue( aPropNames[ind] ) );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
     141                 :         65 : }
     142                 :            : 
     143                 :          0 : uno::Reference< io::XInputStream > GetSeekableTempCopy( uno::Reference< io::XInputStream > xInStream,
     144                 :            :                                                         uno::Reference< lang::XMultiServiceFactory > xFactory )
     145                 :            : {
     146                 :            :     uno::Reference < io::XOutputStream > xTempOut(
     147         [ #  # ]:          0 :                         xFactory->createInstance ( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.io.TempFile" ) ) ),
     148 [ #  # ][ #  # ]:          0 :                         uno::UNO_QUERY );
                 [ #  # ]
     149         [ #  # ]:          0 :     uno::Reference < io::XInputStream > xTempIn( xTempOut, uno::UNO_QUERY );
     150                 :            : 
     151 [ #  # ][ #  # ]:          0 :     if ( !xTempOut.is() || !xTempIn.is() )
                 [ #  # ]
     152 [ #  # ][ #  # ]:          0 :         throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
     153                 :            : 
     154         [ #  # ]:          0 :     ::comphelper::OStorageHelper::CopyInputToOutput( xInStream, xTempOut );
     155 [ #  # ][ #  # ]:          0 :     xTempOut->closeOutput();
     156                 :            : 
     157                 :          0 :     return xTempIn;
     158                 :            : }
     159                 :            : 
     160         [ +  - ]:      33885 : StorInternalData_Impl::~StorInternalData_Impl()
     161                 :            : {
     162         [ -  + ]:      33885 :     if ( m_pTypeCollection )
     163 [ #  # ][ #  # ]:          0 :         delete m_pTypeCollection;
     164                 :      33885 : }
     165                 :            : 
     166                 :            : 
     167                 :      43436 : SotElement_Impl::SotElement_Impl( const ::rtl::OUString& rName, sal_Bool bStor, sal_Bool bNew )
     168                 :            : : m_aName( rName )
     169                 :            : , m_aOriginalName( rName )
     170                 :            : , m_bIsRemoved( sal_False )
     171                 :            : , m_bIsInserted( bNew )
     172                 :            : , m_bIsStorage( bStor )
     173                 :            : , m_pStorage( NULL )
     174                 :      43436 : , m_pStream( NULL )
     175                 :            : {
     176                 :      43436 : }
     177                 :            : 
     178                 :      41037 : SotElement_Impl::~SotElement_Impl()
     179                 :            : {
     180         [ +  + ]:      41037 :     if ( m_pStorage )
     181 [ +  - ][ +  - ]:      27463 :         delete m_pStorage;
     182                 :            : 
     183         [ +  + ]:      41037 :     if ( m_pStream )
     184 [ +  - ][ +  - ]:       5907 :         delete m_pStream;
     185                 :      41037 : }
     186                 :            : 
     187                 :            : //-----------------------------------------------
     188                 :            : // most of properties are holt by the storage but are not used
     189                 :       1283 : OStorage_Impl::OStorage_Impl(   uno::Reference< io::XInputStream > xInputStream,
     190                 :            :                                 sal_Int32 nMode,
     191                 :            :                                 uno::Sequence< beans::PropertyValue > xProperties,
     192                 :            :                                 uno::Reference< lang::XMultiServiceFactory > xFactory,
     193                 :            :                                 sal_Int32 nStorageType )
     194         [ +  - ]:       1283 : : m_rMutexRef( new SotMutexHolder )
     195                 :            : , m_pAntiImpl( NULL )
     196                 :            : , m_nStorageMode( nMode & ~embed::ElementModes::SEEKABLE )
     197                 :            : , m_bIsModified( ( nMode & ( embed::ElementModes::WRITE | embed::ElementModes::TRUNCATE ) ) == ( embed::ElementModes::WRITE | embed::ElementModes::TRUNCATE ) )
     198                 :            : , m_bBroadcastModified( sal_False )
     199                 :            : , m_bCommited( sal_False )
     200                 :            : , m_bIsRoot( sal_True )
     201                 :            : , m_bListCreated( sal_False )
     202                 :            : , m_xFactory( xFactory )
     203                 :            : , m_xProperties( xProperties )
     204                 :            : , m_bHasCommonEncryptionData( sal_False )
     205                 :            : , m_pParent( NULL )
     206                 :            : , m_bControlMediaType( sal_False )
     207                 :            : , m_bMTFallbackUsed( sal_False )
     208                 :            : , m_bControlVersion( sal_False )
     209                 :            : , m_pSwitchStream( NULL )
     210                 :            : , m_nStorageType( nStorageType )
     211                 :            : , m_pRelStorElement( NULL )
     212 [ +  - ][ +  - ]:       2566 : , m_nRelInfoStatus( RELINFO_NO_INIT )
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     213                 :            : {
     214                 :            :     // all the checks done below by assertion statements must be done by factory
     215                 :            :     OSL_ENSURE( xInputStream.is(), "No input stream is provided!\n" );
     216                 :            : 
     217         [ +  - ]:       1283 :     m_pSwitchStream = (SwitchablePersistenceStream*) new SwitchablePersistenceStream( xFactory, xInputStream );
     218 [ +  - ][ +  - ]:       1283 :     m_xInputStream = m_pSwitchStream->getInputStream();
     219                 :            : 
     220                 :       1283 :     if ( m_nStorageMode & embed::ElementModes::WRITE )
     221                 :            :     {
     222                 :            :         // check that the stream allows to write
     223                 :            :         OSL_FAIL( "No stream for writing is provided!\n" );
     224                 :            :     }
     225                 :       1283 : }
     226                 :            : 
     227                 :            : //-----------------------------------------------
     228                 :            : // most of properties are holt by the storage but are not used
     229                 :       3588 : OStorage_Impl::OStorage_Impl(   uno::Reference< io::XStream > xStream,
     230                 :            :                                 sal_Int32 nMode,
     231                 :            :                                 uno::Sequence< beans::PropertyValue > xProperties,
     232                 :            :                                 uno::Reference< lang::XMultiServiceFactory > xFactory,
     233                 :            :                                 sal_Int32 nStorageType )
     234         [ +  - ]:       3588 : : m_rMutexRef( new SotMutexHolder )
     235                 :            : , m_pAntiImpl( NULL )
     236                 :            : , m_nStorageMode( nMode & ~embed::ElementModes::SEEKABLE )
     237                 :            : , m_bIsModified( ( nMode & ( embed::ElementModes::WRITE | embed::ElementModes::TRUNCATE ) ) == ( embed::ElementModes::WRITE | embed::ElementModes::TRUNCATE ) )
     238                 :            : , m_bBroadcastModified( sal_False )
     239                 :            : , m_bCommited( sal_False )
     240                 :            : , m_bIsRoot( sal_True )
     241                 :            : , m_bListCreated( sal_False )
     242                 :            : , m_xFactory( xFactory )
     243                 :            : , m_xProperties( xProperties )
     244                 :            : , m_bHasCommonEncryptionData( sal_False )
     245                 :            : , m_pParent( NULL )
     246                 :            : , m_bControlMediaType( sal_False )
     247                 :            : , m_bMTFallbackUsed( sal_False )
     248                 :            : , m_bControlVersion( sal_False )
     249                 :            : , m_pSwitchStream( NULL )
     250                 :            : , m_nStorageType( nStorageType )
     251                 :            : , m_pRelStorElement( NULL )
     252 [ +  - ][ +  - ]:       7176 : , m_nRelInfoStatus( RELINFO_NO_INIT )
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     253                 :            : {
     254                 :            :     // all the checks done below by assertion statements must be done by factory
     255                 :            :     OSL_ENSURE( xStream.is(), "No stream is provided!\n" );
     256                 :            : 
     257         [ +  + ]:       3588 :     if ( m_nStorageMode & embed::ElementModes::WRITE )
     258                 :            :     {
     259         [ +  - ]:       3390 :         m_pSwitchStream = (SwitchablePersistenceStream*) new SwitchablePersistenceStream( xFactory, xStream );
     260 [ +  - ][ +  - ]:       3390 :         m_xStream = static_cast< io::XStream* >( m_pSwitchStream );
     261                 :            :     }
     262                 :            :     else
     263                 :            :     {
     264                 :            :         m_pSwitchStream = (SwitchablePersistenceStream*) new SwitchablePersistenceStream( xFactory,
     265 [ +  - ][ +  - ]:        198 :                                                                                           xStream->getInputStream() );
                 [ +  - ]
     266 [ +  - ][ +  - ]:        198 :         m_xInputStream = m_pSwitchStream->getInputStream();
     267                 :            :     }
     268                 :       3588 : }
     269                 :            : 
     270                 :            : //-----------------------------------------------
     271                 :      30456 : OStorage_Impl::OStorage_Impl(   OStorage_Impl* pParent,
     272                 :            :                                 sal_Int32 nMode,
     273                 :            :                                 uno::Reference< container::XNameContainer > xPackageFolder,
     274                 :            :                                 uno::Reference< lang::XSingleServiceFactory > xPackage,
     275                 :            :                                 uno::Reference< lang::XMultiServiceFactory > xFactory,
     276                 :            :                                 sal_Int32 nStorageType )
     277         [ +  - ]:      30456 : : m_rMutexRef( new SotMutexHolder )
     278                 :            : , m_pAntiImpl( NULL )
     279                 :            : , m_nStorageMode( nMode & ~embed::ElementModes::SEEKABLE )
     280                 :            : , m_bIsModified( ( nMode & ( embed::ElementModes::WRITE | embed::ElementModes::TRUNCATE ) ) == ( embed::ElementModes::WRITE | embed::ElementModes::TRUNCATE ) )
     281                 :            : , m_bBroadcastModified( sal_False )
     282                 :            : , m_bCommited( sal_False )
     283                 :            : , m_bIsRoot( sal_False )
     284                 :            : , m_bListCreated( sal_False )
     285                 :            : , m_xPackageFolder( xPackageFolder )
     286                 :            : , m_xPackage( xPackage )
     287                 :            : , m_xFactory( xFactory )
     288                 :            : , m_bHasCommonEncryptionData( sal_False )
     289                 :            : , m_pParent( pParent ) // can be empty in case of temporary readonly substorages and relation storage
     290                 :            : , m_bControlMediaType( sal_False )
     291                 :            : , m_bMTFallbackUsed( sal_False )
     292                 :            : , m_bControlVersion( sal_False )
     293                 :            : , m_pSwitchStream( NULL )
     294                 :            : , m_nStorageType( nStorageType )
     295                 :            : , m_pRelStorElement( NULL )
     296 [ +  - ][ +  - ]:      60912 : , m_nRelInfoStatus( RELINFO_NO_INIT )
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     297                 :            : {
     298                 :            :     OSL_ENSURE( xPackageFolder.is(), "No package folder!\n" );
     299                 :      30456 : }
     300                 :            : 
     301                 :            : //-----------------------------------------------
     302 [ +  - ][ +  - ]:      33445 : OStorage_Impl::~OStorage_Impl()
                 [ +  - ]
     303                 :            : {
     304                 :            :     {
     305         [ +  - ]:      33445 :         ::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() );
     306         [ +  + ]:      33445 :         if ( m_pAntiImpl ) // root storage wrapper must set this member to NULL before destruction of object
     307                 :            :         {
     308                 :            :             OSL_ENSURE( !m_bIsRoot, "The root storage wrapper must be disposed already" );
     309                 :            : 
     310                 :            :             try {
     311         [ +  - ]:      17362 :                 m_pAntiImpl->InternalDispose( sal_False );
     312                 :            :             }
     313   [ #  #  #  # ]:          0 :             catch ( const uno::Exception& rException )
     314                 :            :             {
     315         [ #  # ]:          0 :                 AddLog( rException.Message );
     316   [ #  #  #  # ]:          0 :                 AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Quiet exception" ) ) );
     317                 :            :             }
     318                 :      17362 :             m_pAntiImpl = NULL;
     319                 :            :         }
     320         [ +  + ]:      16083 :         else if ( !m_aReadOnlyWrapList.empty() )
     321                 :            :         {
     322         [ +  + ]:       1180 :             for ( OStorageList_Impl::iterator pStorageIter = m_aReadOnlyWrapList.begin();
     323                 :        590 :                   pStorageIter != m_aReadOnlyWrapList.end(); ++pStorageIter )
     324                 :            :             {
     325         [ +  - ]:        295 :                 uno::Reference< embed::XStorage > xTmp = pStorageIter->m_xWeakRef;
     326         [ +  - ]:        295 :                 if ( xTmp.is() )
     327                 :            :                     try {
     328         [ +  - ]:        295 :                         pStorageIter->m_pPointer->InternalDispose( sal_False );
     329   [ #  #  #  # ]:          0 :                     } catch( const uno::Exception& rException )
     330                 :            :                     {
     331         [ #  # ]:          0 :                         AddLog( rException.Message );
     332   [ #  #  #  # ]:          0 :                         AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Quiet exception" ) ) );
     333                 :            :                     }
     334                 :        295 :             }
     335                 :            : 
     336                 :        295 :             m_aReadOnlyWrapList.clear();
     337                 :            :         }
     338                 :            : 
     339         [ +  - ]:      33445 :         m_pParent = NULL;
     340                 :            :     }
     341                 :            : 
     342         [ +  + ]:     100228 :     for ( SotElementList_Impl::iterator pElementIter = m_aChildrenList.begin();
     343                 :      50114 :           pElementIter != m_aChildrenList.end(); ++pElementIter )
     344 [ +  - ][ +  - ]:      16669 :         delete *pElementIter;
     345                 :            : 
     346                 :      33445 :     m_aChildrenList.clear();
     347                 :            : 
     348         [ -  + ]:      66890 :     for ( SotElementList_Impl::iterator pDeletedIter = m_aDeletedList.begin();
     349                 :      33445 :           pDeletedIter != m_aDeletedList.end(); ++pDeletedIter )
     350 [ #  # ][ #  # ]:          0 :         delete *pDeletedIter;
     351                 :            : 
     352                 :      33445 :     m_aDeletedList.clear();
     353                 :            : 
     354 [ +  + ][ +  + ]:      33445 :     if ( m_nStorageType == embed::StorageFormats::OFOPXML && m_pRelStorElement )
     355                 :            :     {
     356 [ +  - ][ +  - ]:        711 :         delete m_pRelStorElement;
     357                 :        711 :         m_pRelStorElement = NULL;
     358                 :            :     }
     359                 :            : 
     360         [ +  - ]:      33445 :     m_xPackageFolder = uno::Reference< container::XNameContainer >();
     361         [ +  - ]:      33445 :     m_xPackage = uno::Reference< lang::XSingleServiceFactory >();
     362                 :            : 
     363         [ +  - ]:      33445 :     ::rtl::OUString aPropertyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "URL" ) );
     364         [ +  + ]:      33559 :     for ( sal_Int32 aInd = 0; aInd < m_xProperties.getLength(); ++aInd )
     365                 :            :     {
     366 [ +  - ][ -  + ]:        114 :         if ( m_xProperties[aInd].Name.equals( aPropertyName ) )
     367                 :            :         {
     368                 :            :             // the storage is URL based so all the streams are opened by factory and should be closed
     369                 :            :             try
     370                 :            :             {
     371         [ #  # ]:          0 :                 if ( m_xInputStream.is() )
     372                 :            :                 {
     373 [ #  # ][ #  # ]:          0 :                     m_xInputStream->closeInput();
     374         [ #  # ]:          0 :                     m_xInputStream = uno::Reference< io::XInputStream >();
     375                 :            :                 }
     376                 :            : 
     377         [ #  # ]:          0 :                 if ( m_xStream.is() )
     378                 :            :                 {
     379 [ #  # ][ #  # ]:          0 :                     uno::Reference< io::XInputStream > xInStr = m_xStream->getInputStream();
     380         [ #  # ]:          0 :                     if ( xInStr.is() )
     381 [ #  # ][ #  # ]:          0 :                         xInStr->closeInput();
     382                 :            : 
     383 [ #  # ][ #  # ]:          0 :                     uno::Reference< io::XOutputStream > xOutStr = m_xStream->getOutputStream();
     384         [ #  # ]:          0 :                     if ( xOutStr.is() )
     385 [ #  # ][ #  # ]:          0 :                         xOutStr->closeOutput();
     386                 :            : 
     387         [ #  # ]:          0 :                     m_xStream = uno::Reference< io::XStream >();
     388                 :            :                 }
     389                 :            :             }
     390   [ #  #  #  # ]:          0 :             catch( const uno::Exception& rException )
     391                 :            :             {
     392   [ #  #  #  # ]:          0 :                 AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Quiet exception" ) ) );
     393         [ #  # ]:          0 :                 AddLog( rException.Message );
     394                 :            :             }
     395                 :            :         }
     396                 :      33445 :     }
     397                 :      33445 : }
     398                 :            : 
     399                 :            : //-----------------------------------------------
     400                 :      11126 : void OStorage_Impl::AddLog( const ::rtl::OUString& aMessage )
     401                 :            : {
     402         [ +  + ]:      11126 :     if ( !m_xLogRing.is() )
     403                 :            :     {
     404                 :            :         try
     405                 :            :         {
     406 [ +  - ][ +  - ]:       4096 :             ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() );
     407         [ +  - ]:       4096 :             if ( aContext.is() )
     408 [ +  - ][ +  - ]:       4096 :                 m_xLogRing.set( aContext.getSingleton( "com.sun.star.logging.DocumentIOLogRing" ), uno::UNO_QUERY_THROW );
         [ +  - ][ #  # ]
     409                 :            :         }
     410                 :          0 :         catch( const uno::Exception& )
     411                 :            :         {
     412                 :            :             // No log
     413                 :            :         }
     414                 :            :     }
     415                 :            : 
     416         [ +  - ]:      11126 :     if ( m_xLogRing.is() )
     417                 :      11126 :         m_xLogRing->logString( aMessage );
     418                 :      11126 : }
     419                 :            : 
     420                 :            : //-----------------------------------------------
     421                 :       1334 : void OStorage_Impl::SetReadOnlyWrap( OStorage& aStorage )
     422                 :            : {
     423                 :            :     // Weak reference is used inside the holder so the refcount must not be zero at this point
     424                 :            :     OSL_ENSURE( aStorage.GetRefCount_Impl(), "There must be a reference alive to use this method!\n" );
     425         [ +  - ]:       1334 :     m_aReadOnlyWrapList.push_back( StorageHolder_Impl( &aStorage ) );
     426                 :       1334 : }
     427                 :            : 
     428                 :            : //-----------------------------------------------
     429                 :       1039 : void OStorage_Impl::RemoveReadOnlyWrap( OStorage& aStorage )
     430                 :            : {
     431         [ +  + ]:       3117 :     for ( OStorageList_Impl::iterator pStorageIter = m_aReadOnlyWrapList.begin();
     432                 :       2078 :       pStorageIter != m_aReadOnlyWrapList.end();)
     433                 :            :     {
     434         [ +  - ]:       1039 :         uno::Reference< embed::XStorage > xTmp = pStorageIter->m_xWeakRef;
     435 [ +  + ][ +  - ]:       1039 :         if ( !xTmp.is() || pStorageIter->m_pPointer == &aStorage )
                 [ +  - ]
     436                 :            :         {
     437                 :            :             try {
     438         [ +  - ]:       1039 :                 pStorageIter->m_pPointer->InternalDispose( sal_False );
     439   [ #  #  #  # ]:          0 :             } catch( const uno::Exception& rException )
     440                 :            :             {
     441   [ #  #  #  # ]:          0 :                 AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Quiet exception" ) ) );
     442         [ #  # ]:          0 :                 AddLog( rException.Message );
     443                 :            :             }
     444                 :            : 
     445                 :       1039 :             OStorageList_Impl::iterator pIterToDelete( pStorageIter );
     446                 :       1039 :             ++pStorageIter;
     447         [ +  - ]:       1039 :             m_aReadOnlyWrapList.erase( pIterToDelete );
     448                 :            :         }
     449                 :            :         else
     450                 :          0 :             ++pStorageIter;
     451                 :       1039 :     }
     452                 :       1039 : }
     453                 :            : 
     454                 :            : //-----------------------------------------------
     455                 :       4119 : void OStorage_Impl::OpenOwnPackage()
     456                 :            : {
     457                 :            :     OSL_ENSURE( m_bIsRoot, "Opening of the package has no sence!\n" );
     458                 :            : 
     459         [ +  - ]:       4119 :     ::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() );
     460                 :            : 
     461         [ +  - ]:       4119 :     if ( !m_xPackageFolder.is() )
     462                 :            :     {
     463         [ +  - ]:       4119 :         if ( !m_xPackage.is() )
     464                 :            :         {
     465         [ +  - ]:       4119 :             uno::Sequence< uno::Any > aArguments( 2 );
     466         [ +  + ]:       4119 :             if ( m_nStorageMode & embed::ElementModes::WRITE )
     467 [ +  - ][ +  - ]:       3174 :                 aArguments[ 0 ] <<= m_xStream;
     468                 :            :             else
     469                 :            :             {
     470                 :            :                 OSL_ENSURE( m_xInputStream.is(), "Input stream must be set for readonly access!\n" );
     471 [ +  - ][ +  - ]:        945 :                 aArguments[ 0 ] <<= m_xInputStream;
     472                 :            :                 // TODO: if input stream is not seekable or XSeekable interface is supported
     473                 :            :                 // on XStream object a wrapper must be used
     474                 :            :             }
     475                 :            : 
     476                 :            :             // do not allow elements to remove themself from the old container in case of insertion to another container
     477         [ +  - ]:       4119 :             aArguments[ 1 ] <<= beans::NamedValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "AllowRemoveOnInsert" ) ),
     478 [ +  - ][ +  - ]:       8238 :                                                     uno::makeAny( (sal_Bool)sal_False ) );
                 [ +  - ]
     479                 :            : 
     480                 :       4119 :             sal_Int32 nArgNum = 2;
     481         [ +  + ]:       4233 :             for ( sal_Int32 aInd = 0; aInd < m_xProperties.getLength(); aInd++ )
     482                 :            :             {
     483         [ +  - ]:        171 :                 if ( m_xProperties[aInd].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "RepairPackage" ) )
           [ +  +  -  + ]
                 [ +  + ]
     484         [ +  - ]:         57 :                   || m_xProperties[aInd].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ProgressHandler" ) ) )
     485                 :            :                 {
     486         [ +  - ]:         57 :                     beans::NamedValue aNamedValue( m_xProperties[aInd].Name,
     487         [ +  - ]:        114 :                                                     m_xProperties[aInd].Value );
     488         [ +  - ]:         57 :                     aArguments.realloc( ++nArgNum );
     489 [ +  - ][ +  - ]:         57 :                     aArguments[nArgNum-1] <<= aNamedValue;
     490                 :            :                 }
     491         [ +  - ]:         57 :                 else if ( m_xProperties[aInd].Name == "Password" )
     492                 :            :                 {
     493                 :            :                     // TODO: implement password setting for documents
     494                 :            :                     // the password entry must be removed after setting
     495                 :            :                 }
     496                 :            :             }
     497                 :            : 
     498         [ +  + ]:       4119 :             if ( m_nStorageType == embed::StorageFormats::ZIP )
     499                 :            :             {
     500                 :            :                 // let the package support only plain zip format
     501                 :        387 :                 beans::NamedValue aNamedValue;
     502         [ +  - ]:        387 :                 aNamedValue.Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "StorageFormat" ) );
     503 [ +  - ][ +  - ]:        387 :                 aNamedValue.Value <<= ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ZipFormat" ) );
     504         [ +  - ]:        387 :                 aArguments.realloc( ++nArgNum );
     505 [ +  - ][ +  - ]:        387 :                 aArguments[nArgNum-1] <<= aNamedValue;
     506                 :            :             }
     507         [ +  + ]:       3732 :             else if ( m_nStorageType == embed::StorageFormats::OFOPXML )
     508                 :            :             {
     509                 :            :                 // let the package support OFOPXML media type handling
     510                 :        463 :                 beans::NamedValue aNamedValue;
     511         [ +  - ]:        463 :                 aNamedValue.Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "StorageFormat" ) );
     512 [ +  - ][ +  - ]:        463 :                 aNamedValue.Value <<= ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OFOPXMLFormat" ) );
     513         [ +  - ]:        463 :                 aArguments.realloc( ++nArgNum );
     514 [ +  - ][ +  - ]:        463 :                 aArguments[nArgNum-1] <<= aNamedValue;
     515                 :            :             }
     516                 :            : 
     517                 :            :             m_xPackage = uno::Reference< lang::XSingleServiceFactory > (
     518 [ +  - ][ +  - ]:       8238 :                                         GetServiceFactory()->createInstanceWithArguments(
     519                 :            :                                             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.packages.comp.ZipPackage" ) ),
     520                 :       4119 :                                             aArguments ),
     521 [ +  - ][ +  + ]:       8238 :                                         uno::UNO_QUERY );
         [ +  - ][ +  - ]
                 [ +  - ]
     522                 :            :         }
     523                 :            : 
     524         [ +  - ]:       4105 :         uno::Reference< container::XHierarchicalNameAccess > xHNameAccess( m_xPackage, uno::UNO_QUERY );
     525                 :            :         OSL_ENSURE( xHNameAccess.is(), "The package could not be created!\n" );
     526                 :            : 
     527         [ +  - ]:       4105 :         if ( xHNameAccess.is() )
     528                 :            :         {
     529 [ +  - ][ +  - ]:       4105 :             uno::Any aFolder = xHNameAccess->getByHierarchicalName( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/" ) ) );
                 [ +  - ]
     530         [ +  - ]:       4105 :             aFolder >>= m_xPackageFolder;
     531                 :       4119 :         }
     532                 :            :     }
     533                 :            : 
     534                 :            :     OSL_ENSURE( m_xPackageFolder.is(), "The package root folder can not be opened!\n" );
     535         [ -  + ]:       4105 :     if ( !m_xPackageFolder.is() )
     536 [ #  # ][ #  # ]:       4119 :         throw embed::InvalidStorageException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
                 [ +  - ]
     537                 :       4105 : }
     538                 :            : 
     539                 :            : //-----------------------------------------------
     540                 :       4119 : uno::Reference< lang::XMultiServiceFactory > OStorage_Impl::GetServiceFactory()
     541                 :            : {
     542         [ +  - ]:       4119 :     if ( m_xFactory.is() )
     543                 :       4119 :         return m_xFactory;
     544                 :            : 
     545                 :       4119 :     return ::comphelper::getProcessServiceFactory();
     546                 :            : }
     547                 :            : 
     548                 :            : //-----------------------------------------------
     549                 :        570 : SotElementList_Impl& OStorage_Impl::GetChildrenList()
     550                 :            : {
     551         [ +  - ]:        570 :     ::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() );
     552                 :            : 
     553         [ +  - ]:        570 :     ReadContents();
     554         [ +  - ]:        570 :     return m_aChildrenList;
     555                 :            : }
     556                 :            : 
     557                 :            : //-----------------------------------------------
     558                 :      30795 : void OStorage_Impl::GetStorageProperties()
     559                 :            : {
     560         [ +  + ]:      30795 :     if ( m_nStorageType == embed::StorageFormats::PACKAGE )
     561                 :            :     {
     562         [ +  - ]:      27843 :         uno::Reference< beans::XPropertySet > xProps( m_xPackageFolder, uno::UNO_QUERY_THROW );
     563                 :            : 
     564         [ +  + ]:      27843 :         if ( !m_bControlMediaType )
     565                 :            :         {
     566         [ +  - ]:      24508 :             uno::Reference< beans::XPropertySet > xPackageProps( m_xPackage, uno::UNO_QUERY_THROW );
     567 [ +  - ][ +  - ]:      24508 :             xPackageProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( MEDIATYPE_FALLBACK_USED_PROPERTY ) ) ) >>= m_bMTFallbackUsed;
                 [ +  - ]
     568                 :            : 
     569 [ +  - ][ +  - ]:      24508 :             xProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MediaType" ) ) ) >>= m_aMediaType;
                 [ +  - ]
     570                 :      24508 :             m_bControlMediaType = sal_True;
     571                 :            :         }
     572                 :            : 
     573         [ +  + ]:      27843 :         if ( !m_bControlVersion )
     574                 :            :         {
     575 [ +  - ][ +  - ]:      24685 :             xProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Version" ) ) ) >>= m_aVersion;
                 [ +  - ]
     576                 :      24685 :             m_bControlVersion = sal_True;
     577                 :      27843 :         }
     578                 :            :     }
     579                 :            : 
     580                 :            :     // the properties of OFOPXML will be handled directly
     581                 :      30795 : }
     582                 :            : 
     583                 :            : //-----------------------------------------------
     584                 :       1129 : void OStorage_Impl::ReadRelInfoIfNecessary()
     585                 :            : {
     586         [ -  + ]:       1129 :     if ( m_nStorageType != embed::StorageFormats::OFOPXML )
     587                 :       1129 :         return;
     588                 :            : 
     589         [ +  + ]:       1129 :     if ( m_nRelInfoStatus == RELINFO_NO_INIT )
     590                 :            :     {
     591                 :            :         // Init from original stream
     592         [ +  - ]:        463 :         uno::Reference< io::XInputStream > xRelInfoStream = GetRelInfoStreamForName( ::rtl::OUString() );
     593         [ +  + ]:        463 :         if ( xRelInfoStream.is() )
     594                 :            :             m_aRelInfo = ::comphelper::OFOPXMLHelper::ReadRelationsInfoSequence(
     595                 :            :                                     xRelInfoStream,
     596                 :            :                                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_rels/.rels" ) ),
     597 [ +  - ][ +  - ]:        406 :                                     m_xFactory );
         [ +  - ][ +  - ]
     598                 :            : 
     599                 :        463 :         m_nRelInfoStatus = RELINFO_READ;
     600                 :            :     }
     601         [ -  + ]:        666 :     else if ( m_nRelInfoStatus == RELINFO_CHANGED_STREAM )
     602                 :            :     {
     603                 :            :         // Init from the new stream
     604                 :            :         try
     605                 :            :         {
     606         [ #  # ]:          0 :             if ( m_xNewRelInfoStream.is() )
     607                 :            :                 m_aRelInfo = ::comphelper::OFOPXMLHelper::ReadRelationsInfoSequence(
     608                 :            :                                         m_xNewRelInfoStream,
     609                 :            :                                         ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_rels/.rels" ) ),
     610 [ #  # ][ #  # ]:          0 :                                         m_xFactory );
         [ #  # ][ #  # ]
                 [ #  # ]
     611                 :            : 
     612                 :          0 :             m_nRelInfoStatus = RELINFO_CHANGED_STREAM_READ;
     613                 :            :         }
     614                 :          0 :         catch( const uno::Exception& )
     615                 :            :         {
     616                 :          0 :             m_nRelInfoStatus = RELINFO_CHANGED_BROKEN;
     617                 :            :         }
     618                 :            :     }
     619                 :            : }
     620                 :            : 
     621                 :            : //-----------------------------------------------
     622                 :      97171 : void OStorage_Impl::ReadContents()
     623                 :            : {
     624         [ +  - ]:      97171 :     ::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() );
     625                 :            : 
     626         [ +  + ]:      97171 :     if ( m_bListCreated )
     627                 :      97157 :         return;
     628                 :            : 
     629         [ +  + ]:      20375 :     if ( m_bIsRoot )
     630         [ +  + ]:       4119 :         OpenOwnPackage();
     631                 :            : 
     632         [ +  - ]:      20361 :     uno::Reference< container::XEnumerationAccess > xEnumAccess( m_xPackageFolder, uno::UNO_QUERY );
     633         [ -  + ]:      20361 :     if ( !xEnumAccess.is() )
     634 [ #  # ][ #  # ]:          0 :         throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
     635                 :            : 
     636 [ +  - ][ +  - ]:      20361 :     uno::Reference< container::XEnumeration > xEnum = xEnumAccess->createEnumeration();
     637         [ -  + ]:      20361 :     if ( !xEnum.is() )
     638 [ #  # ][ #  # ]:          0 :         throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
     639                 :            : 
     640                 :      20361 :     m_bListCreated = sal_True;
     641                 :            : 
     642 [ +  - ][ +  - ]:      31860 :     while( xEnum->hasMoreElements() )
                 [ +  + ]
     643                 :            :     {
     644                 :            :         try {
     645                 :      11499 :             uno::Reference< container::XNamed > xNamed;
     646 [ +  - ][ +  - ]:      11499 :             xEnum->nextElement() >>= xNamed;
                 [ +  - ]
     647                 :            : 
     648         [ -  + ]:      11499 :             if ( !xNamed.is() )
     649                 :            :             {
     650                 :            :                 OSL_FAIL( "XNamed is not supported!\n" );
     651 [ #  # ][ #  # ]:          0 :                 throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
     652                 :            :             }
     653                 :            : 
     654 [ +  - ][ +  - ]:      11499 :             ::rtl::OUString aName = xNamed->getName();
     655                 :            :             OSL_ENSURE( !aName.isEmpty(), "Empty name!\n" );
     656                 :            : 
     657         [ +  - ]:      11499 :             uno::Reference< container::XNameContainer > xNameContainer( xNamed, uno::UNO_QUERY );
     658                 :            : 
     659         [ +  - ]:      11499 :             SotElement_Impl* pNewElement = new SotElement_Impl( aName, xNameContainer.is(), sal_False );
     660 [ +  + ][ +  + ]:      11499 :             if ( m_nStorageType == embed::StorageFormats::OFOPXML && aName == "_rels" )
                 [ +  + ]
     661                 :            :             {
     662         [ -  + ]:        597 :                 if ( !pNewElement->m_bIsStorage )
     663 [ #  # ][ #  # ]:          0 :                     throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); // TODO: Unexpected format
     664                 :            : 
     665                 :        597 :                 m_pRelStorElement = pNewElement;
     666         [ +  - ]:        597 :                 CreateRelStorage();
     667                 :            :             }
     668                 :            :             else
     669                 :            :             {
     670         [ -  + ]:      10902 :                 if ( ( m_nStorageMode & embed::ElementModes::TRUNCATE ) == embed::ElementModes::TRUNCATE )
     671                 :            :                 {
     672                 :            :                     // if a storage is truncated all of it elements are marked as deleted
     673                 :          0 :                     pNewElement->m_bIsRemoved = sal_True;
     674                 :            :                 }
     675                 :            : 
     676         [ +  - ]:      10902 :                 m_aChildrenList.push_back( pNewElement );
     677                 :      11499 :             }
     678                 :            :         }
     679   [ #  #  #  # ]:          0 :         catch( const container::NoSuchElementException& rNoSuchElementException )
     680                 :            :         {
     681         [ #  # ]:          0 :             AddLog( rNoSuchElementException.Message );
     682   [ #  #  #  # ]:          0 :             AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "NoSuchElement" ) ) );
     683                 :            : 
     684                 :            :             OSL_FAIL( "hasMoreElements() implementation has problems!\n" );
     685                 :            :             break;
     686                 :            :         }
     687                 :            :     }
     688         [ +  + ]:      20361 :     if ( ( m_nStorageMode & embed::ElementModes::TRUNCATE ) == embed::ElementModes::TRUNCATE )
     689                 :            :     {
     690                 :            :         // if a storage is truncated the relations information should be cleaned
     691         [ +  - ]:        229 :         m_xNewRelInfoStream = uno::Reference< io::XInputStream >();
     692 [ +  - ][ +  - ]:        229 :         m_aRelInfo = uno::Sequence< uno::Sequence< beans::StringPair > >();
                 [ +  - ]
     693                 :        229 :         m_nRelInfoStatus = RELINFO_CHANGED;
     694                 :            :     }
     695                 :            : 
     696                 :            :     // cache changeable folder properties
     697 [ +  - ][ +  - ]:      97171 :     GetStorageProperties();
                 [ +  + ]
     698                 :            : }
     699                 :            : 
     700                 :            : //-----------------------------------------------
     701                 :        396 : void OStorage_Impl::CopyToStorage( const uno::Reference< embed::XStorage >& xDest, sal_Bool bDirect )
     702                 :            : {
     703         [ +  - ]:        396 :     ::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() );
     704                 :            : 
     705         [ +  - ]:        396 :     uno::Reference< beans::XPropertySet > xPropSet( xDest, uno::UNO_QUERY );
     706         [ -  + ]:        396 :     if ( !xPropSet.is() )
     707 [ #  # ][ #  # ]:          0 :         throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 1 );
     708                 :            : 
     709                 :        396 :     sal_Int32 nDestMode = embed::ElementModes::READ;
     710 [ +  - ][ +  - ]:        396 :     xPropSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OpenMode" ) ) ) >>= nDestMode;
                 [ +  - ]
     711                 :            : 
     712         [ -  + ]:        396 :     if ( !( nDestMode & embed::ElementModes::WRITE ) )
     713 [ #  # ][ #  # ]:          0 :         throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); // TODO: access_denied
     714                 :            : 
     715         [ +  - ]:        396 :     ReadContents();
     716                 :            : 
     717         [ -  + ]:        396 :     if ( !m_xPackageFolder.is() )
     718 [ #  # ][ #  # ]:          0 :         throw embed::InvalidStorageException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
     719                 :            : 
     720         [ +  + ]:       1642 :     for ( SotElementList_Impl::iterator pElementIter = m_aChildrenList.begin();
     721                 :        821 :           pElementIter != m_aChildrenList.end(); ++pElementIter )
     722                 :            :     {
     723         [ +  - ]:        425 :         if ( !(*pElementIter)->m_bIsRemoved )
     724         [ +  - ]:        425 :             CopyStorageElement( *pElementIter, xDest, (*pElementIter)->m_aName, bDirect );
     725                 :            :     }
     726                 :            : 
     727                 :            :     // move storage properties to the destination one ( means changeable properties )
     728         [ +  - ]:        396 :     if ( m_nStorageType == embed::StorageFormats::PACKAGE )
     729                 :            :     {
     730         [ +  - ]:        396 :         ::rtl::OUString aMediaTypeString = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MediaType" ) );
     731         [ +  - ]:        396 :         ::rtl::OUString aVersionString = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Version" ) );
     732 [ +  - ][ +  - ]:        396 :         xPropSet->setPropertyValue( aMediaTypeString, uno::makeAny( m_aMediaType ) );
                 [ +  - ]
     733 [ +  - ][ +  - ]:        396 :         xPropSet->setPropertyValue( aVersionString, uno::makeAny( m_aVersion ) );
                 [ +  - ]
     734                 :            :     }
     735                 :            : 
     736         [ +  - ]:        396 :     if ( m_nStorageType == embed::StorageFormats::PACKAGE )
     737                 :            :     {
     738                 :            :         // if this is a root storage, the common key from current one should be moved there
     739                 :        396 :         sal_Bool bIsRoot = sal_False;
     740         [ +  - ]:        396 :         ::rtl::OUString aRootString = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsRoot" ) );
     741 [ +  - ][ +  - ]:        396 :         if ( ( xPropSet->getPropertyValue( aRootString ) >>= bIsRoot ) && bIsRoot )
         [ +  - ][ +  + ]
                 [ +  - ]
           [ +  +  #  # ]
     742                 :            :         {
     743                 :            :             try
     744                 :            :             {
     745         [ +  - ]:          5 :                 uno::Reference< embed::XEncryptionProtectedStorage > xEncr( xDest, uno::UNO_QUERY );
     746         [ +  - ]:          5 :                 if ( xEncr.is() )
     747                 :            :                 {
     748 [ +  - ][ -  + ]:          5 :                     xEncr->setEncryptionData( GetCommonRootEncryptionData().getAsConstNamedValueList() );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     749                 :            : 
     750         [ #  # ]:          0 :                     uno::Sequence< beans::NamedValue > aAlgorithms;
     751         [ #  # ]:          0 :                     uno::Reference< beans::XPropertySet > xPackPropSet( m_xPackage, uno::UNO_QUERY_THROW );
     752         [ #  # ]:          0 :                     xPackPropSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ENCRYPTION_ALGORITHMS_PROPERTY ) ) )
     753 [ #  # ][ #  # ]:          0 :                         >>= aAlgorithms;
                 [ #  # ]
     754 [ #  # ][ #  # ]:          5 :                     xEncr->setEncryptionAlgorithms( aAlgorithms );
                 [ #  # ]
     755                 :          5 :                 }
     756                 :            :             }
     757 [ -  + ][ +  - ]:         10 :             catch( const packages::NoEncryptionException& rNoEncryptionException )
     758                 :            :             {
     759         [ -  + ]:          5 :                 AddLog( rNoEncryptionException.Message );
     760 [ -  + ][ -  + ]:          5 :                 AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "No Encryption" ) ) );
     761                 :            :             }
     762                 :        396 :         }
     763                 :            :     }
     764         [ #  # ]:          0 :     else if ( m_nStorageType == embed::StorageFormats::OFOPXML )
     765                 :            :     {
     766                 :            : 
     767                 :            :         // TODO/LATER: currently the optimization is not active
     768                 :            :         // uno::Reference< io::XInputStream > xRelInfoStream = GetRelInfoStreamForName( ::rtl::OUString() ); // own stream
     769                 :            :         // if ( xRelInfoStream.is() )
     770                 :            :         // {
     771                 :            :         //  // Relations info stream is a writeonly property, introduced only to optimyze copying
     772                 :            :         //  // Should be used carefuly since no check for stream consistency is done, and the stream must not stay locked
     773                 :            :         //
     774                 :            :         //  ::rtl::OUString aRelInfoString = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "RelationsInfoStream" ) );
     775                 :            :         //  xPropSet->setPropertyValue( aRelInfoString, uno::makeAny( GetSeekableTempCopy( xRelInfoStream, m_xFactory ) ) );
     776                 :            :         // }
     777                 :            : 
     778         [ #  # ]:          0 :         uno::Reference< embed::XRelationshipAccess > xRels( xDest, uno::UNO_QUERY );
     779         [ #  # ]:          0 :         if ( !xRels.is() )
     780 [ #  # ][ #  # ]:          0 :             throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 1 );
     781                 :            : 
     782 [ #  # ][ #  # ]:          0 :         xRels->insertRelationships( GetAllRelationshipsIfAny(), sal_False );
         [ #  # ][ #  # ]
     783                 :            :     }
     784                 :            : 
     785                 :            :     // if possible the destination storage should be commited after successful copying
     786         [ +  - ]:        396 :     uno::Reference< embed::XTransactedObject > xObjToCommit( xDest, uno::UNO_QUERY );
     787         [ +  - ]:        396 :     if ( xObjToCommit.is() )
     788 [ +  - ][ +  - ]:        396 :         xObjToCommit->commit();
                 [ +  - ]
     789                 :        396 : }
     790                 :            : 
     791                 :            : //-----------------------------------------------
     792                 :        456 : void OStorage_Impl::CopyStorageElement( SotElement_Impl* pElement,
     793                 :            :                                         uno::Reference< embed::XStorage > xDest,
     794                 :            :                                         ::rtl::OUString aName,
     795                 :            :                                         sal_Bool bDirect )
     796                 :            : {
     797                 :            :     OSL_ENSURE( xDest.is(), "No destination storage!\n" );
     798                 :            :     OSL_ENSURE( !aName.isEmpty(), "Empty element name!\n" );
     799                 :            : 
     800         [ +  - ]:        456 :     ::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() );
     801                 :            : 
     802         [ +  - ]:        456 :     uno::Reference< container::XNameAccess > xDestAccess( xDest, uno::UNO_QUERY );
     803         [ -  + ]:        456 :     if ( !xDestAccess.is() )
     804 [ #  # ][ #  # ]:          0 :         throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
     805                 :            : 
     806 [ +  - ][ +  - ]:        456 :     if ( xDestAccess->hasByName( aName )
         [ -  + ][ #  # ]
                 [ -  + ]
     807 [ #  # ][ #  # ]:          0 :       && !( pElement->m_bIsStorage && xDest->isStorageElement( aName ) ) )
                 [ #  # ]
     808 [ #  # ][ #  # ]:          0 :         xDest->removeElement( aName );
     809                 :            : 
     810         [ +  + ]:        456 :     if ( pElement->m_bIsStorage )
     811                 :            :     {
     812                 :            :         uno::Reference< embed::XStorage > xSubDest =
     813         [ +  - ]:        391 :                                     xDest->openStorageElement(  aName,
     814         [ +  - ]:        391 :                                                                 embed::ElementModes::WRITE );
     815                 :            : 
     816                 :            :         OSL_ENSURE( xSubDest.is(), "No destination substorage!\n" );
     817                 :            : 
     818         [ +  + ]:        391 :         if ( !pElement->m_pStorage )
     819                 :            :         {
     820         [ +  - ]:         77 :             OpenSubStorage( pElement, embed::ElementModes::READ );
     821         [ -  + ]:         77 :             if ( !pElement->m_pStorage )
     822 [ #  # ][ #  # ]:          0 :                 throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
     823                 :            :         }
     824                 :            : 
     825         [ +  - ]:        391 :         pElement->m_pStorage->CopyToStorage( xSubDest, bDirect );
     826                 :            :     }
     827                 :            :     else
     828                 :            :     {
     829         [ +  + ]:         65 :         if ( !pElement->m_pStream )
     830                 :            :         {
     831         [ +  - ]:         20 :             OpenSubStream( pElement );
     832         [ -  + ]:         20 :             if ( !pElement->m_pStream )
     833 [ #  # ][ #  # ]:          0 :                 throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
     834                 :            :         }
     835                 :            : 
     836 [ +  - ][ +  - ]:         65 :         if ( !pElement->m_pStream->IsEncrypted() )
     837                 :            :         {
     838         [ -  + ]:         65 :             if ( bDirect )
     839                 :            :             {
     840                 :            :                 // fill in the properties for the stream
     841         [ #  # ]:          0 :                 uno::Sequence< beans::PropertyValue > aStrProps(0);
     842         [ #  # ]:          0 :                 uno::Sequence< beans::PropertyValue > aSrcPkgProps = pElement->m_pStream->GetStreamProperties();
     843                 :          0 :                 sal_Int32 nNum = 0;
     844         [ #  # ]:          0 :                 for ( int ind = 0; ind < aSrcPkgProps.getLength(); ind++ )
     845                 :            :                 {
     846 [ #  # ][ #  # ]:          0 :                     if ( aSrcPkgProps[ind].Name == "MediaType" || aSrcPkgProps[ind].Name == "Compressed" )
         [ #  # ][ #  # ]
                 [ #  # ]
     847                 :            :                     {
     848         [ #  # ]:          0 :                         aStrProps.realloc( ++nNum );
     849 [ #  # ][ #  # ]:          0 :                         aStrProps[nNum-1].Name = aSrcPkgProps[ind].Name;
     850 [ #  # ][ #  # ]:          0 :                         aStrProps[nNum-1].Value = aSrcPkgProps[ind].Value;
     851                 :            :                     }
     852                 :            :                 }
     853                 :            : 
     854         [ #  # ]:          0 :                 if ( m_nStorageType == embed::StorageFormats::PACKAGE )
     855                 :            :                 {
     856         [ #  # ]:          0 :                     aStrProps.realloc( ++nNum );
     857 [ #  # ][ #  # ]:          0 :                     aStrProps[nNum-1].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "UseCommonStoragePasswordEncryption" ) );
     858 [ #  # ][ #  # ]:          0 :                     aStrProps[nNum-1].Value <<= (sal_Bool)( pElement->m_pStream->UsesCommonEncryption_Impl() );
     859                 :            :                 }
     860         [ #  # ]:          0 :                 else if ( m_nStorageType == embed::StorageFormats::OFOPXML )
     861                 :            :                 {
     862                 :            :                     // TODO/LATER: currently the optimization is not active
     863                 :            :                     // uno::Reference< io::XInputStream > xInStream = GetRelInfoStreamForName( ::rtl::OUString() ); // own rels stream
     864                 :            :                     // if ( xInStream.is() )
     865                 :            :                     // {
     866                 :            :                     //  aStrProps.realloc( ++nNum );
     867                 :            :                     //  aStrProps[nNum-1].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "RelationsInfoStream" ) );
     868                 :            :                     //  aStrProps[nNum-1].Value <<= GetSeekableTempCopy( xInStream, m_xFactory );
     869                 :            :                     // }
     870                 :            : 
     871         [ #  # ]:          0 :                     uno::Reference< embed::XRelationshipAccess > xRels( xDest, uno::UNO_QUERY );
     872         [ #  # ]:          0 :                     if ( !xRels.is() )
     873 [ #  # ][ #  # ]:          0 :                         throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 0 );
     874                 :            : 
     875 [ #  # ][ #  # ]:          0 :                     xRels->insertRelationships( GetAllRelationshipsIfAny(), sal_False );
         [ #  # ][ #  # ]
     876                 :            :                 }
     877                 :            : 
     878         [ #  # ]:          0 :                 uno::Reference< embed::XOptimizedStorage > xOptDest( xDest, uno::UNO_QUERY_THROW );
     879                 :          0 :                 uno::Reference < io::XInputStream > xInputToInsert;
     880                 :            : 
     881 [ #  # ][ #  # ]:          0 :                 if ( pElement->m_pStream->HasTempFile_Impl() || !pElement->m_pStream->m_xPackageStream.is() )
                 [ #  # ]
     882                 :            :                 {
     883                 :            :                     OSL_ENSURE( pElement->m_pStream->m_xPackageStream.is(), "No package stream!" );
     884                 :            : 
     885                 :            :                     // if the stream is modified - the temporary file must be used for insertion
     886 [ #  # ][ #  # ]:          0 :                     xInputToInsert = pElement->m_pStream->GetTempFileAsInputStream();
     887                 :            :                 }
     888                 :            :                 else
     889                 :            :                 {
     890                 :            :                     // for now get just nonseekable access to the stream
     891                 :            :                     // TODO/LATER: the raw stream can be used
     892                 :            : 
     893 [ #  # ][ #  # ]:          0 :                     xInputToInsert = pElement->m_pStream->m_xPackageStream->getDataStream();
                 [ #  # ]
     894                 :            :                 }
     895                 :            : 
     896         [ #  # ]:          0 :                 if ( !xInputToInsert.is() )
     897 [ #  # ][ #  # ]:          0 :                         throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
     898                 :            : 
     899 [ #  # ][ #  # ]:          0 :                 xOptDest->insertStreamElementDirect( aName, xInputToInsert, aStrProps );
         [ #  # ][ #  # ]
     900                 :            :             }
     901                 :            :             else
     902                 :            :             {
     903                 :            :                 uno::Reference< io::XStream > xSubStr =
     904         [ +  - ]:         65 :                                             xDest->openStreamElement( aName,
     905         [ +  - ]:         65 :                                             embed::ElementModes::READWRITE | embed::ElementModes::TRUNCATE );
     906                 :            :                 OSL_ENSURE( xSubStr.is(), "No destination substream!\n" );
     907                 :            : 
     908         [ +  - ]:         65 :                 pElement->m_pStream->CopyInternallyTo_Impl( xSubStr );
     909                 :            :             }
     910                 :            :         }
     911         [ #  # ]:          0 :         else if ( m_nStorageType != embed::StorageFormats::PACKAGE )
     912                 :            :         {
     913                 :            :             OSL_FAIL( "Encryption is only supported in package storage!\n" );
     914 [ #  # ][ #  # ]:          0 :             throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
     915                 :            :         }
     916   [ #  #  #  #  :          0 :         else if ( pElement->m_pStream->HasCachedEncryptionData()
           #  # ][ #  # ]
     917                 :          0 :              && ( pElement->m_pStream->IsModified() || pElement->m_pStream->HasWriteOwner_Impl() ) )
     918                 :            :         {
     919         [ #  # ]:          0 :             ::comphelper::SequenceAsHashMap aCommonEncryptionData;
     920                 :          0 :             sal_Bool bHasCommonEncryptionData = sal_False;
     921                 :            :             try
     922                 :            :             {
     923 [ #  # ][ #  # ]:          0 :                 aCommonEncryptionData = GetCommonRootEncryptionData();
                 [ #  # ]
     924                 :          0 :                 bHasCommonEncryptionData = sal_True;
     925                 :            :             }
     926   [ #  #  #  # ]:          0 :             catch( const packages::NoEncryptionException& rNoEncryptionException )
     927                 :            :             {
     928         [ #  # ]:          0 :                 AddLog( rNoEncryptionException.Message );
     929   [ #  #  #  # ]:          0 :                 AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "No Encryption" ) ) );
     930                 :            :             }
     931                 :            : 
     932 [ #  # ][ #  # ]:          0 :             if ( bHasCommonEncryptionData && ::package::PackageEncryptionDatasEqual( pElement->m_pStream->GetCachedEncryptionData(), aCommonEncryptionData ) )
         [ #  # ][ #  # ]
     933                 :            :             {
     934                 :            :                 // If the stream can be opened with the common storage password
     935                 :            :                 // it must be stored with the common storage password as well
     936                 :            :                 uno::Reference< io::XStream > xDestStream =
     937         [ #  # ]:          0 :                                             xDest->openStreamElement( aName,
     938         [ #  # ]:          0 :                                                 embed::ElementModes::READWRITE | embed::ElementModes::TRUNCATE );
     939                 :            : 
     940         [ #  # ]:          0 :                 pElement->m_pStream->CopyInternallyTo_Impl( xDestStream );
     941                 :            : 
     942         [ #  # ]:          0 :                 uno::Reference< beans::XPropertySet > xProps( xDestStream, uno::UNO_QUERY_THROW );
     943         [ #  # ]:          0 :                 xProps->setPropertyValue(
     944                 :            :                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "UseCommonStoragePasswordEncryption" ) ),
     945 [ #  # ][ #  # ]:          0 :                     uno::Any( (sal_Bool) sal_True ) );
                 [ #  # ]
     946                 :            :             }
     947                 :            :             else
     948                 :            :             {
     949                 :            :                 // the stream is already opened for writing or was changed
     950         [ #  # ]:          0 :                 uno::Reference< embed::XStorage2 > xDest2( xDest, uno::UNO_QUERY_THROW );
     951                 :            :                 uno::Reference< io::XStream > xSubStr =
     952         [ #  # ]:          0 :                                             xDest2->openEncryptedStream( aName,
     953                 :            :                                                 embed::ElementModes::READWRITE | embed::ElementModes::TRUNCATE,
     954 [ #  # ][ #  # ]:          0 :                                                 pElement->m_pStream->GetCachedEncryptionData().getAsConstNamedValueList() );
                 [ #  # ]
     955                 :            :                 OSL_ENSURE( xSubStr.is(), "No destination substream!\n" );
     956                 :            : 
     957         [ #  # ]:          0 :                 pElement->m_pStream->CopyInternallyTo_Impl( xSubStr, pElement->m_pStream->GetCachedEncryptionData() );
     958         [ #  # ]:          0 :             }
     959                 :            :         }
     960                 :            :         else
     961                 :            :         {
     962                 :            :             // the stream is not opened at all, so it can be just opened for reading
     963                 :            :             try
     964                 :            :             {
     965                 :            :                 // If the stream can be opened with the common storage password
     966                 :            :                 // it must be stored with the common storage password as well
     967                 :            : 
     968                 :            :                 uno::Reference< io::XStream > xOwnStream = pElement->m_pStream->GetStream( embed::ElementModes::READ,
     969         [ #  # ]:          0 :                                                                                             sal_False );
     970                 :            :                 uno::Reference< io::XStream > xDestStream =
     971         [ #  # ]:          0 :                                             xDest->openStreamElement( aName,
     972         [ #  # ]:          0 :                                                 embed::ElementModes::READWRITE | embed::ElementModes::TRUNCATE );
     973                 :            :                 OSL_ENSURE( xDestStream.is(), "No destination substream!\n" );
     974 [ #  # ][ #  # ]:          0 :                 completeStorageStreamCopy_Impl( xOwnStream, xDestStream, m_nStorageType, GetAllRelationshipsIfAny() );
                 [ #  # ]
     975                 :            : 
     976         [ #  # ]:          0 :                 uno::Reference< beans::XPropertySet > xProps( xDestStream, uno::UNO_QUERY_THROW );
     977         [ #  # ]:          0 :                 xProps->setPropertyValue(
     978                 :            :                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "UseCommonStoragePasswordEncryption" ) ),
     979 [ #  # ][ #  # ]:          0 :                     uno::Any( (sal_Bool) sal_True ) );
                 [ #  # ]
     980                 :            :             }
     981   [ #  #  #  # ]:          0 :             catch( const packages::WrongPasswordException& rWrongPasswordException )
     982                 :            :             {
     983         [ #  # ]:          0 :                 AddLog( rWrongPasswordException.Message );
     984   [ #  #  #  # ]:          0 :                 AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Handled exception" ) ) );
     985                 :            : 
     986                 :            :                 // If the common storage password does not allow to open the stream
     987                 :            :                 // it could be copyed in raw way, the problem is that the StartKey should be the same
     988                 :            :                 // in the ODF1.2 package, so an invalid package could be produced if the stream
     989                 :            :                 // is copied from ODF1.1 package, where it is allowed to have different StartKeys
     990         [ #  # ]:          0 :                 uno::Reference< embed::XStorageRawAccess > xRawDest( xDest, uno::UNO_QUERY_THROW );
     991         [ #  # ]:          0 :                 uno::Reference< io::XInputStream > xRawInStream = pElement->m_pStream->GetRawInStream();
     992   [ #  #  #  # ]:          0 :                 xRawDest->insertRawEncrStreamElement( aName, xRawInStream );
     993                 :            :             }
     994                 :            :         }
     995         [ +  - ]:        456 :     }
     996                 :        456 : }
     997                 :            : 
     998                 :            : //-----------------------------------------------
     999                 :       1129 : uno::Sequence< uno::Sequence< beans::StringPair > > OStorage_Impl::GetAllRelationshipsIfAny()
    1000                 :            : {
    1001         [ -  + ]:       1129 :     if ( m_nStorageType != embed::StorageFormats::OFOPXML )
    1002                 :          0 :         return uno::Sequence< uno::Sequence< beans::StringPair > >();
    1003                 :            : 
    1004                 :       1129 :     ReadRelInfoIfNecessary();
    1005                 :            : 
    1006 [ +  - ][ +  - ]:       1129 :     if ( m_nRelInfoStatus == RELINFO_READ
                 [ +  + ]
    1007                 :            :       || m_nRelInfoStatus == RELINFO_CHANGED_STREAM_READ || m_nRelInfoStatus == RELINFO_CHANGED )
    1008                 :       1129 :         return m_aRelInfo;
    1009                 :            :     else // m_nRelInfoStatus == RELINFO_CHANGED_BROKEN || m_nRelInfoStatus == RELINFO_BROKEN
    1010                 :            :             throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Wrong relinfo stream!" ) ),
    1011 [ #  # ][ #  # ]:       1129 :                                     uno::Reference< uno::XInterface >() );
    1012                 :            : }
    1013                 :            : 
    1014                 :            : //-----------------------------------------------
    1015                 :          0 : void OStorage_Impl::CopyLastCommitTo( const uno::Reference< embed::XStorage >& xNewStor )
    1016                 :            : {
    1017         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() );
    1018                 :            : 
    1019                 :            :     OSL_ENSURE( m_xPackageFolder.is(), "A commited storage is incomplete!\n" );
    1020         [ #  # ]:          0 :     if ( !m_xPackageFolder.is() )
    1021 [ #  # ][ #  # ]:          0 :         throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    1022                 :            : 
    1023                 :            :     OStorage_Impl aTempRepresent( NULL,
    1024                 :            :                                 embed::ElementModes::READ,
    1025                 :            :                                 m_xPackageFolder,
    1026                 :            :                                 m_xPackage,
    1027                 :            :                                 m_xFactory,
    1028         [ #  # ]:          0 :                                 m_nStorageType);
    1029                 :            : 
    1030                 :            :     // TODO/LATER: could use direct copying
    1031 [ #  # ][ #  # ]:          0 :     aTempRepresent.CopyToStorage( xNewStor, sal_False );
                 [ #  # ]
    1032                 :          0 : }
    1033                 :            : 
    1034                 :            : //-----------------------------------------------
    1035                 :        674 : void OStorage_Impl::InsertIntoPackageFolder( const ::rtl::OUString& aName,
    1036                 :            :                                              const uno::Reference< container::XNameContainer >& xParentPackageFolder )
    1037                 :            : {
    1038         [ +  - ]:        674 :     ::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() );
    1039                 :            : 
    1040                 :            :     OSL_ENSURE( m_xPackageFolder.is(), "An inserted storage is incomplete!\n" );
    1041         [ +  - ]:        674 :     uno::Reference< lang::XUnoTunnel > xTunnel( m_xPackageFolder, uno::UNO_QUERY );
    1042         [ -  + ]:        674 :     if ( !xTunnel.is() )
    1043 [ #  # ][ #  # ]:          0 :         throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    1044                 :            : 
    1045 [ +  - ][ +  - ]:        674 :     xParentPackageFolder->insertByName( aName, uno::makeAny( xTunnel ) );
                 [ +  - ]
    1046                 :            : 
    1047         [ +  - ]:        674 :     m_bCommited = sal_False;
    1048                 :        674 : }
    1049                 :            : 
    1050                 :            : //-----------------------------------------------
    1051                 :       2098 : void OStorage_Impl::Commit()
    1052                 :            : {
    1053         [ +  - ]:       2098 :     ::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() );
    1054                 :            : 
    1055         [ +  + ]:       2098 :     if ( !m_bIsModified )
    1056                 :       2098 :         return;
    1057                 :            : 
    1058                 :            :     // in case of a new empty storage it is possible that the contents are still not read
    1059                 :            :     // ( the storage of course has no contents, but the initialization is postponed till the first use,
    1060                 :            :     //   thus if a new storage was created and commited immediatelly it must be initialized here )
    1061         [ +  - ]:       2044 :     ReadContents();
    1062                 :            : 
    1063                 :            :     // if storage is commited it should have a valid Package representation
    1064                 :            :     OSL_ENSURE( m_xPackageFolder.is(), "The package representation should exist!\n" );
    1065         [ -  + ]:       2044 :     if ( !m_xPackageFolder.is() )
    1066 [ #  # ][ #  # ]:          0 :         throw embed::InvalidStorageException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    1067                 :            : 
    1068                 :            :     OSL_ENSURE( m_nStorageMode & embed::ElementModes::WRITE,
    1069                 :            :                 "Commit of readonly storage, should be detected before!\n" );
    1070                 :            : 
    1071                 :       2044 :     uno::Reference< container::XNameContainer > xNewPackageFolder;
    1072                 :            : 
    1073                 :            :     // here the storage will switch to the temporary package folder
    1074                 :            :     // if the storage was already commited and the parent was not commited after that
    1075                 :            :     // the switch should not be done since the package folder in use is a temporary one;
    1076                 :            :     // it can be detected by m_bCommited flag ( root storage doesn't need temporary representation )
    1077 [ +  + ][ +  - ]:       2044 :     if ( !m_bCommited && !m_bIsRoot )
    1078                 :            :     {
    1079         [ +  - ]:       1706 :         uno::Sequence< uno::Any > aSeq( 1 );
    1080 [ +  - ][ +  - ]:       1706 :         aSeq[0] <<= sal_True;
    1081                 :            : 
    1082                 :            :         xNewPackageFolder = uno::Reference< container::XNameContainer >(
    1083         [ +  - ]:       1706 :                                                     m_xPackage->createInstanceWithArguments( aSeq ),
    1084 [ +  - ][ +  - ]:       1706 :                                                     uno::UNO_QUERY );
         [ +  - ][ +  - ]
    1085                 :            :     }
    1086                 :            :     else
    1087         [ +  - ]:        338 :         xNewPackageFolder = m_xPackageFolder;
    1088                 :            : 
    1089                 :            :     // remove replaced removed elements
    1090         [ -  + ]:       4088 :     for ( SotElementList_Impl::iterator pDeletedIter = m_aDeletedList.begin();
    1091                 :       2044 :           pDeletedIter != m_aDeletedList.end();
    1092                 :            :           ++pDeletedIter )
    1093                 :            :     {
    1094                 :            : 
    1095 [ #  # ][ #  # ]:          0 :         if ( m_nStorageType == embed::StorageFormats::OFOPXML && !(*pDeletedIter)->m_bIsStorage )
                 [ #  # ]
    1096         [ #  # ]:          0 :             RemoveStreamRelInfo( (*pDeletedIter)->m_aOriginalName );
    1097                 :            : 
    1098                 :            :         // the removed elements are not in new temporary storage
    1099 [ #  # ][ #  # ]:          0 :         if ( m_bCommited || m_bIsRoot )
    1100 [ #  # ][ #  # ]:          0 :             xNewPackageFolder->removeByName( (*pDeletedIter)->m_aOriginalName );
    1101 [ #  # ][ #  # ]:          0 :         delete *pDeletedIter;
    1102                 :          0 :         *pDeletedIter = NULL;
    1103                 :            :     }
    1104                 :       2044 :     m_aDeletedList.clear();
    1105                 :            : 
    1106                 :            :     // remove removed elements
    1107                 :       2044 :     SotElementList_Impl::iterator pElementIter = m_aChildrenList.begin();
    1108         [ +  + ]:       5969 :     while (  pElementIter != m_aChildrenList.end() )
    1109                 :            :     {
    1110                 :            :         // renamed and inserted elements must be really inserted to package later
    1111                 :            :         // since thay can conflict with removed elements
    1112                 :            : 
    1113         [ -  + ]:       3925 :         if ( (*pElementIter)->m_bIsRemoved )
    1114                 :            :         {
    1115 [ #  # ][ #  # ]:          0 :             if ( m_nStorageType == embed::StorageFormats::OFOPXML && !(*pElementIter)->m_bIsStorage )
                 [ #  # ]
    1116         [ #  # ]:          0 :                 RemoveStreamRelInfo( (*pElementIter)->m_aOriginalName );
    1117                 :            : 
    1118                 :            :             // the removed elements are not in new temporary storage
    1119 [ #  # ][ #  # ]:          0 :             if ( m_bCommited || m_bIsRoot )
    1120 [ #  # ][ #  # ]:          0 :                 xNewPackageFolder->removeByName( (*pElementIter)->m_aOriginalName );
    1121                 :            : 
    1122                 :          0 :             SotElement_Impl* pToDelete = *pElementIter;
    1123                 :            : 
    1124                 :          0 :             ++pElementIter; // to let the iterator be valid it should be increased before removing
    1125                 :            : 
    1126         [ #  # ]:          0 :             m_aChildrenList.remove( pToDelete );
    1127 [ #  # ][ #  # ]:          0 :             delete pToDelete;
    1128                 :            :         }
    1129                 :            :         else
    1130                 :       3925 :             ++pElementIter;
    1131                 :            :     }
    1132                 :            : 
    1133                 :            :     // there should be no more deleted elements
    1134         [ +  + ]:       5969 :     for ( pElementIter = m_aChildrenList.begin(); pElementIter != m_aChildrenList.end(); ++pElementIter )
    1135                 :            :     {
    1136                 :            :         // if it is a 'duplicate commit' inserted elements must be really inserted to package later
    1137                 :            :         // since thay can conflict with renamed elements
    1138                 :            : 
    1139         [ +  + ]:       3925 :         if ( !(*pElementIter)->m_bIsInserted )
    1140                 :            :         {
    1141                 :            :             // for now stream is opened in direct mode that means that in case
    1142                 :            :             // storage is commited all the streams from it are commited in current state.
    1143                 :            :             // following two steps are separated to allow easily implement transacted mode
    1144                 :            :             // for streams if we need it in future.
    1145                 :            :             // Only hierarchical access uses transacted streams currently
    1146 [ +  + ][ +  + ]:        218 :             if ( !(*pElementIter)->m_bIsStorage && (*pElementIter)->m_pStream
         [ +  - ][ +  + ]
    1147         [ +  - ]:         38 :               && !(*pElementIter)->m_pStream->IsTransacted() )
    1148         [ +  - ]:         38 :                 (*pElementIter)->m_pStream->Commit();
    1149                 :            : 
    1150                 :            :             // if the storage was not open, there is no need to commit it ???
    1151                 :            :             // the storage should be checked that it is commited
    1152 [ +  + ][ +  + ]:        180 :             if ( (*pElementIter)->m_bIsStorage && (*pElementIter)->m_pStorage && (*pElementIter)->m_pStorage->m_bCommited )
         [ +  + ][ +  + ]
    1153                 :            :             {
    1154                 :            :                 // it's temporary PackageFolder should be inserted instead of current one
    1155                 :            :                 // also the new copy of PackageFolder should be used by the children storages
    1156                 :            : 
    1157                 :            :                 // the renamed elements are not in new temporary storage
    1158 [ +  - ][ +  - ]:          8 :                 if ( m_bCommited || m_bIsRoot )
    1159 [ +  - ][ +  - ]:          8 :                     xNewPackageFolder->removeByName( (*pElementIter)->m_aOriginalName );
    1160                 :            : 
    1161         [ +  - ]:          8 :                 (*pElementIter)->m_pStorage->InsertIntoPackageFolder( (*pElementIter)->m_aName, xNewPackageFolder );
    1162                 :            :             }
    1163 [ +  + ][ +  + ]:        172 :             else if ( !(*pElementIter)->m_bIsStorage && (*pElementIter)->m_pStream && (*pElementIter)->m_pStream->m_bFlushed )
         [ +  - ][ +  + ]
    1164                 :            :             {
    1165         [ -  + ]:         38 :                 if ( m_nStorageType == embed::StorageFormats::OFOPXML )
    1166         [ #  # ]:          0 :                     CommitStreamRelInfo( *pElementIter );
    1167                 :            : 
    1168                 :            :                 // the renamed elements are not in new temporary storage
    1169 [ +  - ][ +  + ]:         38 :                 if ( m_bCommited || m_bIsRoot )
    1170 [ +  - ][ +  - ]:         34 :                     xNewPackageFolder->removeByName( (*pElementIter)->m_aOriginalName );
    1171                 :            : 
    1172         [ +  - ]:         38 :                 (*pElementIter)->m_pStream->InsertIntoPackageFolder( (*pElementIter)->m_aName, xNewPackageFolder );
    1173                 :            :             }
    1174 [ +  - ][ +  + ]:        134 :             else if ( !m_bCommited && !m_bIsRoot )
    1175                 :            :             {
    1176                 :            :                 // the element must be just copied to the new temporary package folder
    1177                 :            :                 // the connection with the original package should not be lost just because
    1178                 :            :                 // the element is still refered by the folder in the original hierarchy
    1179 [ +  - ][ +  - ]:          4 :                 uno::Any aPackageElement = m_xPackageFolder->getByName( (*pElementIter)->m_aOriginalName );
    1180 [ +  - ][ +  - ]:          4 :                 xNewPackageFolder->insertByName( (*pElementIter)->m_aName, aPackageElement );
    1181                 :            :             }
    1182         [ -  + ]:        130 :             else if ( (*pElementIter)->m_aName.compareTo( (*pElementIter)->m_aOriginalName ) )
    1183                 :            :             {
    1184                 :            :                 // this is the case when xNewPackageFolder refers to m_xPackageFolder
    1185                 :            :                 // in case the name was changed and it is not a changed storage - rename the element
    1186                 :          0 :                 uno::Reference< container::XNamed > xNamed;
    1187 [ #  # ][ #  # ]:          0 :                 uno::Any aPackageElement = xNewPackageFolder->getByName( (*pElementIter)->m_aOriginalName );
    1188 [ #  # ][ #  # ]:          0 :                 xNewPackageFolder->removeByName( (*pElementIter)->m_aOriginalName );
    1189 [ #  # ][ #  # ]:          0 :                 xNewPackageFolder->insertByName( (*pElementIter)->m_aName, aPackageElement );
    1190                 :            : 
    1191 [ #  # ][ #  # ]:          0 :                 if ( m_nStorageType == embed::StorageFormats::OFOPXML && !(*pElementIter)->m_bIsStorage )
                 [ #  # ]
    1192                 :            :                 {
    1193         [ #  # ]:          0 :                     if ( !(*pElementIter)->m_pStream )
    1194                 :            :                     {
    1195         [ #  # ]:          0 :                         OpenSubStream( *pElementIter );
    1196         [ #  # ]:          0 :                         if ( !(*pElementIter)->m_pStream )
    1197 [ #  # ][ #  # ]:          0 :                             throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    1198                 :            :                     }
    1199                 :            : 
    1200         [ #  # ]:          0 :                     CommitStreamRelInfo( *pElementIter );
    1201                 :          0 :                 }
    1202                 :            :             }
    1203                 :            : 
    1204                 :        180 :             (*pElementIter)->m_aOriginalName = (*pElementIter)->m_aName;
    1205                 :            :         }
    1206                 :            :     }
    1207                 :            : 
    1208         [ +  + ]:       5969 :     for ( pElementIter = m_aChildrenList.begin(); pElementIter != m_aChildrenList.end(); ++pElementIter )
    1209                 :            :     {
    1210                 :            :         // now inserted elements can be inserted to the package
    1211         [ +  + ]:       3925 :         if ( (*pElementIter)->m_bIsInserted )
    1212                 :            :         {
    1213                 :       3745 :             (*pElementIter)->m_aOriginalName = (*pElementIter)->m_aName;
    1214                 :       3745 :             uno::Reference< lang::XUnoTunnel > xNewElement;
    1215                 :            : 
    1216         [ +  + ]:       3745 :             if ( (*pElementIter)->m_bIsStorage )
    1217                 :            :             {
    1218         [ +  - ]:        552 :                 if ( (*pElementIter)->m_pStorage->m_bCommited )
    1219                 :            :                 {
    1220                 :            :                     OSL_ENSURE( (*pElementIter)->m_pStorage, "An inserted storage is incomplete!\n" );
    1221         [ -  + ]:        552 :                     if ( !(*pElementIter)->m_pStorage )
    1222 [ #  # ][ #  # ]:          0 :                         throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    1223                 :            : 
    1224         [ +  - ]:        552 :                     (*pElementIter)->m_pStorage->InsertIntoPackageFolder( (*pElementIter)->m_aName, xNewPackageFolder );
    1225                 :            : 
    1226                 :        552 :                     (*pElementIter)->m_bIsInserted = sal_False;
    1227                 :            :                 }
    1228                 :            :             }
    1229                 :            :             else
    1230                 :            :             {
    1231                 :            :                 OSL_ENSURE( (*pElementIter)->m_pStream, "An inserted stream is incomplete!\n" );
    1232         [ -  + ]:       3193 :                 if ( !(*pElementIter)->m_pStream )
    1233 [ #  # ][ #  # ]:          0 :                     throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    1234                 :            : 
    1235 [ +  - ][ +  - ]:       3193 :                 if ( !(*pElementIter)->m_pStream->IsTransacted() )
    1236         [ +  - ]:       3193 :                     (*pElementIter)->m_pStream->Commit();
    1237                 :            : 
    1238         [ +  - ]:       3193 :                 if ( (*pElementIter)->m_pStream->m_bFlushed )
    1239                 :            :                 {
    1240         [ +  + ]:       3193 :                     if ( m_nStorageType == embed::StorageFormats::OFOPXML )
    1241         [ +  - ]:        459 :                         CommitStreamRelInfo( *pElementIter );
    1242                 :            : 
    1243         [ +  - ]:       3193 :                     (*pElementIter)->m_pStream->InsertIntoPackageFolder( (*pElementIter)->m_aName, xNewPackageFolder );
    1244                 :            : 
    1245                 :       3193 :                     (*pElementIter)->m_bIsInserted = sal_False;
    1246                 :            :                 }
    1247                 :       3745 :             }
    1248                 :            :         }
    1249                 :            :     }
    1250                 :            : 
    1251         [ +  + ]:       2044 :     if ( m_nStorageType == embed::StorageFormats::PACKAGE )
    1252                 :            :     {
    1253                 :            :         // move properties to the destination package folder
    1254         [ +  - ]:       1759 :         uno::Reference< beans::XPropertySet > xProps( xNewPackageFolder, uno::UNO_QUERY );
    1255         [ -  + ]:       1759 :         if ( !xProps.is() )
    1256 [ #  # ][ #  # ]:          0 :             throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    1257                 :            : 
    1258 [ +  - ][ +  - ]:       1759 :         xProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MediaType" ) ), uno::makeAny( m_aMediaType ) );
         [ +  - ][ +  - ]
    1259 [ +  - ][ +  - ]:       1759 :         xProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Version" ) ), uno::makeAny( m_aVersion ) );
         [ +  - ][ +  - ]
    1260                 :            :     }
    1261                 :            : 
    1262         [ +  + ]:       2044 :     if ( m_nStorageType == embed::StorageFormats::OFOPXML )
    1263         [ +  - ]:        285 :         CommitRelInfo( xNewPackageFolder ); // store own relations and commit complete relations storage
    1264                 :            : 
    1265         [ +  + ]:       2044 :     if ( m_bIsRoot )
    1266                 :            :     {
    1267         [ +  - ]:        338 :         uno::Reference< util::XChangesBatch > xChangesBatch( m_xPackage, uno::UNO_QUERY );
    1268                 :            : 
    1269                 :            :         OSL_ENSURE( xChangesBatch.is(), "Impossible to commit package!\n" );
    1270         [ -  + ]:        338 :         if ( !xChangesBatch.is() )
    1271 [ #  # ][ #  # ]:          0 :             throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    1272                 :            : 
    1273                 :            :         try
    1274                 :            :         {
    1275 [ +  - ][ +  - ]:        338 :             xChangesBatch->commitChanges();
    1276                 :            :         }
    1277         [ #  # ]:          0 :         catch( const lang::WrappedTargetException& r )
    1278                 :            :         {
    1279                 :            :             // the wrapped UseBackupException means that the target medium can be corrupted
    1280         [ #  # ]:          0 :             embed::UseBackupException aException;
    1281   [ #  #  #  # ]:          0 :             if ( r.TargetException >>= aException )
    1282                 :            :             {
    1283         [ #  # ]:          0 :                 m_xStream = uno::Reference< io::XStream >();
    1284         [ #  # ]:          0 :                 m_xInputStream = uno::Reference< io::XInputStream >();
    1285         [ #  # ]:          0 :                 throw aException;
    1286                 :            :             }
    1287                 :            : 
    1288         [ #  # ]:          0 :             AddLog( aException.Message );
    1289   [ #  #  #  # ]:          0 :             AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    1290                 :          0 :             throw;
    1291                 :        338 :         }
    1292                 :            :     }
    1293         [ +  - ]:       1706 :     else if ( !m_bCommited )
    1294                 :            :     {
    1295         [ +  - ]:       1706 :         m_xPackageFolder = xNewPackageFolder;
    1296                 :       1706 :         m_bCommited = sal_True;
    1297                 :            :     }
    1298                 :            : 
    1299                 :            :     // after commit the mediatype treated as the correct one
    1300 [ +  - ][ +  + ]:       2098 :     m_bMTFallbackUsed = sal_False;
    1301                 :            : }
    1302                 :            : 
    1303                 :            : //-----------------------------------------------
    1304                 :      10434 : void OStorage_Impl::Revert()
    1305                 :            : {
    1306         [ +  - ]:      10434 :     ::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() );
    1307                 :            : 
    1308         [ -  + ]:      10434 :     if ( !( m_nStorageMode & embed::ElementModes::WRITE ) )
    1309                 :      10434 :         return; // nothing to do
    1310                 :            : 
    1311                 :            :     // all the children must be removed
    1312                 :            :     // they will be created later on demand
    1313                 :            : 
    1314                 :      10434 :     SotElementList_Impl::iterator pElementIter = m_aChildrenList.begin();
    1315         [ +  + ]:      37189 :     while (  pElementIter != m_aChildrenList.end() )
    1316                 :            :     {
    1317         [ +  + ]:      26755 :         if ( (*pElementIter)->m_bIsInserted )
    1318                 :            :         {
    1319                 :      23404 :             SotElement_Impl* pToDelete = *pElementIter;
    1320                 :            : 
    1321                 :      23404 :             ++pElementIter; // to let the iterator be valid it should be increased before removing
    1322                 :            : 
    1323         [ +  - ]:      23404 :             m_aChildrenList.remove( pToDelete );
    1324 [ +  - ][ +  - ]:      23404 :             delete pToDelete;
    1325                 :            :         }
    1326                 :            :         else
    1327                 :            :         {
    1328         [ +  - ]:       3351 :             ClearElement( *pElementIter );
    1329                 :            : 
    1330                 :       3351 :             (*pElementIter)->m_aName = (*pElementIter)->m_aOriginalName;
    1331                 :       3351 :             (*pElementIter)->m_bIsRemoved = sal_False;
    1332                 :            : 
    1333                 :       3351 :             ++pElementIter;
    1334                 :            :         }
    1335                 :            :     }
    1336                 :            : 
    1337                 :            :     // return replaced removed elements
    1338         [ -  + ]:      20868 :     for ( SotElementList_Impl::iterator pDeletedIter = m_aDeletedList.begin();
    1339                 :      10434 :           pDeletedIter != m_aDeletedList.end();
    1340                 :            :           ++pDeletedIter )
    1341                 :            :     {
    1342         [ #  # ]:          0 :         m_aChildrenList.push_back( (*pDeletedIter) );
    1343                 :            : 
    1344         [ #  # ]:          0 :         ClearElement( *pDeletedIter );
    1345                 :            : 
    1346                 :          0 :         (*pDeletedIter)->m_aName = (*pDeletedIter)->m_aOriginalName;
    1347                 :          0 :         (*pDeletedIter)->m_bIsRemoved = sal_False;
    1348                 :            :     }
    1349                 :      10434 :     m_aDeletedList.clear();
    1350                 :            : 
    1351                 :      10434 :     m_bControlMediaType = sal_False;
    1352                 :      10434 :     m_bControlVersion = sal_False;
    1353                 :            : 
    1354         [ +  - ]:      10434 :     GetStorageProperties();
    1355                 :            : 
    1356         [ -  + ]:      10434 :     if ( m_nStorageType == embed::StorageFormats::OFOPXML )
    1357                 :            :     {
    1358                 :            :         // currently the relations storage is changed only on commit
    1359         [ #  # ]:          0 :         m_xNewRelInfoStream = uno::Reference< io::XInputStream >();
    1360 [ #  # ][ #  # ]:          0 :         m_aRelInfo = uno::Sequence< uno::Sequence< beans::StringPair > >();
                 [ #  # ]
    1361                 :      10434 :         m_nRelInfoStatus = RELINFO_NO_INIT;
    1362 [ +  - ][ +  - ]:      10434 :     }
    1363                 :            : }
    1364                 :            : 
    1365                 :            : //-----------------------------------------------
    1366                 :         29 : ::comphelper::SequenceAsHashMap OStorage_Impl::GetCommonRootEncryptionData()
    1367                 :            :     throw ( packages::NoEncryptionException )
    1368                 :            : {
    1369         [ +  - ]:         29 :     ::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() ) ;
    1370                 :            : 
    1371         [ -  + ]:         29 :     if ( m_nStorageType != embed::StorageFormats::PACKAGE )
    1372 [ #  # ][ #  # ]:          0 :         throw packages::NoEncryptionException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    1373                 :            : 
    1374         [ +  - ]:         29 :     if ( m_bIsRoot )
    1375                 :            :     {
    1376         [ +  + ]:         29 :         if ( !m_bHasCommonEncryptionData )
    1377 [ +  - ][ +  - ]:          5 :             throw packages::NoEncryptionException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    1378                 :            : 
    1379         [ +  - ]:         24 :         return m_aCommonEncryptionData;
    1380                 :            :     }
    1381                 :            :     else
    1382                 :            :     {
    1383         [ #  # ]:          0 :         if ( !m_pParent )
    1384 [ #  # ][ #  # ]:          0 :             throw packages::NoEncryptionException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    1385                 :            : 
    1386         [ #  # ]:          0 :         return m_pParent->GetCommonRootEncryptionData();
    1387         [ +  - ]:         29 :     }
    1388                 :            : }
    1389                 :            : 
    1390                 :            : //-----------------------------------------------
    1391                 :      62207 : SotElement_Impl* OStorage_Impl::FindElement( const ::rtl::OUString& rName )
    1392                 :            : {
    1393                 :            :     OSL_ENSURE( !rName.isEmpty(), "Name is empty!" );
    1394                 :            : 
    1395         [ +  - ]:      62207 :     ::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() );
    1396                 :            : 
    1397         [ +  + ]:      62207 :     ReadContents();
    1398                 :            : 
    1399         [ +  + ]:     486352 :     for ( SotElementList_Impl::iterator pElementIter = m_aChildrenList.begin();
    1400                 :     243176 :           pElementIter != m_aChildrenList.end(); ++pElementIter )
    1401                 :            :     {
    1402 [ +  + ][ +  - ]:     198015 :         if ( (*pElementIter)->m_aName == rName && !(*pElementIter)->m_bIsRemoved )
                 [ +  + ]
    1403                 :      17032 :             return *pElementIter;
    1404                 :            :     }
    1405                 :            : 
    1406         [ +  - ]:      62207 :     return NULL;
    1407                 :            : }
    1408                 :            : 
    1409                 :            : //-----------------------------------------------
    1410                 :       4475 : SotElement_Impl* OStorage_Impl::InsertStream( ::rtl::OUString aName, sal_Bool bEncr )
    1411                 :            : {
    1412                 :            :     OSL_ENSURE( m_xPackage.is(), "Not possible to refer to package as to factory!\n" );
    1413         [ -  + ]:       4475 :     if ( !m_xPackage.is() )
    1414 [ #  # ][ #  # ]:          0 :         throw embed::InvalidStorageException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    1415                 :            : 
    1416         [ +  - ]:       4475 :     uno::Sequence< uno::Any > aSeq( 1 );
    1417 [ +  - ][ +  - ]:       4475 :     aSeq[0] <<= sal_False;
    1418         [ +  - ]:       4475 :     uno::Reference< lang::XUnoTunnel > xNewElement( m_xPackage->createInstanceWithArguments( aSeq ),
    1419 [ +  - ][ +  - ]:       4475 :                                                     uno::UNO_QUERY );
    1420                 :            : 
    1421                 :            :     OSL_ENSURE( xNewElement.is(), "Not possible to create a new stream!\n" );
    1422         [ -  + ]:       4475 :     if ( !xNewElement.is() )
    1423 [ #  # ][ #  # ]:          0 :         throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    1424                 :            : 
    1425         [ +  - ]:       4475 :     uno::Reference< packages::XDataSinkEncrSupport > xPackageSubStream( xNewElement, uno::UNO_QUERY );
    1426         [ -  + ]:       4475 :     if ( !xPackageSubStream.is() )
    1427 [ #  # ][ #  # ]:          0 :         throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    1428                 :            : 
    1429                 :            :     OSL_ENSURE( m_nStorageType == embed::StorageFormats::PACKAGE || !bEncr, "Only package storage supports encryption!\n" );
    1430 [ +  + ][ -  + ]:       4475 :     if ( m_nStorageType != embed::StorageFormats::PACKAGE && bEncr )
    1431 [ #  # ][ #  # ]:          0 :         throw packages::NoEncryptionException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    1432                 :            : 
    1433                 :            :     // the mode is not needed for storage stream internal implementation
    1434         [ +  - ]:       4475 :     SotElement_Impl* pNewElement = InsertElement( aName, sal_False );
    1435 [ +  - ][ +  - ]:       4475 :     pNewElement->m_pStream = new OWriteStream_Impl( this, xPackageSubStream, m_xPackage, m_xFactory, bEncr, m_nStorageType, sal_True );
    1436                 :            : 
    1437         [ +  - ]:       4475 :     m_aChildrenList.push_back( pNewElement );
    1438                 :       4475 :     m_bIsModified = sal_True;
    1439                 :       4475 :     m_bBroadcastModified = sal_True;
    1440                 :            : 
    1441         [ +  - ]:       4475 :     return pNewElement;
    1442                 :            : }
    1443                 :            : 
    1444                 :            : //-----------------------------------------------
    1445                 :          0 : SotElement_Impl* OStorage_Impl::InsertRawStream( ::rtl::OUString aName, const uno::Reference< io::XInputStream >& xInStream )
    1446                 :            : {
    1447                 :            :     // insert of raw stream means insert and commit
    1448                 :            :     OSL_ENSURE( m_xPackage.is(), "Not possible to refer to package as to factory!\n" );
    1449         [ #  # ]:          0 :     if ( !m_xPackage.is() )
    1450 [ #  # ][ #  # ]:          0 :         throw embed::InvalidStorageException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    1451                 :            : 
    1452         [ #  # ]:          0 :     if ( m_nStorageType != embed::StorageFormats::PACKAGE )
    1453 [ #  # ][ #  # ]:          0 :         throw packages::NoEncryptionException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    1454                 :            : 
    1455         [ #  # ]:          0 :     uno::Reference< io::XSeekable > xSeek( xInStream, uno::UNO_QUERY );
    1456                 :          0 :     uno::Reference< io::XInputStream > xInStrToInsert = xSeek.is() ? xInStream :
    1457 [ #  # ][ #  # ]:          0 :                                                                      GetSeekableTempCopy( xInStream, GetServiceFactory() );
         [ #  # ][ #  # ]
           [ #  #  #  # ]
                 [ #  # ]
    1458                 :            : 
    1459         [ #  # ]:          0 :     uno::Sequence< uno::Any > aSeq( 1 );
    1460 [ #  # ][ #  # ]:          0 :     aSeq[0] <<= sal_False;
    1461         [ #  # ]:          0 :     uno::Reference< lang::XUnoTunnel > xNewElement( m_xPackage->createInstanceWithArguments( aSeq ),
    1462 [ #  # ][ #  # ]:          0 :                                                     uno::UNO_QUERY );
    1463                 :            : 
    1464                 :            :     OSL_ENSURE( xNewElement.is(), "Not possible to create a new stream!\n" );
    1465         [ #  # ]:          0 :     if ( !xNewElement.is() )
    1466 [ #  # ][ #  # ]:          0 :         throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    1467                 :            : 
    1468         [ #  # ]:          0 :     uno::Reference< packages::XDataSinkEncrSupport > xPackageSubStream( xNewElement, uno::UNO_QUERY );
    1469         [ #  # ]:          0 :     if ( !xPackageSubStream.is() )
    1470 [ #  # ][ #  # ]:          0 :         throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    1471                 :            : 
    1472 [ #  # ][ #  # ]:          0 :     xPackageSubStream->setRawStream( xInStrToInsert );
    1473                 :            : 
    1474                 :            :     // the mode is not needed for storage stream internal implementation
    1475         [ #  # ]:          0 :     SotElement_Impl* pNewElement = InsertElement( aName, sal_False );
    1476 [ #  # ][ #  # ]:          0 :     pNewElement->m_pStream = new OWriteStream_Impl( this, xPackageSubStream, m_xPackage, m_xFactory, sal_True, m_nStorageType, sal_False );
    1477                 :            :     // the stream is inserted and must be treated as a commited one
    1478                 :          0 :     pNewElement->m_pStream->SetToBeCommited();
    1479                 :            : 
    1480         [ #  # ]:          0 :     m_aChildrenList.push_back( pNewElement );
    1481                 :          0 :     m_bIsModified = sal_True;
    1482                 :          0 :     m_bBroadcastModified = sal_True;
    1483                 :            : 
    1484         [ #  # ]:          0 :     return pNewElement;
    1485                 :            : }
    1486                 :            : 
    1487                 :            : //-----------------------------------------------
    1488                 :      27462 : OStorage_Impl* OStorage_Impl::CreateNewStorageImpl( sal_Int32 nStorageMode )
    1489                 :            : {
    1490                 :            :     OSL_ENSURE( m_xPackage.is(), "Not possible to refer to package as to factory!\n" );
    1491         [ -  + ]:      27462 :     if ( !m_xPackage.is() )
    1492 [ #  # ][ #  # ]:          0 :         throw embed::InvalidStorageException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    1493                 :            : 
    1494         [ +  - ]:      27462 :     uno::Sequence< uno::Any > aSeq( 1 );
    1495 [ +  - ][ +  - ]:      27462 :     aSeq[0] <<= sal_True;
    1496         [ +  - ]:      27462 :     uno::Reference< lang::XUnoTunnel > xNewElement( m_xPackage->createInstanceWithArguments( aSeq ),
    1497 [ +  - ][ +  - ]:      27462 :                                                     uno::UNO_QUERY );
    1498                 :            : 
    1499                 :            :     OSL_ENSURE( xNewElement.is(), "Not possible to create a new storage!\n" );
    1500         [ -  + ]:      27462 :     if ( !xNewElement.is() )
    1501 [ #  # ][ #  # ]:          0 :         throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    1502                 :            : 
    1503         [ +  - ]:      27462 :     uno::Reference< container::XNameContainer > xPackageSubFolder( xNewElement, uno::UNO_QUERY );
    1504         [ -  + ]:      27462 :     if ( !xPackageSubFolder.is() )
    1505 [ #  # ][ #  # ]:          0 :         throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    1506                 :            : 
    1507                 :            :     OStorage_Impl* pResult =
    1508 [ +  - ][ +  - ]:      27462 :             new OStorage_Impl( this, nStorageMode, xPackageSubFolder, m_xPackage, m_xFactory, m_nStorageType );
    1509                 :      27462 :     pResult->m_bIsModified = sal_True;
    1510                 :            : 
    1511         [ +  - ]:      27462 :     return pResult;
    1512                 :            : }
    1513                 :            : 
    1514                 :            : //-----------------------------------------------
    1515                 :      27177 : SotElement_Impl* OStorage_Impl::InsertStorage( ::rtl::OUString aName, sal_Int32 nStorageMode )
    1516                 :            : {
    1517         [ +  - ]:      27177 :     SotElement_Impl* pNewElement = InsertElement( aName, sal_True );
    1518                 :            : 
    1519         [ +  - ]:      27177 :     pNewElement->m_pStorage = CreateNewStorageImpl( nStorageMode );
    1520                 :            : 
    1521         [ +  - ]:      27177 :     m_aChildrenList.push_back( pNewElement );
    1522                 :            : 
    1523                 :      27177 :     return pNewElement;
    1524                 :            : }
    1525                 :            : 
    1526                 :            : //-----------------------------------------------
    1527                 :      31652 : SotElement_Impl* OStorage_Impl::InsertElement( ::rtl::OUString aName, sal_Bool bIsStorage )
    1528                 :            : {
    1529                 :            :     OSL_ENSURE( FindElement( aName ) == NULL, "Should not try to insert existing element" );
    1530                 :            : 
    1531         [ +  - ]:      31652 :     ::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() );
    1532                 :            : 
    1533                 :      31652 :     SotElement_Impl* pDeletedElm = NULL;
    1534                 :            : 
    1535         [ +  + ]:     268434 :     for ( SotElementList_Impl::iterator pElementIter = m_aChildrenList.begin();
    1536                 :     134217 :           pElementIter != m_aChildrenList.end(); ++pElementIter )
    1537                 :            :     {
    1538         [ -  + ]:     102565 :         if ( (*pElementIter)->m_aName == aName )
    1539                 :            :         {
    1540                 :            :             OSL_ENSURE( (*pElementIter)->m_bIsRemoved, "Try to insert an element instead of existing one!\n" );
    1541         [ #  # ]:          0 :             if ( (*pElementIter)->m_bIsRemoved )
    1542                 :            :             {
    1543                 :            :                 OSL_ENSURE( !(*pElementIter)->m_bIsInserted, "Inserted elements must be deleted immediatelly!\n" );
    1544                 :          0 :                 pDeletedElm = *pElementIter;
    1545                 :          0 :                 break;
    1546                 :            :             }
    1547                 :            :         }
    1548                 :            :     }
    1549                 :            : 
    1550         [ -  + ]:      31652 :     if ( pDeletedElm )
    1551                 :            :     {
    1552         [ #  # ]:          0 :         if ( pDeletedElm->m_bIsStorage )
    1553         [ #  # ]:          0 :             OpenSubStorage( pDeletedElm, embed::ElementModes::READWRITE );
    1554                 :            :         else
    1555         [ #  # ]:          0 :             OpenSubStream( pDeletedElm );
    1556                 :            : 
    1557         [ #  # ]:          0 :         m_aChildrenList.remove( pDeletedElm );  // correct usage of list ???
    1558         [ #  # ]:          0 :         m_aDeletedList.push_back( pDeletedElm );
    1559                 :            :     }
    1560                 :            : 
    1561                 :            :     // create new element
    1562 [ +  - ][ +  - ]:      31652 :     return new SotElement_Impl( aName, bIsStorage, sal_True );
    1563                 :            : }
    1564                 :            : 
    1565                 :            : //-----------------------------------------------
    1566                 :       2994 : void OStorage_Impl::OpenSubStorage( SotElement_Impl* pElement, sal_Int32 nStorageMode )
    1567                 :            : {
    1568                 :            :     OSL_ENSURE( pElement, "pElement is not set!\n" );
    1569                 :            :     OSL_ENSURE( pElement->m_bIsStorage, "Storage flag is not set!\n" );
    1570                 :            : 
    1571         [ +  - ]:       2994 :     ::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() );
    1572                 :            : 
    1573         [ +  - ]:       2994 :     if ( !pElement->m_pStorage )
    1574                 :            :     {
    1575                 :            :         OSL_ENSURE( !pElement->m_bIsInserted, "Inserted element must be created already!\n" );
    1576                 :            : 
    1577                 :       2994 :         uno::Reference< lang::XUnoTunnel > xTunnel;
    1578 [ +  - ][ +  - ]:       2994 :         m_xPackageFolder->getByName( pElement->m_aOriginalName ) >>= xTunnel;
                 [ +  - ]
    1579         [ -  + ]:       2994 :         if ( !xTunnel.is() )
    1580 [ #  # ][ #  # ]:          0 :             throw container::NoSuchElementException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    1581                 :            : 
    1582         [ +  - ]:       2994 :         uno::Reference< container::XNameContainer > xPackageSubFolder( xTunnel, uno::UNO_QUERY );
    1583                 :            : 
    1584                 :            :         OSL_ENSURE( xPackageSubFolder.is(), "Can not get XNameContainer interface from folder!\n" );
    1585                 :            : 
    1586         [ -  + ]:       2994 :         if ( !xPackageSubFolder.is() )
    1587 [ #  # ][ #  # ]:          0 :             throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    1588                 :            : 
    1589 [ +  - ][ +  - ]:       2994 :         pElement->m_pStorage = new OStorage_Impl( this, nStorageMode, xPackageSubFolder, m_xPackage, m_xFactory, m_nStorageType );
    1590         [ +  - ]:       2994 :     }
    1591                 :       2994 : }
    1592                 :            : 
    1593                 :            : //-----------------------------------------------
    1594                 :       3849 : void OStorage_Impl::OpenSubStream( SotElement_Impl* pElement )
    1595                 :            : {
    1596                 :            :     OSL_ENSURE( pElement, "pElement is not set!\n" );
    1597                 :            :     OSL_ENSURE( !pElement->m_bIsStorage, "Storage flag is set!\n" );
    1598                 :            : 
    1599         [ +  - ]:       3849 :     ::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() );
    1600                 :            : 
    1601         [ +  - ]:       3849 :     if ( !pElement->m_pStream )
    1602                 :            :     {
    1603                 :            :         OSL_ENSURE( !pElement->m_bIsInserted, "Inserted element must be created already!\n" );
    1604                 :            : 
    1605                 :       3849 :         uno::Reference< lang::XUnoTunnel > xTunnel;
    1606 [ +  - ][ +  - ]:       3849 :         m_xPackageFolder->getByName( pElement->m_aOriginalName ) >>= xTunnel;
                 [ +  - ]
    1607         [ -  + ]:       3849 :         if ( !xTunnel.is() )
    1608 [ #  # ][ #  # ]:          0 :             throw container::NoSuchElementException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    1609                 :            : 
    1610         [ +  - ]:       3849 :         uno::Reference< packages::XDataSinkEncrSupport > xPackageSubStream( xTunnel, uno::UNO_QUERY );
    1611         [ -  + ]:       3849 :         if ( !xPackageSubStream.is() )
    1612 [ #  # ][ #  # ]:          0 :             throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    1613                 :            : 
    1614                 :            :         // the stream can never be inserted here, because inserted stream element holds the stream till commit or destruction
    1615 [ +  - ][ +  - ]:       3849 :         pElement->m_pStream = new OWriteStream_Impl( this, xPackageSubStream, m_xPackage, m_xFactory, sal_False, m_nStorageType, sal_False, GetRelInfoStreamForName( pElement->m_aOriginalName ) );
                 [ +  - ]
    1616         [ +  - ]:       3849 :     }
    1617                 :       3849 : }
    1618                 :            : 
    1619                 :            : //-----------------------------------------------
    1620                 :       7966 : uno::Sequence< ::rtl::OUString > OStorage_Impl::GetElementNames()
    1621                 :            : {
    1622         [ +  - ]:       7966 :     ::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() );
    1623                 :            : 
    1624         [ +  - ]:       7966 :     ReadContents();
    1625                 :            : 
    1626                 :       7966 :     sal_uInt32 nSize = m_aChildrenList.size();
    1627         [ +  - ]:       7966 :     uno::Sequence< ::rtl::OUString > aElementNames( nSize );
    1628                 :            : 
    1629                 :       7966 :     sal_uInt32 nInd = 0;
    1630         [ +  + ]:      27072 :     for ( SotElementList_Impl::iterator pElementIter = m_aChildrenList.begin();
    1631                 :      13536 :           pElementIter != m_aChildrenList.end(); ++pElementIter )
    1632                 :            :     {
    1633         [ +  - ]:       5570 :         if ( !(*pElementIter)->m_bIsRemoved )
    1634         [ +  - ]:       5570 :             aElementNames[nInd++] = (*pElementIter)->m_aName;
    1635                 :            :     }
    1636                 :            : 
    1637         [ +  - ]:       7966 :     aElementNames.realloc( nInd );
    1638         [ +  - ]:       7966 :     return aElementNames;
    1639                 :            : }
    1640                 :            : 
    1641                 :            : //-----------------------------------------------
    1642                 :         82 : void OStorage_Impl::RemoveElement( SotElement_Impl* pElement )
    1643                 :            : {
    1644                 :            :     OSL_ENSURE( pElement, "Element must be provided!" );
    1645                 :            : 
    1646         [ -  + ]:         82 :     if ( !pElement )
    1647                 :         82 :         return;
    1648                 :            : 
    1649 [ +  + ][ +  - ]:        161 :     if ( (pElement->m_pStorage && ( pElement->m_pStorage->m_pAntiImpl || !pElement->m_pStorage->m_aReadOnlyWrapList.empty() ))
         [ +  - ][ +  + ]
           [ +  -  -  + ]
                 [ -  + ]
    1650                 :         79 :       || (pElement->m_pStream && ( pElement->m_pStream->m_pAntiImpl || !pElement->m_pStream->m_aInputStreamsList.empty() )) )
    1651 [ #  # ][ #  # ]:          0 :         throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); // TODO: Access denied
    1652                 :            : 
    1653         [ +  - ]:         82 :     if ( pElement->m_bIsInserted )
    1654                 :            :     {
    1655                 :         82 :         m_aChildrenList.remove( pElement );
    1656         [ +  - ]:         82 :         delete pElement; // ???
    1657                 :            :     }
    1658                 :            :     else
    1659                 :            :     {
    1660                 :          0 :         pElement->m_bIsRemoved = sal_True;
    1661                 :          0 :         ClearElement( pElement );
    1662                 :            :     }
    1663                 :            : 
    1664                 :            :     // TODO/OFOPXML: the rel stream should be removed as well
    1665                 :            : }
    1666                 :            : 
    1667                 :            : //-----------------------------------------------
    1668                 :       3351 : void OStorage_Impl::ClearElement( SotElement_Impl* pElement )
    1669                 :            : {
    1670         [ +  + ]:       3351 :     if ( pElement->m_pStorage )
    1671                 :            :     {
    1672         [ +  - ]:       1227 :         delete pElement->m_pStorage;
    1673                 :       1227 :         pElement->m_pStorage = NULL;
    1674                 :            :     }
    1675                 :            : 
    1676         [ +  + ]:       3351 :     if ( pElement->m_pStream )
    1677                 :            :     {
    1678         [ +  - ]:       2062 :         delete pElement->m_pStream;
    1679                 :       2062 :         pElement->m_pStream = NULL;
    1680                 :            :     }
    1681                 :       3351 : }
    1682                 :            : 
    1683                 :            : //-----------------------------------------------
    1684                 :          0 : void OStorage_Impl::CloneStreamElement( const ::rtl::OUString& aStreamName,
    1685                 :            :                                         sal_Bool bEncryptionDataProvided,
    1686                 :            :                                         const ::comphelper::SequenceAsHashMap& aEncryptionData,
    1687                 :            :                                         uno::Reference< io::XStream >& xTargetStream )
    1688                 :            :         throw ( embed::InvalidStorageException,
    1689                 :            :                 lang::IllegalArgumentException,
    1690                 :            :                 packages::WrongPasswordException,
    1691                 :            :                 io::IOException,
    1692                 :            :                 embed::StorageWrappedTargetException,
    1693                 :            :                 uno::RuntimeException )
    1694                 :            : {
    1695                 :          0 :     SotElement_Impl *pElement = FindElement( aStreamName );
    1696         [ #  # ]:          0 :     if ( !pElement )
    1697                 :            :     {
    1698                 :            :         // element does not exist, throw exception
    1699 [ #  # ][ #  # ]:          0 :         throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); // TODO: access_denied
    1700                 :            :     }
    1701         [ #  # ]:          0 :     else if ( pElement->m_bIsStorage )
    1702 [ #  # ][ #  # ]:          0 :         throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    1703                 :            : 
    1704         [ #  # ]:          0 :     if ( !pElement->m_pStream )
    1705                 :          0 :         OpenSubStream( pElement );
    1706                 :            : 
    1707 [ #  # ][ #  # ]:          0 :     if ( pElement->m_pStream && pElement->m_pStream->m_xPackageStream.is() )
                 [ #  # ]
    1708                 :            :     {
    1709                 :            :         // the existence of m_pAntiImpl of the child is not interesting,
    1710                 :            :         // the copy will be created internally
    1711                 :            : 
    1712                 :            :         // usual copying is not applicable here, only last flushed version of the
    1713                 :            :         // child stream should be used for copiing. Probably the children m_xPackageStream
    1714                 :            :         // can be used as a base of a new stream, that would be copied to result
    1715                 :            :         // storage. The only problem is that some package streams can be accessed from outside
    1716                 :            :         // at the same time ( now solwed by wrappers that remember own position ).
    1717                 :            : 
    1718         [ #  # ]:          0 :         if ( bEncryptionDataProvided )
    1719                 :          0 :             pElement->m_pStream->GetCopyOfLastCommit( xTargetStream, aEncryptionData );
    1720                 :            :         else
    1721                 :          0 :             pElement->m_pStream->GetCopyOfLastCommit( xTargetStream );
    1722                 :            :     }
    1723                 :            :     else
    1724 [ #  # ][ #  # ]:          0 :         throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); // TODO: general_error
    1725                 :          0 : }
    1726                 :            : 
    1727                 :            : //-----------------------------------------------
    1728                 :          0 : void OStorage_Impl::RemoveStreamRelInfo( const ::rtl::OUString& aOriginalName )
    1729                 :            : {
    1730                 :            :     // this method should be used only in OStorage_Impl::Commit() method
    1731                 :            :     // the aOriginalName can be empty, in this case the storage relation info should be removed
    1732                 :            : 
    1733 [ #  # ][ #  # ]:          0 :     if ( m_nStorageType == embed::StorageFormats::OFOPXML && m_xRelStorage.is() )
                 [ #  # ]
    1734                 :            :     {
    1735                 :          0 :         ::rtl::OUString aRelStreamName = aOriginalName;
    1736         [ #  # ]:          0 :         aRelStreamName += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".rels" ) );
    1737                 :            : 
    1738 [ #  # ][ #  # ]:          0 :         if ( m_xRelStorage->hasByName( aRelStreamName ) )
                 [ #  # ]
    1739 [ #  # ][ #  # ]:          0 :             m_xRelStorage->removeElement( aRelStreamName );
    1740                 :            :     }
    1741                 :          0 : }
    1742                 :            : 
    1743                 :            : //-----------------------------------------------
    1744                 :        882 : void OStorage_Impl::CreateRelStorage()
    1745                 :            : {
    1746         [ -  + ]:        882 :     if ( m_nStorageType != embed::StorageFormats::OFOPXML )
    1747                 :        882 :         return;
    1748                 :            : 
    1749         [ +  - ]:        882 :     if ( !m_xRelStorage.is() )
    1750                 :            :     {
    1751         [ +  + ]:        882 :         if ( !m_pRelStorElement )
    1752                 :            :         {
    1753         [ +  - ]:        285 :             m_pRelStorElement = new SotElement_Impl( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_rels" ) ), sal_True, sal_True );
    1754                 :        285 :             m_pRelStorElement->m_pStorage = CreateNewStorageImpl( embed::ElementModes::WRITE );
    1755         [ +  - ]:        285 :             if ( m_pRelStorElement->m_pStorage )
    1756                 :        285 :                 m_pRelStorElement->m_pStorage->m_pParent = NULL; // the relation storage is completely controlled by parent
    1757                 :            :         }
    1758                 :            : 
    1759         [ +  + ]:        882 :         if ( !m_pRelStorElement->m_pStorage )
    1760                 :        597 :             OpenSubStorage( m_pRelStorElement, embed::ElementModes::WRITE );
    1761                 :            : 
    1762         [ -  + ]:        882 :         if ( !m_pRelStorElement->m_pStorage )
    1763 [ #  # ][ #  # ]:          0 :             throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    1764                 :            : 
    1765         [ +  - ]:        882 :         OStorage* pResultStorage = new OStorage( m_pRelStorElement->m_pStorage, sal_False );
    1766 [ +  - ][ +  - ]:        882 :         m_xRelStorage = uno::Reference< embed::XStorage >( (embed::XStorage*) pResultStorage );
    1767                 :            :     }
    1768                 :            : }
    1769                 :            : 
    1770                 :            : //-----------------------------------------------
    1771                 :        459 : void OStorage_Impl::CommitStreamRelInfo( SotElement_Impl* pStreamElement )
    1772                 :            : {
    1773                 :            :     // this method should be used only in OStorage_Impl::Commit() method
    1774                 :            : 
    1775                 :            :     // the stream element must be provided
    1776         [ -  + ]:        459 :     if ( !pStreamElement )
    1777 [ #  # ][ #  # ]:          0 :         throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    1778                 :            : 
    1779 [ +  - ][ +  - ]:        459 :     if ( m_nStorageType == embed::StorageFormats::OFOPXML && pStreamElement->m_pStream )
    1780                 :            :     {
    1781                 :            :         OSL_ENSURE( !pStreamElement->m_aName.isEmpty(), "The name must not be empty!\n" );
    1782                 :            : 
    1783         [ +  + ]:        459 :         if ( !m_xRelStorage.is() )
    1784                 :            :         {
    1785                 :            :             // Create new rels storage, this is commit scenario so it must be possible
    1786                 :        228 :             CreateRelStorage();
    1787                 :            :         }
    1788                 :            : 
    1789                 :        459 :         pStreamElement->m_pStream->CommitStreamRelInfo( m_xRelStorage, pStreamElement->m_aOriginalName, pStreamElement->m_aName );
    1790                 :            :     }
    1791                 :        459 : }
    1792                 :            : 
    1793                 :            : //-----------------------------------------------
    1794                 :       4312 : uno::Reference< io::XInputStream > OStorage_Impl::GetRelInfoStreamForName( const ::rtl::OUString& aName )
    1795                 :            : {
    1796         [ +  + ]:       4312 :     if ( m_nStorageType == embed::StorageFormats::OFOPXML )
    1797                 :            :     {
    1798                 :       2352 :         ReadContents();
    1799         [ +  + ]:       2352 :         if ( m_xRelStorage.is() )
    1800                 :            :         {
    1801                 :       1182 :             ::rtl::OUString aRelStreamName = aName;
    1802         [ +  - ]:       1182 :             aRelStreamName += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".rels" ) );
    1803 [ +  - ][ +  + ]:       1182 :             if ( m_xRelStorage->hasByName( aRelStreamName ) )
                 [ +  - ]
    1804                 :            :             {
    1805 [ +  - ][ +  - ]:        600 :                 uno::Reference< io::XStream > xStream = m_xRelStorage->openStreamElement( aRelStreamName, embed::ElementModes::READ );
    1806         [ +  - ]:        600 :                 if ( xStream.is() )
    1807 [ +  - ][ +  - ]:       1182 :                     return xStream->getInputStream();
                 [ -  + ]
    1808         [ +  + ]:       1182 :             }
    1809                 :            :         }
    1810                 :            :     }
    1811                 :            : 
    1812                 :       4312 :     return uno::Reference< io::XInputStream >();
    1813                 :            : }
    1814                 :            : 
    1815                 :            : //-----------------------------------------------
    1816                 :        285 : void OStorage_Impl::CommitRelInfo( const uno::Reference< container::XNameContainer >& xNewPackageFolder )
    1817                 :            : {
    1818                 :            :     // this method should be used only in OStorage_Impl::Commit() method
    1819         [ +  - ]:        285 :     ::rtl::OUString aRelsStorName( RTL_CONSTASCII_USTRINGPARAM( "_rels" ) );
    1820                 :            : 
    1821         [ -  + ]:        285 :     if ( !xNewPackageFolder.is() )
    1822 [ #  # ][ #  # ]:          0 :         throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    1823                 :            : 
    1824         [ +  - ]:        285 :     if ( m_nStorageType == embed::StorageFormats::OFOPXML )
    1825                 :            :     {
    1826 [ +  - ][ -  + ]:        285 :         if ( m_nRelInfoStatus == RELINFO_BROKEN || m_nRelInfoStatus == RELINFO_CHANGED_BROKEN )
    1827 [ #  # ][ #  # ]:          0 :             throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    1828                 :            : 
    1829 [ +  + ][ +  - ]:        285 :         if ( m_nRelInfoStatus == RELINFO_CHANGED
                 [ -  + ]
    1830                 :            :           || m_nRelInfoStatus == RELINFO_CHANGED_STREAM_READ
    1831                 :            :           || m_nRelInfoStatus == RELINFO_CHANGED_STREAM )
    1832                 :            :         {
    1833         [ +  - ]:         57 :             if ( m_nRelInfoStatus == RELINFO_CHANGED )
    1834                 :            :             {
    1835         [ +  - ]:         57 :                 if ( m_aRelInfo.getLength() )
    1836                 :            :                 {
    1837         [ +  - ]:         57 :                     CreateRelStorage();
    1838                 :            : 
    1839                 :            :                     uno::Reference< io::XStream > xRelsStream =
    1840         [ +  - ]:         57 :                         m_xRelStorage->openStreamElement( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".rels" ) ),
    1841 [ +  - ][ +  - ]:         57 :                                                             embed::ElementModes::TRUNCATE | embed::ElementModes::READWRITE );
    1842                 :            : 
    1843 [ +  - ][ +  - ]:         57 :                     uno::Reference< io::XOutputStream > xOutStream = xRelsStream->getOutputStream();
    1844         [ -  + ]:         57 :                     if ( !xOutStream.is() )
    1845 [ #  # ][ #  # ]:          0 :                         throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    1846                 :            : 
    1847         [ +  - ]:         57 :                     ::comphelper::OFOPXMLHelper::WriteRelationsInfoSequence( xOutStream, m_aRelInfo, m_xFactory );
    1848                 :            : 
    1849                 :            :                     // set the mediatype
    1850         [ +  - ]:         57 :                     uno::Reference< beans::XPropertySet > xPropSet( xRelsStream, uno::UNO_QUERY_THROW );
    1851         [ +  - ]:         57 :                     xPropSet->setPropertyValue(
    1852                 :            :                         ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MediaType" ) ),
    1853                 :            :                         uno::makeAny( ::rtl::OUString(
    1854 [ +  - ][ +  - ]:         57 :                              RTL_CONSTASCII_USTRINGPARAM( "application/vnd.openxmlformats-package.relationships+xml" ) ) ) );
         [ +  - ][ +  - ]
    1855                 :            : 
    1856                 :         57 :                     m_nRelInfoStatus = RELINFO_READ;
    1857                 :            :                 }
    1858         [ #  # ]:          0 :                 else if ( m_xRelStorage.is() )
    1859         [ #  # ]:          0 :                     RemoveStreamRelInfo( ::rtl::OUString() ); // remove own rel info
    1860                 :            :             }
    1861 [ #  # ][ #  # ]:          0 :             else if ( m_nRelInfoStatus == RELINFO_CHANGED_STREAM_READ
    1862                 :            :                       || m_nRelInfoStatus == RELINFO_CHANGED_STREAM )
    1863                 :            :             {
    1864         [ #  # ]:          0 :                 CreateRelStorage();
    1865                 :            : 
    1866                 :            :                 uno::Reference< io::XStream > xRelsStream =
    1867         [ #  # ]:          0 :                     m_xRelStorage->openStreamElement( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".rels" ) ),
    1868 [ #  # ][ #  # ]:          0 :                                                         embed::ElementModes::TRUNCATE | embed::ElementModes::READWRITE );
    1869                 :            : 
    1870 [ #  # ][ #  # ]:          0 :                 uno::Reference< io::XOutputStream > xOutputStream = xRelsStream->getOutputStream();
    1871         [ #  # ]:          0 :                 if ( !xOutputStream.is() )
    1872 [ #  # ][ #  # ]:          0 :                     throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    1873                 :            : 
    1874         [ #  # ]:          0 :                 uno::Reference< io::XSeekable > xSeek( m_xNewRelInfoStream, uno::UNO_QUERY_THROW );
    1875 [ #  # ][ #  # ]:          0 :                 xSeek->seek( 0 );
    1876         [ #  # ]:          0 :                 ::comphelper::OStorageHelper::CopyInputToOutput( m_xNewRelInfoStream, xOutputStream );
    1877                 :            : 
    1878                 :            :                 // set the mediatype
    1879         [ #  # ]:          0 :                 uno::Reference< beans::XPropertySet > xPropSet( xRelsStream, uno::UNO_QUERY_THROW );
    1880         [ #  # ]:          0 :                 xPropSet->setPropertyValue(
    1881                 :            :                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MediaType" ) ),
    1882                 :            :                     uno::makeAny( ::rtl::OUString(
    1883 [ #  # ][ #  # ]:          0 :                          RTL_CONSTASCII_USTRINGPARAM( "application/vnd.openxmlformats-package.relationships+xml" ) ) ) );
         [ #  # ][ #  # ]
    1884                 :            : 
    1885         [ #  # ]:          0 :                 m_xNewRelInfoStream = uno::Reference< io::XInputStream >();
    1886         [ #  # ]:          0 :                   if ( m_nRelInfoStatus == RELINFO_CHANGED_STREAM )
    1887                 :            :                 {
    1888 [ #  # ][ #  # ]:          0 :                     m_aRelInfo = uno::Sequence< uno::Sequence< beans::StringPair > >();
                 [ #  # ]
    1889                 :          0 :                     m_nRelInfoStatus = RELINFO_NO_INIT;
    1890                 :            :                 }
    1891                 :            :                 else
    1892                 :          0 :                     m_nRelInfoStatus = RELINFO_READ;
    1893                 :            :             }
    1894                 :            :         }
    1895                 :            : 
    1896         [ +  - ]:        285 :         if ( m_xRelStorage.is() )
    1897                 :            :         {
    1898 [ +  - ][ +  - ]:        285 :             if ( m_xRelStorage->hasElements() )
                 [ +  + ]
    1899                 :            :             {
    1900         [ +  - ]:        114 :                 uno::Reference< embed::XTransactedObject > xTrans( m_xRelStorage, uno::UNO_QUERY_THROW );
    1901         [ +  - ]:        114 :                 if ( xTrans.is() )
    1902 [ +  - ][ +  - ]:        114 :                     xTrans->commit();
    1903                 :            :             }
    1904                 :            : 
    1905 [ +  - ][ +  - ]:        285 :             if ( xNewPackageFolder.is() && xNewPackageFolder->hasByName( aRelsStorName ) )
         [ +  - ][ -  + ]
                 [ -  + ]
    1906 [ #  # ][ #  # ]:          0 :                 xNewPackageFolder->removeByName( aRelsStorName );
    1907                 :            : 
    1908 [ +  - ][ +  - ]:        285 :             if ( !m_xRelStorage->hasElements() )
                 [ +  + ]
    1909                 :            :             {
    1910                 :            :                 // the empty relations storage should not be created
    1911 [ +  - ][ +  - ]:        171 :                 delete m_pRelStorElement;
    1912                 :        171 :                 m_pRelStorElement = NULL;
    1913         [ +  - ]:        171 :                 m_xRelStorage = uno::Reference< embed::XStorage >();
    1914                 :            :             }
    1915 [ +  - ][ +  - ]:        114 :             else if ( m_pRelStorElement && m_pRelStorElement->m_pStorage && xNewPackageFolder.is() )
         [ +  - ][ +  - ]
    1916         [ +  - ]:        114 :                 m_pRelStorElement->m_pStorage->InsertIntoPackageFolder( aRelsStorName, xNewPackageFolder );
    1917                 :            :         }
    1918                 :        285 :     }
    1919                 :        285 : }
    1920                 :            : 
    1921                 :            : //=====================================================
    1922                 :            : // OStorage implementation
    1923                 :            : //=====================================================
    1924                 :            : 
    1925                 :            : //-----------------------------------------------
    1926                 :       1283 : OStorage::OStorage( uno::Reference< io::XInputStream > xInputStream,
    1927                 :            :                     sal_Int32 nMode,
    1928                 :            :                     uno::Sequence< beans::PropertyValue > xProperties,
    1929                 :            :                     uno::Reference< lang::XMultiServiceFactory > xFactory,
    1930                 :            :                     sal_Int32 nStorageType )
    1931 [ +  - ][ +  - ]:       1283 : : m_pImpl( new OStorage_Impl( xInputStream, nMode, xProperties, xFactory, nStorageType ) )
         [ +  - ][ +  - ]
    1932                 :            : {
    1933                 :       1283 :     m_pImpl->m_pAntiImpl = this;
    1934 [ +  - ][ +  - ]:       1283 :     m_pData = new StorInternalData_Impl( m_pImpl->m_rMutexRef, m_pImpl->m_bIsRoot, m_pImpl->m_nStorageType, sal_False );
    1935                 :       1283 : }
    1936                 :            : 
    1937                 :            : //-----------------------------------------------
    1938                 :       3588 : OStorage::OStorage( uno::Reference< io::XStream > xStream,
    1939                 :            :                     sal_Int32 nMode,
    1940                 :            :                     uno::Sequence< beans::PropertyValue > xProperties,
    1941                 :            :                     uno::Reference< lang::XMultiServiceFactory > xFactory,
    1942                 :            :                     sal_Int32 nStorageType )
    1943 [ +  - ][ +  - ]:       3588 : : m_pImpl( new OStorage_Impl( xStream, nMode, xProperties, xFactory, nStorageType ) )
         [ +  - ][ +  - ]
    1944                 :            : {
    1945                 :       3588 :     m_pImpl->m_pAntiImpl = this;
    1946 [ +  - ][ +  - ]:       3588 :     m_pData = new StorInternalData_Impl( m_pImpl->m_rMutexRef, m_pImpl->m_bIsRoot, m_pImpl->m_nStorageType, sal_False );
    1947                 :       3588 : }
    1948                 :            : 
    1949                 :            : //-----------------------------------------------
    1950                 :      30551 : OStorage::OStorage( OStorage_Impl* pImpl, sal_Bool bReadOnlyWrap )
    1951                 :      30551 : : m_pImpl( pImpl )
    1952                 :            : {
    1953                 :            :     // this call can be done only from OStorage_Impl implementation to create child storage
    1954                 :            :     OSL_ENSURE( m_pImpl && m_pImpl->m_rMutexRef.Is(), "The provided pointer & mutex MUST NOT be empty!\n" );
    1955                 :            : 
    1956 [ +  - ][ +  - ]:      30551 :     m_pData = new StorInternalData_Impl( m_pImpl->m_rMutexRef, m_pImpl->m_bIsRoot, m_pImpl->m_nStorageType, bReadOnlyWrap );
    1957                 :            : 
    1958                 :            :     OSL_ENSURE( ( m_pImpl->m_nStorageMode & embed::ElementModes::WRITE ) == embed::ElementModes::WRITE ||
    1959                 :            :                     m_pData->m_bReadOnlyWrap,
    1960                 :            :                 "The wrapper can not allow writing in case implementation does not!\n" );
    1961                 :            : 
    1962         [ +  + ]:      30551 :     if ( !bReadOnlyWrap )
    1963                 :      29217 :         m_pImpl->m_pAntiImpl = this;
    1964                 :      30551 : }
    1965                 :            : 
    1966                 :            : //-----------------------------------------------
    1967         [ +  - ]:      33885 : OStorage::~OStorage()
    1968                 :            : {
    1969                 :            :     {
    1970         [ +  - ]:      33885 :         ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    1971         [ +  + ]:      33885 :         if ( m_pImpl )
    1972                 :            :         {
    1973                 :      10588 :             m_refCount++; // to call dispose
    1974                 :            :             try {
    1975         [ +  - ]:      10588 :                 dispose();
    1976                 :            :             }
    1977   [ #  #  #  # ]:          0 :             catch( const uno::RuntimeException& rRuntimeException )
    1978                 :            :             {
    1979         [ #  # ]:          0 :                 m_pImpl->AddLog( rRuntimeException.Message );
    1980   [ #  #  #  # ]:          0 :                 m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Handled exception" ) ) );
    1981                 :            :             }
    1982         [ +  - ]:      33885 :         }
    1983                 :            :     }
    1984                 :            : 
    1985         [ +  - ]:      33885 :     if ( m_pData )
    1986                 :            :     {
    1987         [ +  + ]:      33885 :         if ( m_pData->m_pSubElDispListener )
    1988                 :            :         {
    1989                 :       1616 :             m_pData->m_pSubElDispListener->release();
    1990                 :       1616 :             m_pData->m_pSubElDispListener = NULL;
    1991                 :            :         }
    1992                 :            : 
    1993         [ -  + ]:      33885 :         if ( m_pData->m_pTypeCollection )
    1994                 :            :         {
    1995 [ #  # ][ #  # ]:          0 :             delete m_pData->m_pTypeCollection;
    1996                 :          0 :             m_pData->m_pTypeCollection = NULL;
    1997                 :            :         }
    1998                 :            : 
    1999 [ +  - ][ +  - ]:      33885 :         delete m_pData;
    2000                 :            :     }
    2001         [ -  + ]:      67770 : }
    2002                 :            : 
    2003                 :            : //-----------------------------------------------
    2004                 :      34924 : void SAL_CALL OStorage::InternalDispose( sal_Bool bNotifyImpl )
    2005                 :            : {
    2006                 :            :     RTL_LOGFILE_CONTEXT( aLog, "package (mv76033) OStorage::InternalDispose" );
    2007                 :            : 
    2008         [ -  + ]:      34924 :     if ( !m_pImpl )
    2009                 :            :     {
    2010 [ #  # ][ #  # ]:          0 :         ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    2011 [ #  # ][ #  # ]:          0 :         throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    2012                 :            :     }
    2013                 :            : 
    2014                 :            :     // the source object is also a kind of locker for the current object
    2015                 :            :     // since the listeners could dispose the object while being notified
    2016 [ +  - ][ +  - ]:      34924 :        lang::EventObject aSource( static_cast< ::cppu::OWeakObject* >(this) );
    2017         [ +  - ]:      34924 :     m_pData->m_aListenersContainer.disposeAndClear( aSource );
    2018                 :            : 
    2019         [ +  + ]:      34924 :     if ( m_pData->m_bReadOnlyWrap )
    2020                 :            :     {
    2021                 :            :         OSL_ENSURE( !m_pData->m_aOpenSubComponentsList.size() || m_pData->m_pSubElDispListener,
    2022                 :            :                     "If any subelements are open the listener must exist!\n" );
    2023                 :            : 
    2024         [ +  + ]:       2373 :         if ( m_pData->m_pSubElDispListener )
    2025                 :            :         {
    2026         [ +  - ]:       1335 :             m_pData->m_pSubElDispListener->OwnerIsDisposed();
    2027                 :            : 
    2028                 :            :             // iterate through m_pData->m_aOpenSubComponentsList
    2029                 :            :             // deregister m_pData->m_pSubElDispListener and dispose all of them
    2030         [ +  + ]:       1335 :             if ( !m_pData->m_aOpenSubComponentsList.empty() )
    2031                 :            :             {
    2032         [ +  + ]:        678 :                 for ( WeakComponentList::iterator pCompIter = m_pData->m_aOpenSubComponentsList.begin();
    2033                 :        339 :                       pCompIter != m_pData->m_aOpenSubComponentsList.end(); ++pCompIter )
    2034                 :            :                 {
    2035         [ +  - ]:        222 :                     uno::Reference< lang::XComponent > xTmp = (*pCompIter);
    2036         [ +  - ]:        222 :                     if ( xTmp.is() )
    2037                 :            :                     {
    2038         [ +  - ]:        222 :                         xTmp->removeEventListener( uno::Reference< lang::XEventListener >(
    2039 [ +  - ][ +  - ]:        222 :                                     static_cast< lang::XEventListener* >( m_pData->m_pSubElDispListener ) ) );
                 [ +  - ]
    2040                 :            : 
    2041                 :            :                         try {
    2042 [ +  - ][ +  - ]:        222 :                             xTmp->dispose();
    2043   [ #  #  #  # ]:          0 :                         } catch( const uno::Exception& rException )
    2044                 :            :                         {
    2045         [ #  # ]:          0 :                             m_pImpl->AddLog( rException.Message );
    2046   [ #  #  #  # ]:          0 :                             m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Quiet exception" ) ) );
    2047                 :            :                         }
    2048                 :            :                     }
    2049                 :        222 :                 }
    2050                 :            : 
    2051                 :        117 :                 m_pData->m_aOpenSubComponentsList.clear();
    2052                 :            :             }
    2053                 :            :         }
    2054                 :            : 
    2055         [ +  + ]:       2373 :         if ( bNotifyImpl )
    2056         [ +  - ]:       1039 :             m_pImpl->RemoveReadOnlyWrap( *this );
    2057                 :            :     }
    2058                 :            :     else
    2059                 :            :     {
    2060                 :      32551 :         m_pImpl->m_pAntiImpl = NULL;
    2061                 :            : 
    2062         [ +  + ]:      32551 :         if ( bNotifyImpl )
    2063                 :            :         {
    2064         [ +  + ]:      15189 :             if ( m_pData->m_bIsRoot )
    2065 [ +  - ][ +  - ]:       4755 :                 delete m_pImpl;
    2066                 :            :             else
    2067                 :            :             {
    2068                 :            :                 // the noncommited changes for the storage must be removed
    2069         [ +  - ]:      10434 :                 m_pImpl->Revert();
    2070                 :            :             }
    2071                 :            :         }
    2072                 :            :     }
    2073                 :            : 
    2074         [ +  - ]:      34924 :     m_pImpl = NULL;
    2075                 :      34924 : }
    2076                 :            : 
    2077                 :            : //-----------------------------------------------
    2078                 :       1906 : void OStorage::ChildIsDisposed( const uno::Reference< uno::XInterface >& xChild )
    2079                 :            : {
    2080                 :            :     // this method can only be called by child disposing listener
    2081                 :            : 
    2082                 :            :     // this method must not contain any locking
    2083                 :            :     // the locking is done in the listener
    2084                 :            : 
    2085         [ +  - ]:       1906 :     if ( !m_pData->m_aOpenSubComponentsList.empty() )
    2086                 :            :     {
    2087         [ +  + ]:       6033 :         for ( WeakComponentList::iterator pCompIter = m_pData->m_aOpenSubComponentsList.begin();
    2088                 :       4127 :               pCompIter != m_pData->m_aOpenSubComponentsList.end(); )
    2089                 :            :         {
    2090         [ +  - ]:       2221 :             uno::Reference< lang::XComponent > xTmp = (*pCompIter);
    2091 [ +  + ][ +  - ]:       2221 :             if ( !xTmp.is() || xTmp == xChild )
         [ +  + ][ +  + ]
    2092                 :            :             {
    2093                 :       1906 :                 WeakComponentList::iterator pIterToRemove = pCompIter;
    2094                 :       1906 :                 ++pCompIter;
    2095         [ +  - ]:       1906 :                 m_pData->m_aOpenSubComponentsList.erase( pIterToRemove );
    2096                 :            :             }
    2097                 :            :             else
    2098                 :        315 :                 ++pCompIter;
    2099                 :       2221 :         }
    2100                 :            :     }
    2101                 :       1906 : }
    2102                 :            : 
    2103                 :            : //-----------------------------------------------
    2104                 :     101093 : void OStorage::BroadcastModifiedIfNecessary()
    2105                 :            : {
    2106                 :            :     // no need to lock mutex here for the checking of m_pImpl, and m_pData is alive until the object is destructed
    2107         [ -  + ]:     101093 :     if ( !m_pImpl )
    2108                 :            :     {
    2109 [ #  # ][ #  # ]:          0 :         ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    2110 [ #  # ][ #  # ]:          0 :         throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    2111                 :            :     }
    2112                 :            : 
    2113         [ +  + ]:     101093 :     if ( !m_pImpl->m_bBroadcastModified )
    2114                 :     101093 :         return;
    2115                 :            : 
    2116                 :      98521 :     m_pImpl->m_bBroadcastModified = sal_False;
    2117                 :            : 
    2118                 :            :     OSL_ENSURE( !m_pData->m_bReadOnlyWrap, "The storage can not be modified at all!\n" );
    2119                 :            : 
    2120 [ +  - ][ +  - ]:      98521 :        lang::EventObject aSource( static_cast< ::cppu::OWeakObject* >(this) );
    2121                 :            : 
    2122                 :            :        ::cppu::OInterfaceContainerHelper* pContainer =
    2123                 :            :             m_pData->m_aListenersContainer.getContainer(
    2124 [ +  - ][ +  - ]:      98521 :                 ::getCppuType( ( const uno::Reference< util::XModifyListener >*) NULL ) );
    2125         [ +  + ]:      98521 :        if ( pContainer )
    2126                 :            :     {
    2127         [ +  - ]:       2081 :            ::cppu::OInterfaceIteratorHelper pIterator( *pContainer );
    2128         [ +  + ]:       4162 :            while ( pIterator.hasMoreElements( ) )
    2129                 :            :            {
    2130 [ +  - ][ +  - ]:       2081 :                ( ( util::XModifyListener* )pIterator.next( ) )->modified( aSource );
    2131         [ +  - ]:       2081 :            }
    2132         [ +  - ]:     101093 :     }
    2133                 :            : }
    2134                 :            : 
    2135                 :            : //-----------------------------------------------
    2136                 :       4196 : void OStorage::BroadcastTransaction( sal_Int8 nMessage )
    2137                 :            : /*
    2138                 :            :     1 - preCommit
    2139                 :            :     2 - commited
    2140                 :            :     3 - preRevert
    2141                 :            :     4 - reverted
    2142                 :            : */
    2143                 :            : {
    2144                 :            :     // no need to lock mutex here for the checking of m_pImpl, and m_pData is alive until the object is destructed
    2145         [ -  + ]:       4196 :     if ( !m_pImpl )
    2146                 :            :     {
    2147 [ #  # ][ #  # ]:          0 :         ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    2148 [ #  # ][ #  # ]:          0 :         throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    2149                 :            :     }
    2150                 :            : 
    2151                 :            :     OSL_ENSURE( !m_pData->m_bReadOnlyWrap, "The storage can not be modified at all!\n" );
    2152                 :            : 
    2153 [ +  - ][ +  - ]:       4196 :        lang::EventObject aSource( static_cast< ::cppu::OWeakObject* >(this) );
    2154                 :            : 
    2155                 :            :        ::cppu::OInterfaceContainerHelper* pContainer =
    2156                 :            :             m_pData->m_aListenersContainer.getContainer(
    2157 [ +  - ][ +  - ]:       4196 :                 ::getCppuType( ( const uno::Reference< embed::XTransactionListener >*) NULL ) );
    2158         [ -  + ]:       4196 :        if ( pContainer )
    2159                 :            :     {
    2160         [ #  # ]:          0 :            ::cppu::OInterfaceIteratorHelper pIterator( *pContainer );
    2161         [ #  # ]:          0 :            while ( pIterator.hasMoreElements( ) )
    2162                 :            :            {
    2163                 :            :             OSL_ENSURE( nMessage >= 1 && nMessage <= 4, "Wrong internal notification code is used!\n" );
    2164                 :            : 
    2165   [ #  #  #  #  :          0 :             switch( nMessage )
                      # ]
    2166                 :            :             {
    2167                 :            :                 case STOR_MESS_PRECOMMIT:
    2168 [ #  # ][ #  # ]:          0 :                        ( ( embed::XTransactionListener* )pIterator.next( ) )->preCommit( aSource );
    2169                 :          0 :                     break;
    2170                 :            :                 case STOR_MESS_COMMITED:
    2171 [ #  # ][ #  # ]:          0 :                        ( ( embed::XTransactionListener* )pIterator.next( ) )->commited( aSource );
    2172                 :          0 :                     break;
    2173                 :            :                 case STOR_MESS_PREREVERT:
    2174 [ #  # ][ #  # ]:          0 :                        ( ( embed::XTransactionListener* )pIterator.next( ) )->preRevert( aSource );
    2175                 :          0 :                     break;
    2176                 :            :                 case STOR_MESS_REVERTED:
    2177 [ #  # ][ #  # ]:          0 :                        ( ( embed::XTransactionListener* )pIterator.next( ) )->reverted( aSource );
    2178                 :          0 :                     break;
    2179                 :            :             }
    2180         [ #  # ]:          0 :            }
    2181         [ +  - ]:       4196 :     }
    2182                 :       4196 : }
    2183                 :            : 
    2184                 :            : //-----------------------------------------------
    2185                 :      10837 : SotElement_Impl* OStorage::OpenStreamElement_Impl( const ::rtl::OUString& aStreamName, sal_Int32 nOpenMode, sal_Bool bEncr )
    2186                 :            : {
    2187         [ +  - ]:      10837 :     ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    2188                 :            : 
    2189                 :            :     OSL_ENSURE( !m_pData->m_bReadOnlyWrap || ( nOpenMode & embed::ElementModes::WRITE ) != embed::ElementModes::WRITE,
    2190                 :            :                 "An element can not be opened for writing in readonly storage!\n" );
    2191                 :            : 
    2192         [ +  - ]:      10837 :     SotElement_Impl *pElement = m_pImpl->FindElement( aStreamName );
    2193         [ +  + ]:      10837 :     if ( !pElement )
    2194                 :            :     {
    2195                 :            :         // element does not exist, check if creation is allowed
    2196 [ +  + ][ +  + ]:       6976 :         if ( !( m_pImpl->m_nStorageMode & embed::ElementModes::WRITE )
                 [ -  + ]
    2197                 :            :           || (( nOpenMode & embed::ElementModes::WRITE ) != embed::ElementModes::WRITE )
    2198                 :            :           || ( nOpenMode & embed::ElementModes::NOCREATE ) == embed::ElementModes::NOCREATE )
    2199 [ +  - ][ +  - ]:       2501 :             throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); // TODO: access_denied
    2200                 :            : 
    2201                 :            :         // create a new StreamElement and insert it into the list
    2202         [ +  - ]:       4475 :         pElement = m_pImpl->InsertStream( aStreamName, bEncr );
    2203                 :            :     }
    2204         [ -  + ]:       3861 :     else if ( pElement->m_bIsStorage )
    2205                 :            :     {
    2206 [ #  # ][ #  # ]:          0 :         throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    2207                 :            :     }
    2208                 :            : 
    2209                 :            :     OSL_ENSURE( pElement, "In case element can not be created an exception must be thrown!" );
    2210                 :            : 
    2211         [ +  + ]:       8336 :     if ( !pElement->m_pStream )
    2212         [ +  - ]:       3829 :         m_pImpl->OpenSubStream( pElement );
    2213                 :            : 
    2214         [ -  + ]:       8336 :     if ( !pElement->m_pStream )
    2215 [ #  # ][ #  # ]:          0 :         throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    2216                 :            : 
    2217         [ +  - ]:      10837 :     return pElement;
    2218                 :            : }
    2219                 :            : 
    2220                 :            : //-----------------------------------------------
    2221                 :       2128 : void OStorage::MakeLinkToSubComponent_Impl( const uno::Reference< lang::XComponent >& xComponent )
    2222                 :            : {
    2223         [ -  + ]:       2128 :     if ( !xComponent.is() )
    2224 [ #  # ][ #  # ]:          0 :         throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    2225                 :            : 
    2226         [ +  + ]:       2128 :     if ( !m_pData->m_pSubElDispListener )
    2227                 :            :     {
    2228         [ +  - ]:       1622 :         m_pData->m_pSubElDispListener = new OChildDispListener_Impl( *this );
    2229                 :       1622 :         m_pData->m_pSubElDispListener->acquire();
    2230                 :            :     }
    2231                 :            : 
    2232                 :       2128 :     xComponent->addEventListener( uno::Reference< lang::XEventListener >(
    2233         [ +  - ]:       2128 :         static_cast< ::cppu::OWeakObject* >( m_pData->m_pSubElDispListener ), uno::UNO_QUERY ) );
    2234                 :            : 
    2235         [ +  - ]:       2128 :     m_pData->m_aOpenSubComponentsList.push_back( xComponent );
    2236                 :       2128 : }
    2237                 :            : 
    2238                 :            : //____________________________________________________________________________________________________
    2239                 :            : //  XInterface
    2240                 :            : //____________________________________________________________________________________________________
    2241                 :            : 
    2242                 :            : //-----------------------------------------------
    2243                 :      92243 : uno::Any SAL_CALL OStorage::queryInterface( const uno::Type& rType )
    2244                 :            :         throw( uno::RuntimeException )
    2245                 :            : {
    2246                 :      92243 :     uno::Any aReturn;
    2247                 :            : 
    2248                 :            :     // common interfaces
    2249                 :            :     aReturn <<= ::cppu::queryInterface
    2250                 :            :                 (   rType
    2251                 :            :                 ,   static_cast<lang::XTypeProvider*> ( this )
    2252                 :            :                 ,   static_cast<embed::XStorage*> ( this )
    2253                 :            :                 ,   static_cast<embed::XStorage2*> ( this )
    2254                 :            :                 ,   static_cast<embed::XTransactedObject*> ( this )
    2255                 :            :                 ,   static_cast<embed::XTransactionBroadcaster*> ( this )
    2256                 :            :                 ,   static_cast<util::XModifiable*> ( this )
    2257                 :            :                 ,   static_cast<container::XNameAccess*> ( this )
    2258                 :            :                 ,   static_cast<container::XElementAccess*> ( this )
    2259                 :            :                 ,   static_cast<lang::XComponent*> ( this )
    2260                 :            :                 ,   static_cast<beans::XPropertySet*> ( this )
    2261 [ +  - ][ +  - ]:      92243 :                 ,   static_cast<embed::XOptimizedStorage*> ( this ) );
    2262                 :            : 
    2263         [ +  + ]:      92243 :     if ( aReturn.hasValue() == sal_True )
    2264                 :      56324 :         return aReturn ;
    2265                 :            : 
    2266                 :            :     aReturn <<= ::cppu::queryInterface
    2267                 :            :                 (   rType
    2268                 :            :                 ,   static_cast<embed::XHierarchicalStorageAccess*> ( this )
    2269 [ +  - ][ +  - ]:      35919 :                 ,   static_cast<embed::XHierarchicalStorageAccess2*> ( this ) );
    2270                 :            : 
    2271         [ +  + ]:      35919 :     if ( aReturn.hasValue() == sal_True )
    2272                 :       2915 :         return aReturn ;
    2273                 :            : 
    2274         [ +  + ]:      33004 :     if ( m_pData->m_nStorageType == embed::StorageFormats::PACKAGE )
    2275                 :            :     {
    2276         [ +  + ]:      22986 :         if ( m_pData->m_bIsRoot )
    2277                 :            :         {
    2278                 :            :             aReturn <<= ::cppu::queryInterface
    2279                 :            :                         (   rType
    2280                 :            :                         ,   static_cast<embed::XStorageRawAccess*> ( this )
    2281                 :            :                         ,   static_cast<embed::XEncryptionProtectedSource*> ( this )
    2282                 :            :                         ,   static_cast<embed::XEncryptionProtectedSource2*> ( this )
    2283 [ +  - ][ +  - ]:      11400 :                         ,   static_cast<embed::XEncryptionProtectedStorage*> ( this ) );
    2284                 :            :         }
    2285                 :            :         else
    2286                 :            :         {
    2287                 :            :             aReturn <<= ::cppu::queryInterface
    2288                 :            :                         (   rType
    2289 [ +  - ][ +  - ]:      11586 :                         ,   static_cast<embed::XStorageRawAccess*> ( this ) );
    2290                 :            :         }
    2291                 :            :     }
    2292         [ +  + ]:      10018 :     else if ( m_pData->m_nStorageType == embed::StorageFormats::OFOPXML )
    2293                 :            :     {
    2294                 :            :         aReturn <<= ::cppu::queryInterface
    2295                 :            :                     (   rType
    2296 [ +  - ][ +  - ]:       5744 :                     ,   static_cast<embed::XRelationshipAccess*> ( this ) );
    2297                 :            :     }
    2298                 :            : 
    2299         [ +  + ]:      33004 :     if ( aReturn.hasValue() == sal_True )
    2300                 :       3320 :         return aReturn ;
    2301                 :            : 
    2302         [ +  - ]:      92243 :     return OWeakObject::queryInterface( rType );
    2303                 :            : }
    2304                 :            : 
    2305                 :            : //-----------------------------------------------
    2306                 :     812993 : void SAL_CALL OStorage::acquire() throw()
    2307                 :            : {
    2308                 :     812993 :     OWeakObject::acquire();
    2309                 :     812993 : }
    2310                 :            : 
    2311                 :            : //-----------------------------------------------
    2312                 :     810926 : void SAL_CALL OStorage::release() throw()
    2313                 :            : {
    2314                 :     810926 :     OWeakObject::release();
    2315                 :     810926 : }
    2316                 :            : 
    2317                 :            : //____________________________________________________________________________________________________
    2318                 :            : //  XTypeProvider
    2319                 :            : //____________________________________________________________________________________________________
    2320                 :            : 
    2321                 :            : //-----------------------------------------------
    2322                 :          0 : uno::Sequence< uno::Type > SAL_CALL OStorage::getTypes()
    2323                 :            :         throw( uno::RuntimeException )
    2324                 :            : {
    2325         [ #  # ]:          0 :     if ( m_pData->m_pTypeCollection == NULL )
    2326                 :            :     {
    2327         [ #  # ]:          0 :         ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    2328                 :            : 
    2329         [ #  # ]:          0 :         if ( m_pData->m_pTypeCollection == NULL )
    2330                 :            :         {
    2331         [ #  # ]:          0 :             if ( m_pData->m_nStorageType == embed::StorageFormats::PACKAGE )
    2332                 :            :             {
    2333         [ #  # ]:          0 :                 if ( m_pData->m_bIsRoot )
    2334                 :            :                 {
    2335                 :            :                     m_pData->m_pTypeCollection = new ::cppu::OTypeCollection
    2336                 :            :                                     (   ::getCppuType( ( const uno::Reference< lang::XTypeProvider >* )NULL )
    2337                 :            :                                     ,   ::getCppuType( ( const uno::Reference< embed::XStorage >* )NULL )
    2338                 :            :                                     ,   ::getCppuType( ( const uno::Reference< embed::XStorage2 >* )NULL )
    2339                 :            :                                     ,   ::getCppuType( ( const uno::Reference< embed::XStorageRawAccess >* )NULL )
    2340                 :            :                                     ,   ::getCppuType( ( const uno::Reference< embed::XTransactedObject >* )NULL )
    2341                 :            :                                     ,   ::getCppuType( ( const uno::Reference< embed::XTransactionBroadcaster >* )NULL )
    2342                 :            :                                     ,   ::getCppuType( ( const uno::Reference< util::XModifiable >* )NULL )
    2343                 :            :                                     ,   ::getCppuType( ( const uno::Reference< embed::XEncryptionProtectedStorage >* )NULL )
    2344                 :            :                                     ,   ::getCppuType( ( const uno::Reference< embed::XEncryptionProtectedSource2 >* )NULL )
    2345                 :            :                                     ,   ::getCppuType( ( const uno::Reference< embed::XEncryptionProtectedSource >* )NULL )
    2346 [ #  # ][ #  # ]:          0 :                                     ,   ::getCppuType( ( const uno::Reference< beans::XPropertySet >* )NULL ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2347                 :            :                 }
    2348                 :            :                 else
    2349                 :            :                 {
    2350                 :            :                     m_pData->m_pTypeCollection = new ::cppu::OTypeCollection
    2351                 :            :                                     (   ::getCppuType( ( const uno::Reference< lang::XTypeProvider >* )NULL )
    2352                 :            :                                     ,   ::getCppuType( ( const uno::Reference< embed::XStorage >* )NULL )
    2353                 :            :                                     ,   ::getCppuType( ( const uno::Reference< embed::XStorage2 >* )NULL )
    2354                 :            :                                     ,   ::getCppuType( ( const uno::Reference< embed::XStorageRawAccess >* )NULL )
    2355                 :            :                                     ,   ::getCppuType( ( const uno::Reference< embed::XTransactedObject >* )NULL )
    2356                 :            :                                     ,   ::getCppuType( ( const uno::Reference< embed::XTransactionBroadcaster >* )NULL )
    2357                 :            :                                     ,   ::getCppuType( ( const uno::Reference< util::XModifiable >* )NULL )
    2358 [ #  # ][ #  # ]:          0 :                                     ,   ::getCppuType( ( const uno::Reference< beans::XPropertySet >* )NULL ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    2359                 :            :                 }
    2360                 :            :             }
    2361         [ #  # ]:          0 :             else if ( m_pData->m_nStorageType == embed::StorageFormats::OFOPXML )
    2362                 :            :             {
    2363                 :            :                 m_pData->m_pTypeCollection = new ::cppu::OTypeCollection
    2364                 :            :                                 (   ::getCppuType( ( const uno::Reference< lang::XTypeProvider >* )NULL )
    2365                 :            :                                 ,   ::getCppuType( ( const uno::Reference< embed::XStorage >* )NULL )
    2366                 :            :                                 ,   ::getCppuType( ( const uno::Reference< embed::XTransactedObject >* )NULL )
    2367                 :            :                                 ,   ::getCppuType( ( const uno::Reference< embed::XTransactionBroadcaster >* )NULL )
    2368                 :            :                                 ,   ::getCppuType( ( const uno::Reference< util::XModifiable >* )NULL )
    2369                 :            :                                 ,   ::getCppuType( ( const uno::Reference< embed::XRelationshipAccess >* )NULL )
    2370 [ #  # ][ #  # ]:          0 :                                 ,   ::getCppuType( ( const uno::Reference< beans::XPropertySet >* )NULL ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2371                 :            :             }
    2372                 :            :             else
    2373                 :            :             {
    2374                 :            :                 m_pData->m_pTypeCollection = new ::cppu::OTypeCollection
    2375                 :            :                                 (   ::getCppuType( ( const uno::Reference< lang::XTypeProvider >* )NULL )
    2376                 :            :                                 ,   ::getCppuType( ( const uno::Reference< embed::XStorage >* )NULL )
    2377                 :            :                                 ,   ::getCppuType( ( const uno::Reference< embed::XTransactedObject >* )NULL )
    2378                 :            :                                 ,   ::getCppuType( ( const uno::Reference< embed::XTransactionBroadcaster >* )NULL )
    2379                 :            :                                 ,   ::getCppuType( ( const uno::Reference< util::XModifiable >* )NULL )
    2380 [ #  # ][ #  # ]:          0 :                                 ,   ::getCppuType( ( const uno::Reference< beans::XPropertySet >* )NULL ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    2381                 :            :             }
    2382         [ #  # ]:          0 :         }
    2383                 :            :     }
    2384                 :            : 
    2385                 :          0 :     return m_pData->m_pTypeCollection->getTypes() ;
    2386                 :            : }
    2387                 :            : 
    2388                 :            : namespace { struct lcl_ImplId : public rtl::Static< ::cppu::OImplementationId, lcl_ImplId > {}; }
    2389                 :            : 
    2390                 :            : //-----------------------------------------------
    2391                 :          0 : uno::Sequence< sal_Int8 > SAL_CALL OStorage::getImplementationId()
    2392                 :            :         throw( uno::RuntimeException )
    2393                 :            : {
    2394                 :          0 :     ::cppu::OImplementationId &rID = lcl_ImplId::get();
    2395                 :          0 :     return rID.getImplementationId();
    2396                 :            : }
    2397                 :            : 
    2398                 :            : //____________________________________________________________________________________________________
    2399                 :            : //  XStorage
    2400                 :            : //____________________________________________________________________________________________________
    2401                 :            : 
    2402                 :            : 
    2403                 :            : //-----------------------------------------------
    2404                 :          5 : void SAL_CALL OStorage::copyToStorage( const uno::Reference< embed::XStorage >& xDest )
    2405                 :            :         throw ( embed::InvalidStorageException,
    2406                 :            :                 io::IOException,
    2407                 :            :                 lang::IllegalArgumentException,
    2408                 :            :                 embed::StorageWrappedTargetException,
    2409                 :            :                 uno::RuntimeException )
    2410                 :            : {
    2411                 :            :     RTL_LOGFILE_CONTEXT( aLog, "package (mv76033) OStorage::copyToStorage" );
    2412                 :            : 
    2413         [ +  - ]:          5 :     ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    2414                 :            : 
    2415         [ -  + ]:          5 :     if ( !m_pImpl )
    2416                 :            :     {
    2417 [ #  # ][ #  # ]:          0 :         ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    2418 [ #  # ][ #  # ]:          0 :         throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    2419                 :            :     }
    2420                 :            : 
    2421 [ +  - ][ +  - ]:          5 :     if ( !xDest.is() || xDest == uno::Reference< uno::XInterface >( static_cast< OWeakObject*> ( this ), uno::UNO_QUERY ) )
         [ +  - ][ -  + ]
                 [ +  - ]
           [ -  +  #  # ]
    2422 [ #  # ][ #  # ]:          0 :         throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 1 );
    2423                 :            : 
    2424                 :            :     try {
    2425         [ +  - ]:          5 :         m_pImpl->CopyToStorage( xDest, sal_False );
    2426                 :            :     }
    2427                 :          0 :     catch( const embed::InvalidStorageException& rInvalidStorageException )
    2428                 :            :     {
    2429         [ #  # ]:          0 :         m_pImpl->AddLog( rInvalidStorageException.Message );
    2430   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    2431                 :          0 :         throw;
    2432                 :            :     }
    2433                 :          0 :     catch( const lang::IllegalArgumentException& rIllegalArgumentException )
    2434                 :            :     {
    2435         [ #  # ]:          0 :         m_pImpl->AddLog( rIllegalArgumentException.Message );
    2436   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    2437                 :          0 :         throw;
    2438                 :            :     }
    2439                 :          0 :     catch( const embed::StorageWrappedTargetException& rStorageWrappedTargetException )
    2440                 :            :     {
    2441         [ #  # ]:          0 :         m_pImpl->AddLog( rStorageWrappedTargetException.Message );
    2442   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    2443                 :          0 :         throw;
    2444                 :            :     }
    2445                 :          0 :     catch( const io::IOException& rIOException )
    2446                 :            :     {
    2447         [ #  # ]:          0 :         m_pImpl->AddLog( rIOException.Message );
    2448   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    2449                 :          0 :         throw;
    2450                 :            :     }
    2451                 :          0 :     catch( const uno::RuntimeException& rRuntimeException )
    2452                 :            :     {
    2453         [ #  # ]:          0 :         m_pImpl->AddLog( rRuntimeException.Message );
    2454   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    2455                 :          0 :         throw;
    2456                 :            :     }
    2457   [ #  #  #  #  :          0 :     catch( const uno::Exception& rException )
                #  #  # ]
    2458                 :            :     {
    2459         [ #  # ]:          0 :           m_pImpl->AddLog( rException.Message );
    2460   [ #  #  #  # ]:          0 :           m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    2461                 :            : 
    2462         [ #  # ]:          0 :           uno::Any aCaught( ::cppu::getCaughtException() );
    2463                 :            :         throw embed::StorageWrappedTargetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Can't copy storage!" ) ),
    2464                 :            :                                                  uno::Reference< io::XInputStream >(),
    2465   [ #  #  #  # ]:          0 :                                                  aCaught );
    2466         [ +  - ]:          5 :     }
    2467                 :          5 : }
    2468                 :            : 
    2469                 :            : //-----------------------------------------------
    2470                 :       9548 : uno::Reference< io::XStream > SAL_CALL OStorage::openStreamElement(
    2471                 :            :     const ::rtl::OUString& aStreamName, sal_Int32 nOpenMode )
    2472                 :            :         throw ( embed::InvalidStorageException,
    2473                 :            :                 lang::IllegalArgumentException,
    2474                 :            :                 packages::WrongPasswordException,
    2475                 :            :                 io::IOException,
    2476                 :            :                 embed::StorageWrappedTargetException,
    2477                 :            :                 uno::RuntimeException )
    2478                 :            : {
    2479                 :            :     RTL_LOGFILE_CONTEXT( aLog, "package (mv76033) OStorage::openStreamElement" );
    2480                 :            : 
    2481         [ +  - ]:       9548 :     ::osl::ResettableMutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    2482                 :            : 
    2483         [ -  + ]:       9548 :     if ( !m_pImpl )
    2484                 :            :     {
    2485 [ #  # ][ #  # ]:          0 :         ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    2486 [ #  # ][ #  # ]:          0 :         throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    2487                 :            :     }
    2488                 :            : 
    2489 [ +  - ][ +  - ]:       9548 :     if ( aStreamName.isEmpty() || !::comphelper::OStorageHelper::IsValidZipEntryFileName( aStreamName, sal_False ) )
         [ -  + ][ -  + ]
    2490 [ #  # ][ #  # ]:          0 :         throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Unexpected entry name syntax." ) ), uno::Reference< uno::XInterface >(), 1 );
    2491                 :            : 
    2492 [ +  + ][ -  + ]:       9548 :     if ( m_pData->m_nStorageType == embed::StorageFormats::OFOPXML && aStreamName == "_rels" )
                 [ -  + ]
    2493 [ #  # ][ #  # ]:          0 :         throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 1 ); // unacceptable element name
    2494                 :            : 
    2495 [ +  + ][ -  + ]:       9548 :     if ( ( nOpenMode & embed::ElementModes::WRITE ) && m_pData->m_bReadOnlyWrap )
    2496 [ #  # ][ #  # ]:          0 :         throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); // TODO: access denied
    2497                 :            : 
    2498                 :       9548 :     uno::Reference< io::XStream > xResult;
    2499                 :            :     try
    2500                 :            :     {
    2501         [ +  + ]:       9548 :         SotElement_Impl *pElement = OpenStreamElement_Impl( aStreamName, nOpenMode, sal_False );
    2502                 :            :         OSL_ENSURE( pElement && pElement->m_pStream, "In case element can not be created an exception must be thrown!" );
    2503                 :            : 
    2504 [ +  - ][ +  - ]:       7047 :         xResult = pElement->m_pStream->GetStream( nOpenMode, sal_False );
    2505                 :            :         OSL_ENSURE( xResult.is(), "The method must throw exception instead of removing empty result!\n" );
    2506                 :            : 
    2507         [ +  + ]:       7047 :         if ( m_pData->m_bReadOnlyWrap )
    2508                 :            :         {
    2509                 :            :             // before the storage disposes the stream it must deregister itself as listener
    2510         [ +  - ]:        794 :             uno::Reference< lang::XComponent > xStreamComponent( xResult, uno::UNO_QUERY );
    2511         [ -  + ]:        794 :             if ( !xStreamComponent.is() )
    2512 [ #  # ][ #  # ]:          0 :                 throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    2513                 :            : 
    2514         [ +  - ]:        794 :             MakeLinkToSubComponent_Impl( xStreamComponent );
    2515                 :            :         }
    2516                 :            :     }
    2517                 :          0 :     catch( const embed::InvalidStorageException& rInvalidStorageException )
    2518                 :            :     {
    2519         [ #  # ]:          0 :         m_pImpl->AddLog( rInvalidStorageException.Message );
    2520   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    2521                 :          0 :         throw;
    2522                 :            :     }
    2523                 :          0 :     catch( const lang::IllegalArgumentException& rIllegalArgumentException )
    2524                 :            :     {
    2525         [ #  # ]:          0 :         m_pImpl->AddLog( rIllegalArgumentException.Message );
    2526   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    2527                 :          0 :         throw;
    2528                 :            :     }
    2529                 :          0 :     catch( const packages::WrongPasswordException& rWrongPasswordException )
    2530                 :            :     {
    2531         [ #  # ]:          0 :         m_pImpl->AddLog( rWrongPasswordException.Message );
    2532   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    2533                 :          0 :         throw;
    2534                 :            :     }
    2535                 :          0 :     catch( const embed::StorageWrappedTargetException& rStorageWrappedTargetException )
    2536                 :            :     {
    2537         [ #  # ]:          0 :         m_pImpl->AddLog( rStorageWrappedTargetException.Message );
    2538   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    2539                 :          0 :         throw;
    2540                 :            :     }
    2541                 :       5002 :     catch( const io::IOException& rIOException )
    2542                 :            :     {
    2543         [ -  + ]:       2501 :         m_pImpl->AddLog( rIOException.Message );
    2544 [ -  + ][ -  + ]:       2501 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    2545                 :       2501 :         throw;
    2546                 :            :     }
    2547                 :          0 :     catch( const uno::RuntimeException& rRuntimeException )
    2548                 :            :     {
    2549         [ #  # ]:          0 :         m_pImpl->AddLog( rRuntimeException.Message );
    2550   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    2551                 :          0 :         throw;
    2552                 :            :     }
    2553   [ -  -  -  -  :       2501 :     catch( const uno::Exception& rException )
             -  +  -  - ]
    2554                 :            :     {
    2555         [ #  # ]:          0 :           m_pImpl->AddLog( rException.Message );
    2556   [ #  #  #  # ]:          0 :           m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    2557                 :            : 
    2558         [ #  # ]:          0 :           uno::Any aCaught( ::cppu::getCaughtException() );
    2559                 :            :         throw embed::StorageWrappedTargetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Can't open stream element!" ) ),
    2560                 :            :                                                  uno::Reference< io::XInputStream >(),
    2561   [ #  #  #  # ]:          0 :                                                  aCaught );
    2562                 :            :     }
    2563                 :            : 
    2564         [ +  - ]:       7047 :     aGuard.clear();
    2565                 :            : 
    2566         [ +  - ]:       7047 :     BroadcastModifiedIfNecessary();
    2567                 :            : 
    2568         [ +  - ]:       9548 :     return xResult;
    2569                 :            : }
    2570                 :            : 
    2571                 :            : //-----------------------------------------------
    2572                 :          0 : uno::Reference< io::XStream > SAL_CALL OStorage::openEncryptedStreamElement(
    2573                 :            :     const ::rtl::OUString& aStreamName, sal_Int32 nOpenMode, const ::rtl::OUString& aPass )
    2574                 :            :         throw ( embed::InvalidStorageException,
    2575                 :            :                 lang::IllegalArgumentException,
    2576                 :            :                 packages::NoEncryptionException,
    2577                 :            :                 packages::WrongPasswordException,
    2578                 :            :                 io::IOException,
    2579                 :            :                 embed::StorageWrappedTargetException,
    2580                 :            :                 uno::RuntimeException )
    2581                 :            : {
    2582                 :            :     RTL_LOGFILE_CONTEXT( aLog, "package (mv76033) OStorage::openEncryptedStreamElement" );
    2583                 :            : 
    2584 [ #  # ][ #  # ]:          0 :     return openEncryptedStream( aStreamName, nOpenMode, ::comphelper::OStorageHelper::CreatePackageEncryptionData( aPass ) );
                 [ #  # ]
    2585                 :            : }
    2586                 :            : 
    2587                 :            : //-----------------------------------------------
    2588                 :      32574 : uno::Reference< embed::XStorage > SAL_CALL OStorage::openStorageElement(
    2589                 :            :             const ::rtl::OUString& aStorName, sal_Int32 nStorageMode )
    2590                 :            :         throw ( embed::InvalidStorageException,
    2591                 :            :                 lang::IllegalArgumentException,
    2592                 :            :                 io::IOException,
    2593                 :            :                 embed::StorageWrappedTargetException,
    2594                 :            :                 uno::RuntimeException )
    2595                 :            : {
    2596                 :            :     RTL_LOGFILE_CONTEXT( aLog, "package (mv76033) OStorage::openStorageElement" );
    2597                 :            : 
    2598         [ +  - ]:      32574 :     ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    2599                 :            : 
    2600         [ -  + ]:      32574 :     if ( !m_pImpl )
    2601                 :            :     {
    2602 [ #  # ][ #  # ]:          0 :         ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    2603 [ #  # ][ #  # ]:          0 :         throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    2604                 :            :     }
    2605                 :            : 
    2606 [ +  - ][ +  - ]:      32574 :     if ( aStorName.isEmpty() || !::comphelper::OStorageHelper::IsValidZipEntryFileName( aStorName, sal_False ) )
         [ -  + ][ -  + ]
    2607 [ #  # ][ #  # ]:          0 :         throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Unexpected entry name syntax." ) ), uno::Reference< uno::XInterface >(), 1 );
    2608                 :            : 
    2609 [ +  + ][ -  + ]:      32574 :     if ( m_pData->m_nStorageType == embed::StorageFormats::OFOPXML && aStorName == "_rels" )
                 [ -  + ]
    2610 [ #  # ][ #  # ]:          0 :         throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 1 ); // unacceptable storage name
    2611                 :            : 
    2612 [ +  + ][ -  + ]:      32574 :     if ( ( nStorageMode & embed::ElementModes::WRITE ) && m_pData->m_bReadOnlyWrap )
    2613 [ #  # ][ #  # ]:          0 :         throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); // TODO: access denied
    2614                 :            : 
    2615 [ -  + ][ #  # ]:      32574 :     if ( ( nStorageMode & embed::ElementModes::TRUNCATE )
    2616                 :          0 :       && !( nStorageMode & embed::ElementModes::WRITE ) )
    2617 [ #  # ][ #  # ]:          0 :         throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); // TODO: access denied
    2618                 :            : 
    2619                 :            :     // it's allways possible to read written storage in this implementation
    2620                 :      32574 :     nStorageMode |= embed::ElementModes::READ;
    2621                 :            : 
    2622                 :      32574 :     uno::Reference< embed::XStorage > xResult;
    2623                 :            :     try
    2624                 :            :     {
    2625         [ +  - ]:      32574 :         SotElement_Impl *pElement = m_pImpl->FindElement( aStorName );
    2626         [ +  + ]:      32574 :         if ( !pElement )
    2627                 :            :         {
    2628                 :            :             // element does not exist, check if creation is allowed
    2629 [ +  - ][ +  + ]:      30082 :             if ( !( m_pImpl->m_nStorageMode & embed::ElementModes::WRITE )
                 [ -  + ]
    2630                 :            :               || (( nStorageMode & embed::ElementModes::WRITE ) != embed::ElementModes::WRITE )
    2631                 :            :               || ( nStorageMode & embed::ElementModes::NOCREATE ) == embed::ElementModes::NOCREATE )
    2632 [ +  - ][ +  - ]:       2905 :                 throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); // TODO: access_denied
    2633                 :            : 
    2634                 :            :             // create a new StorageElement and insert it into the list
    2635         [ +  - ]:      27177 :             pElement = m_pImpl->InsertStorage( aStorName, nStorageMode );
    2636                 :            :         }
    2637         [ -  + ]:       2492 :         else if ( !pElement->m_bIsStorage )
    2638                 :            :         {
    2639 [ #  # ][ #  # ]:          0 :             throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    2640                 :            :         }
    2641         [ +  + ]:       2492 :         else if ( pElement->m_pStorage )
    2642                 :            :         {
    2643                 :            :             // storage has already been opened; it may be opened another time, if it the mode allows to do so
    2644         [ -  + ]:        189 :             if ( pElement->m_pStorage->m_pAntiImpl )
    2645                 :            :             {
    2646 [ #  # ][ #  # ]:          0 :                 throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); // TODO: access_denied
    2647                 :            :             }
    2648 [ -  + ][ #  # ]:        189 :             else if ( !pElement->m_pStorage->m_aReadOnlyWrapList.empty()
                 [ -  + ]
    2649                 :            :                     && ( nStorageMode & embed::ElementModes::WRITE ) )
    2650                 :            :             {
    2651 [ #  # ][ #  # ]:          0 :                 throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); // TODO: access_denied
    2652                 :            :             }
    2653                 :            :             else
    2654                 :            :             {
    2655                 :            :                 // in case parent storage allows writing the readonly mode of the child storage is
    2656                 :            :                 // virtual, that means that it is just enough to change the flag to let it be writable
    2657                 :            :                 // and since there is no AntiImpl nobody should be notified about it
    2658                 :        189 :                 pElement->m_pStorage->m_nStorageMode = nStorageMode | embed::ElementModes::READ;
    2659                 :            : 
    2660         [ -  + ]:        189 :                 if ( ( nStorageMode & embed::ElementModes::TRUNCATE ) )
    2661                 :            :                 {
    2662         [ #  # ]:          0 :                     for ( SotElementList_Impl::iterator pElementIter = pElement->m_pStorage->m_aChildrenList.begin();
    2663                 :          0 :                            pElementIter != pElement->m_pStorage->m_aChildrenList.end(); )
    2664                 :            :                        {
    2665                 :          0 :                         SotElement_Impl* pElementToDel = (*pElementIter);
    2666                 :          0 :                         ++pElementIter;
    2667                 :            : 
    2668         [ #  # ]:          0 :                         m_pImpl->RemoveElement( pElementToDel );
    2669                 :            :                        }
    2670                 :            :                 }
    2671                 :            :             }
    2672                 :            :         }
    2673                 :            : 
    2674         [ +  + ]:      29669 :         if ( !pElement->m_pStorage )
    2675         [ +  - ]:       2303 :             m_pImpl->OpenSubStorage( pElement, nStorageMode );
    2676                 :            : 
    2677         [ -  + ]:      29669 :         if ( !pElement->m_pStorage )
    2678 [ #  # ][ #  # ]:          0 :             throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); // TODO: general_error
    2679                 :            : 
    2680                 :      29669 :         sal_Bool bReadOnlyWrap = ( ( nStorageMode & embed::ElementModes::WRITE ) != embed::ElementModes::WRITE );
    2681         [ +  - ]:      29669 :         OStorage* pResultStorage = new OStorage( pElement->m_pStorage, bReadOnlyWrap );
    2682 [ +  - ][ +  - ]:      29669 :         xResult = uno::Reference< embed::XStorage >( (embed::XStorage*) pResultStorage );
                 [ +  - ]
    2683                 :            : 
    2684         [ +  + ]:      29669 :         if ( bReadOnlyWrap )
    2685                 :            :         {
    2686                 :            :             // Before this call is done the object must be refcounted already
    2687         [ +  - ]:       1334 :             pElement->m_pStorage->SetReadOnlyWrap( *pResultStorage );
    2688                 :            : 
    2689                 :            :             // before the storage disposes the stream it must deregister itself as listener
    2690         [ +  - ]:       1334 :             uno::Reference< lang::XComponent > xStorageComponent( xResult, uno::UNO_QUERY );
    2691         [ -  + ]:       1334 :             if ( !xStorageComponent.is() )
    2692 [ #  # ][ #  # ]:          0 :                 throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    2693                 :            : 
    2694         [ +  - ]:       1334 :             MakeLinkToSubComponent_Impl( xStorageComponent );
    2695                 :            :         }
    2696                 :            :     }
    2697                 :          0 :     catch( const embed::InvalidStorageException& rInvalidStorageException )
    2698                 :            :     {
    2699         [ #  # ]:          0 :         m_pImpl->AddLog( rInvalidStorageException.Message );
    2700   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    2701                 :          0 :         throw;
    2702                 :            :     }
    2703                 :          0 :     catch( const lang::IllegalArgumentException& rIllegalArgumentException )
    2704                 :            :     {
    2705         [ #  # ]:          0 :         m_pImpl->AddLog( rIllegalArgumentException.Message );
    2706   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    2707                 :          0 :         throw;
    2708                 :            :     }
    2709                 :          0 :     catch( const embed::StorageWrappedTargetException& rStorageWrappedTargetException )
    2710                 :            :     {
    2711         [ #  # ]:          0 :         m_pImpl->AddLog( rStorageWrappedTargetException.Message );
    2712   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    2713                 :          0 :         throw;
    2714                 :            :     }
    2715                 :       5810 :     catch( const io::IOException& rIOException )
    2716                 :            :     {
    2717         [ -  + ]:       2905 :         m_pImpl->AddLog( rIOException.Message );
    2718 [ -  + ][ -  + ]:       2905 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    2719                 :       2905 :         throw;
    2720                 :            :     }
    2721                 :          0 :     catch( const uno::RuntimeException& rRuntimeException )
    2722                 :            :     {
    2723         [ #  # ]:          0 :         m_pImpl->AddLog( rRuntimeException.Message );
    2724   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    2725                 :          0 :         throw;
    2726                 :            :     }
    2727   [ -  -  -  -  :       2905 :     catch( const uno::Exception& rException )
                +  -  - ]
    2728                 :            :     {
    2729         [ #  # ]:          0 :           m_pImpl->AddLog( rException.Message );
    2730   [ #  #  #  # ]:          0 :           m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    2731                 :            : 
    2732         [ #  # ]:          0 :           uno::Any aCaught( ::cppu::getCaughtException() );
    2733                 :            :         throw embed::StorageWrappedTargetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Can't open storage!" ) ),
    2734                 :            :                                                  uno::Reference< io::XInputStream >(),
    2735   [ #  #  #  # ]:          0 :                                                  aCaught );
    2736                 :            :     }
    2737                 :            : 
    2738         [ +  - ]:      32574 :     return xResult;
    2739                 :            : }
    2740                 :            : 
    2741                 :            : //-----------------------------------------------
    2742                 :          0 : uno::Reference< io::XStream > SAL_CALL OStorage::cloneStreamElement( const ::rtl::OUString& aStreamName )
    2743                 :            :         throw ( embed::InvalidStorageException,
    2744                 :            :                 lang::IllegalArgumentException,
    2745                 :            :                 packages::WrongPasswordException,
    2746                 :            :                 io::IOException,
    2747                 :            :                 embed::StorageWrappedTargetException,
    2748                 :            :                 uno::RuntimeException )
    2749                 :            : {
    2750                 :            :     RTL_LOGFILE_CONTEXT( aLog, "package (mv76033) OStorage::cloneStreamElement" );
    2751                 :            : 
    2752         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    2753                 :            : 
    2754         [ #  # ]:          0 :     if ( !m_pImpl )
    2755                 :            :     {
    2756 [ #  # ][ #  # ]:          0 :         ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    2757 [ #  # ][ #  # ]:          0 :         throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    2758                 :            :     }
    2759                 :            : 
    2760 [ #  # ][ #  # ]:          0 :     if ( aStreamName.isEmpty() || !::comphelper::OStorageHelper::IsValidZipEntryFileName( aStreamName, sal_False ) )
         [ #  # ][ #  # ]
    2761 [ #  # ][ #  # ]:          0 :         throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Unexpected entry name syntax." ) ), uno::Reference< uno::XInterface >(), 1 );
    2762                 :            : 
    2763 [ #  # ][ #  # ]:          0 :     if ( m_pData->m_nStorageType == embed::StorageFormats::OFOPXML && aStreamName == "_rels" )
                 [ #  # ]
    2764 [ #  # ][ #  # ]:          0 :         throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 1 ); // unacceptable storage name
    2765                 :            : 
    2766                 :            :     try
    2767                 :            :     {
    2768                 :          0 :         uno::Reference< io::XStream > xResult;
    2769 [ #  # ][ #  # ]:          0 :         m_pImpl->CloneStreamElement( aStreamName, sal_False, ::comphelper::SequenceAsHashMap(), xResult );
                 [ #  # ]
    2770         [ #  # ]:          0 :         if ( !xResult.is() )
    2771 [ #  # ][ #  # ]:          0 :             throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    2772                 :          0 :         return xResult;
    2773                 :            :     }
    2774                 :          0 :     catch( const embed::InvalidStorageException& rInvalidStorageException )
    2775                 :            :     {
    2776         [ #  # ]:          0 :         m_pImpl->AddLog( rInvalidStorageException.Message );
    2777   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    2778                 :          0 :         throw;
    2779                 :            :     }
    2780                 :          0 :     catch( const lang::IllegalArgumentException& rIllegalArgumentException )
    2781                 :            :     {
    2782         [ #  # ]:          0 :         m_pImpl->AddLog( rIllegalArgumentException.Message );
    2783   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    2784                 :          0 :         throw;
    2785                 :            :     }
    2786                 :          0 :     catch( const packages::WrongPasswordException& rWrongPasswordException )
    2787                 :            :     {
    2788         [ #  # ]:          0 :         m_pImpl->AddLog( rWrongPasswordException.Message );
    2789   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    2790                 :          0 :         throw;
    2791                 :            :     }
    2792                 :          0 :     catch( const io::IOException& rIOException )
    2793                 :            :     {
    2794         [ #  # ]:          0 :         m_pImpl->AddLog( rIOException.Message );
    2795   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    2796                 :          0 :         throw;
    2797                 :            :     }
    2798                 :          0 :     catch( const embed::StorageWrappedTargetException& rStorageWrappedTargetException )
    2799                 :            :     {
    2800         [ #  # ]:          0 :         m_pImpl->AddLog( rStorageWrappedTargetException.Message );
    2801   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    2802                 :          0 :         throw;
    2803                 :            :     }
    2804                 :          0 :     catch( const uno::RuntimeException& rRuntimeException )
    2805                 :            :     {
    2806         [ #  # ]:          0 :         m_pImpl->AddLog( rRuntimeException.Message );
    2807   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    2808                 :          0 :         throw;
    2809                 :            :     }
    2810   [ #  #  #  #  :          0 :     catch( const uno::Exception& rException )
             #  #  #  # ]
    2811                 :            :     {
    2812         [ #  # ]:          0 :           m_pImpl->AddLog( rException.Message );
    2813   [ #  #  #  # ]:          0 :           m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    2814                 :            : 
    2815         [ #  # ]:          0 :           uno::Any aCaught( ::cppu::getCaughtException() );
    2816                 :            :         throw embed::StorageWrappedTargetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Can't clone stream!" ) ),
    2817                 :            :                                                  uno::Reference< io::XInputStream >(),
    2818   [ #  #  #  # ]:          0 :                                                  aCaught );
    2819         [ #  # ]:          0 :     }
    2820                 :            : }
    2821                 :            : 
    2822                 :            : //-----------------------------------------------
    2823                 :          0 : uno::Reference< io::XStream > SAL_CALL OStorage::cloneEncryptedStreamElement(
    2824                 :            :     const ::rtl::OUString& aStreamName,
    2825                 :            :     const ::rtl::OUString& aPass )
    2826                 :            :         throw ( embed::InvalidStorageException,
    2827                 :            :                 lang::IllegalArgumentException,
    2828                 :            :                 packages::NoEncryptionException,
    2829                 :            :                 packages::WrongPasswordException,
    2830                 :            :                 io::IOException,
    2831                 :            :                 embed::StorageWrappedTargetException,
    2832                 :            :                 uno::RuntimeException )
    2833                 :            : {
    2834                 :            :     RTL_LOGFILE_CONTEXT( aLog, "package (mv76033) OStorage::cloneEncryptedStreamElement" );
    2835                 :            : 
    2836 [ #  # ][ #  # ]:          0 :     return cloneEncryptedStream( aStreamName, ::comphelper::OStorageHelper::CreatePackageEncryptionData( aPass ) );
                 [ #  # ]
    2837                 :            : }
    2838                 :            : 
    2839                 :            : //-----------------------------------------------
    2840                 :          0 : void SAL_CALL OStorage::copyLastCommitTo(
    2841                 :            :             const uno::Reference< embed::XStorage >& xTargetStorage )
    2842                 :            :         throw ( embed::InvalidStorageException,
    2843                 :            :                 lang::IllegalArgumentException,
    2844                 :            :                 io::IOException,
    2845                 :            :                 embed::StorageWrappedTargetException,
    2846                 :            :                 uno::RuntimeException )
    2847                 :            : {
    2848                 :            :     RTL_LOGFILE_CONTEXT( aLog, "package (mv76033) OStorage::copyLastCommitTo" );
    2849                 :            : 
    2850         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    2851                 :            : 
    2852         [ #  # ]:          0 :     if ( !m_pImpl )
    2853                 :            :     {
    2854 [ #  # ][ #  # ]:          0 :         ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    2855 [ #  # ][ #  # ]:          0 :         throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    2856                 :            :     }
    2857                 :            : 
    2858                 :            :     try
    2859                 :            :     {
    2860         [ #  # ]:          0 :         m_pImpl->CopyLastCommitTo( xTargetStorage );
    2861                 :            :     }
    2862                 :          0 :     catch( const embed::InvalidStorageException& rInvalidStorageException )
    2863                 :            :     {
    2864         [ #  # ]:          0 :         m_pImpl->AddLog( rInvalidStorageException.Message );
    2865   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    2866                 :          0 :         throw;
    2867                 :            :     }
    2868                 :          0 :     catch( const lang::IllegalArgumentException& rIllegalArgumentException )
    2869                 :            :     {
    2870         [ #  # ]:          0 :         m_pImpl->AddLog( rIllegalArgumentException.Message );
    2871   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    2872                 :          0 :         throw;
    2873                 :            :     }
    2874                 :          0 :     catch( const embed::StorageWrappedTargetException& rStorageWrappedTargetException )
    2875                 :            :     {
    2876         [ #  # ]:          0 :         m_pImpl->AddLog( rStorageWrappedTargetException.Message );
    2877   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    2878                 :          0 :         throw;
    2879                 :            :     }
    2880                 :          0 :     catch( const io::IOException& rIOException )
    2881                 :            :     {
    2882         [ #  # ]:          0 :         m_pImpl->AddLog( rIOException.Message );
    2883   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    2884                 :          0 :         throw;
    2885                 :            :     }
    2886                 :          0 :     catch( const uno::RuntimeException& rRuntimeException )
    2887                 :            :     {
    2888         [ #  # ]:          0 :         m_pImpl->AddLog( rRuntimeException.Message );
    2889   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    2890                 :          0 :         throw;
    2891                 :            :     }
    2892   [ #  #  #  #  :          0 :     catch( const uno::Exception& rException )
                #  #  # ]
    2893                 :            :     {
    2894         [ #  # ]:          0 :           m_pImpl->AddLog( rException.Message );
    2895   [ #  #  #  # ]:          0 :           m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    2896                 :            : 
    2897         [ #  # ]:          0 :           uno::Any aCaught( ::cppu::getCaughtException() );
    2898                 :            :         throw embed::StorageWrappedTargetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Can't copy last commit version!" ) ),
    2899                 :            :                                                  uno::Reference< io::XInputStream >(),
    2900   [ #  #  #  # ]:          0 :                                                  aCaught );
    2901         [ #  # ]:          0 :     }
    2902                 :            : 
    2903                 :          0 : }
    2904                 :            : 
    2905                 :            : //-----------------------------------------------
    2906                 :          0 : void SAL_CALL OStorage::copyStorageElementLastCommitTo(
    2907                 :            :             const ::rtl::OUString& aStorName,
    2908                 :            :             const uno::Reference< embed::XStorage >& xTargetStorage )
    2909                 :            :         throw ( embed::InvalidStorageException,
    2910                 :            :                 lang::IllegalArgumentException,
    2911                 :            :                 io::IOException,
    2912                 :            :                 embed::StorageWrappedTargetException,
    2913                 :            :                 uno::RuntimeException )
    2914                 :            : {
    2915                 :            :     RTL_LOGFILE_CONTEXT( aLog, "package (mv76033) OStorage::copyStorageElementLastCommitTo" );
    2916                 :            : 
    2917         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    2918                 :            : 
    2919         [ #  # ]:          0 :     if ( !m_pImpl )
    2920                 :            :     {
    2921 [ #  # ][ #  # ]:          0 :         ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    2922 [ #  # ][ #  # ]:          0 :         throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    2923                 :            :     }
    2924                 :            : 
    2925 [ #  # ][ #  # ]:          0 :     if ( aStorName.isEmpty() || !::comphelper::OStorageHelper::IsValidZipEntryFileName( aStorName, sal_False ) )
         [ #  # ][ #  # ]
    2926 [ #  # ][ #  # ]:          0 :         throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Unexpected entry name syntax." ) ), uno::Reference< uno::XInterface >(), 1 );
    2927                 :            : 
    2928 [ #  # ][ #  # ]:          0 :     if ( m_pData->m_nStorageType == embed::StorageFormats::OFOPXML && aStorName == "_rels" )
                 [ #  # ]
    2929 [ #  # ][ #  # ]:          0 :         throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 1 ); // unacceptable storage name
    2930                 :            : 
    2931                 :            :     // it's allways possible to read written storage in this implementation
    2932                 :          0 :     sal_Int32 nStorageMode = embed::ElementModes::READ;
    2933                 :            : 
    2934                 :            :     try
    2935                 :            :     {
    2936         [ #  # ]:          0 :         SotElement_Impl *pElement = m_pImpl->FindElement( aStorName );
    2937         [ #  # ]:          0 :         if ( !pElement )
    2938                 :            :         {
    2939                 :            :             // element does not exist, throw exception
    2940 [ #  # ][ #  # ]:          0 :             throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); // TODO: access_denied
    2941                 :            :         }
    2942         [ #  # ]:          0 :         else if ( !pElement->m_bIsStorage )
    2943                 :            :         {
    2944 [ #  # ][ #  # ]:          0 :             throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    2945                 :            :         }
    2946                 :            : 
    2947         [ #  # ]:          0 :         if ( !pElement->m_pStorage )
    2948         [ #  # ]:          0 :             m_pImpl->OpenSubStorage( pElement, nStorageMode );
    2949                 :            : 
    2950                 :          0 :         uno::Reference< embed::XStorage > xResult;
    2951         [ #  # ]:          0 :         if ( pElement->m_pStorage )
    2952                 :            :         {
    2953                 :            :             // the existence of m_pAntiImpl of the child is not interesting,
    2954                 :            :             // the copy will be created internally
    2955                 :            : 
    2956         [ #  # ]:          0 :             pElement->m_pStorage->CopyLastCommitTo( xTargetStorage );
    2957                 :            :         }
    2958                 :            :         else
    2959 [ #  # ][ #  # ]:          0 :             throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); // TODO: general_error
    2960                 :            :     }
    2961                 :          0 :     catch( const embed::InvalidStorageException& rInvalidStorageException )
    2962                 :            :     {
    2963         [ #  # ]:          0 :         m_pImpl->AddLog( rInvalidStorageException.Message );
    2964   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    2965                 :          0 :         throw;
    2966                 :            :     }
    2967                 :          0 :     catch( const lang::IllegalArgumentException& rIllegalArgumentException )
    2968                 :            :     {
    2969         [ #  # ]:          0 :         m_pImpl->AddLog( rIllegalArgumentException.Message );
    2970   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    2971                 :          0 :         throw;
    2972                 :            :     }
    2973                 :          0 :     catch( const io::IOException& rIOException )
    2974                 :            :     {
    2975         [ #  # ]:          0 :         m_pImpl->AddLog( rIOException.Message );
    2976   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    2977                 :          0 :         throw;
    2978                 :            :     }
    2979                 :          0 :     catch( const embed::StorageWrappedTargetException& rStorageWrappedTargetException )
    2980                 :            :     {
    2981         [ #  # ]:          0 :         m_pImpl->AddLog( rStorageWrappedTargetException.Message );
    2982   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    2983                 :          0 :         throw;
    2984                 :            :     }
    2985                 :          0 :     catch( const uno::RuntimeException& rRuntimeException )
    2986                 :            :     {
    2987         [ #  # ]:          0 :         m_pImpl->AddLog( rRuntimeException.Message );
    2988   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    2989                 :          0 :         throw;
    2990                 :            :     }
    2991   [ #  #  #  #  :          0 :     catch( const uno::Exception& rException )
                #  #  # ]
    2992                 :            :     {
    2993         [ #  # ]:          0 :           m_pImpl->AddLog( rException.Message );
    2994   [ #  #  #  # ]:          0 :           m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    2995                 :            : 
    2996         [ #  # ]:          0 :           uno::Any aCaught( ::cppu::getCaughtException() );
    2997                 :            :         throw embed::StorageWrappedTargetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Can't copy last commit element version!" ) ),
    2998                 :            :                                                  uno::Reference< io::XInputStream >(),
    2999   [ #  #  #  # ]:          0 :                                                  aCaught );
    3000         [ #  # ]:          0 :     }
    3001                 :          0 : }
    3002                 :            : 
    3003                 :            : //-----------------------------------------------
    3004                 :        948 : sal_Bool SAL_CALL OStorage::isStreamElement( const ::rtl::OUString& aElementName )
    3005                 :            :         throw ( embed::InvalidStorageException,
    3006                 :            :                 lang::IllegalArgumentException,
    3007                 :            :                 container::NoSuchElementException,
    3008                 :            :                 uno::RuntimeException )
    3009                 :            : {
    3010         [ +  - ]:        948 :     ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    3011                 :            : 
    3012         [ -  + ]:        948 :     if ( !m_pImpl )
    3013                 :            :     {
    3014 [ #  # ][ #  # ]:          0 :         ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    3015 [ #  # ][ #  # ]:          0 :         throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    3016                 :            :     }
    3017                 :            : 
    3018 [ +  - ][ +  - ]:        948 :     if ( aElementName.isEmpty() || !::comphelper::OStorageHelper::IsValidZipEntryFileName( aElementName, sal_False ) )
         [ -  + ][ -  + ]
    3019 [ #  # ][ #  # ]:          0 :         throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Unexpected entry name syntax." ) ), uno::Reference< uno::XInterface >(), 1 );
    3020                 :            : 
    3021 [ -  + ][ #  # ]:        948 :     if ( m_pData->m_nStorageType == embed::StorageFormats::OFOPXML && aElementName == "_rels" )
                 [ -  + ]
    3022 [ #  # ][ #  # ]:          0 :         throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 1 ); // unacceptable name
    3023                 :            : 
    3024                 :        948 :     SotElement_Impl* pElement = NULL;
    3025                 :            : 
    3026                 :            :     try
    3027                 :            :     {
    3028         [ +  - ]:        948 :         pElement = m_pImpl->FindElement( aElementName );
    3029                 :            :     }
    3030                 :          0 :     catch( const embed::InvalidStorageException& rInvalidStorageException )
    3031                 :            :     {
    3032         [ #  # ]:          0 :         m_pImpl->AddLog( rInvalidStorageException.Message );
    3033   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3034                 :          0 :         throw;
    3035                 :            :     }
    3036                 :          0 :     catch( const lang::IllegalArgumentException& rIllegalArgumentException )
    3037                 :            :     {
    3038         [ #  # ]:          0 :         m_pImpl->AddLog( rIllegalArgumentException.Message );
    3039   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3040                 :          0 :         throw;
    3041                 :            :     }
    3042                 :          0 :     catch( const container::NoSuchElementException& rNoSuchElementException )
    3043                 :            :     {
    3044         [ #  # ]:          0 :         m_pImpl->AddLog( rNoSuchElementException.Message );
    3045   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3046                 :          0 :         throw;
    3047                 :            :     }
    3048                 :          0 :     catch( const uno::RuntimeException& rRuntimeException )
    3049                 :            :     {
    3050         [ #  # ]:          0 :         m_pImpl->AddLog( rRuntimeException.Message );
    3051   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3052                 :          0 :         throw;
    3053                 :            :     }
    3054   [ #  #  #  #  :          0 :     catch( const uno::Exception& rException )
                   #  # ]
    3055                 :            :     {
    3056         [ #  # ]:          0 :           m_pImpl->AddLog( rException.Message );
    3057   [ #  #  #  # ]:          0 :           m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3058                 :            : 
    3059         [ #  # ]:          0 :           uno::Any aCaught( ::cppu::getCaughtException() );
    3060                 :            :         throw lang::WrappedTargetRuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Can't detect whether it is a stream!" ) ),
    3061                 :            :                                                  uno::Reference< io::XInputStream >(),
    3062   [ #  #  #  # ]:          0 :                                                  aCaught );
    3063                 :            :     }
    3064                 :            : 
    3065         [ +  + ]:        948 :     if ( !pElement )
    3066 [ +  - ][ +  - ]:         16 :         throw container::NoSuchElementException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); //???
    3067                 :            : 
    3068         [ +  - ]:        948 :     return !pElement->m_bIsStorage;
    3069                 :            : }
    3070                 :            : 
    3071                 :            : //-----------------------------------------------
    3072                 :       5136 : sal_Bool SAL_CALL OStorage::isStorageElement( const ::rtl::OUString& aElementName )
    3073                 :            :         throw ( embed::InvalidStorageException,
    3074                 :            :                 lang::IllegalArgumentException,
    3075                 :            :                 container::NoSuchElementException,
    3076                 :            :                 uno::RuntimeException )
    3077                 :            : {
    3078         [ +  - ]:       5136 :     ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    3079                 :            : 
    3080         [ -  + ]:       5136 :     if ( !m_pImpl )
    3081                 :            :     {
    3082 [ #  # ][ #  # ]:          0 :         ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    3083 [ #  # ][ #  # ]:          0 :         throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    3084                 :            :     }
    3085                 :            : 
    3086 [ +  - ][ +  - ]:       5136 :     if ( aElementName.isEmpty() || !::comphelper::OStorageHelper::IsValidZipEntryFileName( aElementName, sal_False ) )
         [ -  + ][ -  + ]
    3087 [ #  # ][ #  # ]:          0 :         throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Unexpected entry name syntax." ) ), uno::Reference< uno::XInterface >(), 1 );
    3088                 :            : 
    3089 [ +  + ][ -  + ]:       5136 :     if ( m_pData->m_nStorageType == embed::StorageFormats::OFOPXML && aElementName == "_rels" )
                 [ -  + ]
    3090 [ #  # ][ #  # ]:          0 :         throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 1 );
    3091                 :            : 
    3092                 :       5136 :     SotElement_Impl* pElement = NULL;
    3093                 :            : 
    3094                 :            :     try
    3095                 :            :     {
    3096         [ +  - ]:       5136 :         pElement = m_pImpl->FindElement( aElementName );
    3097                 :            :     }
    3098                 :          0 :     catch( const embed::InvalidStorageException& rInvalidStorageException )
    3099                 :            :     {
    3100         [ #  # ]:          0 :         m_pImpl->AddLog( rInvalidStorageException.Message );
    3101   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3102                 :          0 :         throw;
    3103                 :            :     }
    3104                 :          0 :     catch( const lang::IllegalArgumentException& rIllegalArgumentException )
    3105                 :            :     {
    3106         [ #  # ]:          0 :         m_pImpl->AddLog( rIllegalArgumentException.Message );
    3107   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3108                 :          0 :         throw;
    3109                 :            :     }
    3110                 :          0 :     catch( const container::NoSuchElementException& rNoSuchElementException )
    3111                 :            :     {
    3112         [ #  # ]:          0 :         m_pImpl->AddLog( rNoSuchElementException.Message );
    3113   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3114                 :          0 :         throw;
    3115                 :            :     }
    3116                 :          0 :     catch( const uno::RuntimeException& rRuntimeException )
    3117                 :            :     {
    3118         [ #  # ]:          0 :         m_pImpl->AddLog( rRuntimeException.Message );
    3119   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3120                 :          0 :         throw;
    3121                 :            :     }
    3122   [ #  #  #  #  :          0 :     catch( const uno::Exception& rException )
                   #  # ]
    3123                 :            :     {
    3124         [ #  # ]:          0 :           m_pImpl->AddLog( rException.Message );
    3125   [ #  #  #  # ]:          0 :           m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3126                 :            : 
    3127         [ #  # ]:          0 :           uno::Any aCaught( ::cppu::getCaughtException() );
    3128                 :            :         throw lang::WrappedTargetRuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "can't detect whether it is a storage" ) ),
    3129                 :            :                                                  uno::Reference< io::XInputStream >(),
    3130   [ #  #  #  # ]:          0 :                                                  aCaught );
    3131                 :            :     }
    3132                 :            : 
    3133         [ +  + ]:       5136 :     if ( !pElement )
    3134 [ +  - ][ +  - ]:        205 :         throw container::NoSuchElementException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); //???
    3135                 :            : 
    3136         [ +  - ]:       5136 :     return pElement->m_bIsStorage;
    3137                 :            : }
    3138                 :            : 
    3139                 :            : //-----------------------------------------------
    3140                 :        220 : void SAL_CALL OStorage::removeElement( const ::rtl::OUString& aElementName )
    3141                 :            :         throw ( embed::InvalidStorageException,
    3142                 :            :                 lang::IllegalArgumentException,
    3143                 :            :                 container::NoSuchElementException,
    3144                 :            :                 io::IOException,
    3145                 :            :                 embed::StorageWrappedTargetException,
    3146                 :            :                 uno::RuntimeException )
    3147                 :            : {
    3148                 :            :     RTL_LOGFILE_CONTEXT( aLog, "package (mv76033) OStorage::removeElement" );
    3149                 :            : 
    3150         [ +  - ]:        220 :     ::osl::ResettableMutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    3151                 :            : 
    3152         [ -  + ]:        220 :     if ( !m_pImpl )
    3153                 :            :     {
    3154 [ #  # ][ #  # ]:          0 :         ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    3155 [ #  # ][ #  # ]:          0 :         throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    3156                 :            :     }
    3157                 :            : 
    3158 [ +  - ][ +  - ]:        220 :     if ( aElementName.isEmpty() || !::comphelper::OStorageHelper::IsValidZipEntryFileName( aElementName, sal_False ) )
         [ -  + ][ -  + ]
    3159 [ #  # ][ #  # ]:          0 :         throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Unexpected entry name syntax." ) ), uno::Reference< uno::XInterface >(), 1 );
    3160                 :            : 
    3161 [ -  + ][ #  # ]:        220 :     if ( m_pData->m_nStorageType == embed::StorageFormats::OFOPXML && aElementName == "_rels" )
                 [ -  + ]
    3162 [ #  # ][ #  # ]:          0 :         throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 1 ); // TODO: unacceptable name
    3163                 :            : 
    3164         [ -  + ]:        220 :     if ( !( m_pImpl->m_nStorageMode & embed::ElementModes::WRITE ) )
    3165 [ #  # ][ #  # ]:          0 :         throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); // TODO: access denied
    3166                 :            : 
    3167                 :            :     try
    3168                 :            :     {
    3169         [ +  - ]:        220 :         SotElement_Impl* pElement = m_pImpl->FindElement( aElementName );
    3170                 :            : 
    3171         [ +  + ]:        220 :         if ( !pElement )
    3172 [ +  - ][ +  - ]:        138 :             throw container::NoSuchElementException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); //???
    3173                 :            : 
    3174         [ +  - ]:         82 :         m_pImpl->RemoveElement( pElement );
    3175                 :            : 
    3176                 :         82 :         m_pImpl->m_bIsModified = sal_True;
    3177                 :         82 :         m_pImpl->m_bBroadcastModified = sal_True;
    3178                 :            :     }
    3179                 :          0 :     catch( const embed::InvalidStorageException& rInvalidStorageException )
    3180                 :            :     {
    3181         [ #  # ]:          0 :         m_pImpl->AddLog( rInvalidStorageException.Message );
    3182   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3183                 :          0 :         throw;
    3184                 :            :     }
    3185                 :          0 :     catch( const lang::IllegalArgumentException& rIllegalArgumentException )
    3186                 :            :     {
    3187         [ #  # ]:          0 :         m_pImpl->AddLog( rIllegalArgumentException.Message );
    3188   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3189                 :          0 :         throw;
    3190                 :            :     }
    3191                 :        276 :     catch( const container::NoSuchElementException& rNoSuchElementException )
    3192                 :            :     {
    3193         [ -  + ]:        138 :         m_pImpl->AddLog( rNoSuchElementException.Message );
    3194 [ -  + ][ -  + ]:        138 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3195                 :        138 :         throw;
    3196                 :            :     }
    3197                 :          0 :     catch( const io::IOException& rIOException )
    3198                 :            :     {
    3199         [ #  # ]:          0 :         m_pImpl->AddLog( rIOException.Message );
    3200   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3201                 :          0 :         throw;
    3202                 :            :     }
    3203                 :          0 :     catch( const embed::StorageWrappedTargetException& rStorageWrappedTargetException )
    3204                 :            :     {
    3205         [ #  # ]:          0 :         m_pImpl->AddLog( rStorageWrappedTargetException.Message );
    3206   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3207                 :          0 :         throw;
    3208                 :            :     }
    3209                 :          0 :     catch( const uno::RuntimeException& rRuntimeException )
    3210                 :            :     {
    3211         [ #  # ]:          0 :         m_pImpl->AddLog( rRuntimeException.Message );
    3212   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3213                 :          0 :         throw;
    3214                 :            :     }
    3215   [ -  -  -  +  :        138 :     catch( const uno::Exception& rException )
             -  -  -  - ]
    3216                 :            :     {
    3217         [ #  # ]:          0 :           m_pImpl->AddLog( rException.Message );
    3218   [ #  #  #  # ]:          0 :           m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3219                 :            : 
    3220         [ #  # ]:          0 :           uno::Any aCaught( ::cppu::getCaughtException() );
    3221                 :            :         throw embed::StorageWrappedTargetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Can't remove element!" ) ),
    3222                 :            :                                                  uno::Reference< io::XInputStream >(),
    3223   [ #  #  #  # ]:          0 :                                                  aCaught );
    3224                 :            :     }
    3225                 :            : 
    3226         [ +  - ]:         82 :     aGuard.clear();
    3227                 :            : 
    3228 [ +  - ][ +  - ]:        220 :     BroadcastModifiedIfNecessary();
    3229                 :         82 : }
    3230                 :            : 
    3231                 :            : //-----------------------------------------------
    3232                 :          4 : void SAL_CALL OStorage::renameElement( const ::rtl::OUString& aElementName, const ::rtl::OUString& aNewName )
    3233                 :            :         throw ( embed::InvalidStorageException,
    3234                 :            :                 lang::IllegalArgumentException,
    3235                 :            :                 container::NoSuchElementException,
    3236                 :            :                 container::ElementExistException,
    3237                 :            :                 io::IOException,
    3238                 :            :                 embed::StorageWrappedTargetException,
    3239                 :            :                 uno::RuntimeException )
    3240                 :            : {
    3241                 :            :     RTL_LOGFILE_CONTEXT( aLog, "package (mv76033) OStorage::renameElement" );
    3242                 :            : 
    3243         [ +  - ]:          4 :     ::osl::ResettableMutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    3244                 :            : 
    3245         [ -  + ]:          4 :     if ( !m_pImpl )
    3246                 :            :     {
    3247 [ #  # ][ #  # ]:          0 :         ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    3248 [ #  # ][ #  # ]:          0 :         throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    3249                 :            :     }
    3250                 :            : 
    3251 [ +  - ][ +  - ]:         12 :     if ( aElementName.isEmpty() || !::comphelper::OStorageHelper::IsValidZipEntryFileName( aElementName, sal_False )
           [ +  -  +  - ]
         [ -  + ][ -  + ]
    3252         [ +  - ]:          8 :       || aNewName.isEmpty() || !::comphelper::OStorageHelper::IsValidZipEntryFileName( aNewName, sal_False ) )
    3253 [ #  # ][ #  # ]:          0 :         throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Unexpected entry name syntax." ) ), uno::Reference< uno::XInterface >(), 1 );
    3254                 :            : 
    3255 [ -  + ][ #  # ]:          4 :     if ( m_pData->m_nStorageType == embed::StorageFormats::OFOPXML && ( aElementName == "_rels" || aNewName == "_rels" ) )
         [ #  # ][ -  + ]
    3256 [ #  # ][ #  # ]:          0 :         throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 0 ); // TODO: unacceptable element name
    3257                 :            : 
    3258         [ -  + ]:          4 :     if ( !( m_pImpl->m_nStorageMode & embed::ElementModes::WRITE ) )
    3259 [ #  # ][ #  # ]:          0 :         throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); // TODO: access denied
    3260                 :            : 
    3261                 :            :     try
    3262                 :            :     {
    3263         [ +  - ]:          4 :         SotElement_Impl* pRefElement = m_pImpl->FindElement( aNewName );
    3264         [ -  + ]:          4 :         if ( pRefElement )
    3265 [ #  # ][ #  # ]:          0 :             throw container::ElementExistException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); //???
    3266                 :            : 
    3267         [ +  - ]:          4 :         SotElement_Impl* pElement = m_pImpl->FindElement( aElementName );
    3268         [ -  + ]:          4 :         if ( !pElement )
    3269 [ #  # ][ #  # ]:          0 :             throw container::NoSuchElementException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); //???
    3270                 :            : 
    3271                 :          4 :         pElement->m_aName = aNewName;
    3272                 :            : 
    3273                 :          4 :         m_pImpl->m_bIsModified = sal_True;
    3274                 :          4 :         m_pImpl->m_bBroadcastModified = sal_True;
    3275                 :            :     }
    3276                 :          0 :     catch( const embed::InvalidStorageException& rInvalidStorageException )
    3277                 :            :     {
    3278         [ #  # ]:          0 :         m_pImpl->AddLog( rInvalidStorageException.Message );
    3279   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3280                 :          0 :         throw;
    3281                 :            :     }
    3282                 :          0 :     catch( const lang::IllegalArgumentException& rIllegalArgumentException )
    3283                 :            :     {
    3284         [ #  # ]:          0 :         m_pImpl->AddLog( rIllegalArgumentException.Message );
    3285   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3286                 :          0 :         throw;
    3287                 :            :     }
    3288                 :          0 :     catch( const container::NoSuchElementException& rNoSuchElementException )
    3289                 :            :     {
    3290         [ #  # ]:          0 :         m_pImpl->AddLog( rNoSuchElementException.Message );
    3291   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3292                 :          0 :         throw;
    3293                 :            :     }
    3294                 :          0 :     catch( const container::ElementExistException& rElementExistException )
    3295                 :            :     {
    3296         [ #  # ]:          0 :         m_pImpl->AddLog( rElementExistException.Message );
    3297   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3298                 :          0 :         throw;
    3299                 :            :     }
    3300                 :          0 :     catch( const io::IOException& rIOException )
    3301                 :            :     {
    3302         [ #  # ]:          0 :         m_pImpl->AddLog( rIOException.Message );
    3303   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3304                 :          0 :         throw;
    3305                 :            :     }
    3306                 :          0 :     catch( const embed::StorageWrappedTargetException& rStorageWrappedTargetException )
    3307                 :            :     {
    3308         [ #  # ]:          0 :         m_pImpl->AddLog( rStorageWrappedTargetException.Message );
    3309   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3310                 :          0 :         throw;
    3311                 :            :     }
    3312                 :          0 :     catch( const uno::RuntimeException& rRuntimeException )
    3313                 :            :     {
    3314         [ #  # ]:          0 :         m_pImpl->AddLog( rRuntimeException.Message );
    3315   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3316                 :          0 :         throw;
    3317                 :            :     }
    3318   [ #  #  #  #  :          0 :     catch( const uno::Exception& rException )
             #  #  #  #  
                      # ]
    3319                 :            :     {
    3320         [ #  # ]:          0 :           m_pImpl->AddLog( rException.Message );
    3321   [ #  #  #  # ]:          0 :           m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3322                 :            : 
    3323         [ #  # ]:          0 :           uno::Any aCaught( ::cppu::getCaughtException() );
    3324                 :            :         throw embed::StorageWrappedTargetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Can't rename element!" ) ),
    3325                 :            :                                                  uno::Reference< io::XInputStream >(),
    3326   [ #  #  #  # ]:          0 :                                                  aCaught );
    3327                 :            :     }
    3328                 :            : 
    3329         [ +  - ]:          4 :     aGuard.clear();
    3330                 :            : 
    3331 [ +  - ][ +  - ]:          4 :     BroadcastModifiedIfNecessary();
    3332                 :          4 : }
    3333                 :            : 
    3334                 :            : //-----------------------------------------------
    3335                 :         31 : void SAL_CALL OStorage::copyElementTo(  const ::rtl::OUString& aElementName,
    3336                 :            :                                         const uno::Reference< embed::XStorage >& xDest,
    3337                 :            :                                         const ::rtl::OUString& aNewName )
    3338                 :            :         throw ( embed::InvalidStorageException,
    3339                 :            :                 lang::IllegalArgumentException,
    3340                 :            :                 container::NoSuchElementException,
    3341                 :            :                 container::ElementExistException,
    3342                 :            :                 io::IOException,
    3343                 :            :                 embed::StorageWrappedTargetException,
    3344                 :            :                 uno::RuntimeException )
    3345                 :            : {
    3346                 :            :     RTL_LOGFILE_CONTEXT( aLog, "package (mv76033) OStorage::copyElementTo" );
    3347                 :            : 
    3348         [ +  - ]:         31 :     ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    3349                 :            : 
    3350         [ -  + ]:         31 :     if ( !m_pImpl )
    3351                 :            :     {
    3352 [ #  # ][ #  # ]:          0 :         ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    3353 [ #  # ][ #  # ]:          0 :         throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    3354                 :            :     }
    3355                 :            : 
    3356 [ +  - ][ +  - ]:         93 :     if ( aElementName.isEmpty() || !::comphelper::OStorageHelper::IsValidZipEntryFileName( aElementName, sal_False )
           [ +  -  +  - ]
         [ -  + ][ -  + ]
    3357         [ +  - ]:         62 :       || aNewName.isEmpty() || !::comphelper::OStorageHelper::IsValidZipEntryFileName( aNewName, sal_False ) )
    3358 [ #  # ][ #  # ]:          0 :         throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Unexpected entry name syntax." ) ), uno::Reference< uno::XInterface >(), 1 );
    3359                 :            : 
    3360         [ -  + ]:         31 :     if ( !xDest.is() )
    3361                 :            :         // || xDest == uno::Reference< uno::XInterface >( static_cast< OWeakObject* >( this ), uno::UNO_QUERY ) )
    3362 [ #  # ][ #  # ]:          0 :         throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 2 );
    3363                 :            : 
    3364 [ -  + ][ #  # ]:         31 :     if ( m_pData->m_nStorageType == embed::StorageFormats::OFOPXML && ( aElementName == "_rels" || aNewName == "_rels" ) )
         [ #  # ][ -  + ]
    3365 [ #  # ][ #  # ]:          0 :         throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 0 ); // unacceptable element name
    3366                 :            : 
    3367                 :            :     try
    3368                 :            :     {
    3369         [ +  - ]:         31 :         SotElement_Impl* pElement = m_pImpl->FindElement( aElementName );
    3370         [ -  + ]:         31 :         if ( !pElement )
    3371 [ #  # ][ #  # ]:          0 :             throw container::NoSuchElementException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    3372                 :            : 
    3373         [ +  - ]:         31 :         uno::Reference< XNameAccess > xNameAccess( xDest, uno::UNO_QUERY );
    3374         [ -  + ]:         31 :         if ( !xNameAccess.is() )
    3375 [ #  # ][ #  # ]:          0 :             throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    3376                 :            : 
    3377 [ +  - ][ +  - ]:         31 :         if ( xNameAccess->hasByName( aNewName ) )
                 [ -  + ]
    3378 [ #  # ][ #  # ]:          0 :             throw container::ElementExistException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    3379                 :            : 
    3380         [ +  - ]:         31 :         m_pImpl->CopyStorageElement( pElement, xDest, aNewName, sal_False );
    3381                 :            :     }
    3382                 :          0 :     catch( const embed::InvalidStorageException& rInvalidStorageException )
    3383                 :            :     {
    3384         [ #  # ]:          0 :         m_pImpl->AddLog( rInvalidStorageException.Message );
    3385   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3386                 :          0 :         throw;
    3387                 :            :     }
    3388                 :          0 :     catch( const lang::IllegalArgumentException& rIllegalArgumentException )
    3389                 :            :     {
    3390         [ #  # ]:          0 :         m_pImpl->AddLog( rIllegalArgumentException.Message );
    3391   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3392                 :          0 :         throw;
    3393                 :            :     }
    3394                 :          0 :     catch( const container::NoSuchElementException& rNoSuchElementException )
    3395                 :            :     {
    3396         [ #  # ]:          0 :         m_pImpl->AddLog( rNoSuchElementException.Message );
    3397   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3398                 :          0 :         throw;
    3399                 :            :     }
    3400                 :          0 :     catch( const container::ElementExistException& rElementExistException )
    3401                 :            :     {
    3402         [ #  # ]:          0 :         m_pImpl->AddLog( rElementExistException.Message );
    3403   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3404                 :          0 :         throw;
    3405                 :            :     }
    3406                 :          0 :     catch( const embed::StorageWrappedTargetException& rStorageWrappedTargetException )
    3407                 :            :     {
    3408         [ #  # ]:          0 :         m_pImpl->AddLog( rStorageWrappedTargetException.Message );
    3409   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3410                 :          0 :         throw;
    3411                 :            :     }
    3412                 :          0 :     catch( const io::IOException& rIOException )
    3413                 :            :     {
    3414         [ #  # ]:          0 :         m_pImpl->AddLog( rIOException.Message );
    3415   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3416                 :          0 :         throw;
    3417                 :            :     }
    3418                 :          0 :     catch( const uno::RuntimeException& rRuntimeException )
    3419                 :            :     {
    3420         [ #  # ]:          0 :         m_pImpl->AddLog( rRuntimeException.Message );
    3421   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3422                 :          0 :         throw;
    3423                 :            :     }
    3424   [ #  #  #  #  :          0 :     catch( const uno::Exception& rException )
             #  #  #  #  
                      # ]
    3425                 :            :     {
    3426         [ #  # ]:          0 :           m_pImpl->AddLog( rException.Message );
    3427   [ #  #  #  # ]:          0 :           m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3428                 :            : 
    3429         [ #  # ]:          0 :           uno::Any aCaught( ::cppu::getCaughtException() );
    3430                 :            :         throw embed::StorageWrappedTargetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Can't copy element!" ) ),
    3431                 :            :                                                  uno::Reference< io::XInputStream >(),
    3432   [ #  #  #  # ]:          0 :                                                  aCaught );
    3433         [ +  - ]:         31 :     }
    3434                 :         31 : }
    3435                 :            : 
    3436                 :            : 
    3437                 :            : //-----------------------------------------------
    3438                 :          0 : void SAL_CALL OStorage::moveElementTo(  const ::rtl::OUString& aElementName,
    3439                 :            :                                         const uno::Reference< embed::XStorage >& xDest,
    3440                 :            :                                         const ::rtl::OUString& aNewName )
    3441                 :            :         throw ( embed::InvalidStorageException,
    3442                 :            :                 lang::IllegalArgumentException,
    3443                 :            :                 container::NoSuchElementException,
    3444                 :            :                 container::ElementExistException,
    3445                 :            :                 io::IOException,
    3446                 :            :                 embed::StorageWrappedTargetException,
    3447                 :            :                 uno::RuntimeException )
    3448                 :            : {
    3449                 :            :     RTL_LOGFILE_CONTEXT( aLog, "package (mv76033) OStorage::moveElementTo" );
    3450                 :            : 
    3451         [ #  # ]:          0 :     ::osl::ResettableMutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    3452                 :            : 
    3453         [ #  # ]:          0 :     if ( !m_pImpl )
    3454                 :            :     {
    3455 [ #  # ][ #  # ]:          0 :         ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    3456 [ #  # ][ #  # ]:          0 :         throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    3457                 :            :     }
    3458                 :            : 
    3459 [ #  # ][ #  # ]:          0 :     if ( aElementName.isEmpty() || !::comphelper::OStorageHelper::IsValidZipEntryFileName( aElementName, sal_False )
           [ #  #  #  # ]
         [ #  # ][ #  # ]
    3460         [ #  # ]:          0 :       || aNewName.isEmpty() || !::comphelper::OStorageHelper::IsValidZipEntryFileName( aNewName, sal_False ) )
    3461 [ #  # ][ #  # ]:          0 :         throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Unexpected entry name syntax." ) ), uno::Reference< uno::XInterface >(), 1 );
    3462                 :            : 
    3463 [ #  # ][ #  # ]:          0 :     if ( !xDest.is() || xDest == uno::Reference< uno::XInterface >( static_cast< OWeakObject* >( this ), uno::UNO_QUERY ) )
         [ #  # ][ #  # ]
                 [ #  # ]
           [ #  #  #  # ]
    3464 [ #  # ][ #  # ]:          0 :         throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 2 );
    3465                 :            : 
    3466 [ #  # ][ #  # ]:          0 :     if ( m_pData->m_nStorageType == embed::StorageFormats::OFOPXML && ( aElementName == "_rels" || aNewName == "_rels" ) )
         [ #  # ][ #  # ]
    3467 [ #  # ][ #  # ]:          0 :         throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 0 ); // unacceptable element name
    3468                 :            : 
    3469         [ #  # ]:          0 :     if ( !( m_pImpl->m_nStorageMode & embed::ElementModes::WRITE ) )
    3470 [ #  # ][ #  # ]:          0 :         throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); // TODO: access denied
    3471                 :            : 
    3472                 :            :     try
    3473                 :            :     {
    3474         [ #  # ]:          0 :         SotElement_Impl* pElement = m_pImpl->FindElement( aElementName );
    3475         [ #  # ]:          0 :         if ( !pElement )
    3476 [ #  # ][ #  # ]:          0 :             throw container::NoSuchElementException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); //???
    3477                 :            : 
    3478         [ #  # ]:          0 :         uno::Reference< XNameAccess > xNameAccess( xDest, uno::UNO_QUERY );
    3479         [ #  # ]:          0 :         if ( !xNameAccess.is() )
    3480 [ #  # ][ #  # ]:          0 :             throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    3481                 :            : 
    3482 [ #  # ][ #  # ]:          0 :         if ( xNameAccess->hasByName( aNewName ) )
                 [ #  # ]
    3483 [ #  # ][ #  # ]:          0 :             throw container::ElementExistException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    3484                 :            : 
    3485         [ #  # ]:          0 :         m_pImpl->CopyStorageElement( pElement, xDest, aNewName, sal_False );
    3486                 :            : 
    3487         [ #  # ]:          0 :         m_pImpl->RemoveElement( pElement );
    3488                 :            : 
    3489                 :          0 :         m_pImpl->m_bIsModified = sal_True;
    3490                 :          0 :         m_pImpl->m_bBroadcastModified = sal_True;
    3491                 :            :     }
    3492                 :          0 :     catch( const embed::InvalidStorageException& rInvalidStorageException )
    3493                 :            :     {
    3494         [ #  # ]:          0 :         m_pImpl->AddLog( rInvalidStorageException.Message );
    3495   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3496                 :          0 :         throw;
    3497                 :            :     }
    3498                 :          0 :     catch( const lang::IllegalArgumentException& rIllegalArgumentException )
    3499                 :            :     {
    3500         [ #  # ]:          0 :         m_pImpl->AddLog( rIllegalArgumentException.Message );
    3501   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3502                 :          0 :         throw;
    3503                 :            :     }
    3504                 :          0 :     catch( const container::NoSuchElementException& rNoSuchElementException )
    3505                 :            :     {
    3506         [ #  # ]:          0 :         m_pImpl->AddLog( rNoSuchElementException.Message );
    3507   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3508                 :          0 :         throw;
    3509                 :            :     }
    3510                 :          0 :     catch( const container::ElementExistException& rElementExistException )
    3511                 :            :     {
    3512         [ #  # ]:          0 :         m_pImpl->AddLog( rElementExistException.Message );
    3513   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3514                 :          0 :         throw;
    3515                 :            :     }
    3516                 :          0 :     catch( const embed::StorageWrappedTargetException& rStorageWrappedTargetException )
    3517                 :            :     {
    3518         [ #  # ]:          0 :         m_pImpl->AddLog( rStorageWrappedTargetException.Message );
    3519   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3520                 :          0 :         throw;
    3521                 :            :     }
    3522                 :          0 :     catch( const io::IOException& rIOException )
    3523                 :            :     {
    3524         [ #  # ]:          0 :         m_pImpl->AddLog( rIOException.Message );
    3525   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3526                 :          0 :         throw;
    3527                 :            :     }
    3528                 :          0 :     catch( const uno::RuntimeException& rRuntimeException )
    3529                 :            :     {
    3530         [ #  # ]:          0 :         m_pImpl->AddLog( rRuntimeException.Message );
    3531   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3532                 :          0 :         throw;
    3533                 :            :     }
    3534   [ #  #  #  #  :          0 :     catch( const uno::Exception& rException )
             #  #  #  #  
                      # ]
    3535                 :            :     {
    3536         [ #  # ]:          0 :           m_pImpl->AddLog( rException.Message );
    3537   [ #  #  #  # ]:          0 :           m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3538                 :            : 
    3539         [ #  # ]:          0 :           uno::Any aCaught( ::cppu::getCaughtException() );
    3540                 :            :         throw embed::StorageWrappedTargetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Can't move element!" ) ),
    3541                 :            :                                                  uno::Reference< io::XInputStream >(),
    3542   [ #  #  #  # ]:          0 :                                                  aCaught );
    3543                 :            :     }
    3544                 :            : 
    3545         [ #  # ]:          0 :     aGuard.clear();
    3546                 :            : 
    3547 [ #  # ][ #  # ]:          0 :     BroadcastModifiedIfNecessary();
    3548                 :          0 : }
    3549                 :            : 
    3550                 :            : //____________________________________________________________________________________________________
    3551                 :            : //  XStorage2
    3552                 :            : //____________________________________________________________________________________________________
    3553                 :            : 
    3554                 :            : //-----------------------------------------------
    3555                 :          0 : uno::Reference< io::XStream > SAL_CALL OStorage::openEncryptedStream(
    3556                 :            :     const ::rtl::OUString& aStreamName, sal_Int32 nOpenMode, const uno::Sequence< beans::NamedValue >& aEncryptionData )
    3557                 :            :         throw ( embed::InvalidStorageException,
    3558                 :            :                 lang::IllegalArgumentException,
    3559                 :            :                 packages::NoEncryptionException,
    3560                 :            :                 packages::WrongPasswordException,
    3561                 :            :                 io::IOException,
    3562                 :            :                 embed::StorageWrappedTargetException,
    3563                 :            :                 uno::RuntimeException )
    3564                 :            : {
    3565                 :            :     RTL_LOGFILE_CONTEXT( aLog, "package (mv76033) OStorage::openEncryptedStream" );
    3566                 :            : 
    3567         [ #  # ]:          0 :     ::osl::ResettableMutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    3568                 :            : 
    3569         [ #  # ]:          0 :     if ( !m_pImpl )
    3570                 :            :     {
    3571 [ #  # ][ #  # ]:          0 :         ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    3572 [ #  # ][ #  # ]:          0 :         throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    3573                 :            :     }
    3574                 :            : 
    3575         [ #  # ]:          0 :     if ( m_pData->m_nStorageType != embed::StorageFormats::PACKAGE )
    3576 [ #  # ][ #  # ]:          0 :         packages::NoEncryptionException();
    3577                 :            : 
    3578 [ #  # ][ #  # ]:          0 :     if ( ( nOpenMode & embed::ElementModes::WRITE ) && m_pData->m_bReadOnlyWrap )
    3579 [ #  # ][ #  # ]:          0 :         throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); // TODO: access denied
    3580                 :            : 
    3581         [ #  # ]:          0 :     if ( !aEncryptionData.getLength() )
    3582 [ #  # ][ #  # ]:          0 :         throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 3 );
    3583                 :            : 
    3584                 :          0 :     uno::Reference< io::XStream > xResult;
    3585                 :            :     try
    3586                 :            :     {
    3587         [ #  # ]:          0 :         SotElement_Impl *pElement = OpenStreamElement_Impl( aStreamName, nOpenMode, sal_True );
    3588                 :            :         OSL_ENSURE( pElement && pElement->m_pStream, "In case element can not be created an exception must be thrown!" );
    3589                 :            : 
    3590 [ #  # ][ #  # ]:          0 :         xResult = pElement->m_pStream->GetStream( nOpenMode, aEncryptionData, sal_False );
         [ #  # ][ #  # ]
    3591                 :            :         OSL_ENSURE( xResult.is(), "The method must throw exception instead of removing empty result!\n" );
    3592                 :            : 
    3593         [ #  # ]:          0 :         if ( m_pData->m_bReadOnlyWrap )
    3594                 :            :         {
    3595                 :            :             // before the storage disposes the stream it must deregister itself as listener
    3596         [ #  # ]:          0 :             uno::Reference< lang::XComponent > xStreamComponent( xResult, uno::UNO_QUERY );
    3597         [ #  # ]:          0 :             if ( !xStreamComponent.is() )
    3598 [ #  # ][ #  # ]:          0 :                 throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    3599                 :            : 
    3600         [ #  # ]:          0 :             MakeLinkToSubComponent_Impl( xStreamComponent );
    3601                 :            :         }
    3602                 :            :     }
    3603                 :          0 :     catch( const embed::InvalidStorageException& rInvalidStorageException )
    3604                 :            :     {
    3605         [ #  # ]:          0 :         m_pImpl->AddLog( rInvalidStorageException.Message );
    3606   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3607                 :          0 :         throw;
    3608                 :            :     }
    3609                 :          0 :     catch( const lang::IllegalArgumentException& rIllegalArgumentException )
    3610                 :            :     {
    3611         [ #  # ]:          0 :         m_pImpl->AddLog( rIllegalArgumentException.Message );
    3612   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3613                 :          0 :         throw;
    3614                 :            :     }
    3615                 :          0 :     catch( const packages::NoEncryptionException& rNoEncryptionException )
    3616                 :            :     {
    3617         [ #  # ]:          0 :         m_pImpl->AddLog( rNoEncryptionException.Message );
    3618   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3619                 :          0 :         throw;
    3620                 :            :     }
    3621                 :          0 :     catch( const packages::WrongPasswordException& rWrongPasswordException )
    3622                 :            :     {
    3623         [ #  # ]:          0 :         m_pImpl->AddLog( rWrongPasswordException.Message );
    3624   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3625                 :          0 :         throw;
    3626                 :            :     }
    3627                 :          0 :     catch( const embed::StorageWrappedTargetException& rStorageWrappedTargetException )
    3628                 :            :     {
    3629         [ #  # ]:          0 :         m_pImpl->AddLog( rStorageWrappedTargetException.Message );
    3630   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3631                 :          0 :         throw;
    3632                 :            :     }
    3633                 :          0 :     catch( const io::IOException& rIOException )
    3634                 :            :     {
    3635         [ #  # ]:          0 :         m_pImpl->AddLog( rIOException.Message );
    3636   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3637                 :          0 :         throw;
    3638                 :            :     }
    3639                 :          0 :     catch( const uno::RuntimeException& rRuntimeException )
    3640                 :            :     {
    3641         [ #  # ]:          0 :         m_pImpl->AddLog( rRuntimeException.Message );
    3642   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3643                 :          0 :         throw;
    3644                 :            :     }
    3645   [ #  #  #  #  :          0 :     catch( const uno::Exception& rException )
             #  #  #  #  
                      # ]
    3646                 :            :     {
    3647         [ #  # ]:          0 :           m_pImpl->AddLog( rException.Message );
    3648   [ #  #  #  # ]:          0 :           m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3649                 :            : 
    3650         [ #  # ]:          0 :           uno::Any aCaught( ::cppu::getCaughtException() );
    3651                 :            :         throw embed::StorageWrappedTargetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Can't open encrypted stream stream!" ) ),
    3652                 :            :                                                  uno::Reference< io::XInputStream >(),
    3653   [ #  #  #  # ]:          0 :                                                  aCaught );
    3654                 :            :     }
    3655                 :            : 
    3656         [ #  # ]:          0 :     aGuard.clear();
    3657                 :            : 
    3658         [ #  # ]:          0 :     BroadcastModifiedIfNecessary();
    3659                 :            : 
    3660         [ #  # ]:          0 :     return xResult;
    3661                 :            : }
    3662                 :            : 
    3663                 :            : //-----------------------------------------------
    3664                 :          0 : uno::Reference< io::XStream > SAL_CALL OStorage::cloneEncryptedStream(
    3665                 :            :     const ::rtl::OUString& aStreamName,
    3666                 :            :     const uno::Sequence< beans::NamedValue >& aEncryptionData )
    3667                 :            :         throw ( embed::InvalidStorageException,
    3668                 :            :                 lang::IllegalArgumentException,
    3669                 :            :                 packages::NoEncryptionException,
    3670                 :            :                 packages::WrongPasswordException,
    3671                 :            :                 io::IOException,
    3672                 :            :                 embed::StorageWrappedTargetException,
    3673                 :            :                 uno::RuntimeException )
    3674                 :            : {
    3675                 :            :     RTL_LOGFILE_CONTEXT( aLog, "package (mv76033) OStorage::cloneEncryptedStream" );
    3676                 :            : 
    3677         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    3678                 :            : 
    3679         [ #  # ]:          0 :     if ( !m_pImpl )
    3680                 :            :     {
    3681 [ #  # ][ #  # ]:          0 :         ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    3682 [ #  # ][ #  # ]:          0 :         throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    3683                 :            :     }
    3684                 :            : 
    3685         [ #  # ]:          0 :     if ( m_pData->m_nStorageType != embed::StorageFormats::PACKAGE )
    3686 [ #  # ][ #  # ]:          0 :         packages::NoEncryptionException();
    3687                 :            : 
    3688         [ #  # ]:          0 :     if ( !aEncryptionData.getLength() )
    3689 [ #  # ][ #  # ]:          0 :         throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 2 );
    3690                 :            : 
    3691                 :            :     try
    3692                 :            :     {
    3693                 :          0 :         uno::Reference< io::XStream > xResult;
    3694 [ #  # ][ #  # ]:          0 :         m_pImpl->CloneStreamElement( aStreamName, sal_True, aEncryptionData, xResult );
                 [ #  # ]
    3695         [ #  # ]:          0 :         if ( !xResult.is() )
    3696 [ #  # ][ #  # ]:          0 :             throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    3697                 :          0 :         return xResult;
    3698                 :            :     }
    3699                 :          0 :     catch( const embed::InvalidStorageException& rInvalidStorageException )
    3700                 :            :     {
    3701         [ #  # ]:          0 :         m_pImpl->AddLog( rInvalidStorageException.Message );
    3702   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3703                 :          0 :         throw;
    3704                 :            :     }
    3705                 :          0 :     catch( const lang::IllegalArgumentException& rIllegalArgumentException )
    3706                 :            :     {
    3707         [ #  # ]:          0 :         m_pImpl->AddLog( rIllegalArgumentException.Message );
    3708   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3709                 :          0 :         throw;
    3710                 :            :     }
    3711                 :          0 :     catch( const packages::NoEncryptionException& rNoEncryptionException )
    3712                 :            :     {
    3713         [ #  # ]:          0 :         m_pImpl->AddLog( rNoEncryptionException.Message );
    3714   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3715                 :          0 :         throw;
    3716                 :            :     }
    3717                 :          0 :     catch( const packages::WrongPasswordException& rWrongPasswordException )
    3718                 :            :     {
    3719         [ #  # ]:          0 :         m_pImpl->AddLog( rWrongPasswordException.Message );
    3720   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3721                 :          0 :         throw;
    3722                 :            :     }
    3723                 :          0 :     catch( const io::IOException& rIOException )
    3724                 :            :     {
    3725         [ #  # ]:          0 :         m_pImpl->AddLog( rIOException.Message );
    3726   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3727                 :          0 :         throw;
    3728                 :            :     }
    3729                 :          0 :     catch( const embed::StorageWrappedTargetException& rStorageWrappedTargetException )
    3730                 :            :     {
    3731         [ #  # ]:          0 :         m_pImpl->AddLog( rStorageWrappedTargetException.Message );
    3732   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3733                 :          0 :         throw;
    3734                 :            :     }
    3735                 :          0 :     catch( const uno::RuntimeException& rRuntimeException )
    3736                 :            :     {
    3737         [ #  # ]:          0 :         m_pImpl->AddLog( rRuntimeException.Message );
    3738   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3739                 :          0 :         throw;
    3740                 :            :     }
    3741   [ #  #  #  #  :          0 :     catch( const uno::Exception& rException )
             #  #  #  #  
                      # ]
    3742                 :            :     {
    3743         [ #  # ]:          0 :           m_pImpl->AddLog( rException.Message );
    3744   [ #  #  #  # ]:          0 :           m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3745                 :            : 
    3746         [ #  # ]:          0 :           uno::Any aCaught( ::cppu::getCaughtException() );
    3747                 :            :         throw embed::StorageWrappedTargetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Can't clone encrypted stream!" ) ),
    3748                 :            :                                                  uno::Reference< io::XInputStream >(),
    3749   [ #  #  #  # ]:          0 :                                                  aCaught );
    3750         [ #  # ]:          0 :     }
    3751                 :            : }
    3752                 :            : 
    3753                 :            : 
    3754                 :            : //____________________________________________________________________________________________________
    3755                 :            : //  XStorageRawAccess
    3756                 :            : //____________________________________________________________________________________________________
    3757                 :            : 
    3758                 :            : //-----------------------------------------------
    3759                 :          0 : uno::Reference< io::XInputStream > SAL_CALL OStorage::getPlainRawStreamElement(
    3760                 :            :             const ::rtl::OUString& sStreamName )
    3761                 :            :         throw ( embed::InvalidStorageException,
    3762                 :            :                 lang::IllegalArgumentException,
    3763                 :            :                 container::NoSuchElementException,
    3764                 :            :                 io::IOException,
    3765                 :            :                 embed::StorageWrappedTargetException,
    3766                 :            :                 uno::RuntimeException )
    3767                 :            : {
    3768                 :            :     RTL_LOGFILE_CONTEXT( aLog, "package (mv76033) OStorage::getPlainRawStreamElement" );
    3769                 :            : 
    3770         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    3771                 :            : 
    3772         [ #  # ]:          0 :     if ( !m_pImpl )
    3773                 :            :     {
    3774 [ #  # ][ #  # ]:          0 :         ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    3775 [ #  # ][ #  # ]:          0 :         throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    3776                 :            :     }
    3777                 :            : 
    3778         [ #  # ]:          0 :     if ( m_pData->m_nStorageType == embed::StorageFormats::OFOPXML )
    3779 [ #  # ][ #  # ]:          0 :         throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); // the interface is not supported and must not be accessible
    3780                 :            : 
    3781 [ #  # ][ #  # ]:          0 :     if ( sStreamName.isEmpty() || !::comphelper::OStorageHelper::IsValidZipEntryFileName( sStreamName, sal_False ) )
         [ #  # ][ #  # ]
    3782 [ #  # ][ #  # ]:          0 :         throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Unexpected entry name syntax." ) ), uno::Reference< uno::XInterface >(), 1 );
    3783                 :            : 
    3784                 :          0 :     uno::Reference < io::XInputStream > xTempIn;
    3785                 :            :     try
    3786                 :            :     {
    3787         [ #  # ]:          0 :         SotElement_Impl* pElement = m_pImpl->FindElement( sStreamName );
    3788         [ #  # ]:          0 :         if ( !pElement )
    3789 [ #  # ][ #  # ]:          0 :             throw container::NoSuchElementException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    3790                 :            : 
    3791         [ #  # ]:          0 :         if ( !pElement->m_pStream )
    3792                 :            :         {
    3793         [ #  # ]:          0 :             m_pImpl->OpenSubStream( pElement );
    3794         [ #  # ]:          0 :             if ( !pElement->m_pStream )
    3795 [ #  # ][ #  # ]:          0 :                 throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    3796                 :            :         }
    3797                 :            : 
    3798         [ #  # ]:          0 :         uno::Reference< io::XInputStream > xRawInStream = pElement->m_pStream->GetPlainRawInStream();
    3799         [ #  # ]:          0 :         if ( !xRawInStream.is() )
    3800 [ #  # ][ #  # ]:          0 :             throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    3801                 :            : 
    3802                 :            :         uno::Reference < io::XOutputStream > xTempOut(
    3803 [ #  # ][ #  # ]:          0 :                             m_pImpl->GetServiceFactory()->createInstance (
    3804                 :          0 :                                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.io.TempFile" ) ) ),
    3805 [ #  # ][ #  # ]:          0 :                             uno::UNO_QUERY );
                 [ #  # ]
    3806 [ #  # ][ #  # ]:          0 :         xTempIn = uno::Reference < io::XInputStream >( xTempOut, uno::UNO_QUERY );
    3807         [ #  # ]:          0 :         uno::Reference < io::XSeekable > xSeek( xTempOut, uno::UNO_QUERY );
    3808                 :            : 
    3809 [ #  # ][ #  # ]:          0 :         if ( !xTempOut.is() || !xTempIn.is() || !xSeek.is() )
         [ #  # ][ #  # ]
    3810 [ #  # ][ #  # ]:          0 :             throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    3811                 :            : 
    3812                 :            :         // Copy temporary file to a new one
    3813         [ #  # ]:          0 :         ::comphelper::OStorageHelper::CopyInputToOutput( xRawInStream, xTempOut );
    3814 [ #  # ][ #  # ]:          0 :         xTempOut->closeOutput();
    3815 [ #  # ][ #  # ]:          0 :         xSeek->seek( 0 );
    3816                 :            :     }
    3817                 :          0 :     catch( const embed::InvalidStorageException& rInvalidStorageException )
    3818                 :            :     {
    3819         [ #  # ]:          0 :         m_pImpl->AddLog( rInvalidStorageException.Message );
    3820   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3821                 :          0 :         throw;
    3822                 :            :     }
    3823                 :          0 :     catch( const lang::IllegalArgumentException& rIllegalArgumentException )
    3824                 :            :     {
    3825         [ #  # ]:          0 :         m_pImpl->AddLog( rIllegalArgumentException.Message );
    3826   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3827                 :          0 :         throw;
    3828                 :            :     }
    3829                 :          0 :     catch( const container::NoSuchElementException& rNoSuchElementException )
    3830                 :            :     {
    3831         [ #  # ]:          0 :         m_pImpl->AddLog( rNoSuchElementException.Message );
    3832   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3833                 :          0 :         throw;
    3834                 :            :     }
    3835                 :          0 :     catch( const embed::StorageWrappedTargetException& rStorageWrappedTargetException )
    3836                 :            :     {
    3837         [ #  # ]:          0 :         m_pImpl->AddLog( rStorageWrappedTargetException.Message );
    3838   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3839                 :          0 :         throw;
    3840                 :            :     }
    3841                 :          0 :     catch( const io::IOException& rIOException )
    3842                 :            :     {
    3843         [ #  # ]:          0 :         m_pImpl->AddLog( rIOException.Message );
    3844   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3845                 :          0 :         throw;
    3846                 :            :     }
    3847                 :          0 :     catch( const uno::RuntimeException& rRuntimeException )
    3848                 :            :     {
    3849         [ #  # ]:          0 :         m_pImpl->AddLog( rRuntimeException.Message );
    3850   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3851                 :          0 :         throw;
    3852                 :            :     }
    3853   [ #  #  #  #  :          0 :     catch( const uno::Exception& rException )
             #  #  #  # ]
    3854                 :            :     {
    3855         [ #  # ]:          0 :           m_pImpl->AddLog( rException.Message );
    3856   [ #  #  #  # ]:          0 :           m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3857                 :            : 
    3858         [ #  # ]:          0 :           uno::Any aCaught( ::cppu::getCaughtException() );
    3859                 :            :         throw embed::StorageWrappedTargetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Can't get plain raw stream!" ) ),
    3860                 :            :                                                  uno::Reference< io::XInputStream >(),
    3861   [ #  #  #  # ]:          0 :                                                  aCaught );
    3862                 :            :     }
    3863                 :            : 
    3864         [ #  # ]:          0 :     return xTempIn;
    3865                 :            : }
    3866                 :            : 
    3867                 :            : //-----------------------------------------------
    3868                 :          0 : uno::Reference< io::XInputStream > SAL_CALL OStorage::getRawEncrStreamElement(
    3869                 :            :             const ::rtl::OUString& sStreamName )
    3870                 :            :         throw ( embed::InvalidStorageException,
    3871                 :            :                 lang::IllegalArgumentException,
    3872                 :            :                 packages::NoEncryptionException,
    3873                 :            :                 container::NoSuchElementException,
    3874                 :            :                 io::IOException,
    3875                 :            :                 embed::StorageWrappedTargetException,
    3876                 :            :                 uno::RuntimeException )
    3877                 :            : {
    3878                 :            :     RTL_LOGFILE_CONTEXT( aLog, "package (mv76033) OStorage::getRawEncrStreamElement" );
    3879                 :            : 
    3880         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    3881                 :            : 
    3882         [ #  # ]:          0 :     if ( !m_pImpl )
    3883                 :            :     {
    3884 [ #  # ][ #  # ]:          0 :         ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    3885 [ #  # ][ #  # ]:          0 :         throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    3886                 :            :     }
    3887                 :            : 
    3888         [ #  # ]:          0 :     if ( m_pData->m_nStorageType != embed::StorageFormats::PACKAGE )
    3889 [ #  # ][ #  # ]:          0 :         throw packages::NoEncryptionException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    3890                 :            : 
    3891 [ #  # ][ #  # ]:          0 :     if ( sStreamName.isEmpty() || !::comphelper::OStorageHelper::IsValidZipEntryFileName( sStreamName, sal_False ) )
         [ #  # ][ #  # ]
    3892 [ #  # ][ #  # ]:          0 :         throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Unexpected entry name syntax." ) ), uno::Reference< uno::XInterface >(), 1 );
    3893                 :            : 
    3894                 :          0 :     uno::Reference < io::XInputStream > xTempIn;
    3895                 :            :     try
    3896                 :            :     {
    3897         [ #  # ]:          0 :         SotElement_Impl* pElement = m_pImpl->FindElement( sStreamName );
    3898         [ #  # ]:          0 :         if ( !pElement )
    3899 [ #  # ][ #  # ]:          0 :             throw container::NoSuchElementException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    3900                 :            : 
    3901         [ #  # ]:          0 :         if ( !pElement->m_pStream )
    3902                 :            :         {
    3903         [ #  # ]:          0 :             m_pImpl->OpenSubStream( pElement );
    3904         [ #  # ]:          0 :             if ( !pElement->m_pStream )
    3905 [ #  # ][ #  # ]:          0 :                 throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    3906                 :            :         }
    3907                 :            : 
    3908 [ #  # ][ #  # ]:          0 :         if ( !pElement->m_pStream->IsEncrypted() )
    3909 [ #  # ][ #  # ]:          0 :             throw packages::NoEncryptionException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    3910                 :            : 
    3911         [ #  # ]:          0 :         uno::Reference< io::XInputStream > xRawInStream = pElement->m_pStream->GetRawInStream();
    3912         [ #  # ]:          0 :         if ( !xRawInStream.is() )
    3913 [ #  # ][ #  # ]:          0 :             throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    3914                 :            : 
    3915                 :            :         uno::Reference < io::XOutputStream > xTempOut(
    3916 [ #  # ][ #  # ]:          0 :                             m_pImpl->GetServiceFactory()->createInstance (
    3917                 :          0 :                                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.io.TempFile" ) ) ),
    3918 [ #  # ][ #  # ]:          0 :                             uno::UNO_QUERY );
                 [ #  # ]
    3919 [ #  # ][ #  # ]:          0 :         xTempIn = uno::Reference < io::XInputStream >( xTempOut, uno::UNO_QUERY );
    3920         [ #  # ]:          0 :         uno::Reference < io::XSeekable > xSeek( xTempOut, uno::UNO_QUERY );
    3921                 :            : 
    3922 [ #  # ][ #  # ]:          0 :         if ( !xTempOut.is() || !xTempIn.is() || !xSeek.is() )
         [ #  # ][ #  # ]
    3923 [ #  # ][ #  # ]:          0 :             throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    3924                 :            : 
    3925                 :            :         // Copy temporary file to a new one
    3926         [ #  # ]:          0 :         ::comphelper::OStorageHelper::CopyInputToOutput( xRawInStream, xTempOut );
    3927 [ #  # ][ #  # ]:          0 :         xTempOut->closeOutput();
    3928 [ #  # ][ #  # ]:          0 :         xSeek->seek( 0 );
    3929                 :            : 
    3930                 :            :     }
    3931                 :          0 :     catch( const embed::InvalidStorageException& rInvalidStorageException )
    3932                 :            :     {
    3933         [ #  # ]:          0 :         m_pImpl->AddLog( rInvalidStorageException.Message );
    3934   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3935                 :          0 :         throw;
    3936                 :            :     }
    3937                 :          0 :     catch( const lang::IllegalArgumentException& rIllegalArgumentException )
    3938                 :            :     {
    3939         [ #  # ]:          0 :         m_pImpl->AddLog( rIllegalArgumentException.Message );
    3940   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3941                 :          0 :         throw;
    3942                 :            :     }
    3943                 :          0 :     catch( const packages::NoEncryptionException& rNoEncryptionException )
    3944                 :            :     {
    3945         [ #  # ]:          0 :         m_pImpl->AddLog( rNoEncryptionException.Message );
    3946   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3947                 :          0 :         throw;
    3948                 :            :     }
    3949                 :          0 :     catch( const container::NoSuchElementException& rNoSuchElementException )
    3950                 :            :     {
    3951         [ #  # ]:          0 :         m_pImpl->AddLog( rNoSuchElementException.Message );
    3952   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3953                 :          0 :         throw;
    3954                 :            :     }
    3955                 :          0 :     catch( const embed::StorageWrappedTargetException& rStorageWrappedTargetException )
    3956                 :            :     {
    3957         [ #  # ]:          0 :         m_pImpl->AddLog( rStorageWrappedTargetException.Message );
    3958   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3959                 :          0 :         throw;
    3960                 :            :     }
    3961                 :          0 :     catch( const io::IOException& rIOException )
    3962                 :            :     {
    3963         [ #  # ]:          0 :         m_pImpl->AddLog( rIOException.Message );
    3964   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3965                 :          0 :         throw;
    3966                 :            :     }
    3967                 :          0 :     catch( const uno::RuntimeException& rRuntimeException )
    3968                 :            :     {
    3969         [ #  # ]:          0 :         m_pImpl->AddLog( rRuntimeException.Message );
    3970   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3971                 :          0 :         throw;
    3972                 :            :     }
    3973   [ #  #  #  #  :          0 :     catch( const uno::Exception& rException )
             #  #  #  #  
                      # ]
    3974                 :            :     {
    3975         [ #  # ]:          0 :           m_pImpl->AddLog( rException.Message );
    3976   [ #  #  #  # ]:          0 :           m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    3977                 :            : 
    3978         [ #  # ]:          0 :           uno::Any aCaught( ::cppu::getCaughtException() );
    3979                 :            :         throw embed::StorageWrappedTargetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Can't get raw stream!" ) ),
    3980                 :            :                                                  uno::Reference< io::XInputStream >(),
    3981   [ #  #  #  # ]:          0 :                                                  aCaught );
    3982                 :            :     }
    3983                 :            : 
    3984         [ #  # ]:          0 :     return xTempIn;
    3985                 :            : }
    3986                 :            : 
    3987                 :            : //-----------------------------------------------
    3988                 :          0 : void SAL_CALL OStorage::insertRawEncrStreamElement( const ::rtl::OUString& aStreamName,
    3989                 :            :                                 const uno::Reference< io::XInputStream >& xInStream )
    3990                 :            :         throw ( embed::InvalidStorageException,
    3991                 :            :                 lang::IllegalArgumentException,
    3992                 :            :                 packages::NoRawFormatException,
    3993                 :            :                 container::ElementExistException,
    3994                 :            :                 io::IOException,
    3995                 :            :                 embed::StorageWrappedTargetException,
    3996                 :            :                 uno::RuntimeException)
    3997                 :            : {
    3998                 :            :     RTL_LOGFILE_CONTEXT( aLog, "package (mv76033) OStorage::insertRawEncrStreamElement" );
    3999                 :            : 
    4000         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    4001                 :            : 
    4002         [ #  # ]:          0 :     if ( !m_pImpl )
    4003                 :            :     {
    4004 [ #  # ][ #  # ]:          0 :         ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    4005 [ #  # ][ #  # ]:          0 :         throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    4006                 :            :     }
    4007                 :            : 
    4008         [ #  # ]:          0 :     if ( m_pData->m_nStorageType != embed::StorageFormats::PACKAGE )
    4009 [ #  # ][ #  # ]:          0 :         throw packages::NoEncryptionException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    4010                 :            : 
    4011 [ #  # ][ #  # ]:          0 :     if ( aStreamName.isEmpty() || !::comphelper::OStorageHelper::IsValidZipEntryFileName( aStreamName, sal_False ) )
         [ #  # ][ #  # ]
    4012 [ #  # ][ #  # ]:          0 :         throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Unexpected entry name syntax." ) ), uno::Reference< uno::XInterface >(), 1 );
    4013                 :            : 
    4014         [ #  # ]:          0 :     if ( !xInStream.is() )
    4015 [ #  # ][ #  # ]:          0 :         throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 2 );
    4016                 :            : 
    4017         [ #  # ]:          0 :     if ( !( m_pImpl->m_nStorageMode & embed::ElementModes::WRITE ) )
    4018 [ #  # ][ #  # ]:          0 :         throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); // TODO: access denied
    4019                 :            : 
    4020                 :            :     try
    4021                 :            :     {
    4022         [ #  # ]:          0 :         SotElement_Impl* pElement = m_pImpl->FindElement( aStreamName );
    4023         [ #  # ]:          0 :         if ( pElement )
    4024 [ #  # ][ #  # ]:          0 :             throw container::ElementExistException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    4025                 :            : 
    4026         [ #  # ]:          0 :         m_pImpl->InsertRawStream( aStreamName, xInStream );
    4027                 :            :     }
    4028                 :          0 :     catch( const embed::InvalidStorageException& rInvalidStorageException )
    4029                 :            :     {
    4030         [ #  # ]:          0 :         m_pImpl->AddLog( rInvalidStorageException.Message );
    4031   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    4032                 :          0 :         throw;
    4033                 :            :     }
    4034                 :          0 :     catch( const lang::IllegalArgumentException& rIllegalArgumentException )
    4035                 :            :     {
    4036         [ #  # ]:          0 :         m_pImpl->AddLog( rIllegalArgumentException.Message );
    4037   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    4038                 :          0 :         throw;
    4039                 :            :     }
    4040                 :          0 :     catch( const packages::NoRawFormatException& rNoRawFormatException )
    4041                 :            :     {
    4042         [ #  # ]:          0 :         m_pImpl->AddLog( rNoRawFormatException.Message );
    4043   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    4044                 :          0 :         throw;
    4045                 :            :     }
    4046                 :          0 :     catch( const container::ElementExistException& rElementExistException )
    4047                 :            :     {
    4048         [ #  # ]:          0 :         m_pImpl->AddLog( rElementExistException.Message );
    4049   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    4050                 :          0 :         throw;
    4051                 :            :     }
    4052                 :          0 :     catch( const embed::StorageWrappedTargetException& rStorageWrappedTargetException )
    4053                 :            :     {
    4054         [ #  # ]:          0 :         m_pImpl->AddLog( rStorageWrappedTargetException.Message );
    4055   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    4056                 :          0 :         throw;
    4057                 :            :     }
    4058                 :          0 :     catch( const io::IOException& rIOException )
    4059                 :            :     {
    4060         [ #  # ]:          0 :         m_pImpl->AddLog( rIOException.Message );
    4061   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    4062                 :          0 :         throw;
    4063                 :            :     }
    4064                 :          0 :     catch( const uno::RuntimeException& rRuntimeException )
    4065                 :            :     {
    4066         [ #  # ]:          0 :         m_pImpl->AddLog( rRuntimeException.Message );
    4067   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    4068                 :          0 :         throw;
    4069                 :            :     }
    4070   [ #  #  #  #  :          0 :     catch( const uno::Exception& rException )
             #  #  #  #  
                      # ]
    4071                 :            :     {
    4072         [ #  # ]:          0 :           m_pImpl->AddLog( rException.Message );
    4073   [ #  #  #  # ]:          0 :           m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    4074                 :            : 
    4075         [ #  # ]:          0 :           uno::Any aCaught( ::cppu::getCaughtException() );
    4076                 :            :         throw embed::StorageWrappedTargetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Can't insert raw stream!" ) ),
    4077                 :            :                                                  uno::Reference< io::XInputStream >(),
    4078   [ #  #  #  # ]:          0 :                                                  aCaught );
    4079         [ #  # ]:          0 :     }
    4080                 :          0 : }
    4081                 :            : 
    4082                 :            : //____________________________________________________________________________________________________
    4083                 :            : //  XTransactedObject
    4084                 :            : //____________________________________________________________________________________________________
    4085                 :            : 
    4086                 :            : //-----------------------------------------------
    4087                 :       2098 : void SAL_CALL OStorage::commit()
    4088                 :            :         throw ( io::IOException,
    4089                 :            :                 embed::StorageWrappedTargetException,
    4090                 :            :                 uno::RuntimeException )
    4091                 :            : {
    4092                 :            :     RTL_LOGFILE_CONTEXT( aLog, "package (mv76033) OStorage::commit" );
    4093                 :            : 
    4094                 :       2098 :     uno::Reference< util::XModifiable > xParentModif;
    4095                 :            : 
    4096                 :            :     try {
    4097         [ +  - ]:       2098 :         BroadcastTransaction( STOR_MESS_PRECOMMIT );
    4098                 :            : 
    4099         [ +  - ]:       2098 :         ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    4100                 :            : 
    4101         [ -  + ]:       2098 :         if ( !m_pImpl )
    4102                 :            :         {
    4103 [ #  # ][ #  # ]:          0 :             ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    4104 [ #  # ][ #  # ]:          0 :             throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    4105                 :            :         }
    4106                 :            : 
    4107         [ -  + ]:       2098 :         if ( m_pData->m_bReadOnlyWrap )
    4108 [ #  # ][ #  # ]:          0 :             throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); // TODO: access_denied
    4109                 :            : 
    4110         [ +  - ]:       2098 :         m_pImpl->Commit(); // the root storage initiates the storing to source
    4111                 :            : 
    4112                 :            :         // when the storage is commited the parent is modified
    4113 [ +  + ][ +  - ]:       2098 :         if ( m_pImpl->m_pParent && m_pImpl->m_pParent->m_pAntiImpl )
    4114 [ +  - ][ +  - ]:       2098 :             xParentModif = (util::XModifiable*)m_pImpl->m_pParent->m_pAntiImpl;
                 [ +  - ]
    4115                 :            :     }
    4116                 :          0 :     catch( const io::IOException& rIOException )
    4117                 :            :     {
    4118         [ #  # ]:          0 :         m_pImpl->AddLog( rIOException.Message );
    4119   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    4120                 :          0 :         throw;
    4121                 :            :     }
    4122                 :          0 :     catch( const embed::StorageWrappedTargetException& rStorageWrappedTargetException )
    4123                 :            :     {
    4124         [ #  # ]:          0 :         m_pImpl->AddLog( rStorageWrappedTargetException.Message );
    4125   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    4126                 :          0 :         throw;
    4127                 :            :     }
    4128                 :          0 :     catch( const uno::RuntimeException& rRuntimeException )
    4129                 :            :     {
    4130         [ #  # ]:          0 :         m_pImpl->AddLog( rRuntimeException.Message );
    4131   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    4132                 :          0 :         throw;
    4133                 :            :     }
    4134   [ #  #  #  #  :          0 :     catch( const uno::Exception& rException )
                      # ]
    4135                 :            :     {
    4136         [ #  # ]:          0 :         m_pImpl->AddLog( rException.Message );
    4137   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    4138                 :            : 
    4139         [ #  # ]:          0 :         uno::Any aCaught( ::cppu::getCaughtException() );
    4140                 :            :         throw embed::StorageWrappedTargetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Problems on commit!" ) ),
    4141                 :            :                                   uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >( this ) ),
    4142   [ #  #  #  #  :          0 :                                   aCaught );
                   #  # ]
    4143                 :            :     }
    4144                 :            : 
    4145         [ +  - ]:       2098 :     setModified( sal_False );
    4146         [ +  + ]:       2098 :     if ( xParentModif.is() )
    4147 [ +  - ][ +  - ]:       1592 :         xParentModif->setModified( sal_True );
    4148                 :            : 
    4149         [ +  - ]:       2098 :     BroadcastTransaction( STOR_MESS_COMMITED );
    4150                 :       2098 : }
    4151                 :            : 
    4152                 :            : //-----------------------------------------------
    4153                 :          0 : void SAL_CALL OStorage::revert()
    4154                 :            :         throw ( io::IOException,
    4155                 :            :                 embed::StorageWrappedTargetException,
    4156                 :            :                 uno::RuntimeException )
    4157                 :            : {
    4158                 :            :     RTL_LOGFILE_CONTEXT( aLog, "package (mv76033) OStorage::revert" );
    4159                 :            : 
    4160                 :            :     // the method removes all the changes done after last commit
    4161                 :            : 
    4162         [ #  # ]:          0 :     BroadcastTransaction( STOR_MESS_PREREVERT );
    4163                 :            : 
    4164         [ #  # ]:          0 :     ::osl::ResettableMutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    4165                 :            : 
    4166         [ #  # ]:          0 :     if ( !m_pImpl )
    4167                 :            :     {
    4168 [ #  # ][ #  # ]:          0 :         ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    4169 [ #  # ][ #  # ]:          0 :         throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    4170                 :            :     }
    4171                 :            : 
    4172         [ #  # ]:          0 :     for ( SotElementList_Impl::iterator pElementIter = m_pImpl->m_aChildrenList.begin();
    4173                 :          0 :           pElementIter != m_pImpl->m_aChildrenList.end(); ++pElementIter )
    4174                 :            :     {
    4175   [ #  #  #  #  :          0 :         if ( ((*pElementIter)->m_pStorage
          #  #  #  #  #  
                #  #  # ]
                 [ #  # ]
    4176                 :          0 :                 && ( (*pElementIter)->m_pStorage->m_pAntiImpl || !(*pElementIter)->m_pStorage->m_aReadOnlyWrapList.empty() ))
    4177                 :          0 :           || ((*pElementIter)->m_pStream
    4178                 :          0 :                   && ( (*pElementIter)->m_pStream->m_pAntiImpl || !(*pElementIter)->m_pStream->m_aInputStreamsList.empty()) ) )
    4179 [ #  # ][ #  # ]:          0 :             throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); // TODO: access denied
    4180                 :            :     }
    4181                 :            : 
    4182 [ #  # ][ #  # ]:          0 :     if ( m_pData->m_bReadOnlyWrap || !m_pImpl->m_bListCreated )
    4183                 :          0 :         return; // nothing to do
    4184                 :            : 
    4185                 :            :     try {
    4186         [ #  # ]:          0 :         m_pImpl->Revert();
    4187                 :          0 :         m_pImpl->m_bIsModified = sal_False;
    4188                 :          0 :         m_pImpl->m_bBroadcastModified = sal_True;
    4189                 :            :     }
    4190                 :          0 :     catch( const io::IOException& rIOException )
    4191                 :            :     {
    4192         [ #  # ]:          0 :         m_pImpl->AddLog( rIOException.Message );
    4193   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    4194                 :          0 :         throw;
    4195                 :            :     }
    4196                 :          0 :     catch( const embed::StorageWrappedTargetException& rStorageWrappedTargetException )
    4197                 :            :     {
    4198         [ #  # ]:          0 :         m_pImpl->AddLog( rStorageWrappedTargetException.Message );
    4199   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    4200                 :          0 :         throw;
    4201                 :            :     }
    4202                 :          0 :     catch( const uno::RuntimeException& rRuntimeException )
    4203                 :            :     {
    4204         [ #  # ]:          0 :         m_pImpl->AddLog( rRuntimeException.Message );
    4205   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    4206                 :          0 :         throw;
    4207                 :            :     }
    4208   [ #  #  #  #  :          0 :     catch( const uno::Exception& rException )
                      # ]
    4209                 :            :     {
    4210         [ #  # ]:          0 :         m_pImpl->AddLog( rException.Message );
    4211   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    4212                 :            : 
    4213         [ #  # ]:          0 :         uno::Any aCaught( ::cppu::getCaughtException() );
    4214                 :            :         throw embed::StorageWrappedTargetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Problems on revert!" ) ),
    4215                 :            :                                   uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >( this ) ),
    4216   [ #  #  #  #  :          0 :                                   aCaught );
                   #  # ]
    4217                 :            :     }
    4218                 :            : 
    4219         [ #  # ]:          0 :     aGuard.clear();
    4220                 :            : 
    4221         [ #  # ]:          0 :     setModified( sal_False );
    4222 [ #  # ][ #  # ]:          0 :     BroadcastTransaction( STOR_MESS_REVERTED );
                 [ #  # ]
    4223                 :            : }
    4224                 :            : 
    4225                 :            : //____________________________________________________________________________________________________
    4226                 :            : //  XTransactionBroadcaster
    4227                 :            : //____________________________________________________________________________________________________
    4228                 :            : 
    4229                 :            : //-----------------------------------------------
    4230                 :         28 : void SAL_CALL OStorage::addTransactionListener( const uno::Reference< embed::XTransactionListener >& aListener )
    4231                 :            :         throw ( uno::RuntimeException )
    4232                 :            : {
    4233         [ +  - ]:         28 :     ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    4234                 :            : 
    4235         [ -  + ]:         28 :     if ( !m_pImpl )
    4236                 :            :     {
    4237 [ #  # ][ #  # ]:          0 :         ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    4238 [ #  # ][ #  # ]:          0 :         throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    4239                 :            :     }
    4240                 :            : 
    4241         [ +  - ]:         28 :     m_pData->m_aListenersContainer.addInterface( ::getCppuType((const uno::Reference< embed::XTransactionListener >*)0),
    4242 [ +  - ][ +  - ]:         56 :                                                 aListener );
    4243                 :         28 : }
    4244                 :            : 
    4245                 :            : //-----------------------------------------------
    4246                 :          0 : void SAL_CALL OStorage::removeTransactionListener( const uno::Reference< embed::XTransactionListener >& aListener )
    4247                 :            :         throw ( uno::RuntimeException )
    4248                 :            : {
    4249         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    4250                 :            : 
    4251         [ #  # ]:          0 :     if ( !m_pImpl )
    4252                 :            :     {
    4253 [ #  # ][ #  # ]:          0 :         ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    4254 [ #  # ][ #  # ]:          0 :         throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    4255                 :            :     }
    4256                 :            : 
    4257         [ #  # ]:          0 :     m_pData->m_aListenersContainer.removeInterface( ::getCppuType((const uno::Reference< embed::XTransactionListener >*)0),
    4258 [ #  # ][ #  # ]:          0 :                                                     aListener );
    4259                 :          0 : }
    4260                 :            : 
    4261                 :            : //____________________________________________________________________________________________________
    4262                 :            : //  XModifiable
    4263                 :            : //  TODO: if there will be no demand on this interface it will be removed from implementation,
    4264                 :            : //        I do not want to remove it now since it is still possible that it will be inserted
    4265                 :            : //        to the service back.
    4266                 :            : //____________________________________________________________________________________________________
    4267                 :            : 
    4268                 :            : //-----------------------------------------------
    4269                 :          0 : sal_Bool SAL_CALL OStorage::isModified()
    4270                 :            :         throw ( uno::RuntimeException )
    4271                 :            : {
    4272         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    4273                 :            : 
    4274         [ #  # ]:          0 :     if ( !m_pImpl )
    4275                 :            :     {
    4276 [ #  # ][ #  # ]:          0 :         ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    4277 [ #  # ][ #  # ]:          0 :         throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    4278                 :            :     }
    4279                 :            : 
    4280         [ #  # ]:          0 :     return m_pImpl->m_bIsModified;
    4281                 :            : }
    4282                 :            : 
    4283                 :            : 
    4284                 :            : //-----------------------------------------------
    4285                 :      85671 : void SAL_CALL OStorage::setModified( sal_Bool bModified )
    4286                 :            :         throw ( beans::PropertyVetoException,
    4287                 :            :                 uno::RuntimeException )
    4288                 :            : {
    4289         [ +  - ]:      85671 :     ::osl::ResettableMutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    4290                 :            : 
    4291         [ -  + ]:      85671 :     if ( !m_pImpl )
    4292                 :            :     {
    4293 [ #  # ][ #  # ]:          0 :         ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    4294 [ #  # ][ #  # ]:          0 :         throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    4295                 :            :     }
    4296                 :            : 
    4297         [ -  + ]:      85671 :     if ( m_pData->m_bReadOnlyWrap )
    4298 [ #  # ][ #  # ]:          0 :         throw beans::PropertyVetoException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); // TODO: access denied
    4299                 :            : 
    4300         [ +  + ]:      85671 :     if ( m_pImpl->m_bIsModified != bModified )
    4301                 :       2060 :         m_pImpl->m_bIsModified = bModified;
    4302                 :            : 
    4303         [ +  - ]:      85671 :     aGuard.clear();
    4304         [ +  + ]:      85671 :     if ( bModified )
    4305                 :            :     {
    4306                 :      83573 :         m_pImpl->m_bBroadcastModified = sal_True;
    4307         [ +  - ]:      83573 :         BroadcastModifiedIfNecessary();
    4308         [ +  - ]:      85671 :     }
    4309                 :      85671 : }
    4310                 :            : 
    4311                 :            : //-----------------------------------------------
    4312                 :       3242 : void SAL_CALL OStorage::addModifyListener(
    4313                 :            :             const uno::Reference< util::XModifyListener >& aListener )
    4314                 :            :         throw ( uno::RuntimeException )
    4315                 :            : {
    4316         [ +  - ]:       3242 :     ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    4317                 :            : 
    4318         [ -  + ]:       3242 :     if ( !m_pImpl )
    4319                 :            :     {
    4320 [ #  # ][ #  # ]:          0 :         ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    4321 [ #  # ][ #  # ]:          0 :         throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    4322                 :            :     }
    4323                 :            : 
    4324                 :            :     m_pData->m_aListenersContainer.addInterface(
    4325 [ +  - ][ +  - ]:       3242 :                                 ::getCppuType( ( const uno::Reference< util::XModifyListener >* )0 ), aListener );
                 [ +  - ]
    4326                 :       3242 : }
    4327                 :            : 
    4328                 :            : 
    4329                 :            : //-----------------------------------------------
    4330                 :        186 : void SAL_CALL OStorage::removeModifyListener(
    4331                 :            :             const uno::Reference< util::XModifyListener >& aListener )
    4332                 :            :         throw ( uno::RuntimeException )
    4333                 :            : {
    4334         [ +  - ]:        186 :     ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    4335                 :            : 
    4336         [ -  + ]:        186 :     if ( !m_pImpl )
    4337                 :            :     {
    4338 [ #  # ][ #  # ]:          0 :         ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    4339 [ #  # ][ #  # ]:          0 :         throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    4340                 :            :     }
    4341                 :            : 
    4342                 :            :     m_pData->m_aListenersContainer.removeInterface(
    4343 [ +  - ][ +  - ]:        186 :                                 ::getCppuType( ( const uno::Reference< util::XModifyListener >* )0 ), aListener );
                 [ +  - ]
    4344                 :        186 : }
    4345                 :            : 
    4346                 :            : //____________________________________________________________________________________________________
    4347                 :            : //  XNameAccess
    4348                 :            : //____________________________________________________________________________________________________
    4349                 :            : 
    4350                 :            : //-----------------------------------------------
    4351                 :          0 : uno::Any SAL_CALL OStorage::getByName( const ::rtl::OUString& aName )
    4352                 :            :         throw ( container::NoSuchElementException,
    4353                 :            :                 lang::WrappedTargetException,
    4354                 :            :                 uno::RuntimeException )
    4355                 :            : {
    4356                 :            :     RTL_LOGFILE_CONTEXT( aLog, "package (mv76033) OStorage::getByName" );
    4357                 :            : 
    4358         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    4359                 :            : 
    4360         [ #  # ]:          0 :     if ( !m_pImpl )
    4361                 :            :     {
    4362 [ #  # ][ #  # ]:          0 :         ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    4363 [ #  # ][ #  # ]:          0 :         throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    4364                 :            :     }
    4365                 :            : 
    4366 [ #  # ][ #  # ]:          0 :     if ( aName.isEmpty() || !::comphelper::OStorageHelper::IsValidZipEntryFileName( aName, sal_False ) )
         [ #  # ][ #  # ]
    4367 [ #  # ][ #  # ]:          0 :         throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Unexpected entry name syntax." ) ), uno::Reference< uno::XInterface >(), 1 );
    4368                 :            : 
    4369 [ #  # ][ #  # ]:          0 :     if ( m_pData->m_nStorageType == embed::StorageFormats::OFOPXML && aName == "_rels" )
                 [ #  # ]
    4370 [ #  # ][ #  # ]:          0 :         throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 1 ); // unacceptable element name
    4371                 :            : 
    4372                 :          0 :     uno::Any aResult;
    4373                 :            :     try
    4374                 :            :     {
    4375         [ #  # ]:          0 :         SotElement_Impl* pElement = m_pImpl->FindElement( aName );
    4376         [ #  # ]:          0 :         if ( !pElement )
    4377 [ #  # ][ #  # ]:          0 :             throw container::NoSuchElementException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    4378                 :            : 
    4379         [ #  # ]:          0 :         if ( pElement->m_bIsStorage )
    4380 [ #  # ][ #  # ]:          0 :             aResult <<= openStorageElement( aName, embed::ElementModes::READ );
    4381                 :            :         else
    4382 [ #  # ][ #  # ]:          0 :             aResult <<= openStreamElement( aName, embed::ElementModes::READ );
    4383                 :            :     }
    4384                 :          0 :     catch( const container::NoSuchElementException& rNoSuchElementException )
    4385                 :            :     {
    4386         [ #  # ]:          0 :         m_pImpl->AddLog( rNoSuchElementException.Message );
    4387   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    4388                 :          0 :         throw;
    4389                 :            :     }
    4390                 :          0 :     catch( const lang::WrappedTargetException& rWrappedTargetException )
    4391                 :            :     {
    4392         [ #  # ]:          0 :         m_pImpl->AddLog( rWrappedTargetException.Message );
    4393   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    4394                 :          0 :         throw;
    4395                 :            :     }
    4396                 :          0 :     catch( const uno::RuntimeException& rRuntimeException )
    4397                 :            :     {
    4398         [ #  # ]:          0 :         m_pImpl->AddLog( rRuntimeException.Message );
    4399   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    4400                 :          0 :         throw;
    4401                 :            :     }
    4402   [ #  #  #  #  :          0 :     catch( const uno::Exception& rException )
                      # ]
    4403                 :            :     {
    4404         [ #  # ]:          0 :            m_pImpl->AddLog( rException.Message );
    4405   [ #  #  #  # ]:          0 :            m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    4406                 :            : 
    4407         [ #  # ]:          0 :            uno::Any aCaught( ::cppu::getCaughtException() );
    4408                 :            :         throw lang::WrappedTargetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Can not open storage!\n" ) ),
    4409                 :            :                                             uno::Reference< uno::XInterface >(  static_cast< OWeakObject* >( this ),
    4410                 :            :                                                                                 uno::UNO_QUERY ),
    4411   [ #  #  #  #  :          0 :                                             aCaught );
                   #  # ]
    4412                 :            :     }
    4413                 :            : 
    4414         [ #  # ]:          0 :     return aResult;
    4415                 :            : }
    4416                 :            : 
    4417                 :            : 
    4418                 :            : //-----------------------------------------------
    4419                 :       7966 : uno::Sequence< ::rtl::OUString > SAL_CALL OStorage::getElementNames()
    4420                 :            :         throw ( uno::RuntimeException )
    4421                 :            : {
    4422                 :            :     RTL_LOGFILE_CONTEXT( aLog, "package (mv76033) OStorage::getElementNames" );
    4423                 :            : 
    4424         [ +  - ]:       7966 :     ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    4425                 :            : 
    4426         [ -  + ]:       7966 :     if ( !m_pImpl )
    4427                 :            :     {
    4428 [ #  # ][ #  # ]:          0 :         ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    4429 [ #  # ][ #  # ]:          0 :         throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    4430                 :            :     }
    4431                 :            : 
    4432                 :            :     try
    4433                 :            :     {
    4434         [ +  - ]:      15932 :         return m_pImpl->GetElementNames();
    4435                 :            :     }
    4436                 :          0 :     catch( const uno::RuntimeException& rRuntimeException )
    4437                 :            :     {
    4438         [ #  # ]:          0 :         m_pImpl->AddLog( rRuntimeException.Message );
    4439   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    4440                 :          0 :         throw;
    4441                 :            :     }
    4442      [ #  #  # ]:          0 :     catch ( const uno::Exception& rException )
    4443                 :            :     {
    4444         [ #  # ]:          0 :            m_pImpl->AddLog( rException.Message );
    4445   [ #  #  #  # ]:          0 :            m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    4446                 :            : 
    4447         [ #  # ]:          0 :            uno::Any aCaught( ::cppu::getCaughtException() );
    4448                 :            :         throw lang::WrappedTargetRuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Can not open storage!\n" ) ),
    4449                 :            :                                             uno::Reference< uno::XInterface >(  static_cast< OWeakObject* >( this ),
    4450                 :            :                                                                                 uno::UNO_QUERY ),
    4451   [ #  #  #  #  :          0 :                                             aCaught );
                   #  # ]
    4452         [ +  - ]:       7966 :     }
    4453                 :            : }
    4454                 :            : 
    4455                 :            : 
    4456                 :            : //-----------------------------------------------
    4457                 :       8997 : sal_Bool SAL_CALL OStorage::hasByName( const ::rtl::OUString& aName )
    4458                 :            :         throw ( uno::RuntimeException )
    4459                 :            : {
    4460                 :            :     RTL_LOGFILE_CONTEXT( aLog, "package (mv76033) OStorage::hasByName" );
    4461                 :            : 
    4462         [ +  - ]:       8997 :     ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    4463                 :            : 
    4464         [ -  + ]:       8997 :     if ( !m_pImpl )
    4465                 :            :     {
    4466 [ #  # ][ #  # ]:          0 :         ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    4467 [ #  # ][ #  # ]:          0 :         throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    4468                 :            :     }
    4469                 :            : 
    4470         [ -  + ]:       8997 :     if ( aName.isEmpty() )
    4471                 :          0 :         return sal_False;
    4472                 :            : 
    4473 [ +  + ][ -  + ]:       8997 :     if ( m_pData->m_nStorageType == embed::StorageFormats::OFOPXML && aName == "_rels" )
                 [ -  + ]
    4474                 :          0 :         return sal_False;
    4475                 :            : 
    4476                 :       8997 :     SotElement_Impl* pElement = NULL;
    4477                 :            :     try
    4478                 :            :     {
    4479         [ +  + ]:       8997 :         pElement = m_pImpl->FindElement( aName );
    4480                 :            :     }
    4481                 :          0 :     catch( const uno::RuntimeException& rRuntimeException )
    4482                 :            :     {
    4483         [ #  # ]:          0 :         m_pImpl->AddLog( rRuntimeException.Message );
    4484   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    4485                 :          0 :         throw;
    4486                 :            :     }
    4487      [ -  -  + ]:         28 :     catch ( const uno::Exception& rException )
    4488                 :            :     {
    4489         [ -  + ]:         14 :            m_pImpl->AddLog( rException.Message );
    4490 [ -  + ][ -  + ]:         14 :            m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    4491                 :            : 
    4492         [ -  + ]:         14 :            uno::Any aCaught( ::cppu::getCaughtException() );
    4493                 :            :         throw lang::WrappedTargetRuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Can not open storage!\n" ) ),
    4494                 :            :                                             uno::Reference< uno::XInterface >(  static_cast< OWeakObject* >( this ),
    4495                 :            :                                                                                 uno::UNO_QUERY ),
    4496 [ -  + ][ -  + ]:         14 :                                             aCaught );
                 [ -  + ]
    4497                 :            :     }
    4498                 :            : 
    4499         [ +  - ]:       8997 :     return ( pElement != NULL );
    4500                 :            : }
    4501                 :            : 
    4502                 :            : 
    4503                 :            : //-----------------------------------------------
    4504                 :          0 : uno::Type SAL_CALL OStorage::getElementType()
    4505                 :            :         throw ( uno::RuntimeException )
    4506                 :            : {
    4507         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    4508                 :            : 
    4509         [ #  # ]:          0 :     if ( !m_pImpl )
    4510                 :            :     {
    4511 [ #  # ][ #  # ]:          0 :         ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    4512 [ #  # ][ #  # ]:          0 :         throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    4513                 :            :     }
    4514                 :            : 
    4515                 :            :     // it is a multitype container
    4516         [ #  # ]:          0 :     return uno::Type();
    4517                 :            : }
    4518                 :            : 
    4519                 :            : 
    4520                 :            : //-----------------------------------------------
    4521                 :        570 : sal_Bool SAL_CALL OStorage::hasElements()
    4522                 :            :         throw ( uno::RuntimeException )
    4523                 :            : {
    4524                 :            :     RTL_LOGFILE_CONTEXT( aLog, "package (mv76033) OStorage::hasElements" );
    4525                 :            : 
    4526         [ +  - ]:        570 :     ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    4527                 :            : 
    4528         [ -  + ]:        570 :     if ( !m_pImpl )
    4529                 :            :     {
    4530 [ #  # ][ #  # ]:          0 :         ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    4531 [ #  # ][ #  # ]:          0 :         throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    4532                 :            :     }
    4533                 :            : 
    4534                 :            :     try
    4535                 :            :     {
    4536         [ +  - ]:       1140 :         return ( m_pImpl->GetChildrenList().size() != 0 );
    4537                 :            :     }
    4538                 :          0 :     catch( const uno::RuntimeException& rRuntimeException )
    4539                 :            :     {
    4540         [ #  # ]:          0 :         m_pImpl->AddLog( rRuntimeException.Message );
    4541   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    4542                 :          0 :         throw;
    4543                 :            :     }
    4544      [ #  #  # ]:          0 :     catch( const uno::Exception& rException )
    4545                 :            :     {
    4546         [ #  # ]:          0 :            m_pImpl->AddLog( rException.Message );
    4547   [ #  #  #  # ]:          0 :            m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    4548                 :            : 
    4549         [ #  # ]:          0 :            uno::Any aCaught( ::cppu::getCaughtException() );
    4550                 :            :         throw lang::WrappedTargetRuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Can not open storage!\n" ) ),
    4551                 :            :                                             uno::Reference< uno::XInterface >(  static_cast< OWeakObject* >( this ),
    4552                 :            :                                                                                 uno::UNO_QUERY ),
    4553   [ #  #  #  #  :          0 :                                             aCaught );
                   #  # ]
    4554         [ +  - ]:        570 :     }
    4555                 :            : }
    4556                 :            : 
    4557                 :            : 
    4558                 :            : //____________________________________________________________________________________________________
    4559                 :            : //  XComponent
    4560                 :            : //____________________________________________________________________________________________________
    4561                 :            : 
    4562                 :            : //-----------------------------------------------
    4563                 :      17080 : void SAL_CALL OStorage::dispose()
    4564                 :            :         throw ( uno::RuntimeException )
    4565                 :            : {
    4566         [ +  - ]:      17080 :     ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    4567                 :            : 
    4568         [ +  + ]:      17080 :     if ( !m_pImpl )
    4569                 :            :     {
    4570 [ +  - ][ +  - ]:        852 :         ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    4571 [ +  - ][ +  - ]:        852 :         throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    4572                 :            :     }
    4573                 :            : 
    4574                 :            :     try
    4575                 :            :     {
    4576         [ +  - ]:      16228 :         InternalDispose( sal_True );
    4577                 :            :     }
    4578                 :          0 :     catch( const uno::RuntimeException& rRuntimeException )
    4579                 :            :     {
    4580         [ #  # ]:          0 :         m_pImpl->AddLog( rRuntimeException.Message );
    4581   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    4582                 :          0 :         throw;
    4583                 :            :     }
    4584      [ #  #  # ]:          0 :     catch( const uno::Exception& rException )
    4585                 :            :     {
    4586         [ #  # ]:          0 :            m_pImpl->AddLog( rException.Message );
    4587   [ #  #  #  # ]:          0 :            m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    4588                 :            : 
    4589         [ #  # ]:          0 :            uno::Any aCaught( ::cppu::getCaughtException() );
    4590                 :            :         throw lang::WrappedTargetRuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Can not open storage!\n" ) ),
    4591                 :            :                                             uno::Reference< uno::XInterface >(  static_cast< OWeakObject* >( this ),
    4592                 :            :                                                                                 uno::UNO_QUERY ),
    4593   [ #  #  #  #  :          0 :                                             aCaught );
                   #  # ]
    4594         [ +  - ]:      17080 :     }
    4595                 :      16228 : }
    4596                 :            : 
    4597                 :            : //-----------------------------------------------
    4598                 :       1334 : void SAL_CALL OStorage::addEventListener(
    4599                 :            :             const uno::Reference< lang::XEventListener >& xListener )
    4600                 :            :         throw ( uno::RuntimeException )
    4601                 :            : {
    4602         [ +  - ]:       1334 :     ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    4603                 :            : 
    4604         [ -  + ]:       1334 :     if ( !m_pImpl )
    4605                 :            :     {
    4606 [ #  # ][ #  # ]:          0 :         ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    4607 [ #  # ][ #  # ]:          0 :         throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    4608                 :            :     }
    4609                 :            : 
    4610                 :            :     m_pData->m_aListenersContainer.addInterface(
    4611 [ +  - ][ +  - ]:       1334 :                                 ::getCppuType( ( const uno::Reference< lang::XEventListener >* )0 ), xListener );
                 [ +  - ]
    4612                 :       1334 : }
    4613                 :            : 
    4614                 :            : //-----------------------------------------------
    4615                 :        216 : void SAL_CALL OStorage::removeEventListener(
    4616                 :            :             const uno::Reference< lang::XEventListener >& xListener )
    4617                 :            :         throw ( uno::RuntimeException )
    4618                 :            : {
    4619         [ +  - ]:        216 :     ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    4620                 :            : 
    4621         [ -  + ]:        216 :     if ( !m_pImpl )
    4622                 :            :     {
    4623 [ #  # ][ #  # ]:          0 :         ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    4624 [ #  # ][ #  # ]:          0 :         throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    4625                 :            :     }
    4626                 :            : 
    4627                 :            :     m_pData->m_aListenersContainer.removeInterface(
    4628 [ +  - ][ +  - ]:        216 :                                 ::getCppuType( ( const uno::Reference< lang::XEventListener >* )0 ), xListener );
                 [ +  - ]
    4629                 :        216 : }
    4630                 :            : 
    4631                 :            : //____________________________________________________________________________________________________
    4632                 :            : //  XEncryptionProtectedSource
    4633                 :            : //____________________________________________________________________________________________________
    4634                 :            : 
    4635                 :          0 : void SAL_CALL OStorage::setEncryptionPassword( const ::rtl::OUString& aPass )
    4636                 :            :     throw ( uno::RuntimeException,
    4637                 :            :             io::IOException )
    4638                 :            : {
    4639                 :            :     RTL_LOGFILE_CONTEXT( aLog, "package (mv76033) OStorage::setEncryptionPassword" );
    4640 [ #  # ][ #  # ]:          0 :     setEncryptionData( ::comphelper::OStorageHelper::CreatePackageEncryptionData( aPass ) );
                 [ #  # ]
    4641                 :          0 : }
    4642                 :            : 
    4643                 :            : //-----------------------------------------------
    4644                 :          0 : void SAL_CALL OStorage::removeEncryption()
    4645                 :            :     throw ( uno::RuntimeException,
    4646                 :            :             io::IOException )
    4647                 :            : {
    4648                 :            :     RTL_LOGFILE_CONTEXT( aLog, "package (mv76033) OStorage::removeEncryption" );
    4649                 :            : 
    4650         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    4651                 :            : 
    4652         [ #  # ]:          0 :     if ( !m_pImpl )
    4653                 :            :     {
    4654 [ #  # ][ #  # ]:          0 :         ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    4655 [ #  # ][ #  # ]:          0 :         throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    4656                 :            :     }
    4657                 :            : 
    4658         [ #  # ]:          0 :     if ( m_pData->m_nStorageType != embed::StorageFormats::PACKAGE )
    4659 [ #  # ][ #  # ]:          0 :         throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); // the interface must be visible only for package storage
    4660                 :            : 
    4661                 :            :     OSL_ENSURE( m_pData->m_bIsRoot, "removeEncryption() method is not available for nonroot storages!\n" );
    4662         [ #  # ]:          0 :     if ( m_pData->m_bIsRoot )
    4663                 :            :     {
    4664                 :            :         try {
    4665         [ #  # ]:          0 :             m_pImpl->ReadContents();
    4666                 :            :         }
    4667                 :          0 :         catch ( const uno::RuntimeException& rRuntimeException )
    4668                 :            :         {
    4669         [ #  # ]:          0 :             m_pImpl->AddLog( rRuntimeException.Message );
    4670   [ #  #  #  # ]:          0 :             m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    4671                 :          0 :             throw;
    4672                 :            :         }
    4673      [ #  #  # ]:          0 :         catch ( const uno::Exception& rException )
    4674                 :            :         {
    4675         [ #  # ]:          0 :             m_pImpl->AddLog( rException.Message );
    4676   [ #  #  #  # ]:          0 :             m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    4677                 :            : 
    4678         [ #  # ]:          0 :             uno::Any aCaught( ::cppu::getCaughtException() );
    4679                 :            :             throw lang::WrappedTargetRuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Can not open package!\n" ) ),
    4680                 :            :                                                 uno::Reference< uno::XInterface >(  static_cast< OWeakObject* >( this ),
    4681                 :            :                                                                                     uno::UNO_QUERY ),
    4682   [ #  #  #  #  :          0 :                                                 aCaught );
                   #  # ]
    4683                 :            :         }
    4684                 :            : 
    4685                 :            :         // TODO: check if the password is valid
    4686                 :            :         // update all streams that was encrypted with old password
    4687                 :            : 
    4688         [ #  # ]:          0 :         uno::Reference< beans::XPropertySet > xPackPropSet( m_pImpl->m_xPackage, uno::UNO_QUERY_THROW );
    4689                 :            :         try
    4690                 :            :         {
    4691         [ #  # ]:          0 :             xPackPropSet->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( STORAGE_ENCRYPTION_KEYS_PROPERTY ) ),
    4692 [ #  # ][ #  # ]:          0 :                                             uno::makeAny( uno::Sequence< beans::NamedValue >() ) );
         [ #  # ][ #  # ]
                 [ #  # ]
    4693                 :            : 
    4694                 :          0 :             m_pImpl->m_bHasCommonEncryptionData = sal_False;
    4695         [ #  # ]:          0 :             m_pImpl->m_aCommonEncryptionData.clear();
    4696                 :            :         }
    4697                 :          0 :         catch( const uno::RuntimeException& rRException )
    4698                 :            :         {
    4699         [ #  # ]:          0 :             m_pImpl->AddLog( rRException.Message );
    4700   [ #  #  #  # ]:          0 :             m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    4701                 :            : 
    4702                 :            :             OSL_ENSURE( sal_False, "The call must not fail, it is pretty simple!" );
    4703                 :          0 :             throw;
    4704                 :            :         }
    4705      [ #  #  # ]:          0 :         catch( const uno::Exception& rException )
    4706                 :            :         {
    4707         [ #  # ]:          0 :             m_pImpl->AddLog( rException.Message );
    4708   [ #  #  #  # ]:          0 :             m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    4709                 :            : 
    4710                 :            :             OSL_FAIL( "The call must not fail, it is pretty simple!" );
    4711   [ #  #  #  # ]:          0 :             throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    4712                 :          0 :         }
    4713         [ #  # ]:          0 :     }
    4714                 :          0 : }
    4715                 :            : 
    4716                 :            : //____________________________________________________________________________________________________
    4717                 :            : //  XEncryptionProtectedSource2
    4718                 :            : //____________________________________________________________________________________________________
    4719                 :            : 
    4720                 :         12 : void SAL_CALL OStorage::setEncryptionData( const uno::Sequence< beans::NamedValue >& aEncryptionData )
    4721                 :            :     throw ( io::IOException,
    4722                 :            :             uno::RuntimeException )
    4723                 :            : {
    4724                 :            :     RTL_LOGFILE_CONTEXT( aLog, "package (mv76033) OStorage::setEncryptionData" );
    4725                 :            : 
    4726         [ +  - ]:         12 :     ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    4727                 :            : 
    4728         [ -  + ]:         12 :     if ( !m_pImpl )
    4729                 :            :     {
    4730 [ #  # ][ #  # ]:          0 :         ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    4731 [ #  # ][ #  # ]:          0 :         throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    4732                 :            :     }
    4733                 :            : 
    4734         [ -  + ]:         12 :     if ( m_pData->m_nStorageType != embed::StorageFormats::PACKAGE )
    4735 [ #  # ][ #  # ]:          0 :         throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); // the interface must be visible only for package storage
    4736                 :            : 
    4737         [ -  + ]:         12 :     if ( !aEncryptionData.getLength() )
    4738 [ #  # ][ #  # ]:          0 :         throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Unexpected empty encryption data!") ), uno::Reference< uno::XInterface >() );
    4739                 :            : 
    4740                 :            :     OSL_ENSURE( m_pData->m_bIsRoot, "setEncryptionData() method is not available for nonroot storages!\n" );
    4741         [ +  - ]:         12 :     if ( m_pData->m_bIsRoot )
    4742                 :            :     {
    4743                 :            :         try {
    4744         [ +  - ]:         12 :             m_pImpl->ReadContents();
    4745                 :            :         }
    4746                 :          0 :         catch ( const uno::RuntimeException& rRuntimeException )
    4747                 :            :         {
    4748         [ #  # ]:          0 :             m_pImpl->AddLog( rRuntimeException.Message );
    4749   [ #  #  #  # ]:          0 :             m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    4750                 :          0 :             throw;
    4751                 :            :         }
    4752      [ #  #  # ]:          0 :         catch ( const uno::Exception& rException )
    4753                 :            :         {
    4754         [ #  # ]:          0 :             m_pImpl->AddLog( rException.Message );
    4755   [ #  #  #  # ]:          0 :             m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    4756                 :            : 
    4757         [ #  # ]:          0 :             uno::Any aCaught( ::cppu::getCaughtException() );
    4758                 :            :             throw lang::WrappedTargetRuntimeException(
    4759                 :            :                                 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Can not open package!\n" ) ),
    4760                 :            :                                 uno::Reference< uno::XInterface >(  static_cast< OWeakObject* >( this ), uno::UNO_QUERY ),
    4761   [ #  #  #  #  :          0 :                                 aCaught );
                   #  # ]
    4762                 :            :         }
    4763                 :            : 
    4764         [ +  - ]:         12 :         uno::Reference< beans::XPropertySet > xPackPropSet( m_pImpl->m_xPackage, uno::UNO_QUERY_THROW );
    4765                 :            :         try
    4766                 :            :         {
    4767         [ +  - ]:         12 :             ::comphelper::SequenceAsHashMap aEncryptionMap( aEncryptionData );
    4768         [ +  - ]:         12 :             xPackPropSet->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( STORAGE_ENCRYPTION_KEYS_PROPERTY ) ),
    4769 [ +  - ][ +  - ]:         12 :                                             uno::makeAny( aEncryptionMap.getAsConstNamedValueList() ) );
         [ +  - ][ +  - ]
                 [ +  - ]
    4770                 :            : 
    4771                 :         12 :             m_pImpl->m_bHasCommonEncryptionData = sal_True;
    4772 [ +  - ][ +  - ]:         12 :             m_pImpl->m_aCommonEncryptionData = aEncryptionMap;
    4773                 :            :         }
    4774         [ #  # ]:          0 :         catch( const uno::Exception& rException )
    4775                 :            :         {
    4776         [ #  # ]:          0 :             m_pImpl->AddLog( rException.Message );
    4777   [ #  #  #  # ]:          0 :             m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    4778                 :            : 
    4779   [ #  #  #  # ]:          0 :             throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    4780                 :         12 :         }
    4781         [ +  - ]:         12 :     }
    4782                 :         12 : }
    4783                 :            : 
    4784                 :        124 : sal_Bool SAL_CALL OStorage::hasEncryptionData()
    4785                 :            :     throw ( uno::RuntimeException )
    4786                 :            : {
    4787         [ +  - ]:        124 :     ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    4788                 :            : 
    4789 [ +  - ][ -  + ]:        124 :     return m_pImpl && m_pImpl->m_bHasCommonEncryptionData;
                 [ +  - ]
    4790                 :            : }
    4791                 :            : 
    4792                 :            : 
    4793                 :            : //____________________________________________________________________________________________________
    4794                 :            : //  XEncryptionProtectedStorage
    4795                 :            : //____________________________________________________________________________________________________
    4796                 :            : 
    4797                 :            : //-----------------------------------------------
    4798                 :       2050 : void SAL_CALL OStorage::setEncryptionAlgorithms( const uno::Sequence< beans::NamedValue >& aAlgorithms )
    4799                 :            :     throw (lang::IllegalArgumentException, uno::RuntimeException)
    4800                 :            : {
    4801                 :            :     RTL_LOGFILE_CONTEXT( aLog, "package (mv76033) OStorage::setEncryptionAlgorithms" );
    4802                 :            : 
    4803         [ +  - ]:       2050 :     ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    4804                 :            : 
    4805         [ -  + ]:       2050 :     if ( !m_pImpl )
    4806                 :            :     {
    4807 [ #  # ][ #  # ]:          0 :         ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    4808 [ #  # ][ #  # ]:          0 :         throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    4809                 :            :     }
    4810                 :            : 
    4811         [ -  + ]:       2050 :     if ( m_pData->m_nStorageType != embed::StorageFormats::PACKAGE )
    4812 [ #  # ][ #  # ]:          0 :         throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); // the interface must be visible only for package storage
    4813                 :            : 
    4814         [ -  + ]:       2050 :     if ( !aAlgorithms.getLength() )
    4815 [ #  # ][ #  # ]:          0 :         throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Unexpected empty encryption algorithms list!") ), uno::Reference< uno::XInterface >() );
    4816                 :            : 
    4817                 :            :     OSL_ENSURE( m_pData->m_bIsRoot, "setEncryptionAlgorithms() method is not available for nonroot storages!\n" );
    4818         [ +  - ]:       2050 :     if ( m_pData->m_bIsRoot )
    4819                 :            :     {
    4820                 :            :         try {
    4821         [ +  - ]:       2050 :             m_pImpl->ReadContents();
    4822                 :            :         }
    4823                 :          0 :         catch ( const uno::RuntimeException& aRuntimeException )
    4824                 :            :         {
    4825         [ #  # ]:          0 :             m_pImpl->AddLog( aRuntimeException.Message );
    4826   [ #  #  #  # ]:          0 :             m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    4827                 :          0 :             throw;
    4828                 :            :         }
    4829      [ #  #  # ]:          0 :         catch ( const uno::Exception& aException )
    4830                 :            :         {
    4831         [ #  # ]:          0 :             m_pImpl->AddLog( aException.Message );
    4832   [ #  #  #  # ]:          0 :             m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    4833                 :            : 
    4834         [ #  # ]:          0 :             uno::Any aCaught( ::cppu::getCaughtException() );
    4835                 :            :             throw lang::WrappedTargetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Can not open package!\n" ) ),
    4836                 :            :                                                 uno::Reference< uno::XInterface >(  static_cast< OWeakObject* >( this ),
    4837                 :            :                                                                                     uno::UNO_QUERY ),
    4838   [ #  #  #  #  :          0 :                                                 aCaught );
                   #  # ]
    4839                 :            :         }
    4840                 :            : 
    4841         [ +  - ]:       2050 :         uno::Reference< beans::XPropertySet > xPackPropSet( m_pImpl->m_xPackage, uno::UNO_QUERY_THROW );
    4842                 :            :         try
    4843                 :            :         {
    4844         [ +  - ]:       2050 :             xPackPropSet->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ENCRYPTION_ALGORITHMS_PROPERTY ) ),
    4845 [ +  - ][ +  - ]:       2050 :                                             uno::makeAny( aAlgorithms ) );
                 [ +  - ]
    4846                 :            :         }
    4847                 :          0 :         catch ( const uno::RuntimeException& aRuntimeException )
    4848                 :            :         {
    4849         [ #  # ]:          0 :             m_pImpl->AddLog( aRuntimeException.Message );
    4850   [ #  #  #  # ]:          0 :             m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    4851                 :          0 :             throw;
    4852                 :            :         }
    4853                 :          0 :         catch( const lang::IllegalArgumentException& aIAException )
    4854                 :            :         {
    4855         [ #  # ]:          0 :             m_pImpl->AddLog( aIAException.Message );
    4856   [ #  #  #  # ]:          0 :             m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    4857                 :            : 
    4858                 :          0 :             throw;
    4859                 :            :         }
    4860   [ #  #  #  # ]:          0 :         catch( const uno::Exception& aException )
    4861                 :            :         {
    4862         [ #  # ]:          0 :             m_pImpl->AddLog( aException.Message );
    4863   [ #  #  #  # ]:          0 :             m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    4864                 :            : 
    4865   [ #  #  #  # ]:          0 :             throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    4866                 :       2050 :         }
    4867         [ +  - ]:       2050 :     }
    4868                 :       2050 : }
    4869                 :            : 
    4870                 :            : //-----------------------------------------------
    4871                 :          0 : uno::Sequence< beans::NamedValue > SAL_CALL OStorage::getEncryptionAlgorithms()
    4872                 :            :     throw (uno::RuntimeException)
    4873                 :            : {
    4874                 :            :     RTL_LOGFILE_CONTEXT( aLog, "package (mv76033) OStorage::getEncryptionAlgorithms" );
    4875                 :            : 
    4876         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    4877                 :            : 
    4878         [ #  # ]:          0 :     if ( !m_pImpl )
    4879                 :            :     {
    4880 [ #  # ][ #  # ]:          0 :         ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    4881 [ #  # ][ #  # ]:          0 :         throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    4882                 :            :     }
    4883                 :            : 
    4884         [ #  # ]:          0 :     if ( m_pData->m_nStorageType != embed::StorageFormats::PACKAGE )
    4885 [ #  # ][ #  # ]:          0 :         throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); // the interface must be visible only for package storage
    4886                 :            : 
    4887         [ #  # ]:          0 :     uno::Sequence< beans::NamedValue > aResult;
    4888                 :            :     OSL_ENSURE( m_pData->m_bIsRoot, "getEncryptionAlgorithms() method is not available for nonroot storages!\n" );
    4889         [ #  # ]:          0 :     if ( m_pData->m_bIsRoot )
    4890                 :            :     {
    4891                 :            :         try {
    4892         [ #  # ]:          0 :             m_pImpl->ReadContents();
    4893                 :            :         }
    4894                 :          0 :         catch ( const uno::RuntimeException& aRuntimeException )
    4895                 :            :         {
    4896         [ #  # ]:          0 :             m_pImpl->AddLog( aRuntimeException.Message );
    4897   [ #  #  #  # ]:          0 :             m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    4898                 :          0 :             throw;
    4899                 :            :         }
    4900      [ #  #  # ]:          0 :         catch ( const uno::Exception& aException )
    4901                 :            :         {
    4902         [ #  # ]:          0 :             m_pImpl->AddLog( aException.Message );
    4903   [ #  #  #  # ]:          0 :             m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    4904                 :            : 
    4905         [ #  # ]:          0 :             uno::Any aCaught( ::cppu::getCaughtException() );
    4906                 :            :             throw lang::WrappedTargetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Can not open package!\n" ) ),
    4907                 :            :                                                 uno::Reference< uno::XInterface >(  static_cast< OWeakObject* >( this ),
    4908                 :            :                                                                                     uno::UNO_QUERY ),
    4909   [ #  #  #  #  :          0 :                                                 aCaught );
                   #  # ]
    4910                 :            :         }
    4911                 :            : 
    4912         [ #  # ]:          0 :         uno::Reference< beans::XPropertySet > xPackPropSet( m_pImpl->m_xPackage, uno::UNO_QUERY_THROW );
    4913                 :            :         try
    4914                 :            :         {
    4915 [ #  # ][ #  # ]:          0 :             xPackPropSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ENCRYPTION_ALGORITHMS_PROPERTY ) ) ) >>= aResult;
         [ #  # ][ #  # ]
    4916                 :            :         }
    4917                 :          0 :         catch ( const uno::RuntimeException& aRuntimeException )
    4918                 :            :         {
    4919         [ #  # ]:          0 :             m_pImpl->AddLog( aRuntimeException.Message );
    4920   [ #  #  #  # ]:          0 :             m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    4921                 :          0 :             throw;
    4922                 :            :         }
    4923      [ #  #  # ]:          0 :         catch( const uno::Exception& aException )
    4924                 :            :         {
    4925         [ #  # ]:          0 :             m_pImpl->AddLog( aException.Message );
    4926   [ #  #  #  # ]:          0 :             m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    4927                 :            : 
    4928   [ #  #  #  # ]:          0 :             throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    4929                 :          0 :         }
    4930                 :            :     }
    4931                 :            : 
    4932         [ #  # ]:          0 :     return aResult;
    4933                 :            : }
    4934                 :            : 
    4935                 :            : 
    4936                 :            : //____________________________________________________________________________________________________
    4937                 :            : //  XPropertySet
    4938                 :            : //____________________________________________________________________________________________________
    4939                 :            : 
    4940                 :            : //-----------------------------------------------
    4941                 :          0 : uno::Reference< beans::XPropertySetInfo > SAL_CALL OStorage::getPropertySetInfo()
    4942                 :            :         throw ( uno::RuntimeException )
    4943                 :            : {
    4944         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    4945                 :            : 
    4946         [ #  # ]:          0 :     if ( !m_pImpl )
    4947                 :            :     {
    4948 [ #  # ][ #  # ]:          0 :         ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    4949 [ #  # ][ #  # ]:          0 :         throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    4950                 :            :     }
    4951                 :            : 
    4952                 :            :     //TODO:
    4953         [ #  # ]:          0 :     return uno::Reference< beans::XPropertySetInfo >();
    4954                 :            : }
    4955                 :            : 
    4956                 :            : 
    4957                 :            : //-----------------------------------------------
    4958                 :      10387 : void SAL_CALL OStorage::setPropertyValue( const ::rtl::OUString& aPropertyName, const uno::Any& aValue )
    4959                 :            :         throw ( beans::UnknownPropertyException,
    4960                 :            :                 beans::PropertyVetoException,
    4961                 :            :                 lang::IllegalArgumentException,
    4962                 :            :                 lang::WrappedTargetException,
    4963                 :            :                 uno::RuntimeException )
    4964                 :            : {
    4965                 :            :     RTL_LOGFILE_CONTEXT( aLog, "package (mv76033) OStorage::setPropertyValue" );
    4966                 :            : 
    4967         [ +  - ]:      10387 :     ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    4968                 :            : 
    4969         [ -  + ]:      10387 :     if ( !m_pImpl )
    4970                 :            :     {
    4971 [ #  # ][ #  # ]:          0 :         ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    4972 [ #  # ][ #  # ]:          0 :         throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    4973                 :            :     }
    4974                 :            : 
    4975                 :            :     //TODO: think about interaction handler
    4976                 :            : 
    4977                 :            :     // WORKAROUND:
    4978                 :            :     // The old document might have no version in the manifest.xml, so we have to allow to set the version
    4979                 :            :     // even for readonly storages, so that the version from content.xml can be used.
    4980 [ -  + ][ #  # ]:      10387 :     if ( m_pData->m_bReadOnlyWrap && aPropertyName != "Version" )
                 [ -  + ]
    4981 [ #  # ][ #  # ]:          0 :         throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); // TODO: Access denied
    4982                 :            : 
    4983         [ -  + ]:      10387 :     if ( m_pData->m_nStorageType == embed::StorageFormats::ZIP )
    4984 [ #  # ][ #  # ]:          0 :         throw beans::UnknownPropertyException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    4985         [ +  - ]:      10387 :     else if ( m_pData->m_nStorageType == embed::StorageFormats::PACKAGE )
    4986                 :            :     {
    4987         [ +  + ]:      10387 :         if ( aPropertyName == "MediaType" )
    4988                 :            :         {
    4989                 :       6237 :             aValue >>= m_pImpl->m_aMediaType;
    4990                 :       6237 :             m_pImpl->m_bControlMediaType = sal_True;
    4991                 :            : 
    4992                 :       6237 :             m_pImpl->m_bBroadcastModified = sal_True;
    4993                 :       6237 :             m_pImpl->m_bIsModified = sal_True;
    4994                 :            :         }
    4995         [ +  - ]:       4150 :         else if ( aPropertyName == "Version" )
    4996                 :            :         {
    4997                 :       4150 :             aValue >>= m_pImpl->m_aVersion;
    4998                 :       4150 :             m_pImpl->m_bControlVersion = sal_True;
    4999                 :            : 
    5000                 :            :             // this property can be set even for readonly storage
    5001         [ +  - ]:       4150 :             if ( !m_pData->m_bReadOnlyWrap )
    5002                 :            :             {
    5003                 :       4150 :                 m_pImpl->m_bBroadcastModified = sal_True;
    5004                 :       4150 :                 m_pImpl->m_bIsModified = sal_True;
    5005                 :            :             }
    5006                 :            :         }
    5007 [ #  # ][ #  #  :          0 :         else if ( ( m_pData->m_bIsRoot && ( aPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( HAS_ENCRYPTED_ENTRIES_PROPERTY ) )
          #  #  #  #  #  
          #  #  #  #  #  
           #  # ][ #  # ]
    5008                 :          0 :                                     || aPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( HAS_NONENCRYPTED_ENTRIES_PROPERTY ) )
    5009                 :          0 :                                     || aPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( IS_INCONSISTENT_PROPERTY ) )
    5010                 :          0 :                                     || aPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "URL" ) )
    5011                 :          0 :                                     || aPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "RepairPackage" ) ) ) )
    5012                 :          0 :            || aPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "IsRoot" ) )
    5013                 :          0 :            || aPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( MEDIATYPE_FALLBACK_USED_PROPERTY ) ) )
    5014 [ #  # ][ #  # ]:          0 :             throw beans::PropertyVetoException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    5015                 :            :         else
    5016 [ #  # ][ #  # ]:          0 :             throw beans::UnknownPropertyException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    5017                 :            :     }
    5018         [ #  # ]:          0 :     else if ( m_pData->m_nStorageType == embed::StorageFormats::OFOPXML )
    5019                 :            :     {
    5020         [ #  # ]:          0 :         if ( aPropertyName == "RelationsInfoStream" )
    5021                 :            :         {
    5022                 :          0 :             uno::Reference< io::XInputStream > xInRelStream;
    5023 [ #  # ][ #  # ]:          0 :             if ( ( aValue >>= xInRelStream ) && xInRelStream.is() )
         [ #  # ][ #  # ]
    5024                 :            :             {
    5025         [ #  # ]:          0 :                 uno::Reference< io::XSeekable > xSeek( xInRelStream, uno::UNO_QUERY );
    5026         [ #  # ]:          0 :                 if ( !xSeek.is() )
    5027                 :            :                 {
    5028                 :            :                     // currently this is an internal property that is used for optimization
    5029                 :            :                     // and the stream must support XSeekable interface
    5030                 :            :                     // TODO/LATER: in future it can be changed if property is used from outside
    5031 [ #  # ][ #  # ]:          0 :                     throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 0 );
    5032                 :            :                 }
    5033                 :            : 
    5034         [ #  # ]:          0 :                 m_pImpl->m_xNewRelInfoStream = xInRelStream;
    5035 [ #  # ][ #  # ]:          0 :                 m_pImpl->m_aRelInfo = uno::Sequence< uno::Sequence< beans::StringPair > >();
                 [ #  # ]
    5036                 :          0 :                 m_pImpl->m_nRelInfoStatus = RELINFO_CHANGED_STREAM;
    5037                 :          0 :                 m_pImpl->m_bBroadcastModified = sal_True;
    5038                 :          0 :                 m_pImpl->m_bIsModified = sal_True;
    5039                 :            :             }
    5040                 :            :             else
    5041 [ #  # ][ #  # ]:          0 :                 throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 0 );
    5042                 :            :         }
    5043         [ #  # ]:          0 :         else if ( aPropertyName == "RelationsInfo" )
    5044                 :            :         {
    5045 [ #  # ][ #  # ]:          0 :             if ( aValue >>= m_pImpl->m_aRelInfo )
    5046                 :            :             {
    5047         [ #  # ]:          0 :                 m_pImpl->m_xNewRelInfoStream = uno::Reference< io::XInputStream >();
    5048                 :          0 :                 m_pImpl->m_nRelInfoStatus = RELINFO_CHANGED;
    5049                 :          0 :                 m_pImpl->m_bBroadcastModified = sal_True;
    5050                 :          0 :                 m_pImpl->m_bIsModified = sal_True;
    5051                 :            :             }
    5052                 :            :             else
    5053 [ #  # ][ #  # ]:          0 :                 throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 0 );
    5054                 :            :         }
    5055 [ #  # ][ #  # ]:          0 :         else if ( ( m_pData->m_bIsRoot && ( aPropertyName == "URL" || aPropertyName == "RepairPackage") )
           [ #  #  #  # ]
                 [ #  # ]
    5056                 :          0 :                  || aPropertyName == "IsRoot" )
    5057 [ #  # ][ #  # ]:          0 :             throw beans::PropertyVetoException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    5058                 :            :         else
    5059 [ #  # ][ #  # ]:          0 :             throw beans::UnknownPropertyException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    5060                 :            :     }
    5061                 :            :     else
    5062 [ #  # ][ #  # ]:          0 :         throw beans::UnknownPropertyException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    5063                 :            : 
    5064 [ +  - ][ +  - ]:      10387 :     BroadcastModifiedIfNecessary();
    5065                 :      10387 : }
    5066                 :            : 
    5067                 :            : 
    5068                 :            : //-----------------------------------------------
    5069                 :      22126 : uno::Any SAL_CALL OStorage::getPropertyValue( const ::rtl::OUString& aPropertyName )
    5070                 :            :         throw ( beans::UnknownPropertyException,
    5071                 :            :                 lang::WrappedTargetException,
    5072                 :            :                 uno::RuntimeException )
    5073                 :            : {
    5074                 :            :     RTL_LOGFILE_CONTEXT( aLog, "package (mv76033) OStorage::getPropertyValue" );
    5075                 :            : 
    5076         [ +  - ]:      22126 :     ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    5077                 :            : 
    5078         [ -  + ]:      22126 :     if ( !m_pImpl )
    5079                 :            :     {
    5080 [ #  # ][ #  # ]:          0 :         ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    5081 [ #  # ][ #  # ]:          0 :         throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    5082                 :            :     }
    5083                 :            : 
    5084   [ +  -  +  +  :      71141 :     if ( m_pData->m_nStorageType == embed::StorageFormats::PACKAGE
             +  +  +  + ]
                 [ +  + ]
    5085                 :      49015 :       && ( aPropertyName == "MediaType" || aPropertyName == MEDIATYPE_FALLBACK_USED_PROPERTY || aPropertyName == "Version" ) )
    5086                 :            :     {
    5087                 :            :         try
    5088                 :            :         {
    5089         [ +  - ]:      11332 :             m_pImpl->ReadContents();
    5090                 :            :         }
    5091                 :          0 :         catch ( const uno::RuntimeException& rRuntimeException )
    5092                 :            :         {
    5093         [ #  # ]:          0 :             m_pImpl->AddLog( rRuntimeException.Message );
    5094   [ #  #  #  # ]:          0 :             m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    5095                 :          0 :             throw;
    5096                 :            :         }
    5097      [ #  #  # ]:          0 :         catch ( const uno::Exception& rException )
    5098                 :            :         {
    5099         [ #  # ]:          0 :             m_pImpl->AddLog( rException.Message );
    5100   [ #  #  #  # ]:          0 :             m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    5101                 :            : 
    5102         [ #  # ]:          0 :             uno::Any aCaught( ::cppu::getCaughtException() );
    5103                 :            :             throw lang::WrappedTargetException(
    5104                 :            :                                         ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Can't read contents!" ) ),
    5105                 :            :                                         uno::Reference< XInterface >( static_cast< OWeakObject* >( this ), uno::UNO_QUERY ),
    5106   [ #  #  #  #  :          0 :                                         aCaught );
                   #  # ]
    5107                 :            :         }
    5108                 :            : 
    5109         [ +  + ]:      11332 :         if ( aPropertyName == "MediaType" )
    5110         [ +  - ]:       8598 :             return uno::makeAny( m_pImpl->m_aMediaType );
    5111         [ +  + ]:       2734 :         else if ( aPropertyName == "Version" )
    5112         [ +  - ]:       2567 :             return uno::makeAny( m_pImpl->m_aVersion );
    5113                 :            :         else
    5114         [ +  - ]:        167 :             return uno::makeAny( m_pImpl->m_bMTFallbackUsed );
    5115                 :            :     }
    5116         [ +  + ]:      10794 :     else if ( aPropertyName == "IsRoot" )
    5117                 :            :     {
    5118         [ +  - ]:        396 :         return uno::makeAny( m_pData->m_bIsRoot );
    5119                 :            :     }
    5120         [ +  + ]:      10398 :     else if ( aPropertyName == "OpenMode" )
    5121                 :            :     {
    5122         [ +  - ]:       5465 :         return uno::makeAny( m_pImpl->m_nStorageMode );
    5123                 :            :     }
    5124         [ +  - ]:       4933 :     else if ( m_pData->m_bIsRoot )
    5125                 :            :     {
    5126   [ +  -  +  + ]:       9866 :         if ( aPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "URL" ) )
                 [ +  + ]
    5127                 :       4933 :           || aPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "RepairPackage" ) ) )
    5128                 :            :         {
    5129         [ -  + ]:        147 :             for ( sal_Int32 aInd = 0; aInd < m_pImpl->m_xProperties.getLength(); aInd++ )
    5130                 :            :             {
    5131 [ #  # ][ #  # ]:          0 :                 if ( m_pImpl->m_xProperties[aInd].Name.equals( aPropertyName ) )
    5132         [ #  # ]:          0 :                     return m_pImpl->m_xProperties[aInd].Value;
    5133                 :            :             }
    5134                 :            : 
    5135         [ -  + ]:        147 :             if ( aPropertyName == "URL" )
    5136         [ #  # ]:          0 :                 return uno::makeAny( ::rtl::OUString() );
    5137                 :            : 
    5138         [ +  - ]:        147 :             return uno::makeAny( sal_False ); // RepairPackage
    5139                 :            :         }
    5140   [ +  -  +  +  :      12102 :         else if ( m_pData->m_nStorageType == embed::StorageFormats::PACKAGE
             +  +  +  - ]
                 [ +  - ]
    5141                 :       4786 :           && ( aPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( HAS_ENCRYPTED_ENTRIES_PROPERTY ) )
    5142                 :       2383 :             || aPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( HAS_NONENCRYPTED_ENTRIES_PROPERTY ) )
    5143                 :        147 :             || aPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( IS_INCONSISTENT_PROPERTY ) ) ) )
    5144                 :            :         {
    5145                 :            :             try {
    5146         [ +  - ]:       4786 :                 m_pImpl->ReadContents();
    5147         [ +  - ]:       4786 :                 uno::Reference< beans::XPropertySet > xPackPropSet( m_pImpl->m_xPackage, uno::UNO_QUERY );
    5148         [ -  + ]:       4786 :                 if ( !xPackPropSet.is() )
    5149 [ #  # ][ #  # ]:          0 :                     throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    5150                 :            : 
    5151 [ +  - ][ +  - ]:       4786 :                 return xPackPropSet->getPropertyValue( aPropertyName );
    5152                 :            :             }
    5153                 :          0 :             catch ( const uno::RuntimeException& rRuntimeException )
    5154                 :            :             {
    5155         [ #  # ]:          0 :                 m_pImpl->AddLog( rRuntimeException.Message );
    5156   [ #  #  #  # ]:          0 :                 m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    5157                 :          0 :                 throw;
    5158                 :            :             }
    5159      [ #  #  # ]:          0 :             catch ( const uno::Exception& rException )
    5160                 :            :             {
    5161         [ #  # ]:          0 :                 m_pImpl->AddLog( rException.Message );
    5162   [ #  #  #  # ]:          0 :                 m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    5163                 :            : 
    5164         [ #  # ]:          0 :                 uno::Any aCaught( ::cppu::getCaughtException() );
    5165                 :            :                 throw lang::WrappedTargetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Can not open package!\n" ) ),
    5166                 :            :                                                     uno::Reference< uno::XInterface >(  static_cast< OWeakObject* >( this ),
    5167                 :            :                                                                                         uno::UNO_QUERY ),
    5168   [ #  #  #  #  :          0 :                                                     aCaught );
                   #  # ]
    5169                 :            :             }
    5170                 :            :         }
    5171                 :            :     }
    5172                 :            : 
    5173 [ #  # ][ #  # ]:      22126 :     throw beans::UnknownPropertyException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
                 [ +  - ]
    5174                 :            : }
    5175                 :            : 
    5176                 :            : 
    5177                 :            : //-----------------------------------------------
    5178                 :          0 : void SAL_CALL OStorage::addPropertyChangeListener(
    5179                 :            :     const ::rtl::OUString& /*aPropertyName*/,
    5180                 :            :     const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/ )
    5181                 :            :         throw ( beans::UnknownPropertyException,
    5182                 :            :                 lang::WrappedTargetException,
    5183                 :            :                 uno::RuntimeException )
    5184                 :            : {
    5185         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    5186                 :            : 
    5187         [ #  # ]:          0 :     if ( !m_pImpl )
    5188                 :            :     {
    5189 [ #  # ][ #  # ]:          0 :         ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    5190 [ #  # ][ #  # ]:          0 :         throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    5191         [ #  # ]:          0 :     }
    5192                 :            : 
    5193                 :            :     //TODO:
    5194                 :          0 : }
    5195                 :            : 
    5196                 :            : 
    5197                 :            : //-----------------------------------------------
    5198                 :          0 : void SAL_CALL OStorage::removePropertyChangeListener(
    5199                 :            :     const ::rtl::OUString& /*aPropertyName*/,
    5200                 :            :     const uno::Reference< beans::XPropertyChangeListener >& /*aListener*/ )
    5201                 :            :         throw ( beans::UnknownPropertyException,
    5202                 :            :                 lang::WrappedTargetException,
    5203                 :            :                 uno::RuntimeException )
    5204                 :            : {
    5205         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    5206                 :            : 
    5207         [ #  # ]:          0 :     if ( !m_pImpl )
    5208                 :            :     {
    5209 [ #  # ][ #  # ]:          0 :         ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    5210 [ #  # ][ #  # ]:          0 :         throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    5211         [ #  # ]:          0 :     }
    5212                 :            : 
    5213                 :            :     //TODO:
    5214                 :          0 : }
    5215                 :            : 
    5216                 :            : 
    5217                 :            : //-----------------------------------------------
    5218                 :          0 : void SAL_CALL OStorage::addVetoableChangeListener(
    5219                 :            :     const ::rtl::OUString& /*PropertyName*/,
    5220                 :            :     const uno::Reference< beans::XVetoableChangeListener >& /*aListener*/ )
    5221                 :            :         throw ( beans::UnknownPropertyException,
    5222                 :            :                 lang::WrappedTargetException,
    5223                 :            :                 uno::RuntimeException )
    5224                 :            : {
    5225         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    5226                 :            : 
    5227         [ #  # ]:          0 :     if ( !m_pImpl )
    5228                 :            :     {
    5229 [ #  # ][ #  # ]:          0 :         ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    5230 [ #  # ][ #  # ]:          0 :         throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    5231         [ #  # ]:          0 :     }
    5232                 :            : 
    5233                 :            :     //TODO:
    5234                 :          0 : }
    5235                 :            : 
    5236                 :            : 
    5237                 :            : //-----------------------------------------------
    5238                 :          0 : void SAL_CALL OStorage::removeVetoableChangeListener(
    5239                 :            :     const ::rtl::OUString& /*PropertyName*/,
    5240                 :            :     const uno::Reference< beans::XVetoableChangeListener >& /*aListener*/ )
    5241                 :            :         throw ( beans::UnknownPropertyException,
    5242                 :            :                 lang::WrappedTargetException,
    5243                 :            :                 uno::RuntimeException )
    5244                 :            : {
    5245         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    5246                 :            : 
    5247         [ #  # ]:          0 :     if ( !m_pImpl )
    5248                 :            :     {
    5249 [ #  # ][ #  # ]:          0 :         ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    5250 [ #  # ][ #  # ]:          0 :         throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    5251         [ #  # ]:          0 :     }
    5252                 :            : 
    5253                 :            :     //TODO:
    5254                 :          0 : }
    5255                 :            : 
    5256                 :            : //____________________________________________________________________________________________________
    5257                 :            : //  XRelationshipAccess
    5258                 :            : //____________________________________________________________________________________________________
    5259                 :            : 
    5260                 :            : // TODO/LATER: the storage and stream implementations of this interface are very similar, they could use a helper class
    5261                 :            : 
    5262                 :            : //-----------------------------------------------
    5263                 :          0 : sal_Bool SAL_CALL OStorage::hasByID(  const ::rtl::OUString& sID )
    5264                 :            :         throw ( io::IOException,
    5265                 :            :                 uno::RuntimeException )
    5266                 :            : {
    5267         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    5268                 :            : 
    5269         [ #  # ]:          0 :     if ( !m_pImpl )
    5270                 :            :     {
    5271 [ #  # ][ #  # ]:          0 :         ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    5272 [ #  # ][ #  # ]:          0 :         throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    5273                 :            :     }
    5274                 :            : 
    5275         [ #  # ]:          0 :     if ( m_pData->m_nStorageType != embed::StorageFormats::OFOPXML )
    5276 [ #  # ][ #  # ]:          0 :         throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    5277                 :            : 
    5278                 :            :     try
    5279                 :            :     {
    5280 [ #  # ][ #  # ]:          0 :         getRelationshipByID( sID );
    5281                 :          0 :         return sal_True;
    5282                 :            :     }
    5283   [ #  #  #  # ]:          0 :     catch( const container::NoSuchElementException& rNoSuchElementException )
    5284                 :            :     {
    5285         [ #  # ]:          0 :         m_pImpl->AddLog( rNoSuchElementException.Message );
    5286   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Quiet exception" ) ) );
    5287                 :            :     }
    5288                 :            : 
    5289         [ #  # ]:          0 :     return sal_False;
    5290                 :            : }
    5291                 :            : 
    5292                 :            : //-----------------------------------------------
    5293                 :          0 : ::rtl::OUString SAL_CALL OStorage::getTargetByID(  const ::rtl::OUString& sID  )
    5294                 :            :         throw ( container::NoSuchElementException,
    5295                 :            :                 io::IOException,
    5296                 :            :                 uno::RuntimeException )
    5297                 :            : {
    5298         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    5299                 :            : 
    5300         [ #  # ]:          0 :     if ( !m_pImpl )
    5301                 :            :     {
    5302 [ #  # ][ #  # ]:          0 :         ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    5303 [ #  # ][ #  # ]:          0 :         throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    5304                 :            :     }
    5305                 :            : 
    5306         [ #  # ]:          0 :     if ( m_pData->m_nStorageType != embed::StorageFormats::OFOPXML )
    5307 [ #  # ][ #  # ]:          0 :         throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    5308                 :            : 
    5309         [ #  # ]:          0 :     uno::Sequence< beans::StringPair > aSeq = getRelationshipByID( sID );
    5310         [ #  # ]:          0 :     for ( sal_Int32 nInd = 0; nInd < aSeq.getLength(); nInd++ )
    5311 [ #  # ][ #  # ]:          0 :         if ( aSeq[nInd].First == "Target" )
    5312         [ #  # ]:          0 :             return aSeq[nInd].Second;
    5313                 :            : 
    5314 [ #  # ][ #  # ]:          0 :     return ::rtl::OUString();
    5315                 :            : }
    5316                 :            : 
    5317                 :            : //-----------------------------------------------
    5318                 :          0 : ::rtl::OUString SAL_CALL OStorage::getTypeByID(  const ::rtl::OUString& sID  )
    5319                 :            :         throw ( container::NoSuchElementException,
    5320                 :            :                 io::IOException,
    5321                 :            :                 uno::RuntimeException )
    5322                 :            : {
    5323         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    5324                 :            : 
    5325         [ #  # ]:          0 :     if ( !m_pImpl )
    5326                 :            :     {
    5327 [ #  # ][ #  # ]:          0 :         ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    5328 [ #  # ][ #  # ]:          0 :         throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    5329                 :            :     }
    5330                 :            : 
    5331         [ #  # ]:          0 :     if ( m_pData->m_nStorageType != embed::StorageFormats::OFOPXML )
    5332 [ #  # ][ #  # ]:          0 :         throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    5333                 :            : 
    5334         [ #  # ]:          0 :     uno::Sequence< beans::StringPair > aSeq = getRelationshipByID( sID );
    5335         [ #  # ]:          0 :     for ( sal_Int32 nInd = 0; nInd < aSeq.getLength(); nInd++ )
    5336 [ #  # ][ #  # ]:          0 :         if ( aSeq[nInd].First == "Type" )
    5337         [ #  # ]:          0 :             return aSeq[nInd].Second;
    5338                 :            : 
    5339 [ #  # ][ #  # ]:          0 :     return ::rtl::OUString();
    5340                 :            : }
    5341                 :            : 
    5342                 :            : //-----------------------------------------------
    5343                 :          0 : uno::Sequence< beans::StringPair > SAL_CALL OStorage::getRelationshipByID(  const ::rtl::OUString& sID  )
    5344                 :            :         throw ( container::NoSuchElementException,
    5345                 :            :                 io::IOException,
    5346                 :            :                 uno::RuntimeException )
    5347                 :            : {
    5348         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    5349                 :            : 
    5350         [ #  # ]:          0 :     if ( !m_pImpl )
    5351                 :            :     {
    5352 [ #  # ][ #  # ]:          0 :         ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    5353 [ #  # ][ #  # ]:          0 :         throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    5354                 :            :     }
    5355                 :            : 
    5356         [ #  # ]:          0 :     if ( m_pData->m_nStorageType != embed::StorageFormats::OFOPXML )
    5357 [ #  # ][ #  # ]:          0 :         throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    5358                 :            : 
    5359                 :            :     // TODO/LATER: in future the unification of the ID could be checked
    5360         [ #  # ]:          0 :     uno::Sequence< uno::Sequence< beans::StringPair > > aSeq = getAllRelationships();
    5361         [ #  # ]:          0 :     for ( sal_Int32 nInd1 = 0; nInd1 < aSeq.getLength(); nInd1++ )
    5362 [ #  # ][ #  # ]:          0 :         for ( sal_Int32 nInd2 = 0; nInd2 < aSeq[nInd1].getLength(); nInd2++ )
    5363 [ #  # ][ #  # ]:          0 :             if ( aSeq[nInd1][nInd2].First == "Id" )
                 [ #  # ]
    5364                 :            :             {
    5365 [ #  # ][ #  # ]:          0 :                 if ( aSeq[nInd1][nInd2].Second.equals( sID ) )
                 [ #  # ]
    5366 [ #  # ][ #  # ]:          0 :                     return aSeq[nInd1];
    5367                 :          0 :                 break;
    5368                 :            :             }
    5369                 :            : 
    5370 [ #  # ][ #  # ]:          0 :     throw container::NoSuchElementException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
         [ #  # ][ #  # ]
    5371                 :            : }
    5372                 :            : 
    5373                 :            : //-----------------------------------------------
    5374                 :        767 : uno::Sequence< uno::Sequence< beans::StringPair > > SAL_CALL OStorage::getRelationshipsByType(  const ::rtl::OUString& sType  )
    5375                 :            :         throw ( io::IOException,
    5376                 :            :                 uno::RuntimeException )
    5377                 :            : {
    5378         [ +  - ]:        767 :     ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    5379                 :            : 
    5380         [ -  + ]:        767 :     if ( !m_pImpl )
    5381                 :            :     {
    5382 [ #  # ][ #  # ]:          0 :         ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    5383 [ #  # ][ #  # ]:          0 :         throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    5384                 :            :     }
    5385                 :            : 
    5386         [ -  + ]:        767 :     if ( m_pData->m_nStorageType != embed::StorageFormats::OFOPXML )
    5387 [ #  # ][ #  # ]:          0 :         throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    5388                 :            : 
    5389         [ +  - ]:        767 :     uno::Sequence< uno::Sequence< beans::StringPair > > aResult;
    5390                 :        767 :     sal_Int32 nEntriesNum = 0;
    5391                 :            : 
    5392                 :            :     // TODO/LATER: in future the unification of the ID could be checked
    5393         [ +  - ]:        767 :     uno::Sequence< uno::Sequence< beans::StringPair > > aSeq = getAllRelationships();
    5394         [ +  + ]:       3101 :     for ( sal_Int32 nInd1 = 0; nInd1 < aSeq.getLength(); nInd1++ )
    5395 [ +  - ][ +  - ]:       4668 :         for ( sal_Int32 nInd2 = 0; nInd2 < aSeq[nInd1].getLength(); nInd2++ )
    5396 [ +  - ][ +  - ]:       4668 :             if ( aSeq[nInd1][nInd2].First == "Type" )
                 [ +  + ]
    5397                 :            :             {
    5398                 :            :                 // the type is usually an URL, so the check should be case insensitive
    5399 [ +  - ][ +  - ]:       2334 :                 if ( aSeq[nInd1][nInd2].Second.equalsIgnoreAsciiCase( sType ) )
                 [ +  + ]
    5400                 :            :                 {
    5401         [ +  - ]:        430 :                     aResult.realloc( ++nEntriesNum );
    5402 [ +  - ][ +  - ]:        430 :                     aResult[nEntriesNum-1] = aSeq[nInd1];
                 [ +  - ]
    5403                 :            :                 }
    5404                 :       2334 :                 break;
    5405                 :            :             }
    5406                 :            : 
    5407 [ +  - ][ +  - ]:        767 :     return aResult;
    5408                 :            : }
    5409                 :            : 
    5410                 :            : //-----------------------------------------------
    5411                 :       1129 : uno::Sequence< uno::Sequence< beans::StringPair > > SAL_CALL OStorage::getAllRelationships()
    5412                 :            :         throw (io::IOException, uno::RuntimeException)
    5413                 :            : {
    5414         [ +  - ]:       1129 :     ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    5415                 :            : 
    5416         [ -  + ]:       1129 :     if ( !m_pImpl )
    5417                 :            :     {
    5418 [ #  # ][ #  # ]:          0 :         ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    5419 [ #  # ][ #  # ]:          0 :         throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    5420                 :            :     }
    5421                 :            : 
    5422         [ -  + ]:       1129 :     if ( m_pData->m_nStorageType != embed::StorageFormats::OFOPXML )
    5423 [ #  # ][ #  # ]:          0 :         throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    5424                 :            : 
    5425 [ +  - ][ +  - ]:       1129 :     return m_pImpl->GetAllRelationshipsIfAny();
    5426                 :            : }
    5427                 :            : 
    5428                 :            : //-----------------------------------------------
    5429                 :        171 : void SAL_CALL OStorage::insertRelationshipByID(  const ::rtl::OUString& sID, const uno::Sequence< beans::StringPair >& aEntry, ::sal_Bool bReplace  )
    5430                 :            :         throw ( container::ElementExistException,
    5431                 :            :                 io::IOException,
    5432                 :            :                 uno::RuntimeException )
    5433                 :            : {
    5434         [ +  - ]:        171 :     ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    5435                 :            : 
    5436         [ -  + ]:        171 :     if ( !m_pImpl )
    5437                 :            :     {
    5438 [ #  # ][ #  # ]:          0 :         ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    5439 [ #  # ][ #  # ]:          0 :         throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    5440                 :            :     }
    5441                 :            : 
    5442         [ -  + ]:        171 :     if ( m_pData->m_nStorageType != embed::StorageFormats::OFOPXML )
    5443 [ #  # ][ #  # ]:          0 :         throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    5444                 :            : 
    5445         [ +  - ]:        171 :     ::rtl::OUString aIDTag( RTL_CONSTASCII_USTRINGPARAM( "Id" ) );
    5446                 :            : 
    5447                 :        171 :     sal_Int32 nIDInd = -1;
    5448                 :            : 
    5449                 :            :     // TODO/LATER: in future the unification of the ID could be checked
    5450         [ +  - ]:        171 :     uno::Sequence< uno::Sequence< beans::StringPair > > aSeq = getAllRelationships();
    5451         [ +  + ]:        342 :     for ( sal_Int32 nInd1 = 0; nInd1 < aSeq.getLength(); nInd1++ )
    5452 [ +  - ][ +  - ]:        171 :         for ( sal_Int32 nInd2 = 0; nInd2 < aSeq[nInd1].getLength(); nInd2++ )
    5453 [ +  - ][ +  - ]:        171 :             if ( aSeq[nInd1][nInd2].First.equals( aIDTag ) )
                 [ +  - ]
    5454                 :            :             {
    5455 [ +  - ][ +  - ]:        171 :                 if ( aSeq[nInd1][nInd2].Second.equals( sID ) )
                 [ -  + ]
    5456                 :          0 :                     nIDInd = nInd1;
    5457                 :            : 
    5458                 :        171 :                 break;
    5459                 :            :             }
    5460                 :            : 
    5461 [ -  + ][ #  # ]:        171 :     if ( nIDInd == -1 || bReplace )
    5462                 :            :     {
    5463         [ +  - ]:        171 :         if ( nIDInd == -1 )
    5464                 :            :         {
    5465                 :        171 :             nIDInd = aSeq.getLength();
    5466         [ +  - ]:        171 :             aSeq.realloc( nIDInd + 1 );
    5467                 :            :         }
    5468                 :            : 
    5469 [ +  - ][ +  - ]:        171 :         aSeq[nIDInd].realloc( aEntry.getLength() + 1 );
    5470                 :            : 
    5471 [ +  - ][ +  - ]:        171 :         aSeq[nIDInd][0].First = aIDTag;
    5472 [ +  - ][ +  - ]:        171 :         aSeq[nIDInd][0].Second = sID;
    5473                 :        171 :         sal_Int32 nIndTarget = 1;
    5474         [ +  + ]:       1026 :         for ( sal_Int32 nIndOrig = 0;
    5475                 :        513 :               nIndOrig < aEntry.getLength();
    5476                 :            :               nIndOrig++ )
    5477                 :            :         {
    5478         [ +  - ]:        342 :             if ( !aEntry[nIndOrig].First.equals( aIDTag ) )
    5479 [ +  - ][ +  - ]:        342 :                 aSeq[nIDInd][nIndTarget++] = aEntry[nIndOrig];
    5480                 :            :         }
    5481                 :            : 
    5482 [ +  - ][ +  - ]:        171 :         aSeq[nIDInd].realloc( nIndTarget );
    5483                 :            :     }
    5484                 :            :     else
    5485 [ #  # ][ #  # ]:          0 :         throw container::ElementExistException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    5486                 :            : 
    5487                 :            : 
    5488         [ +  - ]:        171 :     m_pImpl->m_aRelInfo = aSeq;
    5489         [ +  - ]:        171 :     m_pImpl->m_xNewRelInfoStream = uno::Reference< io::XInputStream >();
    5490 [ +  - ][ +  - ]:        171 :     m_pImpl->m_nRelInfoStatus = RELINFO_CHANGED;
    5491                 :        171 : }
    5492                 :            : 
    5493                 :            : //-----------------------------------------------
    5494                 :          0 : void SAL_CALL OStorage::removeRelationshipByID(  const ::rtl::OUString& sID  )
    5495                 :            :         throw ( container::NoSuchElementException,
    5496                 :            :                 io::IOException,
    5497                 :            :                 uno::RuntimeException )
    5498                 :            : {
    5499         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    5500                 :            : 
    5501         [ #  # ]:          0 :     if ( !m_pImpl )
    5502                 :            :     {
    5503 [ #  # ][ #  # ]:          0 :         ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    5504 [ #  # ][ #  # ]:          0 :         throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    5505                 :            :     }
    5506                 :            : 
    5507         [ #  # ]:          0 :     if ( m_pData->m_nStorageType != embed::StorageFormats::OFOPXML )
    5508 [ #  # ][ #  # ]:          0 :         throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    5509                 :            : 
    5510         [ #  # ]:          0 :     uno::Sequence< uno::Sequence< beans::StringPair > > aSeq = getAllRelationships();
    5511         [ #  # ]:          0 :     for ( sal_Int32 nInd1 = 0; nInd1 < aSeq.getLength(); nInd1++ )
    5512 [ #  # ][ #  # ]:          0 :         for ( sal_Int32 nInd2 = 0; nInd2 < aSeq[nInd1].getLength(); nInd2++ )
    5513 [ #  # ][ #  # ]:          0 :             if ( aSeq[nInd1][nInd2].First == "Id" )
                 [ #  # ]
    5514                 :            :             {
    5515 [ #  # ][ #  # ]:          0 :                 if ( aSeq[nInd1][nInd2].Second.equals( sID ) )
                 [ #  # ]
    5516                 :            :                 {
    5517                 :          0 :                     sal_Int32 nLength = aSeq.getLength();
    5518 [ #  # ][ #  # ]:          0 :                     aSeq[nInd1] = aSeq[nLength-1];
                 [ #  # ]
    5519         [ #  # ]:          0 :                     aSeq.realloc( nLength - 1 );
    5520                 :            : 
    5521         [ #  # ]:          0 :                     m_pImpl->m_aRelInfo = aSeq;
    5522         [ #  # ]:          0 :                     m_pImpl->m_xNewRelInfoStream = uno::Reference< io::XInputStream >();
    5523                 :          0 :                     m_pImpl->m_nRelInfoStatus = RELINFO_CHANGED;
    5524                 :            : 
    5525                 :            :                     // TODO/LATER: in future the unification of the ID could be checked
    5526                 :          0 :                     return;
    5527                 :            :                 }
    5528                 :            : 
    5529                 :          0 :                 break;
    5530                 :            :             }
    5531                 :            : 
    5532 [ #  # ][ #  # ]:          0 :     throw container::NoSuchElementException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
         [ #  # ][ #  # ]
    5533                 :            : }
    5534                 :            : 
    5535                 :            : //-----------------------------------------------
    5536                 :          0 : void SAL_CALL OStorage::insertRelationships(  const uno::Sequence< uno::Sequence< beans::StringPair > >& aEntries, ::sal_Bool bReplace  )
    5537                 :            :         throw ( container::ElementExistException,
    5538                 :            :                 io::IOException,
    5539                 :            :                 uno::RuntimeException )
    5540                 :            : {
    5541         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    5542                 :            : 
    5543         [ #  # ]:          0 :     if ( !m_pImpl )
    5544                 :            :     {
    5545 [ #  # ][ #  # ]:          0 :         ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    5546 [ #  # ][ #  # ]:          0 :         throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    5547                 :            :     }
    5548                 :            : 
    5549         [ #  # ]:          0 :     if ( m_pData->m_nStorageType != embed::StorageFormats::OFOPXML )
    5550 [ #  # ][ #  # ]:          0 :         throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    5551                 :            : 
    5552         [ #  # ]:          0 :     ::rtl::OUString aIDTag( RTL_CONSTASCII_USTRINGPARAM( "Id" ) );
    5553         [ #  # ]:          0 :     uno::Sequence< uno::Sequence< beans::StringPair > > aSeq = getAllRelationships();
    5554         [ #  # ]:          0 :     uno::Sequence< uno::Sequence< beans::StringPair > > aResultSeq( aSeq.getLength() + aEntries.getLength() );
    5555                 :          0 :     sal_Int32 nResultInd = 0;
    5556                 :            : 
    5557         [ #  # ]:          0 :     for ( sal_Int32 nIndTarget1 = 0; nIndTarget1 < aSeq.getLength(); nIndTarget1++ )
    5558 [ #  # ][ #  # ]:          0 :         for ( sal_Int32 nIndTarget2 = 0; nIndTarget2 < aSeq[nIndTarget1].getLength(); nIndTarget2++ )
    5559 [ #  # ][ #  # ]:          0 :             if ( aSeq[nIndTarget1][nIndTarget2].First.equals( aIDTag ) )
                 [ #  # ]
    5560                 :            :             {
    5561                 :          0 :                 sal_Int32 nIndSourceSame = -1;
    5562                 :            : 
    5563         [ #  # ]:          0 :                 for ( sal_Int32 nIndSource1 = 0; nIndSource1 < aEntries.getLength(); nIndSource1++ )
    5564         [ #  # ]:          0 :                     for ( sal_Int32 nIndSource2 = 0; nIndSource2 < aEntries[nIndSource1].getLength(); nIndSource2++ )
    5565                 :            :                     {
    5566         [ #  # ]:          0 :                         if ( aEntries[nIndSource1][nIndSource2].First.equals( aIDTag ) )
    5567                 :            :                         {
    5568 [ #  # ][ #  # ]:          0 :                             if ( aEntries[nIndSource1][nIndSource2].Second.equals( aSeq[nIndTarget1][nIndTarget2].Second ) )
                 [ #  # ]
    5569                 :            :                             {
    5570         [ #  # ]:          0 :                                 if ( !bReplace )
    5571 [ #  # ][ #  # ]:          0 :                                     throw container::ElementExistException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    5572                 :            : 
    5573                 :          0 :                                 nIndSourceSame = nIndSource1;
    5574                 :            :                             }
    5575                 :            : 
    5576                 :          0 :                             break;
    5577                 :            :                         }
    5578                 :            :                     }
    5579                 :            : 
    5580         [ #  # ]:          0 :                 if ( nIndSourceSame == -1 )
    5581                 :            :                 {
    5582                 :            :                     // no such element in the provided sequence
    5583 [ #  # ][ #  # ]:          0 :                     aResultSeq[nResultInd++] = aSeq[nIndTarget1];
                 [ #  # ]
    5584                 :            :                 }
    5585                 :            : 
    5586                 :          0 :                 break;
    5587                 :            :             }
    5588                 :            : 
    5589         [ #  # ]:          0 :     for ( sal_Int32 nIndSource1 = 0; nIndSource1 < aEntries.getLength(); nIndSource1++ )
    5590                 :            :     {
    5591 [ #  # ][ #  # ]:          0 :         aResultSeq[nResultInd].realloc( aEntries[nIndSource1].getLength() );
    5592                 :          0 :         sal_Bool bHasID = sal_False;
    5593                 :          0 :         sal_Int32 nResInd2 = 1;
    5594                 :            : 
    5595         [ #  # ]:          0 :         for ( sal_Int32 nIndSource2 = 0; nIndSource2 < aEntries[nIndSource1].getLength(); nIndSource2++ )
    5596         [ #  # ]:          0 :             if ( aEntries[nIndSource1][nIndSource2].First.equals( aIDTag ) )
    5597                 :            :             {
    5598 [ #  # ][ #  # ]:          0 :                 aResultSeq[nResultInd][0] = aEntries[nIndSource1][nIndSource2];
    5599                 :          0 :                 bHasID = sal_True;
    5600                 :            :             }
    5601 [ #  # ][ #  # ]:          0 :             else if ( nResInd2 < aResultSeq[nResultInd].getLength() )
    5602 [ #  # ][ #  # ]:          0 :                 aResultSeq[nResultInd][nResInd2++] = aEntries[nIndSource1][nIndSource2];
    5603                 :            :             else
    5604 [ #  # ][ #  # ]:          0 :                 throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); // TODO: illegal relation ( no ID )
    5605                 :            : 
    5606         [ #  # ]:          0 :         if ( !bHasID )
    5607 [ #  # ][ #  # ]:          0 :             throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); // TODO: illegal relations
    5608                 :            : 
    5609                 :          0 :         nResultInd++;
    5610                 :            :     }
    5611                 :            : 
    5612         [ #  # ]:          0 :     aResultSeq.realloc( nResultInd );
    5613         [ #  # ]:          0 :     m_pImpl->m_aRelInfo = aResultSeq;
    5614         [ #  # ]:          0 :     m_pImpl->m_xNewRelInfoStream = uno::Reference< io::XInputStream >();
    5615 [ #  # ][ #  # ]:          0 :     m_pImpl->m_nRelInfoStatus = RELINFO_CHANGED;
                 [ #  # ]
    5616                 :          0 : }
    5617                 :            : 
    5618                 :            : //-----------------------------------------------
    5619                 :          0 : void SAL_CALL OStorage::clearRelationships()
    5620                 :            :         throw ( io::IOException,
    5621                 :            :                 uno::RuntimeException )
    5622                 :            : {
    5623         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    5624                 :            : 
    5625         [ #  # ]:          0 :     if ( !m_pImpl )
    5626                 :            :     {
    5627 [ #  # ][ #  # ]:          0 :         ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    5628 [ #  # ][ #  # ]:          0 :         throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    5629                 :            :     }
    5630                 :            : 
    5631         [ #  # ]:          0 :     if ( m_pData->m_nStorageType != embed::StorageFormats::OFOPXML )
    5632 [ #  # ][ #  # ]:          0 :         throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    5633                 :            : 
    5634         [ #  # ]:          0 :     m_pImpl->m_aRelInfo.realloc( 0 );
    5635         [ #  # ]:          0 :     m_pImpl->m_xNewRelInfoStream = uno::Reference< io::XInputStream >();
    5636         [ #  # ]:          0 :     m_pImpl->m_nRelInfoStatus = RELINFO_CHANGED;
    5637                 :          0 : }
    5638                 :            : 
    5639                 :            : //____________________________________________________________________________________________________
    5640                 :            : //  XOptimizedStorage
    5641                 :            : //____________________________________________________________________________________________________
    5642                 :            : //-----------------------------------------------
    5643                 :          0 : void SAL_CALL OStorage::insertRawNonEncrStreamElementDirect(
    5644                 :            :             const ::rtl::OUString& /*sStreamName*/,
    5645                 :            :             const uno::Reference< io::XInputStream >& /*xInStream*/ )
    5646                 :            :         throw ( embed::InvalidStorageException,
    5647                 :            :                 lang::IllegalArgumentException,
    5648                 :            :                 packages::NoRawFormatException,
    5649                 :            :                 container::ElementExistException,
    5650                 :            :                 io::IOException,
    5651                 :            :                 embed::StorageWrappedTargetException,
    5652                 :            :                 uno::RuntimeException )
    5653                 :            : {
    5654                 :            :     // not implemented currently because there is still no demand
    5655                 :            :     // might need to be implemented if direct copying of compressed streams is used
    5656 [ #  # ][ #  # ]:          0 :     throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    5657                 :            : }
    5658                 :            : 
    5659                 :            : //-----------------------------------------------
    5660                 :          0 : void SAL_CALL OStorage::insertStreamElementDirect(
    5661                 :            :             const ::rtl::OUString& aStreamName,
    5662                 :            :             const uno::Reference< io::XInputStream >& xInStream,
    5663                 :            :             const uno::Sequence< beans::PropertyValue >& aProps )
    5664                 :            :         throw ( embed::InvalidStorageException,
    5665                 :            :                 lang::IllegalArgumentException,
    5666                 :            :                 container::ElementExistException,
    5667                 :            :                 io::IOException,
    5668                 :            :                 embed::StorageWrappedTargetException,
    5669                 :            :                 uno::RuntimeException )
    5670                 :            : {
    5671                 :            :     RTL_LOGFILE_CONTEXT( aLog, "package (mv76033) OStorage::insertStreamElementDirect" );
    5672                 :            : 
    5673         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    5674                 :            : 
    5675         [ #  # ]:          0 :     if ( !m_pImpl )
    5676                 :            :     {
    5677 [ #  # ][ #  # ]:          0 :         ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    5678 [ #  # ][ #  # ]:          0 :         throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    5679                 :            :     }
    5680                 :            : 
    5681 [ #  # ][ #  # ]:          0 :     if ( aStreamName.isEmpty() || !::comphelper::OStorageHelper::IsValidZipEntryFileName( aStreamName, sal_False ) )
         [ #  # ][ #  # ]
    5682 [ #  # ][ #  # ]:          0 :         throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Unexpected entry name syntax." ) ), uno::Reference< uno::XInterface >(), 1 );
    5683                 :            : 
    5684 [ #  # ][ #  # ]:          0 :     if ( m_pData->m_nStorageType == embed::StorageFormats::OFOPXML && aStreamName == "_rels" )
                 [ #  # ]
    5685 [ #  # ][ #  # ]:          0 :         throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 1 ); // unacceptable storage name
    5686                 :            : 
    5687         [ #  # ]:          0 :     if ( m_pData->m_bReadOnlyWrap )
    5688 [ #  # ][ #  # ]:          0 :         throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); // TODO: access denied
    5689                 :            : 
    5690                 :            :     try
    5691                 :            :     {
    5692         [ #  # ]:          0 :         SotElement_Impl* pElement = m_pImpl->FindElement( aStreamName );
    5693                 :            : 
    5694         [ #  # ]:          0 :         if ( pElement )
    5695 [ #  # ][ #  # ]:          0 :             throw container::ElementExistException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    5696                 :            : 
    5697         [ #  # ]:          0 :         pElement = OpenStreamElement_Impl( aStreamName, embed::ElementModes::READWRITE, sal_False );
    5698                 :            :         OSL_ENSURE( pElement && pElement->m_pStream, "In case element can not be created an exception must be thrown!" );
    5699                 :            : 
    5700         [ #  # ]:          0 :         pElement->m_pStream->InsertStreamDirectly( xInStream, aProps );
    5701                 :            :     }
    5702                 :          0 :     catch( const embed::InvalidStorageException& rInvalidStorageException )
    5703                 :            :     {
    5704         [ #  # ]:          0 :         m_pImpl->AddLog( rInvalidStorageException.Message );
    5705   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    5706                 :          0 :         throw;
    5707                 :            :     }
    5708                 :          0 :     catch( const lang::IllegalArgumentException& rIllegalArgumentException )
    5709                 :            :     {
    5710         [ #  # ]:          0 :         m_pImpl->AddLog( rIllegalArgumentException.Message );
    5711   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    5712                 :          0 :         throw;
    5713                 :            :     }
    5714                 :          0 :     catch( const container::ElementExistException& rElementExistException )
    5715                 :            :     {
    5716         [ #  # ]:          0 :         m_pImpl->AddLog( rElementExistException.Message );
    5717   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    5718                 :          0 :         throw;
    5719                 :            :     }
    5720                 :          0 :     catch( const embed::StorageWrappedTargetException& rStorageWrappedTargetException )
    5721                 :            :     {
    5722         [ #  # ]:          0 :         m_pImpl->AddLog( rStorageWrappedTargetException.Message );
    5723   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    5724                 :          0 :         throw;
    5725                 :            :     }
    5726                 :          0 :     catch( const io::IOException& rIOException )
    5727                 :            :     {
    5728         [ #  # ]:          0 :         m_pImpl->AddLog( rIOException.Message );
    5729   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    5730                 :          0 :         throw;
    5731                 :            :     }
    5732                 :          0 :     catch( const uno::RuntimeException& rRuntimeException )
    5733                 :            :     {
    5734         [ #  # ]:          0 :         m_pImpl->AddLog( rRuntimeException.Message );
    5735   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    5736                 :          0 :         throw;
    5737                 :            :     }
    5738   [ #  #  #  #  :          0 :     catch( const uno::Exception& rException )
             #  #  #  # ]
    5739                 :            :     {
    5740         [ #  # ]:          0 :           m_pImpl->AddLog( rException.Message );
    5741   [ #  #  #  # ]:          0 :           m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    5742                 :            : 
    5743         [ #  # ]:          0 :           uno::Any aCaught( ::cppu::getCaughtException() );
    5744                 :            :         throw embed::StorageWrappedTargetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Can't insert stream directly!" ) ),
    5745                 :            :                                                  uno::Reference< io::XInputStream >(),
    5746   [ #  #  #  # ]:          0 :                                                  aCaught );
    5747         [ #  # ]:          0 :     }
    5748                 :          0 : }
    5749                 :            : 
    5750                 :            : //-----------------------------------------------
    5751                 :          0 : void SAL_CALL OStorage::copyElementDirectlyTo(
    5752                 :            :             const ::rtl::OUString& aElementName,
    5753                 :            :             const uno::Reference< embed::XOptimizedStorage >& xDest,
    5754                 :            :             const ::rtl::OUString& aNewName )
    5755                 :            :         throw ( embed::InvalidStorageException,
    5756                 :            :                 lang::IllegalArgumentException,
    5757                 :            :                 container::NoSuchElementException,
    5758                 :            :                 container::ElementExistException,
    5759                 :            :                 io::IOException,
    5760                 :            :                 embed::StorageWrappedTargetException,
    5761                 :            :                 uno::RuntimeException )
    5762                 :            : {
    5763                 :            :     RTL_LOGFILE_CONTEXT( aLog, "package (mv76033) OStorage::copyElementDirectlyTo" );
    5764                 :            : 
    5765         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    5766                 :            : 
    5767         [ #  # ]:          0 :     if ( !m_pImpl )
    5768                 :            :     {
    5769 [ #  # ][ #  # ]:          0 :         ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    5770 [ #  # ][ #  # ]:          0 :         throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    5771                 :            :     }
    5772                 :            : 
    5773 [ #  # ][ #  # ]:          0 :     if ( aElementName.isEmpty() || !::comphelper::OStorageHelper::IsValidZipEntryFileName( aElementName, sal_False )
           [ #  #  #  # ]
         [ #  # ][ #  # ]
    5774         [ #  # ]:          0 :       || aNewName.isEmpty() || !::comphelper::OStorageHelper::IsValidZipEntryFileName( aNewName, sal_False ) )
    5775 [ #  # ][ #  # ]:          0 :         throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Unexpected entry name syntax." ) ), uno::Reference< uno::XInterface >(), 1 );
    5776                 :            : 
    5777 [ #  # ][ #  # ]:          0 :     if ( !xDest.is() || xDest == uno::Reference< uno::XInterface >( static_cast< OWeakObject* >( this ), uno::UNO_QUERY ) )
         [ #  # ][ #  # ]
                 [ #  # ]
           [ #  #  #  # ]
    5778 [ #  # ][ #  # ]:          0 :         throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 2 );
    5779                 :            : 
    5780 [ #  # ][ #  # ]:          0 :     if ( m_pData->m_nStorageType == embed::StorageFormats::OFOPXML && ( aElementName == "_rels" || aNewName == "_rels" ) )
         [ #  # ][ #  # ]
    5781 [ #  # ][ #  # ]:          0 :         throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 0 ); // unacceptable name
    5782                 :            : 
    5783                 :            :     try
    5784                 :            :     {
    5785         [ #  # ]:          0 :         SotElement_Impl* pElement = m_pImpl->FindElement( aElementName );
    5786         [ #  # ]:          0 :         if ( !pElement )
    5787 [ #  # ][ #  # ]:          0 :             throw container::NoSuchElementException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    5788                 :            : 
    5789         [ #  # ]:          0 :         uno::Reference< XNameAccess > xNameAccess( xDest, uno::UNO_QUERY );
    5790         [ #  # ]:          0 :         if ( !xNameAccess.is() )
    5791 [ #  # ][ #  # ]:          0 :             throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    5792                 :            : 
    5793 [ #  # ][ #  # ]:          0 :         if ( xNameAccess->hasByName( aNewName ) )
                 [ #  # ]
    5794 [ #  # ][ #  # ]:          0 :             throw container::ElementExistException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    5795                 :            : 
    5796                 :            :         // let the element be copied directly
    5797         [ #  # ]:          0 :         uno::Reference< embed::XStorage > xStorDest( xDest, uno::UNO_QUERY_THROW );
    5798         [ #  # ]:          0 :         m_pImpl->CopyStorageElement( pElement, xStorDest, aNewName, sal_True );
    5799                 :            :     }
    5800                 :          0 :     catch( const embed::InvalidStorageException& rInvalidStorageException )
    5801                 :            :     {
    5802         [ #  # ]:          0 :         m_pImpl->AddLog( rInvalidStorageException.Message );
    5803   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    5804                 :          0 :         throw;
    5805                 :            :     }
    5806                 :          0 :     catch( const lang::IllegalArgumentException& rIllegalArgumentException )
    5807                 :            :     {
    5808         [ #  # ]:          0 :         m_pImpl->AddLog( rIllegalArgumentException.Message );
    5809   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    5810                 :          0 :         throw;
    5811                 :            :     }
    5812                 :          0 :     catch( const container::NoSuchElementException& rNoSuchElementException )
    5813                 :            :     {
    5814         [ #  # ]:          0 :         m_pImpl->AddLog( rNoSuchElementException.Message );
    5815   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    5816                 :          0 :         throw;
    5817                 :            :     }
    5818                 :          0 :     catch( const container::ElementExistException& rElementExistException )
    5819                 :            :     {
    5820         [ #  # ]:          0 :         m_pImpl->AddLog( rElementExistException.Message );
    5821   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    5822                 :          0 :         throw;
    5823                 :            :     }
    5824                 :          0 :     catch( const embed::StorageWrappedTargetException& rStorageWrappedTargetException )
    5825                 :            :     {
    5826         [ #  # ]:          0 :         m_pImpl->AddLog( rStorageWrappedTargetException.Message );
    5827   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    5828                 :          0 :         throw;
    5829                 :            :     }
    5830                 :          0 :     catch( const io::IOException& rIOException )
    5831                 :            :     {
    5832         [ #  # ]:          0 :         m_pImpl->AddLog( rIOException.Message );
    5833   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    5834                 :          0 :         throw;
    5835                 :            :     }
    5836                 :          0 :     catch( const uno::RuntimeException& rRuntimeException )
    5837                 :            :     {
    5838         [ #  # ]:          0 :         m_pImpl->AddLog( rRuntimeException.Message );
    5839   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    5840                 :          0 :         throw;
    5841                 :            :     }
    5842   [ #  #  #  #  :          0 :     catch( const uno::Exception& rException )
             #  #  #  #  
                      # ]
    5843                 :            :     {
    5844         [ #  # ]:          0 :           m_pImpl->AddLog( rException.Message );
    5845   [ #  #  #  # ]:          0 :           m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    5846                 :            : 
    5847         [ #  # ]:          0 :           uno::Any aCaught( ::cppu::getCaughtException() );
    5848                 :            :         throw embed::StorageWrappedTargetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Can't copy element direcly!" ) ),
    5849                 :            :                                                  uno::Reference< io::XInputStream >(),
    5850   [ #  #  #  # ]:          0 :                                                  aCaught );
    5851         [ #  # ]:          0 :     }
    5852                 :          0 : }
    5853                 :            : 
    5854                 :            : //-----------------------------------------------
    5855                 :          0 : void SAL_CALL OStorage::writeAndAttachToStream( const uno::Reference< io::XStream >& xStream )
    5856                 :            :         throw ( embed::InvalidStorageException,
    5857                 :            :                 lang::IllegalArgumentException,
    5858                 :            :                 io::IOException,
    5859                 :            :                 embed::StorageWrappedTargetException,
    5860                 :            :                 uno::RuntimeException )
    5861                 :            : {
    5862                 :            :     RTL_LOGFILE_CONTEXT( aLog, "package (mv76033) OStorage::writeAndAttachToStream" );
    5863                 :            : 
    5864         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    5865                 :            : 
    5866         [ #  # ]:          0 :     if ( !m_pImpl )
    5867                 :            :     {
    5868 [ #  # ][ #  # ]:          0 :         ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    5869 [ #  # ][ #  # ]:          0 :         throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    5870                 :            :     }
    5871                 :            : 
    5872         [ #  # ]:          0 :     if ( !m_pData->m_bIsRoot )
    5873 [ #  # ][ #  # ]:          0 :         throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 0 );
    5874                 :            : 
    5875         [ #  # ]:          0 :     if ( !m_pImpl->m_pSwitchStream )
    5876 [ #  # ][ #  # ]:          0 :         throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    5877                 :            : 
    5878                 :            :     try
    5879                 :            :     {
    5880         [ #  # ]:          0 :         m_pImpl->m_pSwitchStream->CopyAndSwitchPersistenceTo( xStream );
    5881                 :            :     }
    5882                 :          0 :     catch( const embed::InvalidStorageException& rInvalidStorageException )
    5883                 :            :     {
    5884         [ #  # ]:          0 :         m_pImpl->AddLog( rInvalidStorageException.Message );
    5885   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    5886                 :          0 :         throw;
    5887                 :            :     }
    5888                 :          0 :     catch( const lang::IllegalArgumentException& rIllegalArgumentException )
    5889                 :            :     {
    5890         [ #  # ]:          0 :         m_pImpl->AddLog( rIllegalArgumentException.Message );
    5891   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    5892                 :          0 :         throw;
    5893                 :            :     }
    5894                 :          0 :     catch( const embed::StorageWrappedTargetException& rStorageWrappedTargetException )
    5895                 :            :     {
    5896         [ #  # ]:          0 :         m_pImpl->AddLog( rStorageWrappedTargetException.Message );
    5897   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    5898                 :          0 :         throw;
    5899                 :            :     }
    5900                 :          0 :     catch( const io::IOException& rIOException )
    5901                 :            :     {
    5902         [ #  # ]:          0 :         m_pImpl->AddLog( rIOException.Message );
    5903   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    5904                 :          0 :         throw;
    5905                 :            :     }
    5906                 :          0 :     catch( const uno::RuntimeException& rRuntimeException )
    5907                 :            :     {
    5908         [ #  # ]:          0 :         m_pImpl->AddLog( rRuntimeException.Message );
    5909   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    5910                 :          0 :         throw;
    5911                 :            :     }
    5912   [ #  #  #  #  :          0 :     catch( const uno::Exception& rException )
                #  #  # ]
    5913                 :            :     {
    5914         [ #  # ]:          0 :           m_pImpl->AddLog( rException.Message );
    5915   [ #  #  #  # ]:          0 :           m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    5916                 :            : 
    5917         [ #  # ]:          0 :           uno::Any aCaught( ::cppu::getCaughtException() );
    5918                 :            :         throw embed::StorageWrappedTargetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Can't write and attach to stream!" ) ),
    5919                 :            :                                                  uno::Reference< io::XInputStream >(),
    5920   [ #  #  #  # ]:          0 :                                                  aCaught );
    5921         [ #  # ]:          0 :     }
    5922                 :            : 
    5923                 :          0 : }
    5924                 :            : 
    5925                 :            : //-----------------------------------------------
    5926                 :          0 : void SAL_CALL OStorage::attachToURL( const ::rtl::OUString& sURL,
    5927                 :            :                                     sal_Bool bReadOnly )
    5928                 :            :         throw ( embed::InvalidStorageException,
    5929                 :            :                 lang::IllegalArgumentException,
    5930                 :            :                 io::IOException,
    5931                 :            :                 embed::StorageWrappedTargetException,
    5932                 :            :                 uno::RuntimeException )
    5933                 :            : {
    5934                 :            :     RTL_LOGFILE_CONTEXT( aLog, "package (mv76033) OStorage::attachToURL" );
    5935                 :            : 
    5936         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    5937                 :            : 
    5938         [ #  # ]:          0 :     if ( !m_pImpl )
    5939                 :            :     {
    5940 [ #  # ][ #  # ]:          0 :         ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    5941 [ #  # ][ #  # ]:          0 :         throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    5942                 :            :     }
    5943                 :            : 
    5944         [ #  # ]:          0 :     if ( !m_pData->m_bIsRoot )
    5945 [ #  # ][ #  # ]:          0 :         throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 0 );
    5946                 :            : 
    5947         [ #  # ]:          0 :     if ( !m_pImpl->m_pSwitchStream )
    5948 [ #  # ][ #  # ]:          0 :         throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    5949                 :            : 
    5950                 :            :     uno::Reference < ucb::XSimpleFileAccess2 > xAccess(
    5951                 :            :         ucb::SimpleFileAccess::create(
    5952 [ #  # ][ #  # ]:          0 :             comphelper::ComponentContext(m_pImpl->m_xFactory).getUNOContext() ) );
         [ #  # ][ #  # ]
    5953                 :            : 
    5954                 :            :     try
    5955                 :            :     {
    5956         [ #  # ]:          0 :         if ( bReadOnly )
    5957                 :            :         {
    5958 [ #  # ][ #  # ]:          0 :             uno::Reference< io::XInputStream > xInputStream = xAccess->openFileRead( sURL );
    5959         [ #  # ]:          0 :             m_pImpl->m_pSwitchStream->SwitchPersistenceTo( xInputStream );
    5960                 :            :         }
    5961                 :            :         else
    5962                 :            :         {
    5963 [ #  # ][ #  # ]:          0 :             uno::Reference< io::XStream > xStream = xAccess->openFileReadWrite( sURL );
    5964         [ #  # ]:          0 :             m_pImpl->m_pSwitchStream->SwitchPersistenceTo( xStream );
    5965                 :            :         }
    5966                 :            :     }
    5967                 :          0 :     catch( const embed::InvalidStorageException& rInvalidStorageException )
    5968                 :            :     {
    5969         [ #  # ]:          0 :         m_pImpl->AddLog( rInvalidStorageException.Message );
    5970   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    5971                 :          0 :         throw;
    5972                 :            :     }
    5973                 :          0 :     catch( const lang::IllegalArgumentException& rIllegalArgumentException )
    5974                 :            :     {
    5975         [ #  # ]:          0 :         m_pImpl->AddLog( rIllegalArgumentException.Message );
    5976   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    5977                 :          0 :         throw;
    5978                 :            :     }
    5979                 :          0 :     catch( const embed::StorageWrappedTargetException& rStorageWrappedTargetException )
    5980                 :            :     {
    5981         [ #  # ]:          0 :         m_pImpl->AddLog( rStorageWrappedTargetException.Message );
    5982   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    5983                 :          0 :         throw;
    5984                 :            :     }
    5985                 :          0 :     catch( const io::IOException& rIOException )
    5986                 :            :     {
    5987         [ #  # ]:          0 :         m_pImpl->AddLog( rIOException.Message );
    5988   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    5989                 :          0 :         throw;
    5990                 :            :     }
    5991                 :          0 :     catch( const uno::RuntimeException& rRuntimeException )
    5992                 :            :     {
    5993         [ #  # ]:          0 :         m_pImpl->AddLog( rRuntimeException.Message );
    5994   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    5995                 :          0 :         throw;
    5996                 :            :     }
    5997   [ #  #  #  #  :          0 :     catch( const uno::Exception& rException )
                #  #  # ]
    5998                 :            :     {
    5999         [ #  # ]:          0 :           m_pImpl->AddLog( rException.Message );
    6000   [ #  #  #  # ]:          0 :           m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    6001                 :            : 
    6002         [ #  # ]:          0 :           uno::Any aCaught( ::cppu::getCaughtException() );
    6003                 :            :         throw embed::StorageWrappedTargetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Can't attach to URL!" ) ),
    6004                 :            :                                                  uno::Reference< io::XInputStream >(),
    6005   [ #  #  #  # ]:          0 :                                                  aCaught );
    6006         [ #  # ]:          0 :     }
    6007                 :          0 : }
    6008                 :            : 
    6009                 :            : //-----------------------------------------------
    6010                 :       3456 : uno::Any SAL_CALL OStorage::getElementPropertyValue( const ::rtl::OUString& aElementName, const ::rtl::OUString& aPropertyName )
    6011                 :            :         throw ( embed::InvalidStorageException,
    6012                 :            :                 lang::IllegalArgumentException,
    6013                 :            :                 container::NoSuchElementException,
    6014                 :            :                 io::IOException,
    6015                 :            :                 beans::UnknownPropertyException,
    6016                 :            :                 beans::PropertyVetoException,
    6017                 :            :                 embed::StorageWrappedTargetException,
    6018                 :            :                 uno::RuntimeException)
    6019                 :            : {
    6020                 :            :     RTL_LOGFILE_CONTEXT( aLog, "package (mv76033) OStorage::getElementPropertyValue" );
    6021                 :            : 
    6022         [ +  - ]:       3456 :     ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    6023                 :            : 
    6024         [ -  + ]:       3456 :     if ( !m_pImpl )
    6025                 :            :     {
    6026 [ #  # ][ #  # ]:          0 :         ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    6027 [ #  # ][ #  # ]:          0 :         throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    6028                 :            :     }
    6029                 :            : 
    6030 [ +  - ][ +  - ]:       3456 :     if ( aElementName.isEmpty() || !::comphelper::OStorageHelper::IsValidZipEntryFileName( aElementName, sal_False ) )
         [ -  + ][ -  + ]
    6031 [ #  # ][ #  # ]:          0 :         throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Unexpected entry name syntax." ) ), uno::Reference< uno::XInterface >(), 1 );
    6032                 :            : 
    6033 [ -  + ][ #  # ]:       3456 :     if ( m_pData->m_nStorageType == embed::StorageFormats::OFOPXML && aElementName == "_rels" )
                 [ -  + ]
    6034 [ #  # ][ #  # ]:          0 :         throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 1 ); // TODO: unacceptable name
    6035                 :            : 
    6036                 :            :     try
    6037                 :            :     {
    6038         [ +  - ]:       3456 :         SotElement_Impl *pElement = m_pImpl->FindElement( aElementName );
    6039         [ -  + ]:       3456 :         if ( !pElement )
    6040 [ #  # ][ #  # ]:          0 :             throw container::NoSuchElementException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    6041                 :            : 
    6042                 :            :         // TODO/LATER: Currently it is only implemented for MediaType property of substorages, might be changed in future
    6043 [ +  - ][ +  - ]:       3456 :         if ( !pElement->m_bIsStorage || m_pData->m_nStorageType != embed::StorageFormats::PACKAGE || aPropertyName != "MediaType" )
         [ -  + ][ -  + ]
    6044 [ #  # ][ #  # ]:          0 :             throw beans::PropertyVetoException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    6045                 :            : 
    6046         [ +  + ]:       3456 :         if ( !pElement->m_pStorage )
    6047         [ +  - ]:         17 :             m_pImpl->OpenSubStorage( pElement, embed::ElementModes::READ );
    6048                 :            : 
    6049         [ -  + ]:       3456 :         if ( !pElement->m_pStorage )
    6050 [ #  # ][ #  # ]:          0 :             throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); // TODO: general_error
    6051                 :            : 
    6052         [ +  - ]:       3456 :         pElement->m_pStorage->ReadContents();
    6053         [ +  - ]:       6912 :         return uno::makeAny( pElement->m_pStorage->m_aMediaType );
    6054                 :            :     }
    6055                 :          0 :     catch( const embed::InvalidStorageException& rInvalidStorageException )
    6056                 :            :     {
    6057         [ #  # ]:          0 :         m_pImpl->AddLog( rInvalidStorageException.Message );
    6058   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    6059                 :          0 :         throw;
    6060                 :            :     }
    6061                 :          0 :     catch( const lang::IllegalArgumentException& rIllegalArgumentException )
    6062                 :            :     {
    6063         [ #  # ]:          0 :         m_pImpl->AddLog( rIllegalArgumentException.Message );
    6064   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    6065                 :          0 :         throw;
    6066                 :            :     }
    6067                 :          0 :     catch( const container::NoSuchElementException& rNoSuchElementException )
    6068                 :            :     {
    6069         [ #  # ]:          0 :         m_pImpl->AddLog( rNoSuchElementException.Message );
    6070   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    6071                 :          0 :         throw;
    6072                 :            :     }
    6073                 :          0 :     catch( const beans::UnknownPropertyException& rUnknownPropertyException )
    6074                 :            :     {
    6075         [ #  # ]:          0 :         m_pImpl->AddLog( rUnknownPropertyException.Message );
    6076   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    6077                 :          0 :         throw;
    6078                 :            :     }
    6079                 :          0 :     catch( const beans::PropertyVetoException& rPropertyVetoException )
    6080                 :            :     {
    6081         [ #  # ]:          0 :         m_pImpl->AddLog( rPropertyVetoException.Message );
    6082   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    6083                 :          0 :         throw;
    6084                 :            :     }
    6085                 :          0 :     catch( const embed::StorageWrappedTargetException& rStorageWrappedTargetException )
    6086                 :            :     {
    6087         [ #  # ]:          0 :         m_pImpl->AddLog( rStorageWrappedTargetException.Message );
    6088   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    6089                 :          0 :         throw;
    6090                 :            :     }
    6091                 :          0 :     catch( const io::IOException& rIOException )
    6092                 :            :     {
    6093         [ #  # ]:          0 :         m_pImpl->AddLog( rIOException.Message );
    6094   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    6095                 :          0 :         throw;
    6096                 :            :     }
    6097                 :          0 :     catch( const uno::RuntimeException& rRuntimeException )
    6098                 :            :     {
    6099         [ #  # ]:          0 :         m_pImpl->AddLog( rRuntimeException.Message );
    6100   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    6101                 :          0 :         throw;
    6102                 :            :     }
    6103   [ #  #  #  #  :          0 :     catch( const uno::Exception& rException )
          #  #  #  #  #  
                      # ]
    6104                 :            :     {
    6105         [ #  # ]:          0 :           m_pImpl->AddLog( rException.Message );
    6106   [ #  #  #  # ]:          0 :           m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    6107                 :            : 
    6108         [ #  # ]:          0 :           uno::Any aCaught( ::cppu::getCaughtException() );
    6109                 :            :         throw embed::StorageWrappedTargetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Can't get element property!" ) ),
    6110                 :            :                                                  uno::Reference< io::XInputStream >(),
    6111   [ #  #  #  # ]:          0 :                                                  aCaught );
    6112         [ +  - ]:       3456 :     }
    6113                 :            : }
    6114                 :            : 
    6115                 :            : //-----------------------------------------------
    6116                 :          0 : void SAL_CALL OStorage::copyStreamElementData( const ::rtl::OUString& aStreamName, const uno::Reference< io::XStream >& xTargetStream )
    6117                 :            :         throw ( embed::InvalidStorageException,
    6118                 :            :                 lang::IllegalArgumentException,
    6119                 :            :                 packages::WrongPasswordException,
    6120                 :            :                 io::IOException,
    6121                 :            :                 embed::StorageWrappedTargetException,
    6122                 :            :                 uno::RuntimeException )
    6123                 :            : {
    6124         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    6125                 :            : 
    6126         [ #  # ]:          0 :     if ( !m_pImpl )
    6127                 :            :     {
    6128 [ #  # ][ #  # ]:          0 :         ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    6129 [ #  # ][ #  # ]:          0 :         throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    6130                 :            :     }
    6131                 :            : 
    6132 [ #  # ][ #  # ]:          0 :     if ( aStreamName.isEmpty() || !::comphelper::OStorageHelper::IsValidZipEntryFileName( aStreamName, sal_False ) )
         [ #  # ][ #  # ]
    6133 [ #  # ][ #  # ]:          0 :         throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Unexpected entry name syntax." ) ), uno::Reference< uno::XInterface >(), 1 );
    6134                 :            : 
    6135 [ #  # ][ #  # ]:          0 :     if ( m_pData->m_nStorageType == embed::StorageFormats::OFOPXML && aStreamName == "_rels" )
                 [ #  # ]
    6136 [ #  # ][ #  # ]:          0 :         throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 1 ); // unacceptable name
    6137                 :            : 
    6138         [ #  # ]:          0 :     if ( !xTargetStream.is() )
    6139 [ #  # ][ #  # ]:          0 :         throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 2 );
    6140                 :            : 
    6141                 :            :     try
    6142                 :            :     {
    6143                 :          0 :         uno::Reference< io::XStream > xNonconstRef = xTargetStream;
    6144 [ #  # ][ #  # ]:          0 :         m_pImpl->CloneStreamElement( aStreamName, sal_False, ::comphelper::SequenceAsHashMap(), xNonconstRef );
                 [ #  # ]
    6145                 :            : 
    6146                 :            :         OSL_ENSURE( xNonconstRef == xTargetStream, "The provided stream reference seems not be filled in correctly!\n" );
    6147 [ #  # ][ #  # ]:          0 :         if ( xNonconstRef != xTargetStream )
    6148 [ #  # ][ #  # ]:          0 :             throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); // if the stream reference is set it must not be changed!
    6149                 :            :     }
    6150                 :          0 :     catch( const embed::InvalidStorageException& rInvalidStorageException )
    6151                 :            :     {
    6152         [ #  # ]:          0 :         m_pImpl->AddLog( rInvalidStorageException.Message );
    6153   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    6154                 :          0 :         throw;
    6155                 :            :     }
    6156                 :          0 :     catch( const lang::IllegalArgumentException& rIllegalArgumentException )
    6157                 :            :     {
    6158         [ #  # ]:          0 :         m_pImpl->AddLog( rIllegalArgumentException.Message );
    6159   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    6160                 :          0 :         throw;
    6161                 :            :     }
    6162                 :          0 :     catch( const packages::WrongPasswordException& rWrongPasswordException )
    6163                 :            :     {
    6164         [ #  # ]:          0 :         m_pImpl->AddLog( rWrongPasswordException.Message );
    6165   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    6166                 :          0 :         throw;
    6167                 :            :     }
    6168                 :          0 :     catch( const io::IOException& rIOException )
    6169                 :            :     {
    6170         [ #  # ]:          0 :         m_pImpl->AddLog( rIOException.Message );
    6171   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    6172                 :          0 :         throw;
    6173                 :            :     }
    6174                 :          0 :     catch( const embed::StorageWrappedTargetException& rStorageWrappedTargetException )
    6175                 :            :     {
    6176         [ #  # ]:          0 :         m_pImpl->AddLog( rStorageWrappedTargetException.Message );
    6177   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    6178                 :          0 :         throw;
    6179                 :            :     }
    6180                 :          0 :     catch( const uno::RuntimeException& rRuntimeException )
    6181                 :            :     {
    6182         [ #  # ]:          0 :         m_pImpl->AddLog( rRuntimeException.Message );
    6183   [ #  #  #  # ]:          0 :         m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    6184                 :          0 :         throw;
    6185                 :            :     }
    6186   [ #  #  #  #  :          0 :     catch( const uno::Exception& rException )
             #  #  #  # ]
    6187                 :            :     {
    6188         [ #  # ]:          0 :           m_pImpl->AddLog( rException.Message );
    6189   [ #  #  #  # ]:          0 :           m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
    6190                 :            : 
    6191         [ #  # ]:          0 :           uno::Any aCaught( ::cppu::getCaughtException() );
    6192                 :            :         throw embed::StorageWrappedTargetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Can't copy stream data!" ) ),
    6193                 :            :                                                  uno::Reference< io::XInputStream >(),
    6194   [ #  #  #  # ]:          0 :                                                  aCaught );
    6195         [ #  # ]:          0 :     }
    6196                 :            : 
    6197                 :            : 
    6198                 :          0 : }
    6199                 :            : 
    6200                 :            : //____________________________________________________________________________________________________
    6201                 :            : // XHierarchicalStorageAccess
    6202                 :            : //____________________________________________________________________________________________________
    6203                 :            : 
    6204                 :            : //-----------------------------------------------
    6205                 :       2578 : uno::Reference< embed::XExtendedStorageStream > SAL_CALL OStorage::openStreamElementByHierarchicalName( const ::rtl::OUString& aStreamPath, ::sal_Int32 nOpenMode )
    6206                 :            :         throw ( embed::InvalidStorageException,
    6207                 :            :                 lang::IllegalArgumentException,
    6208                 :            :                 packages::WrongPasswordException,
    6209                 :            :                 io::IOException,
    6210                 :            :                 embed::StorageWrappedTargetException,
    6211                 :            :                 uno::RuntimeException )
    6212                 :            : {
    6213         [ +  - ]:       2578 :     ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    6214                 :            : 
    6215         [ -  + ]:       2578 :     if ( !m_pImpl )
    6216                 :            :     {
    6217 [ #  # ][ #  # ]:          0 :         ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    6218 [ #  # ][ #  # ]:          0 :         throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    6219                 :            :     }
    6220                 :            : 
    6221 [ +  - ][ +  - ]:       2578 :     if ( aStreamPath.isEmpty() || !::comphelper::OStorageHelper::IsValidZipEntryFileName( aStreamPath, sal_True ) )
         [ -  + ][ -  + ]
    6222 [ #  # ][ #  # ]:          0 :         throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Unexpected entry name syntax." ) ), uno::Reference< uno::XInterface >(), 1 );
    6223                 :            : 
    6224 [ +  - ][ -  + ]:       2578 :     if ( !( m_pImpl->m_nStorageMode & embed::ElementModes::WRITE )
    6225                 :            :       && ( nOpenMode & embed::ElementModes::WRITE ) )
    6226 [ #  # ][ #  # ]:          0 :         throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); // Access denied
    6227                 :            : 
    6228         [ +  - ]:       2578 :     OStringList_Impl aListPath = OHierarchyHolder_Impl::GetListPathFromString( aStreamPath );
    6229                 :            :     OSL_ENSURE( aListPath.size(), "The result list must not be empty!" );
    6230                 :            : 
    6231                 :       2578 :     uno::Reference< embed::XExtendedStorageStream > xResult;
    6232         [ +  + ]:       2578 :     if ( aListPath.size() == 1 )
    6233                 :            :     {
    6234                 :            :         // that must be a direct request for a stream
    6235                 :            :         // the transacted version of the stream should be opened
    6236                 :            : 
    6237         [ +  - ]:       1289 :         SotElement_Impl *pElement = OpenStreamElement_Impl( aStreamPath, nOpenMode, sal_False );
    6238                 :            :         OSL_ENSURE( pElement && pElement->m_pStream, "In case element can not be created an exception must be thrown!" );
    6239                 :            : 
    6240                 :            :         xResult = uno::Reference< embed::XExtendedStorageStream >(
    6241                 :            :                         pElement->m_pStream->GetStream( nOpenMode, sal_True ),
    6242 [ +  - ][ +  - ]:       1289 :                         uno::UNO_QUERY_THROW );
                 [ +  - ]
    6243                 :            :     }
    6244                 :            :     else
    6245                 :            :     {
    6246                 :            :         // there are still storages in between
    6247         [ +  + ]:       1289 :         if ( !m_pData->m_rHierarchyHolder.is() )
    6248                 :            :             m_pData->m_rHierarchyHolder = new OHierarchyHolder_Impl(
    6249 [ +  - ][ +  - ]:        406 :                 uno::Reference< embed::XStorage >( static_cast< embed::XStorage* >( this ) ) );
                 [ +  - ]
    6250                 :            : 
    6251                 :            :         xResult = m_pData->m_rHierarchyHolder->GetStreamHierarchically(
    6252                 :            :                                                 ( m_pImpl->m_nStorageMode & embed::ElementModes::READWRITE ),
    6253                 :            :                                                 aListPath,
    6254 [ +  - ][ +  - ]:       1289 :                                                 nOpenMode );
         [ +  - ][ +  - ]
    6255                 :            :     }
    6256                 :            : 
    6257         [ -  + ]:       2578 :     if ( !xResult.is() )
    6258 [ #  # ][ #  # ]:          0 :         throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    6259                 :            : 
    6260         [ +  - ]:       2578 :     return xResult;
    6261                 :            : }
    6262                 :            : 
    6263                 :            : //-----------------------------------------------
    6264                 :          0 : uno::Reference< embed::XExtendedStorageStream > SAL_CALL OStorage::openEncryptedStreamElementByHierarchicalName( const ::rtl::OUString& aStreamPath, ::sal_Int32 nOpenMode, const ::rtl::OUString& sPassword )
    6265                 :            :         throw ( embed::InvalidStorageException,
    6266                 :            :                 lang::IllegalArgumentException,
    6267                 :            :                 packages::NoEncryptionException,
    6268                 :            :                 packages::WrongPasswordException,
    6269                 :            :                 io::IOException,
    6270                 :            :                 embed::StorageWrappedTargetException,
    6271                 :            :                 uno::RuntimeException )
    6272                 :            : {
    6273 [ #  # ][ #  # ]:          0 :     return openEncryptedStreamByHierarchicalName( aStreamPath, nOpenMode, ::comphelper::OStorageHelper::CreatePackageEncryptionData( sPassword ) );
                 [ #  # ]
    6274                 :            : }
    6275                 :            : 
    6276                 :            : //-----------------------------------------------
    6277                 :          0 : void SAL_CALL OStorage::removeStreamElementByHierarchicalName( const ::rtl::OUString& aStreamPath )
    6278                 :            :         throw ( embed::InvalidStorageException,
    6279                 :            :                 lang::IllegalArgumentException,
    6280                 :            :                 container::NoSuchElementException,
    6281                 :            :                 io::IOException,
    6282                 :            :                 embed::StorageWrappedTargetException,
    6283                 :            :                 uno::RuntimeException )
    6284                 :            : {
    6285         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    6286                 :            : 
    6287         [ #  # ]:          0 :     if ( !m_pImpl )
    6288                 :            :     {
    6289 [ #  # ][ #  # ]:          0 :         ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    6290 [ #  # ][ #  # ]:          0 :         throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    6291                 :            :     }
    6292                 :            : 
    6293 [ #  # ][ #  # ]:          0 :     if ( aStreamPath.isEmpty() || !::comphelper::OStorageHelper::IsValidZipEntryFileName( aStreamPath, sal_True ) )
         [ #  # ][ #  # ]
    6294 [ #  # ][ #  # ]:          0 :         throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Unexpected entry name syntax." ) ), uno::Reference< uno::XInterface >(), 1 );
    6295                 :            : 
    6296         [ #  # ]:          0 :     if ( !( m_pImpl->m_nStorageMode & embed::ElementModes::WRITE ) )
    6297 [ #  # ][ #  # ]:          0 :         throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); // Access denied
    6298                 :            : 
    6299         [ #  # ]:          0 :     OStringList_Impl aListPath = OHierarchyHolder_Impl::GetListPathFromString( aStreamPath );
    6300                 :            :     OSL_ENSURE( aListPath.size(), "The result list must not be empty!" );
    6301                 :            : 
    6302         [ #  # ]:          0 :     if ( !m_pData->m_rHierarchyHolder.is() )
    6303                 :            :         m_pData->m_rHierarchyHolder = new OHierarchyHolder_Impl(
    6304 [ #  # ][ #  # ]:          0 :             uno::Reference< embed::XStorage >( static_cast< embed::XStorage* >( this ) ) );
                 [ #  # ]
    6305                 :            : 
    6306 [ #  # ][ #  # ]:          0 :     m_pData->m_rHierarchyHolder->RemoveStreamHierarchically( aListPath );
    6307                 :          0 : }
    6308                 :            : 
    6309                 :            : //____________________________________________________________________________________________________
    6310                 :            : // XHierarchicalStorageAccess2
    6311                 :            : //____________________________________________________________________________________________________
    6312                 :            : 
    6313                 :          0 : uno::Reference< embed::XExtendedStorageStream > SAL_CALL OStorage::openEncryptedStreamByHierarchicalName( const ::rtl::OUString& aStreamPath, ::sal_Int32 nOpenMode, const uno::Sequence< beans::NamedValue >& aEncryptionData )
    6314                 :            :         throw ( embed::InvalidStorageException,
    6315                 :            :                 lang::IllegalArgumentException,
    6316                 :            :                 packages::NoEncryptionException,
    6317                 :            :                 packages::WrongPasswordException,
    6318                 :            :                 io::IOException,
    6319                 :            :                 embed::StorageWrappedTargetException,
    6320                 :            :                 uno::RuntimeException )
    6321                 :            : {
    6322         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
    6323                 :            : 
    6324         [ #  # ]:          0 :     if ( !m_pImpl )
    6325                 :            :     {
    6326 [ #  # ][ #  # ]:          0 :         ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
    6327 [ #  # ][ #  # ]:          0 :         throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    6328                 :            :     }
    6329                 :            : 
    6330         [ #  # ]:          0 :     if ( m_pData->m_nStorageType != embed::StorageFormats::PACKAGE )
    6331 [ #  # ][ #  # ]:          0 :         throw packages::NoEncryptionException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    6332                 :            : 
    6333 [ #  # ][ #  # ]:          0 :     if ( aStreamPath.isEmpty() || !::comphelper::OStorageHelper::IsValidZipEntryFileName( aStreamPath, sal_True ) )
         [ #  # ][ #  # ]
    6334 [ #  # ][ #  # ]:          0 :         throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Unexpected entry name syntax." ) ), uno::Reference< uno::XInterface >(), 1 );
    6335                 :            : 
    6336         [ #  # ]:          0 :     if ( !aEncryptionData.getLength() )
    6337 [ #  # ][ #  # ]:          0 :         throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 3 );
    6338                 :            : 
    6339 [ #  # ][ #  # ]:          0 :     if ( !( m_pImpl->m_nStorageMode & embed::ElementModes::WRITE )
    6340                 :            :       && ( nOpenMode & embed::ElementModes::WRITE ) )
    6341 [ #  # ][ #  # ]:          0 :         throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); // Access denied
    6342                 :            : 
    6343         [ #  # ]:          0 :     OStringList_Impl aListPath = OHierarchyHolder_Impl::GetListPathFromString( aStreamPath );
    6344                 :            :     OSL_ENSURE( aListPath.size(), "The result list must not be empty!" );
    6345                 :            : 
    6346                 :          0 :     uno::Reference< embed::XExtendedStorageStream > xResult;
    6347         [ #  # ]:          0 :     if ( aListPath.size() == 1 )
    6348                 :            :     {
    6349                 :            :         // that must be a direct request for a stream
    6350                 :            :         // the transacted version of the stream should be opened
    6351                 :            : 
    6352         [ #  # ]:          0 :         SotElement_Impl *pElement = OpenStreamElement_Impl( aStreamPath, nOpenMode, sal_True );
    6353                 :            :         OSL_ENSURE( pElement && pElement->m_pStream, "In case element can not be created an exception must be thrown!" );
    6354                 :            : 
    6355                 :            :         xResult = uno::Reference< embed::XExtendedStorageStream >(
    6356                 :            :                         pElement->m_pStream->GetStream( nOpenMode, aEncryptionData, sal_True ),
    6357 [ #  # ][ #  # ]:          0 :                         uno::UNO_QUERY_THROW );
         [ #  # ][ #  # ]
                 [ #  # ]
    6358                 :            :     }
    6359                 :            :     else
    6360                 :            :     {
    6361                 :            :         // there are still storages in between
    6362         [ #  # ]:          0 :         if ( !m_pData->m_rHierarchyHolder.is() )
    6363                 :            :             m_pData->m_rHierarchyHolder = new OHierarchyHolder_Impl(
    6364 [ #  # ][ #  # ]:          0 :                 uno::Reference< embed::XStorage >( static_cast< embed::XStorage* >( this ) ) );
                 [ #  # ]
    6365                 :            : 
    6366                 :            :         xResult = m_pData->m_rHierarchyHolder->GetStreamHierarchically(
    6367                 :            :                                                 ( m_pImpl->m_nStorageMode & embed::ElementModes::READWRITE ),
    6368                 :            :                                                 aListPath,
    6369                 :            :                                                 nOpenMode,
    6370 [ #  # ][ #  # ]:          0 :                                                 aEncryptionData );
         [ #  # ][ #  # ]
    6371                 :            :     }
    6372                 :            : 
    6373         [ #  # ]:          0 :     if ( !xResult.is() )
    6374 [ #  # ][ #  # ]:          0 :         throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
    6375                 :            : 
    6376         [ #  # ]:          0 :     return xResult;
    6377                 :            : }
    6378                 :            : 
    6379                 :            : 
    6380                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10