lok: vcl: fix multiple floatwin removal case more robustly.
[LibreOffice.git] / package / inc / ZipOutputEntry.hxx
blob15c94aecc14bc46290a626e84d629b847c784cd3
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 INCLUDED_PACKAGE_INC_ZIPOUTPUTENTRY_HXX
20 #define INCLUDED_PACKAGE_INC_ZIPOUTPUTENTRY_HXX
22 #include <com/sun/star/io/XOutputStream.hpp>
23 #include <com/sun/star/io/XTempFile.hpp>
24 #include <com/sun/star/uno/Reference.hxx>
25 #include <com/sun/star/uno/XComponentContext.hpp>
26 #include <com/sun/star/xml/crypto/XCipherContext.hpp>
27 #include <com/sun/star/xml/crypto/XDigestContext.hpp>
29 #include <package/Deflater.hxx>
30 #include "CRC32.hxx"
31 #include <atomic>
33 struct ZipEntry;
34 class ZipPackageBuffer;
35 class ZipPackageStream;
37 class ZipOutputEntry
39 // allow only DeflateThread to change m_bFinished using setFinished()
40 friend class DeflateThread;
42 css::uno::Sequence< sal_Int8 > m_aDeflateBuffer;
43 ZipUtils::Deflater m_aDeflater;
44 css::uno::Reference< css::uno::XComponentContext > m_xContext;
45 OUString m_aTempURL;
46 css::uno::Reference< css::io::XOutputStream > m_xOutStream;
48 css::uno::Reference< css::xml::crypto::XCipherContext > m_xCipherContext;
49 css::uno::Reference< css::xml::crypto::XDigestContext > m_xDigestContext;
50 std::exception_ptr m_aParallelDeflateException;
52 CRC32 m_aCRC;
53 ZipEntry *m_pCurrentEntry;
54 sal_Int16 m_nDigested;
55 ZipPackageStream* m_pCurrentStream;
56 bool const m_bEncryptCurrentEntry;
57 std::atomic<bool> m_bFinished;
59 public:
60 ZipOutputEntry(
61 const css::uno::Reference< css::io::XOutputStream >& rxOutStream,
62 const css::uno::Reference< css::uno::XComponentContext >& rxContext,
63 ZipEntry& rEntry, ZipPackageStream* pStream, bool bEncrypt);
65 ~ZipOutputEntry();
67 /* This block of methods is for threaded zipping, where we compress to a temp stream, whose
68 data is retrieved via getData */
69 ZipOutputEntry(
70 const css::uno::Reference< css::uno::XComponentContext >& rxContext,
71 ZipEntry& rEntry, ZipPackageStream* pStream, bool bEncrypt);
72 void createBufferFile();
73 void setParallelDeflateException(const std::exception_ptr& exception) { m_aParallelDeflateException = exception; }
74 css::uno::Reference< css::io::XInputStream > getData() const;
75 const std::exception_ptr& getParallelDeflateException() const { return m_aParallelDeflateException; }
76 void closeBufferFile();
77 void deleteBufferFile();
79 ZipEntry* getZipEntry() { return m_pCurrentEntry; }
80 ZipPackageStream* getZipPackageStream() { return m_pCurrentStream; }
81 bool isEncrypt() { return m_bEncryptCurrentEntry; }
83 void closeEntry();
84 void write(const css::uno::Sequence< sal_Int8 >& rBuffer);
86 bool isFinished() const { return m_bFinished; }
88 private:
89 void setFinished() { m_bFinished = true; }
90 void doDeflate();
93 #endif
95 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */