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 <vector> 31 #include <ZipPackageEntry.hxx> 32 #include <cppuhelper/implbase2.hxx> 33 34 namespace com { namespace sun { namespace star { 35 namespace beans 36 { 37 struct PropertyValue; 38 } 39 namespace packages 40 { 41 class ContentInfo; 42 } 43 } } } 44 45 class ZipFile; 46 class ZipPackage; 47 class ZipOutputStream; 48 struct ZipEntry; 49 typedef void* rtlRandomPool; 50 51 class ZipPackageFolder : public cppu::ImplInheritanceHelper2 52 < 53 ZipPackageEntry, 54 ::com::sun::star::container::XNameContainer, 55 ::com::sun::star::container::XEnumerationAccess 56 > 57 { 58 protected: 59 ContentHash maContents; 60 const ::com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory > m_xFactory; 61 sal_Int32 m_nFormat; 62 ::rtl::OUString m_sVersion; 63 64 public: 65 66 ZipPackageFolder( const ::com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory >& xFactory, 67 sal_Int32 nFormat, 68 sal_Bool bAllowRemoveOnInsert ); 69 virtual ~ZipPackageFolder(); 70 GetVersion()71 ::rtl::OUString& GetVersion() { return m_sVersion; } SetVersion(const::rtl::OUString & aVersion)72 void SetVersion( const ::rtl::OUString& aVersion ) { m_sVersion = aVersion; } 73 74 sal_Bool LookForUnexpectedODF12Streams( const ::rtl::OUString& aPath ); 75 76 void setChildStreamsTypeByExtension( const ::com::sun::star::beans::StringPair& aPair ); 77 78 void doInsertByName ( ZipPackageEntry *pEntry, sal_Bool bSetParent ); 79 80 com::sun::star::packages::ContentInfo & doGetByName( const ::rtl::OUString& aName ); 81 82 static void copyZipEntry( ZipEntry &rDest, const ZipEntry &rSource); 83 static const ::com::sun::star::uno::Sequence < sal_Int8 >& static_getImplementationId(); 84 setPackageFormat_Impl(sal_Int32 nFormat)85 void setPackageFormat_Impl( sal_Int32 nFormat ) { m_nFormat = nFormat; } setRemoveOnInsertMode_Impl(sal_Bool bRemove)86 void setRemoveOnInsertMode_Impl( sal_Bool bRemove ) { this->mbAllowRemoveOnInsert = bRemove; } 87 88 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); 89 90 // Recursive functions 91 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); 92 void releaseUpwardRef(); 93 94 // XNameContainer 95 virtual void SAL_CALL insertByName( const ::rtl::OUString& aName, const ::com::sun::star::uno::Any& aElement ); 96 virtual void SAL_CALL removeByName( const ::rtl::OUString& Name ); 97 98 // XEnumerationAccess 99 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createEnumeration( ); 100 101 // XElementAccess 102 virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ); 103 virtual sal_Bool SAL_CALL hasElements( ); 104 105 // XNameAccess 106 virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ); 107 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames( ); 108 virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ); 109 110 // XNameReplace 111 virtual void SAL_CALL replaceByName( const ::rtl::OUString& aName, const ::com::sun::star::uno::Any& aElement ); 112 113 // XPropertySet 114 virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ); 115 virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ); 116 117 // XUnoTunnel 118 virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ); 119 120 // XServiceInfo 121 virtual ::rtl::OUString SAL_CALL getImplementationName( ); 122 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ); 123 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ); 124 }; 125 #endif 126