diff options
author | Oliver Bolte <obo@openoffice.org> | 2004-05-28 14:17:16 +0000 |
---|---|---|
committer | Oliver Bolte <obo@openoffice.org> | 2004-05-28 14:17:16 +0000 |
commit | 4b50fee3a484234d93aa424c8ef21ed573374885 (patch) | |
tree | 4fc29c0e76bb3d781f794b2f3d3b12e3d2b4a023 /ucb | |
parent | INTEGRATION: CWS tdocfixes1 (1.1.2); FILE ADDED (diff) | |
download | core-4b50fee3a484234d93aa424c8ef21ed573374885.tar.gz core-4b50fee3a484234d93aa424c8ef21ed573374885.zip |
INTEGRATION: CWS tdocfixes1 (1.2.14); FILE MERGED
2004/05/18 14:52:18 kso 1.2.14.7: #116171# - Adapted to src680 m39 XStorage API changes.
Issue number:
Submitted by:
Reviewed by:
2004/05/18 12:09:33 kso 1.2.14.6: RESYNC: (1.2-1.3); FILE MERGED
2004/05/14 10:22:55 kso 1.2.14.5: #116171# - Value of property "Storage" now always is a clone.
Issue number:
Submitted by:
Reviewed by:
2004/05/13 15:44:27 kso 1.2.14.4: #116171# Changes from lst revision withdrawn; performance problems.
Issue number:
Submitted by:
Reviewed by:
2004/05/12 14:34:23 kso 1.2.14.3: #116171# - store objects do not hold parent storage when in read-only mode
- clone storages when read-only mode
Issue number:
Submitted by:
Reviewed by:
2004/05/12 12:33:12 kso 1.2.14.2: #i27499# - Added support for XActiveDataStreamer to 'open' command.
Issue number:
Submitted by:
Reviewed by:
2004/05/07 13:57:58 kso 1.2.14.1: #i27500# : writable streams are now opened truncated
- streams are now opened seekable
- fixed implementation of XTypeProvider for class Storage,InputStream,OutputStream
Issue number:
Submitted by:
Reviewed by:
Diffstat (limited to 'ucb')
-rw-r--r-- | ucb/source/ucp/tdoc/tdoc_storage.cxx | 1420 |
1 files changed, 148 insertions, 1272 deletions
diff --git a/ucb/source/ucp/tdoc/tdoc_storage.cxx b/ucb/source/ucp/tdoc/tdoc_storage.cxx index 2e903c26e6b6..ede92bfa2273 100644 --- a/ucb/source/ucp/tdoc/tdoc_storage.cxx +++ b/ucb/source/ucp/tdoc/tdoc_storage.cxx @@ -2,9 +2,9 @@ * * $RCSfile: tdoc_storage.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: hr $ $Date: 2004-05-10 17:40:11 $ + * last change: $Author: obo $ $Date: 2004-05-28 15:17:16 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -63,27 +63,21 @@ TODO ************************************************************************** + - remove root storage access workaround + *************************************************************************/ -#include <memory> +#define ROOTSTORAGE_ACCESS_WORKAROUND 1 -#include "osl/mutex.hxx" +#include <memory> #include "com/sun/star/beans/XPropertySet.hpp" #include "com/sun/star/embed/ElementModes.hpp" -#include "com/sun/star/embed/XTransactedObject.hpp" -#include "com/sun/star/io/IOException.hpp" -#include "com/sun/star/lang/DisposedException.hpp" -#include "com/sun/star/lang/XComponent.hpp" #include "com/sun/star/lang/XSingleServiceFactory.hpp" -#include "com/sun/star/reflection/XProxyFactory.hpp" -#include "com/sun/star/uno/XAggregation.hpp" - -#include "cppuhelper/implbase1.hxx" -#include "cppuhelper/implbase2.hxx" #include "tdoc_uri.hxx" #include "tdoc_docmgr.hxx" +#include "tdoc_stgelems.hxx" #include "tdoc_storage.hxx" @@ -92,351 +86,6 @@ using namespace com::sun::star; using namespace tdoc_ucp; -namespace tdoc_ucp -{ - struct MutexHolder - { - osl::Mutex m_aMutex; - }; - - //======================================================================= - - class ParentStorageHolder : public MutexHolder - { - public: - ParentStorageHolder( - const uno::Reference< embed::XStorage > & xParentStorage, - const rtl::OUString & rUri ); - - bool isRootParentStorage() const - { return m_bParentStorageIsRoot; } - uno::Reference< embed::XStorage > getParentStorage() const - { return m_xParentStorage; } - void setParentStorage( const uno::Reference< embed::XStorage > & xStg ) - { osl::MutexGuard aGuard( m_aMutex ); m_xParentStorage = xStg; } - - private: - uno::Reference< embed::XStorage > m_xParentStorage; - bool m_bParentStorageIsRoot; - }; - - //======================================================================= - - typedef - cppu::WeakImplHelper2< - com::sun::star::embed::XStorage, - com::sun::star::embed::XTransactedObject > StorageUNOBase; - - class Storage : public StorageUNOBase, public ParentStorageHolder - { - public: - Storage( - const uno::Reference< lang::XMultiServiceFactory > & xSMgr, - const rtl::Reference< StorageElementFactory > & xFactory, - const rtl::OUString & rUri, - const uno::Reference< embed::XStorage > & xParentStorage, - const uno::Reference< embed::XStorage > & xStorageToWrap ); - virtual ~Storage(); - - // XInterface - virtual uno::Any SAL_CALL queryInterface( const uno::Type& aType ) - throw ( uno::RuntimeException ); - virtual void SAL_CALL acquire() - throw (); - virtual void SAL_CALL release() - throw (); - - // XStorage - virtual void SAL_CALL - copyToStorage( const uno::Reference< embed::XStorage >& xDest ) - throw ( embed::InvalidStorageException, - lang::IllegalArgumentException, - io::IOException, - embed::StorageWrappedTargetException, - uno::RuntimeException ); - virtual uno::Reference< io::XStream > SAL_CALL - openStreamElement( const ::rtl::OUString& aStreamName, - sal_Int32 nOpenMode ) - throw ( embed::InvalidStorageException, - lang::IllegalArgumentException, - packages::WrongPasswordException, - io::IOException, - embed::StorageWrappedTargetException, - uno::RuntimeException ); - virtual uno::Reference< io::XStream > SAL_CALL - openEncryptedStreamElement( const ::rtl::OUString& aStreamName, - sal_Int32 nOpenMode, - const ::rtl::OUString& aPassword ) - throw ( embed::InvalidStorageException, - lang::IllegalArgumentException, - packages::NoEncryptionException, - packages::WrongPasswordException, - io::IOException, - embed::StorageWrappedTargetException, - uno::RuntimeException ); - virtual uno::Reference< embed::XStorage > SAL_CALL - openStorageElement( const ::rtl::OUString& aStorName, - sal_Int32 nOpenMode ) - throw ( embed::InvalidStorageException, - lang::IllegalArgumentException, - io::IOException, - embed::StorageWrappedTargetException, - uno::RuntimeException ); - virtual uno::Reference< io::XStream > SAL_CALL - cloneStreamElement( const ::rtl::OUString& aStreamName ) - throw ( embed::InvalidStorageException, - lang::IllegalArgumentException, - packages::WrongPasswordException, - io::IOException, - embed::StorageWrappedTargetException, - uno::RuntimeException ); - virtual uno::Reference< io::XStream > SAL_CALL - cloneEncryptedStreamElement( const ::rtl::OUString& aStreamName, - const ::rtl::OUString& aPassword ) - throw ( embed::InvalidStorageException, - lang::IllegalArgumentException, - packages::NoEncryptionException, - packages::WrongPasswordException, - io::IOException, - embed::StorageWrappedTargetException, - uno::RuntimeException ); - virtual void SAL_CALL - copyLastCommitTo( const uno::Reference< embed::XStorage >& xTargetStorage ) - throw ( embed::InvalidStorageException, - lang::IllegalArgumentException, - io::IOException, - embed::StorageWrappedTargetException, - uno::RuntimeException ); - virtual void SAL_CALL - copyStorageElementLastCommitTo( const ::rtl::OUString& aStorName, - const uno::Reference< embed::XStorage >& xTargetStorage ) - throw ( embed::InvalidStorageException, - lang::IllegalArgumentException, - io::IOException, - embed::StorageWrappedTargetException, - uno::RuntimeException ); - virtual sal_Bool SAL_CALL - isStreamElement( const ::rtl::OUString& aElementName ) - throw ( container::NoSuchElementException, - lang::IllegalArgumentException, - embed::InvalidStorageException, - uno::RuntimeException ); - virtual sal_Bool SAL_CALL - isStorageElement( const ::rtl::OUString& aElementName ) - throw ( container::NoSuchElementException, - lang::IllegalArgumentException, - embed::InvalidStorageException, - uno::RuntimeException ); - virtual void SAL_CALL - removeElement( const ::rtl::OUString& aElementName ) - throw ( embed::InvalidStorageException, - lang::IllegalArgumentException, - container::NoSuchElementException, - io::IOException, - embed::StorageWrappedTargetException, - uno::RuntimeException ); - virtual void SAL_CALL - renameElement( const ::rtl::OUString& aEleName, - const ::rtl::OUString& aNewName ) - throw ( embed::InvalidStorageException, - lang::IllegalArgumentException, - container::NoSuchElementException, - container::ElementExistException, - io::IOException, - embed::StorageWrappedTargetException, - uno::RuntimeException ); - virtual void SAL_CALL - copyElementTo( const ::rtl::OUString& aElementName, - const uno::Reference< embed::XStorage >& xDest, - const ::rtl::OUString& aNewName ) - throw ( embed::InvalidStorageException, - lang::IllegalArgumentException, - container::NoSuchElementException, - container::ElementExistException, - io::IOException, - embed::StorageWrappedTargetException, - uno::RuntimeException ); - virtual void SAL_CALL - moveElementTo( const ::rtl::OUString& aElementName, - const uno::Reference< embed::XStorage >& xDest, - const ::rtl::OUString& rNewName ) - throw ( embed::InvalidStorageException, - lang::IllegalArgumentException, - container::NoSuchElementException, - container::ElementExistException, - io::IOException, - embed::StorageWrappedTargetException, - uno::RuntimeException ); - virtual void SAL_CALL - insertRawEncrStreamElement( const ::rtl::OUString& aStreamName, - const uno::Reference< - io::XInputStream >& xInStream ) - throw ( embed::InvalidStorageException, - lang::IllegalArgumentException, - packages::NoRawFormatException, - container::ElementExistException, - io::IOException, - embed::StorageWrappedTargetException, - uno::RuntimeException ); - - // XNameAccess - virtual uno::Any SAL_CALL - getByName( const ::rtl::OUString& aName ) - throw ( container::NoSuchElementException, - lang::WrappedTargetException, - uno::RuntimeException ); - virtual uno::Sequence< ::rtl::OUString > SAL_CALL - getElementNames() - throw ( uno::RuntimeException ); - virtual ::sal_Bool SAL_CALL - hasByName( const ::rtl::OUString& aName ) - throw ( uno::RuntimeException ); - virtual uno::Type SAL_CALL - getElementType() - throw ( uno::RuntimeException ); - virtual ::sal_Bool SAL_CALL - hasElements() - throw ( uno::RuntimeException ); - - // XComponent - virtual void SAL_CALL - dispose() - throw ( uno::RuntimeException ); - virtual void SAL_CALL - addEventListener( const uno::Reference< lang::XEventListener >& xListener ) - throw ( uno::RuntimeException ); - virtual void SAL_CALL - removeEventListener( const uno::Reference< lang::XEventListener >& aListener ) - throw (uno::RuntimeException); - - // XTransactedObject - virtual void SAL_CALL commit() - throw ( io::IOException, - lang::WrappedTargetException, - uno::RuntimeException ); - virtual void SAL_CALL revert() - throw ( io::IOException, - lang::WrappedTargetException, - uno::RuntimeException ); - - private: - Storage( const rtl::Reference< Storage > & rFactory ); // n.i. - - // not done in ctor to avoid refcounting problems. - void setDelegator(); - - rtl::Reference< StorageElementFactory > m_xFactory; - uno::Reference< embed::XStorage > m_xWrappedStorage; - uno::Reference< uno::XAggregation > m_xWrappedAggregate; - bool m_bDelegatorSet; - StorageElementFactory::StorageMap::iterator m_aContainerIt; - - friend class StorageElementFactory; - friend class std::auto_ptr< Storage >; - }; - - //======================================================================= - - typedef - cppu::WeakImplHelper1< - com::sun::star::io::XInputStream > InputStreamUNOBase; - - class InputStream : public InputStreamUNOBase, public ParentStorageHolder - { - public: - InputStream( - const uno::Reference< lang::XMultiServiceFactory > & xSMgr, - const rtl::OUString & rUri, - const uno::Reference< embed::XStorage > & xParentStorage, - const uno::Reference< io::XInputStream > & xStreamToWrap ); - virtual ~InputStream(); - - // XInterface - virtual uno::Any SAL_CALL queryInterface( const uno::Type& aType ) - throw ( uno::RuntimeException ); - - // XInputStream - virtual sal_Int32 SAL_CALL - readBytes( uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead ) - throw ( io::NotConnectedException, - io::BufferSizeExceededException, - io::IOException, - uno::RuntimeException ); - virtual sal_Int32 SAL_CALL - readSomeBytes( uno::Sequence< sal_Int8 >& aData, - sal_Int32 nMaxBytesToRead ) - throw ( io::NotConnectedException, - io::BufferSizeExceededException, - io::IOException, - uno::RuntimeException ); - virtual void SAL_CALL - skipBytes( sal_Int32 nBytesToSkip ) - throw ( io::NotConnectedException, - io::BufferSizeExceededException, - io::IOException, - uno::RuntimeException ); - virtual sal_Int32 SAL_CALL - available() - throw ( io::NotConnectedException, - io::IOException, - uno::RuntimeException ); - // Note: We need to intercept this one. - virtual void SAL_CALL - closeInput() - throw ( io::NotConnectedException, - io::IOException, - uno::RuntimeException ); - private: - uno::Reference< io::XInputStream > m_xWrappedStream; - uno::Reference< uno::XAggregation > m_xWrappedAggregate; - }; - - //======================================================================= - - typedef - cppu::WeakImplHelper1< - com::sun::star::io::XOutputStream > OutputStreamUNOBase; - - class OutputStream : public OutputStreamUNOBase, public ParentStorageHolder - { - public: - OutputStream( - const uno::Reference< lang::XMultiServiceFactory > & xSMgr, - const rtl::OUString & rUri, - const uno::Reference< embed::XStorage > & xParentStorage, - const uno::Reference< io::XOutputStream > & xStreamToWrap ); - virtual ~OutputStream(); - - // XInterface - virtual uno::Any SAL_CALL queryInterface( const uno::Type& aType ) - throw ( uno::RuntimeException ); - - // XOutputStream - virtual void SAL_CALL - writeBytes( const uno::Sequence< sal_Int8 >& aData ) - throw ( io::NotConnectedException, - io::BufferSizeExceededException, - io::IOException, - uno::RuntimeException ); - virtual void SAL_CALL - flush( ) - throw ( io::NotConnectedException, - io::BufferSizeExceededException, - io::IOException, - uno::RuntimeException ); - // Note: We need to intercept this one. - virtual void SAL_CALL - closeOutput( ) - throw ( io::NotConnectedException, - io::BufferSizeExceededException, - io::IOException, - uno::RuntimeException ); - private: - uno::Reference< io::XOutputStream > m_xWrappedStream; - uno::Reference< uno::XAggregation > m_xWrappedAggregate; - }; - -} // namespace tdoc_ucp //========================================================================= //========================================================================= @@ -503,7 +152,6 @@ StorageElementFactory::createStorage( const rtl::OUString & rUri, osl::MutexGuard aGuard( m_aMutex ); if ( ( eMode != READ ) && - ( eMode != READ_ONLY ) && ( eMode != READ_WRITE_NOCREATE ) && ( eMode != READ_WRITE_CREATE ) ) throw lang::IllegalArgumentException( @@ -543,11 +191,6 @@ StorageElementFactory::createStorage( const rtl::OUString & rUri, bMatch = true; break; - case READ_ONLY: - // If found storage is writable, it cannot be used. - bMatch = !(*aIt).first.second; - break; - case READ_WRITE_NOCREATE: case READ_WRITE_CREATE: // If found storage is writable, it can be used. @@ -591,12 +234,12 @@ StorageElementFactory::createStorage( const rtl::OUString & rUri, return xStorage; } - std::auto_ptr< Storage > xElement( - new Storage( m_xSMgr, this, aUriKey, xParentStorage, xStorage ) ); - bool bWritable = ( ( eMode == READ_WRITE_NOCREATE ) || ( eMode == READ_WRITE_CREATE ) ); + std::auto_ptr< Storage > xElement( + new Storage( m_xSMgr, this, aUriKey, xParentStorage, xStorage ) ); + aIt = m_aMap.insert( StorageMap::value_type( std::pair< rtl::OUString, bool >( aUriKey, bWritable ), @@ -644,6 +287,8 @@ StorageElementFactory::createStorage( const rtl::OUString & rUri, return xStorage; } + bool bWritable = ( ( eMode == READ_WRITE_NOCREATE ) + || ( eMode == READ_WRITE_CREATE ) ); aIt->second = new Storage( m_xSMgr, this, aUriKey, xParentStorage, xStorage ); aIt->second->m_aContainerIt = aIt; @@ -672,20 +317,19 @@ StorageElementFactory::createInputStream( const rtl::OUString & rUri, return uno::Reference< io::XInputStream >(); uno::Reference< io::XStream > xStream - = queryStream( xParentStorage, rUri, rPassword, READ ); + = queryStream( xParentStorage, rUri, rPassword, READ, false ); if ( !xStream.is() ) return uno::Reference< io::XInputStream >(); - return uno::Reference< io::XInputStream >( - new InputStream( - m_xSMgr, rUri, xParentStorage, xStream->getInputStream() ) ); + return xStream->getInputStream(); } //========================================================================= uno::Reference< io::XOutputStream > StorageElementFactory::createOutputStream( const rtl::OUString & rUri, - const rtl::OUString & rPassword ) + const rtl::OUString & rPassword, + bool bTruncate ) throw ( embed::InvalidStorageException, lang::IllegalArgumentException, io::IOException, @@ -708,7 +352,8 @@ StorageElementFactory::createOutputStream( const rtl::OUString & rUri, } uno::Reference< io::XStream > xStream - = queryStream( xParentStorage, rUri, rPassword, READ_WRITE_CREATE ); + = queryStream( + xParentStorage, rUri, rPassword, READ_WRITE_CREATE, bTruncate ); if ( !xStream.is() ) { @@ -718,12 +363,59 @@ StorageElementFactory::createOutputStream( const rtl::OUString & rUri, return uno::Reference< io::XOutputStream >(); } + // Note: We need a wrapper to hold a reference to the parent storage to + // ensure that nobody else owns it at the moment we want to commit + // our changes. (There can be only one writable instance at a time + // and even no writable instance if there is already another + // read-only instance!) return uno::Reference< io::XOutputStream >( new OutputStream( m_xSMgr, rUri, xParentStorage, xStream->getOutputStream() ) ); } //========================================================================= +uno::Reference< io::XStream > +StorageElementFactory::createStream( const rtl::OUString & rUri, + const rtl::OUString & rPassword, + bool bTruncate ) + throw ( embed::InvalidStorageException, + lang::IllegalArgumentException, + io::IOException, + embed::StorageWrappedTargetException, + packages::WrongPasswordException, + uno::RuntimeException ) +{ + osl::MutexGuard aGuard( m_aMutex ); + + uno::Reference< embed::XStorage > xParentStorage + = queryParentStorage( rUri, READ_WRITE_CREATE ); + + // Each stream must have a parent storage. + if ( !xParentStorage.is() ) + { + OSL_ENSURE( false, + "StorageElementFactory::createStream - " + "Unable to create parent storage!" ); + return uno::Reference< io::XStream >(); + } + + uno::Reference< io::XStream > xStream + = queryStream( + xParentStorage, rUri, rPassword, READ_WRITE_NOCREATE, bTruncate ); + + if ( !xStream.is() ) + { + OSL_ENSURE( false, + "StorageElementFactory::createStream - " + "Unable to create stream!" ); + return uno::Reference< io::XStream >(); + } + + return uno::Reference< io::XStream >( + new Stream( m_xSMgr, rUri, xParentStorage, xStream ) ); +} + +//========================================================================= void StorageElementFactory::releaseElement( Storage * pElement ) SAL_THROW( () ) { OSL_ASSERT( pElement ); @@ -817,8 +509,7 @@ uno::Reference< embed::XStorage > StorageElementFactory::queryStorage( switch ( eMode ) { case READ: - if ( !( nOpenMode - & embed::ElementModes::READ ) ) + if ( !( nOpenMode & embed::ElementModes::READ ) ) { // document opened, but not readable. throw embed::InvalidStorageException( @@ -829,22 +520,9 @@ uno::Reference< embed::XStorage > StorageElementFactory::queryStorage( // storage okay break; - case READ_ONLY: - if ( nOpenMode & embed::ElementModes::WRITE ) - { - // document opened, but it's writable. - throw embed::InvalidStorageException( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( - "Storage is open, but writable!" ) ), - uno::Reference< uno::XInterface >() ); - } - // storage okay - break; - case READ_WRITE_NOCREATE: case READ_WRITE_CREATE: - if ( !( nOpenMode - & embed::ElementModes::WRITE ) ) + if ( !( nOpenMode & embed::ElementModes::WRITE ) ) { // document opened, but not writable. throw embed::InvalidStorageException( @@ -892,63 +570,33 @@ uno::Reference< embed::XStorage > StorageElementFactory::queryStorage( { // sub storage - sal_Int32 nOpenMode; - switch ( eMode ) - { - case READ: - case READ_ONLY: - nOpenMode = embed::ElementModes::READ - | embed::ElementModes::NOCREATE; - break; - - case READ_WRITE_NOCREATE: - nOpenMode = embed::ElementModes::READWRITE - | embed::ElementModes::NOCREATE; - break; - - case READ_WRITE_CREATE: - nOpenMode = embed::ElementModes::READWRITE; - break; - } - const rtl::OUString & rName = aUri.getDecodedName(); - try - { - xStorage = xParentStorage->openStorageElement( rName, nOpenMode ); - } - catch ( io::IOException const & ) + + if ( eMode == READ ) { - if ( ( eMode == READ ) || ( eMode == READ_ONLY ) ) + try { - // Distinguish between 'not existing' and 'access denied' - // (somebody else already opened storage for writing?) and - // "existing, but stream". - - bool bAccessDenied = true; - try - { - // true: element exists and is a storage, but access is - // denied false: element exists, but is a stream - bAccessDenied = xParentStorage->isStorageElement( rName ); - } - catch ( container::NoSuchElementException const & ) - { - // element does not exist - bAccessDenied = false; - } - - if ( bAccessDenied ) - { - // Clone - xStorage = createTemporaryStorage(); - xParentStorage->copyStorageElementLastCommitTo( rName, xStorage ); - } + sal_Int32 nOpenMode = embed::ElementModes::READ + | embed::ElementModes::NOCREATE; + xStorage + = xParentStorage->openStorageElement( rName, nOpenMode ); } - else + catch ( io::IOException const & ) { - throw; + // Another chance: Try to clone storage. + xStorage = createTemporaryStorage(); + xParentStorage->copyStorageElementLastCommitTo( rName, + xStorage ); } } + else + { + sal_Int32 nOpenMode = embed::ElementModes::READWRITE; + if ( eMode == READ_WRITE_NOCREATE ) + nOpenMode |= embed::ElementModes::NOCREATE; + + xStorage = xParentStorage->openStorageElement( rName, nOpenMode ); + } } OSL_ENSURE( xStorage.is() || ( eMode != READ_WRITE_CREATE ), @@ -962,7 +610,8 @@ StorageElementFactory::queryStream( const uno::Reference< embed::XStorage > & xParentStorage, const rtl::OUString & rUri, const rtl::OUString & rPassword, - StorageAccessMode eMode ) + StorageAccessMode eMode, + bool bTruncate ) throw ( embed::InvalidStorageException, lang::IllegalArgumentException, io::IOException, @@ -999,873 +648,100 @@ StorageElementFactory::queryStream( sal_Int16( 2 ) ); } - // @@@ Sophisticated object reusage (like for storages) needed??? - sal_Int32 nOpenMode; switch ( eMode ) { case READ: - case READ_ONLY: nOpenMode = embed::ElementModes::READ - | embed::ElementModes::NOCREATE; + | embed::ElementModes::NOCREATE + | embed::ElementModes::SEEKABLE; break; case READ_WRITE_NOCREATE: nOpenMode = embed::ElementModes::READWRITE - | embed::ElementModes::NOCREATE; - break; + | embed::ElementModes::NOCREATE + | embed::ElementModes::SEEKABLE; - case READ_WRITE_CREATE: - nOpenMode = embed::ElementModes::READWRITE; - break; - } + if ( bTruncate ) + nOpenMode |= embed::ElementModes::TRUNCATE; - uno::Reference< io::XStream > xStream; - if ( rPassword.getLength() > 0 ) - { - try - { - xStream = xParentStorage->openEncryptedStreamElement( - aUri.getDecodedName(), - nOpenMode, - rPassword ); - } - catch ( packages::NoEncryptionException const & ) - { - xStream = xParentStorage->openStreamElement( aUri.getDecodedName(), - nOpenMode ); - } - } - else - { - xStream = xParentStorage->openStreamElement( aUri.getDecodedName(), - nOpenMode ); - } - - if ( !xStream.is() ) - { - throw embed::InvalidStorageException( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( - "No stream!" ) ), - uno::Reference< uno::XInterface >() ); - } - - return xStream; -} + break; -//========================================================================= -//========================================================================= -// -// ParentStorageHolder Implementation. -// -//========================================================================= -//========================================================================= + case READ_WRITE_CREATE: + nOpenMode = embed::ElementModes::READWRITE + | embed::ElementModes::SEEKABLE; -ParentStorageHolder::ParentStorageHolder( - const uno::Reference< embed::XStorage > & xParentStorage, - const rtl::OUString & rUri ) -: m_xParentStorage( xParentStorage ), - m_bParentStorageIsRoot( false ) -{ - Uri aUri( rUri ); - if ( aUri.isDocument() ) // This correct; aUri.isRoot() is not! - m_bParentStorageIsRoot = true; -} + if ( bTruncate ) + nOpenMode |= embed::ElementModes::TRUNCATE; -//========================================================================= -//========================================================================= -// -// Storage Implementation. -// -//========================================================================= -//========================================================================= + break; -Storage::Storage( const uno::Reference< lang::XMultiServiceFactory > & xSMgr, - const rtl::Reference< StorageElementFactory > & xFactory, - const rtl::OUString & rUri, - const uno::Reference< embed::XStorage > & xParentStorage, - const uno::Reference< embed::XStorage > & xStorageToWrap ) -: ParentStorageHolder( xParentStorage, Uri( rUri ).getParentUri() ), - m_xFactory( xFactory ), - m_xWrappedStorage( xStorageToWrap ), - m_bDelegatorSet( false ) -{ - OSL_ENSURE( m_xWrappedStorage.is(), - "Storage::Storage: No storage to wrap!" ); + default: + OSL_ENSURE( false, + "StorageElementFactory::queryStream : Unknown open mode!" ); - // Use proxy factory service to create aggregatable proxy. - try - { - uno::Reference< reflection::XProxyFactory > xProxyFac( - xSMgr->createInstance( + throw embed::InvalidStorageException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( - "com.sun.star.reflection.ProxyFactory" ) ) ), - uno::UNO_QUERY ); - if ( xProxyFac.is() ) - { - m_xWrappedAggregate - = xProxyFac->createProxy( m_xWrappedStorage ); - m_xWrappedStorage - = uno::Reference< embed::XStorage >( - m_xWrappedAggregate, uno::UNO_QUERY ); - } + "Unknown open mode!" ) ), + uno::Reference< uno::XInterface >() ); } - catch ( uno::Exception const & ) - { - OSL_ENSURE( false, "Storage::Storage: Caught exception!" ); - } - - OSL_ENSURE( m_xWrappedAggregate.is(), - "Storage::Storage: Wrapped storage cannot be aggregated!" ); -} -//========================================================================= -// virtual -Storage::~Storage() -{ - if ( m_xWrappedAggregate.is() ) - m_xWrappedAggregate->setDelegator( - uno::Reference< uno::XInterface >() ); + // No object re-usage mechanism; streams are seekable => not stateless. - if ( m_xWrappedStorage.is() ) + uno::Reference< io::XStream > xStream; + if ( rPassword.getLength() > 0 ) { - // "Auto-dispose"... - uno::Reference< lang::XComponent > - xC( m_xWrappedStorage, uno::UNO_QUERY ); - OSL_ENSURE ( xC.is(), "Required interface XComponent missing!" ); - - try - { - xC->dispose(); - } - catch ( lang::DisposedException const & ) + if ( eMode == READ ) { - // might happen. + try + { + xStream = xParentStorage->cloneEncryptedStreamElement( + aUri.getDecodedName(), + rPassword ); + } + catch ( packages::NoEncryptionException const & ) + { + xStream + = xParentStorage->cloneStreamElement( aUri.getDecodedName() ); + } } - catch ( ... ) + else { - OSL_ENSURE( false, "Storage::~Storage - Caught exception!" ); - } - } -} - -//========================================================================= -void Storage::setDelegator() -{ - if ( !m_bDelegatorSet ) - { - osl::MutexGuard aGuard( m_aMutex ); - if ( !m_bDelegatorSet ) - { - m_xWrappedAggregate->setDelegator( - static_cast< cppu::OWeakObject * >( this ) ); - m_bDelegatorSet = true; - } - } -} - -//========================================================================= -// -// uno::XInterface -// -//========================================================================= - -// virtual -uno::Any SAL_CALL Storage::queryInterface( const uno::Type& aType ) - throw ( uno::RuntimeException) -{ - // First, try to use interfaces implemented by myself and base class(es) - uno::Any aRet = StorageUNOBase::queryInterface( aType ); - - if ( aRet.hasValue() ) - return aRet; - - // Late init: Set this as delegator for wrapped storage. - setDelegator(); - - // Try to use requested interface from aggregated storage - return m_xWrappedAggregate->queryAggregation( aType ); -} - -//========================================================================= -// virtual -void SAL_CALL Storage::acquire() - throw () -{ - osl_incrementInterlockedCount( &m_refCount ); -} - -//========================================================================= -// virtual -void SAL_CALL Storage::release() - throw () -{ - if ( osl_decrementInterlockedCount( &m_refCount ) == 0 ) - { - m_xFactory->releaseElement( this ); - delete this; - } -} - -//========================================================================= -// -// embed::XStorage -// -//========================================================================= - -// virtual -void SAL_CALL Storage::copyToStorage( - const uno::Reference< embed::XStorage >& xDest ) - throw ( embed::InvalidStorageException, - lang::IllegalArgumentException, - io::IOException, - embed::StorageWrappedTargetException, - uno::RuntimeException ) -{ - m_xWrappedStorage->copyToStorage( xDest ); -} - -//========================================================================= -// virtual -uno::Reference< io::XStream > SAL_CALL Storage::openStreamElement( - const ::rtl::OUString& aStreamName, sal_Int32 nOpenMode ) - throw ( embed::InvalidStorageException, - lang::IllegalArgumentException, - packages::WrongPasswordException, - io::IOException, - embed::StorageWrappedTargetException, - uno::RuntimeException ) -{ - return m_xWrappedStorage->openStreamElement( aStreamName, nOpenMode ); -} - -//========================================================================= -// virtual -uno::Reference< io::XStream > SAL_CALL Storage::openEncryptedStreamElement( - const ::rtl::OUString& aStreamName, - sal_Int32 nOpenMode, - const ::rtl::OUString& aPassword ) - throw ( embed::InvalidStorageException, - lang::IllegalArgumentException, - packages::NoEncryptionException, - packages::WrongPasswordException, - io::IOException, - embed::StorageWrappedTargetException, - uno::RuntimeException ) -{ - return m_xWrappedStorage->openEncryptedStreamElement( - aStreamName, nOpenMode, aPassword ); -} - -//========================================================================= -// virtual -uno::Reference< embed::XStorage > SAL_CALL Storage::openStorageElement( - const ::rtl::OUString& aStorName, sal_Int32 nOpenMode ) - throw ( embed::InvalidStorageException, - lang::IllegalArgumentException, - io::IOException, - embed::StorageWrappedTargetException, - uno::RuntimeException ) -{ - return m_xWrappedStorage->openStorageElement( aStorName, nOpenMode ); -} - -//========================================================================= -// virtual -uno::Reference< io::XStream > SAL_CALL Storage::cloneStreamElement( - const ::rtl::OUString& aStreamName ) - throw ( embed::InvalidStorageException, - lang::IllegalArgumentException, - packages::WrongPasswordException, - io::IOException, - embed::StorageWrappedTargetException, - uno::RuntimeException ) -{ - return m_xWrappedStorage->cloneStreamElement( aStreamName ); -} - -//========================================================================= -// virtual -uno::Reference< io::XStream > SAL_CALL Storage::cloneEncryptedStreamElement( - const ::rtl::OUString& aStreamName, - const ::rtl::OUString& aPassword ) - throw ( embed::InvalidStorageException, - lang::IllegalArgumentException, - packages::NoEncryptionException, - packages::WrongPasswordException, - io::IOException, - embed::StorageWrappedTargetException, - uno::RuntimeException ) -{ - return m_xWrappedStorage->cloneEncryptedStreamElement( aStreamName, aPassword ); -} - -//========================================================================= -// virtual -void SAL_CALL Storage::copyLastCommitTo( - const uno::Reference< embed::XStorage >& xTargetStorage ) - throw ( embed::InvalidStorageException, - lang::IllegalArgumentException, - io::IOException, - embed::StorageWrappedTargetException, - uno::RuntimeException) -{ - m_xWrappedStorage->copyLastCommitTo( xTargetStorage ); -} - -//========================================================================= -// virtual -void SAL_CALL Storage::copyStorageElementLastCommitTo( - const ::rtl::OUString& aStorName, - const uno::Reference< embed::XStorage >& xTargetStorage ) - throw ( embed::InvalidStorageException, - lang::IllegalArgumentException, - io::IOException, - embed::StorageWrappedTargetException, - uno::RuntimeException) -{ - m_xWrappedStorage->copyStorageElementLastCommitTo( aStorName, xTargetStorage ); -} - -//========================================================================= -// virtual -sal_Bool SAL_CALL Storage::isStreamElement( - const ::rtl::OUString& aElementName ) - throw ( container::NoSuchElementException, - lang::IllegalArgumentException, - embed::InvalidStorageException, - uno::RuntimeException ) -{ - return m_xWrappedStorage->isStreamElement( aElementName ); -} - -//========================================================================= -// virtual -sal_Bool SAL_CALL Storage::isStorageElement( - const ::rtl::OUString& aElementName ) - throw ( container::NoSuchElementException, - lang::IllegalArgumentException, - embed::InvalidStorageException, - uno::RuntimeException ) -{ - return m_xWrappedStorage->isStorageElement( aElementName ); -} - -//========================================================================= -// virtual -void SAL_CALL Storage::removeElement( const ::rtl::OUString& aElementName ) - throw ( embed::InvalidStorageException, - lang::IllegalArgumentException, - container::NoSuchElementException, - io::IOException, - embed::StorageWrappedTargetException, - uno::RuntimeException ) -{ - m_xWrappedStorage->removeElement( aElementName ); -} - -//========================================================================= -// virtual -void SAL_CALL Storage::renameElement( const ::rtl::OUString& aEleName, - const ::rtl::OUString& aNewName ) - throw ( embed::InvalidStorageException, - lang::IllegalArgumentException, - container::NoSuchElementException, - container::ElementExistException, - io::IOException, - embed::StorageWrappedTargetException, - uno::RuntimeException ) -{ - m_xWrappedStorage->renameElement( aEleName, aNewName ); -} - -//========================================================================= -// virtual -void SAL_CALL Storage::copyElementTo( - const ::rtl::OUString& aElementName, - const uno::Reference< embed::XStorage >& xDest, - const ::rtl::OUString& aNewName ) - throw ( embed::InvalidStorageException, - lang::IllegalArgumentException, - container::NoSuchElementException, - container::ElementExistException, - io::IOException, - embed::StorageWrappedTargetException, - uno::RuntimeException ) -{ - m_xWrappedStorage->copyElementTo( aElementName, xDest, aNewName ); -} - -//========================================================================= -// virtual -void SAL_CALL Storage::moveElementTo( - const ::rtl::OUString& aElementName, - const uno::Reference< embed::XStorage >& xDest, - const ::rtl::OUString& rNewName ) - throw ( embed::InvalidStorageException, - lang::IllegalArgumentException, - container::NoSuchElementException, - container::ElementExistException, - io::IOException, - embed::StorageWrappedTargetException, - uno::RuntimeException ) -{ - m_xWrappedStorage->moveElementTo( aElementName, xDest, rNewName ); -} - -//========================================================================= -// virtual -void SAL_CALL Storage::insertRawEncrStreamElement( - const ::rtl::OUString& aStreamName, - const uno::Reference< io::XInputStream >& xInStream ) - throw ( embed::InvalidStorageException, - lang::IllegalArgumentException, - packages::NoRawFormatException, - container::ElementExistException, - io::IOException, - embed::StorageWrappedTargetException, - uno::RuntimeException ) -{ - m_xWrappedStorage->insertRawEncrStreamElement( aStreamName, xInStream ); -} - -//========================================================================= -// -// XNameAccess -// -//========================================================================= -// virtual -uno::Any SAL_CALL Storage::getByName( const ::rtl::OUString& aName ) - throw ( container::NoSuchElementException, - lang::WrappedTargetException, - uno::RuntimeException ) -{ - return m_xWrappedStorage->getByName( aName ); -} - -//========================================================================= -// virtual -uno::Sequence< ::rtl::OUString > SAL_CALL Storage::getElementNames() - throw ( uno::RuntimeException ) -{ - return m_xWrappedStorage->getElementNames(); -} - -//========================================================================= -// virtual -::sal_Bool SAL_CALL Storage::hasByName( const ::rtl::OUString& aName ) - throw ( uno::RuntimeException ) -{ - return m_xWrappedStorage->hasByName( aName ); -} - -//========================================================================= -// virtual -uno::Type SAL_CALL Storage::getElementType() - throw ( uno::RuntimeException ) -{ - return m_xWrappedStorage->getElementType(); -} - -//========================================================================= -// virtual -::sal_Bool SAL_CALL Storage::hasElements() - throw ( uno::RuntimeException ) -{ - return m_xWrappedStorage->hasElements(); -} - -//========================================================================= -// -// XComponent -// -//========================================================================= -// virtual -void SAL_CALL Storage::dispose() - throw ( uno::RuntimeException ) -{ - // Not implemented yet, may be it is just enough to redirect the call to m_xWrappedStorage - OSL_ENSURE( sal_False, "Storage::dispose() is not implemented!" ); -} - -//========================================================================= -// virtual -void SAL_CALL Storage::addEventListener( - const uno::Reference< lang::XEventListener >& xListener ) - throw ( uno::RuntimeException ) -{ - // Not implemented yet, may be it is just enough to redirect the call to m_xWrappedStorage - OSL_ENSURE( sal_False, "Storage::addEventListener() is not implemented!" ); -} -//========================================================================= -// virtual -void SAL_CALL Storage::removeEventListener( - const uno::Reference< lang::XEventListener >& aListener ) - throw (uno::RuntimeException) -{ - // Not implemented yet, may be it is just enough to redirect the call to m_xWrappedStorage - OSL_ENSURE( sal_False, "Storage::removeEventListener() is not implemented!" ); -} - - -//========================================================================= -// -// embed::XTransactedObject -// -//========================================================================= - -// virtual -void SAL_CALL Storage::commit() - throw ( io::IOException, - lang::WrappedTargetException, - uno::RuntimeException ) -{ - // Never commit a root storage (-> has no parent)! - // Would lead in writing the whole document to disk. - - uno::Reference< embed::XStorage > xParentStorage = getParentStorage(); - if ( xParentStorage.is() ) - { - // Important: don't use 'normal' queryInterface-based ctor here - // to obtain XTransactedObject reference. wrapped storage is aggregated. - // qI call will lead to Storage::qI, which returns 'this' -> endless - // recursion!!! - uno::Reference< embed::XTransactedObject > xTA( - m_xWrappedAggregate->queryAggregation( - getCppuType( static_cast< - const uno::Reference< - embed::XTransactedObject > * >( 0 ) ) ), - uno::UNO_QUERY ); - OSL_ENSURE( xTA.is(), "No XTransactedObject interface!" ); - - if ( xTA.is() ) - xTA->commit(); - - if ( !isRootParentStorage() ) - { - uno::Reference< embed::XTransactedObject > xParentTA( - xParentStorage, uno::UNO_QUERY ); - OSL_ENSURE( xParentTA.is(), "No XTransactedObject interface!" ); - - if ( xParentTA.is() ) - xParentTA->commit(); + try + { + xStream = xParentStorage->openEncryptedStreamElement( + aUri.getDecodedName(), + nOpenMode, + rPassword ); + } + catch ( packages::NoEncryptionException const & ) + { + xStream + = xParentStorage->openStreamElement( aUri.getDecodedName(), + nOpenMode ); + } } } -} - -//========================================================================= -// virtual -void SAL_CALL Storage::revert() - throw ( io::IOException, - lang::WrappedTargetException, - uno::RuntimeException ) -{ - uno::Reference< embed::XStorage > xParentStorage = getParentStorage(); - if ( xParentStorage.is() ) + else { - // Important: don't use 'normal' queryInterface-based ctor here - // to obtain XTransactedObject reference. wrapped storage is aggregated. - // qI call will lead to Storage::qI, which returns 'this' -> endless - // recursion!!! - uno::Reference< embed::XTransactedObject > xTA( - m_xWrappedAggregate->queryAggregation( - getCppuType( static_cast< - const uno::Reference< - embed::XTransactedObject > * >( 0 ) ) ), - uno::UNO_QUERY ); - OSL_ENSURE( xTA.is(), "No XTransactedObject interface!" ); - - if ( xTA.is() ) - xTA->revert(); - - if ( !isRootParentStorage() ) + if ( eMode == READ ) { - uno::Reference< embed::XTransactedObject > xParentTA( - xParentStorage, uno::UNO_QUERY ); - OSL_ENSURE( xParentTA.is(), "No XTransactedObject interface!" ); - - if ( xParentTA.is() ) - xParentTA->revert(); + xStream = xParentStorage->cloneStreamElement( aUri.getDecodedName() ); } - } -} - -//========================================================================= -//========================================================================= -// -// InputStream Implementation. -// -//========================================================================= -//========================================================================= - -InputStream::InputStream( - const uno::Reference< lang::XMultiServiceFactory > & xSMgr, - const rtl::OUString & rUri, - const uno::Reference< embed::XStorage > & xParentStorage, - const uno::Reference< io::XInputStream > & xStreamToWrap ) -: ParentStorageHolder( xParentStorage, Uri( rUri ).getParentUri() ), - m_xWrappedStream( xStreamToWrap ) -{ - OSL_ENSURE( m_xWrappedStream.is(), - "InputStream::InputStream: No stream to wrap!" ); - - // Use proxy factory service to create aggregatable proxy. - try - { - uno::Reference< reflection::XProxyFactory > xProxyFac( - xSMgr->createInstance( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( - "com.sun.star.reflection.ProxyFactory" ) ) ), - uno::UNO_QUERY ); - if ( xProxyFac.is() ) + else { - m_xWrappedAggregate - = xProxyFac->createProxy( m_xWrappedStream ); - m_xWrappedStream - = uno::Reference< io::XInputStream >( - m_xWrappedAggregate, uno::UNO_QUERY ); + xStream = xParentStorage->openStreamElement( aUri.getDecodedName(), + nOpenMode ); } } - catch ( uno::Exception const & ) - { - OSL_ENSURE( false, "InputStream::InputStream: Caught exception!" ); - } - - OSL_ENSURE( m_xWrappedAggregate.is(), - "InputStream::InputStream: Wrapped stream cannot be aggregated!" ); - if ( m_xWrappedAggregate.is() ) + if ( !xStream.is() ) { - osl_incrementInterlockedCount( &m_refCount ); - m_xWrappedAggregate->setDelegator( - static_cast< cppu::OWeakObject * >( this ) ); - osl_decrementInterlockedCount( &m_refCount ); - } -} - -//========================================================================= -// virtual -InputStream::~InputStream() -{ - if ( m_xWrappedAggregate.is() ) - m_xWrappedAggregate->setDelegator( + throw embed::InvalidStorageException( + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( + "No stream!" ) ), uno::Reference< uno::XInterface >() ); -} - -//========================================================================= -// -// uno::XInterface -// -//========================================================================= - -// virtual -uno::Any SAL_CALL InputStream::queryInterface( const uno::Type& aType ) - throw ( uno::RuntimeException) -{ - uno::Any aRet = InputStreamUNOBase::queryInterface( aType ); - - if ( aRet.hasValue() ) - return aRet; - - if ( m_xWrappedAggregate.is() ) - return m_xWrappedAggregate->queryAggregation( aType ); - else - return uno::Any(); -} - -//========================================================================= -// -// io::XInputStream -// -//========================================================================= - -// virtual -sal_Int32 SAL_CALL -InputStream::readBytes( uno::Sequence< sal_Int8 >& aData, - sal_Int32 nBytesToRead ) - throw ( io::NotConnectedException, - io::BufferSizeExceededException, - io::IOException, - uno::RuntimeException ) -{ - return m_xWrappedStream->readBytes( aData, nBytesToRead ); -} - -//========================================================================= -// virtual -sal_Int32 SAL_CALL -InputStream::readSomeBytes( uno::Sequence< sal_Int8 >& aData, - sal_Int32 nMaxBytesToRead ) - throw ( io::NotConnectedException, - io::BufferSizeExceededException, - io::IOException, - uno::RuntimeException ) -{ - return m_xWrappedStream->readSomeBytes( aData, nMaxBytesToRead ); -} - -//========================================================================= -// virtual -void SAL_CALL -InputStream::skipBytes( sal_Int32 nBytesToSkip ) - throw ( io::NotConnectedException, - io::BufferSizeExceededException, - io::IOException, - uno::RuntimeException ) -{ - m_xWrappedStream->skipBytes( nBytesToSkip ); -} - -//========================================================================= -// virtual -sal_Int32 SAL_CALL -InputStream::available() - throw ( io::NotConnectedException, - io::IOException, - uno::RuntimeException ) -{ - return m_xWrappedStream->available(); -} - -//========================================================================= -// virtual -void SAL_CALL -InputStream::closeInput() - throw ( io::NotConnectedException, - io::IOException, - uno::RuntimeException ) -{ - m_xWrappedStream->closeInput(); - - // Release parent storage. - // Now, that the stream is closed it is not needed any longer. - setParentStorage( uno::Reference< embed::XStorage >() ); -} - -//========================================================================= -//========================================================================= -// -// OutputStream Implementation. -// -//========================================================================= -//========================================================================= - -OutputStream::OutputStream( - const uno::Reference< lang::XMultiServiceFactory > & xSMgr, - const rtl::OUString & rUri, - const uno::Reference< embed::XStorage > & xParentStorage, - const uno::Reference< io::XOutputStream > & xStreamToWrap ) -: ParentStorageHolder( xParentStorage, Uri( rUri ).getParentUri() ), - m_xWrappedStream( xStreamToWrap ) -{ - OSL_ENSURE( m_xWrappedStream.is(), - "OutputStream::OutputStream: No stream to wrap!" ); - - // Use proxy factory service to create aggregatable proxy. - try - { - uno::Reference< reflection::XProxyFactory > xProxyFac( - xSMgr->createInstance( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( - "com.sun.star.reflection.ProxyFactory" ) ) ), - uno::UNO_QUERY ); - if ( xProxyFac.is() ) - { - m_xWrappedAggregate - = xProxyFac->createProxy( m_xWrappedStream ); - m_xWrappedStream - = uno::Reference< io::XOutputStream >( - m_xWrappedAggregate, uno::UNO_QUERY ); - } - } - catch ( uno::Exception const & ) - { - OSL_ENSURE( false, "OutputStream::OutputStream: Caught exception!" ); - } - - OSL_ENSURE( m_xWrappedAggregate.is(), - "OutputStream::OutputStream: Wrapped stream cannot be aggregated!" ); - - if ( m_xWrappedAggregate.is() ) - { - osl_incrementInterlockedCount( &m_refCount ); - m_xWrappedAggregate->setDelegator( - static_cast< cppu::OWeakObject * >( this ) ); - osl_decrementInterlockedCount( &m_refCount ); } -} - -//========================================================================= -// virtual -OutputStream::~OutputStream() -{ - if ( m_xWrappedAggregate.is() ) - m_xWrappedAggregate->setDelegator( - uno::Reference< uno::XInterface >() ); -} -//========================================================================= -// -// uno::XInterface -// -//========================================================================= - -// virtual -uno::Any SAL_CALL OutputStream::queryInterface( const uno::Type& aType ) - throw ( uno::RuntimeException) -{ - uno::Any aRet = OutputStreamUNOBase::queryInterface( aType ); - - if ( aRet.hasValue() ) - return aRet; - - if ( m_xWrappedAggregate.is() ) - return m_xWrappedAggregate->queryAggregation( aType ); - else - return uno::Any(); -} - -//========================================================================= -// -// io::XOutputStream -// -//========================================================================= - -// virtual -void SAL_CALL -OutputStream::writeBytes( const uno::Sequence< sal_Int8 >& aData ) - throw ( io::NotConnectedException, - io::BufferSizeExceededException, - io::IOException, - uno::RuntimeException ) -{ - m_xWrappedStream->writeBytes( aData ); -} - -//========================================================================= -// virtual -void SAL_CALL -OutputStream::flush( ) - throw ( io::NotConnectedException, - io::BufferSizeExceededException, - io::IOException, - uno::RuntimeException ) -{ - m_xWrappedStream->flush(); -} - -//========================================================================= -// virtual -void SAL_CALL -OutputStream::closeOutput( ) - throw ( io::NotConnectedException, - io::BufferSizeExceededException, - io::IOException, - uno::RuntimeException ) -{ - m_xWrappedStream->closeOutput(); - - // Release parent storage. - // Now, that the stream is closed it is not needed any longer. - setParentStorage( uno::Reference< embed::XStorage >() ); + return xStream; } |