LCOV - code coverage report
Current view: top level - package/inc - ZipPackage.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 7 7 100.0 %
Date: 2012-08-25 Functions: 7 7 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 1 2 50.0 %

           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                 :            : #ifndef _ZIP_PACKAGE_HXX
      20                 :            : #define _ZIP_PACKAGE_HXX
      21                 :            : 
      22                 :            : #include <cppuhelper/implbase7.hxx>
      23                 :            : #include <com/sun/star/lang/XInitialization.hpp>
      24                 :            : #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
      25                 :            : #include <com/sun/star/lang/XSingleServiceFactory.hpp>
      26                 :            : #include <com/sun/star/util/XChangesBatch.hpp>
      27                 :            : #include <com/sun/star/lang/XUnoTunnel.hpp>
      28                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      29                 :            : #include <com/sun/star/beans/PropertyValue.hpp>
      30                 :            : #include <com/sun/star/beans/NamedValue.hpp>
      31                 :            : #include <com/sun/star/lang/XServiceInfo.hpp>
      32                 :            : #include <com/sun/star/xml/crypto/CipherID.hpp>
      33                 :            : #include <com/sun/star/lang/IllegalArgumentException.hpp>
      34                 :            : 
      35                 :            : #include <HashMaps.hxx>
      36                 :            : #include <osl/file.h>
      37                 :            : #include <mutexholder.hxx>
      38                 :            : #include <vector>
      39                 :            : 
      40                 :            : class ZipOutputStream;
      41                 :            : class ZipPackageFolder;
      42                 :            : class ZipFile;
      43                 :            : namespace com { namespace sun { namespace star {
      44                 :            :     namespace container { class XNameContainer; }
      45                 :            :     namespace io { class XStream; class XOutputStream; class XInputStream; class XSeekable; class XActiveDataStreamer; }
      46                 :            :     namespace lang { class XMultiServiceFactory; }
      47                 :            :     namespace task { class XInteractionHandler; }
      48                 :            : } } }
      49                 :            : enum SegmentEnum
      50                 :            : {
      51                 :            :     e_Aborted = -1000,
      52                 :            :     e_Retry,
      53                 :            :     e_Finished,
      54                 :            :     e_Success = 0
      55                 :            : };
      56                 :            : 
      57                 :            : enum InitialisationMode
      58                 :            : {
      59                 :            :     e_IMode_None,
      60                 :            :     e_IMode_URL,
      61                 :            :     e_IMode_XInputStream,
      62                 :            :     e_IMode_XStream
      63                 :            : };
      64                 :            : 
      65                 :            : class ZipPackage : public cppu::WeakImplHelper7
      66                 :            :                     <
      67                 :            :                        com::sun::star::lang::XInitialization,
      68                 :            :                        com::sun::star::lang::XSingleServiceFactory,
      69                 :            :                        com::sun::star::lang::XUnoTunnel,
      70                 :            :                        com::sun::star::lang::XServiceInfo,
      71                 :            :                        com::sun::star::container::XHierarchicalNameAccess,
      72                 :            :                        com::sun::star::util::XChangesBatch,
      73                 :            :                        com::sun::star::beans::XPropertySet
      74                 :            :                     >
      75                 :            : {
      76                 :            : protected:
      77                 :            :     SotMutexHolderRef m_aMutexHolder;
      78                 :            : 
      79                 :            :     ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > m_aStorageEncryptionKeys;
      80                 :            :     ::com::sun::star::uno::Sequence< sal_Int8 > m_aEncryptionKey;
      81                 :            : 
      82                 :            :     FolderHash        m_aRecent;
      83                 :            :     ::rtl::OUString   m_aURL;
      84                 :            : 
      85                 :            :     sal_Int32         m_nStartKeyGenerationID;
      86                 :            :     sal_Int32         m_nChecksumDigestID;
      87                 :            :     sal_Int32         m_nCommonEncryptionID;
      88                 :            :     sal_Bool          m_bHasEncryptedEntries;
      89                 :            :     sal_Bool          m_bHasNonEncryptedEntries;
      90                 :            : 
      91                 :            :     sal_Bool          m_bInconsistent;
      92                 :            :     sal_Bool          m_bForceRecovery;
      93                 :            : 
      94                 :            :     sal_Bool          m_bMediaTypeFallbackUsed;
      95                 :            :     sal_Int32         m_nFormat;
      96                 :            :     sal_Bool          m_bAllowRemoveOnInsert;
      97                 :            : 
      98                 :            :     InitialisationMode m_eMode;
      99                 :            : 
     100                 :            :     ::com::sun::star::uno::Reference < com::sun::star::container::XNameContainer > m_xRootFolder;
     101                 :            :     ::com::sun::star::uno::Reference < com::sun::star::io::XStream > m_xStream;
     102                 :            :     ::com::sun::star::uno::Reference < com::sun::star::io::XInputStream > m_xContentStream;
     103                 :            :     ::com::sun::star::uno::Reference < com::sun::star::io::XSeekable > m_xContentSeek;
     104                 :            :     const ::com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory > m_xFactory;
     105                 :            : 
     106                 :            :     ZipPackageFolder *m_pRootFolder;
     107                 :            :     ZipFile          *m_pZipFile;
     108                 :            : 
     109                 :            :     void parseManifest();
     110                 :            :     void parseContentType();
     111                 :            :     void getZipFileContents();
     112                 :            : 
     113                 :            :     void WriteMimetypeMagicFile( ZipOutputStream& aZipOut );
     114                 :            :     void WriteManifest( ZipOutputStream& aZipOut, const ::std::vector< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > >& aManList );
     115                 :            :     void WriteContentTypes( ZipOutputStream& aZipOut, const ::std::vector< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > >& aManList );
     116                 :            : 
     117                 :            :     ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > writeTempFile();
     118                 :            :     ::com::sun::star::uno::Reference < ::com::sun::star::io::XActiveDataStreamer > openOriginalForOutput();
     119                 :            :     void DisconnectFromTargetAndThrowException_Impl(
     120                 :            :             const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xTempStream );
     121                 :            : 
     122                 :            : public:
     123                 :            :     ZipPackage( const ::com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory > &xNewFactory );
     124                 :            :     virtual ~ZipPackage( void );
     125                 :       6584 :     ZipFile& getZipFile() { return *m_pZipFile;}
     126                 :      18858 :     sal_Int32 getFormat() const { return m_nFormat; }
     127                 :            : 
     128                 :         72 :     sal_Int32 GetStartKeyGenID() const { return m_nStartKeyGenerationID; }
     129                 :         36 :     sal_Int32 GetEncAlgID() const { return m_nCommonEncryptionID; }
     130                 :         36 :     sal_Int32 GetChecksumAlgID() const { return m_nChecksumDigestID; }
     131         [ -  + ]:         36 :     sal_Int32 GetDefaultDerivedKeySize() const { return m_nCommonEncryptionID == ::com::sun::star::xml::crypto::CipherID::AES_CBC_W3C_PADDING ? 32 : 16; }
     132                 :            : 
     133                 :       7860 :     SotMutexHolderRef GetSharedMutexRef() { return m_aMutexHolder; }
     134                 :            : 
     135                 :            :     void ConnectTo( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xInStream );
     136                 :            :     const ::com::sun::star::uno::Sequence< sal_Int8 > GetEncryptionKey();
     137                 :            : 
     138                 :            :     // XInitialization
     139                 :            :     virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
     140                 :            :         throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
     141                 :            :     // XHierarchicalNameAccess
     142                 :            :     virtual ::com::sun::star::uno::Any SAL_CALL getByHierarchicalName( const ::rtl::OUString& aName )
     143                 :            :         throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
     144                 :            :     virtual sal_Bool SAL_CALL hasByHierarchicalName( const ::rtl::OUString& aName )
     145                 :            :         throw(::com::sun::star::uno::RuntimeException);
     146                 :            :     // XSingleServiceFactory
     147                 :            :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstance(  )
     148                 :            :         throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
     149                 :            :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstanceWithArguments( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
     150                 :            :         throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
     151                 :            :     // XChangesBatch
     152                 :            :     virtual void SAL_CALL commitChanges(  )
     153                 :            :         throw(::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
     154                 :            :     virtual sal_Bool SAL_CALL hasPendingChanges(  )
     155                 :            :         throw(::com::sun::star::uno::RuntimeException);
     156                 :            :     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::util::ElementChange > SAL_CALL getPendingChanges(  )
     157                 :            :         throw(::com::sun::star::uno::RuntimeException);
     158                 :            :     // XUnoTunnel
     159                 :            :     virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier )
     160                 :            :         throw(::com::sun::star::uno::RuntimeException);
     161                 :            :     com::sun::star::uno::Sequence < sal_Int8 > getUnoTunnelImplementationId( void )
     162                 :            :         throw(::com::sun::star::uno::RuntimeException);
     163                 :            :     // XPropertySet
     164                 :            :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  )
     165                 :            :         throw(::com::sun::star::uno::RuntimeException);
     166                 :            :     virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue )
     167                 :            :         throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
     168                 :            :     virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName )
     169                 :            :         throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
     170                 :            :     virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener )
     171                 :            :         throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
     172                 :            :     virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener )
     173                 :            :         throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
     174                 :            :     virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener )
     175                 :            :         throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
     176                 :            :     virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener )
     177                 :            :         throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
     178                 :            : 
     179                 :            :     // XServiceInfo
     180                 :            :     virtual ::rtl::OUString SAL_CALL getImplementationName(  )
     181                 :            :         throw (::com::sun::star::uno::RuntimeException);
     182                 :            :     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
     183                 :            :         throw (::com::sun::star::uno::RuntimeException);
     184                 :            :     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  )
     185                 :            :         throw (::com::sun::star::uno::RuntimeException);
     186                 :            : 
     187                 :            :     // Uno componentiseralation
     188                 :            :     static ::rtl::OUString static_getImplementationName();
     189                 :            :     static ::com::sun::star::uno::Sequence < ::rtl::OUString > static_getSupportedServiceNames();
     190                 :            :     static ::com::sun::star::uno::Reference < com::sun::star::lang::XSingleServiceFactory > createServiceFactory( com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory > const & rServiceFactory );
     191                 :            :     sal_Bool SAL_CALL static_supportsService(rtl::OUString const & rServiceName);
     192                 :            : };
     193                 :            : #endif
     194                 :            : 
     195                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10