1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_sot.hxx" 30*cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp> 31*cdf0e10cSrcweir #include <com/sun/star/io/XStream.hpp> 32*cdf0e10cSrcweir #include <com/sun/star/io/XInputStream.hpp> 33*cdf0e10cSrcweir #include <com/sun/star/io/XSeekable.hpp> 34*cdf0e10cSrcweir #include <com/sun/star/io/XTruncate.hpp> 35*cdf0e10cSrcweir 36*cdf0e10cSrcweir #include <comphelper/storagehelper.hxx> 37*cdf0e10cSrcweir 38*cdf0e10cSrcweir #include <unotools/ucbstreamhelper.hxx> 39*cdf0e10cSrcweir 40*cdf0e10cSrcweir #include <cppuhelper/exc_hlp.hxx> 41*cdf0e10cSrcweir 42*cdf0e10cSrcweir #include <sot/storinfo.hxx> 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir #include "xolesimplestorage.hxx" 45*cdf0e10cSrcweir 46*cdf0e10cSrcweir 47*cdf0e10cSrcweir using namespace ::com::sun::star; 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir const sal_Int32 nBytesCount = 32000; 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir // -------------------------------------------------------------------------------- 53*cdf0e10cSrcweir OLESimpleStorage::OLESimpleStorage( uno::Reference< lang::XMultiServiceFactory > xFactory ) 54*cdf0e10cSrcweir : m_bDisposed( sal_False ) 55*cdf0e10cSrcweir , m_pStream( NULL ) 56*cdf0e10cSrcweir , m_pStorage( NULL ) 57*cdf0e10cSrcweir , m_pListenersContainer( NULL ) 58*cdf0e10cSrcweir , m_xFactory( xFactory ) 59*cdf0e10cSrcweir , m_bNoTemporaryCopy( sal_False ) 60*cdf0e10cSrcweir { 61*cdf0e10cSrcweir OSL_ENSURE( m_xFactory.is(), "No factory is provided on creation!\n" ); 62*cdf0e10cSrcweir if ( !m_xFactory.is() ) 63*cdf0e10cSrcweir throw uno::RuntimeException(); 64*cdf0e10cSrcweir } 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir // -------------------------------------------------------------------------------- 67*cdf0e10cSrcweir OLESimpleStorage::~OLESimpleStorage() 68*cdf0e10cSrcweir { 69*cdf0e10cSrcweir try { 70*cdf0e10cSrcweir m_refCount++; 71*cdf0e10cSrcweir dispose(); 72*cdf0e10cSrcweir } catch( uno::Exception& ) 73*cdf0e10cSrcweir {} 74*cdf0e10cSrcweir 75*cdf0e10cSrcweir if ( m_pListenersContainer ) 76*cdf0e10cSrcweir { 77*cdf0e10cSrcweir delete m_pListenersContainer; 78*cdf0e10cSrcweir m_pListenersContainer = NULL; 79*cdf0e10cSrcweir } 80*cdf0e10cSrcweir } 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir //------------------------------------------------------------------------- 83*cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > SAL_CALL OLESimpleStorage::impl_staticGetSupportedServiceNames() 84*cdf0e10cSrcweir { 85*cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > aRet(1); 86*cdf0e10cSrcweir aRet[0] = ::rtl::OUString::createFromAscii("com.sun.star.embed.OLESimpleStorage"); 87*cdf0e10cSrcweir return aRet; 88*cdf0e10cSrcweir } 89*cdf0e10cSrcweir 90*cdf0e10cSrcweir //------------------------------------------------------------------------- 91*cdf0e10cSrcweir ::rtl::OUString SAL_CALL OLESimpleStorage::impl_staticGetImplementationName() 92*cdf0e10cSrcweir { 93*cdf0e10cSrcweir return ::rtl::OUString::createFromAscii("com.sun.star.comp.embed.OLESimpleStorage"); 94*cdf0e10cSrcweir } 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir //------------------------------------------------------------------------- 97*cdf0e10cSrcweir uno::Reference< uno::XInterface > SAL_CALL OLESimpleStorage::impl_staticCreateSelfInstance( 98*cdf0e10cSrcweir const uno::Reference< lang::XMultiServiceFactory >& xServiceManager ) 99*cdf0e10cSrcweir { 100*cdf0e10cSrcweir return uno::Reference< uno::XInterface >( *new OLESimpleStorage( xServiceManager ) ); 101*cdf0e10cSrcweir } 102*cdf0e10cSrcweir 103*cdf0e10cSrcweir //------------------------------------------------------------------------- 104*cdf0e10cSrcweir void OLESimpleStorage::UpdateOriginal_Impl() 105*cdf0e10cSrcweir { 106*cdf0e10cSrcweir if ( !m_bNoTemporaryCopy ) 107*cdf0e10cSrcweir { 108*cdf0e10cSrcweir uno::Reference< io::XSeekable > xSeek( m_xStream, uno::UNO_QUERY_THROW ); 109*cdf0e10cSrcweir xSeek->seek( 0 ); 110*cdf0e10cSrcweir 111*cdf0e10cSrcweir uno::Reference< io::XSeekable > xTempSeek( m_xTempStream, uno::UNO_QUERY_THROW ); 112*cdf0e10cSrcweir sal_Int64 nPos = xTempSeek->getPosition(); 113*cdf0e10cSrcweir xTempSeek->seek( 0 ); 114*cdf0e10cSrcweir 115*cdf0e10cSrcweir uno::Reference< io::XInputStream > xTempInp = m_xTempStream->getInputStream(); 116*cdf0e10cSrcweir uno::Reference< io::XOutputStream > xOutputStream = m_xStream->getOutputStream(); 117*cdf0e10cSrcweir if ( !xTempInp.is() || !xOutputStream.is() ) 118*cdf0e10cSrcweir throw uno::RuntimeException(); 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir uno::Reference< io::XTruncate > xTrunc( xOutputStream, uno::UNO_QUERY_THROW ); 121*cdf0e10cSrcweir xTrunc->truncate(); 122*cdf0e10cSrcweir 123*cdf0e10cSrcweir ::comphelper::OStorageHelper::CopyInputToOutput( xTempInp, xOutputStream ); 124*cdf0e10cSrcweir xOutputStream->flush(); 125*cdf0e10cSrcweir xTempSeek->seek( nPos ); 126*cdf0e10cSrcweir } 127*cdf0e10cSrcweir } 128*cdf0e10cSrcweir 129*cdf0e10cSrcweir //------------------------------------------------------------------------- 130*cdf0e10cSrcweir void OLESimpleStorage::InsertInputStreamToStorage_Impl( BaseStorage* pStorage, ::rtl::OUString aName, const uno::Reference< io::XInputStream >& xInputStream ) 131*cdf0e10cSrcweir throw ( uno::Exception ) 132*cdf0e10cSrcweir { 133*cdf0e10cSrcweir if ( !pStorage || !aName.getLength() || !xInputStream.is() ) 134*cdf0e10cSrcweir throw uno::RuntimeException(); 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir if ( pStorage->IsContained( aName ) ) 137*cdf0e10cSrcweir throw container::ElementExistException(); // TODO: 138*cdf0e10cSrcweir 139*cdf0e10cSrcweir BaseStorageStream* pNewStream = pStorage->OpenStream( aName ); 140*cdf0e10cSrcweir if ( !pNewStream || pNewStream->GetError() || pStorage->GetError() ) 141*cdf0e10cSrcweir { 142*cdf0e10cSrcweir if ( pNewStream ) 143*cdf0e10cSrcweir DELETEZ( pNewStream ); 144*cdf0e10cSrcweir pStorage->ResetError(); 145*cdf0e10cSrcweir throw io::IOException(); // TODO 146*cdf0e10cSrcweir } 147*cdf0e10cSrcweir 148*cdf0e10cSrcweir try 149*cdf0e10cSrcweir { 150*cdf0e10cSrcweir uno::Sequence< sal_Int8 > aData( nBytesCount ); 151*cdf0e10cSrcweir sal_Int32 nRead = 0; 152*cdf0e10cSrcweir do 153*cdf0e10cSrcweir { 154*cdf0e10cSrcweir nRead = xInputStream->readBytes( aData, nBytesCount ); 155*cdf0e10cSrcweir if ( nRead < nBytesCount ) 156*cdf0e10cSrcweir aData.realloc( nRead ); 157*cdf0e10cSrcweir 158*cdf0e10cSrcweir sal_Int32 nWritten = pNewStream->Write( aData.getArray(), nRead ); 159*cdf0e10cSrcweir if ( nWritten < nRead ) 160*cdf0e10cSrcweir throw io::IOException(); 161*cdf0e10cSrcweir } while( nRead == nBytesCount ); 162*cdf0e10cSrcweir } 163*cdf0e10cSrcweir catch( uno::Exception& ) 164*cdf0e10cSrcweir { 165*cdf0e10cSrcweir DELETEZ( pNewStream ); 166*cdf0e10cSrcweir pStorage->Remove( aName ); 167*cdf0e10cSrcweir 168*cdf0e10cSrcweir throw; 169*cdf0e10cSrcweir } 170*cdf0e10cSrcweir 171*cdf0e10cSrcweir DELETEZ( pNewStream ); 172*cdf0e10cSrcweir } 173*cdf0e10cSrcweir 174*cdf0e10cSrcweir //------------------------------------------------------------------------- 175*cdf0e10cSrcweir void OLESimpleStorage::InsertNameAccessToStorage_Impl( BaseStorage* pStorage, ::rtl::OUString aName, const uno::Reference< container::XNameAccess >& xNameAccess ) 176*cdf0e10cSrcweir throw ( uno::Exception ) 177*cdf0e10cSrcweir { 178*cdf0e10cSrcweir if ( !pStorage || !aName.getLength() || !xNameAccess.is() ) 179*cdf0e10cSrcweir throw uno::RuntimeException(); 180*cdf0e10cSrcweir 181*cdf0e10cSrcweir if ( pStorage->IsContained( aName ) ) 182*cdf0e10cSrcweir throw container::ElementExistException(); // TODO: 183*cdf0e10cSrcweir 184*cdf0e10cSrcweir BaseStorage* pNewStorage = pStorage->OpenStorage( aName ); 185*cdf0e10cSrcweir if ( !pNewStorage || pNewStorage->GetError() || pStorage->GetError() ) 186*cdf0e10cSrcweir { 187*cdf0e10cSrcweir if ( pNewStorage ) 188*cdf0e10cSrcweir DELETEZ( pNewStorage ); 189*cdf0e10cSrcweir pStorage->ResetError(); 190*cdf0e10cSrcweir throw io::IOException(); // TODO 191*cdf0e10cSrcweir } 192*cdf0e10cSrcweir 193*cdf0e10cSrcweir try 194*cdf0e10cSrcweir { 195*cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > aElements = xNameAccess->getElementNames(); 196*cdf0e10cSrcweir for ( sal_Int32 nInd = 0; nInd < aElements.getLength(); nInd++ ) 197*cdf0e10cSrcweir { 198*cdf0e10cSrcweir uno::Reference< io::XInputStream > xInputStream; 199*cdf0e10cSrcweir uno::Reference< container::XNameAccess > xSubNameAccess; 200*cdf0e10cSrcweir uno::Any aAny = xNameAccess->getByName( aElements[nInd] ); 201*cdf0e10cSrcweir if ( aAny >>= xInputStream ) 202*cdf0e10cSrcweir InsertInputStreamToStorage_Impl( pNewStorage, aElements[nInd], xInputStream ); 203*cdf0e10cSrcweir else if ( aAny >>= xSubNameAccess ) 204*cdf0e10cSrcweir InsertNameAccessToStorage_Impl( pNewStorage, aElements[nInd], xSubNameAccess ); 205*cdf0e10cSrcweir } 206*cdf0e10cSrcweir } 207*cdf0e10cSrcweir catch( uno::Exception& ) 208*cdf0e10cSrcweir { 209*cdf0e10cSrcweir DELETEZ( pNewStorage ); 210*cdf0e10cSrcweir pStorage->Remove( aName ); 211*cdf0e10cSrcweir 212*cdf0e10cSrcweir throw; 213*cdf0e10cSrcweir } 214*cdf0e10cSrcweir 215*cdf0e10cSrcweir DELETEZ( pNewStorage ); 216*cdf0e10cSrcweir } 217*cdf0e10cSrcweir 218*cdf0e10cSrcweir //____________________________________________________________________________________________________ 219*cdf0e10cSrcweir // XInitialization 220*cdf0e10cSrcweir //____________________________________________________________________________________________________ 221*cdf0e10cSrcweir 222*cdf0e10cSrcweir void SAL_CALL OLESimpleStorage::initialize( const uno::Sequence< uno::Any >& aArguments ) 223*cdf0e10cSrcweir throw ( uno::Exception, 224*cdf0e10cSrcweir uno::RuntimeException) 225*cdf0e10cSrcweir { 226*cdf0e10cSrcweir if ( m_pStream || m_pStorage ) 227*cdf0e10cSrcweir throw io::IOException(); // TODO: already initilized 228*cdf0e10cSrcweir 229*cdf0e10cSrcweir sal_Int32 nArgNum = aArguments.getLength(); 230*cdf0e10cSrcweir OSL_ENSURE( nArgNum >= 1 && nArgNum <= 2, "Wrong parameter number" ); 231*cdf0e10cSrcweir 232*cdf0e10cSrcweir if ( nArgNum < 1 || nArgNum > 2 ) 233*cdf0e10cSrcweir throw lang::IllegalArgumentException(); // TODO: 234*cdf0e10cSrcweir 235*cdf0e10cSrcweir uno::Reference< io::XStream > xStream; 236*cdf0e10cSrcweir uno::Reference< io::XInputStream > xInputStream; 237*cdf0e10cSrcweir if ( !( aArguments[0] >>= xStream ) && !( aArguments[0] >>= xInputStream ) ) 238*cdf0e10cSrcweir throw lang::IllegalArgumentException(); // TODO: 239*cdf0e10cSrcweir 240*cdf0e10cSrcweir if ( nArgNum == 2 ) 241*cdf0e10cSrcweir { 242*cdf0e10cSrcweir if ( !( aArguments[1] >>= m_bNoTemporaryCopy ) ) 243*cdf0e10cSrcweir throw lang::IllegalArgumentException(); // TODO: 244*cdf0e10cSrcweir } 245*cdf0e10cSrcweir 246*cdf0e10cSrcweir if ( m_bNoTemporaryCopy ) 247*cdf0e10cSrcweir { 248*cdf0e10cSrcweir // TODO: ??? 249*cdf0e10cSrcweir // If the temporary stream is not created, the original stream must be wrapped 250*cdf0e10cSrcweir // since SvStream wrapper closes the stream is owns 251*cdf0e10cSrcweir if ( xInputStream.is() ) 252*cdf0e10cSrcweir { 253*cdf0e10cSrcweir // the stream must be seekable for direct access 254*cdf0e10cSrcweir uno::Reference< io::XSeekable > xSeek( xInputStream, uno::UNO_QUERY_THROW ); 255*cdf0e10cSrcweir m_pStream = ::utl::UcbStreamHelper::CreateStream( xInputStream, sal_False ); 256*cdf0e10cSrcweir } 257*cdf0e10cSrcweir else if ( xStream.is() ) 258*cdf0e10cSrcweir { 259*cdf0e10cSrcweir // the stream must be seekable for direct access 260*cdf0e10cSrcweir uno::Reference< io::XSeekable > xSeek( xStream, uno::UNO_QUERY_THROW ); 261*cdf0e10cSrcweir m_pStream = ::utl::UcbStreamHelper::CreateStream( xStream, sal_False ); 262*cdf0e10cSrcweir } 263*cdf0e10cSrcweir else 264*cdf0e10cSrcweir throw lang::IllegalArgumentException(); // TODO: 265*cdf0e10cSrcweir } 266*cdf0e10cSrcweir else 267*cdf0e10cSrcweir { 268*cdf0e10cSrcweir uno::Reference < io::XStream > xTempFile( 269*cdf0e10cSrcweir m_xFactory->createInstance( ::rtl::OUString::createFromAscii( "com.sun.star.io.TempFile" ) ), 270*cdf0e10cSrcweir uno::UNO_QUERY_THROW ); 271*cdf0e10cSrcweir uno::Reference < io::XSeekable > xTempSeek( xTempFile, uno::UNO_QUERY_THROW ); 272*cdf0e10cSrcweir uno::Reference< io::XOutputStream > xTempOut = xTempFile->getOutputStream(); 273*cdf0e10cSrcweir if ( !xTempOut.is() ) 274*cdf0e10cSrcweir throw uno::RuntimeException(); 275*cdf0e10cSrcweir 276*cdf0e10cSrcweir if ( xInputStream.is() ) 277*cdf0e10cSrcweir { 278*cdf0e10cSrcweir try 279*cdf0e10cSrcweir { 280*cdf0e10cSrcweir uno::Reference< io::XSeekable > xSeek( xInputStream, uno::UNO_QUERY_THROW ); 281*cdf0e10cSrcweir xSeek->seek( 0 ); 282*cdf0e10cSrcweir } 283*cdf0e10cSrcweir catch( uno::Exception& ) 284*cdf0e10cSrcweir {} 285*cdf0e10cSrcweir 286*cdf0e10cSrcweir ::comphelper::OStorageHelper::CopyInputToOutput( xInputStream, xTempOut ); 287*cdf0e10cSrcweir xTempOut->closeOutput(); 288*cdf0e10cSrcweir xTempSeek->seek( 0 ); 289*cdf0e10cSrcweir uno::Reference< io::XInputStream > xTempInput = xTempFile->getInputStream(); 290*cdf0e10cSrcweir m_pStream = ::utl::UcbStreamHelper::CreateStream( xTempInput, sal_False ); 291*cdf0e10cSrcweir } 292*cdf0e10cSrcweir else if ( xStream.is() ) 293*cdf0e10cSrcweir { 294*cdf0e10cSrcweir // not sure that the storage flashes the stream on commit 295*cdf0e10cSrcweir m_xStream = xStream; 296*cdf0e10cSrcweir m_xTempStream = xTempFile; 297*cdf0e10cSrcweir 298*cdf0e10cSrcweir uno::Reference< io::XSeekable > xSeek( xStream, uno::UNO_QUERY_THROW ); 299*cdf0e10cSrcweir xSeek->seek( 0 ); 300*cdf0e10cSrcweir uno::Reference< io::XInputStream > xInpStream = xStream->getInputStream(); 301*cdf0e10cSrcweir if ( !xInpStream.is() || !xStream->getOutputStream().is() ) 302*cdf0e10cSrcweir throw uno::RuntimeException(); 303*cdf0e10cSrcweir 304*cdf0e10cSrcweir ::comphelper::OStorageHelper::CopyInputToOutput( xInpStream, xTempOut ); 305*cdf0e10cSrcweir xTempOut->flush(); 306*cdf0e10cSrcweir xTempSeek->seek( 0 ); 307*cdf0e10cSrcweir 308*cdf0e10cSrcweir m_pStream = ::utl::UcbStreamHelper::CreateStream( xTempFile, sal_False ); 309*cdf0e10cSrcweir } 310*cdf0e10cSrcweir else 311*cdf0e10cSrcweir throw lang::IllegalArgumentException(); // TODO: 312*cdf0e10cSrcweir } 313*cdf0e10cSrcweir 314*cdf0e10cSrcweir if ( !m_pStream || m_pStream->GetError() ) 315*cdf0e10cSrcweir throw io::IOException(); // TODO 316*cdf0e10cSrcweir 317*cdf0e10cSrcweir m_pStorage = new Storage( *m_pStream, sal_False ); 318*cdf0e10cSrcweir } 319*cdf0e10cSrcweir 320*cdf0e10cSrcweir 321*cdf0e10cSrcweir //____________________________________________________________________________________________________ 322*cdf0e10cSrcweir // XNameContainer 323*cdf0e10cSrcweir //____________________________________________________________________________________________________ 324*cdf0e10cSrcweir 325*cdf0e10cSrcweir // -------------------------------------------------------------------------------- 326*cdf0e10cSrcweir void SAL_CALL OLESimpleStorage::insertByName( const ::rtl::OUString& aName, const uno::Any& aElement ) 327*cdf0e10cSrcweir throw ( lang::IllegalArgumentException, 328*cdf0e10cSrcweir container::ElementExistException, 329*cdf0e10cSrcweir lang::WrappedTargetException, 330*cdf0e10cSrcweir uno::RuntimeException) 331*cdf0e10cSrcweir { 332*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 333*cdf0e10cSrcweir 334*cdf0e10cSrcweir if ( m_bDisposed ) 335*cdf0e10cSrcweir throw lang::DisposedException(); 336*cdf0e10cSrcweir 337*cdf0e10cSrcweir if ( !m_pStorage ) 338*cdf0e10cSrcweir throw uno::RuntimeException(); 339*cdf0e10cSrcweir 340*cdf0e10cSrcweir uno::Reference< io::XStream > xStream; 341*cdf0e10cSrcweir uno::Reference< io::XInputStream > xInputStream; 342*cdf0e10cSrcweir uno::Reference< container::XNameAccess > xNameAccess; 343*cdf0e10cSrcweir 344*cdf0e10cSrcweir try 345*cdf0e10cSrcweir { 346*cdf0e10cSrcweir if ( !m_bNoTemporaryCopy && !m_xStream.is() ) 347*cdf0e10cSrcweir throw io::IOException(); // TODO 348*cdf0e10cSrcweir 349*cdf0e10cSrcweir if ( aElement >>= xStream ) 350*cdf0e10cSrcweir xInputStream = xStream->getInputStream(); 351*cdf0e10cSrcweir else if ( !( aElement >>= xInputStream ) && !( aElement >>= xNameAccess ) ) 352*cdf0e10cSrcweir throw lang::IllegalArgumentException(); // TODO: 353*cdf0e10cSrcweir 354*cdf0e10cSrcweir if ( xInputStream.is() ) 355*cdf0e10cSrcweir InsertInputStreamToStorage_Impl( m_pStorage, aName, xInputStream ); 356*cdf0e10cSrcweir else if ( xNameAccess.is() ) 357*cdf0e10cSrcweir InsertNameAccessToStorage_Impl( m_pStorage, aName, xNameAccess ); 358*cdf0e10cSrcweir else 359*cdf0e10cSrcweir throw uno::RuntimeException(); 360*cdf0e10cSrcweir } 361*cdf0e10cSrcweir catch( uno::RuntimeException& ) 362*cdf0e10cSrcweir { 363*cdf0e10cSrcweir throw; 364*cdf0e10cSrcweir } 365*cdf0e10cSrcweir catch( container::ElementExistException& ) 366*cdf0e10cSrcweir { 367*cdf0e10cSrcweir throw; 368*cdf0e10cSrcweir } 369*cdf0e10cSrcweir catch( uno::Exception& e ) 370*cdf0e10cSrcweir { 371*cdf0e10cSrcweir throw lang::WrappedTargetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Insert has failed!" ) ), 372*cdf0e10cSrcweir uno::Reference< uno::XInterface >(), 373*cdf0e10cSrcweir uno::makeAny( e ) ); 374*cdf0e10cSrcweir } 375*cdf0e10cSrcweir } 376*cdf0e10cSrcweir 377*cdf0e10cSrcweir // -------------------------------------------------------------------------------- 378*cdf0e10cSrcweir void SAL_CALL OLESimpleStorage::removeByName( const ::rtl::OUString& aName ) 379*cdf0e10cSrcweir throw ( container::NoSuchElementException, 380*cdf0e10cSrcweir lang::WrappedTargetException, 381*cdf0e10cSrcweir uno::RuntimeException) 382*cdf0e10cSrcweir { 383*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 384*cdf0e10cSrcweir 385*cdf0e10cSrcweir if ( m_bDisposed ) 386*cdf0e10cSrcweir throw lang::DisposedException(); 387*cdf0e10cSrcweir 388*cdf0e10cSrcweir if ( !m_pStorage ) 389*cdf0e10cSrcweir throw uno::RuntimeException(); 390*cdf0e10cSrcweir 391*cdf0e10cSrcweir if ( !m_bNoTemporaryCopy && !m_xStream.is() ) 392*cdf0e10cSrcweir throw lang::WrappedTargetException(); // io::IOException(); // TODO 393*cdf0e10cSrcweir 394*cdf0e10cSrcweir if ( !m_pStorage->IsContained( aName ) ) 395*cdf0e10cSrcweir throw container::NoSuchElementException(); // TODO: 396*cdf0e10cSrcweir 397*cdf0e10cSrcweir m_pStorage->Remove( aName ); 398*cdf0e10cSrcweir 399*cdf0e10cSrcweir if ( m_pStorage->GetError() ) 400*cdf0e10cSrcweir { 401*cdf0e10cSrcweir m_pStorage->ResetError(); 402*cdf0e10cSrcweir throw lang::WrappedTargetException(); // io::IOException(); // TODO 403*cdf0e10cSrcweir } 404*cdf0e10cSrcweir } 405*cdf0e10cSrcweir 406*cdf0e10cSrcweir // -------------------------------------------------------------------------------- 407*cdf0e10cSrcweir void SAL_CALL OLESimpleStorage::replaceByName( const ::rtl::OUString& aName, const uno::Any& aElement ) 408*cdf0e10cSrcweir throw ( lang::IllegalArgumentException, 409*cdf0e10cSrcweir container::NoSuchElementException, 410*cdf0e10cSrcweir lang::WrappedTargetException, 411*cdf0e10cSrcweir uno::RuntimeException) 412*cdf0e10cSrcweir { 413*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 414*cdf0e10cSrcweir 415*cdf0e10cSrcweir if ( m_bDisposed ) 416*cdf0e10cSrcweir throw lang::DisposedException(); 417*cdf0e10cSrcweir 418*cdf0e10cSrcweir removeByName( aName ); 419*cdf0e10cSrcweir 420*cdf0e10cSrcweir try 421*cdf0e10cSrcweir { 422*cdf0e10cSrcweir insertByName( aName, aElement ); 423*cdf0e10cSrcweir } 424*cdf0e10cSrcweir catch( container::ElementExistException& ) 425*cdf0e10cSrcweir { 426*cdf0e10cSrcweir uno::Any aCaught( ::cppu::getCaughtException() ); 427*cdf0e10cSrcweir 428*cdf0e10cSrcweir throw lang::WrappedTargetException( ::rtl::OUString::createFromAscii( "Can't copy raw stream" ), 429*cdf0e10cSrcweir uno::Reference< uno::XInterface >(), 430*cdf0e10cSrcweir aCaught ); 431*cdf0e10cSrcweir } 432*cdf0e10cSrcweir } 433*cdf0e10cSrcweir 434*cdf0e10cSrcweir // -------------------------------------------------------------------------------- 435*cdf0e10cSrcweir uno::Any SAL_CALL OLESimpleStorage::getByName( const ::rtl::OUString& aName ) 436*cdf0e10cSrcweir throw ( container::NoSuchElementException, 437*cdf0e10cSrcweir lang::WrappedTargetException, 438*cdf0e10cSrcweir uno::RuntimeException ) 439*cdf0e10cSrcweir { 440*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 441*cdf0e10cSrcweir 442*cdf0e10cSrcweir if ( m_bDisposed ) 443*cdf0e10cSrcweir throw lang::DisposedException(); 444*cdf0e10cSrcweir 445*cdf0e10cSrcweir if ( !m_pStorage ) 446*cdf0e10cSrcweir throw uno::RuntimeException(); 447*cdf0e10cSrcweir 448*cdf0e10cSrcweir if ( !m_pStorage->IsContained( aName ) ) 449*cdf0e10cSrcweir throw container::NoSuchElementException(); // TODO: 450*cdf0e10cSrcweir 451*cdf0e10cSrcweir uno::Any aResult; 452*cdf0e10cSrcweir 453*cdf0e10cSrcweir uno::Reference< io::XStream > xTempFile( 454*cdf0e10cSrcweir m_xFactory->createInstance( ::rtl::OUString::createFromAscii( "com.sun.star.io.TempFile" ) ), 455*cdf0e10cSrcweir uno::UNO_QUERY ); 456*cdf0e10cSrcweir uno::Reference< io::XSeekable > xSeekable( xTempFile, uno::UNO_QUERY_THROW ); 457*cdf0e10cSrcweir uno::Reference< io::XOutputStream > xOutputStream = xTempFile->getOutputStream(); 458*cdf0e10cSrcweir uno::Reference< io::XInputStream > xInputStream = xTempFile->getInputStream(); 459*cdf0e10cSrcweir if ( !xOutputStream.is() || !xInputStream.is() ) 460*cdf0e10cSrcweir throw uno::RuntimeException(); 461*cdf0e10cSrcweir 462*cdf0e10cSrcweir if ( m_pStorage->IsStorage( aName ) ) 463*cdf0e10cSrcweir { 464*cdf0e10cSrcweir BaseStorage* pStrg = m_pStorage->OpenStorage( aName ); 465*cdf0e10cSrcweir m_pStorage->ResetError(); 466*cdf0e10cSrcweir if ( !pStrg ) 467*cdf0e10cSrcweir throw io::IOException(); 468*cdf0e10cSrcweir 469*cdf0e10cSrcweir SvStream* pStream = ::utl::UcbStreamHelper::CreateStream( xTempFile, sal_False ); // do not close the original stream 470*cdf0e10cSrcweir if ( !pStream ) 471*cdf0e10cSrcweir throw uno::RuntimeException(); 472*cdf0e10cSrcweir 473*cdf0e10cSrcweir BaseStorage* pNewStor = new Storage( *pStream, sal_False ); 474*cdf0e10cSrcweir sal_Bool bSuccess = 475*cdf0e10cSrcweir ( pStrg->CopyTo( pNewStor ) && pNewStor->Commit() && !pNewStor->GetError() && !pStrg->GetError() ); 476*cdf0e10cSrcweir 477*cdf0e10cSrcweir DELETEZ( pNewStor ); 478*cdf0e10cSrcweir DELETEZ( pStrg ); 479*cdf0e10cSrcweir DELETEZ( pStream ); 480*cdf0e10cSrcweir 481*cdf0e10cSrcweir if ( !bSuccess ) 482*cdf0e10cSrcweir throw uno::RuntimeException(); 483*cdf0e10cSrcweir 484*cdf0e10cSrcweir uno::Sequence< uno::Any > aArgs( 2 ); 485*cdf0e10cSrcweir aArgs[0] <<= xInputStream; // allow readonly access only 486*cdf0e10cSrcweir aArgs[1] <<= (sal_Bool)sal_True; // do not create copy 487*cdf0e10cSrcweir 488*cdf0e10cSrcweir uno::Reference< container::XNameContainer > xResultNameContainer( 489*cdf0e10cSrcweir m_xFactory->createInstanceWithArguments( 490*cdf0e10cSrcweir ::rtl::OUString::createFromAscii( "com.sun.star.embed.OLESimpleStorage" ), 491*cdf0e10cSrcweir aArgs ), 492*cdf0e10cSrcweir uno::UNO_QUERY_THROW ); 493*cdf0e10cSrcweir 494*cdf0e10cSrcweir aResult <<= xResultNameContainer; 495*cdf0e10cSrcweir } 496*cdf0e10cSrcweir else 497*cdf0e10cSrcweir { 498*cdf0e10cSrcweir BaseStorageStream* pStream = m_pStorage->OpenStream( aName, STREAM_READ | STREAM_SHARE_DENYALL | STREAM_NOCREATE ); 499*cdf0e10cSrcweir if ( !pStream || pStream->GetError() || m_pStorage->GetError() ) 500*cdf0e10cSrcweir { 501*cdf0e10cSrcweir m_pStorage->ResetError(); 502*cdf0e10cSrcweir DELETEZ( pStream ); 503*cdf0e10cSrcweir throw io::IOException(); // TODO 504*cdf0e10cSrcweir } 505*cdf0e10cSrcweir 506*cdf0e10cSrcweir try 507*cdf0e10cSrcweir { 508*cdf0e10cSrcweir uno::Sequence< sal_Int8 > aData( nBytesCount ); 509*cdf0e10cSrcweir sal_Int32 nSize = nBytesCount; 510*cdf0e10cSrcweir sal_Int32 nRead = 0; 511*cdf0e10cSrcweir while( 0 != ( nRead = pStream->Read( aData.getArray(), nSize ) ) ) 512*cdf0e10cSrcweir { 513*cdf0e10cSrcweir if ( nRead < nSize ) 514*cdf0e10cSrcweir { 515*cdf0e10cSrcweir nSize = nRead; 516*cdf0e10cSrcweir aData.realloc( nSize ); 517*cdf0e10cSrcweir } 518*cdf0e10cSrcweir 519*cdf0e10cSrcweir xOutputStream->writeBytes( aData ); 520*cdf0e10cSrcweir } 521*cdf0e10cSrcweir 522*cdf0e10cSrcweir if ( pStream->GetError() ) 523*cdf0e10cSrcweir throw io::IOException(); // TODO 524*cdf0e10cSrcweir 525*cdf0e10cSrcweir xOutputStream->closeOutput(); 526*cdf0e10cSrcweir xSeekable->seek( 0 ); 527*cdf0e10cSrcweir } 528*cdf0e10cSrcweir catch( uno::RuntimeException& ) 529*cdf0e10cSrcweir { 530*cdf0e10cSrcweir DELETEZ( pStream ); 531*cdf0e10cSrcweir throw; 532*cdf0e10cSrcweir } 533*cdf0e10cSrcweir catch( uno::Exception& ) 534*cdf0e10cSrcweir { 535*cdf0e10cSrcweir DELETEZ( pStream ); 536*cdf0e10cSrcweir throw lang::WrappedTargetException(); // TODO: 537*cdf0e10cSrcweir } 538*cdf0e10cSrcweir 539*cdf0e10cSrcweir DELETEZ( pStream ); 540*cdf0e10cSrcweir 541*cdf0e10cSrcweir aResult <<= xInputStream; 542*cdf0e10cSrcweir } 543*cdf0e10cSrcweir 544*cdf0e10cSrcweir return aResult; 545*cdf0e10cSrcweir } 546*cdf0e10cSrcweir 547*cdf0e10cSrcweir // -------------------------------------------------------------------------------- 548*cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > SAL_CALL OLESimpleStorage::getElementNames() 549*cdf0e10cSrcweir throw ( uno::RuntimeException ) 550*cdf0e10cSrcweir { 551*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 552*cdf0e10cSrcweir 553*cdf0e10cSrcweir if ( m_bDisposed ) 554*cdf0e10cSrcweir throw lang::DisposedException(); 555*cdf0e10cSrcweir 556*cdf0e10cSrcweir if ( !m_pStorage ) 557*cdf0e10cSrcweir throw uno::RuntimeException(); 558*cdf0e10cSrcweir 559*cdf0e10cSrcweir SvStorageInfoList aList; 560*cdf0e10cSrcweir m_pStorage->FillInfoList( &aList ); 561*cdf0e10cSrcweir 562*cdf0e10cSrcweir if ( m_pStorage->GetError() ) 563*cdf0e10cSrcweir { 564*cdf0e10cSrcweir m_pStorage->ResetError(); 565*cdf0e10cSrcweir throw uno::RuntimeException(); // TODO: 566*cdf0e10cSrcweir } 567*cdf0e10cSrcweir 568*cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > aSeq( aList.Count() ); 569*cdf0e10cSrcweir for ( sal_uInt32 nInd = 0; nInd < aList.Count(); nInd++ ) 570*cdf0e10cSrcweir aSeq[nInd] = aList[nInd].GetName(); 571*cdf0e10cSrcweir 572*cdf0e10cSrcweir return aSeq; 573*cdf0e10cSrcweir } 574*cdf0e10cSrcweir 575*cdf0e10cSrcweir // -------------------------------------------------------------------------------- 576*cdf0e10cSrcweir sal_Bool SAL_CALL OLESimpleStorage::hasByName( const ::rtl::OUString& aName ) 577*cdf0e10cSrcweir throw ( uno::RuntimeException ) 578*cdf0e10cSrcweir { 579*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 580*cdf0e10cSrcweir 581*cdf0e10cSrcweir if ( m_bDisposed ) 582*cdf0e10cSrcweir throw lang::DisposedException(); 583*cdf0e10cSrcweir 584*cdf0e10cSrcweir if ( !m_pStorage ) 585*cdf0e10cSrcweir throw uno::RuntimeException(); 586*cdf0e10cSrcweir 587*cdf0e10cSrcweir sal_Bool bResult = m_pStorage->IsContained( aName ); 588*cdf0e10cSrcweir 589*cdf0e10cSrcweir if ( m_pStorage->GetError() ) 590*cdf0e10cSrcweir { 591*cdf0e10cSrcweir m_pStorage->ResetError(); 592*cdf0e10cSrcweir throw uno::RuntimeException(); // TODO: 593*cdf0e10cSrcweir } 594*cdf0e10cSrcweir 595*cdf0e10cSrcweir return bResult; 596*cdf0e10cSrcweir } 597*cdf0e10cSrcweir 598*cdf0e10cSrcweir // -------------------------------------------------------------------------------- 599*cdf0e10cSrcweir uno::Type SAL_CALL OLESimpleStorage::getElementType() 600*cdf0e10cSrcweir throw ( uno::RuntimeException ) 601*cdf0e10cSrcweir { 602*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 603*cdf0e10cSrcweir 604*cdf0e10cSrcweir if ( m_bDisposed ) 605*cdf0e10cSrcweir throw lang::DisposedException(); 606*cdf0e10cSrcweir 607*cdf0e10cSrcweir return getCppuType( (const uno::Reference< io::XInputStream >*)NULL ); 608*cdf0e10cSrcweir } 609*cdf0e10cSrcweir 610*cdf0e10cSrcweir // -------------------------------------------------------------------------------- 611*cdf0e10cSrcweir sal_Bool SAL_CALL OLESimpleStorage::hasElements() 612*cdf0e10cSrcweir throw ( uno::RuntimeException ) 613*cdf0e10cSrcweir { 614*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 615*cdf0e10cSrcweir 616*cdf0e10cSrcweir if ( m_bDisposed ) 617*cdf0e10cSrcweir throw lang::DisposedException(); 618*cdf0e10cSrcweir 619*cdf0e10cSrcweir if ( !m_pStorage ) 620*cdf0e10cSrcweir throw uno::RuntimeException(); 621*cdf0e10cSrcweir 622*cdf0e10cSrcweir SvStorageInfoList aList; 623*cdf0e10cSrcweir m_pStorage->FillInfoList( &aList ); 624*cdf0e10cSrcweir 625*cdf0e10cSrcweir if ( m_pStorage->GetError() ) 626*cdf0e10cSrcweir { 627*cdf0e10cSrcweir m_pStorage->ResetError(); 628*cdf0e10cSrcweir throw uno::RuntimeException(); // TODO: 629*cdf0e10cSrcweir } 630*cdf0e10cSrcweir 631*cdf0e10cSrcweir return ( aList.Count() != 0 ); 632*cdf0e10cSrcweir } 633*cdf0e10cSrcweir 634*cdf0e10cSrcweir //____________________________________________________________________________________________________ 635*cdf0e10cSrcweir // XComponent 636*cdf0e10cSrcweir //____________________________________________________________________________________________________ 637*cdf0e10cSrcweir 638*cdf0e10cSrcweir // -------------------------------------------------------------------------------- 639*cdf0e10cSrcweir void SAL_CALL OLESimpleStorage::dispose() 640*cdf0e10cSrcweir throw ( uno::RuntimeException ) 641*cdf0e10cSrcweir { 642*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 643*cdf0e10cSrcweir 644*cdf0e10cSrcweir if ( m_bDisposed ) 645*cdf0e10cSrcweir throw lang::DisposedException(); 646*cdf0e10cSrcweir 647*cdf0e10cSrcweir if ( m_pListenersContainer ) 648*cdf0e10cSrcweir { 649*cdf0e10cSrcweir lang::EventObject aSource( static_cast< ::cppu::OWeakObject* >(this) ); 650*cdf0e10cSrcweir m_pListenersContainer->disposeAndClear( aSource ); 651*cdf0e10cSrcweir } 652*cdf0e10cSrcweir 653*cdf0e10cSrcweir DELETEZ( m_pStorage ); 654*cdf0e10cSrcweir DELETEZ( m_pStream ); 655*cdf0e10cSrcweir 656*cdf0e10cSrcweir m_xStream = uno::Reference< io::XStream >(); 657*cdf0e10cSrcweir m_xTempStream = uno::Reference< io::XStream >(); 658*cdf0e10cSrcweir 659*cdf0e10cSrcweir m_bDisposed = sal_True; 660*cdf0e10cSrcweir } 661*cdf0e10cSrcweir 662*cdf0e10cSrcweir // -------------------------------------------------------------------------------- 663*cdf0e10cSrcweir void SAL_CALL OLESimpleStorage::addEventListener( 664*cdf0e10cSrcweir const uno::Reference< lang::XEventListener >& xListener ) 665*cdf0e10cSrcweir throw ( uno::RuntimeException ) 666*cdf0e10cSrcweir { 667*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 668*cdf0e10cSrcweir 669*cdf0e10cSrcweir if ( m_bDisposed ) 670*cdf0e10cSrcweir throw lang::DisposedException(); 671*cdf0e10cSrcweir 672*cdf0e10cSrcweir if ( !m_pListenersContainer ) 673*cdf0e10cSrcweir m_pListenersContainer = new ::cppu::OInterfaceContainerHelper( m_aMutex ); 674*cdf0e10cSrcweir 675*cdf0e10cSrcweir m_pListenersContainer->addInterface( xListener ); 676*cdf0e10cSrcweir } 677*cdf0e10cSrcweir 678*cdf0e10cSrcweir // -------------------------------------------------------------------------------- 679*cdf0e10cSrcweir void SAL_CALL OLESimpleStorage::removeEventListener( 680*cdf0e10cSrcweir const uno::Reference< lang::XEventListener >& xListener ) 681*cdf0e10cSrcweir throw ( uno::RuntimeException ) 682*cdf0e10cSrcweir { 683*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 684*cdf0e10cSrcweir 685*cdf0e10cSrcweir if ( m_bDisposed ) 686*cdf0e10cSrcweir throw lang::DisposedException(); 687*cdf0e10cSrcweir 688*cdf0e10cSrcweir if ( m_pListenersContainer ) 689*cdf0e10cSrcweir m_pListenersContainer->removeInterface( xListener ); 690*cdf0e10cSrcweir } 691*cdf0e10cSrcweir 692*cdf0e10cSrcweir //____________________________________________________________________________________________________ 693*cdf0e10cSrcweir // XTransactedObject 694*cdf0e10cSrcweir //____________________________________________________________________________________________________ 695*cdf0e10cSrcweir 696*cdf0e10cSrcweir // -------------------------------------------------------------------------------- 697*cdf0e10cSrcweir void SAL_CALL OLESimpleStorage::commit() 698*cdf0e10cSrcweir throw ( ::com::sun::star::io::IOException, 699*cdf0e10cSrcweir ::com::sun::star::lang::WrappedTargetException, 700*cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException ) 701*cdf0e10cSrcweir { 702*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 703*cdf0e10cSrcweir 704*cdf0e10cSrcweir if ( m_bDisposed ) 705*cdf0e10cSrcweir throw lang::DisposedException(); 706*cdf0e10cSrcweir 707*cdf0e10cSrcweir if ( !m_pStorage ) 708*cdf0e10cSrcweir throw uno::RuntimeException(); 709*cdf0e10cSrcweir 710*cdf0e10cSrcweir if ( !m_bNoTemporaryCopy && !m_xStream.is() ) 711*cdf0e10cSrcweir throw io::IOException(); // TODO 712*cdf0e10cSrcweir 713*cdf0e10cSrcweir if ( !m_pStorage->Commit() || m_pStorage->GetError() ) 714*cdf0e10cSrcweir { 715*cdf0e10cSrcweir m_pStorage->ResetError(); 716*cdf0e10cSrcweir throw io::IOException(); // TODO 717*cdf0e10cSrcweir } 718*cdf0e10cSrcweir 719*cdf0e10cSrcweir UpdateOriginal_Impl(); 720*cdf0e10cSrcweir } 721*cdf0e10cSrcweir 722*cdf0e10cSrcweir // -------------------------------------------------------------------------------- 723*cdf0e10cSrcweir void SAL_CALL OLESimpleStorage::revert() 724*cdf0e10cSrcweir throw ( ::com::sun::star::io::IOException, 725*cdf0e10cSrcweir ::com::sun::star::lang::WrappedTargetException, 726*cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException ) 727*cdf0e10cSrcweir { 728*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 729*cdf0e10cSrcweir 730*cdf0e10cSrcweir if ( m_bDisposed ) 731*cdf0e10cSrcweir throw lang::DisposedException(); 732*cdf0e10cSrcweir 733*cdf0e10cSrcweir if ( !m_pStorage ) 734*cdf0e10cSrcweir throw uno::RuntimeException(); 735*cdf0e10cSrcweir 736*cdf0e10cSrcweir if ( !m_bNoTemporaryCopy && !m_xStream.is() ) 737*cdf0e10cSrcweir throw io::IOException(); // TODO 738*cdf0e10cSrcweir 739*cdf0e10cSrcweir if ( !m_pStorage->Revert() || m_pStorage->GetError() ) 740*cdf0e10cSrcweir { 741*cdf0e10cSrcweir m_pStorage->ResetError(); 742*cdf0e10cSrcweir throw io::IOException(); // TODO 743*cdf0e10cSrcweir } 744*cdf0e10cSrcweir 745*cdf0e10cSrcweir UpdateOriginal_Impl(); 746*cdf0e10cSrcweir } 747*cdf0e10cSrcweir 748*cdf0e10cSrcweir //____________________________________________________________________________________________________ 749*cdf0e10cSrcweir // XClassifiedObject 750*cdf0e10cSrcweir //____________________________________________________________________________________________________ 751*cdf0e10cSrcweir 752*cdf0e10cSrcweir uno::Sequence< sal_Int8 > SAL_CALL OLESimpleStorage::getClassID() 753*cdf0e10cSrcweir throw ( uno::RuntimeException ) 754*cdf0e10cSrcweir { 755*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 756*cdf0e10cSrcweir 757*cdf0e10cSrcweir if ( m_bDisposed ) 758*cdf0e10cSrcweir throw lang::DisposedException(); 759*cdf0e10cSrcweir 760*cdf0e10cSrcweir if ( !m_pStorage ) 761*cdf0e10cSrcweir throw uno::RuntimeException(); 762*cdf0e10cSrcweir 763*cdf0e10cSrcweir return m_pStorage->GetClassName().GetByteSequence(); 764*cdf0e10cSrcweir } 765*cdf0e10cSrcweir 766*cdf0e10cSrcweir ::rtl::OUString SAL_CALL OLESimpleStorage::getClassName() 767*cdf0e10cSrcweir throw ( uno::RuntimeException ) 768*cdf0e10cSrcweir { 769*cdf0e10cSrcweir return ::rtl::OUString(); 770*cdf0e10cSrcweir } 771*cdf0e10cSrcweir 772*cdf0e10cSrcweir void SAL_CALL OLESimpleStorage::setClassInfo( const uno::Sequence< sal_Int8 >& /*aClassID*/, 773*cdf0e10cSrcweir const ::rtl::OUString& /*sClassName*/ ) 774*cdf0e10cSrcweir throw ( lang::NoSupportException, 775*cdf0e10cSrcweir uno::RuntimeException ) 776*cdf0e10cSrcweir { 777*cdf0e10cSrcweir throw lang::NoSupportException(); 778*cdf0e10cSrcweir } 779*cdf0e10cSrcweir 780*cdf0e10cSrcweir //____________________________________________________________________________________________________ 781*cdf0e10cSrcweir // XServiceInfo 782*cdf0e10cSrcweir //____________________________________________________________________________________________________ 783*cdf0e10cSrcweir 784*cdf0e10cSrcweir // -------------------------------------------------------------------------------- 785*cdf0e10cSrcweir ::rtl::OUString SAL_CALL OLESimpleStorage::getImplementationName() 786*cdf0e10cSrcweir throw ( uno::RuntimeException ) 787*cdf0e10cSrcweir { 788*cdf0e10cSrcweir return impl_staticGetImplementationName(); 789*cdf0e10cSrcweir } 790*cdf0e10cSrcweir 791*cdf0e10cSrcweir // -------------------------------------------------------------------------------- 792*cdf0e10cSrcweir ::sal_Bool SAL_CALL OLESimpleStorage::supportsService( const ::rtl::OUString& ServiceName ) 793*cdf0e10cSrcweir throw ( uno::RuntimeException ) 794*cdf0e10cSrcweir { 795*cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > aSeq = impl_staticGetSupportedServiceNames(); 796*cdf0e10cSrcweir 797*cdf0e10cSrcweir for ( sal_Int32 nInd = 0; nInd < aSeq.getLength(); nInd++ ) 798*cdf0e10cSrcweir if ( ServiceName.compareTo( aSeq[nInd] ) == 0 ) 799*cdf0e10cSrcweir return sal_True; 800*cdf0e10cSrcweir 801*cdf0e10cSrcweir return sal_False; 802*cdf0e10cSrcweir } 803*cdf0e10cSrcweir 804*cdf0e10cSrcweir // -------------------------------------------------------------------------------- 805*cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > SAL_CALL OLESimpleStorage::getSupportedServiceNames() 806*cdf0e10cSrcweir throw ( uno::RuntimeException ) 807*cdf0e10cSrcweir { 808*cdf0e10cSrcweir return impl_staticGetSupportedServiceNames(); 809*cdf0e10cSrcweir } 810*cdf0e10cSrcweir 811*cdf0e10cSrcweir 812