1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ZipPackageFolder.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _ZIP_PACKAGE_FOLDER_HXX
31 #define _ZIP_PACKAGE_FOLDER_HXX
33 #include <com/sun/star/container/XNameContainer.hpp>
34 #include <com/sun/star/container/XEnumerationAccess.hpp>
35 #include <com/sun/star/beans/StringPair.hpp>
36 #include <HashMaps.hxx>
37 #include <ZipPackageEntry.hxx>
38 #include <cppuhelper/implbase2.hxx>
40 namespace com
{ namespace sun
{ namespace star
{
48 class ZipOutputStream
;
50 typedef void* rtlRandomPool
;
52 class ZipPackageFolder
: public cppu::ImplInheritanceHelper2
55 ::com::sun::star::container::XNameContainer
,
56 ::com::sun::star::container::XEnumerationAccess
59 static com::sun::star::uno::Sequence
< sal_Int8
> aImplementationId
;
62 ContentHash maContents
;
63 const ::com::sun::star::uno::Reference
< com::sun::star::lang::XMultiServiceFactory
> m_xFactory
;
65 ::rtl::OUString m_sVersion
;
69 ZipPackageFolder( const ::com::sun::star::uno::Reference
< com::sun::star::lang::XMultiServiceFactory
>& xFactory
,
71 sal_Bool bAllowRemoveOnInsert
);
72 virtual ~ZipPackageFolder();
74 ::rtl::OUString
& GetVersion() { return m_sVersion
; }
75 void SetVersion( const ::rtl::OUString
& aVersion
) { m_sVersion
= aVersion
; }
77 sal_Bool
LookForUnexpectedODF12Streams( const ::rtl::OUString
& aPath
);
79 void setChildStreamsTypeByExtension( const ::com::sun::star::beans::StringPair
& aPair
);
81 void doInsertByName ( ZipPackageEntry
*pEntry
, sal_Bool bSetParent
)
82 throw(::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::container::ElementExistException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
84 com::sun::star::packages::ContentInfo
& doGetByName( const ::rtl::OUString
& aName
)
85 throw(::com::sun::star::container::NoSuchElementException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
87 static void copyZipEntry( ZipEntry
&rDest
, const ZipEntry
&rSource
);
88 static ::com::sun::star::uno::Sequence
< sal_Int8
> static_getImplementationId()
90 return aImplementationId
;
93 void setPackageFormat_Impl( sal_Int16 nFormat
) { m_nFormat
= nFormat
; }
94 void setRemoveOnInsertMode_Impl( sal_Bool bRemove
) { this->mbAllowRemoveOnInsert
= bRemove
; }
96 // Recursive functions
97 void saveContents(rtl::OUString
&rPath
, std::vector
< com::sun::star::uno::Sequence
< com::sun::star::beans::PropertyValue
> > &rManList
, ZipOutputStream
& rZipOut
, com::sun::star::uno::Sequence
< sal_Int8
> &rEncryptionKey
, rtlRandomPool
& rRandomPool
)
98 throw(::com::sun::star::uno::RuntimeException
);
99 void releaseUpwardRef();
102 virtual void SAL_CALL
insertByName( const ::rtl::OUString
& aName
, const ::com::sun::star::uno::Any
& aElement
)
103 throw(::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::container::ElementExistException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
104 virtual void SAL_CALL
removeByName( const ::rtl::OUString
& Name
)
105 throw(::com::sun::star::container::NoSuchElementException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
107 // XEnumerationAccess
108 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::container::XEnumeration
> SAL_CALL
createEnumeration( )
109 throw(::com::sun::star::uno::RuntimeException
);
112 virtual ::com::sun::star::uno::Type SAL_CALL
getElementType( )
113 throw(::com::sun::star::uno::RuntimeException
);
114 virtual sal_Bool SAL_CALL
hasElements( )
115 throw(::com::sun::star::uno::RuntimeException
);
118 virtual ::com::sun::star::uno::Any SAL_CALL
getByName( const ::rtl::OUString
& aName
)
119 throw(::com::sun::star::container::NoSuchElementException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
120 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getElementNames( )
121 throw(::com::sun::star::uno::RuntimeException
);
122 virtual sal_Bool SAL_CALL
hasByName( const ::rtl::OUString
& aName
)
123 throw(::com::sun::star::uno::RuntimeException
);
126 virtual void SAL_CALL
replaceByName( const ::rtl::OUString
& aName
, const ::com::sun::star::uno::Any
& aElement
)
127 throw(::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::container::NoSuchElementException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
130 virtual void SAL_CALL
setPropertyValue( const ::rtl::OUString
& aPropertyName
, const ::com::sun::star::uno::Any
& aValue
)
131 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
);
132 virtual ::com::sun::star::uno::Any SAL_CALL
getPropertyValue( const ::rtl::OUString
& PropertyName
)
133 throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
136 virtual sal_Int64 SAL_CALL
getSomething( const ::com::sun::star::uno::Sequence
< sal_Int8
>& aIdentifier
)
137 throw(::com::sun::star::uno::RuntimeException
);
140 virtual ::rtl::OUString SAL_CALL
getImplementationName( )
141 throw (::com::sun::star::uno::RuntimeException
);
142 virtual sal_Bool SAL_CALL
supportsService( const ::rtl::OUString
& ServiceName
)
143 throw (::com::sun::star::uno::RuntimeException
);
144 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getSupportedServiceNames( )
145 throw (::com::sun::star::uno::RuntimeException
);