1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 /**************************************************************************
23 **************************************************************************
25 - remove root storage access workaround
27 *************************************************************************/
29 #include <osl/diagnose.h>
31 #include "com/sun/star/lang/DisposedException.hpp"
32 #include "com/sun/star/reflection/ProxyFactory.hpp"
34 #include "tdoc_uri.hxx"
36 #include "tdoc_stgelems.hxx"
38 using namespace com::sun::star
;
39 using namespace tdoc_ucp
;
44 // ParentStorageHolder Implementation.
49 ParentStorageHolder::ParentStorageHolder(
50 const uno::Reference
< embed::XStorage
> & xParentStorage
,
51 const OUString
& rUri
)
52 : m_xParentStorage( xParentStorage
),
53 m_bParentIsRootStorage( false )
56 if ( aUri
.isDocument() )
57 m_bParentIsRootStorage
= true;
63 // Storage Implementation.
68 Storage::Storage( const uno::Reference
< uno::XComponentContext
> & rxContext
,
69 const rtl::Reference
< StorageElementFactory
> & xFactory
,
70 const OUString
& rUri
,
71 const uno::Reference
< embed::XStorage
> & xParentStorage
,
72 const uno::Reference
< embed::XStorage
> & xStorageToWrap
)
73 : ParentStorageHolder( xParentStorage
, Uri( rUri
).getParentUri() ),
74 m_xFactory( xFactory
),
75 m_xWrappedStorage( xStorageToWrap
),
76 m_xWrappedTransObj( xStorageToWrap
, uno::UNO_QUERY
), // optional interface
77 m_xWrappedComponent( xStorageToWrap
, uno::UNO_QUERY
),
78 m_xWrappedTypeProv( xStorageToWrap
, uno::UNO_QUERY
),
79 m_bIsDocumentStorage( Uri( rUri
).isDocument() )
81 OSL_ENSURE( m_xWrappedStorage
.is(),
82 "Storage::Storage: No storage to wrap!" );
84 OSL_ENSURE( m_xWrappedComponent
.is(),
85 "Storage::Storage: No component to wrap!" );
87 OSL_ENSURE( m_xWrappedTypeProv
.is(),
88 "Storage::Storage: No Type Provider!" );
90 // Use proxy factory service to create aggregatable proxy.
93 uno::Reference
< reflection::XProxyFactory
> xProxyFac
=
94 reflection::ProxyFactory::create( rxContext
);
95 m_xAggProxy
= xProxyFac
->createProxy( m_xWrappedStorage
);
97 catch ( uno::Exception
const & )
99 OSL_FAIL( "Storage::Storage: Caught exception!" );
102 OSL_ENSURE( m_xAggProxy
.is(),
103 "Storage::Storage: Wrapped storage cannot be aggregated!" );
105 if ( m_xAggProxy
.is() )
107 osl_atomic_increment( &m_refCount
);
109 // Solaris compiler problem:
110 // Extra block to enforce destruction of temporary object created
111 // in next statement _before_ osl_atomic_decrement is
112 // called. Otherwise 'this' will destroy itself even before ctor
113 // is completed (See impl. of XInterface::release())!
115 m_xAggProxy
->setDelegator(
116 static_cast< cppu::OWeakObject
* >( this ) );
118 osl_atomic_decrement( &m_refCount
);
126 if ( m_xAggProxy
.is() )
127 m_xAggProxy
->setDelegator( uno::Reference
< uno::XInterface
>() );
129 // Never dispose a document storage. Not owner!
130 if ( !isDocumentStorage() )
132 if ( m_xWrappedComponent
.is() )
137 m_xWrappedComponent
->dispose();
139 catch ( lang::DisposedException
const & )
145 OSL_FAIL( "Storage::~Storage - Caught exception!" );
158 uno::Any SAL_CALL
Storage::queryInterface( const uno::Type
& aType
)
159 throw ( uno::RuntimeException
, std::exception
)
161 // First, try to use interfaces implemented by myself and base class(es)
162 uno::Any aRet
= StorageUNOBase::queryInterface( aType
);
164 if ( aRet
.hasValue() )
167 // Try to use requested interface from aggregated storage
168 return m_xAggProxy
->queryAggregation( aType
);
173 void SAL_CALL
Storage::acquire()
176 osl_atomic_increment( &m_refCount
);
181 void SAL_CALL
Storage::release()
184 //#i120738, Storage::release overrides OWeakObject::release(),
185 //need call OWeakObject::release() to release OWeakObject::m_pWeakConnectionPoint
187 if ( m_refCount
== 1 )
188 m_xFactory
->releaseElement( this );
191 OWeakObject::release();
196 // lang::XTypeProvider
201 uno::Sequence
< uno::Type
> SAL_CALL
Storage::getTypes()
202 throw ( uno::RuntimeException
, std::exception
)
204 return m_xWrappedTypeProv
->getTypes();
209 uno::Sequence
< sal_Int8
> SAL_CALL
Storage::getImplementationId()
210 throw ( uno::RuntimeException
, std::exception
)
212 return css::uno::Sequence
<sal_Int8
>();
217 // lang::XComponent (base of embed::XStorage)
221 void SAL_CALL
Storage::dispose()
222 throw ( uno::RuntimeException
, std::exception
)
224 m_xWrappedStorage
->dispose();
229 void SAL_CALL
Storage::addEventListener(
230 const uno::Reference
< lang::XEventListener
>& xListener
)
231 throw ( uno::RuntimeException
, std::exception
)
233 m_xWrappedStorage
->addEventListener( xListener
);
237 void SAL_CALL
Storage::removeEventListener(
238 const uno::Reference
< lang::XEventListener
>& aListener
)
239 throw (uno::RuntimeException
, std::exception
)
241 m_xWrappedStorage
->removeEventListener( aListener
);
246 // container::XElementAccess (base of container::XNameAccess)
251 uno::Type SAL_CALL
Storage::getElementType()
252 throw ( uno::RuntimeException
, std::exception
)
254 return m_xWrappedStorage
->getElementType();
259 sal_Bool SAL_CALL
Storage::hasElements()
260 throw ( uno::RuntimeException
, std::exception
)
262 return m_xWrappedStorage
->hasElements();
267 // container::XNameAccess (base of embed::XStorage)
272 uno::Any SAL_CALL
Storage::getByName( const OUString
& aName
)
273 throw ( container::NoSuchElementException
,
274 lang::WrappedTargetException
,
275 uno::RuntimeException
, std::exception
)
277 return m_xWrappedStorage
->getByName( aName
);
282 uno::Sequence
< OUString
> SAL_CALL
Storage::getElementNames()
283 throw ( uno::RuntimeException
, std::exception
)
285 return m_xWrappedStorage
->getElementNames();
290 sal_Bool SAL_CALL
Storage::hasByName( const OUString
& aName
)
291 throw ( uno::RuntimeException
, std::exception
)
293 return m_xWrappedStorage
->hasByName( aName
);
303 void SAL_CALL
Storage::copyToStorage(
304 const uno::Reference
< embed::XStorage
>& xDest
)
305 throw ( embed::InvalidStorageException
,
306 lang::IllegalArgumentException
,
308 embed::StorageWrappedTargetException
,
309 uno::RuntimeException
, std::exception
)
311 m_xWrappedStorage
->copyToStorage( xDest
);
316 uno::Reference
< io::XStream
> SAL_CALL
Storage::openStreamElement(
317 const OUString
& aStreamName
, sal_Int32 nOpenMode
)
318 throw ( embed::InvalidStorageException
,
319 lang::IllegalArgumentException
,
320 packages::WrongPasswordException
,
322 embed::StorageWrappedTargetException
,
323 uno::RuntimeException
, std::exception
)
325 return m_xWrappedStorage
->openStreamElement( aStreamName
, nOpenMode
);
330 uno::Reference
< io::XStream
> SAL_CALL
Storage::openEncryptedStreamElement(
331 const OUString
& aStreamName
,
333 const OUString
& aPassword
)
334 throw ( embed::InvalidStorageException
,
335 lang::IllegalArgumentException
,
336 packages::NoEncryptionException
,
337 packages::WrongPasswordException
,
339 embed::StorageWrappedTargetException
,
340 uno::RuntimeException
, std::exception
)
342 return m_xWrappedStorage
->openEncryptedStreamElement(
343 aStreamName
, nOpenMode
, aPassword
);
348 uno::Reference
< embed::XStorage
> SAL_CALL
Storage::openStorageElement(
349 const OUString
& aStorName
, sal_Int32 nOpenMode
)
350 throw ( embed::InvalidStorageException
,
351 lang::IllegalArgumentException
,
353 embed::StorageWrappedTargetException
,
354 uno::RuntimeException
, std::exception
)
356 return m_xWrappedStorage
->openStorageElement( aStorName
, nOpenMode
);
361 uno::Reference
< io::XStream
> SAL_CALL
Storage::cloneStreamElement(
362 const OUString
& aStreamName
)
363 throw ( embed::InvalidStorageException
,
364 lang::IllegalArgumentException
,
365 packages::WrongPasswordException
,
367 embed::StorageWrappedTargetException
,
368 uno::RuntimeException
, std::exception
)
370 return m_xWrappedStorage
->cloneStreamElement( aStreamName
);
375 uno::Reference
< io::XStream
> SAL_CALL
Storage::cloneEncryptedStreamElement(
376 const OUString
& aStreamName
,
377 const OUString
& aPassword
)
378 throw ( embed::InvalidStorageException
,
379 lang::IllegalArgumentException
,
380 packages::NoEncryptionException
,
381 packages::WrongPasswordException
,
383 embed::StorageWrappedTargetException
,
384 uno::RuntimeException
, std::exception
)
386 return m_xWrappedStorage
->cloneEncryptedStreamElement( aStreamName
,
392 void SAL_CALL
Storage::copyLastCommitTo(
393 const uno::Reference
< embed::XStorage
>& xTargetStorage
)
394 throw ( embed::InvalidStorageException
,
395 lang::IllegalArgumentException
,
397 embed::StorageWrappedTargetException
,
398 uno::RuntimeException
, std::exception
)
400 m_xWrappedStorage
->copyLastCommitTo( xTargetStorage
);
405 void SAL_CALL
Storage::copyStorageElementLastCommitTo(
406 const OUString
& aStorName
,
407 const uno::Reference
< embed::XStorage
>& xTargetStorage
)
408 throw ( embed::InvalidStorageException
,
409 lang::IllegalArgumentException
,
411 embed::StorageWrappedTargetException
,
412 uno::RuntimeException
, std::exception
)
414 m_xWrappedStorage
->copyStorageElementLastCommitTo( aStorName
, xTargetStorage
);
419 sal_Bool SAL_CALL
Storage::isStreamElement(
420 const OUString
& aElementName
)
421 throw ( container::NoSuchElementException
,
422 lang::IllegalArgumentException
,
423 embed::InvalidStorageException
,
424 uno::RuntimeException
, std::exception
)
426 return m_xWrappedStorage
->isStreamElement( aElementName
);
431 sal_Bool SAL_CALL
Storage::isStorageElement(
432 const OUString
& aElementName
)
433 throw ( container::NoSuchElementException
,
434 lang::IllegalArgumentException
,
435 embed::InvalidStorageException
,
436 uno::RuntimeException
, std::exception
)
438 return m_xWrappedStorage
->isStorageElement( aElementName
);
443 void SAL_CALL
Storage::removeElement( const OUString
& aElementName
)
444 throw ( embed::InvalidStorageException
,
445 lang::IllegalArgumentException
,
446 container::NoSuchElementException
,
448 embed::StorageWrappedTargetException
,
449 uno::RuntimeException
, std::exception
)
451 m_xWrappedStorage
->removeElement( aElementName
);
456 void SAL_CALL
Storage::renameElement( const OUString
& aEleName
,
457 const OUString
& aNewName
)
458 throw ( embed::InvalidStorageException
,
459 lang::IllegalArgumentException
,
460 container::NoSuchElementException
,
461 container::ElementExistException
,
463 embed::StorageWrappedTargetException
,
464 uno::RuntimeException
, std::exception
)
466 m_xWrappedStorage
->renameElement( aEleName
, aNewName
);
471 void SAL_CALL
Storage::copyElementTo(
472 const OUString
& aElementName
,
473 const uno::Reference
< embed::XStorage
>& xDest
,
474 const OUString
& aNewName
)
475 throw ( embed::InvalidStorageException
,
476 lang::IllegalArgumentException
,
477 container::NoSuchElementException
,
478 container::ElementExistException
,
480 embed::StorageWrappedTargetException
,
481 uno::RuntimeException
, std::exception
)
483 m_xWrappedStorage
->copyElementTo( aElementName
, xDest
, aNewName
);
488 void SAL_CALL
Storage::moveElementTo(
489 const OUString
& aElementName
,
490 const uno::Reference
< embed::XStorage
>& xDest
,
491 const OUString
& rNewName
)
492 throw ( embed::InvalidStorageException
,
493 lang::IllegalArgumentException
,
494 container::NoSuchElementException
,
495 container::ElementExistException
,
497 embed::StorageWrappedTargetException
,
498 uno::RuntimeException
, std::exception
)
500 m_xWrappedStorage
->moveElementTo( aElementName
, xDest
, rNewName
);
505 // embed::XTransactedObject
510 void SAL_CALL
Storage::commit()
511 throw ( io::IOException
,
512 lang::WrappedTargetException
,
513 uno::RuntimeException
, std::exception
)
515 // Never commit a root storage (-> has no parent)!
516 // Would lead in writing the whole document to disk.
518 uno::Reference
< embed::XStorage
> xParentStorage
= getParentStorage();
519 if ( xParentStorage
.is() )
521 OSL_ENSURE( m_xWrappedTransObj
.is(), "No XTransactedObject interface!" );
523 if ( m_xWrappedTransObj
.is() )
525 m_xWrappedTransObj
->commit();
527 if ( !isParentARootStorage() )
529 uno::Reference
< embed::XTransactedObject
> xParentTA(
530 xParentStorage
, uno::UNO_QUERY
);
531 OSL_ENSURE( xParentTA
.is(), "No XTransactedObject interface!" );
533 if ( xParentTA
.is() )
542 void SAL_CALL
Storage::revert()
543 throw ( io::IOException
,
544 lang::WrappedTargetException
,
545 uno::RuntimeException
, std::exception
)
547 uno::Reference
< embed::XStorage
> xParentStorage
= getParentStorage();
548 if ( xParentStorage
.is() )
550 OSL_ENSURE( m_xWrappedTransObj
.is(), "No XTransactedObject interface!" );
552 if ( m_xWrappedTransObj
.is() )
554 m_xWrappedTransObj
->revert();
556 if ( !isParentARootStorage() )
558 uno::Reference
< embed::XTransactedObject
> xParentTA(
559 xParentStorage
, uno::UNO_QUERY
);
560 OSL_ENSURE( xParentTA
.is(), "No XTransactedObject interface!" );
562 if ( xParentTA
.is() )
572 // OutputStream Implementation.
577 OutputStream::OutputStream(
578 const uno::Reference
< uno::XComponentContext
> & rxContext
,
579 const OUString
& rUri
,
580 const uno::Reference
< embed::XStorage
> & xParentStorage
,
581 const uno::Reference
< io::XOutputStream
> & xStreamToWrap
)
582 : ParentStorageHolder( xParentStorage
, Uri( rUri
).getParentUri() ),
583 m_xWrappedStream( xStreamToWrap
),
584 m_xWrappedComponent( xStreamToWrap
, uno::UNO_QUERY
),
585 m_xWrappedTypeProv( xStreamToWrap
, uno::UNO_QUERY
)
587 OSL_ENSURE( m_xWrappedStream
.is(),
588 "OutputStream::OutputStream: No stream to wrap!" );
590 OSL_ENSURE( m_xWrappedComponent
.is(),
591 "OutputStream::OutputStream: No component to wrap!" );
593 OSL_ENSURE( m_xWrappedTypeProv
.is(),
594 "OutputStream::OutputStream: No Type Provider!" );
596 // Use proxy factory service to create aggregatable proxy.
599 uno::Reference
< reflection::XProxyFactory
> xProxyFac
=
600 reflection::ProxyFactory::create( rxContext
);
601 m_xAggProxy
= xProxyFac
->createProxy( m_xWrappedStream
);
603 catch ( uno::Exception
const & )
605 OSL_FAIL( "OutputStream::OutputStream: Caught exception!" );
608 OSL_ENSURE( m_xAggProxy
.is(),
609 "OutputStream::OutputStream: Wrapped stream cannot be aggregated!" );
611 if ( m_xAggProxy
.is() )
613 osl_atomic_increment( &m_refCount
);
615 // Solaris compiler problem:
616 // Extra block to enforce destruction of temporary object created
617 // in next statement _before_ osl_atomic_decrement is
618 // called. Otherwise 'this' will destroy itself even before ctor
619 // is completed (See impl. of XInterface::release())!
621 m_xAggProxy
->setDelegator(
622 static_cast< cppu::OWeakObject
* >( this ) );
624 osl_atomic_decrement( &m_refCount
);
630 OutputStream::~OutputStream()
632 if ( m_xAggProxy
.is() )
633 m_xAggProxy
->setDelegator( uno::Reference
< uno::XInterface
>() );
643 uno::Any SAL_CALL
OutputStream::queryInterface( const uno::Type
& aType
)
644 throw ( uno::RuntimeException
, std::exception
)
646 uno::Any aRet
= OutputStreamUNOBase::queryInterface( aType
);
648 if ( aRet
.hasValue() )
651 if ( m_xAggProxy
.is() )
652 return m_xAggProxy
->queryAggregation( aType
);
659 // lang::XTypeProvider
664 uno::Sequence
< uno::Type
> SAL_CALL
OutputStream::getTypes()
665 throw ( uno::RuntimeException
, std::exception
)
667 return m_xWrappedTypeProv
->getTypes();
672 uno::Sequence
< sal_Int8
> SAL_CALL
OutputStream::getImplementationId()
673 throw ( uno::RuntimeException
, std::exception
)
675 return css::uno::Sequence
<sal_Int8
>();
686 OutputStream::writeBytes( const uno::Sequence
< sal_Int8
>& aData
)
687 throw ( io::NotConnectedException
,
688 io::BufferSizeExceededException
,
690 uno::RuntimeException
, std::exception
)
692 m_xWrappedStream
->writeBytes( aData
);
698 OutputStream::flush()
699 throw ( io::NotConnectedException
,
700 io::BufferSizeExceededException
,
702 uno::RuntimeException
, std::exception
)
704 m_xWrappedStream
->flush();
710 OutputStream::closeOutput( )
711 throw ( io::NotConnectedException
,
712 io::BufferSizeExceededException
,
714 uno::RuntimeException
, std::exception
)
716 m_xWrappedStream
->closeOutput();
718 // Release parent storage.
719 // Now, that the stream is closed/disposed it is not needed any longer.
720 setParentStorage( uno::Reference
< embed::XStorage
>() );
731 OutputStream::dispose()
732 throw ( uno::RuntimeException
, std::exception
)
734 m_xWrappedComponent
->dispose();
736 // Release parent storage.
737 // Now, that the stream is closed/disposed it is not needed any longer.
738 setParentStorage( uno::Reference
< embed::XStorage
>() );
744 OutputStream::addEventListener(
745 const uno::Reference
< lang::XEventListener
>& xListener
)
746 throw ( uno::RuntimeException
, std::exception
)
748 m_xWrappedComponent
->addEventListener( xListener
);
754 OutputStream::removeEventListener(
755 const uno::Reference
< lang::XEventListener
>& aListener
)
756 throw ( uno::RuntimeException
, std::exception
)
758 m_xWrappedComponent
->removeEventListener( aListener
);
764 // Stream Implementation.
770 const uno::Reference
< uno::XComponentContext
> & rxContext
,
771 const OUString
& rUri
,
772 const uno::Reference
< embed::XStorage
> & xParentStorage
,
773 const uno::Reference
< io::XStream
> & xStreamToWrap
)
774 : ParentStorageHolder( xParentStorage
, Uri( rUri
).getParentUri() ),
775 m_xWrappedStream( xStreamToWrap
),
776 m_xWrappedOutputStream( xStreamToWrap
->getOutputStream() ), // might be empty
777 m_xWrappedTruncate( m_xWrappedOutputStream
, uno::UNO_QUERY
), // might be empty
778 m_xWrappedInputStream( xStreamToWrap
->getInputStream(), uno::UNO_QUERY
),
779 m_xWrappedComponent( xStreamToWrap
, uno::UNO_QUERY
),
780 m_xWrappedTypeProv( xStreamToWrap
, uno::UNO_QUERY
)
782 OSL_ENSURE( m_xWrappedStream
.is(),
783 "OutputStream::OutputStream: No stream to wrap!" );
785 OSL_ENSURE( m_xWrappedComponent
.is(),
786 "OutputStream::OutputStream: No component to wrap!" );
788 OSL_ENSURE( m_xWrappedTypeProv
.is(),
789 "OutputStream::OutputStream: No Type Provider!" );
791 // Use proxy factory service to create aggregatable proxy.
794 uno::Reference
< reflection::XProxyFactory
> xProxyFac
=
795 reflection::ProxyFactory::create( rxContext
);
796 m_xAggProxy
= xProxyFac
->createProxy( m_xWrappedStream
);
798 catch ( uno::Exception
const & )
800 OSL_FAIL( "OutputStream::OutputStream: Caught exception!" );
803 OSL_ENSURE( m_xAggProxy
.is(),
804 "OutputStream::OutputStream: Wrapped stream cannot be aggregated!" );
806 if ( m_xAggProxy
.is() )
808 osl_atomic_increment( &m_refCount
);
810 // Solaris compiler problem:
811 // Extra block to enforce destruction of temporary object created
812 // in next statement _before_ osl_atomic_decrement is
813 // called. Otherwise 'this' will destroy itself even before ctor
814 // is completed (See impl. of XInterface::release())!
816 m_xAggProxy
->setDelegator(
817 static_cast< cppu::OWeakObject
* >( this ) );
819 osl_atomic_decrement( &m_refCount
);
827 if ( m_xAggProxy
.is() )
828 m_xAggProxy
->setDelegator( uno::Reference
< uno::XInterface
>() );
838 uno::Any SAL_CALL
Stream::queryInterface( const uno::Type
& aType
)
839 throw ( uno::RuntimeException
, std::exception
)
841 uno::Any aRet
= StreamUNOBase::queryInterface( aType
);
843 if ( aRet
.hasValue() )
846 if ( m_xAggProxy
.is() )
847 return m_xAggProxy
->queryAggregation( aType
);
854 // lang::XTypeProvider
859 uno::Sequence
< uno::Type
> SAL_CALL
Stream::getTypes()
860 throw ( uno::RuntimeException
, std::exception
)
862 return m_xWrappedTypeProv
->getTypes();
867 uno::Sequence
< sal_Int8
> SAL_CALL
Stream::getImplementationId()
868 throw ( uno::RuntimeException
, std::exception
)
870 return css::uno::Sequence
<sal_Int8
>();
880 uno::Reference
< io::XInputStream
> SAL_CALL
Stream::getInputStream()
881 throw( uno::RuntimeException
, std::exception
)
883 return uno::Reference
< io::XInputStream
>( this );
888 uno::Reference
< io::XOutputStream
> SAL_CALL
Stream::getOutputStream()
889 throw( uno::RuntimeException
, std::exception
)
891 return uno::Reference
< io::XOutputStream
>( this );
896 // io::XOutputStream.
901 void SAL_CALL
Stream::writeBytes( const uno::Sequence
< sal_Int8
>& aData
)
902 throw( io::NotConnectedException
,
903 io::BufferSizeExceededException
,
905 uno::RuntimeException
, std::exception
)
907 if ( m_xWrappedOutputStream
.is() )
909 m_xWrappedOutputStream
->writeBytes( aData
);
916 void SAL_CALL
Stream::flush()
917 throw( io::NotConnectedException
,
918 io::BufferSizeExceededException
,
920 uno::RuntimeException
, std::exception
)
922 if ( m_xWrappedOutputStream
.is() )
924 m_xWrappedOutputStream
->flush();
931 void SAL_CALL
Stream::closeOutput()
932 throw( io::NotConnectedException
,
934 uno::RuntimeException
, std::exception
)
936 if ( m_xWrappedOutputStream
.is() )
938 m_xWrappedOutputStream
->closeOutput();
942 // Release parent storage.
943 // Now, that the stream is closed/disposed it is not needed any longer.
944 setParentStorage( uno::Reference
< embed::XStorage
>() );
954 void SAL_CALL
Stream::truncate()
955 throw( io::IOException
,
956 uno::RuntimeException
, std::exception
)
958 if ( m_xWrappedTruncate
.is() )
960 m_xWrappedTruncate
->truncate();
972 sal_Int32 SAL_CALL
Stream::readBytes( uno::Sequence
< sal_Int8
>& aData
,
973 sal_Int32 nBytesToRead
)
974 throw( io::NotConnectedException
,
975 io::BufferSizeExceededException
,
977 uno::RuntimeException
, std::exception
)
979 return m_xWrappedInputStream
->readBytes( aData
, nBytesToRead
);
984 sal_Int32 SAL_CALL
Stream::readSomeBytes( uno::Sequence
< sal_Int8
>& aData
,
985 sal_Int32 nMaxBytesToRead
)
986 throw( io::NotConnectedException
,
987 io::BufferSizeExceededException
,
989 uno::RuntimeException
, std::exception
)
991 return m_xWrappedInputStream
->readSomeBytes( aData
, nMaxBytesToRead
);
996 void SAL_CALL
Stream::skipBytes( sal_Int32 nBytesToSkip
)
997 throw( io::NotConnectedException
,
998 io::BufferSizeExceededException
,
1000 uno::RuntimeException
, std::exception
)
1002 m_xWrappedInputStream
->skipBytes( nBytesToSkip
);
1007 sal_Int32 SAL_CALL
Stream::available()
1008 throw( io::NotConnectedException
,
1010 uno::RuntimeException
, std::exception
)
1012 return m_xWrappedInputStream
->available();
1017 void SAL_CALL
Stream::closeInput()
1018 throw( io::NotConnectedException
,
1020 uno::RuntimeException
, std::exception
)
1022 m_xWrappedInputStream
->closeInput();
1032 void SAL_CALL
Stream::dispose()
1033 throw ( uno::RuntimeException
, std::exception
)
1035 m_xWrappedComponent
->dispose();
1037 // Release parent storage.
1038 // Now, that the stream is closed/disposed it is not needed any longer.
1039 setParentStorage( uno::Reference
< embed::XStorage
>() );
1044 void SAL_CALL
Stream::addEventListener(
1045 const uno::Reference
< lang::XEventListener
>& xListener
)
1046 throw ( uno::RuntimeException
, std::exception
)
1048 m_xWrappedComponent
->addEventListener( xListener
);
1053 void SAL_CALL
Stream::removeEventListener(
1054 const uno::Reference
< lang::XEventListener
>& aListener
)
1055 throw ( uno::RuntimeException
, std::exception
)
1057 m_xWrappedComponent
->removeEventListener( aListener
);
1066 void Stream::commitChanges()
1067 throw( io::IOException
)
1069 uno::Reference
< embed::XTransactedObject
>
1070 xParentTA( getParentStorage(), uno::UNO_QUERY
);
1071 OSL_ENSURE( xParentTA
.is(), "No XTransactedObject interface!" );
1073 if ( xParentTA
.is() )
1077 xParentTA
->commit();
1079 catch ( lang::WrappedTargetException
const & )
1081 throw io::IOException(); // @@@
1086 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */