bump product version to 4.1.6.2
[LibreOffice.git] / package / inc / ZipOutputStream.hxx
blobd14d53eac6a4f37ffbeebe196c6ef2684e9b1126
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef _ZIP_OUTPUT_STREAM_HXX
20 #define _ZIP_OUTPUT_STREAM_HXX
22 #include <com/sun/star/uno/Reference.hxx>
23 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
24 #include <com/sun/star/io/XOutputStream.hpp>
25 #include <com/sun/star/xml/crypto/XCipherContext.hpp>
26 #include <com/sun/star/xml/crypto/XDigestContext.hpp>
28 #include <package/Deflater.hxx>
29 #include <ByteChucker.hxx>
30 #include <CRC32.hxx>
32 #include <vector>
34 struct ZipEntry;
35 class ZipPackageStream;
36 namespace rtl
38 template < class T > class Reference;
41 class ZipOutputStream
43 protected:
44 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext> m_xContext;
45 ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > xStream;
47 ::std::vector < ZipEntry * > aZipList;
49 ::com::sun::star::uno::Sequence< sal_Int8 > m_aDeflateBuffer;
51 OUString sComment;
52 ZipUtils::Deflater aDeflater;
54 ::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XCipherContext > m_xCipherContext;
55 ::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XDigestContext > m_xDigestContext;
57 CRC32 aCRC;
58 ByteChucker aChucker;
59 ZipEntry *pCurrentEntry;
60 sal_Int16 nMethod, nLevel, mnDigested;
61 sal_Bool bFinished, bEncryptCurrentEntry;
62 ZipPackageStream* m_pCurrentStream;
64 public:
65 ZipOutputStream(
66 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext,
67 const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > &xOStream );
68 ~ZipOutputStream();
70 // rawWrite to support a direct write to the output stream
71 void SAL_CALL rawWrite( ::com::sun::star::uno::Sequence< sal_Int8 >& rBuffer, sal_Int32 nNewOffset, sal_Int32 nNewLength )
72 throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
73 void SAL_CALL rawCloseEntry( )
74 throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
76 // XZipOutputStream interfaces
77 void SAL_CALL setMethod( sal_Int32 nNewMethod )
78 throw(::com::sun::star::uno::RuntimeException);
79 void SAL_CALL setLevel( sal_Int32 nNewLevel )
80 throw(::com::sun::star::uno::RuntimeException);
81 void SAL_CALL putNextEntry( ZipEntry& rEntry,
82 ZipPackageStream* pStream,
83 sal_Bool bEncrypt = sal_False )
84 throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
85 void SAL_CALL closeEntry( )
86 throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
87 void SAL_CALL write( const ::com::sun::star::uno::Sequence< sal_Int8 >& rBuffer, sal_Int32 nNewOffset, sal_Int32 nNewLength )
88 throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
89 void SAL_CALL finish( )
90 throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
91 static sal_uInt32 getCurrentDosTime ( );
92 protected:
93 void doDeflate();
94 void writeEND(sal_uInt32 nOffset, sal_uInt32 nLength)
95 throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
96 void writeCEN( const ZipEntry &rEntry )
97 throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
98 void writeEXT( const ZipEntry &rEntry )
99 throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
100 sal_Int32 writeLOC( const ZipEntry &rEntry )
101 throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
104 #endif
106 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */