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 ZipOutputEntryInThread
;
33 class ZipPackageStream
;
37 css::uno::Reference
< css::io::XOutputStream
> m_xStream
;
38 ::std::vector
< ZipEntry
* > m_aZipList
;
39 std::shared_ptr
<comphelper::ThreadTaskTag
> mpThreadTaskTag
;
41 ByteChucker m_aChucker
;
42 ZipEntry
*m_pCurrentEntry
;
43 std::vector
< ZipOutputEntryInThread
* > m_aEntries
;
44 std::exception_ptr m_aDeflateException
;
48 const css::uno::Reference
< css::io::XOutputStream
> &xOStream
);
51 void addDeflatingThreadTask( ZipOutputEntryInThread
*pEntry
, std::unique_ptr
<comphelper::ThreadTask
> pThreadTask
);
53 /// @throws css::io::IOException
54 /// @throws css::uno::RuntimeException
55 void writeLOC( ZipEntry
*pEntry
, bool bEncrypt
= false );
56 /// @throws css::io::IOException
57 /// @throws css::uno::RuntimeException
58 void rawWrite( const css::uno::Sequence
< sal_Int8
>& rBuffer
);
59 /// @throws css::io::IOException
60 /// @throws css::uno::RuntimeException
61 void rawCloseEntry( bool bEncrypt
= false );
63 /// @throws css::io::IOException
64 /// @throws css::uno::RuntimeException
66 const css::uno::Reference
< css::io::XOutputStream
>& getStream() const;
68 static sal_uInt32
getCurrentDosTime();
69 static void setEntry( ZipEntry
*pEntry
);
72 /// @throws css::io::IOException
73 /// @throws css::uno::RuntimeException
74 void writeEND(sal_uInt32 nOffset
, sal_uInt32 nLength
);
75 /// @throws css::io::IOException
76 /// @throws css::uno::RuntimeException
77 void writeCEN( const ZipEntry
&rEntry
);
78 /// @throws css::io::IOException
79 /// @throws css::uno::RuntimeException
80 void writeEXT( const ZipEntry
&rEntry
);
82 // ScheduledThread handling helpers
83 void consumeScheduledThreadTaskEntry(std::unique_ptr
<ZipOutputEntryInThread
> pCandidate
);
84 void consumeFinishedScheduledThreadTaskEntries();
87 void reduceScheduledThreadTasksToGivenNumberOrLess(
88 sal_Int32 nThreadTasks
);
90 const std::shared_ptr
<comphelper::ThreadTaskTag
>& getThreadTaskTag() const { return mpThreadTaskTag
; }
95 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */