1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 #ifndef _ZIP_PACKAGE_FOLDER_HXX 28 #define _ZIP_PACKAGE_FOLDER_HXX 29 30 #include <com/sun/star/container/XNameContainer.hpp> 31 #include <com/sun/star/container/XEnumerationAccess.hpp> 32 #include <com/sun/star/beans/StringPair.hpp> 33 #include <HashMaps.hxx> 34 #include <ZipPackageEntry.hxx> 35 #include <cppuhelper/implbase2.hxx> 36 37 namespace com { namespace sun { namespace star { 38 namespace beans 39 { 40 struct PropertyValue; 41 } 42 namespace packages 43 { 44 class ContentInfo; 45 } 46 } } } 47 48 class ZipFile; 49 class ZipPackage; 50 class ZipOutputStream; 51 struct ZipEntry; 52 typedef void* rtlRandomPool; 53 54 class ZipPackageFolder : public cppu::ImplInheritanceHelper2 55 < 56 ZipPackageEntry, 57 ::com::sun::star::container::XNameContainer, 58 ::com::sun::star::container::XEnumerationAccess 59 > 60 { 61 protected: 62 ContentHash maContents; 63 const ::com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory > m_xFactory; 64 sal_Int32 m_nFormat; 65 ::rtl::OUString m_sVersion; 66 67 public: 68 69 ZipPackageFolder( const ::com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory >& xFactory, 70 sal_Int32 nFormat, 71 sal_Bool bAllowRemoveOnInsert ); 72 virtual ~ZipPackageFolder(); 73 74 ::rtl::OUString& GetVersion() { return m_sVersion; } 75 void SetVersion( const ::rtl::OUString& aVersion ) { m_sVersion = aVersion; } 76 77 sal_Bool LookForUnexpectedODF12Streams( const ::rtl::OUString& aPath ); 78 79 void setChildStreamsTypeByExtension( const ::com::sun::star::beans::StringPair& aPair ); 80 81 void doInsertByName ( ZipPackageEntry *pEntry, sal_Bool bSetParent ) 82 throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::ElementExistException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 83 84 com::sun::star::packages::ContentInfo & doGetByName( const ::rtl::OUString& aName ) 85 throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 86 87 static void copyZipEntry( ZipEntry &rDest, const ZipEntry &rSource); 88 static const ::com::sun::star::uno::Sequence < sal_Int8 >& static_getImplementationId(); 89 90 void setPackageFormat_Impl( sal_Int32 nFormat ) { m_nFormat = nFormat; } 91 void setRemoveOnInsertMode_Impl( sal_Bool bRemove ) { this->mbAllowRemoveOnInsert = bRemove; } 92 93 bool saveChild(const rtl::OUString &rShortName, const com::sun::star::packages::ContentInfo &rInfo, rtl::OUString &rPath, std::vector < com::sun::star::uno::Sequence < com::sun::star::beans::PropertyValue > > &rManList, ZipOutputStream & rZipOut, const com::sun::star::uno::Sequence < sal_Int8 >& rEncryptionKey, rtlRandomPool & rRandomPool); 94 95 // Recursive functions 96 void saveContents(rtl::OUString &rPath, std::vector < com::sun::star::uno::Sequence < com::sun::star::beans::PropertyValue > > &rManList, ZipOutputStream & rZipOut, const com::sun::star::uno::Sequence< sal_Int8 > &rEncryptionKey, rtlRandomPool & rRandomPool) 97 throw(::com::sun::star::uno::RuntimeException); 98 void releaseUpwardRef(); 99 100 // XNameContainer 101 virtual void SAL_CALL insertByName( const ::rtl::OUString& aName, const ::com::sun::star::uno::Any& aElement ) 102 throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::ElementExistException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 103 virtual void SAL_CALL removeByName( const ::rtl::OUString& Name ) 104 throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 105 106 // XEnumerationAccess 107 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createEnumeration( ) 108 throw(::com::sun::star::uno::RuntimeException); 109 110 // XElementAccess 111 virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) 112 throw(::com::sun::star::uno::RuntimeException); 113 virtual sal_Bool SAL_CALL hasElements( ) 114 throw(::com::sun::star::uno::RuntimeException); 115 116 // XNameAccess 117 virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) 118 throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 119 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames( ) 120 throw(::com::sun::star::uno::RuntimeException); 121 virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) 122 throw(::com::sun::star::uno::RuntimeException); 123 124 // XNameReplace 125 virtual void SAL_CALL replaceByName( const ::rtl::OUString& aName, const ::com::sun::star::uno::Any& aElement ) 126 throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 127 128 // XPropertySet 129 virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) 130 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); 131 virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) 132 throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 133 134 // XUnoTunnel 135 virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) 136 throw(::com::sun::star::uno::RuntimeException); 137 138 // XServiceInfo 139 virtual ::rtl::OUString SAL_CALL getImplementationName( ) 140 throw (::com::sun::star::uno::RuntimeException); 141 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) 142 throw (::com::sun::star::uno::RuntimeException); 143 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) 144 throw (::com::sun::star::uno::RuntimeException); 145 }; 146 #endif 147