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 _XUNBUFFERED_STREAM_HXX
20 #define _XUNBUFFERED_STREAM_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 #define UNBUFF_STREAM_DATA 0
36 #define UNBUFF_STREAM_RAW 1
37 #define UNBUFF_STREAM_WRAPPEDRAW 2
40 class XUnbufferedStream
: public cppu::WeakImplHelper1
42 com::sun::star::io::XInputStream
46 SotMutexHolderRef maMutexHolder
;
48 com::sun::star::uno::Reference
< com::sun::star::io::XInputStream
> mxZipStream
;
49 com::sun::star::uno::Reference
< com::sun::star::io::XSeekable
> mxZipSeek
;
50 com::sun::star::uno::Sequence
< sal_Int8
> maCompBuffer
, maHeader
;
52 ::rtl::Reference
< EncryptionData
> mxData
;
53 sal_Int32 mnBlockSize
;
54 ::com::sun::star::uno::Reference
< ::com::sun::star::xml::crypto::XCipherContext
> m_xCipherContext
;
55 ZipUtils::Inflater maInflater
;
56 sal_Bool mbRawStream
, mbWrappedRaw
, mbFinished
;
57 sal_Int16 mnHeaderToRead
;
58 sal_Int64 mnZipCurrent
, mnZipEnd
, mnZipSize
, mnMyCurrent
;
64 const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>& xContext
,
65 SotMutexHolderRef aMutexHolder
,
67 com::sun::star::uno::Reference
< com::sun::star::io::XInputStream
> xNewZipStream
,
68 const ::rtl::Reference
< EncryptionData
>& rData
,
70 sal_Bool bIsEncrypted
,
71 const OUString
& aMediaType
,
72 sal_Bool bRecoveryMode
);
74 // allows to read package raw stream
76 const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>& xContext
,
77 const com::sun::star::uno::Reference
< com::sun::star::io::XInputStream
>& xRawStream
,
78 const ::rtl::Reference
< EncryptionData
>& rData
);
81 virtual ~XUnbufferedStream();
84 virtual sal_Int32 SAL_CALL
readBytes( ::com::sun::star::uno::Sequence
< sal_Int8
>& aData
, sal_Int32 nBytesToRead
)
85 throw(::com::sun::star::io::NotConnectedException
, ::com::sun::star::io::BufferSizeExceededException
, ::com::sun::star::io::IOException
, ::com::sun::star::uno::RuntimeException
);
86 virtual sal_Int32 SAL_CALL
readSomeBytes( ::com::sun::star::uno::Sequence
< sal_Int8
>& aData
, sal_Int32 nMaxBytesToRead
)
87 throw(::com::sun::star::io::NotConnectedException
, ::com::sun::star::io::BufferSizeExceededException
, ::com::sun::star::io::IOException
, ::com::sun::star::uno::RuntimeException
);
88 virtual void SAL_CALL
skipBytes( sal_Int32 nBytesToSkip
)
89 throw(::com::sun::star::io::NotConnectedException
, ::com::sun::star::io::BufferSizeExceededException
, ::com::sun::star::io::IOException
, ::com::sun::star::uno::RuntimeException
);
90 virtual sal_Int32 SAL_CALL
available( )
91 throw(::com::sun::star::io::NotConnectedException
, ::com::sun::star::io::IOException
, ::com::sun::star::uno::RuntimeException
);
92 virtual void SAL_CALL
closeInput( )
93 throw(::com::sun::star::io::NotConnectedException
, ::com::sun::star::io::IOException
, ::com::sun::star::uno::RuntimeException
);
96 virtual void SAL_CALL seek( sal_Int64 location )
97 throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
98 virtual sal_Int64 SAL_CALL getPosition( )
99 throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
100 virtual sal_Int64 SAL_CALL getLength( )
101 throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
106 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */