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
22 #include <com/sun/star/lang/IllegalArgumentException.hpp>
23 #include <com/sun/star/io/XSeekable.hpp>
24 #include <com/sun/star/io/XInputStream.hpp>
25 #include <com/sun/star/io/XOutputStream.hpp>
26 #include <com/sun/star/xml/crypto/XCipherContext.hpp>
28 #include <cppuhelper/implbase1.hxx>
29 #include <rtl/ref.hxx>
30 #include <package/Inflater.hxx>
31 #include <ZipEntry.hxx>
33 #include <mutexholder.hxx>
35 namespace com
{ namespace sun
{ namespace star
{ namespace 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
: public cppu::WeakImplHelper1
46 com::sun::star::io::XInputStream
50 SotMutexHolderRef maMutexHolder
;
52 com::sun::star::uno::Reference
< com::sun::star::io::XInputStream
> mxZipStream
;
53 com::sun::star::uno::Reference
< com::sun::star::io::XSeekable
> mxZipSeek
;
54 com::sun::star::uno::Sequence
< sal_Int8
> maCompBuffer
, maHeader
;
56 ::rtl::Reference
< EncryptionData
> mxData
;
57 sal_Int32 mnBlockSize
;
58 ::com::sun::star::uno::Reference
< ::com::sun::star::xml::crypto::XCipherContext
> m_xCipherContext
;
59 ZipUtils::Inflater maInflater
;
60 bool mbRawStream
, mbWrappedRaw
, mbFinished
;
61 sal_Int16 mnHeaderToRead
;
62 sal_Int64 mnZipCurrent
, mnZipEnd
, mnZipSize
, mnMyCurrent
;
68 const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>& xContext
,
69 SotMutexHolderRef aMutexHolder
,
71 com::sun::star::uno::Reference
< com::sun::star::io::XInputStream
> xNewZipStream
,
72 const ::rtl::Reference
< EncryptionData
>& rData
,
75 const OUString
& aMediaType
,
78 // allows to read package raw stream
80 const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>& xContext
,
81 const com::sun::star::uno::Reference
< com::sun::star::io::XInputStream
>& xRawStream
,
82 const ::rtl::Reference
< EncryptionData
>& rData
);
84 virtual ~XUnbufferedStream();
87 virtual sal_Int32 SAL_CALL
readBytes( ::com::sun::star::uno::Sequence
< sal_Int8
>& aData
, sal_Int32 nBytesToRead
)
88 throw(::com::sun::star::io::NotConnectedException
, ::com::sun::star::io::BufferSizeExceededException
, ::com::sun::star::io::IOException
, ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
89 virtual sal_Int32 SAL_CALL
readSomeBytes( ::com::sun::star::uno::Sequence
< sal_Int8
>& aData
, sal_Int32 nMaxBytesToRead
)
90 throw(::com::sun::star::io::NotConnectedException
, ::com::sun::star::io::BufferSizeExceededException
, ::com::sun::star::io::IOException
, ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
91 virtual void SAL_CALL
skipBytes( sal_Int32 nBytesToSkip
)
92 throw(::com::sun::star::io::NotConnectedException
, ::com::sun::star::io::BufferSizeExceededException
, ::com::sun::star::io::IOException
, ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
93 virtual sal_Int32 SAL_CALL
available( )
94 throw(::com::sun::star::io::NotConnectedException
, ::com::sun::star::io::IOException
, ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
95 virtual void SAL_CALL
closeInput( )
96 throw(::com::sun::star::io::NotConnectedException
, ::com::sun::star::io::IOException
, ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
99 virtual void SAL_CALL seek( sal_Int64 location )
100 throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
101 virtual sal_Int64 SAL_CALL getPosition( )
102 throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
103 virtual sal_Int64 SAL_CALL getLength( )
104 throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
109 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */