1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 #ifndef _ZIP_PACKAGE_FOLDER_HXX 24 #define _ZIP_PACKAGE_FOLDER_HXX 25 26 #include <com/sun/star/container/XNameContainer.hpp> 27 #include <com/sun/star/container/XEnumerationAccess.hpp> 28 #include <com/sun/star/beans/StringPair.hpp> 29 #include <HashMaps.hxx> 30 #include <ZipPackageEntry.hxx> 31 #include <cppuhelper/implbase2.hxx> 32 33 namespace com { namespace sun { namespace star { 34 namespace beans 35 { 36 struct PropertyValue; 37 } 38 namespace packages 39 { 40 class ContentInfo; 41 } 42 } } } 43 44 class ZipFile; 45 class ZipPackage; 46 class ZipOutputStream; 47 struct ZipEntry; 48 typedef void* rtlRandomPool; 49 50 class ZipPackageFolder : public cppu::ImplInheritanceHelper2 51 < 52 ZipPackageEntry, 53 ::com::sun::star::container::XNameContainer, 54 ::com::sun::star::container::XEnumerationAccess 55 > 56 { 57 protected: 58 ContentHash maContents; 59 const ::com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory > m_xFactory; 60 sal_Int32 m_nFormat; 61 ::rtl::OUString m_sVersion; 62 63 public: 64 65 ZipPackageFolder( const ::com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory >& xFactory, 66 sal_Int32 nFormat, 67 sal_Bool bAllowRemoveOnInsert ); 68 virtual ~ZipPackageFolder(); 69 70 ::rtl::OUString& GetVersion() { return m_sVersion; } 71 void SetVersion( const ::rtl::OUString& aVersion ) { m_sVersion = aVersion; } 72 73 sal_Bool LookForUnexpectedODF12Streams( const ::rtl::OUString& aPath ); 74 75 void setChildStreamsTypeByExtension( const ::com::sun::star::beans::StringPair& aPair ); 76 77 void doInsertByName ( ZipPackageEntry *pEntry, sal_Bool bSetParent ) 78 throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::ElementExistException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 79 80 com::sun::star::packages::ContentInfo & doGetByName( const ::rtl::OUString& aName ) 81 throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 82 83 static void copyZipEntry( ZipEntry &rDest, const ZipEntry &rSource); 84 static const ::com::sun::star::uno::Sequence < sal_Int8 >& static_getImplementationId(); 85 86 void setPackageFormat_Impl( sal_Int32 nFormat ) { m_nFormat = nFormat; } 87 void setRemoveOnInsertMode_Impl( sal_Bool bRemove ) { this->mbAllowRemoveOnInsert = bRemove; } 88 89 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); 90 91 // Recursive functions 92 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) 93 throw(::com::sun::star::uno::RuntimeException); 94 void releaseUpwardRef(); 95 96 // XNameContainer 97 virtual void SAL_CALL insertByName( const ::rtl::OUString& aName, const ::com::sun::star::uno::Any& aElement ) 98 throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::ElementExistException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 99 virtual void SAL_CALL removeByName( const ::rtl::OUString& Name ) 100 throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 101 102 // XEnumerationAccess 103 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createEnumeration( ) 104 throw(::com::sun::star::uno::RuntimeException); 105 106 // XElementAccess 107 virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) 108 throw(::com::sun::star::uno::RuntimeException); 109 virtual sal_Bool SAL_CALL hasElements( ) 110 throw(::com::sun::star::uno::RuntimeException); 111 112 // XNameAccess 113 virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) 114 throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 115 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames( ) 116 throw(::com::sun::star::uno::RuntimeException); 117 virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) 118 throw(::com::sun::star::uno::RuntimeException); 119 120 // XNameReplace 121 virtual void SAL_CALL replaceByName( const ::rtl::OUString& aName, const ::com::sun::star::uno::Any& aElement ) 122 throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 123 124 // XPropertySet 125 virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) 126 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); 127 virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) 128 throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 129 130 // XUnoTunnel 131 virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) 132 throw(::com::sun::star::uno::RuntimeException); 133 134 // XServiceInfo 135 virtual ::rtl::OUString SAL_CALL getImplementationName( ) 136 throw (::com::sun::star::uno::RuntimeException); 137 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) 138 throw (::com::sun::star::uno::RuntimeException); 139 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) 140 throw (::com::sun::star::uno::RuntimeException); 141 }; 142 #endif 143