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