LCOV - code coverage report
Current view: top level - package/source/zippackage - zipfileaccess.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 67 209 32.1 %
Date: 2012-08-25 Functions: 10 21 47.6 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 67 390 17.2 %

           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/lang/DisposedException.hpp>
      21                 :            : #include <com/sun/star/lang/IllegalArgumentException.hpp>
      22                 :            : #include <com/sun/star/ucb/XCommandEnvironment.hpp>
      23                 :            : #include <com/sun/star/io/XActiveDataSink.hpp>
      24                 :            : #include <com/sun/star/io/XStream.hpp>
      25                 :            : #include <com/sun/star/io/XSeekable.hpp>
      26                 :            : 
      27                 :            : #include <zipfileaccess.hxx>
      28                 :            : #include <ZipEnumeration.hxx>
      29                 :            : #include <ZipPackageSink.hxx>
      30                 :            : #include <EncryptionData.hxx>
      31                 :            : 
      32                 :            : #include <ucbhelper/content.hxx>
      33                 :            : #include <rtl/ref.hxx>
      34                 :            : 
      35                 :            : #include <memory>
      36                 :            : 
      37                 :            : 
      38                 :            : using namespace ::com::sun::star;
      39                 :            : 
      40                 :            : // ----------------------------------------------------------------
      41                 :        464 : OZipFileAccess::OZipFileAccess( const uno::Reference< lang::XMultiServiceFactory >& xFactory )
      42         [ +  - ]:        464 : : m_aMutexHolder( new SotMutexHolder )
      43                 :            : , m_xFactory( xFactory )
      44                 :            : , m_pZipFile( NULL )
      45                 :            : , m_pListenersContainer( NULL )
      46         [ +  - ]:        928 : , m_bDisposed( sal_False )
      47                 :            : {
      48         [ -  + ]:        464 :     if ( !xFactory.is() )
      49         [ #  # ]:          0 :         throw uno::RuntimeException(OSL_LOG_PREFIX, uno::Reference< uno::XInterface >() );
      50                 :        464 : }
      51                 :            : 
      52                 :            : // ----------------------------------------------------------------
      53         [ +  - ]:        464 : OZipFileAccess::~OZipFileAccess()
      54                 :            : {
      55                 :            :     {
      56         [ +  - ]:        464 :         ::osl::MutexGuard aGuard( m_aMutexHolder->GetMutex() );
      57         [ +  - ]:        464 :         if ( !m_bDisposed )
      58                 :            :         {
      59                 :            :             try {
      60                 :        464 :                 m_refCount++; // dispose will use refcounting so the further distruction must be avoided
      61         [ +  - ]:        464 :                 dispose();
      62         [ #  # ]:          0 :             } catch( uno::Exception& )
      63                 :            :             {}
      64         [ +  - ]:        464 :         }
      65                 :            :     }
      66 [ -  + ][ #  # ]:        928 : }
      67                 :            : 
      68                 :            : // ----------------------------------------------------------------
      69                 :          0 : uno::Sequence< OUString > OZipFileAccess::GetPatternsFromString_Impl( const OUString& aString )
      70                 :            : {
      71         [ #  # ]:          0 :     if ( aString.isEmpty() )
      72         [ #  # ]:          0 :         return uno::Sequence< OUString >();
      73                 :            : 
      74         [ #  # ]:          0 :     uno::Sequence< OUString > aPattern( 1 );
      75                 :          0 :     sal_Int32 nInd = 0;
      76                 :            : 
      77                 :          0 :     const sal_Unicode* pString = aString.getStr();
      78         [ #  # ]:          0 :     while( *pString )
      79                 :            :     {
      80         [ #  # ]:          0 :         if ( *pString == (sal_Unicode)'\\' )
      81                 :            :         {
      82                 :          0 :             pString++;
      83                 :            : 
      84         [ #  # ]:          0 :             if ( *pString == (sal_Unicode)'\\' )
      85                 :            :             {
      86         [ #  # ]:          0 :                 aPattern[nInd] += OUString::valueOf( (sal_Unicode)'\\' );
      87                 :          0 :                 pString++;
      88                 :            :             }
      89         [ #  # ]:          0 :             else if ( *pString == (sal_Unicode)'*' )
      90                 :            :             {
      91         [ #  # ]:          0 :                 aPattern[nInd] += OUString::valueOf( (sal_Unicode)'*' );
      92                 :          0 :                 pString++;
      93                 :            :             }
      94                 :            :             else
      95                 :            :             {
      96                 :            :                 OSL_FAIL( "The backslash is not guarded!\n" );
      97         [ #  # ]:          0 :                 aPattern[nInd] += OUString::valueOf( (sal_Unicode)'\\' );
      98                 :            :             }
      99                 :            :         }
     100         [ #  # ]:          0 :         else if ( *pString == (sal_Unicode)'*' )
     101                 :            :         {
     102         [ #  # ]:          0 :             aPattern.realloc( ( ++nInd ) + 1 );
     103                 :          0 :             pString++;
     104                 :            :         }
     105                 :            :         else
     106                 :            :         {
     107         [ #  # ]:          0 :             aPattern[nInd] += OUString::valueOf( *pString );
     108                 :          0 :             pString++;
     109                 :            :         }
     110                 :            :     }
     111                 :            : 
     112 [ #  # ][ #  # ]:          0 :     return aPattern;
     113                 :            : }
     114                 :            : 
     115                 :            : // ----------------------------------------------------------------
     116                 :          0 : sal_Bool OZipFileAccess::StringGoodForPattern_Impl( const OUString& aString,
     117                 :            :                                                     const uno::Sequence< OUString >& aPattern )
     118                 :            : {
     119                 :          0 :     sal_Int32 nInd = aPattern.getLength() - 1;
     120         [ #  # ]:          0 :     if ( nInd < 0 )
     121                 :          0 :         return sal_False;
     122                 :            : 
     123         [ #  # ]:          0 :     if ( nInd == 0 )
     124                 :            :     {
     125         [ #  # ]:          0 :         if ( aPattern[0].isEmpty() )
     126                 :          0 :             return sal_True;
     127                 :            : 
     128                 :          0 :         return aString.equals( aPattern[0] );
     129                 :            :     }
     130                 :            : 
     131                 :          0 :     sal_Int32 nBeginInd = aPattern[0].getLength();
     132                 :          0 :     sal_Int32 nEndInd = aString.getLength() - aPattern[nInd].getLength();
     133   [ #  #  #  # ]:          0 :     if ( nEndInd >= nBeginInd
         [ #  # ][ #  #  
             #  #  #  # ]
     134         [ #  # ]:          0 :       && ( nEndInd == aString.getLength() || aString.copy( nEndInd ).equals( aPattern[nInd] ) )
     135         [ #  # ]:          0 :       && ( nBeginInd == 0 || aString.copy( 0, nBeginInd ).equals( aPattern[0] ) ) )
     136                 :            :     {
     137         [ #  # ]:          0 :         for ( sal_Int32 nCurInd = aPattern.getLength() - 2; nCurInd > 0; nCurInd-- )
     138                 :            :         {
     139         [ #  # ]:          0 :             if ( aPattern[nCurInd].isEmpty() )
     140                 :          0 :                 continue;
     141                 :            : 
     142         [ #  # ]:          0 :             if ( nEndInd == nBeginInd )
     143                 :          0 :                 return sal_False;
     144                 :            : 
     145                 :            :             // check that search does not use nEndInd position
     146                 :          0 :             sal_Int32 nLastInd = aString.lastIndexOf( aPattern[nCurInd], nEndInd - 1 );
     147                 :            : 
     148         [ #  # ]:          0 :             if ( nLastInd == -1 )
     149                 :          0 :                 return sal_False;
     150                 :            : 
     151         [ #  # ]:          0 :             if ( nLastInd < nBeginInd )
     152                 :          0 :                 return sal_False;
     153                 :            : 
     154                 :          0 :             nEndInd = nLastInd;
     155                 :            :         }
     156                 :            : 
     157                 :          0 :         return sal_True;
     158                 :            :     }
     159                 :            : 
     160                 :          0 :     return sal_False;
     161                 :            : }
     162                 :            : 
     163                 :            : // XInitialization
     164                 :            : // ----------------------------------------------------------------
     165                 :        464 : void SAL_CALL OZipFileAccess::initialize( const uno::Sequence< uno::Any >& aArguments )
     166                 :            :     throw ( uno::Exception,
     167                 :            :             uno::RuntimeException )
     168                 :            : {
     169         [ +  - ]:        464 :     ::osl::MutexGuard aGuard( m_aMutexHolder->GetMutex() );
     170                 :            : 
     171         [ -  + ]:        464 :     if ( m_bDisposed )
     172         [ #  # ]:          0 :         throw lang::DisposedException(OSL_LOG_PREFIX, uno::Reference< uno::XInterface >() );
     173                 :            : 
     174         [ -  + ]:        464 :     if ( m_pZipFile )
     175         [ #  # ]:          0 :         throw uno::Exception(OSL_LOG_PREFIX, uno::Reference< uno::XInterface >() ); // initialization is allowed only one time
     176                 :            : 
     177         [ -  + ]:        464 :     if ( !aArguments.getLength() )
     178         [ #  # ]:          0 :         throw lang::IllegalArgumentException(OSL_LOG_PREFIX, uno::Reference< uno::XInterface >(), 1 );
     179                 :            : 
     180                 :            :     OSL_ENSURE( aArguments.getLength() == 1, "Too many arguments are provided, only the first one will be used!\n" );
     181                 :            : 
     182                 :        464 :     OUString aParamURL;
     183                 :        464 :     uno::Reference< io::XStream > xStream;
     184                 :        464 :     uno::Reference< io::XSeekable > xSeekable;
     185                 :            : 
     186         [ +  - ]:        464 :     if ( ( aArguments[0] >>= aParamURL ) )
     187                 :            :     {
     188         [ +  + ]:        464 :         ::ucbhelper::Content aContent ( aParamURL, uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >() );
     189 [ +  - ][ +  - ]:        248 :         uno::Reference < io::XActiveDataSink > xSink = new ZipPackageSink;
                 [ +  - ]
     190 [ +  + ][ +  - ]:        248 :         if ( aContent.openStream ( xSink ) )
     191                 :            :         {
     192 [ +  - ][ +  - ]:        124 :             m_xContentStream = xSink->getInputStream();
                 [ +  - ]
     193 [ +  - ][ +  - ]:        124 :             xSeekable = uno::Reference< io::XSeekable >( m_xContentStream, uno::UNO_QUERY );
     194         [ +  - ]:        464 :         }
     195                 :            :     }
     196 [ #  # ][ #  # ]:          0 :     else if ( (aArguments[0] >>= xStream ) )
     197                 :            :     {
     198                 :            :         // a writable stream can implement both XStream & XInputStream
     199 [ #  # ][ #  # ]:          0 :         m_xContentStream = xStream->getInputStream();
                 [ #  # ]
     200 [ #  # ][ #  # ]:          0 :         xSeekable = uno::Reference< io::XSeekable >( xStream, uno::UNO_QUERY );
     201                 :            :     }
     202 [ #  # ][ #  # ]:          0 :     else if ( !( aArguments[0] >>= m_xContentStream ) )
     203                 :            :     {
     204 [ #  # ][ #  # ]:          0 :         xSeekable = uno::Reference< io::XSeekable >( m_xContentStream, uno::UNO_QUERY );
     205                 :            :     }
     206                 :            :     else
     207         [ #  # ]:          0 :         throw lang::IllegalArgumentException(OSL_LOG_PREFIX, uno::Reference< uno::XInterface >(), 1 );
     208                 :            : 
     209         [ -  + ]:        124 :     if ( !m_xContentStream.is() )
     210         [ #  # ]:          0 :         throw io::IOException(OSL_LOG_PREFIX, uno::Reference< uno::XInterface >() );
     211                 :            : 
     212         [ -  + ]:        124 :     if ( !xSeekable.is() )
     213                 :            :     {
     214                 :            :         // TODO: after fwkbugfix02 is integrated a helper class can be used to make the stream seekable
     215         [ #  # ]:          0 :         throw io::IOException(OSL_LOG_PREFIX, uno::Reference< uno::XInterface >() );
     216                 :            :     }
     217                 :            : 
     218                 :            :     // TODO: in case xSeekable is implemented on separated XStream implementation a wrapper is required
     219                 :            :     m_pZipFile = new ZipFile(
     220                 :            :                 m_xContentStream,
     221                 :            :                 m_xFactory,
     222 [ +  - ][ +  + ]:        464 :                 sal_True );
                 [ +  - ]
     223                 :         62 : }
     224                 :            : 
     225                 :            : // XNameAccess
     226                 :            : // ----------------------------------------------------------------
     227                 :       7400 : uno::Any SAL_CALL OZipFileAccess::getByName( const OUString& aName )
     228                 :            :     throw ( container::NoSuchElementException,
     229                 :            :             lang::WrappedTargetException,
     230                 :            :             uno::RuntimeException )
     231                 :            : {
     232         [ +  - ]:       7400 :     ::osl::MutexGuard aGuard( m_aMutexHolder->GetMutex() );
     233                 :            : 
     234         [ -  + ]:       7400 :     if ( m_bDisposed )
     235         [ #  # ]:          0 :         throw lang::DisposedException(OSL_LOG_PREFIX, uno::Reference< uno::XInterface >() );
     236                 :            : 
     237         [ -  + ]:       7400 :     if ( !m_pZipFile )
     238         [ #  # ]:          0 :         throw io::NotConnectedException(OSL_LOG_PREFIX, uno::Reference< uno::XInterface >() );
     239                 :            : 
     240         [ +  - ]:       7400 :     EntryHash::iterator aIter = m_pZipFile->GetEntryHash().find( aName );
     241 [ +  - ][ -  + ]:       7400 :     if ( aIter == m_pZipFile->GetEntryHash().end() )
     242         [ #  # ]:          0 :         throw container::NoSuchElementException(OSL_LOG_PREFIX, uno::Reference< uno::XInterface >() );
     243                 :            : 
     244         [ +  - ]:       7400 :     uno::Reference< io::XInputStream > xEntryStream( m_pZipFile->getDataStream( (*aIter).second,
     245                 :            :                                                                                 ::rtl::Reference< EncryptionData >(),
     246                 :            :                                                                                 sal_False,
     247 [ +  - ][ +  - ]:      14800 :                                                                                 m_aMutexHolder ) );
     248                 :            : 
     249         [ -  + ]:       7400 :     if ( !xEntryStream.is() )
     250         [ #  # ]:          0 :         throw uno::RuntimeException(OSL_LOG_PREFIX, uno::Reference< uno::XInterface >() );
     251                 :            : 
     252 [ +  - ][ +  - ]:       7400 :     return uno::makeAny ( xEntryStream );
     253                 :            : }
     254                 :            : 
     255                 :            : // ----------------------------------------------------------------
     256                 :          0 : uno::Sequence< OUString > SAL_CALL OZipFileAccess::getElementNames()
     257                 :            :     throw ( uno::RuntimeException )
     258                 :            : {
     259         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_aMutexHolder->GetMutex() );
     260                 :            : 
     261         [ #  # ]:          0 :     if ( m_bDisposed )
     262         [ #  # ]:          0 :         throw lang::DisposedException(OSL_LOG_PREFIX, uno::Reference< uno::XInterface >() );
     263                 :            : 
     264         [ #  # ]:          0 :     if ( !m_pZipFile )
     265         [ #  # ]:          0 :         throw io::NotConnectedException(OSL_LOG_PREFIX, uno::Reference< uno::XInterface >() );
     266                 :            : 
     267         [ #  # ]:          0 :     uno::Sequence< OUString > aNames( m_pZipFile->GetEntryHash().size() );
     268                 :          0 :     sal_Int32 nLen = 0;
     269                 :            : 
     270 [ #  # ][ #  # ]:          0 :     for ( EntryHash::iterator aIter = m_pZipFile->GetEntryHash().begin(); aIter != m_pZipFile->GetEntryHash().end(); ++aIter )
                 [ #  # ]
     271                 :            :     {
     272         [ #  # ]:          0 :         if ( aNames.getLength() < ++nLen )
     273                 :            :         {
     274                 :            :             OSL_FAIL( "The size must be the same!\n" );
     275         [ #  # ]:          0 :             aNames.realloc( nLen );
     276                 :            :         }
     277                 :            : 
     278 [ #  # ][ #  # ]:          0 :         aNames[nLen-1] = (*aIter).second.sPath;
     279                 :            :     }
     280                 :            : 
     281         [ #  # ]:          0 :     if ( aNames.getLength() != nLen )
     282                 :            :     {
     283                 :            :         OSL_FAIL( "The size must be the same!\n" );
     284         [ #  # ]:          0 :         aNames.realloc( nLen );
     285                 :            :     }
     286                 :            : 
     287         [ #  # ]:          0 :     return aNames;
     288                 :            : }
     289                 :            : 
     290                 :            : // ----------------------------------------------------------------
     291                 :      22192 : sal_Bool SAL_CALL OZipFileAccess::hasByName( const OUString& aName )
     292                 :            :     throw (uno::RuntimeException)
     293                 :            : {
     294         [ +  - ]:      22192 :     ::osl::MutexGuard aGuard( m_aMutexHolder->GetMutex() );
     295                 :            : 
     296         [ -  + ]:      22192 :     if ( m_bDisposed )
     297         [ #  # ]:          0 :         throw lang::DisposedException(OSL_LOG_PREFIX, uno::Reference< uno::XInterface >() );
     298                 :            : 
     299         [ -  + ]:      22192 :     if ( !m_pZipFile )
     300         [ #  # ]:          0 :         throw io::NotConnectedException(OSL_LOG_PREFIX, uno::Reference< uno::XInterface >() );
     301                 :            : 
     302         [ +  - ]:      22192 :     EntryHash::iterator aIter = m_pZipFile->GetEntryHash().find( aName );
     303                 :            : 
     304 [ +  - ][ +  - ]:      22192 :     return ( aIter != m_pZipFile->GetEntryHash().end() );
     305                 :            : }
     306                 :            : 
     307                 :            : // ----------------------------------------------------------------
     308                 :          0 : uno::Type SAL_CALL OZipFileAccess::getElementType()
     309                 :            :     throw ( uno::RuntimeException )
     310                 :            : {
     311         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_aMutexHolder->GetMutex() );
     312                 :            : 
     313         [ #  # ]:          0 :     if ( m_bDisposed )
     314         [ #  # ]:          0 :         throw lang::DisposedException(OSL_LOG_PREFIX, uno::Reference< uno::XInterface >() );
     315                 :            : 
     316         [ #  # ]:          0 :     if ( !m_pZipFile )
     317         [ #  # ]:          0 :         throw io::NotConnectedException(OSL_LOG_PREFIX, uno::Reference< uno::XInterface >() );
     318                 :            : 
     319 [ #  # ][ #  # ]:          0 :     return getCppuType( ( const uno::Reference< io::XInputStream >* )NULL );
     320                 :            : }
     321                 :            : 
     322                 :            : // ----------------------------------------------------------------
     323                 :          0 : sal_Bool SAL_CALL OZipFileAccess::hasElements()
     324                 :            :     throw ( uno::RuntimeException )
     325                 :            : {
     326         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_aMutexHolder->GetMutex() );
     327                 :            : 
     328         [ #  # ]:          0 :     if ( m_bDisposed )
     329         [ #  # ]:          0 :         throw lang::DisposedException(OSL_LOG_PREFIX, uno::Reference< uno::XInterface >() );
     330                 :            : 
     331         [ #  # ]:          0 :     if ( !m_pZipFile )
     332         [ #  # ]:          0 :         throw io::NotConnectedException(OSL_LOG_PREFIX, uno::Reference< uno::XInterface >() );
     333                 :            : 
     334         [ #  # ]:          0 :     return ( m_pZipFile->GetEntryHash().size() != 0 );
     335                 :            : }
     336                 :            : 
     337                 :            : // XZipFileAccess
     338                 :            : // ----------------------------------------------------------------
     339                 :          0 : uno::Reference< io::XInputStream > SAL_CALL OZipFileAccess::getStreamByPattern( const OUString& aPatternString )
     340                 :            :     throw ( container::NoSuchElementException,
     341                 :            :             io::IOException,
     342                 :            :             uno::RuntimeException )
     343                 :            : {
     344         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_aMutexHolder->GetMutex() );
     345                 :            : 
     346         [ #  # ]:          0 :     if ( m_bDisposed )
     347         [ #  # ]:          0 :         throw lang::DisposedException(OSL_LOG_PREFIX, uno::Reference< uno::XInterface >() );
     348                 :            : 
     349         [ #  # ]:          0 :     if ( !m_pZipFile )
     350         [ #  # ]:          0 :         throw io::NotConnectedException(OSL_LOG_PREFIX, uno::Reference< uno::XInterface >() );
     351                 :            : 
     352                 :            :     // Code to compare strings by patterns
     353         [ #  # ]:          0 :     uno::Sequence< OUString > aPattern = GetPatternsFromString_Impl( aPatternString );
     354                 :            : 
     355 [ #  # ][ #  # ]:          0 :     for ( EntryHash::iterator aIter = m_pZipFile->GetEntryHash().begin(); aIter != m_pZipFile->GetEntryHash().end(); ++aIter )
                 [ #  # ]
     356                 :            :     {
     357 [ #  # ][ #  # ]:          0 :         if ( StringGoodForPattern_Impl( (*aIter).second.sPath, aPattern ) )
                 [ #  # ]
     358                 :            :         {
     359         [ #  # ]:          0 :             uno::Reference< io::XInputStream > xEntryStream( m_pZipFile->getDataStream( (*aIter).second,
     360                 :            :                                                                                         ::rtl::Reference< EncryptionData >(),
     361                 :            :                                                                                         sal_False,
     362 [ #  # ][ #  # ]:          0 :                                                                                         m_aMutexHolder ) );
     363                 :            : 
     364         [ #  # ]:          0 :             if ( !xEntryStream.is() )
     365         [ #  # ]:          0 :                 throw uno::RuntimeException(OSL_LOG_PREFIX, uno::Reference< uno::XInterface >() );
     366                 :          0 :             return xEntryStream;
     367                 :            :         }
     368                 :            :     }
     369                 :            : 
     370 [ #  # ][ #  # ]:          0 :     throw container::NoSuchElementException(OSL_LOG_PREFIX, uno::Reference< uno::XInterface >() );
                 [ #  # ]
     371                 :            : }
     372                 :            : 
     373                 :            : // XComponent
     374                 :            : // ----------------------------------------------------------------
     375                 :        464 : void SAL_CALL OZipFileAccess::dispose()
     376                 :            :     throw ( uno::RuntimeException )
     377                 :            : {
     378         [ +  - ]:        464 :     ::osl::MutexGuard aGuard( m_aMutexHolder->GetMutex() );
     379                 :            : 
     380         [ -  + ]:        464 :     if ( m_bDisposed )
     381         [ #  # ]:          0 :         throw lang::DisposedException(OSL_LOG_PREFIX, uno::Reference< uno::XInterface >() );
     382                 :            : 
     383         [ -  + ]:        464 :     if ( m_pListenersContainer )
     384                 :            :     {
     385 [ #  # ][ #  # ]:          0 :            lang::EventObject aSource( static_cast< ::cppu::OWeakObject* >(this) );
     386         [ #  # ]:          0 :         m_pListenersContainer->disposeAndClear( aSource );
     387 [ #  # ][ #  # ]:          0 :         delete m_pListenersContainer;
     388 [ #  # ][ #  # ]:          0 :         m_pListenersContainer = NULL;
     389                 :            :     }
     390                 :            : 
     391         [ +  + ]:        464 :     if ( m_pZipFile )
     392                 :            :     {
     393 [ +  - ][ +  - ]:         62 :         delete m_pZipFile;
     394                 :         62 :         m_pZipFile = NULL;
     395                 :            :     }
     396                 :            : 
     397         [ +  + ]:        464 :     if ( m_xContentStream.is() )
     398                 :            :         try {
     399 [ +  - ][ +  - ]:        124 :             m_xContentStream->closeInput();
     400         [ #  # ]:          0 :         } catch( uno::Exception& )
     401                 :            :         {}
     402                 :            : 
     403         [ +  - ]:        464 :     m_bDisposed = sal_True;
     404                 :        464 : }
     405                 :            : 
     406                 :            : // ----------------------------------------------------------------
     407                 :          0 : void SAL_CALL OZipFileAccess::addEventListener( const uno::Reference< lang::XEventListener >& xListener )
     408                 :            :     throw ( uno::RuntimeException )
     409                 :            : {
     410         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_aMutexHolder->GetMutex() );
     411                 :            : 
     412         [ #  # ]:          0 :     if ( m_bDisposed )
     413         [ #  # ]:          0 :         throw lang::DisposedException(OSL_LOG_PREFIX, uno::Reference< uno::XInterface >() );
     414                 :            : 
     415         [ #  # ]:          0 :     if ( !m_pListenersContainer )
     416         [ #  # ]:          0 :         m_pListenersContainer = new ::cppu::OInterfaceContainerHelper( m_aMutexHolder->GetMutex() );
     417 [ #  # ][ #  # ]:          0 :     m_pListenersContainer->addInterface( xListener );
     418                 :          0 : }
     419                 :            : 
     420                 :            : // ----------------------------------------------------------------
     421                 :          0 : void SAL_CALL OZipFileAccess::removeEventListener( const uno::Reference< lang::XEventListener >& xListener )
     422                 :            :     throw ( uno::RuntimeException )
     423                 :            : {
     424         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_aMutexHolder->GetMutex() );
     425                 :            : 
     426         [ #  # ]:          0 :     if ( m_bDisposed )
     427         [ #  # ]:          0 :         throw lang::DisposedException(OSL_LOG_PREFIX, uno::Reference< uno::XInterface >() );
     428                 :            : 
     429         [ #  # ]:          0 :     if ( m_pListenersContainer )
     430 [ #  # ][ #  # ]:          0 :         m_pListenersContainer->removeInterface( xListener );
     431                 :          0 : }
     432                 :            : 
     433                 :            : //-------------------------------------------------------------------------
     434                 :        116 : uno::Sequence< OUString > SAL_CALL OZipFileAccess::impl_staticGetSupportedServiceNames()
     435                 :            : {
     436                 :        116 :     uno::Sequence< OUString > aRet(2);
     437         [ +  - ]:        116 :     aRet[0] = "com.sun.star.packages.zip.ZipFileAccess";
     438         [ +  - ]:        116 :     aRet[1] = "com.sun.star.comp.packages.zip.ZipFileAccess";
     439                 :        116 :     return aRet;
     440                 :            : }
     441                 :            : 
     442                 :            : //-------------------------------------------------------------------------
     443                 :        232 : OUString SAL_CALL OZipFileAccess::impl_staticGetImplementationName()
     444                 :            : {
     445                 :        232 :     return OUString("com.sun.star.comp.package.zip.ZipFileAccess");
     446                 :            : }
     447                 :            : 
     448                 :            : //-------------------------------------------------------------------------
     449                 :        464 : uno::Reference< uno::XInterface > SAL_CALL OZipFileAccess::impl_staticCreateSelfInstance(
     450                 :            :             const uno::Reference< lang::XMultiServiceFactory >& xServiceManager )
     451                 :            : {
     452         [ +  - ]:        464 :     return uno::Reference< uno::XInterface >( *new OZipFileAccess( xServiceManager ) );
     453                 :            : }
     454                 :            : 
     455                 :            : //-------------------------------------------------------------------------
     456                 :          0 : OUString SAL_CALL OZipFileAccess::getImplementationName()
     457                 :            :     throw ( uno::RuntimeException )
     458                 :            : {
     459                 :          0 :     return impl_staticGetImplementationName();
     460                 :            : }
     461                 :            : 
     462                 :            : //-------------------------------------------------------------------------
     463                 :          0 : sal_Bool SAL_CALL OZipFileAccess::supportsService( const OUString& ServiceName )
     464                 :            :     throw ( uno::RuntimeException )
     465                 :            : {
     466         [ #  # ]:          0 :     uno::Sequence< OUString > aSeq = impl_staticGetSupportedServiceNames();
     467                 :            : 
     468         [ #  # ]:          0 :     for ( sal_Int32 nInd = 0; nInd < aSeq.getLength(); nInd++ )
     469 [ #  # ][ #  # ]:          0 :         if ( ServiceName.compareTo( aSeq[nInd] ) == 0 )
     470                 :          0 :             return sal_True;
     471                 :            : 
     472         [ #  # ]:          0 :     return sal_False;
     473                 :            : }
     474                 :            : 
     475                 :            : //-------------------------------------------------------------------------
     476                 :          0 : uno::Sequence< OUString > SAL_CALL OZipFileAccess::getSupportedServiceNames()
     477                 :            :     throw ( uno::RuntimeException )
     478                 :            : {
     479                 :          0 :     return impl_staticGetSupportedServiceNames();
     480                 :            : }
     481                 :            : 
     482                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10