merge the formfield patch from ooo-build
[ooovba.git] / package / inc / ZipPackage.hxx
blob3f531928805a9e78d9735c5c8d1b1fe6e0f65326
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ZipPackage.hxx,v $
10 * $Revision: 1.41.20.1 $
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_HXX
31 #define _ZIP_PACKAGE_HXX
33 #include <cppuhelper/implbase7.hxx>
34 #include <com/sun/star/lang/XInitialization.hpp>
35 #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
36 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
37 #include <com/sun/star/util/XChangesBatch.hpp>
38 #include <com/sun/star/lang/XUnoTunnel.hpp>
39 #include <com/sun/star/beans/XPropertySet.hpp>
40 #include <com/sun/star/beans/PropertyValue.hpp>
41 #ifndef _COM_SUN_STAR_LANG_XPSERVICEINFO_HPP_
42 #include <com/sun/star/lang/XServiceInfo.hpp>
43 #endif
44 #include <HashMaps.hxx>
45 #include <com/sun/star/lang/IllegalArgumentException.hpp>
46 #include <osl/file.h>
47 #include <mutexholder.hxx>
49 class ZipOutputStream;
50 class ZipPackageFolder;
51 class ZipFile;
52 class ByteGrabber;
53 namespace com { namespace sun { namespace star {
54 namespace container { class XNameContainer; }
55 namespace io { class XStream; class XOutputStream; class XInputStream; class XSeekable; class XActiveDataStreamer; }
56 namespace lang { class XMultiServiceFactory; }
57 namespace task { class XInteractionHandler; }
58 } } }
59 enum SegmentEnum
61 e_Aborted = -1000,
62 e_Retry,
63 e_Finished,
64 e_Success = 0
67 enum InitialisationMode
69 e_IMode_None,
70 e_IMode_URL,
71 e_IMode_XInputStream,
72 e_IMode_XStream
75 class ZipPackage : public cppu::WeakImplHelper7
77 com::sun::star::lang::XInitialization,
78 com::sun::star::lang::XSingleServiceFactory,
79 com::sun::star::lang::XUnoTunnel,
80 com::sun::star::lang::XServiceInfo,
81 com::sun::star::container::XHierarchicalNameAccess,
82 com::sun::star::util::XChangesBatch,
83 com::sun::star::beans::XPropertySet
86 protected:
87 SotMutexHolderRef m_aMutexHolder;
89 ::com::sun::star::uno::Sequence < sal_Int8 > m_aEncryptionKey;
90 FolderHash m_aRecent;
91 ::rtl::OUString m_aURL;
92 sal_Bool m_bHasEncryptedEntries;
93 sal_Bool m_bHasNonEncryptedEntries;
94 sal_Bool m_bUseManifest;
95 sal_Bool m_bForceRecovery;
97 sal_Bool m_bMediaTypeFallbackUsed;
98 sal_Int16 m_nFormat;
99 sal_Bool m_bAllowRemoveOnInsert;
101 InitialisationMode m_eMode;
103 ::com::sun::star::uno::Reference < com::sun::star::container::XNameContainer > m_xRootFolder;
104 ::com::sun::star::uno::Reference < com::sun::star::io::XStream > m_xStream;
105 ::com::sun::star::uno::Reference < com::sun::star::io::XInputStream > m_xContentStream;
106 ::com::sun::star::uno::Reference < com::sun::star::io::XSeekable > m_xContentSeek;
107 const ::com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory > m_xFactory;
109 ZipPackageFolder *m_pRootFolder;
110 ZipFile *m_pZipFile;
112 void parseManifest();
113 void parseContentType();
114 void getZipFileContents();
116 void WriteMimetypeMagicFile( ZipOutputStream& aZipOut );
117 void WriteManifest( ZipOutputStream& aZipOut, const ::std::vector< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > >& aManList );
118 void WriteContentTypes( ZipOutputStream& aZipOut, const ::std::vector< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > >& aManList );
120 ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > writeTempFile();
121 ::com::sun::star::uno::Reference < ::com::sun::star::io::XActiveDataStreamer > openOriginalForOutput();
122 void DisconnectFromTargetAndThrowException_Impl(
123 const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xTempStream );
125 public:
126 ZipPackage (const ::com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory > &xNewFactory);
127 virtual ~ZipPackage( void );
128 ZipFile& getZipFile() { return *m_pZipFile;}
129 const com::sun::star::uno::Sequence < sal_Int8 > & getEncryptionKey ( ) {return m_aEncryptionKey;}
130 sal_Int16 getFormat() const { return m_nFormat; }
132 SotMutexHolderRef GetSharedMutexRef() { return m_aMutexHolder; }
134 void ConnectTo( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xInStream );
136 // XInitialization
137 virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
138 throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
139 // XHierarchicalNameAccess
140 virtual ::com::sun::star::uno::Any SAL_CALL getByHierarchicalName( const ::rtl::OUString& aName )
141 throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
142 virtual sal_Bool SAL_CALL hasByHierarchicalName( const ::rtl::OUString& aName )
143 throw(::com::sun::star::uno::RuntimeException);
144 // XSingleServiceFactory
145 virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstance( )
146 throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
147 virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstanceWithArguments( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
148 throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
149 // XChangesBatch
150 virtual void SAL_CALL commitChanges( )
151 throw(::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
152 virtual sal_Bool SAL_CALL hasPendingChanges( )
153 throw(::com::sun::star::uno::RuntimeException);
154 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::util::ElementChange > SAL_CALL getPendingChanges( )
155 throw(::com::sun::star::uno::RuntimeException);
156 // XUnoTunnel
157 virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier )
158 throw(::com::sun::star::uno::RuntimeException);
159 com::sun::star::uno::Sequence < sal_Int8 > getUnoTunnelImplementationId( void )
160 throw(::com::sun::star::uno::RuntimeException);
161 // XPropertySet
162 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( )
163 throw(::com::sun::star::uno::RuntimeException);
164 virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue )
165 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);
166 virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName )
167 throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
168 virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener )
169 throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
170 virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener )
171 throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
172 virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener )
173 throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
174 virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener )
175 throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
177 // XServiceInfo
178 virtual ::rtl::OUString SAL_CALL getImplementationName( )
179 throw (::com::sun::star::uno::RuntimeException);
180 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
181 throw (::com::sun::star::uno::RuntimeException);
182 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( )
183 throw (::com::sun::star::uno::RuntimeException);
185 // Uno componentiseralation
186 static ::rtl::OUString static_getImplementationName();
187 static ::com::sun::star::uno::Sequence < ::rtl::OUString > static_getSupportedServiceNames();
188 static ::com::sun::star::uno::Reference < com::sun::star::lang::XSingleServiceFactory > createServiceFactory( com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory > const & rServiceFactory );
189 sal_Bool SAL_CALL static_supportsService(rtl::OUString const & rServiceName);
191 #endif