2010-10-27 12:45:03 +01:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-06-22 18:32:07 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2014-04-18 22:14:30 +02:00
|
|
|
#ifndef INCLUDED_PACKAGE_SOURCE_ZIPAPI_XUNBUFFEREDSTREAM_HXX
|
|
|
|
#define INCLUDED_PACKAGE_SOURCE_ZIPAPI_XUNBUFFEREDSTREAM_HXX
|
2001-12-04 16:45:30 +00:00
|
|
|
|
|
|
|
#include <com/sun/star/lang/IllegalArgumentException.hpp>
|
|
|
|
#include <com/sun/star/io/XSeekable.hpp>
|
|
|
|
#include <com/sun/star/io/XInputStream.hpp>
|
|
|
|
#include <com/sun/star/io/XOutputStream.hpp>
|
2011-08-21 18:12:16 -05:00
|
|
|
#include <com/sun/star/xml/crypto/XCipherContext.hpp>
|
|
|
|
|
2017-06-19 17:06:34 +02:00
|
|
|
#include <comphelper/refcountedmutex.hxx>
|
2015-08-25 16:10:12 +09:00
|
|
|
#include <cppuhelper/implbase.hxx>
|
2010-10-15 12:18:51 -05:00
|
|
|
#include <rtl/ref.hxx>
|
2011-08-26 14:04:17 +02:00
|
|
|
#include <package/Inflater.hxx>
|
2001-12-04 16:45:30 +00:00
|
|
|
#include <ZipEntry.hxx>
|
2003-03-26 13:16:07 +00:00
|
|
|
#include <CRC32.hxx>
|
2001-12-04 16:45:30 +00:00
|
|
|
|
2013-12-17 16:15:48 +01:00
|
|
|
namespace com { namespace sun { namespace star { namespace uno {
|
|
|
|
class XComponentContext;
|
|
|
|
} } } }
|
|
|
|
|
2003-09-11 09:17:08 +00:00
|
|
|
#define UNBUFF_STREAM_DATA 0
|
|
|
|
#define UNBUFF_STREAM_RAW 1
|
|
|
|
#define UNBUFF_STREAM_WRAPPEDRAW 2
|
|
|
|
|
2001-12-04 16:45:30 +00:00
|
|
|
class EncryptionData;
|
2017-10-31 14:15:25 +02:00
|
|
|
class XUnbufferedStream final : public cppu::WeakImplHelper
|
2001-12-04 16:45:30 +00:00
|
|
|
<
|
2015-10-23 14:59:15 +02:00
|
|
|
css::io::XInputStream
|
2001-12-04 16:45:30 +00:00
|
|
|
>
|
|
|
|
{
|
2017-06-19 17:06:34 +02:00
|
|
|
rtl::Reference<comphelper::RefCountedMutex> maMutexHolder;
|
2009-09-08 08:54:47 +00:00
|
|
|
|
2015-10-23 14:59:15 +02:00
|
|
|
css::uno::Reference < css::io::XInputStream > mxZipStream;
|
|
|
|
css::uno::Reference < css::io::XSeekable > mxZipSeek;
|
|
|
|
css::uno::Sequence < sal_Int8 > maCompBuffer, maHeader;
|
2001-12-04 16:45:30 +00:00
|
|
|
ZipEntry maEntry;
|
2011-08-21 18:12:16 -05:00
|
|
|
sal_Int32 mnBlockSize;
|
2015-10-23 14:59:15 +02:00
|
|
|
css::uno::Reference< css::xml::crypto::XCipherContext > m_xCipherContext;
|
2011-03-29 14:18:56 +02:00
|
|
|
ZipUtils::Inflater maInflater;
|
2016-06-27 15:08:50 +02:00
|
|
|
bool mbRawStream, mbWrappedRaw;
|
2001-12-04 16:45:30 +00:00
|
|
|
sal_Int16 mnHeaderToRead;
|
|
|
|
sal_Int64 mnZipCurrent, mnZipEnd, mnZipSize, mnMyCurrent;
|
2003-03-26 13:16:07 +00:00
|
|
|
CRC32 maCRC;
|
2014-04-17 13:40:46 +02:00
|
|
|
bool mbCheckCRC;
|
2001-12-04 16:45:30 +00:00
|
|
|
|
|
|
|
public:
|
2009-09-08 08:54:47 +00:00
|
|
|
XUnbufferedStream(
|
2015-10-23 14:59:15 +02:00
|
|
|
const css::uno::Reference< css::uno::XComponentContext >& xContext,
|
2017-06-19 17:06:34 +02:00
|
|
|
const rtl::Reference<comphelper::RefCountedMutex>& aMutexHolder,
|
2017-11-02 12:09:52 +02:00
|
|
|
ZipEntry const & rEntry,
|
2016-07-07 15:57:48 +02:00
|
|
|
css::uno::Reference < css::io::XInputStream > const & xNewZipStream,
|
2011-08-21 18:12:16 -05:00
|
|
|
const ::rtl::Reference< EncryptionData >& rData,
|
2003-09-11 09:17:08 +00:00
|
|
|
sal_Int8 nStreamMode,
|
2014-04-17 13:40:46 +02:00
|
|
|
bool bIsEncrypted,
|
2013-04-07 12:06:47 +02:00
|
|
|
const OUString& aMediaType,
|
2014-04-17 13:40:46 +02:00
|
|
|
bool bRecoveryMode );
|
2003-09-11 09:17:08 +00:00
|
|
|
|
|
|
|
// allows to read package raw stream
|
2011-08-21 18:12:16 -05:00
|
|
|
XUnbufferedStream(
|
2017-06-19 17:06:34 +02:00
|
|
|
const rtl::Reference<comphelper::RefCountedMutex>& aMutexHolder,
|
2015-10-23 14:59:15 +02:00
|
|
|
const css::uno::Reference < css::io::XInputStream >& xRawStream,
|
2011-08-21 18:12:16 -05:00
|
|
|
const ::rtl::Reference< EncryptionData >& rData );
|
2003-09-11 09:17:08 +00:00
|
|
|
|
2017-07-05 17:30:27 +01:00
|
|
|
sal_Int64 getSize() { return mnZipSize; }
|
|
|
|
|
2016-09-13 13:09:01 +02:00
|
|
|
virtual ~XUnbufferedStream() override;
|
2001-12-04 16:45:30 +00:00
|
|
|
|
|
|
|
// XInputStream
|
2017-01-26 12:28:58 +01:00
|
|
|
virtual sal_Int32 SAL_CALL readBytes( css::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead ) override;
|
|
|
|
virtual sal_Int32 SAL_CALL readSomeBytes( css::uno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead ) override;
|
|
|
|
virtual void SAL_CALL skipBytes( sal_Int32 nBytesToSkip ) override;
|
|
|
|
virtual sal_Int32 SAL_CALL available( ) override;
|
|
|
|
virtual void SAL_CALL closeInput( ) override;
|
2001-12-04 16:45:30 +00:00
|
|
|
};
|
|
|
|
#endif
|
2010-10-27 12:45:03 +01:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|