1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 INCLUDED_PACKAGE_INC_ZIPOUTPUTSTREAM_HXX
20 #define INCLUDED_PACKAGE_INC_ZIPOUTPUTSTREAM_HXX
22 #include <com/sun/star/uno/Reference.hxx>
23 #include <com/sun/star/io/XOutputStream.hpp>
25 #include <ByteChucker.hxx>
26 #include <comphelper/threadpool.hxx>
32 class ZipPackageStream
;
36 css::uno::Reference
< css::io::XOutputStream
> m_xStream
;
37 ::std::vector
< ZipEntry
* > m_aZipList
;
38 std::shared_ptr
<comphelper::ThreadTaskTag
> mpThreadTaskTag
;
40 ByteChucker m_aChucker
;
41 ZipEntry
*m_pCurrentEntry
;
42 std::vector
< ZipOutputEntry
* > m_aEntries
;
43 ::css::uno::Any m_aDeflateException
;
47 const css::uno::Reference
< css::io::XOutputStream
> &xOStream
);
50 void addDeflatingThread( ZipOutputEntry
*pEntry
, comphelper::ThreadTask
*pThreadTask
);
52 /// @throws css::io::IOException
53 /// @throws css::uno::RuntimeException
54 void writeLOC( ZipEntry
*pEntry
, bool bEncrypt
= false );
55 /// @throws css::io::IOException
56 /// @throws css::uno::RuntimeException
57 void rawWrite( const css::uno::Sequence
< sal_Int8
>& rBuffer
);
58 /// @throws css::io::IOException
59 /// @throws css::uno::RuntimeException
60 void rawCloseEntry( bool bEncrypt
= false );
62 /// @throws css::io::IOException
63 /// @throws css::uno::RuntimeException
65 const css::uno::Reference
< css::io::XOutputStream
>& getStream();
67 static sal_uInt32
getCurrentDosTime();
68 static void setEntry( ZipEntry
*pEntry
);
71 /// @throws css::io::IOException
72 /// @throws css::uno::RuntimeException
73 void writeEND(sal_uInt32 nOffset
, sal_uInt32 nLength
);
74 /// @throws css::io::IOException
75 /// @throws css::uno::RuntimeException
76 void writeCEN( const ZipEntry
&rEntry
);
77 /// @throws css::io::IOException
78 /// @throws css::uno::RuntimeException
79 void writeEXT( const ZipEntry
&rEntry
);
81 // ScheduledThread handling helpers
82 void consumeScheduledThreadEntry(ZipOutputEntry
* pCandidate
);
83 void consumeFinishedScheduledThreadEntries();
86 void reduceScheduledThreadsToGivenNumberOrLess(
89 const std::shared_ptr
<comphelper::ThreadTaskTag
>& getThreadTaskTag() { return mpThreadTaskTag
; }
94 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */