update dev300-m58
[ooovba.git] / package / inc / ZipOutputStream.hxx
blob58504880ca946a725024e93c44f58029e67047c7
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: ZipOutputStream.hxx,v $
10 * $Revision: 1.25 $
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_OUTPUT_STREAM_HXX
31 #define _ZIP_OUTPUT_STREAM_HXX
33 #include <ByteChucker.hxx>
34 #ifndef _DEFLATER_HXX
35 #include <Deflater.hxx>
36 #endif
37 #include <CRC32.hxx>
38 #include <rtl/cipher.h>
39 #ifndef RTL_DIGEST_H_
40 #include <rtl/digest.h>
41 #endif
43 #include <vector>
45 struct ZipEntry;
46 class EncryptionData;
47 namespace vos
49 template < class T > class ORef;
51 class ZipOutputStream
53 protected:
54 com::sun::star::uno::Reference < com::sun::star::io::XOutputStream > xStream;
55 ::std::vector < ZipEntry * > aZipList;
56 com::sun::star::uno::Sequence < sal_Int8 > aBuffer, aEncryptionBuffer;
57 ::rtl::OUString sComment;
58 Deflater aDeflater;
59 rtlCipher aCipher;
60 rtlDigest aDigest;
61 CRC32 aCRC;
62 ByteChucker aChucker;
63 ZipEntry *pCurrentEntry;
64 sal_Int16 nMethod, nLevel, mnDigested;
65 sal_Bool bFinished, bEncryptCurrentEntry;
66 EncryptionData *pCurrentEncryptData;
68 public:
69 ZipOutputStream( com::sun::star::uno::Reference < com::sun::star::io::XOutputStream > &xOStream );
70 ~ZipOutputStream();
72 // rawWrite to support a direct write to the output stream
73 void SAL_CALL rawWrite( ::com::sun::star::uno::Sequence< sal_Int8 >& rBuffer, sal_Int32 nNewOffset, sal_Int32 nNewLength )
74 throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
75 void SAL_CALL rawCloseEntry( )
76 throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
78 // XZipOutputStream interfaces
79 void SAL_CALL setMethod( sal_Int32 nNewMethod )
80 throw(::com::sun::star::uno::RuntimeException);
81 void SAL_CALL setLevel( sal_Int32 nNewLevel )
82 throw(::com::sun::star::uno::RuntimeException);
83 void SAL_CALL putNextEntry( ZipEntry& rEntry,
84 vos::ORef < EncryptionData > &rData,
85 sal_Bool bEncrypt = sal_False )
86 throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
87 void SAL_CALL closeEntry( )
88 throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
89 void SAL_CALL write( const ::com::sun::star::uno::Sequence< sal_Int8 >& rBuffer, sal_Int32 nNewOffset, sal_Int32 nNewLength )
90 throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
91 void SAL_CALL finish( )
92 throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
93 static sal_uInt32 getCurrentDosTime ( );
94 protected:
95 void doDeflate();
96 void writeEND(sal_uInt32 nOffset, sal_uInt32 nLength)
97 throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
98 void writeCEN( const ZipEntry &rEntry )
99 throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
100 void writeEXT( const ZipEntry &rEntry )
101 throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
102 sal_Int32 writeLOC( const ZipEntry &rEntry )
103 throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
106 #endif