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 "com/sun/star/lang/DisposedException.hpp"
30 #include "com/sun/star/reflection/ProxyFactory.hpp"
32 #include "tdoc_uri.hxx"
34 #include "tdoc_stgelems.hxx"
36 using namespace com::sun::star
;
37 using namespace tdoc_ucp
;
39 //=========================================================================
40 //=========================================================================
42 // ParentStorageHolder Implementation.
44 //=========================================================================
45 //=========================================================================
47 ParentStorageHolder::ParentStorageHolder(
48 const uno::Reference
< embed::XStorage
> & xParentStorage
,
49 const rtl::OUString
& rUri
)
50 : m_xParentStorage( xParentStorage
),
51 m_bParentIsRootStorage( false )
54 if ( aUri
.isDocument() )
55 m_bParentIsRootStorage
= true;
58 //=========================================================================
59 //=========================================================================
61 // Storage Implementation.
63 //=========================================================================
64 //=========================================================================
66 Storage::Storage( const uno::Reference
< uno::XComponentContext
> & rxContext
,
67 const rtl::Reference
< StorageElementFactory
> & xFactory
,
68 const rtl::OUString
& rUri
,
69 const uno::Reference
< embed::XStorage
> & xParentStorage
,
70 const uno::Reference
< embed::XStorage
> & xStorageToWrap
)
71 : ParentStorageHolder( xParentStorage
, Uri( rUri
).getParentUri() ),
72 m_xFactory( xFactory
),
73 m_xWrappedStorage( xStorageToWrap
),
74 m_xWrappedTransObj( xStorageToWrap
, uno::UNO_QUERY
), // optional interface
75 m_xWrappedComponent( xStorageToWrap
, uno::UNO_QUERY
),
76 m_xWrappedTypeProv( xStorageToWrap
, uno::UNO_QUERY
),
77 m_bIsDocumentStorage( Uri( rUri
).isDocument() )
79 OSL_ENSURE( m_xWrappedStorage
.is(),
80 "Storage::Storage: No storage to wrap!" );
82 OSL_ENSURE( m_xWrappedComponent
.is(),
83 "Storage::Storage: No component to wrap!" );
85 OSL_ENSURE( m_xWrappedTypeProv
.is(),
86 "Storage::Storage: No Type Provider!" );
88 // Use proxy factory service to create aggregatable proxy.
91 uno::Reference
< reflection::XProxyFactory
> xProxyFac
=
92 reflection::ProxyFactory::create( rxContext
);
93 m_xAggProxy
= xProxyFac
->createProxy( m_xWrappedStorage
);
95 catch ( uno::Exception
const & )
97 OSL_FAIL( "Storage::Storage: Caught exception!" );
100 OSL_ENSURE( m_xAggProxy
.is(),
101 "Storage::Storage: Wrapped storage cannot be aggregated!" );
103 if ( m_xAggProxy
.is() )
105 osl_atomic_increment( &m_refCount
);
107 // Solaris compiler problem:
108 // Extra block to enforce destruction of temporary object created
109 // in next statement _before_ osl_atomic_decrement is
110 // called. Otherwise 'this' will destroy itself even before ctor
111 // is completed (See impl. of XInterface::release())!
113 m_xAggProxy
->setDelegator(
114 static_cast< cppu::OWeakObject
* >( this ) );
116 osl_atomic_decrement( &m_refCount
);
120 //=========================================================================
124 if ( m_xAggProxy
.is() )
125 m_xAggProxy
->setDelegator( uno::Reference
< uno::XInterface
>() );
127 // Never dispose a document storage. Not owner!
128 if ( !isDocumentStorage() )
130 if ( m_xWrappedComponent
.is() )
135 m_xWrappedComponent
->dispose();
137 catch ( lang::DisposedException
const & )
143 OSL_FAIL( "Storage::~Storage - Caught exception!" );
149 //=========================================================================
153 //=========================================================================
156 uno::Any SAL_CALL
Storage::queryInterface( const uno::Type
& aType
)
157 throw ( uno::RuntimeException
)
159 // First, try to use interfaces implemented by myself and base class(es)
160 uno::Any aRet
= StorageUNOBase::queryInterface( aType
);
162 if ( aRet
.hasValue() )
165 // Try to use requested interface from aggregated storage
166 return m_xAggProxy
->queryAggregation( aType
);
169 //=========================================================================
171 void SAL_CALL
Storage::acquire()
174 osl_atomic_increment( &m_refCount
);
177 //=========================================================================
179 void SAL_CALL
Storage::release()
182 if ( osl_atomic_decrement( &m_refCount
) == 0 )
184 m_xFactory
->releaseElement( this );
189 //=========================================================================
191 // lang::XTypeProvider
193 //=========================================================================
196 uno::Sequence
< uno::Type
> SAL_CALL
Storage::getTypes()
197 throw ( uno::RuntimeException
)
199 return m_xWrappedTypeProv
->getTypes();
202 //=========================================================================
204 uno::Sequence
< sal_Int8
> SAL_CALL
Storage::getImplementationId()
205 throw ( uno::RuntimeException
)
207 return m_xWrappedTypeProv
->getImplementationId();
210 //=========================================================================
212 // lang::XComponent (base of embed::XStorage)
214 //=========================================================================
216 void SAL_CALL
Storage::dispose()
217 throw ( uno::RuntimeException
)
219 m_xWrappedStorage
->dispose();
222 //=========================================================================
224 void SAL_CALL
Storage::addEventListener(
225 const uno::Reference
< lang::XEventListener
>& xListener
)
226 throw ( uno::RuntimeException
)
228 m_xWrappedStorage
->addEventListener( xListener
);
230 //=========================================================================
232 void SAL_CALL
Storage::removeEventListener(
233 const uno::Reference
< lang::XEventListener
>& aListener
)
234 throw (uno::RuntimeException
)
236 m_xWrappedStorage
->removeEventListener( aListener
);
239 //=========================================================================
241 // container::XElementAccess (base of container::XNameAccess)
243 //=========================================================================
246 uno::Type SAL_CALL
Storage::getElementType()
247 throw ( uno::RuntimeException
)
249 return m_xWrappedStorage
->getElementType();
252 //=========================================================================
254 ::sal_Bool SAL_CALL
Storage::hasElements()
255 throw ( uno::RuntimeException
)
257 return m_xWrappedStorage
->hasElements();
260 //=========================================================================
262 // container::XNameAccess (base of embed::XStorage)
264 //=========================================================================
267 uno::Any SAL_CALL
Storage::getByName( const ::rtl::OUString
& aName
)
268 throw ( container::NoSuchElementException
,
269 lang::WrappedTargetException
,
270 uno::RuntimeException
)
272 return m_xWrappedStorage
->getByName( aName
);
275 //=========================================================================
277 uno::Sequence
< ::rtl::OUString
> SAL_CALL
Storage::getElementNames()
278 throw ( uno::RuntimeException
)
280 return m_xWrappedStorage
->getElementNames();
283 //=========================================================================
285 ::sal_Bool SAL_CALL
Storage::hasByName( const ::rtl::OUString
& aName
)
286 throw ( uno::RuntimeException
)
288 return m_xWrappedStorage
->hasByName( aName
);
291 //=========================================================================
295 //=========================================================================
298 void SAL_CALL
Storage::copyToStorage(
299 const uno::Reference
< embed::XStorage
>& xDest
)
300 throw ( embed::InvalidStorageException
,
301 lang::IllegalArgumentException
,
303 embed::StorageWrappedTargetException
,
304 uno::RuntimeException
)
306 m_xWrappedStorage
->copyToStorage( xDest
);
309 //=========================================================================
311 uno::Reference
< io::XStream
> SAL_CALL
Storage::openStreamElement(
312 const ::rtl::OUString
& aStreamName
, sal_Int32 nOpenMode
)
313 throw ( embed::InvalidStorageException
,
314 lang::IllegalArgumentException
,
315 packages::WrongPasswordException
,
317 embed::StorageWrappedTargetException
,
318 uno::RuntimeException
)
320 return m_xWrappedStorage
->openStreamElement( aStreamName
, nOpenMode
);
323 //=========================================================================
325 uno::Reference
< io::XStream
> SAL_CALL
Storage::openEncryptedStreamElement(
326 const ::rtl::OUString
& aStreamName
,
328 const ::rtl::OUString
& aPassword
)
329 throw ( embed::InvalidStorageException
,
330 lang::IllegalArgumentException
,
331 packages::NoEncryptionException
,
332 packages::WrongPasswordException
,
334 embed::StorageWrappedTargetException
,
335 uno::RuntimeException
)
337 return m_xWrappedStorage
->openEncryptedStreamElement(
338 aStreamName
, nOpenMode
, aPassword
);
341 //=========================================================================
343 uno::Reference
< embed::XStorage
> SAL_CALL
Storage::openStorageElement(
344 const ::rtl::OUString
& aStorName
, sal_Int32 nOpenMode
)
345 throw ( embed::InvalidStorageException
,
346 lang::IllegalArgumentException
,
348 embed::StorageWrappedTargetException
,
349 uno::RuntimeException
)
351 return m_xWrappedStorage
->openStorageElement( aStorName
, nOpenMode
);
354 //=========================================================================
356 uno::Reference
< io::XStream
> SAL_CALL
Storage::cloneStreamElement(
357 const ::rtl::OUString
& aStreamName
)
358 throw ( embed::InvalidStorageException
,
359 lang::IllegalArgumentException
,
360 packages::WrongPasswordException
,
362 embed::StorageWrappedTargetException
,
363 uno::RuntimeException
)
365 return m_xWrappedStorage
->cloneStreamElement( aStreamName
);
368 //=========================================================================
370 uno::Reference
< io::XStream
> SAL_CALL
Storage::cloneEncryptedStreamElement(
371 const ::rtl::OUString
& aStreamName
,
372 const ::rtl::OUString
& aPassword
)
373 throw ( embed::InvalidStorageException
,
374 lang::IllegalArgumentException
,
375 packages::NoEncryptionException
,
376 packages::WrongPasswordException
,
378 embed::StorageWrappedTargetException
,
379 uno::RuntimeException
)
381 return m_xWrappedStorage
->cloneEncryptedStreamElement( aStreamName
,
385 //=========================================================================
387 void SAL_CALL
Storage::copyLastCommitTo(
388 const uno::Reference
< embed::XStorage
>& xTargetStorage
)
389 throw ( embed::InvalidStorageException
,
390 lang::IllegalArgumentException
,
392 embed::StorageWrappedTargetException
,
393 uno::RuntimeException
)
395 m_xWrappedStorage
->copyLastCommitTo( xTargetStorage
);
398 //=========================================================================
400 void SAL_CALL
Storage::copyStorageElementLastCommitTo(
401 const ::rtl::OUString
& aStorName
,
402 const uno::Reference
< embed::XStorage
>& xTargetStorage
)
403 throw ( embed::InvalidStorageException
,
404 lang::IllegalArgumentException
,
406 embed::StorageWrappedTargetException
,
407 uno::RuntimeException
)
409 m_xWrappedStorage
->copyStorageElementLastCommitTo( aStorName
, xTargetStorage
);
412 //=========================================================================
414 sal_Bool SAL_CALL
Storage::isStreamElement(
415 const ::rtl::OUString
& aElementName
)
416 throw ( container::NoSuchElementException
,
417 lang::IllegalArgumentException
,
418 embed::InvalidStorageException
,
419 uno::RuntimeException
)
421 return m_xWrappedStorage
->isStreamElement( aElementName
);
424 //=========================================================================
426 sal_Bool SAL_CALL
Storage::isStorageElement(
427 const ::rtl::OUString
& aElementName
)
428 throw ( container::NoSuchElementException
,
429 lang::IllegalArgumentException
,
430 embed::InvalidStorageException
,
431 uno::RuntimeException
)
433 return m_xWrappedStorage
->isStorageElement( aElementName
);
436 //=========================================================================
438 void SAL_CALL
Storage::removeElement( const ::rtl::OUString
& aElementName
)
439 throw ( embed::InvalidStorageException
,
440 lang::IllegalArgumentException
,
441 container::NoSuchElementException
,
443 embed::StorageWrappedTargetException
,
444 uno::RuntimeException
)
446 m_xWrappedStorage
->removeElement( aElementName
);
449 //=========================================================================
451 void SAL_CALL
Storage::renameElement( const ::rtl::OUString
& aEleName
,
452 const ::rtl::OUString
& aNewName
)
453 throw ( embed::InvalidStorageException
,
454 lang::IllegalArgumentException
,
455 container::NoSuchElementException
,
456 container::ElementExistException
,
458 embed::StorageWrappedTargetException
,
459 uno::RuntimeException
)
461 m_xWrappedStorage
->renameElement( aEleName
, aNewName
);
464 //=========================================================================
466 void SAL_CALL
Storage::copyElementTo(
467 const ::rtl::OUString
& aElementName
,
468 const uno::Reference
< embed::XStorage
>& xDest
,
469 const ::rtl::OUString
& aNewName
)
470 throw ( embed::InvalidStorageException
,
471 lang::IllegalArgumentException
,
472 container::NoSuchElementException
,
473 container::ElementExistException
,
475 embed::StorageWrappedTargetException
,
476 uno::RuntimeException
)
478 m_xWrappedStorage
->copyElementTo( aElementName
, xDest
, aNewName
);
481 //=========================================================================
483 void SAL_CALL
Storage::moveElementTo(
484 const ::rtl::OUString
& aElementName
,
485 const uno::Reference
< embed::XStorage
>& xDest
,
486 const ::rtl::OUString
& rNewName
)
487 throw ( embed::InvalidStorageException
,
488 lang::IllegalArgumentException
,
489 container::NoSuchElementException
,
490 container::ElementExistException
,
492 embed::StorageWrappedTargetException
,
493 uno::RuntimeException
)
495 m_xWrappedStorage
->moveElementTo( aElementName
, xDest
, rNewName
);
498 //=========================================================================
500 // embed::XTransactedObject
502 //=========================================================================
505 void SAL_CALL
Storage::commit()
506 throw ( io::IOException
,
507 lang::WrappedTargetException
,
508 uno::RuntimeException
)
510 // Never commit a root storage (-> has no parent)!
511 // Would lead in writing the whole document to disk.
513 uno::Reference
< embed::XStorage
> xParentStorage
= getParentStorage();
514 if ( xParentStorage
.is() )
516 OSL_ENSURE( m_xWrappedTransObj
.is(), "No XTransactedObject interface!" );
518 if ( m_xWrappedTransObj
.is() )
520 m_xWrappedTransObj
->commit();
522 if ( !isParentARootStorage() )
524 uno::Reference
< embed::XTransactedObject
> xParentTA(
525 xParentStorage
, uno::UNO_QUERY
);
526 OSL_ENSURE( xParentTA
.is(), "No XTransactedObject interface!" );
528 if ( xParentTA
.is() )
535 //=========================================================================
537 void SAL_CALL
Storage::revert()
538 throw ( io::IOException
,
539 lang::WrappedTargetException
,
540 uno::RuntimeException
)
542 uno::Reference
< embed::XStorage
> xParentStorage
= getParentStorage();
543 if ( xParentStorage
.is() )
545 OSL_ENSURE( m_xWrappedTransObj
.is(), "No XTransactedObject interface!" );
547 if ( m_xWrappedTransObj
.is() )
549 m_xWrappedTransObj
->revert();
551 if ( !isParentARootStorage() )
553 uno::Reference
< embed::XTransactedObject
> xParentTA(
554 xParentStorage
, uno::UNO_QUERY
);
555 OSL_ENSURE( xParentTA
.is(), "No XTransactedObject interface!" );
557 if ( xParentTA
.is() )
564 //=========================================================================
565 //=========================================================================
567 // OutputStream Implementation.
569 //=========================================================================
570 //=========================================================================
572 OutputStream::OutputStream(
573 const uno::Reference
< uno::XComponentContext
> & rxContext
,
574 const rtl::OUString
& rUri
,
575 const uno::Reference
< embed::XStorage
> & xParentStorage
,
576 const uno::Reference
< io::XOutputStream
> & xStreamToWrap
)
577 : ParentStorageHolder( xParentStorage
, Uri( rUri
).getParentUri() ),
578 m_xWrappedStream( xStreamToWrap
),
579 m_xWrappedComponent( xStreamToWrap
, uno::UNO_QUERY
),
580 m_xWrappedTypeProv( xStreamToWrap
, uno::UNO_QUERY
)
582 OSL_ENSURE( m_xWrappedStream
.is(),
583 "OutputStream::OutputStream: No stream to wrap!" );
585 OSL_ENSURE( m_xWrappedComponent
.is(),
586 "OutputStream::OutputStream: No component to wrap!" );
588 OSL_ENSURE( m_xWrappedTypeProv
.is(),
589 "OutputStream::OutputStream: No Type Provider!" );
591 // Use proxy factory service to create aggregatable proxy.
594 uno::Reference
< reflection::XProxyFactory
> xProxyFac
=
595 reflection::ProxyFactory::create( rxContext
);
596 m_xAggProxy
= xProxyFac
->createProxy( m_xWrappedStream
);
598 catch ( uno::Exception
const & )
600 OSL_FAIL( "OutputStream::OutputStream: Caught exception!" );
603 OSL_ENSURE( m_xAggProxy
.is(),
604 "OutputStream::OutputStream: Wrapped stream cannot be aggregated!" );
606 if ( m_xAggProxy
.is() )
608 osl_atomic_increment( &m_refCount
);
610 // Solaris compiler problem:
611 // Extra block to enforce destruction of temporary object created
612 // in next statement _before_ osl_atomic_decrement is
613 // called. Otherwise 'this' will destroy itself even before ctor
614 // is completed (See impl. of XInterface::release())!
616 m_xAggProxy
->setDelegator(
617 static_cast< cppu::OWeakObject
* >( this ) );
619 osl_atomic_decrement( &m_refCount
);
623 //=========================================================================
625 OutputStream::~OutputStream()
627 if ( m_xAggProxy
.is() )
628 m_xAggProxy
->setDelegator( uno::Reference
< uno::XInterface
>() );
631 //=========================================================================
635 //=========================================================================
638 uno::Any SAL_CALL
OutputStream::queryInterface( const uno::Type
& aType
)
639 throw ( uno::RuntimeException
)
641 uno::Any aRet
= OutputStreamUNOBase::queryInterface( aType
);
643 if ( aRet
.hasValue() )
646 if ( m_xAggProxy
.is() )
647 return m_xAggProxy
->queryAggregation( aType
);
652 //=========================================================================
654 // lang::XTypeProvider
656 //=========================================================================
659 uno::Sequence
< uno::Type
> SAL_CALL
OutputStream::getTypes()
660 throw ( uno::RuntimeException
)
662 return m_xWrappedTypeProv
->getTypes();
665 //=========================================================================
667 uno::Sequence
< sal_Int8
> SAL_CALL
OutputStream::getImplementationId()
668 throw ( uno::RuntimeException
)
670 return m_xWrappedTypeProv
->getImplementationId();
673 //=========================================================================
677 //=========================================================================
681 OutputStream::writeBytes( const uno::Sequence
< sal_Int8
>& aData
)
682 throw ( io::NotConnectedException
,
683 io::BufferSizeExceededException
,
685 uno::RuntimeException
)
687 m_xWrappedStream
->writeBytes( aData
);
690 //=========================================================================
693 OutputStream::flush()
694 throw ( io::NotConnectedException
,
695 io::BufferSizeExceededException
,
697 uno::RuntimeException
)
699 m_xWrappedStream
->flush();
702 //=========================================================================
705 OutputStream::closeOutput( )
706 throw ( io::NotConnectedException
,
707 io::BufferSizeExceededException
,
709 uno::RuntimeException
)
711 m_xWrappedStream
->closeOutput();
713 // Release parent storage.
714 // Now, that the stream is closed/disposed it is not needed any longer.
715 setParentStorage( uno::Reference
< embed::XStorage
>() );
718 //=========================================================================
722 //=========================================================================
726 OutputStream::dispose()
727 throw ( uno::RuntimeException
)
729 m_xWrappedComponent
->dispose();
731 // Release parent storage.
732 // Now, that the stream is closed/disposed it is not needed any longer.
733 setParentStorage( uno::Reference
< embed::XStorage
>() );
736 //=========================================================================
739 OutputStream::addEventListener(
740 const uno::Reference
< lang::XEventListener
>& xListener
)
741 throw ( uno::RuntimeException
)
743 m_xWrappedComponent
->addEventListener( xListener
);
746 //=========================================================================
749 OutputStream::removeEventListener(
750 const uno::Reference
< lang::XEventListener
>& aListener
)
751 throw ( uno::RuntimeException
)
753 m_xWrappedComponent
->removeEventListener( aListener
);
756 //=========================================================================
757 //=========================================================================
759 // Stream Implementation.
761 //=========================================================================
762 //=========================================================================
765 const uno::Reference
< uno::XComponentContext
> & rxContext
,
766 const rtl::OUString
& rUri
,
767 const uno::Reference
< embed::XStorage
> & xParentStorage
,
768 const uno::Reference
< io::XStream
> & xStreamToWrap
)
769 : ParentStorageHolder( xParentStorage
, Uri( rUri
).getParentUri() ),
770 m_xWrappedStream( xStreamToWrap
),
771 m_xWrappedOutputStream( xStreamToWrap
->getOutputStream() ), // might be empty
772 m_xWrappedTruncate( m_xWrappedOutputStream
, uno::UNO_QUERY
), // might be empty
773 m_xWrappedInputStream( xStreamToWrap
->getInputStream(), uno::UNO_QUERY
),
774 m_xWrappedComponent( xStreamToWrap
, uno::UNO_QUERY
),
775 m_xWrappedTypeProv( xStreamToWrap
, uno::UNO_QUERY
)
777 OSL_ENSURE( m_xWrappedStream
.is(),
778 "OutputStream::OutputStream: No stream to wrap!" );
780 OSL_ENSURE( m_xWrappedComponent
.is(),
781 "OutputStream::OutputStream: No component to wrap!" );
783 OSL_ENSURE( m_xWrappedTypeProv
.is(),
784 "OutputStream::OutputStream: No Type Provider!" );
786 // Use proxy factory service to create aggregatable proxy.
789 uno::Reference
< reflection::XProxyFactory
> xProxyFac
=
790 reflection::ProxyFactory::create( rxContext
);
791 m_xAggProxy
= xProxyFac
->createProxy( m_xWrappedStream
);
793 catch ( uno::Exception
const & )
795 OSL_FAIL( "OutputStream::OutputStream: Caught exception!" );
798 OSL_ENSURE( m_xAggProxy
.is(),
799 "OutputStream::OutputStream: Wrapped stream cannot be aggregated!" );
801 if ( m_xAggProxy
.is() )
803 osl_atomic_increment( &m_refCount
);
805 // Solaris compiler problem:
806 // Extra block to enforce destruction of temporary object created
807 // in next statement _before_ osl_atomic_decrement is
808 // called. Otherwise 'this' will destroy itself even before ctor
809 // is completed (See impl. of XInterface::release())!
811 m_xAggProxy
->setDelegator(
812 static_cast< cppu::OWeakObject
* >( this ) );
814 osl_atomic_decrement( &m_refCount
);
818 //=========================================================================
822 if ( m_xAggProxy
.is() )
823 m_xAggProxy
->setDelegator( uno::Reference
< uno::XInterface
>() );
826 //=========================================================================
830 //=========================================================================
833 uno::Any SAL_CALL
Stream::queryInterface( const uno::Type
& aType
)
834 throw ( uno::RuntimeException
)
836 uno::Any aRet
= StreamUNOBase::queryInterface( aType
);
838 if ( aRet
.hasValue() )
841 if ( m_xAggProxy
.is() )
842 return m_xAggProxy
->queryAggregation( aType
);
847 //=========================================================================
849 // lang::XTypeProvider
851 //=========================================================================
854 uno::Sequence
< uno::Type
> SAL_CALL
Stream::getTypes()
855 throw ( uno::RuntimeException
)
857 return m_xWrappedTypeProv
->getTypes();
860 //=========================================================================
862 uno::Sequence
< sal_Int8
> SAL_CALL
Stream::getImplementationId()
863 throw ( uno::RuntimeException
)
865 return m_xWrappedTypeProv
->getImplementationId();
868 //=========================================================================
872 //=========================================================================
875 uno::Reference
< io::XInputStream
> SAL_CALL
Stream::getInputStream()
876 throw( uno::RuntimeException
)
878 return uno::Reference
< io::XInputStream
>( this );
881 //=========================================================================
883 uno::Reference
< io::XOutputStream
> SAL_CALL
Stream::getOutputStream()
884 throw( uno::RuntimeException
)
886 return uno::Reference
< io::XOutputStream
>( this );
889 //=========================================================================
891 // io::XOutputStream.
893 //=========================================================================
896 void SAL_CALL
Stream::writeBytes( const uno::Sequence
< sal_Int8
>& aData
)
897 throw( io::NotConnectedException
,
898 io::BufferSizeExceededException
,
900 uno::RuntimeException
)
902 if ( m_xWrappedOutputStream
.is() )
904 m_xWrappedOutputStream
->writeBytes( aData
);
909 //=========================================================================
911 void SAL_CALL
Stream::flush()
912 throw( io::NotConnectedException
,
913 io::BufferSizeExceededException
,
915 uno::RuntimeException
)
917 if ( m_xWrappedOutputStream
.is() )
919 m_xWrappedOutputStream
->flush();
924 //=========================================================================
926 void SAL_CALL
Stream::closeOutput()
927 throw( io::NotConnectedException
,
929 uno::RuntimeException
)
931 if ( m_xWrappedOutputStream
.is() )
933 m_xWrappedOutputStream
->closeOutput();
937 // Release parent storage.
938 // Now, that the stream is closed/disposed it is not needed any longer.
939 setParentStorage( uno::Reference
< embed::XStorage
>() );
942 //=========================================================================
946 //=========================================================================
949 void SAL_CALL
Stream::truncate()
950 throw( io::IOException
,
951 uno::RuntimeException
)
953 if ( m_xWrappedTruncate
.is() )
955 m_xWrappedTruncate
->truncate();
960 //=========================================================================
964 //=========================================================================
967 sal_Int32 SAL_CALL
Stream::readBytes( uno::Sequence
< sal_Int8
>& aData
,
968 sal_Int32 nBytesToRead
)
969 throw( io::NotConnectedException
,
970 io::BufferSizeExceededException
,
972 uno::RuntimeException
)
974 return m_xWrappedInputStream
->readBytes( aData
, nBytesToRead
);
977 //=========================================================================
979 sal_Int32 SAL_CALL
Stream::readSomeBytes( uno::Sequence
< sal_Int8
>& aData
,
980 sal_Int32 nMaxBytesToRead
)
981 throw( io::NotConnectedException
,
982 io::BufferSizeExceededException
,
984 uno::RuntimeException
)
986 return m_xWrappedInputStream
->readSomeBytes( aData
, nMaxBytesToRead
);
989 //=========================================================================
991 void SAL_CALL
Stream::skipBytes( sal_Int32 nBytesToSkip
)
992 throw( io::NotConnectedException
,
993 io::BufferSizeExceededException
,
995 uno::RuntimeException
)
997 m_xWrappedInputStream
->skipBytes( nBytesToSkip
);
1000 //=========================================================================
1002 sal_Int32 SAL_CALL
Stream::available()
1003 throw( io::NotConnectedException
,
1005 uno::RuntimeException
)
1007 return m_xWrappedInputStream
->available();
1010 //=========================================================================
1012 void SAL_CALL
Stream::closeInput()
1013 throw( io::NotConnectedException
,
1015 uno::RuntimeException
)
1017 m_xWrappedInputStream
->closeInput();
1020 //=========================================================================
1024 //=========================================================================
1027 void SAL_CALL
Stream::dispose()
1028 throw ( uno::RuntimeException
)
1030 m_xWrappedComponent
->dispose();
1032 // Release parent storage.
1033 // Now, that the stream is closed/disposed it is not needed any longer.
1034 setParentStorage( uno::Reference
< embed::XStorage
>() );
1037 //=========================================================================
1039 void SAL_CALL
Stream::addEventListener(
1040 const uno::Reference
< lang::XEventListener
>& xListener
)
1041 throw ( uno::RuntimeException
)
1043 m_xWrappedComponent
->addEventListener( xListener
);
1046 //=========================================================================
1048 void SAL_CALL
Stream::removeEventListener(
1049 const uno::Reference
< lang::XEventListener
>& aListener
)
1050 throw ( uno::RuntimeException
)
1052 m_xWrappedComponent
->removeEventListener( aListener
);
1055 //=========================================================================
1059 //=========================================================================
1061 void Stream::commitChanges()
1062 throw( io::IOException
)
1064 uno::Reference
< embed::XTransactedObject
>
1065 xParentTA( getParentStorage(), uno::UNO_QUERY
);
1066 OSL_ENSURE( xParentTA
.is(), "No XTransactedObject interface!" );
1068 if ( xParentTA
.is() )
1072 xParentTA
->commit();
1074 catch ( lang::WrappedTargetException
const & )
1076 throw io::IOException(); // @@@
1081 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */