fix toolbar import
[ooovba.git] / package / inc / ZipPackage.hxx
blob4c9064b7c39c6b4667c9f415d8383436d91b9e3f
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 #ifndef _COM_SUN_STAR_LANG_XPSERVICEINFO_HPP_
41 #include <com/sun/star/lang/XServiceInfo.hpp>
42 #endif
43 #include <HashMaps.hxx>
44 #include <com/sun/star/lang/IllegalArgumentException.hpp>
45 #include <osl/file.h>
46 class ZipOutputStream;
47 class ZipPackageFolder;
48 class ZipFile;
49 class ByteGrabber;
50 namespace com { namespace sun { namespace star {
51 namespace container { class XNameContainer; }
52 namespace io { class XStream; class XOutputStream; class XInputStream; class XSeekable; class XActiveDataStreamer; }
53 namespace lang { class XMultiServiceFactory; }
54 namespace task { class XInteractionHandler; }
55 } } }
56 enum SegmentEnum
58 e_Aborted = -1000,
59 e_Retry,
60 e_Finished,
61 e_Success = 0
64 enum InitialisationMode
66 e_IMode_None,
67 e_IMode_URL,
68 e_IMode_XInputStream,
69 e_IMode_XStream
72 class ZipPackage : public cppu::WeakImplHelper7
74 com::sun::star::lang::XInitialization,
75 com::sun::star::lang::XSingleServiceFactory,
76 com::sun::star::lang::XUnoTunnel,
77 com::sun::star::lang::XServiceInfo,
78 com::sun::star::container::XHierarchicalNameAccess,
79 com::sun::star::util::XChangesBatch,
80 com::sun::star::beans::XPropertySet
83 protected:
84 ::com::sun::star::uno::Sequence < sal_Int8 > aEncryptionKey;
85 FolderHash aRecent;
86 ::rtl::OUString sURL;
87 sal_Bool bHasEncryptedEntries;
88 sal_Bool bUseManifest;
89 sal_Bool bForceRecovery;
91 sal_Bool m_bMediaTypeFallbackUsed;
92 sal_Int16 m_nFormat;
93 sal_Bool m_bAllowRemoveOnInsert;
95 InitialisationMode eMode;
97 ::com::sun::star::uno::Reference < com::sun::star::container::XNameContainer > xRootFolder;
98 ::com::sun::star::uno::Reference < com::sun::star::io::XStream > xStream;
99 ::com::sun::star::uno::Reference < com::sun::star::io::XInputStream > xContentStream;
100 ::com::sun::star::uno::Reference < com::sun::star::io::XSeekable > xContentSeek;
101 const ::com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory > xFactory;
103 ZipPackageFolder *pRootFolder;
104 ZipFile *pZipFile;
106 void parseManifest();
107 void parseContentType();
108 void getZipFileContents();
109 sal_Bool writeFileIsTemp();
110 ::com::sun::star::uno::Reference < ::com::sun::star::io::XActiveDataStreamer > openOriginalForOutput();
111 void WriteMimetypeMagicFile( ZipOutputStream& aZipOut );
112 void DisconnectFromTargetAndThrowException_Impl(
113 const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xTempStream );
115 public:
116 ZipPackage (const ::com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory > &xNewFactory);
117 virtual ~ZipPackage( void );
118 ZipFile& getZipFile() { return *pZipFile;}
119 const com::sun::star::uno::Sequence < sal_Int8 > & getEncryptionKey ( ) {return aEncryptionKey;}
120 sal_Int16 getFormat() const { return m_nFormat; }
122 // XInitialization
123 virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
124 throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
125 // XHierarchicalNameAccess
126 virtual ::com::sun::star::uno::Any SAL_CALL getByHierarchicalName( const ::rtl::OUString& aName )
127 throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
128 virtual sal_Bool SAL_CALL hasByHierarchicalName( const ::rtl::OUString& aName )
129 throw(::com::sun::star::uno::RuntimeException);
130 // XSingleServiceFactory
131 virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstance( )
132 throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
133 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 )
134 throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
135 // XChangesBatch
136 virtual void SAL_CALL commitChanges( )
137 throw(::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
138 virtual sal_Bool SAL_CALL hasPendingChanges( )
139 throw(::com::sun::star::uno::RuntimeException);
140 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::util::ElementChange > SAL_CALL getPendingChanges( )
141 throw(::com::sun::star::uno::RuntimeException);
142 // XUnoTunnel
143 virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier )
144 throw(::com::sun::star::uno::RuntimeException);
145 com::sun::star::uno::Sequence < sal_Int8 > getUnoTunnelImplementationId( void )
146 throw(::com::sun::star::uno::RuntimeException);
147 // XPropertySet
148 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( )
149 throw(::com::sun::star::uno::RuntimeException);
150 virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue )
151 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);
152 virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName )
153 throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
154 virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener )
155 throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
156 virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener )
157 throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
158 virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener )
159 throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
160 virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener )
161 throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
163 // XServiceInfo
164 virtual ::rtl::OUString SAL_CALL getImplementationName( )
165 throw (::com::sun::star::uno::RuntimeException);
166 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
167 throw (::com::sun::star::uno::RuntimeException);
168 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( )
169 throw (::com::sun::star::uno::RuntimeException);
171 // Uno componentiseralation
172 static ::rtl::OUString static_getImplementationName();
173 static ::com::sun::star::uno::Sequence < ::rtl::OUString > static_getSupportedServiceNames();
174 static ::com::sun::star::uno::Reference < com::sun::star::lang::XSingleServiceFactory > createServiceFactory( com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory > const & rServiceFactory );
175 sal_Bool SAL_CALL static_supportsService(rtl::OUString const & rServiceName);
177 #endif