2010-10-12 15:57:08 +02: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 .
|
|
|
|
*/
|
2000-11-21 09:43:06 +00:00
|
|
|
|
2003-09-11 09:18:07 +00:00
|
|
|
#include <com/sun/star/packages/zip/ZipConstants.hpp>
|
2010-04-13 10:28:25 +02:00
|
|
|
#include <com/sun/star/embed/StorageFormats.hpp>
|
2003-09-11 09:18:07 +00:00
|
|
|
#include <com/sun/star/packages/zip/ZipIOException.hpp>
|
2012-08-23 17:23:26 +02:00
|
|
|
#include <com/sun/star/io/TempFile.hpp>
|
2004-02-03 17:26:32 +00:00
|
|
|
#include <com/sun/star/io/XInputStream.hpp>
|
|
|
|
#include <com/sun/star/io/XOutputStream.hpp>
|
|
|
|
#include <com/sun/star/io/XStream.hpp>
|
2003-09-11 09:18:07 +00:00
|
|
|
#include <com/sun/star/io/XSeekable.hpp>
|
2011-03-09 17:29:09 +01:00
|
|
|
#include <com/sun/star/xml/crypto/DigestID.hpp>
|
|
|
|
#include <com/sun/star/xml/crypto/CipherID.hpp>
|
2003-09-11 09:18:07 +00:00
|
|
|
|
2012-07-28 22:01:59 +02:00
|
|
|
#include <string.h>
|
2003-09-11 09:18:07 +00:00
|
|
|
|
2001-04-19 13:16:31 +00:00
|
|
|
#include <ZipPackageStream.hxx>
|
2001-04-27 13:56:07 +00:00
|
|
|
#include <ZipPackage.hxx>
|
2001-04-19 13:16:31 +00:00
|
|
|
#include <ZipFile.hxx>
|
2003-09-11 09:18:07 +00:00
|
|
|
#include <EncryptedDataHeader.hxx>
|
2010-10-10 19:46:46 -05:00
|
|
|
#include <osl/diagnose.h>
|
2004-02-03 17:26:32 +00:00
|
|
|
#include "wrapstreamforshare.hxx"
|
|
|
|
|
2012-09-19 13:15:15 +02:00
|
|
|
#include <comphelper/processfactory.hxx>
|
2004-05-10 16:29:52 +00:00
|
|
|
#include <comphelper/seekableinput.hxx>
|
2006-02-01 18:15:02 +00:00
|
|
|
#include <comphelper/storagehelper.hxx>
|
2013-10-26 14:22:21 -02:00
|
|
|
#include <cppuhelper/supportsservice.hxx>
|
2014-03-10 08:58:16 +01:00
|
|
|
#include <cppuhelper/typeprovider.hxx>
|
2004-05-10 16:29:52 +00:00
|
|
|
|
2010-10-11 09:29:20 +01:00
|
|
|
#include <rtl/instance.hxx>
|
|
|
|
|
2006-10-13 10:52:21 +00:00
|
|
|
#include <PackageConstants.hxx>
|
2004-05-10 16:29:52 +00:00
|
|
|
|
2001-07-04 13:56:37 +00:00
|
|
|
using namespace com::sun::star::packages::zip::ZipConstants;
|
|
|
|
using namespace com::sun::star::packages::zip;
|
2001-04-27 13:56:07 +00:00
|
|
|
using namespace com::sun::star::uno;
|
|
|
|
using namespace com::sun::star::lang;
|
2000-11-21 09:43:06 +00:00
|
|
|
using namespace com::sun::star;
|
2000-12-19 20:55:41 +00:00
|
|
|
using namespace cppu;
|
2010-10-15 12:18:51 -05:00
|
|
|
|
2014-01-27 22:51:45 +01:00
|
|
|
#if OSL_DEBUG_LEVEL > 0
|
|
|
|
#define THROW_WHERE SAL_WHERE
|
|
|
|
#else
|
|
|
|
#define THROW_WHERE ""
|
|
|
|
#endif
|
|
|
|
|
2014-03-10 08:58:16 +01:00
|
|
|
namespace { struct lcl_CachedImplId : public rtl::Static< cppu::OImplementationId, lcl_CachedImplId > {}; }
|
2001-10-02 21:27:29 +00:00
|
|
|
|
2014-03-10 08:58:16 +01:00
|
|
|
::com::sun::star::uno::Sequence < sal_Int8 > ZipPackageStream::static_getImplementationId()
|
2010-10-11 09:29:20 +01:00
|
|
|
{
|
2014-03-10 08:58:16 +01:00
|
|
|
return lcl_CachedImplId::get().getImplementationId();
|
2010-10-11 09:29:20 +01:00
|
|
|
}
|
2004-02-03 17:26:32 +00:00
|
|
|
|
|
|
|
ZipPackageStream::ZipPackageStream ( ZipPackage & rNewPackage,
|
2013-01-31 17:08:44 +02:00
|
|
|
const uno::Reference< XComponentContext >& xContext,
|
2014-04-17 13:40:46 +02:00
|
|
|
bool bAllowRemoveOnInsert )
|
2013-01-31 17:08:44 +02:00
|
|
|
: m_xContext( xContext )
|
2011-03-09 17:29:09 +01:00
|
|
|
, rZipPackage( rNewPackage )
|
2014-04-17 13:40:46 +02:00
|
|
|
, bToBeCompressed ( true )
|
|
|
|
, bToBeEncrypted ( false )
|
|
|
|
, bHaveOwnKey ( false )
|
|
|
|
, bIsEncrypted ( false )
|
2011-03-23 14:13:24 +01:00
|
|
|
, m_nImportedStartKeyAlgorithm( 0 )
|
2011-03-09 17:29:09 +01:00
|
|
|
, m_nImportedEncryptionAlgorithm( 0 )
|
|
|
|
, m_nImportedChecksumAlgorithm( 0 )
|
2011-03-23 14:13:24 +01:00
|
|
|
, m_nImportedDerivedKeySize( 0 )
|
2003-09-11 09:18:07 +00:00
|
|
|
, m_nStreamMode( PACKAGE_STREAM_NOTSET )
|
|
|
|
, m_nMagicalHackPos( 0 )
|
2006-06-20 05:14:50 +00:00
|
|
|
, m_nMagicalHackSize( 0 )
|
2014-04-17 13:40:46 +02:00
|
|
|
, m_bHasSeekable( false )
|
|
|
|
, m_bCompressedIsSetFromOutside( false )
|
|
|
|
, m_bFromManifest( false )
|
2011-03-09 17:29:09 +01:00
|
|
|
, m_bUseWinEncoding( false )
|
2000-11-21 09:43:06 +00:00
|
|
|
{
|
2013-01-31 17:08:44 +02:00
|
|
|
OSL_ENSURE( m_xContext.is(), "No factory is provided to ZipPackageStream!\n" );
|
2004-02-03 17:26:32 +00:00
|
|
|
|
2005-08-25 15:16:53 +00:00
|
|
|
this->mbAllowRemoveOnInsert = bAllowRemoveOnInsert;
|
2005-07-12 11:31:48 +00:00
|
|
|
|
2014-01-28 20:01:11 +01:00
|
|
|
SetFolder ( false );
|
2000-11-21 09:43:06 +00:00
|
|
|
aEntry.nVersion = -1;
|
|
|
|
aEntry.nFlag = 0;
|
|
|
|
aEntry.nMethod = -1;
|
|
|
|
aEntry.nTime = -1;
|
|
|
|
aEntry.nCrc = -1;
|
|
|
|
aEntry.nCompressedSize = -1;
|
|
|
|
aEntry.nSize = -1;
|
|
|
|
aEntry.nOffset = -1;
|
2009-09-17 13:53:54 +00:00
|
|
|
aEntry.nPathLen = -1;
|
2003-03-26 13:16:07 +00:00
|
|
|
aEntry.nExtraLen = -1;
|
2000-11-21 09:43:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ZipPackageStream::~ZipPackageStream( void )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-03-09 17:29:09 +01:00
|
|
|
void ZipPackageStream::setZipEntryOnLoading( const ZipEntry &rInEntry )
|
2000-11-21 09:43:06 +00:00
|
|
|
{
|
|
|
|
aEntry.nVersion = rInEntry.nVersion;
|
|
|
|
aEntry.nFlag = rInEntry.nFlag;
|
|
|
|
aEntry.nMethod = rInEntry.nMethod;
|
|
|
|
aEntry.nTime = rInEntry.nTime;
|
|
|
|
aEntry.nCrc = rInEntry.nCrc;
|
|
|
|
aEntry.nCompressedSize = rInEntry.nCompressedSize;
|
|
|
|
aEntry.nSize = rInEntry.nSize;
|
|
|
|
aEntry.nOffset = rInEntry.nOffset;
|
2009-09-17 13:53:54 +00:00
|
|
|
aEntry.sPath = rInEntry.sPath;
|
|
|
|
aEntry.nPathLen = rInEntry.nPathLen;
|
2003-03-26 13:16:07 +00:00
|
|
|
aEntry.nExtraLen = rInEntry.nExtraLen;
|
2006-10-13 10:52:21 +00:00
|
|
|
|
|
|
|
if ( aEntry.nMethod == STORED )
|
2014-04-17 13:40:46 +02:00
|
|
|
bToBeCompressed = false;
|
2000-11-21 09:43:06 +00:00
|
|
|
}
|
2000-12-19 20:55:41 +00:00
|
|
|
|
2005-09-23 14:56:03 +00:00
|
|
|
void ZipPackageStream::CloseOwnStreamIfAny()
|
|
|
|
{
|
|
|
|
if ( xStream.is() )
|
|
|
|
{
|
|
|
|
xStream->closeInput();
|
|
|
|
xStream = uno::Reference< io::XInputStream >();
|
2014-04-17 13:40:46 +02:00
|
|
|
m_bHasSeekable = false;
|
2005-09-23 14:56:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-23 14:13:24 +01:00
|
|
|
uno::Reference< io::XInputStream > ZipPackageStream::GetOwnSeekStream()
|
2005-10-19 11:49:50 +00:00
|
|
|
{
|
|
|
|
if ( !m_bHasSeekable && xStream.is() )
|
|
|
|
{
|
|
|
|
// The package component requires that every stream either be FROM a package or it must support XSeekable!
|
|
|
|
// The only exception is a nonseekable stream that is provided only for storing, if such a stream
|
|
|
|
// is accessed before commit it MUST be wrapped.
|
|
|
|
// Wrap the stream in case it is not seekable
|
2013-01-31 17:08:44 +02:00
|
|
|
xStream = ::comphelper::OSeekableInputWrapper::CheckSeekableCanWrap( xStream, m_xContext );
|
2011-03-09 17:29:09 +01:00
|
|
|
uno::Reference< io::XSeekable > xSeek( xStream, UNO_QUERY );
|
2005-10-19 11:49:50 +00:00
|
|
|
if ( !xSeek.is() )
|
2014-05-23 12:03:21 +02:00
|
|
|
throw RuntimeException( THROW_WHERE "The stream must support XSeekable!" );
|
2005-10-19 11:49:50 +00:00
|
|
|
|
2014-04-17 13:40:46 +02:00
|
|
|
m_bHasSeekable = true;
|
2005-10-19 11:49:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return xStream;
|
|
|
|
}
|
|
|
|
|
2004-11-26 19:46:22 +00:00
|
|
|
uno::Reference< io::XInputStream > ZipPackageStream::GetRawEncrStreamNoHeaderCopy()
|
2004-02-03 17:26:32 +00:00
|
|
|
{
|
2005-10-19 11:49:50 +00:00
|
|
|
if ( m_nStreamMode != PACKAGE_STREAM_RAW || !GetOwnSeekStream().is() )
|
2014-05-23 12:03:21 +02:00
|
|
|
throw io::IOException(THROW_WHERE );
|
2004-11-26 19:46:22 +00:00
|
|
|
|
2011-03-09 17:29:09 +01:00
|
|
|
if ( m_xBaseEncryptionData.is() )
|
2014-05-23 12:03:21 +02:00
|
|
|
throw ZipIOException(THROW_WHERE "Encrypted stream without encryption data!" );
|
2004-11-26 19:46:22 +00:00
|
|
|
|
2005-10-19 11:49:50 +00:00
|
|
|
uno::Reference< io::XSeekable > xSeek( GetOwnSeekStream(), UNO_QUERY );
|
2004-11-26 19:46:22 +00:00
|
|
|
if ( !xSeek.is() )
|
2014-05-23 12:03:21 +02:00
|
|
|
throw ZipIOException(THROW_WHERE "The stream must be seekable!" );
|
2004-11-26 19:46:22 +00:00
|
|
|
|
|
|
|
// skip header
|
2011-03-09 17:29:09 +01:00
|
|
|
xSeek->seek( n_ConstHeaderSize + getInitialisationVector().getLength() +
|
|
|
|
getSalt().getLength() + getDigest().getLength() );
|
2004-11-26 19:46:22 +00:00
|
|
|
|
|
|
|
// create temporary stream
|
2013-01-31 17:08:44 +02:00
|
|
|
uno::Reference < io::XTempFile > xTempFile = io::TempFile::create(m_xContext);
|
|
|
|
uno::Reference < io::XOutputStream > xTempOut = xTempFile->getOutputStream();
|
|
|
|
uno::Reference < io::XInputStream > xTempIn = xTempFile->getInputStream();;
|
2012-08-23 17:23:26 +02:00
|
|
|
uno::Reference < io::XSeekable > xTempSeek( xTempOut, UNO_QUERY_THROW );
|
2004-11-26 19:46:22 +00:00
|
|
|
|
|
|
|
// copy the raw stream to the temporary file starting from the current position
|
2006-02-01 18:15:02 +00:00
|
|
|
::comphelper::OStorageHelper::CopyInputToOutput( GetOwnSeekStream(), xTempOut );
|
2004-11-26 19:46:22 +00:00
|
|
|
xTempOut->closeOutput();
|
|
|
|
xTempSeek->seek( 0 );
|
|
|
|
|
|
|
|
return xTempIn;
|
|
|
|
}
|
|
|
|
|
2011-03-23 14:13:24 +01:00
|
|
|
sal_Int32 ZipPackageStream::GetEncryptionAlgorithm() const
|
2004-11-26 19:46:22 +00:00
|
|
|
{
|
2011-03-23 14:13:24 +01:00
|
|
|
return m_nImportedEncryptionAlgorithm ? m_nImportedEncryptionAlgorithm : rZipPackage.GetEncAlgID();
|
|
|
|
}
|
|
|
|
|
|
|
|
sal_Int32 ZipPackageStream::GetBlockSize() const
|
|
|
|
{
|
|
|
|
return GetEncryptionAlgorithm() == ::com::sun::star::xml::crypto::CipherID::AES_CBC_W3C_PADDING ? 16 : 8;
|
|
|
|
}
|
|
|
|
|
2011-03-09 17:29:09 +01:00
|
|
|
::rtl::Reference< EncryptionData > ZipPackageStream::GetEncryptionData( bool bUseWinEncoding )
|
2004-11-26 19:46:22 +00:00
|
|
|
{
|
2011-03-09 17:29:09 +01:00
|
|
|
::rtl::Reference< EncryptionData > xResult;
|
|
|
|
if ( m_xBaseEncryptionData.is() )
|
|
|
|
xResult = new EncryptionData(
|
|
|
|
*m_xBaseEncryptionData,
|
|
|
|
GetEncryptionKey( bUseWinEncoding ),
|
2011-03-23 14:13:24 +01:00
|
|
|
GetEncryptionAlgorithm(),
|
2011-03-09 17:29:09 +01:00
|
|
|
m_nImportedChecksumAlgorithm ? m_nImportedChecksumAlgorithm : rZipPackage.GetChecksumAlgID(),
|
2011-03-24 13:44:49 +01:00
|
|
|
m_nImportedDerivedKeySize ? m_nImportedDerivedKeySize : rZipPackage.GetDefaultDerivedKeySize(),
|
|
|
|
GetStartKeyGenID() );
|
2011-03-09 17:29:09 +01:00
|
|
|
|
|
|
|
return xResult;
|
|
|
|
}
|
|
|
|
|
|
|
|
uno::Sequence< sal_Int8 > ZipPackageStream::GetEncryptionKey( bool bUseWinEncoding )
|
|
|
|
{
|
|
|
|
uno::Sequence< sal_Int8 > aResult;
|
2011-03-24 13:44:49 +01:00
|
|
|
sal_Int32 nKeyGenID = GetStartKeyGenID();
|
2011-03-09 17:29:09 +01:00
|
|
|
bUseWinEncoding = ( bUseWinEncoding || m_bUseWinEncoding );
|
|
|
|
|
|
|
|
if ( bHaveOwnKey && m_aStorageEncryptionKeys.getLength() )
|
|
|
|
{
|
2012-08-17 22:06:10 +02:00
|
|
|
OUString aNameToFind;
|
2011-03-09 17:29:09 +01:00
|
|
|
if ( nKeyGenID == xml::crypto::DigestID::SHA256 )
|
|
|
|
aNameToFind = PACKAGE_ENCRYPTIONDATA_SHA256UTF8;
|
|
|
|
else if ( nKeyGenID == xml::crypto::DigestID::SHA1 )
|
|
|
|
{
|
|
|
|
aNameToFind = bUseWinEncoding ? PACKAGE_ENCRYPTIONDATA_SHA1MS1252 : PACKAGE_ENCRYPTIONDATA_SHA1UTF8;
|
|
|
|
}
|
|
|
|
else
|
2014-05-23 12:03:21 +02:00
|
|
|
throw uno::RuntimeException(THROW_WHERE "No expected key is provided!" );
|
2011-03-09 17:29:09 +01:00
|
|
|
|
|
|
|
for ( sal_Int32 nInd = 0; nInd < m_aStorageEncryptionKeys.getLength(); nInd++ )
|
|
|
|
if ( m_aStorageEncryptionKeys[nInd].Name.equals( aNameToFind ) )
|
|
|
|
m_aStorageEncryptionKeys[nInd].Value >>= aResult;
|
|
|
|
|
|
|
|
// empty keys are not allowed here
|
|
|
|
// so it is not important whether there is no key, or the key is empty, it is an error
|
|
|
|
if ( !aResult.getLength() )
|
2014-05-23 12:03:21 +02:00
|
|
|
throw uno::RuntimeException(THROW_WHERE "No expected key is provided!" );
|
2011-03-09 17:29:09 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
aResult = m_aEncryptionKey;
|
|
|
|
|
|
|
|
if ( !aResult.getLength() || !bHaveOwnKey )
|
|
|
|
aResult = rZipPackage.GetEncryptionKey();
|
|
|
|
|
|
|
|
return aResult;
|
|
|
|
}
|
|
|
|
|
2011-03-24 13:44:49 +01:00
|
|
|
sal_Int32 ZipPackageStream::GetStartKeyGenID()
|
2011-03-17 09:16:41 +01:00
|
|
|
{
|
2011-03-24 13:44:49 +01:00
|
|
|
// generally should all the streams use the same Start Key
|
|
|
|
// but if raw copy without password takes place, we should preserve the imported algorithm
|
|
|
|
return m_nImportedStartKeyAlgorithm ? m_nImportedStartKeyAlgorithm : rZipPackage.GetStartKeyGenID();
|
2011-03-17 09:16:41 +01:00
|
|
|
}
|
|
|
|
|
2014-04-17 13:40:46 +02:00
|
|
|
uno::Reference< io::XInputStream > ZipPackageStream::TryToGetRawFromDataStream( bool bAddHeaderForEncr )
|
2011-03-09 17:29:09 +01:00
|
|
|
{
|
|
|
|
if ( m_nStreamMode != PACKAGE_STREAM_DATA || !GetOwnSeekStream().is() || ( bAddHeaderForEncr && !bToBeEncrypted ) )
|
2014-05-23 12:03:21 +02:00
|
|
|
throw packages::NoEncryptionException(THROW_WHERE );
|
2004-02-03 17:26:32 +00:00
|
|
|
|
2004-11-26 19:46:22 +00:00
|
|
|
Sequence< sal_Int8 > aKey;
|
|
|
|
|
|
|
|
if ( bToBeEncrypted )
|
|
|
|
{
|
2011-03-09 17:29:09 +01:00
|
|
|
aKey = GetEncryptionKey();
|
2004-11-26 19:46:22 +00:00
|
|
|
if ( !aKey.getLength() )
|
2014-05-23 12:03:21 +02:00
|
|
|
throw packages::NoEncryptionException(THROW_WHERE );
|
2004-11-26 19:46:22 +00:00
|
|
|
}
|
2004-02-03 17:26:32 +00:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
// create temporary file
|
|
|
|
uno::Reference < io::XStream > xTempStream(
|
2013-01-31 17:08:44 +02:00
|
|
|
io::TempFile::create(m_xContext),
|
2012-08-23 17:23:26 +02:00
|
|
|
uno::UNO_QUERY_THROW );
|
2004-02-03 17:26:32 +00:00
|
|
|
|
|
|
|
// create a package based on it
|
2013-01-31 17:08:44 +02:00
|
|
|
ZipPackage* pPackage = new ZipPackage( m_xContext );
|
2011-03-09 17:29:09 +01:00
|
|
|
uno::Reference< XSingleServiceFactory > xPackageAsFactory( static_cast< XSingleServiceFactory* >( pPackage ) );
|
2004-02-03 17:26:32 +00:00
|
|
|
if ( !xPackageAsFactory.is() )
|
2014-05-23 12:03:21 +02:00
|
|
|
throw RuntimeException(THROW_WHERE );
|
2004-02-03 17:26:32 +00:00
|
|
|
|
|
|
|
Sequence< Any > aArgs( 1 );
|
|
|
|
aArgs[0] <<= xTempStream;
|
|
|
|
pPackage->initialize( aArgs );
|
|
|
|
|
|
|
|
// create a new package stream
|
2011-03-09 17:29:09 +01:00
|
|
|
uno::Reference< XDataSinkEncrSupport > xNewPackStream( xPackageAsFactory->createInstance(), UNO_QUERY );
|
2004-02-03 17:26:32 +00:00
|
|
|
if ( !xNewPackStream.is() )
|
2014-05-23 12:03:21 +02:00
|
|
|
throw RuntimeException(THROW_WHERE );
|
2004-02-03 17:26:32 +00:00
|
|
|
|
|
|
|
xNewPackStream->setDataStream( static_cast< io::XInputStream* >(
|
2009-09-08 08:54:47 +00:00
|
|
|
new WrapStreamForShare( GetOwnSeekStream(), rZipPackage.GetSharedMutexRef() ) ) );
|
2004-02-03 17:26:32 +00:00
|
|
|
|
2011-03-09 17:29:09 +01:00
|
|
|
uno::Reference< XPropertySet > xNewPSProps( xNewPackStream, UNO_QUERY );
|
2004-02-03 17:26:32 +00:00
|
|
|
if ( !xNewPSProps.is() )
|
2014-05-23 12:03:21 +02:00
|
|
|
throw RuntimeException(THROW_WHERE );
|
2004-02-03 17:26:32 +00:00
|
|
|
|
|
|
|
// copy all the properties of this stream to the new stream
|
2014-10-07 13:56:26 +02:00
|
|
|
xNewPSProps->setPropertyValue("MediaType", makeAny( msMediaType ) );
|
2012-08-17 22:06:10 +02:00
|
|
|
xNewPSProps->setPropertyValue("Compressed", makeAny( bToBeCompressed ) );
|
2004-11-26 19:46:22 +00:00
|
|
|
if ( bToBeEncrypted )
|
|
|
|
{
|
2012-08-17 22:06:10 +02:00
|
|
|
xNewPSProps->setPropertyValue(ENCRYPTION_KEY_PROPERTY, makeAny( aKey ) );
|
2014-04-17 13:40:46 +02:00
|
|
|
xNewPSProps->setPropertyValue("Encrypted", makeAny( true ) );
|
2004-11-26 19:46:22 +00:00
|
|
|
}
|
2004-02-03 17:26:32 +00:00
|
|
|
|
|
|
|
// insert a new stream in the package
|
2011-03-09 17:29:09 +01:00
|
|
|
uno::Reference< XUnoTunnel > xTunnel;
|
2012-08-17 22:06:10 +02:00
|
|
|
Any aRoot = pPackage->getByHierarchicalName("/");
|
2004-02-03 17:26:32 +00:00
|
|
|
aRoot >>= xTunnel;
|
2011-03-09 17:29:09 +01:00
|
|
|
uno::Reference< container::XNameContainer > xRootNameContainer( xTunnel, UNO_QUERY );
|
2004-02-03 17:26:32 +00:00
|
|
|
if ( !xRootNameContainer.is() )
|
2014-05-23 12:03:21 +02:00
|
|
|
throw RuntimeException(THROW_WHERE );
|
2004-02-03 17:26:32 +00:00
|
|
|
|
2011-03-09 17:29:09 +01:00
|
|
|
uno::Reference< XUnoTunnel > xNPSTunnel( xNewPackStream, UNO_QUERY );
|
2012-08-17 22:06:10 +02:00
|
|
|
xRootNameContainer->insertByName("dummy", makeAny( xNPSTunnel ) );
|
2004-02-03 17:26:32 +00:00
|
|
|
|
|
|
|
// commit the temporary package
|
|
|
|
pPackage->commitChanges();
|
|
|
|
|
|
|
|
// get raw stream from the temporary package
|
2011-03-09 17:29:09 +01:00
|
|
|
uno::Reference< io::XInputStream > xInRaw;
|
2004-11-26 19:46:22 +00:00
|
|
|
if ( bAddHeaderForEncr )
|
|
|
|
xInRaw = xNewPackStream->getRawStream();
|
|
|
|
else
|
|
|
|
xInRaw = xNewPackStream->getPlainRawStream();
|
2004-02-03 17:26:32 +00:00
|
|
|
|
|
|
|
// create another temporary file
|
|
|
|
uno::Reference < io::XOutputStream > xTempOut(
|
2013-01-31 17:08:44 +02:00
|
|
|
io::TempFile::create(m_xContext),
|
2012-08-23 17:23:26 +02:00
|
|
|
uno::UNO_QUERY_THROW );
|
|
|
|
uno::Reference < io::XInputStream > xTempIn( xTempOut, UNO_QUERY_THROW );
|
|
|
|
uno::Reference < io::XSeekable > xTempSeek( xTempOut, UNO_QUERY_THROW );
|
2004-02-03 17:26:32 +00:00
|
|
|
|
|
|
|
// copy the raw stream to the temporary file
|
2006-02-01 18:15:02 +00:00
|
|
|
::comphelper::OStorageHelper::CopyInputToOutput( xInRaw, xTempOut );
|
2004-02-03 17:26:32 +00:00
|
|
|
xTempOut->closeOutput();
|
|
|
|
xTempSeek->seek( 0 );
|
|
|
|
|
|
|
|
// close raw stream, package stream and folder
|
2011-03-09 17:29:09 +01:00
|
|
|
xInRaw = uno::Reference< io::XInputStream >();
|
|
|
|
xNewPSProps = uno::Reference< XPropertySet >();
|
|
|
|
xNPSTunnel = uno::Reference< XUnoTunnel >();
|
|
|
|
xNewPackStream = uno::Reference< XDataSinkEncrSupport >();
|
|
|
|
xTunnel = uno::Reference< XUnoTunnel >();
|
|
|
|
xRootNameContainer = uno::Reference< container::XNameContainer >();
|
2004-02-03 17:26:32 +00:00
|
|
|
|
|
|
|
// return the stream representing the first temporary file
|
|
|
|
return xTempIn;
|
|
|
|
}
|
|
|
|
catch ( RuntimeException& )
|
|
|
|
{
|
|
|
|
throw;
|
|
|
|
}
|
|
|
|
catch ( Exception& )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-05-23 12:03:21 +02:00
|
|
|
throw io::IOException(THROW_WHERE );
|
2004-02-03 17:26:32 +00:00
|
|
|
}
|
|
|
|
|
2014-04-17 13:40:46 +02:00
|
|
|
bool ZipPackageStream::ParsePackageRawStream()
|
2003-09-11 09:18:07 +00:00
|
|
|
{
|
2005-10-19 11:49:50 +00:00
|
|
|
OSL_ENSURE( GetOwnSeekStream().is(), "A stream must be provided!\n" );
|
2003-09-11 09:18:07 +00:00
|
|
|
|
2005-10-19 11:49:50 +00:00
|
|
|
if ( !GetOwnSeekStream().is() )
|
2014-04-17 13:40:46 +02:00
|
|
|
return false;
|
2003-09-11 09:18:07 +00:00
|
|
|
|
2014-04-17 13:40:46 +02:00
|
|
|
bool bOk = false;
|
2003-09-11 09:18:07 +00:00
|
|
|
|
2011-03-09 17:29:09 +01:00
|
|
|
::rtl::Reference< BaseEncryptionData > xTempEncrData;
|
2003-09-11 09:18:07 +00:00
|
|
|
sal_Int32 nMagHackSize = 0;
|
|
|
|
Sequence < sal_Int8 > aHeader ( 4 );
|
|
|
|
|
2004-05-10 16:29:52 +00:00
|
|
|
try
|
2003-09-11 09:18:07 +00:00
|
|
|
{
|
2005-10-19 11:49:50 +00:00
|
|
|
if ( GetOwnSeekStream()->readBytes ( aHeader, 4 ) == 4 )
|
2003-09-11 09:18:07 +00:00
|
|
|
{
|
2004-05-10 16:29:52 +00:00
|
|
|
const sal_Int8 *pHeader = aHeader.getConstArray();
|
|
|
|
sal_uInt32 nHeader = ( pHeader [0] & 0xFF ) |
|
|
|
|
( pHeader [1] & 0xFF ) << 8 |
|
|
|
|
( pHeader [2] & 0xFF ) << 16 |
|
|
|
|
( pHeader [3] & 0xFF ) << 24;
|
|
|
|
if ( nHeader == n_ConstHeader )
|
2003-09-11 09:18:07 +00:00
|
|
|
{
|
2004-05-10 16:29:52 +00:00
|
|
|
// this is one of our god-awful, but extremely devious hacks, everyone cheer
|
2011-03-09 17:29:09 +01:00
|
|
|
xTempEncrData = new BaseEncryptionData;
|
2004-05-10 16:29:52 +00:00
|
|
|
|
2012-08-17 22:06:10 +02:00
|
|
|
OUString aMediaType;
|
2011-03-09 17:29:09 +01:00
|
|
|
sal_Int32 nEncAlgorithm = 0;
|
|
|
|
sal_Int32 nChecksumAlgorithm = 0;
|
|
|
|
sal_Int32 nDerivedKeySize = 0;
|
2011-03-24 13:44:49 +01:00
|
|
|
sal_Int32 nStartKeyGenID = 0;
|
|
|
|
if ( ZipFile::StaticFillData( xTempEncrData, nEncAlgorithm, nChecksumAlgorithm, nDerivedKeySize, nStartKeyGenID, nMagHackSize, aMediaType, GetOwnSeekStream() ) )
|
2004-05-10 16:29:52 +00:00
|
|
|
{
|
|
|
|
// We'll want to skip the data we've just read, so calculate how much we just read
|
|
|
|
// and remember it
|
2011-03-09 17:29:09 +01:00
|
|
|
m_nMagicalHackPos = n_ConstHeaderSize + xTempEncrData->m_aSalt.getLength()
|
|
|
|
+ xTempEncrData->m_aInitVector.getLength()
|
|
|
|
+ xTempEncrData->m_aDigest.getLength()
|
2004-05-10 16:29:52 +00:00
|
|
|
+ aMediaType.getLength() * sizeof( sal_Unicode );
|
2011-03-09 17:29:09 +01:00
|
|
|
m_nImportedEncryptionAlgorithm = nEncAlgorithm;
|
|
|
|
m_nImportedChecksumAlgorithm = nChecksumAlgorithm;
|
|
|
|
m_nImportedDerivedKeySize = nDerivedKeySize;
|
2011-03-24 13:44:49 +01:00
|
|
|
m_nImportedStartKeyAlgorithm = nStartKeyGenID;
|
2004-05-10 16:29:52 +00:00
|
|
|
m_nMagicalHackSize = nMagHackSize;
|
2014-10-07 13:56:26 +02:00
|
|
|
msMediaType = aMediaType;
|
2004-05-10 16:29:52 +00:00
|
|
|
|
2014-04-17 13:40:46 +02:00
|
|
|
bOk = true;
|
2004-05-10 16:29:52 +00:00
|
|
|
}
|
2003-09-11 09:18:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-05-10 16:29:52 +00:00
|
|
|
catch( Exception& )
|
|
|
|
{
|
|
|
|
}
|
2003-09-11 09:18:07 +00:00
|
|
|
|
|
|
|
if ( !bOk )
|
|
|
|
{
|
|
|
|
// the provided stream is not a raw stream
|
2014-04-17 13:40:46 +02:00
|
|
|
return false;
|
2003-09-11 09:18:07 +00:00
|
|
|
}
|
|
|
|
|
2011-03-09 17:29:09 +01:00
|
|
|
m_xBaseEncryptionData = xTempEncrData;
|
2014-04-17 13:40:46 +02:00
|
|
|
SetIsEncrypted ( true );
|
2003-09-11 09:18:07 +00:00
|
|
|
// it's already compressed and encrypted
|
2014-04-17 13:40:46 +02:00
|
|
|
bToBeEncrypted = bToBeCompressed = false;
|
2003-09-11 09:18:07 +00:00
|
|
|
|
2014-04-17 13:40:46 +02:00
|
|
|
return true;
|
2003-09-11 09:18:07 +00:00
|
|
|
}
|
|
|
|
|
2014-04-17 13:40:46 +02:00
|
|
|
void ZipPackageStream::SetPackageMember( bool bNewValue )
|
2003-09-11 09:18:07 +00:00
|
|
|
{
|
|
|
|
if ( bNewValue )
|
|
|
|
{
|
|
|
|
m_nStreamMode = PACKAGE_STREAM_PACKAGEMEMBER;
|
|
|
|
m_nMagicalHackPos = 0;
|
|
|
|
m_nMagicalHackSize = 0;
|
|
|
|
}
|
|
|
|
else if ( m_nStreamMode == PACKAGE_STREAM_PACKAGEMEMBER )
|
|
|
|
m_nStreamMode = PACKAGE_STREAM_NOTSET; // must be reset
|
|
|
|
}
|
|
|
|
|
2001-10-02 21:27:29 +00:00
|
|
|
// XActiveDataSink
|
2011-03-09 17:29:09 +01:00
|
|
|
void SAL_CALL ZipPackageStream::setInputStream( const uno::Reference< io::XInputStream >& aStream )
|
2014-02-25 21:31:58 +01:00
|
|
|
throw( RuntimeException, std::exception )
|
2000-11-21 09:43:06 +00:00
|
|
|
{
|
2005-10-19 11:49:50 +00:00
|
|
|
// if seekable access is required the wrapping will be done on demand
|
|
|
|
xStream = aStream;
|
2011-03-09 17:29:09 +01:00
|
|
|
m_nImportedEncryptionAlgorithm = 0;
|
2014-04-17 13:40:46 +02:00
|
|
|
m_bHasSeekable = false;
|
|
|
|
SetPackageMember ( false );
|
2000-11-28 15:49:34 +00:00
|
|
|
aEntry.nTime = -1;
|
2003-09-11 09:18:07 +00:00
|
|
|
m_nStreamMode = PACKAGE_STREAM_DETECT;
|
2000-11-21 09:43:06 +00:00
|
|
|
}
|
2000-12-13 16:00:47 +00:00
|
|
|
|
2011-03-09 17:29:09 +01:00
|
|
|
uno::Reference< io::XInputStream > SAL_CALL ZipPackageStream::getRawData()
|
|
|
|
throw( RuntimeException )
|
2000-12-13 16:00:47 +00:00
|
|
|
{
|
2004-02-03 17:26:32 +00:00
|
|
|
try
|
2000-12-13 16:00:47 +00:00
|
|
|
{
|
2011-03-09 17:29:09 +01:00
|
|
|
if ( IsPackageMember() )
|
2000-12-13 16:00:47 +00:00
|
|
|
{
|
2011-03-09 17:29:09 +01:00
|
|
|
return rZipPackage.getZipFile().getRawData( aEntry, GetEncryptionData(), bIsEncrypted, rZipPackage.GetSharedMutexRef() );
|
2000-12-13 16:00:47 +00:00
|
|
|
}
|
2005-10-19 11:49:50 +00:00
|
|
|
else if ( GetOwnSeekStream().is() )
|
2000-12-13 16:00:47 +00:00
|
|
|
{
|
2009-09-08 08:54:47 +00:00
|
|
|
return new WrapStreamForShare( GetOwnSeekStream(), rZipPackage.GetSharedMutexRef() );
|
2000-12-13 16:00:47 +00:00
|
|
|
}
|
2004-02-03 17:26:32 +00:00
|
|
|
else
|
2011-03-09 17:29:09 +01:00
|
|
|
return uno::Reference < io::XInputStream > ();
|
2004-02-03 17:26:32 +00:00
|
|
|
}
|
2011-03-09 17:29:09 +01:00
|
|
|
catch ( ZipException & )//rException )
|
2004-02-03 17:26:32 +00:00
|
|
|
{
|
2011-04-22 15:08:05 +02:00
|
|
|
OSL_FAIL( "ZipException thrown" );//rException.Message);
|
2011-03-09 17:29:09 +01:00
|
|
|
return uno::Reference < io::XInputStream > ();
|
2004-02-03 17:26:32 +00:00
|
|
|
}
|
2011-03-09 17:29:09 +01:00
|
|
|
catch ( Exception & )
|
2004-02-03 17:26:32 +00:00
|
|
|
{
|
2011-04-22 15:08:05 +02:00
|
|
|
OSL_FAIL( "Exception is thrown during stream wrapping!\n" );
|
2011-03-09 17:29:09 +01:00
|
|
|
return uno::Reference < io::XInputStream > ();
|
2000-12-13 16:00:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-09 17:29:09 +01:00
|
|
|
uno::Reference< io::XInputStream > SAL_CALL ZipPackageStream::getInputStream()
|
2014-02-25 21:31:58 +01:00
|
|
|
throw( RuntimeException, std::exception )
|
2000-11-21 09:43:06 +00:00
|
|
|
{
|
2004-02-03 17:26:32 +00:00
|
|
|
try
|
2000-12-04 10:30:09 +00:00
|
|
|
{
|
2011-03-09 17:29:09 +01:00
|
|
|
if ( IsPackageMember() )
|
2000-12-04 10:30:09 +00:00
|
|
|
{
|
2011-03-09 17:29:09 +01:00
|
|
|
return rZipPackage.getZipFile().getInputStream( aEntry, GetEncryptionData(), bIsEncrypted, rZipPackage.GetSharedMutexRef() );
|
2000-12-04 10:30:09 +00:00
|
|
|
}
|
2005-10-19 11:49:50 +00:00
|
|
|
else if ( GetOwnSeekStream().is() )
|
2000-12-04 10:30:09 +00:00
|
|
|
{
|
2009-09-08 08:54:47 +00:00
|
|
|
return new WrapStreamForShare( GetOwnSeekStream(), rZipPackage.GetSharedMutexRef() );
|
2000-12-04 10:30:09 +00:00
|
|
|
}
|
2004-02-03 17:26:32 +00:00
|
|
|
else
|
2011-03-09 17:29:09 +01:00
|
|
|
return uno::Reference < io::XInputStream > ();
|
2004-02-03 17:26:32 +00:00
|
|
|
}
|
2011-03-09 17:29:09 +01:00
|
|
|
catch ( ZipException & )//rException )
|
2004-02-03 17:26:32 +00:00
|
|
|
{
|
2011-04-22 15:08:05 +02:00
|
|
|
OSL_FAIL( "ZipException thrown" );//rException.Message);
|
2011-03-09 17:29:09 +01:00
|
|
|
return uno::Reference < io::XInputStream > ();
|
2004-02-03 17:26:32 +00:00
|
|
|
}
|
2012-02-12 14:29:55 +01:00
|
|
|
catch ( Exception &ex )
|
2004-02-03 17:26:32 +00:00
|
|
|
{
|
2011-04-22 15:08:05 +02:00
|
|
|
OSL_FAIL( "Exception is thrown during stream wrapping!\n" );
|
2012-02-12 14:29:55 +01:00
|
|
|
OSL_FAIL(OUStringToOString(ex.Message, RTL_TEXTENCODING_UTF8).getStr());
|
2012-02-17 16:32:02 +00:00
|
|
|
(void)ex;
|
2011-03-09 17:29:09 +01:00
|
|
|
return uno::Reference < io::XInputStream > ();
|
2000-12-04 10:30:09 +00:00
|
|
|
}
|
2000-11-21 09:43:06 +00:00
|
|
|
}
|
2001-04-27 13:56:07 +00:00
|
|
|
|
2003-09-11 09:18:07 +00:00
|
|
|
// XDataSinkEncrSupport
|
2011-03-09 17:29:09 +01:00
|
|
|
uno::Reference< io::XInputStream > SAL_CALL ZipPackageStream::getDataStream()
|
2003-09-11 09:18:07 +00:00
|
|
|
throw ( packages::WrongPasswordException,
|
|
|
|
io::IOException,
|
2014-02-25 21:31:58 +01:00
|
|
|
RuntimeException, std::exception )
|
2003-09-11 09:18:07 +00:00
|
|
|
{
|
|
|
|
// There is no stream attached to this object
|
|
|
|
if ( m_nStreamMode == PACKAGE_STREAM_NOTSET )
|
2011-03-09 17:29:09 +01:00
|
|
|
return uno::Reference< io::XInputStream >();
|
2003-09-11 09:18:07 +00:00
|
|
|
|
|
|
|
// this method can not be used together with old approach
|
|
|
|
if ( m_nStreamMode == PACKAGE_STREAM_DETECT )
|
2014-05-23 12:03:21 +02:00
|
|
|
throw packages::zip::ZipIOException(THROW_WHERE );
|
2003-09-11 09:18:07 +00:00
|
|
|
|
2011-03-09 17:29:09 +01:00
|
|
|
if ( IsPackageMember() )
|
2004-11-26 19:46:22 +00:00
|
|
|
{
|
2011-03-09 17:29:09 +01:00
|
|
|
uno::Reference< io::XInputStream > xResult;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
xResult = rZipPackage.getZipFile().getDataStream( aEntry, GetEncryptionData(), bIsEncrypted, rZipPackage.GetSharedMutexRef() );
|
|
|
|
}
|
2013-10-02 11:38:22 +01:00
|
|
|
catch( const packages::WrongPasswordException& )
|
2011-03-09 17:29:09 +01:00
|
|
|
{
|
2013-10-02 11:38:22 +01:00
|
|
|
if ( rZipPackage.GetStartKeyGenID() == xml::crypto::DigestID::SHA1 )
|
2011-03-09 17:29:09 +01:00
|
|
|
{
|
2013-10-02 11:38:22 +01:00
|
|
|
try
|
|
|
|
{
|
|
|
|
// rhbz#1013844 / fdo#47482 workaround for the encrypted
|
|
|
|
// OpenOffice.org 1.0 documents generated by Libreoffice <=
|
|
|
|
// 3.6 with the new encryption format and using SHA256, but
|
|
|
|
// missing a specified startkey of SHA256
|
|
|
|
|
|
|
|
// force SHA256 and see if that works
|
|
|
|
m_nImportedStartKeyAlgorithm = xml::crypto::DigestID::SHA256;
|
|
|
|
xResult = rZipPackage.getZipFile().getDataStream( aEntry, GetEncryptionData(), bIsEncrypted, rZipPackage.GetSharedMutexRef() );
|
|
|
|
return xResult;
|
|
|
|
}
|
|
|
|
catch (const packages::WrongPasswordException&)
|
|
|
|
{
|
|
|
|
// if that didn't work, restore to SHA1 and trundle through the *other* earlier
|
|
|
|
// bug fix
|
|
|
|
m_nImportedStartKeyAlgorithm = xml::crypto::DigestID::SHA1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// workaround for the encrypted documents generated with the old OOo1.x bug.
|
|
|
|
if ( !m_bUseWinEncoding )
|
|
|
|
{
|
|
|
|
xResult = rZipPackage.getZipFile().getDataStream( aEntry, GetEncryptionData( true ), bIsEncrypted, rZipPackage.GetSharedMutexRef() );
|
|
|
|
m_bUseWinEncoding = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
throw;
|
2011-03-09 17:29:09 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
throw;
|
|
|
|
}
|
|
|
|
return xResult;
|
2004-11-26 19:46:22 +00:00
|
|
|
}
|
2003-09-11 09:18:07 +00:00
|
|
|
else if ( m_nStreamMode == PACKAGE_STREAM_RAW )
|
2013-01-31 17:08:44 +02:00
|
|
|
return ZipFile::StaticGetDataFromRawStream( m_xContext, GetOwnSeekStream(), GetEncryptionData() );
|
2005-10-19 11:49:50 +00:00
|
|
|
else if ( GetOwnSeekStream().is() )
|
2003-10-30 08:48:49 +00:00
|
|
|
{
|
2009-09-08 08:54:47 +00:00
|
|
|
return new WrapStreamForShare( GetOwnSeekStream(), rZipPackage.GetSharedMutexRef() );
|
2003-10-30 08:48:49 +00:00
|
|
|
}
|
2004-02-03 17:26:32 +00:00
|
|
|
else
|
|
|
|
return uno::Reference< io::XInputStream >();
|
2003-09-11 09:18:07 +00:00
|
|
|
}
|
|
|
|
|
2011-03-09 17:29:09 +01:00
|
|
|
uno::Reference< io::XInputStream > SAL_CALL ZipPackageStream::getRawStream()
|
2003-09-11 09:18:07 +00:00
|
|
|
throw ( packages::NoEncryptionException,
|
|
|
|
io::IOException,
|
2014-02-25 21:31:58 +01:00
|
|
|
uno::RuntimeException, std::exception )
|
2003-09-11 09:18:07 +00:00
|
|
|
{
|
|
|
|
// There is no stream attached to this object
|
|
|
|
if ( m_nStreamMode == PACKAGE_STREAM_NOTSET )
|
2011-03-09 17:29:09 +01:00
|
|
|
return uno::Reference< io::XInputStream >();
|
2003-09-11 09:18:07 +00:00
|
|
|
|
|
|
|
// this method can not be used together with old approach
|
|
|
|
if ( m_nStreamMode == PACKAGE_STREAM_DETECT )
|
2014-05-23 12:03:21 +02:00
|
|
|
throw packages::zip::ZipIOException(THROW_WHERE );
|
2003-09-11 09:18:07 +00:00
|
|
|
|
2011-03-09 17:29:09 +01:00
|
|
|
if ( IsPackageMember() )
|
2003-09-11 09:18:07 +00:00
|
|
|
{
|
2011-03-09 17:29:09 +01:00
|
|
|
if ( !bIsEncrypted || !GetEncryptionData().is() )
|
2014-05-23 12:03:21 +02:00
|
|
|
throw packages::NoEncryptionException(THROW_WHERE );
|
2003-09-11 09:18:07 +00:00
|
|
|
|
2014-10-07 13:56:26 +02:00
|
|
|
return rZipPackage.getZipFile().getWrappedRawStream( aEntry, GetEncryptionData(), msMediaType, rZipPackage.GetSharedMutexRef() );
|
2003-09-11 09:18:07 +00:00
|
|
|
}
|
2005-10-19 11:49:50 +00:00
|
|
|
else if ( GetOwnSeekStream().is() )
|
2004-02-03 17:26:32 +00:00
|
|
|
{
|
|
|
|
if ( m_nStreamMode == PACKAGE_STREAM_RAW )
|
|
|
|
{
|
2009-09-08 08:54:47 +00:00
|
|
|
return new WrapStreamForShare( GetOwnSeekStream(), rZipPackage.GetSharedMutexRef() );
|
2004-02-03 17:26:32 +00:00
|
|
|
}
|
|
|
|
else if ( m_nStreamMode == PACKAGE_STREAM_DATA && bToBeEncrypted )
|
2014-04-17 13:40:46 +02:00
|
|
|
return TryToGetRawFromDataStream( true );
|
2004-02-03 17:26:32 +00:00
|
|
|
}
|
|
|
|
|
2014-05-23 12:03:21 +02:00
|
|
|
throw packages::NoEncryptionException(THROW_WHERE );
|
2003-09-11 09:18:07 +00:00
|
|
|
}
|
|
|
|
|
2011-03-09 17:29:09 +01:00
|
|
|
void SAL_CALL ZipPackageStream::setDataStream( const uno::Reference< io::XInputStream >& aStream )
|
2003-09-11 09:18:07 +00:00
|
|
|
throw ( io::IOException,
|
2014-02-25 21:31:58 +01:00
|
|
|
RuntimeException, std::exception )
|
2003-09-11 09:18:07 +00:00
|
|
|
{
|
|
|
|
setInputStream( aStream );
|
|
|
|
m_nStreamMode = PACKAGE_STREAM_DATA;
|
|
|
|
}
|
|
|
|
|
2011-03-09 17:29:09 +01:00
|
|
|
void SAL_CALL ZipPackageStream::setRawStream( const uno::Reference< io::XInputStream >& aStream )
|
2003-09-11 09:18:07 +00:00
|
|
|
throw ( packages::EncryptionNotAllowedException,
|
|
|
|
packages::NoRawFormatException,
|
|
|
|
io::IOException,
|
2014-02-25 21:31:58 +01:00
|
|
|
RuntimeException, std::exception )
|
2003-09-11 09:18:07 +00:00
|
|
|
{
|
2004-05-10 16:29:52 +00:00
|
|
|
// wrap the stream in case it is not seekable
|
2013-01-31 17:08:44 +02:00
|
|
|
uno::Reference< io::XInputStream > xNewStream = ::comphelper::OSeekableInputWrapper::CheckSeekableCanWrap( aStream, m_xContext );
|
2011-03-09 17:29:09 +01:00
|
|
|
uno::Reference< io::XSeekable > xSeek( xNewStream, UNO_QUERY );
|
2003-09-11 09:18:07 +00:00
|
|
|
if ( !xSeek.is() )
|
2014-05-23 12:03:21 +02:00
|
|
|
throw RuntimeException(THROW_WHERE "The stream must support XSeekable!" );
|
2003-09-11 09:18:07 +00:00
|
|
|
|
|
|
|
xSeek->seek( 0 );
|
2011-03-09 17:29:09 +01:00
|
|
|
uno::Reference< io::XInputStream > xOldStream = xStream;
|
2004-05-10 16:29:52 +00:00
|
|
|
xStream = xNewStream;
|
2003-09-11 09:18:07 +00:00
|
|
|
if ( !ParsePackageRawStream() )
|
|
|
|
{
|
|
|
|
xStream = xOldStream;
|
2014-05-23 12:03:21 +02:00
|
|
|
throw packages::NoRawFormatException(THROW_WHERE );
|
2003-09-11 09:18:07 +00:00
|
|
|
}
|
|
|
|
|
2005-10-19 11:49:50 +00:00
|
|
|
// the raw stream MUST have seekable access
|
2014-04-17 13:40:46 +02:00
|
|
|
m_bHasSeekable = true;
|
2005-10-19 11:49:50 +00:00
|
|
|
|
2014-04-17 13:40:46 +02:00
|
|
|
SetPackageMember ( false );
|
2003-09-11 09:18:07 +00:00
|
|
|
aEntry.nTime = -1;
|
|
|
|
m_nStreamMode = PACKAGE_STREAM_RAW;
|
|
|
|
}
|
|
|
|
|
2004-11-26 19:46:22 +00:00
|
|
|
uno::Reference< io::XInputStream > SAL_CALL ZipPackageStream::getPlainRawStream()
|
|
|
|
throw ( io::IOException,
|
2014-02-25 21:31:58 +01:00
|
|
|
uno::RuntimeException, std::exception )
|
2004-11-26 19:46:22 +00:00
|
|
|
{
|
|
|
|
// There is no stream attached to this object
|
|
|
|
if ( m_nStreamMode == PACKAGE_STREAM_NOTSET )
|
2011-03-09 17:29:09 +01:00
|
|
|
return uno::Reference< io::XInputStream >();
|
2004-11-26 19:46:22 +00:00
|
|
|
|
|
|
|
// this method can not be used together with old approach
|
|
|
|
if ( m_nStreamMode == PACKAGE_STREAM_DETECT )
|
2014-05-23 12:03:21 +02:00
|
|
|
throw packages::zip::ZipIOException(THROW_WHERE );
|
2004-11-26 19:46:22 +00:00
|
|
|
|
2011-03-09 17:29:09 +01:00
|
|
|
if ( IsPackageMember() )
|
2004-11-26 19:46:22 +00:00
|
|
|
{
|
2011-03-09 17:29:09 +01:00
|
|
|
return rZipPackage.getZipFile().getRawData( aEntry, GetEncryptionData(), bIsEncrypted, rZipPackage.GetSharedMutexRef() );
|
2004-11-26 19:46:22 +00:00
|
|
|
}
|
2005-10-19 11:49:50 +00:00
|
|
|
else if ( GetOwnSeekStream().is() )
|
2004-11-26 19:46:22 +00:00
|
|
|
{
|
|
|
|
if ( m_nStreamMode == PACKAGE_STREAM_RAW )
|
|
|
|
{
|
|
|
|
// the header should not be returned here
|
|
|
|
return GetRawEncrStreamNoHeaderCopy();
|
|
|
|
}
|
|
|
|
else if ( m_nStreamMode == PACKAGE_STREAM_DATA )
|
2014-04-17 13:40:46 +02:00
|
|
|
return TryToGetRawFromDataStream( false );
|
2004-11-26 19:46:22 +00:00
|
|
|
}
|
|
|
|
|
2011-03-09 17:29:09 +01:00
|
|
|
return uno::Reference< io::XInputStream >();
|
2004-11-26 19:46:22 +00:00
|
|
|
}
|
2003-09-11 09:18:07 +00:00
|
|
|
|
|
|
|
// XUnoTunnel
|
2000-11-21 09:43:06 +00:00
|
|
|
|
2001-04-27 13:56:07 +00:00
|
|
|
sal_Int64 SAL_CALL ZipPackageStream::getSomething( const Sequence< sal_Int8 >& aIdentifier )
|
2014-02-25 21:31:58 +01:00
|
|
|
throw( RuntimeException, std::exception )
|
2000-11-21 09:43:06 +00:00
|
|
|
{
|
2001-05-31 09:29:31 +00:00
|
|
|
sal_Int64 nMe = 0;
|
2001-10-02 21:27:29 +00:00
|
|
|
if ( aIdentifier.getLength() == 16 &&
|
2012-07-28 22:01:59 +02:00
|
|
|
0 == memcmp( static_getImplementationId().getConstArray(), aIdentifier.getConstArray(), 16 ) )
|
2001-05-31 09:29:31 +00:00
|
|
|
nMe = reinterpret_cast < sal_Int64 > ( this );
|
|
|
|
return nMe;
|
2000-11-21 09:43:06 +00:00
|
|
|
}
|
2001-10-02 21:27:29 +00:00
|
|
|
|
|
|
|
// XPropertySet
|
2001-04-27 13:56:07 +00:00
|
|
|
void SAL_CALL ZipPackageStream::setPropertyValue( const OUString& aPropertyName, const Any& aValue )
|
2014-02-25 21:31:58 +01:00
|
|
|
throw( beans::UnknownPropertyException, beans::PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException, std::exception )
|
2001-04-27 13:56:07 +00:00
|
|
|
{
|
2012-04-06 14:28:18 +02:00
|
|
|
if ( aPropertyName == "MediaType" )
|
2001-04-27 13:56:07 +00:00
|
|
|
{
|
2010-04-13 10:20:02 +02:00
|
|
|
if ( rZipPackage.getFormat() != embed::StorageFormats::PACKAGE && rZipPackage.getFormat() != embed::StorageFormats::OFOPXML )
|
2014-05-23 12:03:21 +02:00
|
|
|
throw beans::PropertyVetoException(THROW_WHERE );
|
2004-08-12 10:55:22 +00:00
|
|
|
|
2014-10-07 13:56:26 +02:00
|
|
|
if ( aValue >>= msMediaType )
|
2001-04-27 13:56:07 +00:00
|
|
|
{
|
2014-10-07 13:56:26 +02:00
|
|
|
if ( !msMediaType.isEmpty() )
|
2003-09-11 09:18:07 +00:00
|
|
|
{
|
2014-10-07 13:56:26 +02:00
|
|
|
if ( msMediaType.indexOf ( "text" ) != -1
|
|
|
|
|| msMediaType == "application/vnd.sun.star.oleobject" )
|
2014-04-17 13:40:46 +02:00
|
|
|
bToBeCompressed = true;
|
2006-10-13 10:52:21 +00:00
|
|
|
else if ( !m_bCompressedIsSetFromOutside )
|
2014-04-17 13:40:46 +02:00
|
|
|
bToBeCompressed = false;
|
2003-09-11 09:18:07 +00:00
|
|
|
}
|
2001-04-27 13:56:07 +00:00
|
|
|
}
|
2003-09-11 09:18:07 +00:00
|
|
|
else
|
2014-05-28 10:11:15 +02:00
|
|
|
throw IllegalArgumentException(THROW_WHERE "MediaType must be a string!",
|
2011-03-09 17:29:09 +01:00
|
|
|
uno::Reference< XInterface >(),
|
2003-09-11 09:18:07 +00:00
|
|
|
2 );
|
|
|
|
|
2001-04-27 13:56:07 +00:00
|
|
|
}
|
2012-04-06 14:28:18 +02:00
|
|
|
else if ( aPropertyName == "Size" )
|
2003-09-11 09:18:07 +00:00
|
|
|
{
|
|
|
|
if ( !( aValue >>= aEntry.nSize ) )
|
2014-05-28 10:11:15 +02:00
|
|
|
throw IllegalArgumentException(THROW_WHERE "Wrong type for Size property!",
|
2011-03-09 17:29:09 +01:00
|
|
|
uno::Reference< XInterface >(),
|
2003-09-11 09:18:07 +00:00
|
|
|
2 );
|
|
|
|
}
|
2012-04-06 14:28:18 +02:00
|
|
|
else if ( aPropertyName == "Encrypted" )
|
2001-05-31 09:29:31 +00:00
|
|
|
{
|
2010-04-13 10:20:02 +02:00
|
|
|
if ( rZipPackage.getFormat() != embed::StorageFormats::PACKAGE )
|
2014-05-23 12:03:21 +02:00
|
|
|
throw beans::PropertyVetoException(THROW_WHERE );
|
2004-08-12 10:55:22 +00:00
|
|
|
|
2014-04-17 13:40:46 +02:00
|
|
|
bool bEnc = false;
|
2003-09-11 09:18:07 +00:00
|
|
|
if ( aValue >>= bEnc )
|
|
|
|
{
|
|
|
|
// In case of new raw stream, the stream must not be encrypted on storing
|
|
|
|
if ( bEnc && m_nStreamMode == PACKAGE_STREAM_RAW )
|
2014-01-27 22:51:45 +01:00
|
|
|
throw IllegalArgumentException(THROW_WHERE "Raw stream can not be encrypted on storing",
|
2011-03-09 17:29:09 +01:00
|
|
|
uno::Reference< XInterface >(),
|
2003-09-11 09:18:07 +00:00
|
|
|
2 );
|
|
|
|
|
|
|
|
bToBeEncrypted = bEnc;
|
2011-03-09 17:29:09 +01:00
|
|
|
if ( bToBeEncrypted && !m_xBaseEncryptionData.is() )
|
|
|
|
m_xBaseEncryptionData = new BaseEncryptionData;
|
2003-09-11 09:18:07 +00:00
|
|
|
}
|
|
|
|
else
|
2014-05-28 10:11:15 +02:00
|
|
|
throw IllegalArgumentException(THROW_WHERE "Wrong type for Encrypted property!",
|
2011-03-09 17:29:09 +01:00
|
|
|
uno::Reference< XInterface >(),
|
2003-09-11 09:18:07 +00:00
|
|
|
2 );
|
|
|
|
|
2001-05-31 09:29:31 +00:00
|
|
|
}
|
2012-04-06 14:28:18 +02:00
|
|
|
else if ( aPropertyName == ENCRYPTION_KEY_PROPERTY )
|
2001-09-24 17:25:30 +00:00
|
|
|
{
|
2010-04-13 10:20:02 +02:00
|
|
|
if ( rZipPackage.getFormat() != embed::StorageFormats::PACKAGE )
|
2014-05-23 12:03:21 +02:00
|
|
|
throw beans::PropertyVetoException(THROW_WHERE );
|
2004-08-12 10:55:22 +00:00
|
|
|
|
2011-03-09 17:29:09 +01:00
|
|
|
uno::Sequence< sal_Int8 > aNewKey;
|
2003-09-11 09:18:07 +00:00
|
|
|
|
|
|
|
if ( !( aValue >>= aNewKey ) )
|
2001-11-15 19:27:48 +00:00
|
|
|
{
|
|
|
|
OUString sTempString;
|
|
|
|
if ( ( aValue >>= sTempString ) )
|
|
|
|
{
|
2009-09-17 13:53:54 +00:00
|
|
|
sal_Int32 nPathLength = sTempString.getLength();
|
|
|
|
Sequence < sal_Int8 > aSequence ( nPathLength );
|
2001-11-15 19:27:48 +00:00
|
|
|
sal_Int8 *pArray = aSequence.getArray();
|
|
|
|
const sal_Unicode *pChar = sTempString.getStr();
|
2011-03-09 17:29:09 +01:00
|
|
|
for ( sal_Int16 i = 0; i < nPathLength; i++ )
|
|
|
|
pArray[i] = static_cast < const sal_Int8 > ( pChar[i] );
|
2003-09-11 09:18:07 +00:00
|
|
|
aNewKey = aSequence;
|
2001-11-15 19:27:48 +00:00
|
|
|
}
|
|
|
|
else
|
2014-05-28 10:11:15 +02:00
|
|
|
throw IllegalArgumentException(THROW_WHERE "Wrong type for EncryptionKey property!",
|
2011-03-09 17:29:09 +01:00
|
|
|
uno::Reference< XInterface >(),
|
2003-09-11 09:18:07 +00:00
|
|
|
2 );
|
2001-11-15 19:27:48 +00:00
|
|
|
}
|
2003-09-11 09:18:07 +00:00
|
|
|
|
|
|
|
if ( aNewKey.getLength() )
|
|
|
|
{
|
2011-03-09 17:29:09 +01:00
|
|
|
if ( !m_xBaseEncryptionData.is() )
|
|
|
|
m_xBaseEncryptionData = new BaseEncryptionData;
|
|
|
|
|
|
|
|
m_aEncryptionKey = aNewKey;
|
|
|
|
// In case of new raw stream, the stream must not be encrypted on storing
|
2014-04-17 13:40:46 +02:00
|
|
|
bHaveOwnKey = true;
|
2011-03-09 17:29:09 +01:00
|
|
|
if ( m_nStreamMode != PACKAGE_STREAM_RAW )
|
2014-04-17 13:40:46 +02:00
|
|
|
bToBeEncrypted = true;
|
2011-03-09 17:29:09 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-04-17 13:40:46 +02:00
|
|
|
bHaveOwnKey = false;
|
2011-03-09 17:29:09 +01:00
|
|
|
m_aEncryptionKey.realloc( 0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
m_aStorageEncryptionKeys.realloc( 0 );
|
|
|
|
}
|
2012-04-06 14:28:18 +02:00
|
|
|
else if ( aPropertyName == STORAGE_ENCRYPTION_KEYS_PROPERTY )
|
2011-03-09 17:29:09 +01:00
|
|
|
{
|
|
|
|
if ( rZipPackage.getFormat() != embed::StorageFormats::PACKAGE )
|
2014-05-23 12:03:21 +02:00
|
|
|
throw beans::PropertyVetoException(THROW_WHERE );
|
2011-03-09 17:29:09 +01:00
|
|
|
|
|
|
|
uno::Sequence< beans::NamedValue > aKeys;
|
|
|
|
if ( !( aValue >>= aKeys ) )
|
|
|
|
{
|
2014-05-28 10:11:15 +02:00
|
|
|
throw IllegalArgumentException(THROW_WHERE "Wrong type for StorageEncryptionKeys property!",
|
2011-03-09 17:29:09 +01:00
|
|
|
uno::Reference< XInterface >(),
|
|
|
|
2 );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( aKeys.getLength() )
|
|
|
|
{
|
|
|
|
if ( !m_xBaseEncryptionData.is() )
|
|
|
|
m_xBaseEncryptionData = new BaseEncryptionData;
|
|
|
|
|
|
|
|
m_aStorageEncryptionKeys = aKeys;
|
2003-09-11 09:18:07 +00:00
|
|
|
|
|
|
|
// In case of new raw stream, the stream must not be encrypted on storing
|
2014-04-17 13:40:46 +02:00
|
|
|
bHaveOwnKey = true;
|
2003-09-11 09:18:07 +00:00
|
|
|
if ( m_nStreamMode != PACKAGE_STREAM_RAW )
|
2014-04-17 13:40:46 +02:00
|
|
|
bToBeEncrypted = true;
|
2003-09-11 09:18:07 +00:00
|
|
|
}
|
|
|
|
else
|
2011-03-09 17:29:09 +01:00
|
|
|
{
|
2014-04-17 13:40:46 +02:00
|
|
|
bHaveOwnKey = false;
|
2011-03-09 17:29:09 +01:00
|
|
|
m_aStorageEncryptionKeys.realloc( 0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
m_aEncryptionKey.realloc( 0 );
|
2001-09-24 17:25:30 +00:00
|
|
|
}
|
2012-08-17 22:06:10 +02:00
|
|
|
else if ( aPropertyName == "Compressed" )
|
2003-09-11 09:18:07 +00:00
|
|
|
{
|
2014-04-17 13:40:46 +02:00
|
|
|
bool bCompr = false;
|
2003-09-11 09:18:07 +00:00
|
|
|
|
|
|
|
if ( aValue >>= bCompr )
|
|
|
|
{
|
|
|
|
// In case of new raw stream, the stream must not be encrypted on storing
|
|
|
|
if ( bCompr && m_nStreamMode == PACKAGE_STREAM_RAW )
|
2014-01-27 22:51:45 +01:00
|
|
|
throw IllegalArgumentException(THROW_WHERE "Raw stream can not be encrypted on storing",
|
2011-03-09 17:29:09 +01:00
|
|
|
uno::Reference< XInterface >(),
|
2003-09-11 09:18:07 +00:00
|
|
|
2 );
|
|
|
|
|
|
|
|
bToBeCompressed = bCompr;
|
2014-04-17 13:40:46 +02:00
|
|
|
m_bCompressedIsSetFromOutside = true;
|
2003-09-11 09:18:07 +00:00
|
|
|
}
|
|
|
|
else
|
2014-05-28 10:11:15 +02:00
|
|
|
throw IllegalArgumentException(THROW_WHERE "Wrong type for Compressed property!",
|
2011-03-09 17:29:09 +01:00
|
|
|
uno::Reference< XInterface >(),
|
2003-09-11 09:18:07 +00:00
|
|
|
2 );
|
|
|
|
}
|
2001-04-27 13:56:07 +00:00
|
|
|
else
|
2014-05-23 12:03:21 +02:00
|
|
|
throw beans::UnknownPropertyException(THROW_WHERE );
|
2001-04-27 13:56:07 +00:00
|
|
|
}
|
2001-09-24 17:25:30 +00:00
|
|
|
|
2001-04-27 13:56:07 +00:00
|
|
|
Any SAL_CALL ZipPackageStream::getPropertyValue( const OUString& PropertyName )
|
2014-02-25 21:31:58 +01:00
|
|
|
throw( beans::UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception )
|
2001-04-27 13:56:07 +00:00
|
|
|
{
|
|
|
|
Any aAny;
|
2012-04-06 14:28:18 +02:00
|
|
|
if ( PropertyName == "MediaType" )
|
2001-04-27 13:56:07 +00:00
|
|
|
{
|
2014-10-07 13:56:26 +02:00
|
|
|
aAny <<= msMediaType;
|
2001-04-27 13:56:07 +00:00
|
|
|
return aAny;
|
|
|
|
}
|
2012-04-06 14:28:18 +02:00
|
|
|
else if ( PropertyName == "Size" )
|
2001-04-27 13:56:07 +00:00
|
|
|
{
|
|
|
|
aAny <<= aEntry.nSize;
|
|
|
|
return aAny;
|
|
|
|
}
|
2012-04-06 14:28:18 +02:00
|
|
|
else if ( PropertyName == "Encrypted" )
|
2001-04-27 13:56:07 +00:00
|
|
|
{
|
2014-04-17 13:40:46 +02:00
|
|
|
aAny <<= ((m_nStreamMode == PACKAGE_STREAM_RAW) || bToBeEncrypted);
|
2001-04-27 13:56:07 +00:00
|
|
|
return aAny;
|
|
|
|
}
|
2012-04-06 14:28:18 +02:00
|
|
|
else if ( PropertyName == "WasEncrypted" )
|
2004-05-10 16:29:52 +00:00
|
|
|
{
|
|
|
|
aAny <<= bIsEncrypted;
|
|
|
|
return aAny;
|
|
|
|
}
|
2012-04-06 14:28:18 +02:00
|
|
|
else if ( PropertyName == "Compressed" )
|
2001-04-27 13:56:07 +00:00
|
|
|
{
|
|
|
|
aAny <<= bToBeCompressed;
|
|
|
|
return aAny;
|
|
|
|
}
|
2012-04-06 14:28:18 +02:00
|
|
|
else if ( PropertyName == ENCRYPTION_KEY_PROPERTY )
|
2001-09-24 17:25:30 +00:00
|
|
|
{
|
2011-03-09 17:29:09 +01:00
|
|
|
aAny <<= m_aEncryptionKey;
|
2001-09-24 17:25:30 +00:00
|
|
|
return aAny;
|
|
|
|
}
|
2012-04-06 14:28:18 +02:00
|
|
|
else if ( PropertyName == STORAGE_ENCRYPTION_KEYS_PROPERTY )
|
2001-09-24 17:25:30 +00:00
|
|
|
{
|
2011-03-23 14:13:24 +01:00
|
|
|
aAny <<= m_aStorageEncryptionKeys;
|
2001-09-24 17:25:30 +00:00
|
|
|
return aAny;
|
|
|
|
}
|
2001-04-27 13:56:07 +00:00
|
|
|
else
|
2014-05-23 12:03:21 +02:00
|
|
|
throw beans::UnknownPropertyException(THROW_WHERE );
|
2001-04-27 13:56:07 +00:00
|
|
|
}
|
2003-09-11 09:18:07 +00:00
|
|
|
|
2012-09-21 13:09:29 +01:00
|
|
|
void ZipPackageStream::setSize ( const sal_Int64 nNewSize )
|
2001-05-17 15:17:06 +00:00
|
|
|
{
|
2011-03-09 17:29:09 +01:00
|
|
|
if ( aEntry.nCompressedSize != nNewSize )
|
2001-05-17 15:17:06 +00:00
|
|
|
aEntry.nMethod = DEFLATED;
|
|
|
|
aEntry.nSize = nNewSize;
|
|
|
|
}
|
2001-11-15 19:27:48 +00:00
|
|
|
OUString ZipPackageStream::getImplementationName()
|
2014-02-25 21:31:58 +01:00
|
|
|
throw ( RuntimeException, std::exception )
|
2001-11-15 19:27:48 +00:00
|
|
|
{
|
2012-08-17 22:06:10 +02:00
|
|
|
return OUString ("ZipPackageStream");
|
2001-11-15 19:27:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Sequence< OUString > ZipPackageStream::getSupportedServiceNames()
|
2014-02-25 21:31:58 +01:00
|
|
|
throw ( RuntimeException, std::exception )
|
2001-11-15 19:27:48 +00:00
|
|
|
{
|
2011-03-09 17:29:09 +01:00
|
|
|
Sequence< OUString > aNames( 1 );
|
2012-08-17 22:06:10 +02:00
|
|
|
aNames[0] = "com.sun.star.packages.PackageStream";
|
2001-11-15 19:27:48 +00:00
|
|
|
return aNames;
|
|
|
|
}
|
2013-07-29 22:22:17 +02:00
|
|
|
|
2001-11-15 19:27:48 +00:00
|
|
|
sal_Bool SAL_CALL ZipPackageStream::supportsService( OUString const & rServiceName )
|
2014-02-25 21:31:58 +01:00
|
|
|
throw ( RuntimeException, std::exception )
|
2001-11-15 19:27:48 +00:00
|
|
|
{
|
2013-10-26 14:22:21 -02:00
|
|
|
return cppu::supportsService(this, rServiceName);
|
2001-11-15 19:27:48 +00:00
|
|
|
}
|
2004-02-03 17:26:32 +00:00
|
|
|
|
2010-10-12 15:57:08 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|