/src/libreoffice/package/source/zipapi/XUnbufferedStream.hxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
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/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
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 . |
18 | | */ |
19 | | #ifndef INCLUDED_PACKAGE_SOURCE_ZIPAPI_XUNBUFFEREDSTREAM_HXX |
20 | | #define INCLUDED_PACKAGE_SOURCE_ZIPAPI_XUNBUFFEREDSTREAM_HXX |
21 | | |
22 | | #include <optional> |
23 | | |
24 | | #include <com/sun/star/io/XSeekable.hpp> |
25 | | #include <com/sun/star/io/XInputStream.hpp> |
26 | | #include <com/sun/star/xml/crypto/XCipherContext.hpp> |
27 | | |
28 | | #include <comphelper/refcountedmutex.hxx> |
29 | | #include <cppuhelper/implbase.hxx> |
30 | | #include <rtl/ref.hxx> |
31 | | #include <package/Inflater.hxx> |
32 | | #include <memory> |
33 | | #include <ZipEntry.hxx> |
34 | | #include <CRC32.hxx> |
35 | | |
36 | | namespace com::sun::star::uno { |
37 | | class XComponentContext; |
38 | | } |
39 | | |
40 | 890k | #define UNBUFF_STREAM_DATA 0 |
41 | 423k | #define UNBUFF_STREAM_RAW 1 |
42 | 422k | #define UNBUFF_STREAM_WRAPPEDRAW 2 |
43 | | |
44 | | class EncryptionData; |
45 | | class XUnbufferedStream final : public cppu::WeakImplHelper |
46 | | < |
47 | | css::io::XInputStream |
48 | | > |
49 | | { |
50 | | rtl::Reference<comphelper::RefCountedMutex> maMutexHolder; |
51 | | |
52 | | css::uno::Reference < css::io::XInputStream > mxZipStream; |
53 | | css::uno::Reference < css::io::XSeekable > mxZipSeek; |
54 | | css::uno::Sequence < sal_Int8 > maCompBuffer, maHeader; |
55 | | ZipEntry maEntry; |
56 | | sal_Int32 mnBlockSize; |
57 | | css::uno::Reference< css::xml::crypto::XCipherContext > m_xCipherContext; |
58 | | std::unique_ptr<ZipUtils::Inflater> maInflater; |
59 | | bool mbRawStream, mbWrappedRaw; |
60 | | sal_Int16 mnHeaderToRead; |
61 | | sal_Int64 mnZipCurrent, mnZipEnd, mnZipSize, mnMyCurrent; |
62 | | CRC32 maCRC; |
63 | | bool mbCheckCRC; |
64 | | |
65 | | public: |
66 | | XUnbufferedStream( |
67 | | const css::uno::Reference< css::uno::XComponentContext >& xContext, |
68 | | rtl::Reference<comphelper::RefCountedMutex> aMutexHolder, |
69 | | ZipEntry const & rEntry, |
70 | | css::uno::Reference < css::io::XInputStream > const & xNewZipStream, |
71 | | const ::rtl::Reference< EncryptionData >& rData, |
72 | | sal_Int8 nStreamMode, |
73 | | ::std::optional<sal_Int64> oDecryptedSize, |
74 | | const OUString& aMediaType, |
75 | | bool bRecoveryMode ); |
76 | | |
77 | | // allows to read package raw stream |
78 | | XUnbufferedStream( |
79 | | rtl::Reference<comphelper::RefCountedMutex> aMutexHolder, |
80 | | const css::uno::Reference < css::io::XInputStream >& xRawStream, |
81 | | const ::rtl::Reference< EncryptionData >& rData ); |
82 | | |
83 | 22.6k | sal_Int64 getSize() const { return mnZipSize; } |
84 | | |
85 | | virtual ~XUnbufferedStream() override; |
86 | | |
87 | | // XInputStream |
88 | | virtual sal_Int32 SAL_CALL readBytes( css::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead ) override; |
89 | | virtual sal_Int32 SAL_CALL readSomeBytes( css::uno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead ) override; |
90 | | virtual void SAL_CALL skipBytes( sal_Int32 nBytesToSkip ) override; |
91 | | virtual sal_Int32 SAL_CALL available( ) override; |
92 | | virtual void SAL_CALL closeInput( ) override; |
93 | | }; |
94 | | #endif |
95 | | |
96 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |