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_SOURCE_ZIPAPI_XUNBUFFEREDSTREAM_HXX
20 #define INCLUDED_PACKAGE_SOURCE_ZIPAPI_XUNBUFFEREDSTREAM_HXX
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>
28 #include <comphelper/refcountedmutex.hxx>
29 #include <cppuhelper/implbase.hxx>
30 #include <rtl/ref.hxx>
31 #include <package/Inflater.hxx>
32 #include <ZipEntry.hxx>
35 namespace com::sun::star::uno
{
36 class XComponentContext
;
39 #define UNBUFF_STREAM_DATA 0
40 #define UNBUFF_STREAM_RAW 1
41 #define UNBUFF_STREAM_WRAPPEDRAW 2
44 class XUnbufferedStream final
: public cppu::WeakImplHelper
49 rtl::Reference
<comphelper::RefCountedMutex
> maMutexHolder
;
51 css::uno::Reference
< css::io::XInputStream
> mxZipStream
;
52 css::uno::Reference
< css::io::XSeekable
> mxZipSeek
;
53 css::uno::Sequence
< sal_Int8
> maCompBuffer
, maHeader
;
55 sal_Int32 mnBlockSize
;
56 css::uno::Reference
< css::xml::crypto::XCipherContext
> m_xCipherContext
;
57 ZipUtils::Inflater maInflater
;
58 bool mbRawStream
, mbWrappedRaw
;
59 sal_Int16 mnHeaderToRead
;
60 sal_Int64 mnZipCurrent
, mnZipEnd
, mnZipSize
, mnMyCurrent
;
66 const css::uno::Reference
< css::uno::XComponentContext
>& xContext
,
67 rtl::Reference
<comphelper::RefCountedMutex
> aMutexHolder
,
68 ZipEntry
const & rEntry
,
69 css::uno::Reference
< css::io::XInputStream
> const & xNewZipStream
,
70 const ::rtl::Reference
< EncryptionData
>& rData
,
72 ::std::optional
<sal_Int64
> oDecryptedSize
,
73 const OUString
& aMediaType
,
76 // allows to read package raw stream
78 rtl::Reference
<comphelper::RefCountedMutex
> aMutexHolder
,
79 const css::uno::Reference
< css::io::XInputStream
>& xRawStream
,
80 const ::rtl::Reference
< EncryptionData
>& rData
);
82 sal_Int64
getSize() const { return mnZipSize
; }
84 virtual ~XUnbufferedStream() override
;
87 virtual sal_Int32 SAL_CALL
readBytes( css::uno::Sequence
< sal_Int8
>& aData
, sal_Int32 nBytesToRead
) override
;
88 virtual sal_Int32 SAL_CALL
readSomeBytes( css::uno::Sequence
< sal_Int8
>& aData
, sal_Int32 nMaxBytesToRead
) override
;
89 virtual void SAL_CALL
skipBytes( sal_Int32 nBytesToSkip
) override
;
90 virtual sal_Int32 SAL_CALL
available( ) override
;
91 virtual void SAL_CALL
closeInput( ) override
;
95 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */