LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/package/inc - ZipPackage.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 7 7 100.0 %
Date: 2013-07-09 Functions: 7 7 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : #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 uno { class XComponentContext; }
      48             :     namespace task { class XInteractionHandler; }
      49             : } } }
      50             : enum SegmentEnum
      51             : {
      52             :     e_Aborted = -1000,
      53             :     e_Retry,
      54             :     e_Finished,
      55             :     e_Success = 0
      56             : };
      57             : 
      58             : enum InitialisationMode
      59             : {
      60             :     e_IMode_None,
      61             :     e_IMode_URL,
      62             :     e_IMode_XInputStream,
      63             :     e_IMode_XStream
      64             : };
      65             : 
      66             : class ZipPackage : public cppu::WeakImplHelper7
      67             :                     <
      68             :                        com::sun::star::lang::XInitialization,
      69             :                        com::sun::star::lang::XSingleServiceFactory,
      70             :                        com::sun::star::lang::XUnoTunnel,
      71             :                        com::sun::star::lang::XServiceInfo,
      72             :                        com::sun::star::container::XHierarchicalNameAccess,
      73             :                        com::sun::star::util::XChangesBatch,
      74             :                        com::sun::star::beans::XPropertySet
      75             :                     >
      76             : {
      77             : protected:
      78             :     SotMutexHolderRef m_aMutexHolder;
      79             : 
      80             :     ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > m_aStorageEncryptionKeys;
      81             :     ::com::sun::star::uno::Sequence< sal_Int8 > m_aEncryptionKey;
      82             : 
      83             :     FolderHash        m_aRecent;
      84             :     OUString   m_aURL;
      85             : 
      86             :     sal_Int32         m_nStartKeyGenerationID;
      87             :     sal_Int32         m_nChecksumDigestID;
      88             :     sal_Int32         m_nCommonEncryptionID;
      89             :     sal_Bool          m_bHasEncryptedEntries;
      90             :     sal_Bool          m_bHasNonEncryptedEntries;
      91             : 
      92             :     sal_Bool          m_bInconsistent;
      93             :     sal_Bool          m_bForceRecovery;
      94             : 
      95             :     sal_Bool          m_bMediaTypeFallbackUsed;
      96             :     sal_Int32         m_nFormat;
      97             :     sal_Bool          m_bAllowRemoveOnInsert;
      98             : 
      99             :     InitialisationMode m_eMode;
     100             : 
     101             :     ::com::sun::star::uno::Reference < com::sun::star::container::XNameContainer > m_xRootFolder;
     102             :     ::com::sun::star::uno::Reference < com::sun::star::io::XStream > m_xStream;
     103             :     ::com::sun::star::uno::Reference < com::sun::star::io::XInputStream > m_xContentStream;
     104             :     ::com::sun::star::uno::Reference < com::sun::star::io::XSeekable > m_xContentSeek;
     105             :     const ::com::sun::star::uno::Reference < com::sun::star::uno::XComponentContext > m_xContext;
     106             : 
     107             :     ZipPackageFolder *m_pRootFolder;
     108             :     ZipFile          *m_pZipFile;
     109             : 
     110             :     sal_Bool isLocalFile() const;
     111             : 
     112             :     void parseManifest();
     113             :     void parseContentType();
     114             :     void getZipFileContents();
     115             : 
     116             :     void WriteMimetypeMagicFile( ZipOutputStream& aZipOut );
     117             :     void WriteManifest( ZipOutputStream& aZipOut, const ::std::vector< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > >& aManList );
     118             :     void WriteContentTypes( ZipOutputStream& aZipOut, const ::std::vector< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > >& aManList );
     119             : 
     120             :     ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > writeTempFile();
     121             :     ::com::sun::star::uno::Reference < ::com::sun::star::io::XActiveDataStreamer > openOriginalForOutput();
     122             :     void DisconnectFromTargetAndThrowException_Impl(
     123             :             const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xTempStream );
     124             : 
     125             : public:
     126             :     ZipPackage( const ::com::sun::star::uno::Reference < com::sun::star::uno::XComponentContext > &xContext );
     127             :     virtual ~ZipPackage( void );
     128        5316 :     ZipFile& getZipFile() { return *m_pZipFile;}
     129       10756 :     sal_Int32 getFormat() const { return m_nFormat; }
     130             : 
     131          70 :     sal_Int32 GetStartKeyGenID() const { return m_nStartKeyGenerationID; }
     132          40 :     sal_Int32 GetEncAlgID() const { return m_nCommonEncryptionID; }
     133          35 :     sal_Int32 GetChecksumAlgID() const { return m_nChecksumDigestID; }
     134          35 :     sal_Int32 GetDefaultDerivedKeySize() const { return m_nCommonEncryptionID == ::com::sun::star::xml::crypto::CipherID::AES_CBC_W3C_PADDING ? 32 : 16; }
     135             : 
     136        6373 :     SotMutexHolderRef GetSharedMutexRef() { return m_aMutexHolder; }
     137             : 
     138             :     void ConnectTo( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xInStream );
     139             :     const ::com::sun::star::uno::Sequence< sal_Int8 > GetEncryptionKey();
     140             : 
     141             :     // XInitialization
     142             :     virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
     143             :         throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
     144             :     // XHierarchicalNameAccess
     145             :     virtual ::com::sun::star::uno::Any SAL_CALL getByHierarchicalName( const OUString& aName )
     146             :         throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
     147             :     virtual sal_Bool SAL_CALL hasByHierarchicalName( const OUString& aName )
     148             :         throw(::com::sun::star::uno::RuntimeException);
     149             :     // XSingleServiceFactory
     150             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstance(  )
     151             :         throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
     152             :     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 )
     153             :         throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
     154             :     // XChangesBatch
     155             :     virtual void SAL_CALL commitChanges(  )
     156             :         throw(::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
     157             :     virtual sal_Bool SAL_CALL hasPendingChanges(  )
     158             :         throw(::com::sun::star::uno::RuntimeException);
     159             :     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::util::ElementChange > SAL_CALL getPendingChanges(  )
     160             :         throw(::com::sun::star::uno::RuntimeException);
     161             :     // XUnoTunnel
     162             :     virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier )
     163             :         throw(::com::sun::star::uno::RuntimeException);
     164             :     com::sun::star::uno::Sequence < sal_Int8 > getUnoTunnelImplementationId( void )
     165             :         throw(::com::sun::star::uno::RuntimeException);
     166             :     // XPropertySet
     167             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  )
     168             :         throw(::com::sun::star::uno::RuntimeException);
     169             :     virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue )
     170             :         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);
     171             :     virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName )
     172             :         throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
     173             :     virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener )
     174             :         throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
     175             :     virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener )
     176             :         throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
     177             :     virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener )
     178             :         throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
     179             :     virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener )
     180             :         throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
     181             : 
     182             :     // XServiceInfo
     183             :     virtual OUString SAL_CALL getImplementationName(  )
     184             :         throw (::com::sun::star::uno::RuntimeException);
     185             :     virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
     186             :         throw (::com::sun::star::uno::RuntimeException);
     187             :     virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames(  )
     188             :         throw (::com::sun::star::uno::RuntimeException);
     189             : 
     190             :     // Uno componentiseralation
     191             :     static OUString static_getImplementationName();
     192             :     static ::com::sun::star::uno::Sequence < OUString > static_getSupportedServiceNames();
     193             :     static ::com::sun::star::uno::Reference < com::sun::star::lang::XSingleServiceFactory > createServiceFactory( com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory > const & rServiceFactory );
     194             :     sal_Bool SAL_CALL static_supportsService(OUString const & rServiceName);
     195             : };
     196             : #endif
     197             : 
     198             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10