Debian Codegraph @

ucb/source/ucp/tdoc/tdoc_stgelems.cxx

raw
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20
21 /**************************************************************************
22 TODO
23 **************************************************************************
24
25 - remove root storage access workaround
26
27 *************************************************************************/
28
29 #include <comphelper/diagnose_ex.hxx>
30 #include <com/sun/star/io/IOException.hpp>
31 #include <com/sun/star/lang/DisposedException.hpp>
32 #include <com/sun/star/reflection/ProxyFactory.hpp>
33 #include <utility>
34
35 #include "tdoc_docmgr.hxx"
36 #include "tdoc_uri.hxx"
37
38 #include "tdoc_stgelems.hxx"
39
40 using namespace com::sun::star;
41 using namespace tdoc_ucp;
42
43
44 // ParentStorageHolder Implementation.
45
46
47 ParentStorageHolder::ParentStorageHolder(
48 uno::Reference< embed::XStorage > xParentStorage,
49 const OUString & rUri )
50 : m_xParentStorage(std::move( xParentStorage )),
51 m_bParentIsRootStorage( false )
52 {
53 Uri aUri( rUri );
54 if ( aUri.isDocument() )
55 m_bParentIsRootStorage = true;
56 }
57
58
59 // Storage Implementation.
60
61
62 Storage::Storage( const uno::Reference< uno::XComponentContext > & rxContext,
63 rtl::Reference< StorageElementFactory > xFactory,
64 const OUString & rUri,
65 const uno::Reference< embed::XStorage > & xParentStorage,
66 const uno::Reference< embed::XStorage > & xStorageToWrap )
67 : ParentStorageHolder( xParentStorage, Uri( rUri ).getParentUri() ),
68 m_xFactory(std::move( xFactory )),
69 m_xWrappedStorage( xStorageToWrap ),
70 m_xWrappedTransObj( xStorageToWrap, uno::UNO_QUERY ), // optional interface
71 m_xWrappedComponent( xStorageToWrap ),
72 m_xWrappedTypeProv( xStorageToWrap, uno::UNO_QUERY ),
73 m_bIsDocumentStorage( Uri( rUri ).isDocument() )
74 {
75 OSL_ENSURE( m_xWrappedStorage.is(),
76 "Storage::Storage: No storage to wrap!" );
77
78 OSL_ENSURE( m_xWrappedComponent.is(),
79 "Storage::Storage: No component to wrap!" );
80
81 OSL_ENSURE( m_xWrappedTypeProv.is(),
82 "Storage::Storage: No Type Provider!" );
83
84 // Use proxy factory service to create aggregatable proxy.
85 try
86 {
87 uno::Reference< reflection::XProxyFactory > xProxyFac =
88 reflection::ProxyFactory::create( rxContext );
89 m_xAggProxy = xProxyFac->createProxy( m_xWrappedStorage );
90 }
91 catch ( uno::Exception const & )
92 {
93 TOOLS_WARN_EXCEPTION("ucb.ucp", "");
94 }
95
96 OSL_ENSURE( m_xAggProxy.is(),
97 "Storage::Storage: Wrapped storage cannot be aggregated!" );
98
99 if ( !m_xAggProxy.is() )
100 return;
101
102 osl_atomic_increment( &m_refCount );
103 {
104 // Solaris compiler problem:
105 // Extra block to enforce destruction of temporary object created
106 // in next statement _before_ osl_atomic_decrement is
107 // called. Otherwise 'this' will destroy itself even before ctor
108 // is completed (See impl. of XInterface::release())!
109
110 m_xAggProxy->setDelegator(
111 getXWeak() );
112 }
113 osl_atomic_decrement( &m_refCount );
114 }
115
116
117 // virtual
118 Storage::~Storage()
119 {
120 if ( m_xAggProxy.is() )
121 m_xAggProxy->setDelegator( uno::Reference< uno::XInterface >() );
122
123 // Never dispose a document storage. Not owner!
124 if ( m_bIsDocumentStorage )
125 return;
126
127 if ( !m_xWrappedComponent.is() )
128 return;
129
130 // "Auto-dispose"...
131 try
132 {
133 m_xWrappedComponent->dispose();
134 }
135 catch ( lang::DisposedException const & )
136 {
137 // might happen.
138 }
139 catch ( ... )
140 {
141 TOOLS_WARN_EXCEPTION( "ucb", "Storage::~Storage - Caught exception!" );
142 }
143 }
144
145
146 // uno::XInterface
147
148
149 // virtual
150 uno::Any SAL_CALL Storage::queryInterface( const uno::Type& aType )
151 {
152 // First, try to use interfaces implemented by myself and base class(es)
153 uno::Any aRet = StorageUNOBase::queryInterface( aType );
154
155 if ( aRet.hasValue() )
156 return aRet;
157
158 // Try to use requested interface from aggregated storage
159 return m_xAggProxy->queryAggregation( aType );
160 }
161
162
163 // virtual
164 void SAL_CALL Storage::acquire()
165 noexcept
166 {
167 osl_atomic_increment( &m_refCount );
168 }
169
170
171 // virtual
172 void SAL_CALL Storage::release()
173 noexcept
174 {
175 //#i120738, Storage::release overrides OWeakObject::release(),
176 //need call OWeakObject::release() to release OWeakObject::m_pWeakConnectionPoint
177
178 if ( m_refCount == 1 )
179 m_xFactory->releaseElement( this );
180
181 //delete this;
182 OWeakObject::release();
183 }
184
185
186 // lang::XTypeProvider
187
188
189 // virtual
190 uno::Sequence< uno::Type > SAL_CALL Storage::getTypes()
191 {
192 return m_xWrappedTypeProv->getTypes();
193 }
194
195
196 // virtual
197 uno::Sequence< sal_Int8 > SAL_CALL Storage::getImplementationId()
198 {
199 return css::uno::Sequence<sal_Int8>();
200 }
201
202
203 // lang::XComponent (base of embed::XStorage)
204
205
206 // virtual
207 void SAL_CALL Storage::dispose()
208 {
209 m_xWrappedStorage->dispose();
210 m_xWrappedStorage.clear();
211 }
212
213
214 // virtual
215 void SAL_CALL Storage::addEventListener(
216 const uno::Reference< lang::XEventListener >& xListener )
217 {
218 m_xWrappedStorage->addEventListener( xListener );
219 }
220
221 // virtual
222 void SAL_CALL Storage::removeEventListener(
223 const uno::Reference< lang::XEventListener >& aListener )
224 {
225 m_xWrappedStorage->removeEventListener( aListener );
226 }
227
228
229 // container::XElementAccess (base of container::XNameAccess)
230
231
232 // virtual
233 uno::Type SAL_CALL Storage::getElementType()
234 {
235 return m_xWrappedStorage->getElementType();
236 }
237
238
239 // virtual
240 sal_Bool SAL_CALL Storage::hasElements()
241 {
242 return m_xWrappedStorage->hasElements();
243 }
244
245
246 // container::XNameAccess (base of embed::XStorage)
247
248
249 // virtual
250 uno::Any SAL_CALL Storage::getByName( const OUString& aName )
251 {
252 return m_xWrappedStorage->getByName( aName );
253 }
254
255
256 // virtual
257 uno::Sequence< OUString > SAL_CALL Storage::getElementNames()
258 {
259 return m_xWrappedStorage->getElementNames();
260 }
261
262
263 // virtual
264 sal_Bool SAL_CALL Storage::hasByName( const OUString& aName )
265 {
266 return m_xWrappedStorage->hasByName( aName );
267 }
268
269
270 // embed::XStorage
271
272
273 // virtual
274 void SAL_CALL Storage::copyToStorage(
275 const uno::Reference< embed::XStorage >& xDest )
276 {
277 m_xWrappedStorage->copyToStorage( xDest );
278 }
279
280
281 // virtual
282 uno::Reference< io::XStream > SAL_CALL Storage::openStreamElement(
283 const OUString& aStreamName, sal_Int32 nOpenMode )
284 {
285 return m_xWrappedStorage->openStreamElement( aStreamName, nOpenMode );
286 }
287
288
289 // virtual
290 uno::Reference< io::XStream > SAL_CALL Storage::openEncryptedStreamElement(
291 const OUString& aStreamName,
292 sal_Int32 nOpenMode,
293 const OUString& aPassword )
294 {
295 return m_xWrappedStorage->openEncryptedStreamElement(
296 aStreamName, nOpenMode, aPassword );
297 }
298
299
300 // virtual
301 uno::Reference< embed::XStorage > SAL_CALL Storage::openStorageElement(
302 const OUString& aStorName, sal_Int32 nOpenMode )
303 {
304 return m_xWrappedStorage->openStorageElement( aStorName, nOpenMode );
305 }
306
307
308 // virtual
309 uno::Reference< io::XStream > SAL_CALL Storage::cloneStreamElement(
310 const OUString& aStreamName )
311 {
312 return m_xWrappedStorage->cloneStreamElement( aStreamName );
313 }
314
315
316 // virtual
317 uno::Reference< io::XStream > SAL_CALL Storage::cloneEncryptedStreamElement(
318 const OUString& aStreamName,
319 const OUString& aPassword )
320 {
321 return m_xWrappedStorage->cloneEncryptedStreamElement( aStreamName,
322 aPassword );
323 }
324
325
326 // virtual
327 void SAL_CALL Storage::copyLastCommitTo(
328 const uno::Reference< embed::XStorage >& xTargetStorage )
329 {
330 m_xWrappedStorage->copyLastCommitTo( xTargetStorage );
331 }
332
333
334 // virtual
335 void SAL_CALL Storage::copyStorageElementLastCommitTo(
336 const OUString& aStorName,
337 const uno::Reference< embed::XStorage >& xTargetStorage )
338 {
339 m_xWrappedStorage->copyStorageElementLastCommitTo( aStorName, xTargetStorage );
340 }
341
342
343 // virtual
344 sal_Bool SAL_CALL Storage::isStreamElement(
345 const OUString& aElementName )
346 {
347 return m_xWrappedStorage->isStreamElement( aElementName );
348 }
349
350
351 // virtual
352 sal_Bool SAL_CALL Storage::isStorageElement(
353 const OUString& aElementName )
354 {
355 return m_xWrappedStorage->isStorageElement( aElementName );
356 }
357
358
359 // virtual
360 void SAL_CALL Storage::removeElement( const OUString& aElementName )
361 {
362 m_xWrappedStorage->removeElement( aElementName );
363 }
364
365
366 // virtual
367 void SAL_CALL Storage::renameElement( const OUString& aEleName,
368 const OUString& aNewName )
369 {
370 m_xWrappedStorage->renameElement( aEleName, aNewName );
371 }
372
373
374 // virtual
375 void SAL_CALL Storage::copyElementTo(
376 const OUString& aElementName,
377 const uno::Reference< embed::XStorage >& xDest,
378 const OUString& aNewName )
379 {
380 m_xWrappedStorage->copyElementTo( aElementName, xDest, aNewName );
381 }
382
383
384 // virtual
385 void SAL_CALL Storage::moveElementTo(
386 const OUString& aElementName,
387 const uno::Reference< embed::XStorage >& xDest,
388 const OUString& rNewName )
389 {
390 m_xWrappedStorage->moveElementTo( aElementName, xDest, rNewName );
391 }
392
393
394 // embed::XTransactedObject
395
396
397 // virtual
398 void SAL_CALL Storage::commit()
399 {
400 // Never commit a root storage (-> has no parent)!
401 // Would lead in writing the whole document to disk.
402
403 uno::Reference< embed::XStorage > xParentStorage = getParentStorage();
404 if ( !xParentStorage.is() )
405 return;
406
407 OSL_ENSURE( m_xWrappedTransObj.is(), "No XTransactedObject interface!" );
408
409 if ( !m_xWrappedTransObj.is() )
410 return;
411
412 m_xWrappedTransObj->commit();
413
414 if ( !isParentARootStorage() )
415 {
416 uno::Reference< embed::XTransactedObject > xParentTA(
417 xParentStorage, uno::UNO_QUERY );
418 OSL_ENSURE( xParentTA.is(), "No XTransactedObject interface!" );
419
420 if ( xParentTA.is() )
421 xParentTA->commit();
422 }
423 }
424
425
426 // virtual
427 void SAL_CALL Storage::revert()
428 {
429 uno::Reference< embed::XStorage > xParentStorage = getParentStorage();
430 if ( !xParentStorage.is() )
431 return;
432
433 OSL_ENSURE( m_xWrappedTransObj.is(), "No XTransactedObject interface!" );
434
435 if ( !m_xWrappedTransObj.is() )
436 return;
437
438 m_xWrappedTransObj->revert();
439
440 if ( !isParentARootStorage() )
441 {
442 uno::Reference< embed::XTransactedObject > xParentTA(
443 xParentStorage, uno::UNO_QUERY );
444 OSL_ENSURE( xParentTA.is(), "No XTransactedObject interface!" );
445
446 if ( xParentTA.is() )
447 xParentTA->revert();
448 }
449 }
450
451
452 // OutputStream Implementation.
453
454
455 OutputStream::OutputStream(
456 const uno::Reference< uno::XComponentContext > & rxContext,
457 const OUString & rUri,
458 const uno::Reference< embed::XStorage > & xParentStorage,
459 const uno::Reference< io::XOutputStream > & xStreamToWrap )
460 : ParentStorageHolder( xParentStorage, Uri( rUri ).getParentUri() ),
461 m_xWrappedStream( xStreamToWrap ),
462 m_xWrappedComponent( xStreamToWrap, uno::UNO_QUERY ),
463 m_xWrappedTypeProv( xStreamToWrap, uno::UNO_QUERY )
464 {
465 OSL_ENSURE( m_xWrappedStream.is(),
466 "OutputStream::OutputStream: No stream to wrap!" );
467
468 OSL_ENSURE( m_xWrappedComponent.is(),
469 "OutputStream::OutputStream: No component to wrap!" );
470
471 OSL_ENSURE( m_xWrappedTypeProv.is(),
472 "OutputStream::OutputStream: No Type Provider!" );
473
474 // Use proxy factory service to create aggregatable proxy.
475 try
476 {
477 uno::Reference< reflection::XProxyFactory > xProxyFac =
478 reflection::ProxyFactory::create( rxContext );
479 m_xAggProxy = xProxyFac->createProxy( m_xWrappedStream );
480 }
481 catch ( uno::Exception const & )
482 {
483 TOOLS_WARN_EXCEPTION("ucb.ucp", "");
484 }
485
486 OSL_ENSURE( m_xAggProxy.is(),
487 "OutputStream::OutputStream: Wrapped stream cannot be aggregated!" );
488
489 if ( !m_xAggProxy.is() )
490 return;
491
492 osl_atomic_increment( &m_refCount );
493 {
494 // Solaris compiler problem:
495 // Extra block to enforce destruction of temporary object created
496 // in next statement _before_ osl_atomic_decrement is
497 // called. Otherwise 'this' will destroy itself even before ctor
498 // is completed (See impl. of XInterface::release())!
499
500 m_xAggProxy->setDelegator(
501 getXWeak() );
502 }
503 osl_atomic_decrement( &m_refCount );
504 }
505
506
507 // virtual
508 OutputStream::~OutputStream()
509 {
510 if ( m_xAggProxy.is() )
511 m_xAggProxy->setDelegator( uno::Reference< uno::XInterface >() );
512 }
513
514
515 // uno::XInterface
516
517
518 // virtual
519 uno::Any SAL_CALL OutputStream::queryInterface( const uno::Type& aType )
520 {
521 uno::Any aRet = OutputStreamUNOBase::queryInterface( aType );
522
523 if ( aRet.hasValue() )
524 return aRet;
525
526 if ( m_xAggProxy.is() )
527 return m_xAggProxy->queryAggregation( aType );
528 else
529 return uno::Any();
530 }
531
532
533 // lang::XTypeProvider
534
535
536 // virtual
537 uno::Sequence< uno::Type > SAL_CALL OutputStream::getTypes()
538 {
539 return m_xWrappedTypeProv->getTypes();
540 }
541
542
543 // virtual
544 uno::Sequence< sal_Int8 > SAL_CALL OutputStream::getImplementationId()
545 {
546 return css::uno::Sequence<sal_Int8>();
547 }
548
549
550 // io::XOutputStream
551
552
553 // virtual
554 void SAL_CALL
555 OutputStream::writeBytes( const uno::Sequence< sal_Int8 >& aData )
556 {
557 m_xWrappedStream->writeBytes( aData );
558 }
559
560
561 // virtual
562 void SAL_CALL
563 OutputStream::flush()
564 {
565 m_xWrappedStream->flush();
566 }
567
568
569 // virtual
570 void SAL_CALL
571 OutputStream::closeOutput( )
572 {
573 m_xWrappedStream->closeOutput();
574
575 // Release parent storage.
576 // Now, that the stream is closed/disposed it is not needed any longer.
577 clearParentStorage();
578 }
579
580
581 // lang::XComponent
582
583
584 // virtual
585 void SAL_CALL
586 OutputStream::dispose()
587 {
588 m_xWrappedComponent->dispose();
589
590 // Release parent storage.
591 // Now, that the stream is closed/disposed it is not needed any longer.
592 clearParentStorage();
593 }
594
595
596 // virtual
597 void SAL_CALL
598 OutputStream::addEventListener(
599 const uno::Reference< lang::XEventListener >& xListener )
600 {
601 m_xWrappedComponent->addEventListener( xListener );
602 }
603
604
605 // virtual
606 void SAL_CALL
607 OutputStream::removeEventListener(
608 const uno::Reference< lang::XEventListener >& aListener )
609 {
610 m_xWrappedComponent->removeEventListener( aListener );
611 }
612
613
614 // Stream Implementation.
615
616
617 Stream::Stream(
618 const uno::Reference< uno::XComponentContext > & rxContext,
619 rtl::Reference<OfficeDocumentsManager> const & docsMgr,
620 const OUString & rUri,
621 const uno::Reference< embed::XStorage > & xParentStorage,
622 const uno::Reference< io::XStream > & xStreamToWrap )
623 : ParentStorageHolder( xParentStorage, Uri( rUri ).getParentUri() ),
624 m_docsMgr(docsMgr),
625 m_uri(rUri),
626 m_xWrappedStream( xStreamToWrap ),
627 m_xWrappedOutputStream( xStreamToWrap->getOutputStream() ), // might be empty
628 m_xWrappedTruncate( m_xWrappedOutputStream, uno::UNO_QUERY ), // might be empty
629 m_xWrappedInputStream( xStreamToWrap->getInputStream() ),
630 m_xWrappedComponent( xStreamToWrap, uno::UNO_QUERY ),
631 m_xWrappedTypeProv( xStreamToWrap, uno::UNO_QUERY )
632 {
633 OSL_ENSURE( m_xWrappedStream.is(),
634 "OutputStream::OutputStream: No stream to wrap!" );
635
636 OSL_ENSURE( m_xWrappedComponent.is(),
637 "OutputStream::OutputStream: No component to wrap!" );
638
639 OSL_ENSURE( m_xWrappedTypeProv.is(),
640 "OutputStream::OutputStream: No Type Provider!" );
641
642 // Use proxy factory service to create aggregatable proxy.
643 try
644 {
645 uno::Reference< reflection::XProxyFactory > xProxyFac =
646 reflection::ProxyFactory::create( rxContext );
647 m_xAggProxy = xProxyFac->createProxy( m_xWrappedStream );
648 }
649 catch ( uno::Exception const & )
650 {
651 TOOLS_WARN_EXCEPTION("ucb.ucp", "");
652 }
653
654 OSL_ENSURE( m_xAggProxy.is(),
655 "OutputStream::OutputStream: Wrapped stream cannot be aggregated!" );
656
657 if ( !m_xAggProxy.is() )
658 return;
659
660 osl_atomic_increment( &m_refCount );
661 {
662 // Solaris compiler problem:
663 // Extra block to enforce destruction of temporary object created
664 // in next statement _before_ osl_atomic_decrement is
665 // called. Otherwise 'this' will destroy itself even before ctor
666 // is completed (See impl. of XInterface::release())!
667
668 m_xAggProxy->setDelegator(
669 getXWeak() );
670 }
671 osl_atomic_decrement( &m_refCount );
672 }
673
674
675 // virtual
676 Stream::~Stream()
677 {
678 if ( m_xAggProxy.is() )
679 m_xAggProxy->setDelegator( uno::Reference< uno::XInterface >() );
680 }
681
682
683 // uno::XInterface
684
685
686 // virtual
687 uno::Any SAL_CALL Stream::queryInterface( const uno::Type& aType )
688 {
689 uno::Any aRet = StreamUNOBase::queryInterface( aType );
690
691 if ( aRet.hasValue() )
692 return aRet;
693
694 if ( m_xAggProxy.is() )
695 return m_xAggProxy->queryAggregation( aType );
696 else
697 return uno::Any();
698 }
699
700
701 // lang::XTypeProvider
702
703
704 // virtual
705 uno::Sequence< uno::Type > SAL_CALL Stream::getTypes()
706 {
707 return m_xWrappedTypeProv->getTypes();
708 }
709
710
711 // virtual
712 uno::Sequence< sal_Int8 > SAL_CALL Stream::getImplementationId()
713 {
714 return css::uno::Sequence<sal_Int8>();
715 }
716
717
718 // io::XStream.
719
720
721 // virtual
722 uno::Reference< io::XInputStream > SAL_CALL Stream::getInputStream()
723 {
724 return uno::Reference< io::XInputStream >( this );
725 }
726
727
728 // virtual
729 uno::Reference< io::XOutputStream > SAL_CALL Stream::getOutputStream()
730 {
731 return uno::Reference< io::XOutputStream >( this );
732 }
733
734
735 // io::XOutputStream.
736
737
738 // virtual
739 void SAL_CALL Stream::writeBytes( const uno::Sequence< sal_Int8 >& aData )
740 {
741 if ( m_xWrappedOutputStream.is() )
742 {
743 m_xWrappedOutputStream->writeBytes( aData );
744 commitChanges();
745 }
746 }
747
748
749 // virtual
750 void SAL_CALL Stream::flush()
751 {
752 if ( m_xWrappedOutputStream.is() )
753 {
754 m_xWrappedOutputStream->flush();
755 commitChanges();
756 }
757 }
758
759
760 // virtual
761 void SAL_CALL Stream::closeOutput()
762 {
763 if ( m_xWrappedOutputStream.is() )
764 {
765 m_xWrappedOutputStream->closeOutput();
766 commitChanges();
767 }
768
769 // Release parent storage.
770 // Now, that the stream is closed/disposed it is not needed any longer.
771 clearParentStorage();
772 }
773
774
775 // io::XTruncate.
776
777
778 // virtual
779 void SAL_CALL Stream::truncate()
780 {
781 if ( m_xWrappedTruncate.is() )
782 {
783 m_xWrappedTruncate->truncate();
784 commitChanges();
785 }
786 }
787
788
789 // io::XInputStream.
790
791
792 // virtual
793 sal_Int32 SAL_CALL Stream::readBytes( uno::Sequence< sal_Int8 >& aData,
794 sal_Int32 nBytesToRead )
795 {
796 return m_xWrappedInputStream->readBytes( aData, nBytesToRead );
797 }
798
799
800 // virtual
801 sal_Int32 SAL_CALL Stream::readSomeBytes( uno::Sequence< sal_Int8 >& aData,
802 sal_Int32 nMaxBytesToRead )
803 {
804 return m_xWrappedInputStream->readSomeBytes( aData, nMaxBytesToRead );
805 }
806
807
808 // virtual
809 void SAL_CALL Stream::skipBytes( sal_Int32 nBytesToSkip )
810 {
811 m_xWrappedInputStream->skipBytes( nBytesToSkip );
812 }
813
814
815 // virtual
816 sal_Int32 SAL_CALL Stream::available()
817 {
818 return m_xWrappedInputStream->available();
819 }
820
821
822 // virtual
823 void SAL_CALL Stream::closeInput()
824 {
825 m_xWrappedInputStream->closeInput();
826 }
827
828
829 // lang::XComponent
830
831
832 // virtual
833 void SAL_CALL Stream::dispose()
834 {
835 m_xWrappedComponent->dispose();
836
837 // Release parent storage.
838 // Now, that the stream is closed/disposed it is not needed any longer.
839 clearParentStorage();
840 }
841
842
843 // virtual
844 void SAL_CALL Stream::addEventListener(
845 const uno::Reference< lang::XEventListener >& xListener )
846 {
847 m_xWrappedComponent->addEventListener( xListener );
848 }
849
850
851 // virtual
852 void SAL_CALL Stream::removeEventListener(
853 const uno::Reference< lang::XEventListener >& aListener )
854 {
855 m_xWrappedComponent->removeEventListener( aListener );
856 }
857
858
859 // Non-UNO
860
861
862 void Stream::commitChanges()
863 {
864 uno::Reference< embed::XTransactedObject >
865 xParentTA( getParentStorage(), uno::UNO_QUERY );
866 OSL_ENSURE( xParentTA.is(), "No XTransactedObject interface!" );
867
868 if ( xParentTA.is() )
869 {
870 try
871 {
872 xParentTA->commit();
873 }
874 catch ( lang::WrappedTargetException const & )
875 {
876 throw io::IOException(); // @@@
877 }
878 }
879 m_docsMgr->updateStreamDateModified(m_uri);
880 }
881
882 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */