update dev300-m58
[ooovba.git] / sot / source / unoolestorage / xolesimplestorage.cxx
blobaa8043f641928d7d085437e7b28b5f27f19e5e5b
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: xolesimplestorage.cxx,v $
10 * $Revision: 1.11 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sot.hxx"
33 #include <com/sun/star/lang/DisposedException.hpp>
34 #include <com/sun/star/io/XStream.hpp>
35 #include <com/sun/star/io/XInputStream.hpp>
36 #include <com/sun/star/io/XSeekable.hpp>
37 #include <com/sun/star/io/XTruncate.hpp>
39 #include <comphelper/storagehelper.hxx>
41 #include <unotools/ucbstreamhelper.hxx>
43 #include <cppuhelper/exc_hlp.hxx>
45 #include <storinfo.hxx>
47 #include "xolesimplestorage.hxx"
50 using namespace ::com::sun::star;
52 const sal_Int32 nBytesCount = 32000;
55 // --------------------------------------------------------------------------------
56 OLESimpleStorage::OLESimpleStorage( uno::Reference< lang::XMultiServiceFactory > xFactory )
57 : m_bDisposed( sal_False )
58 , m_pStream( NULL )
59 , m_pStorage( NULL )
60 , m_pListenersContainer( NULL )
61 , m_xFactory( xFactory )
62 , m_bNoTemporaryCopy( sal_False )
64 OSL_ENSURE( m_xFactory.is(), "No factory is provided on creation!\n" );
65 if ( !m_xFactory.is() )
66 throw uno::RuntimeException();
69 // --------------------------------------------------------------------------------
70 OLESimpleStorage::~OLESimpleStorage()
72 try {
73 m_refCount++;
74 dispose();
75 } catch( uno::Exception& )
78 if ( m_pListenersContainer )
80 delete m_pListenersContainer;
81 m_pListenersContainer = NULL;
85 //-------------------------------------------------------------------------
86 uno::Sequence< ::rtl::OUString > SAL_CALL OLESimpleStorage::impl_staticGetSupportedServiceNames()
88 uno::Sequence< ::rtl::OUString > aRet(1);
89 aRet[0] = ::rtl::OUString::createFromAscii("com.sun.star.embed.OLESimpleStorage");
90 return aRet;
93 //-------------------------------------------------------------------------
94 ::rtl::OUString SAL_CALL OLESimpleStorage::impl_staticGetImplementationName()
96 return ::rtl::OUString::createFromAscii("com.sun.star.comp.embed.OLESimpleStorage");
99 //-------------------------------------------------------------------------
100 uno::Reference< uno::XInterface > SAL_CALL OLESimpleStorage::impl_staticCreateSelfInstance(
101 const uno::Reference< lang::XMultiServiceFactory >& xServiceManager )
103 return uno::Reference< uno::XInterface >( *new OLESimpleStorage( xServiceManager ) );
106 //-------------------------------------------------------------------------
107 void OLESimpleStorage::UpdateOriginal_Impl()
109 if ( !m_bNoTemporaryCopy )
111 uno::Reference< io::XSeekable > xSeek( m_xStream, uno::UNO_QUERY_THROW );
112 xSeek->seek( 0 );
114 uno::Reference< io::XSeekable > xTempSeek( m_xTempStream, uno::UNO_QUERY_THROW );
115 sal_Int64 nPos = xTempSeek->getPosition();
116 xTempSeek->seek( 0 );
118 uno::Reference< io::XInputStream > xTempInp = m_xTempStream->getInputStream();
119 uno::Reference< io::XOutputStream > xOutputStream = m_xStream->getOutputStream();
120 if ( !xTempInp.is() || !xOutputStream.is() )
121 throw uno::RuntimeException();
123 uno::Reference< io::XTruncate > xTrunc( xOutputStream, uno::UNO_QUERY_THROW );
124 xTrunc->truncate();
126 ::comphelper::OStorageHelper::CopyInputToOutput( xTempInp, xOutputStream );
127 xOutputStream->flush();
128 xTempSeek->seek( nPos );
132 //-------------------------------------------------------------------------
133 void OLESimpleStorage::InsertInputStreamToStorage_Impl( BaseStorage* pStorage, ::rtl::OUString aName, const uno::Reference< io::XInputStream >& xInputStream )
134 throw ( uno::Exception )
136 if ( !pStorage || !aName.getLength() || !xInputStream.is() )
137 throw uno::RuntimeException();
139 if ( pStorage->IsContained( aName ) )
140 throw container::ElementExistException(); // TODO:
142 BaseStorageStream* pNewStream = pStorage->OpenStream( aName );
143 if ( !pNewStream || pNewStream->GetError() || pStorage->GetError() )
145 if ( pNewStream )
146 DELETEZ( pNewStream );
147 pStorage->ResetError();
148 throw io::IOException(); // TODO
153 uno::Sequence< sal_Int8 > aData( nBytesCount );
154 sal_Int32 nRead = 0;
157 nRead = xInputStream->readBytes( aData, nBytesCount );
158 if ( nRead < nBytesCount )
159 aData.realloc( nRead );
161 sal_Int32 nWritten = pNewStream->Write( aData.getArray(), nRead );
162 if ( nWritten < nRead )
163 throw io::IOException();
164 } while( nRead == nBytesCount );
166 catch( uno::Exception& )
168 DELETEZ( pNewStream );
169 pStorage->Remove( aName );
171 throw;
174 DELETEZ( pNewStream );
177 //-------------------------------------------------------------------------
178 void OLESimpleStorage::InsertNameAccessToStorage_Impl( BaseStorage* pStorage, ::rtl::OUString aName, const uno::Reference< container::XNameAccess >& xNameAccess )
179 throw ( uno::Exception )
181 if ( !pStorage || !aName.getLength() || !xNameAccess.is() )
182 throw uno::RuntimeException();
184 if ( pStorage->IsContained( aName ) )
185 throw container::ElementExistException(); // TODO:
187 BaseStorage* pNewStorage = pStorage->OpenStorage( aName );
188 if ( !pNewStorage || pNewStorage->GetError() || pStorage->GetError() )
190 if ( pNewStorage )
191 DELETEZ( pNewStorage );
192 pStorage->ResetError();
193 throw io::IOException(); // TODO
198 uno::Sequence< ::rtl::OUString > aElements = xNameAccess->getElementNames();
199 for ( sal_Int32 nInd = 0; nInd < aElements.getLength(); nInd++ )
201 uno::Reference< io::XInputStream > xInputStream;
202 uno::Reference< container::XNameAccess > xSubNameAccess;
203 uno::Any aAny = xNameAccess->getByName( aElements[nInd] );
204 if ( aAny >>= xInputStream )
205 InsertInputStreamToStorage_Impl( pNewStorage, aName, xInputStream );
206 else if ( aAny >>= xSubNameAccess )
207 InsertNameAccessToStorage_Impl( pNewStorage, aName, xSubNameAccess );
210 catch( uno::Exception& )
212 DELETEZ( pNewStorage );
213 pStorage->Remove( aName );
215 throw;
218 DELETEZ( pNewStorage );
221 //____________________________________________________________________________________________________
222 // XInitialization
223 //____________________________________________________________________________________________________
225 void SAL_CALL OLESimpleStorage::initialize( const uno::Sequence< uno::Any >& aArguments )
226 throw ( uno::Exception,
227 uno::RuntimeException)
229 if ( m_pStream || m_pStorage )
230 throw io::IOException(); // TODO: already initilized
232 sal_Int32 nArgNum = aArguments.getLength();
233 OSL_ENSURE( nArgNum >= 1 && nArgNum <= 2, "Wrong parameter number" );
235 if ( nArgNum < 1 || nArgNum > 2 )
236 throw lang::IllegalArgumentException(); // TODO:
238 uno::Reference< io::XStream > xStream;
239 uno::Reference< io::XInputStream > xInputStream;
240 if ( !( aArguments[0] >>= xStream ) && !( aArguments[0] >>= xInputStream ) )
241 throw lang::IllegalArgumentException(); // TODO:
243 if ( nArgNum == 2 )
245 if ( !( aArguments[1] >>= m_bNoTemporaryCopy ) )
246 throw lang::IllegalArgumentException(); // TODO:
249 if ( m_bNoTemporaryCopy )
251 // TODO: ???
252 // If the temporary stream is not created, the original stream must be wrapped
253 // since SvStream wrapper closes the stream is owns
254 if ( xInputStream.is() )
256 // the stream must be seekable for direct access
257 uno::Reference< io::XSeekable > xSeek( xInputStream, uno::UNO_QUERY_THROW );
258 m_pStream = ::utl::UcbStreamHelper::CreateStream( xInputStream, sal_False );
260 else if ( xStream.is() )
262 // the stream must be seekable for direct access
263 uno::Reference< io::XSeekable > xSeek( xStream, uno::UNO_QUERY_THROW );
264 m_pStream = ::utl::UcbStreamHelper::CreateStream( xStream, sal_False );
266 else
267 throw lang::IllegalArgumentException(); // TODO:
269 else
271 uno::Reference < io::XStream > xTempFile(
272 m_xFactory->createInstance( ::rtl::OUString::createFromAscii( "com.sun.star.io.TempFile" ) ),
273 uno::UNO_QUERY_THROW );
274 uno::Reference < io::XSeekable > xTempSeek( xTempFile, uno::UNO_QUERY_THROW );
275 uno::Reference< io::XOutputStream > xTempOut = xTempFile->getOutputStream();
276 if ( !xTempOut.is() )
277 throw uno::RuntimeException();
279 if ( xInputStream.is() )
283 uno::Reference< io::XSeekable > xSeek( xInputStream, uno::UNO_QUERY_THROW );
284 xSeek->seek( 0 );
286 catch( uno::Exception& )
289 ::comphelper::OStorageHelper::CopyInputToOutput( xInputStream, xTempOut );
290 xTempOut->closeOutput();
291 xTempSeek->seek( 0 );
292 uno::Reference< io::XInputStream > xTempInput = xTempFile->getInputStream();
293 m_pStream = ::utl::UcbStreamHelper::CreateStream( xTempInput, sal_False );
295 else if ( xStream.is() )
297 // not sure that the storage flashes the stream on commit
298 m_xStream = xStream;
299 m_xTempStream = xTempFile;
301 uno::Reference< io::XSeekable > xSeek( xStream, uno::UNO_QUERY_THROW );
302 xSeek->seek( 0 );
303 uno::Reference< io::XInputStream > xInpStream = xStream->getInputStream();
304 if ( !xInpStream.is() || !xStream->getOutputStream().is() )
305 throw uno::RuntimeException();
307 ::comphelper::OStorageHelper::CopyInputToOutput( xInpStream, xTempOut );
308 xTempOut->flush();
309 xTempSeek->seek( 0 );
311 m_pStream = ::utl::UcbStreamHelper::CreateStream( xTempFile, sal_False );
313 else
314 throw lang::IllegalArgumentException(); // TODO:
317 if ( !m_pStream || m_pStream->GetError() )
318 throw io::IOException(); // TODO
320 m_pStorage = new Storage( *m_pStream, sal_False );
324 //____________________________________________________________________________________________________
325 // XNameContainer
326 //____________________________________________________________________________________________________
328 // --------------------------------------------------------------------------------
329 void SAL_CALL OLESimpleStorage::insertByName( const ::rtl::OUString& aName, const uno::Any& aElement )
330 throw ( lang::IllegalArgumentException,
331 container::ElementExistException,
332 lang::WrappedTargetException,
333 uno::RuntimeException)
335 ::osl::MutexGuard aGuard( m_aMutex );
337 if ( m_bDisposed )
338 throw lang::DisposedException();
340 if ( !m_pStorage )
341 throw uno::RuntimeException();
343 uno::Reference< io::XStream > xStream;
344 uno::Reference< io::XInputStream > xInputStream;
345 uno::Reference< container::XNameAccess > xNameAccess;
349 if ( !m_bNoTemporaryCopy && !m_xStream.is() )
350 throw io::IOException(); // TODO
352 if ( aElement >>= xStream )
353 xInputStream = xStream->getInputStream();
354 else if ( !( aElement >>= xInputStream ) && !( aElement >>= xNameAccess ) )
355 throw lang::IllegalArgumentException(); // TODO:
357 if ( xInputStream.is() )
358 InsertInputStreamToStorage_Impl( m_pStorage, aName, xInputStream );
359 else if ( xNameAccess.is() )
360 InsertNameAccessToStorage_Impl( m_pStorage, aName, xNameAccess );
361 else
362 throw uno::RuntimeException();
364 catch( uno::RuntimeException& )
366 throw;
368 catch( container::ElementExistException& )
370 throw;
372 catch( uno::Exception& e )
374 throw lang::WrappedTargetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Insert has failed!" ) ),
375 uno::Reference< uno::XInterface >(),
376 uno::makeAny( e ) );
380 // --------------------------------------------------------------------------------
381 void SAL_CALL OLESimpleStorage::removeByName( const ::rtl::OUString& aName )
382 throw ( container::NoSuchElementException,
383 lang::WrappedTargetException,
384 uno::RuntimeException)
386 ::osl::MutexGuard aGuard( m_aMutex );
388 if ( m_bDisposed )
389 throw lang::DisposedException();
391 if ( !m_pStorage )
392 throw uno::RuntimeException();
394 if ( !m_bNoTemporaryCopy && !m_xStream.is() )
395 throw lang::WrappedTargetException(); // io::IOException(); // TODO
397 if ( !m_pStorage->IsContained( aName ) )
398 throw container::NoSuchElementException(); // TODO:
400 m_pStorage->Remove( aName );
402 if ( m_pStorage->GetError() )
404 m_pStorage->ResetError();
405 throw lang::WrappedTargetException(); // io::IOException(); // TODO
409 // --------------------------------------------------------------------------------
410 void SAL_CALL OLESimpleStorage::replaceByName( const ::rtl::OUString& aName, const uno::Any& aElement )
411 throw ( lang::IllegalArgumentException,
412 container::NoSuchElementException,
413 lang::WrappedTargetException,
414 uno::RuntimeException)
416 ::osl::MutexGuard aGuard( m_aMutex );
418 if ( m_bDisposed )
419 throw lang::DisposedException();
421 removeByName( aName );
425 insertByName( aName, aElement );
427 catch( container::ElementExistException& )
429 uno::Any aCaught( ::cppu::getCaughtException() );
431 throw lang::WrappedTargetException( ::rtl::OUString::createFromAscii( "Can't copy raw stream" ),
432 uno::Reference< uno::XInterface >(),
433 aCaught );
437 // --------------------------------------------------------------------------------
438 uno::Any SAL_CALL OLESimpleStorage::getByName( const ::rtl::OUString& aName )
439 throw ( container::NoSuchElementException,
440 lang::WrappedTargetException,
441 uno::RuntimeException )
443 ::osl::MutexGuard aGuard( m_aMutex );
445 if ( m_bDisposed )
446 throw lang::DisposedException();
448 if ( !m_pStorage )
449 throw uno::RuntimeException();
451 if ( !m_pStorage->IsContained( aName ) )
452 throw container::NoSuchElementException(); // TODO:
454 uno::Any aResult;
456 uno::Reference< io::XStream > xTempFile(
457 m_xFactory->createInstance( ::rtl::OUString::createFromAscii( "com.sun.star.io.TempFile" ) ),
458 uno::UNO_QUERY );
459 uno::Reference< io::XSeekable > xSeekable( xTempFile, uno::UNO_QUERY_THROW );
460 uno::Reference< io::XOutputStream > xOutputStream = xTempFile->getOutputStream();
461 uno::Reference< io::XInputStream > xInputStream = xTempFile->getInputStream();
462 if ( !xOutputStream.is() || !xInputStream.is() )
463 throw uno::RuntimeException();
465 if ( m_pStorage->IsStorage( aName ) )
467 BaseStorage* pStrg = m_pStorage->OpenStorage( aName );
468 m_pStorage->ResetError();
469 if ( !pStrg )
470 throw io::IOException();
472 SvStream* pStream = ::utl::UcbStreamHelper::CreateStream( xTempFile, sal_False ); // do not close the original stream
473 if ( !pStream )
474 throw uno::RuntimeException();
476 BaseStorage* pNewStor = new Storage( *pStream, sal_False );
477 sal_Bool bSuccess =
478 ( pStrg->CopyTo( pNewStor ) && pNewStor->Commit() && !pNewStor->GetError() && !pStrg->GetError() );
480 DELETEZ( pNewStor );
481 DELETEZ( pStrg );
482 DELETEZ( pStream );
484 if ( !bSuccess )
485 throw uno::RuntimeException();
487 uno::Sequence< uno::Any > aArgs( 2 );
488 aArgs[0] <<= xInputStream; // allow readonly access only
489 aArgs[1] <<= (sal_Bool)sal_True; // do not create copy
491 uno::Reference< container::XNameContainer > xResultNameContainer(
492 m_xFactory->createInstanceWithArguments(
493 ::rtl::OUString::createFromAscii( "com.sun.star.embed.OLESimpleStorage" ),
494 aArgs ),
495 uno::UNO_QUERY_THROW );
497 aResult <<= xResultNameContainer;
499 else
501 BaseStorageStream* pStream = m_pStorage->OpenStream( aName, STREAM_READ | STREAM_SHARE_DENYALL | STREAM_NOCREATE );
502 if ( !pStream || pStream->GetError() || m_pStorage->GetError() )
504 m_pStorage->ResetError();
505 DELETEZ( pStream );
506 throw io::IOException(); // TODO
511 uno::Sequence< sal_Int8 > aData( nBytesCount );
512 sal_Int32 nSize = nBytesCount;
513 sal_Int32 nRead = 0;
514 while( 0 != ( nRead = pStream->Read( aData.getArray(), nSize ) ) )
516 if ( nRead < nSize )
518 nSize = nRead;
519 aData.realloc( nSize );
522 xOutputStream->writeBytes( aData );
525 if ( pStream->GetError() )
526 throw io::IOException(); // TODO
528 xOutputStream->closeOutput();
529 xSeekable->seek( 0 );
531 catch( uno::RuntimeException& )
533 DELETEZ( pStream );
534 throw;
536 catch( uno::Exception& )
538 DELETEZ( pStream );
539 throw lang::WrappedTargetException(); // TODO:
542 DELETEZ( pStream );
544 aResult <<= xInputStream;
547 return aResult;
550 // --------------------------------------------------------------------------------
551 uno::Sequence< ::rtl::OUString > SAL_CALL OLESimpleStorage::getElementNames()
552 throw ( uno::RuntimeException )
554 ::osl::MutexGuard aGuard( m_aMutex );
556 if ( m_bDisposed )
557 throw lang::DisposedException();
559 if ( !m_pStorage )
560 throw uno::RuntimeException();
562 SvStorageInfoList aList;
563 m_pStorage->FillInfoList( &aList );
565 if ( m_pStorage->GetError() )
567 m_pStorage->ResetError();
568 throw uno::RuntimeException(); // TODO:
571 uno::Sequence< ::rtl::OUString > aSeq( aList.Count() );
572 for ( sal_uInt32 nInd = 0; nInd < aList.Count(); nInd++ )
573 aSeq[nInd] = aList[nInd].GetName();
575 return aSeq;
578 // --------------------------------------------------------------------------------
579 sal_Bool SAL_CALL OLESimpleStorage::hasByName( const ::rtl::OUString& aName )
580 throw ( uno::RuntimeException )
582 ::osl::MutexGuard aGuard( m_aMutex );
584 if ( m_bDisposed )
585 throw lang::DisposedException();
587 if ( !m_pStorage )
588 throw uno::RuntimeException();
590 sal_Bool bResult = m_pStorage->IsContained( aName );
592 if ( m_pStorage->GetError() )
594 m_pStorage->ResetError();
595 throw uno::RuntimeException(); // TODO:
598 return bResult;
601 // --------------------------------------------------------------------------------
602 uno::Type SAL_CALL OLESimpleStorage::getElementType()
603 throw ( uno::RuntimeException )
605 ::osl::MutexGuard aGuard( m_aMutex );
607 if ( m_bDisposed )
608 throw lang::DisposedException();
610 return getCppuType( (const uno::Reference< io::XInputStream >*)NULL );
613 // --------------------------------------------------------------------------------
614 sal_Bool SAL_CALL OLESimpleStorage::hasElements()
615 throw ( uno::RuntimeException )
617 ::osl::MutexGuard aGuard( m_aMutex );
619 if ( m_bDisposed )
620 throw lang::DisposedException();
622 if ( !m_pStorage )
623 throw uno::RuntimeException();
625 SvStorageInfoList aList;
626 m_pStorage->FillInfoList( &aList );
628 if ( m_pStorage->GetError() )
630 m_pStorage->ResetError();
631 throw uno::RuntimeException(); // TODO:
634 return ( aList.Count() != 0 );
637 //____________________________________________________________________________________________________
638 // XComponent
639 //____________________________________________________________________________________________________
641 // --------------------------------------------------------------------------------
642 void SAL_CALL OLESimpleStorage::dispose()
643 throw ( uno::RuntimeException )
645 ::osl::MutexGuard aGuard( m_aMutex );
647 if ( m_bDisposed )
648 throw lang::DisposedException();
650 if ( m_pListenersContainer )
652 lang::EventObject aSource( static_cast< ::cppu::OWeakObject* >(this) );
653 m_pListenersContainer->disposeAndClear( aSource );
656 DELETEZ( m_pStorage );
657 DELETEZ( m_pStream );
659 m_xStream = uno::Reference< io::XStream >();
660 m_xTempStream = uno::Reference< io::XStream >();
662 m_bDisposed = sal_True;
665 // --------------------------------------------------------------------------------
666 void SAL_CALL OLESimpleStorage::addEventListener(
667 const uno::Reference< lang::XEventListener >& xListener )
668 throw ( uno::RuntimeException )
670 ::osl::MutexGuard aGuard( m_aMutex );
672 if ( m_bDisposed )
673 throw lang::DisposedException();
675 if ( !m_pListenersContainer )
676 m_pListenersContainer = new ::cppu::OInterfaceContainerHelper( m_aMutex );
678 m_pListenersContainer->addInterface( xListener );
681 // --------------------------------------------------------------------------------
682 void SAL_CALL OLESimpleStorage::removeEventListener(
683 const uno::Reference< lang::XEventListener >& xListener )
684 throw ( uno::RuntimeException )
686 ::osl::MutexGuard aGuard( m_aMutex );
688 if ( m_bDisposed )
689 throw lang::DisposedException();
691 if ( m_pListenersContainer )
692 m_pListenersContainer->removeInterface( xListener );
695 //____________________________________________________________________________________________________
696 // XTransactedObject
697 //____________________________________________________________________________________________________
699 // --------------------------------------------------------------------------------
700 void SAL_CALL OLESimpleStorage::commit()
701 throw ( ::com::sun::star::io::IOException,
702 ::com::sun::star::lang::WrappedTargetException,
703 ::com::sun::star::uno::RuntimeException )
705 ::osl::MutexGuard aGuard( m_aMutex );
707 if ( m_bDisposed )
708 throw lang::DisposedException();
710 if ( !m_pStorage )
711 throw uno::RuntimeException();
713 if ( !m_bNoTemporaryCopy && !m_xStream.is() )
714 throw io::IOException(); // TODO
716 if ( !m_pStorage->Commit() || m_pStorage->GetError() )
718 m_pStorage->ResetError();
719 throw io::IOException(); // TODO
722 UpdateOriginal_Impl();
725 // --------------------------------------------------------------------------------
726 void SAL_CALL OLESimpleStorage::revert()
727 throw ( ::com::sun::star::io::IOException,
728 ::com::sun::star::lang::WrappedTargetException,
729 ::com::sun::star::uno::RuntimeException )
731 ::osl::MutexGuard aGuard( m_aMutex );
733 if ( m_bDisposed )
734 throw lang::DisposedException();
736 if ( !m_pStorage )
737 throw uno::RuntimeException();
739 if ( !m_bNoTemporaryCopy && !m_xStream.is() )
740 throw io::IOException(); // TODO
742 if ( !m_pStorage->Revert() || m_pStorage->GetError() )
744 m_pStorage->ResetError();
745 throw io::IOException(); // TODO
748 UpdateOriginal_Impl();
751 //____________________________________________________________________________________________________
752 // XClassifiedObject
753 //____________________________________________________________________________________________________
755 uno::Sequence< sal_Int8 > SAL_CALL OLESimpleStorage::getClassID()
756 throw ( uno::RuntimeException )
758 ::osl::MutexGuard aGuard( m_aMutex );
760 if ( m_bDisposed )
761 throw lang::DisposedException();
763 if ( !m_pStorage )
764 throw uno::RuntimeException();
766 return m_pStorage->GetClassName().GetByteSequence();
769 ::rtl::OUString SAL_CALL OLESimpleStorage::getClassName()
770 throw ( uno::RuntimeException )
772 return ::rtl::OUString();
775 void SAL_CALL OLESimpleStorage::setClassInfo( const uno::Sequence< sal_Int8 >& /*aClassID*/,
776 const ::rtl::OUString& /*sClassName*/ )
777 throw ( lang::NoSupportException,
778 uno::RuntimeException )
780 throw lang::NoSupportException();
783 //____________________________________________________________________________________________________
784 // XServiceInfo
785 //____________________________________________________________________________________________________
787 // --------------------------------------------------------------------------------
788 ::rtl::OUString SAL_CALL OLESimpleStorage::getImplementationName()
789 throw ( uno::RuntimeException )
791 return impl_staticGetImplementationName();
794 // --------------------------------------------------------------------------------
795 ::sal_Bool SAL_CALL OLESimpleStorage::supportsService( const ::rtl::OUString& ServiceName )
796 throw ( uno::RuntimeException )
798 uno::Sequence< ::rtl::OUString > aSeq = impl_staticGetSupportedServiceNames();
800 for ( sal_Int32 nInd = 0; nInd < aSeq.getLength(); nInd++ )
801 if ( ServiceName.compareTo( aSeq[nInd] ) == 0 )
802 return sal_True;
804 return sal_False;
807 // --------------------------------------------------------------------------------
808 uno::Sequence< ::rtl::OUString > SAL_CALL OLESimpleStorage::getSupportedServiceNames()
809 throw ( uno::RuntimeException )
811 return impl_staticGetSupportedServiceNames();