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