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