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_svl.hxx" 30*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp> 31*cdf0e10cSrcweir #include <com/sun/star/embed/ElementModes.hpp> 32*cdf0e10cSrcweir #include <com/sun/star/embed/XTransactedObject.hpp> 33*cdf0e10cSrcweir #include <com/sun/star/ucb/XProgressHandler.hpp> 34*cdf0e10cSrcweir #include <com/sun/star/ucb/XContentAccess.hpp> 35*cdf0e10cSrcweir #include <com/sun/star/ucb/XSimpleFileAccess.hpp> 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UCB_INTERACTIVEIODEXCEPTION_HPP_ 38*cdf0e10cSrcweir #include <com/sun/star/ucb/InteractiveIOException.hpp> 39*cdf0e10cSrcweir #endif 40*cdf0e10cSrcweir #include <com/sun/star/ucb/IOErrorCode.hpp> 41*cdf0e10cSrcweir #include <com/sun/star/container/XHierarchicalNameAccess.hpp> 42*cdf0e10cSrcweir #include <com/sun/star/container/XEnumerationAccess.hpp> 43*cdf0e10cSrcweir #include <com/sun/star/container/XNamed.hpp> 44*cdf0e10cSrcweir #include <com/sun/star/util/XChangesBatch.hpp> 45*cdf0e10cSrcweir #include <com/sun/star/util/XCloneable.hpp> 46*cdf0e10cSrcweir #include <com/sun/star/lang/XUnoTunnel.hpp> 47*cdf0e10cSrcweir #include <com/sun/star/lang/XComponent.hpp> 48*cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp> 49*cdf0e10cSrcweir #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp> 50*cdf0e10cSrcweir #include <com/sun/star/io/IOException.hpp> 51*cdf0e10cSrcweir #include <com/sun/star/io/XTruncate.hpp> 52*cdf0e10cSrcweir #include <com/sun/star/sdbc/XResultSet.hpp> 53*cdf0e10cSrcweir #include <com/sun/star/sdbc/XRow.hpp> 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir #ifndef _COMPHELPER_PROCESSFACTORY_HXX 57*cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 58*cdf0e10cSrcweir #endif 59*cdf0e10cSrcweir #include <comphelper/storagehelper.hxx> 60*cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx> 61*cdf0e10cSrcweir #include <cppuhelper/exc_hlp.hxx> 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir #include <tools/urlobj.hxx> 64*cdf0e10cSrcweir #include <unotools/ucbhelper.hxx> 65*cdf0e10cSrcweir #include <unotools/ucbstreamhelper.hxx> 66*cdf0e10cSrcweir #include <unotools/streamwrap.hxx> 67*cdf0e10cSrcweir #include <ucbhelper/fileidentifierconverter.hxx> 68*cdf0e10cSrcweir #include <ucbhelper/contentbroker.hxx> 69*cdf0e10cSrcweir #include <ucbhelper/content.hxx> 70*cdf0e10cSrcweir 71*cdf0e10cSrcweir #include "fsstorage.hxx" 72*cdf0e10cSrcweir #include "oinputstreamcontainer.hxx" 73*cdf0e10cSrcweir #include "ostreamcontainer.hxx" 74*cdf0e10cSrcweir 75*cdf0e10cSrcweir using namespace ::com::sun::star; 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir //========================================================= 78*cdf0e10cSrcweir 79*cdf0e10cSrcweir // TODO: move to a standard helper 80*cdf0e10cSrcweir sal_Bool isLocalFile_Impl( ::rtl::OUString aURL ) 81*cdf0e10cSrcweir { 82*cdf0e10cSrcweir ::rtl::OUString aSystemPath; 83*cdf0e10cSrcweir ::ucbhelper::ContentBroker* pBroker = ::ucbhelper::ContentBroker::get(); 84*cdf0e10cSrcweir if ( !pBroker ) 85*cdf0e10cSrcweir throw uno::RuntimeException(); 86*cdf0e10cSrcweir 87*cdf0e10cSrcweir uno::Reference< ucb::XContentProviderManager > xManager = 88*cdf0e10cSrcweir pBroker->getContentProviderManagerInterface(); 89*cdf0e10cSrcweir try 90*cdf0e10cSrcweir { 91*cdf0e10cSrcweir aSystemPath = ::ucbhelper::getSystemPathFromFileURL( xManager, aURL ); 92*cdf0e10cSrcweir } 93*cdf0e10cSrcweir catch ( uno::Exception& ) 94*cdf0e10cSrcweir { 95*cdf0e10cSrcweir } 96*cdf0e10cSrcweir 97*cdf0e10cSrcweir return ( aSystemPath.getLength() != 0 ); 98*cdf0e10cSrcweir } 99*cdf0e10cSrcweir 100*cdf0e10cSrcweir 101*cdf0e10cSrcweir //========================================================= 102*cdf0e10cSrcweir 103*cdf0e10cSrcweir struct FSStorage_Impl 104*cdf0e10cSrcweir { 105*cdf0e10cSrcweir ::rtl::OUString m_aURL; 106*cdf0e10cSrcweir 107*cdf0e10cSrcweir ::ucbhelper::Content* m_pContent; 108*cdf0e10cSrcweir sal_Int32 m_nMode; 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir ::cppu::OInterfaceContainerHelper* m_pListenersContainer; // list of listeners 111*cdf0e10cSrcweir ::cppu::OTypeCollection* m_pTypeCollection; 112*cdf0e10cSrcweir 113*cdf0e10cSrcweir uno::Reference< lang::XMultiServiceFactory > m_xFactory; 114*cdf0e10cSrcweir 115*cdf0e10cSrcweir 116*cdf0e10cSrcweir FSStorage_Impl( const ::rtl::OUString& aURL, sal_Int32 nMode, uno::Reference< lang::XMultiServiceFactory > xFactory ) 117*cdf0e10cSrcweir : m_aURL( aURL ) 118*cdf0e10cSrcweir , m_pContent( NULL ) 119*cdf0e10cSrcweir , m_nMode( nMode ) 120*cdf0e10cSrcweir , m_pListenersContainer( NULL ) 121*cdf0e10cSrcweir , m_pTypeCollection( NULL ) 122*cdf0e10cSrcweir , m_xFactory( xFactory ) 123*cdf0e10cSrcweir { 124*cdf0e10cSrcweir OSL_ENSURE( m_aURL.getLength(), "The URL must not be empty" ); 125*cdf0e10cSrcweir } 126*cdf0e10cSrcweir 127*cdf0e10cSrcweir FSStorage_Impl( const ::ucbhelper::Content& aContent, sal_Int32 nMode, uno::Reference< lang::XMultiServiceFactory > xFactory ) 128*cdf0e10cSrcweir : m_aURL( aContent.getURL() ) 129*cdf0e10cSrcweir , m_pContent( new ::ucbhelper::Content( aContent ) ) 130*cdf0e10cSrcweir , m_nMode( nMode ) 131*cdf0e10cSrcweir , m_pListenersContainer( NULL ) 132*cdf0e10cSrcweir , m_pTypeCollection( NULL ) 133*cdf0e10cSrcweir , m_xFactory( xFactory ) 134*cdf0e10cSrcweir { 135*cdf0e10cSrcweir OSL_ENSURE( m_aURL.getLength(), "The URL must not be empty" ); 136*cdf0e10cSrcweir } 137*cdf0e10cSrcweir 138*cdf0e10cSrcweir ~FSStorage_Impl(); 139*cdf0e10cSrcweir }; 140*cdf0e10cSrcweir 141*cdf0e10cSrcweir //========================================================= 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir FSStorage_Impl::~FSStorage_Impl() 144*cdf0e10cSrcweir { 145*cdf0e10cSrcweir if ( m_pListenersContainer ) 146*cdf0e10cSrcweir delete m_pListenersContainer; 147*cdf0e10cSrcweir if ( m_pTypeCollection ) 148*cdf0e10cSrcweir delete m_pTypeCollection; 149*cdf0e10cSrcweir if ( m_pContent ) 150*cdf0e10cSrcweir delete m_pContent; 151*cdf0e10cSrcweir } 152*cdf0e10cSrcweir 153*cdf0e10cSrcweir //===================================================== 154*cdf0e10cSrcweir // FSStorage implementation 155*cdf0e10cSrcweir //===================================================== 156*cdf0e10cSrcweir 157*cdf0e10cSrcweir //----------------------------------------------- 158*cdf0e10cSrcweir FSStorage::FSStorage( const ::ucbhelper::Content& aContent, 159*cdf0e10cSrcweir sal_Int32 nMode, 160*cdf0e10cSrcweir uno::Sequence< beans::PropertyValue >, 161*cdf0e10cSrcweir uno::Reference< lang::XMultiServiceFactory > xFactory ) 162*cdf0e10cSrcweir : m_pImpl( new FSStorage_Impl( aContent, nMode, xFactory ) ) 163*cdf0e10cSrcweir { 164*cdf0e10cSrcweir // TODO: use properties 165*cdf0e10cSrcweir if ( !xFactory.is() ) 166*cdf0e10cSrcweir throw uno::RuntimeException(); 167*cdf0e10cSrcweir 168*cdf0e10cSrcweir GetContent(); 169*cdf0e10cSrcweir } 170*cdf0e10cSrcweir 171*cdf0e10cSrcweir //----------------------------------------------- 172*cdf0e10cSrcweir FSStorage::~FSStorage() 173*cdf0e10cSrcweir { 174*cdf0e10cSrcweir { 175*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 176*cdf0e10cSrcweir m_refCount++; // to call dispose 177*cdf0e10cSrcweir try { 178*cdf0e10cSrcweir dispose(); 179*cdf0e10cSrcweir } 180*cdf0e10cSrcweir catch( uno::RuntimeException& ) 181*cdf0e10cSrcweir {} 182*cdf0e10cSrcweir } 183*cdf0e10cSrcweir } 184*cdf0e10cSrcweir 185*cdf0e10cSrcweir //----------------------------------------------- 186*cdf0e10cSrcweir sal_Bool FSStorage::MakeFolderNoUI( const String& rFolder, sal_Bool ) 187*cdf0e10cSrcweir { 188*cdf0e10cSrcweir INetURLObject aURL( rFolder ); 189*cdf0e10cSrcweir ::rtl::OUString aTitle = aURL.getName( INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET ); 190*cdf0e10cSrcweir aURL.removeSegment(); 191*cdf0e10cSrcweir ::ucbhelper::Content aParent; 192*cdf0e10cSrcweir ::ucbhelper::Content aResultContent; 193*cdf0e10cSrcweir 194*cdf0e10cSrcweir if ( ::ucbhelper::Content::create( aURL.GetMainURL( INetURLObject::NO_DECODE ), 195*cdf0e10cSrcweir uno::Reference< ucb::XCommandEnvironment >(), 196*cdf0e10cSrcweir aParent ) ) 197*cdf0e10cSrcweir return ::utl::UCBContentHelper::MakeFolder( aParent, aTitle, aResultContent, sal_False ); 198*cdf0e10cSrcweir 199*cdf0e10cSrcweir return sal_False; 200*cdf0e10cSrcweir } 201*cdf0e10cSrcweir 202*cdf0e10cSrcweir //----------------------------------------------- 203*cdf0e10cSrcweir ::ucbhelper::Content* FSStorage::GetContent() 204*cdf0e10cSrcweir { 205*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 206*cdf0e10cSrcweir if ( !m_pImpl->m_pContent ) 207*cdf0e10cSrcweir { 208*cdf0e10cSrcweir uno::Reference< ucb::XCommandEnvironment > xDummyEnv; 209*cdf0e10cSrcweir 210*cdf0e10cSrcweir try 211*cdf0e10cSrcweir { 212*cdf0e10cSrcweir m_pImpl->m_pContent = new ::ucbhelper::Content( m_pImpl->m_aURL, xDummyEnv ); 213*cdf0e10cSrcweir } 214*cdf0e10cSrcweir catch( uno::Exception& ) 215*cdf0e10cSrcweir { 216*cdf0e10cSrcweir } 217*cdf0e10cSrcweir } 218*cdf0e10cSrcweir 219*cdf0e10cSrcweir return m_pImpl->m_pContent; 220*cdf0e10cSrcweir } 221*cdf0e10cSrcweir 222*cdf0e10cSrcweir //----------------------------------------------- 223*cdf0e10cSrcweir void FSStorage::CopyStreamToSubStream( const ::rtl::OUString& aSourceURL, 224*cdf0e10cSrcweir const uno::Reference< embed::XStorage >& xDest, 225*cdf0e10cSrcweir const ::rtl::OUString& aNewEntryName ) 226*cdf0e10cSrcweir { 227*cdf0e10cSrcweir if ( !xDest.is() ) 228*cdf0e10cSrcweir throw uno::RuntimeException(); 229*cdf0e10cSrcweir 230*cdf0e10cSrcweir uno::Reference< ucb::XCommandEnvironment > xDummyEnv; 231*cdf0e10cSrcweir ::ucbhelper::Content aSourceContent( aSourceURL, xDummyEnv ); 232*cdf0e10cSrcweir uno::Reference< io::XInputStream > xSourceInput = aSourceContent.openStream(); 233*cdf0e10cSrcweir 234*cdf0e10cSrcweir if ( !xSourceInput.is() ) 235*cdf0e10cSrcweir throw io::IOException(); // TODO: error handling 236*cdf0e10cSrcweir 237*cdf0e10cSrcweir uno::Reference< io::XStream > xSubStream = xDest->openStreamElement( 238*cdf0e10cSrcweir aNewEntryName, 239*cdf0e10cSrcweir embed::ElementModes::READWRITE | embed::ElementModes::TRUNCATE ); 240*cdf0e10cSrcweir if ( !xSubStream.is() ) 241*cdf0e10cSrcweir throw uno::RuntimeException(); 242*cdf0e10cSrcweir 243*cdf0e10cSrcweir uno::Reference< io::XOutputStream > xDestOutput = xSubStream->getOutputStream(); 244*cdf0e10cSrcweir if ( !xDestOutput.is() ) 245*cdf0e10cSrcweir throw uno::RuntimeException(); 246*cdf0e10cSrcweir 247*cdf0e10cSrcweir ::comphelper::OStorageHelper::CopyInputToOutput( xSourceInput, xDestOutput ); 248*cdf0e10cSrcweir xDestOutput->closeOutput(); 249*cdf0e10cSrcweir } 250*cdf0e10cSrcweir 251*cdf0e10cSrcweir //----------------------------------------------- 252*cdf0e10cSrcweir void FSStorage::CopyContentToStorage_Impl( ::ucbhelper::Content* pContent, const uno::Reference< embed::XStorage >& xDest ) 253*cdf0e10cSrcweir { 254*cdf0e10cSrcweir if ( !pContent ) 255*cdf0e10cSrcweir throw uno::RuntimeException(); 256*cdf0e10cSrcweir 257*cdf0e10cSrcweir // get list of contents of the Content 258*cdf0e10cSrcweir // create cursor for access to children 259*cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > aProps( 2 ); 260*cdf0e10cSrcweir ::rtl::OUString* pProps = aProps.getArray(); 261*cdf0e10cSrcweir pProps[0] = ::rtl::OUString::createFromAscii( "TargetURL" ); 262*cdf0e10cSrcweir pProps[1] = ::rtl::OUString::createFromAscii( "IsFolder" ); 263*cdf0e10cSrcweir ::ucbhelper::ResultSetInclude eInclude = ::ucbhelper::INCLUDE_FOLDERS_AND_DOCUMENTS; 264*cdf0e10cSrcweir 265*cdf0e10cSrcweir try 266*cdf0e10cSrcweir { 267*cdf0e10cSrcweir uno::Reference< sdbc::XResultSet > xResultSet = pContent->createCursor( aProps, eInclude ); 268*cdf0e10cSrcweir uno::Reference< ucb::XContentAccess > xContentAccess( xResultSet, uno::UNO_QUERY ); 269*cdf0e10cSrcweir uno::Reference< sdbc::XRow > xRow( xResultSet, uno::UNO_QUERY ); 270*cdf0e10cSrcweir if ( xResultSet.is() ) 271*cdf0e10cSrcweir { 272*cdf0e10cSrcweir // go through the list: insert files as streams, insert folders as substorages using recursion 273*cdf0e10cSrcweir while ( xResultSet->next() ) 274*cdf0e10cSrcweir { 275*cdf0e10cSrcweir ::rtl::OUString aSourceURL( xRow->getString( 1 ) ); 276*cdf0e10cSrcweir sal_Bool bIsFolder( xRow->getBoolean(2) ); 277*cdf0e10cSrcweir 278*cdf0e10cSrcweir // TODO/LATER: not sure whether the entry name must be encoded 279*cdf0e10cSrcweir ::rtl::OUString aNewEntryName( INetURLObject( aSourceURL ).getName( INetURLObject::LAST_SEGMENT, 280*cdf0e10cSrcweir true, 281*cdf0e10cSrcweir INetURLObject::NO_DECODE ) ); 282*cdf0e10cSrcweir if ( bIsFolder ) 283*cdf0e10cSrcweir { 284*cdf0e10cSrcweir uno::Reference< embed::XStorage > xSubStorage = xDest->openStorageElement( aNewEntryName, 285*cdf0e10cSrcweir embed::ElementModes::READWRITE ); 286*cdf0e10cSrcweir if ( !xSubStorage.is() ) 287*cdf0e10cSrcweir throw uno::RuntimeException(); 288*cdf0e10cSrcweir 289*cdf0e10cSrcweir uno::Reference< ucb::XCommandEnvironment > xDummyEnv; 290*cdf0e10cSrcweir ::ucbhelper::Content aSourceContent( aSourceURL, xDummyEnv ); 291*cdf0e10cSrcweir CopyContentToStorage_Impl( &aSourceContent, xSubStorage ); 292*cdf0e10cSrcweir } 293*cdf0e10cSrcweir else 294*cdf0e10cSrcweir { 295*cdf0e10cSrcweir CopyStreamToSubStream( aSourceURL, xDest, aNewEntryName ); 296*cdf0e10cSrcweir } 297*cdf0e10cSrcweir } 298*cdf0e10cSrcweir } 299*cdf0e10cSrcweir 300*cdf0e10cSrcweir uno::Reference< embed::XTransactedObject > xTransact( xDest, uno::UNO_QUERY ); 301*cdf0e10cSrcweir if ( xTransact.is() ) 302*cdf0e10cSrcweir xTransact->commit(); 303*cdf0e10cSrcweir } 304*cdf0e10cSrcweir catch( ucb::InteractiveIOException& r ) 305*cdf0e10cSrcweir { 306*cdf0e10cSrcweir if ( r.Code == ucb::IOErrorCode_NOT_EXISTING ) 307*cdf0e10cSrcweir OSL_ENSURE( sal_False, "The folder does not exist!\n" ); 308*cdf0e10cSrcweir else 309*cdf0e10cSrcweir throw; 310*cdf0e10cSrcweir } 311*cdf0e10cSrcweir } 312*cdf0e10cSrcweir 313*cdf0e10cSrcweir //____________________________________________________________________________________________________ 314*cdf0e10cSrcweir // XInterface 315*cdf0e10cSrcweir //____________________________________________________________________________________________________ 316*cdf0e10cSrcweir 317*cdf0e10cSrcweir //----------------------------------------------- 318*cdf0e10cSrcweir uno::Any SAL_CALL FSStorage::queryInterface( const uno::Type& rType ) 319*cdf0e10cSrcweir throw( uno::RuntimeException ) 320*cdf0e10cSrcweir { 321*cdf0e10cSrcweir uno::Any aReturn; 322*cdf0e10cSrcweir aReturn <<= ::cppu::queryInterface 323*cdf0e10cSrcweir ( rType 324*cdf0e10cSrcweir , static_cast<lang::XTypeProvider*> ( this ) 325*cdf0e10cSrcweir , static_cast<embed::XStorage*> ( this ) 326*cdf0e10cSrcweir , static_cast<embed::XHierarchicalStorageAccess*> ( this ) 327*cdf0e10cSrcweir , static_cast<container::XNameAccess*> ( this ) 328*cdf0e10cSrcweir , static_cast<container::XElementAccess*> ( this ) 329*cdf0e10cSrcweir , static_cast<lang::XComponent*> ( this ) 330*cdf0e10cSrcweir , static_cast<beans::XPropertySet*> ( this ) ); 331*cdf0e10cSrcweir 332*cdf0e10cSrcweir if ( aReturn.hasValue() == sal_True ) 333*cdf0e10cSrcweir return aReturn ; 334*cdf0e10cSrcweir 335*cdf0e10cSrcweir return OWeakObject::queryInterface( rType ); 336*cdf0e10cSrcweir } 337*cdf0e10cSrcweir 338*cdf0e10cSrcweir //----------------------------------------------- 339*cdf0e10cSrcweir void SAL_CALL FSStorage::acquire() throw() 340*cdf0e10cSrcweir { 341*cdf0e10cSrcweir OWeakObject::acquire(); 342*cdf0e10cSrcweir } 343*cdf0e10cSrcweir 344*cdf0e10cSrcweir //----------------------------------------------- 345*cdf0e10cSrcweir void SAL_CALL FSStorage::release() throw() 346*cdf0e10cSrcweir { 347*cdf0e10cSrcweir OWeakObject::release(); 348*cdf0e10cSrcweir } 349*cdf0e10cSrcweir 350*cdf0e10cSrcweir //____________________________________________________________________________________________________ 351*cdf0e10cSrcweir // XTypeProvider 352*cdf0e10cSrcweir //____________________________________________________________________________________________________ 353*cdf0e10cSrcweir 354*cdf0e10cSrcweir //----------------------------------------------- 355*cdf0e10cSrcweir uno::Sequence< uno::Type > SAL_CALL FSStorage::getTypes() 356*cdf0e10cSrcweir throw( uno::RuntimeException ) 357*cdf0e10cSrcweir { 358*cdf0e10cSrcweir if ( m_pImpl->m_pTypeCollection == NULL ) 359*cdf0e10cSrcweir { 360*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 361*cdf0e10cSrcweir 362*cdf0e10cSrcweir if ( m_pImpl->m_pTypeCollection == NULL ) 363*cdf0e10cSrcweir { 364*cdf0e10cSrcweir m_pImpl->m_pTypeCollection = new ::cppu::OTypeCollection 365*cdf0e10cSrcweir ( ::getCppuType( ( const uno::Reference< lang::XTypeProvider >* )NULL ) 366*cdf0e10cSrcweir , ::getCppuType( ( const uno::Reference< embed::XStorage >* )NULL ) 367*cdf0e10cSrcweir , ::getCppuType( ( const uno::Reference< embed::XHierarchicalStorageAccess >* )NULL ) 368*cdf0e10cSrcweir , ::getCppuType( ( const uno::Reference< beans::XPropertySet >* )NULL ) ); 369*cdf0e10cSrcweir } 370*cdf0e10cSrcweir } 371*cdf0e10cSrcweir 372*cdf0e10cSrcweir return m_pImpl->m_pTypeCollection->getTypes() ; 373*cdf0e10cSrcweir } 374*cdf0e10cSrcweir 375*cdf0e10cSrcweir //----------------------------------------------- 376*cdf0e10cSrcweir uno::Sequence< sal_Int8 > SAL_CALL FSStorage::getImplementationId() 377*cdf0e10cSrcweir throw( uno::RuntimeException ) 378*cdf0e10cSrcweir { 379*cdf0e10cSrcweir static ::cppu::OImplementationId* pID = NULL ; 380*cdf0e10cSrcweir 381*cdf0e10cSrcweir if ( pID == NULL ) 382*cdf0e10cSrcweir { 383*cdf0e10cSrcweir ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ) ; 384*cdf0e10cSrcweir 385*cdf0e10cSrcweir if ( pID == NULL ) 386*cdf0e10cSrcweir { 387*cdf0e10cSrcweir static ::cppu::OImplementationId aID( sal_False ) ; 388*cdf0e10cSrcweir pID = &aID ; 389*cdf0e10cSrcweir } 390*cdf0e10cSrcweir } 391*cdf0e10cSrcweir 392*cdf0e10cSrcweir return pID->getImplementationId() ; 393*cdf0e10cSrcweir 394*cdf0e10cSrcweir } 395*cdf0e10cSrcweir 396*cdf0e10cSrcweir //____________________________________________________________________________________________________ 397*cdf0e10cSrcweir // XStorage 398*cdf0e10cSrcweir //____________________________________________________________________________________________________ 399*cdf0e10cSrcweir 400*cdf0e10cSrcweir //----------------------------------------------- 401*cdf0e10cSrcweir void SAL_CALL FSStorage::copyToStorage( const uno::Reference< embed::XStorage >& xDest ) 402*cdf0e10cSrcweir throw ( embed::InvalidStorageException, 403*cdf0e10cSrcweir io::IOException, 404*cdf0e10cSrcweir lang::IllegalArgumentException, 405*cdf0e10cSrcweir embed::StorageWrappedTargetException, 406*cdf0e10cSrcweir uno::RuntimeException ) 407*cdf0e10cSrcweir { 408*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 409*cdf0e10cSrcweir 410*cdf0e10cSrcweir if ( !m_pImpl ) 411*cdf0e10cSrcweir throw lang::DisposedException(); 412*cdf0e10cSrcweir 413*cdf0e10cSrcweir if ( !xDest.is() || xDest == uno::Reference< uno::XInterface >( static_cast< OWeakObject*> ( this ), uno::UNO_QUERY ) ) 414*cdf0e10cSrcweir throw lang::IllegalArgumentException(); // TODO: 415*cdf0e10cSrcweir 416*cdf0e10cSrcweir if ( !GetContent() ) 417*cdf0e10cSrcweir throw io::IOException(); // TODO: error handling 418*cdf0e10cSrcweir 419*cdf0e10cSrcweir try 420*cdf0e10cSrcweir { 421*cdf0e10cSrcweir CopyContentToStorage_Impl( GetContent(), xDest ); 422*cdf0e10cSrcweir } 423*cdf0e10cSrcweir catch( embed::InvalidStorageException& ) 424*cdf0e10cSrcweir { 425*cdf0e10cSrcweir throw; 426*cdf0e10cSrcweir } 427*cdf0e10cSrcweir catch( lang::IllegalArgumentException& ) 428*cdf0e10cSrcweir { 429*cdf0e10cSrcweir throw; 430*cdf0e10cSrcweir } 431*cdf0e10cSrcweir catch( embed::StorageWrappedTargetException& ) 432*cdf0e10cSrcweir { 433*cdf0e10cSrcweir throw; 434*cdf0e10cSrcweir } 435*cdf0e10cSrcweir catch( io::IOException& ) 436*cdf0e10cSrcweir { 437*cdf0e10cSrcweir throw; 438*cdf0e10cSrcweir } 439*cdf0e10cSrcweir catch( uno::RuntimeException& ) 440*cdf0e10cSrcweir { 441*cdf0e10cSrcweir throw; 442*cdf0e10cSrcweir } 443*cdf0e10cSrcweir catch( uno::Exception& ) 444*cdf0e10cSrcweir { 445*cdf0e10cSrcweir uno::Any aCaught( ::cppu::getCaughtException() ); 446*cdf0e10cSrcweir throw embed::StorageWrappedTargetException( ::rtl::OUString::createFromAscii( "Can't copy raw stream" ), 447*cdf0e10cSrcweir uno::Reference< io::XInputStream >(), 448*cdf0e10cSrcweir aCaught ); 449*cdf0e10cSrcweir } 450*cdf0e10cSrcweir } 451*cdf0e10cSrcweir 452*cdf0e10cSrcweir //----------------------------------------------- 453*cdf0e10cSrcweir uno::Reference< io::XStream > SAL_CALL FSStorage::openStreamElement( 454*cdf0e10cSrcweir const ::rtl::OUString& aStreamName, sal_Int32 nOpenMode ) 455*cdf0e10cSrcweir throw ( embed::InvalidStorageException, 456*cdf0e10cSrcweir lang::IllegalArgumentException, 457*cdf0e10cSrcweir packages::WrongPasswordException, 458*cdf0e10cSrcweir io::IOException, 459*cdf0e10cSrcweir embed::StorageWrappedTargetException, 460*cdf0e10cSrcweir uno::RuntimeException ) 461*cdf0e10cSrcweir { 462*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 463*cdf0e10cSrcweir 464*cdf0e10cSrcweir if ( !m_pImpl ) 465*cdf0e10cSrcweir throw lang::DisposedException(); 466*cdf0e10cSrcweir 467*cdf0e10cSrcweir if ( !GetContent() ) 468*cdf0e10cSrcweir throw io::IOException(); // TODO: error handling 469*cdf0e10cSrcweir 470*cdf0e10cSrcweir // TODO/LATER: may need possibility to create folder if it was removed, since the folder can not be locked 471*cdf0e10cSrcweir INetURLObject aFileURL( m_pImpl->m_aURL ); 472*cdf0e10cSrcweir aFileURL.Append( aStreamName ); 473*cdf0e10cSrcweir 474*cdf0e10cSrcweir if ( ::utl::UCBContentHelper::IsFolder( aFileURL.GetMainURL( INetURLObject::NO_DECODE ) ) ) 475*cdf0e10cSrcweir throw io::IOException(); 476*cdf0e10cSrcweir 477*cdf0e10cSrcweir if ( ( nOpenMode & embed::ElementModes::NOCREATE ) 478*cdf0e10cSrcweir && !::utl::UCBContentHelper::IsDocument( aFileURL.GetMainURL( INetURLObject::NO_DECODE ) ) ) 479*cdf0e10cSrcweir throw io::IOException(); // TODO: 480*cdf0e10cSrcweir 481*cdf0e10cSrcweir uno::Reference< ucb::XCommandEnvironment > xDummyEnv; // TODO: provide InteractionHandler if any 482*cdf0e10cSrcweir uno::Reference< io::XStream > xResult; 483*cdf0e10cSrcweir try 484*cdf0e10cSrcweir { 485*cdf0e10cSrcweir if ( nOpenMode & embed::ElementModes::WRITE ) 486*cdf0e10cSrcweir { 487*cdf0e10cSrcweir if ( isLocalFile_Impl( aFileURL.GetMainURL( INetURLObject::NO_DECODE ) ) ) 488*cdf0e10cSrcweir { 489*cdf0e10cSrcweir uno::Reference< ucb::XSimpleFileAccess > xSimpleFileAccess( 490*cdf0e10cSrcweir m_pImpl->m_xFactory->createInstance( 491*cdf0e10cSrcweir ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ucb.SimpleFileAccess" ) ) ), 492*cdf0e10cSrcweir uno::UNO_QUERY_THROW ); 493*cdf0e10cSrcweir xResult = xSimpleFileAccess->openFileReadWrite( aFileURL.GetMainURL( INetURLObject::NO_DECODE ) ); 494*cdf0e10cSrcweir } 495*cdf0e10cSrcweir else 496*cdf0e10cSrcweir { 497*cdf0e10cSrcweir // TODO: test whether it really works for http and fwp 498*cdf0e10cSrcweir SvStream* pStream = ::utl::UcbStreamHelper::CreateStream( aFileURL.GetMainURL( INetURLObject::NO_DECODE ), 499*cdf0e10cSrcweir STREAM_STD_WRITE ); 500*cdf0e10cSrcweir if ( pStream ) 501*cdf0e10cSrcweir { 502*cdf0e10cSrcweir if ( !pStream->GetError() ) 503*cdf0e10cSrcweir xResult = uno::Reference < io::XStream >( new ::utl::OStreamWrapper( *pStream ) ); 504*cdf0e10cSrcweir else 505*cdf0e10cSrcweir delete pStream; 506*cdf0e10cSrcweir } 507*cdf0e10cSrcweir } 508*cdf0e10cSrcweir 509*cdf0e10cSrcweir if ( !xResult.is() ) 510*cdf0e10cSrcweir throw io::IOException(); 511*cdf0e10cSrcweir 512*cdf0e10cSrcweir if ( ( nOpenMode & embed::ElementModes::TRUNCATE ) ) 513*cdf0e10cSrcweir { 514*cdf0e10cSrcweir uno::Reference< io::XTruncate > xTrunc( xResult->getOutputStream(), uno::UNO_QUERY_THROW ); 515*cdf0e10cSrcweir xTrunc->truncate(); 516*cdf0e10cSrcweir } 517*cdf0e10cSrcweir } 518*cdf0e10cSrcweir else 519*cdf0e10cSrcweir { 520*cdf0e10cSrcweir if ( ( nOpenMode & embed::ElementModes::TRUNCATE ) 521*cdf0e10cSrcweir || !::utl::UCBContentHelper::IsDocument( aFileURL.GetMainURL( INetURLObject::NO_DECODE ) ) ) 522*cdf0e10cSrcweir throw io::IOException(); // TODO: access denied 523*cdf0e10cSrcweir 524*cdf0e10cSrcweir ::ucbhelper::Content aResultContent( aFileURL.GetMainURL( INetURLObject::NO_DECODE ), xDummyEnv ); 525*cdf0e10cSrcweir uno::Reference< io::XInputStream > xInStream = aResultContent.openStream(); 526*cdf0e10cSrcweir xResult = static_cast< io::XStream* >( new OFSInputStreamContainer( xInStream ) ); 527*cdf0e10cSrcweir } 528*cdf0e10cSrcweir } 529*cdf0e10cSrcweir catch( embed::InvalidStorageException& ) 530*cdf0e10cSrcweir { 531*cdf0e10cSrcweir throw; 532*cdf0e10cSrcweir } 533*cdf0e10cSrcweir catch( lang::IllegalArgumentException& ) 534*cdf0e10cSrcweir { 535*cdf0e10cSrcweir throw; 536*cdf0e10cSrcweir } 537*cdf0e10cSrcweir catch( packages::WrongPasswordException& ) 538*cdf0e10cSrcweir { 539*cdf0e10cSrcweir throw; 540*cdf0e10cSrcweir } 541*cdf0e10cSrcweir catch( embed::StorageWrappedTargetException& ) 542*cdf0e10cSrcweir { 543*cdf0e10cSrcweir throw; 544*cdf0e10cSrcweir } 545*cdf0e10cSrcweir catch( io::IOException& ) 546*cdf0e10cSrcweir { 547*cdf0e10cSrcweir throw; 548*cdf0e10cSrcweir } 549*cdf0e10cSrcweir catch( uno::RuntimeException& ) 550*cdf0e10cSrcweir { 551*cdf0e10cSrcweir throw; 552*cdf0e10cSrcweir } 553*cdf0e10cSrcweir catch( uno::Exception& ) 554*cdf0e10cSrcweir { 555*cdf0e10cSrcweir uno::Any aCaught( ::cppu::getCaughtException() ); 556*cdf0e10cSrcweir throw embed::StorageWrappedTargetException( ::rtl::OUString::createFromAscii( "Can't copy raw stream" ), 557*cdf0e10cSrcweir uno::Reference< io::XInputStream >(), 558*cdf0e10cSrcweir aCaught ); 559*cdf0e10cSrcweir } 560*cdf0e10cSrcweir 561*cdf0e10cSrcweir return xResult; 562*cdf0e10cSrcweir } 563*cdf0e10cSrcweir 564*cdf0e10cSrcweir //----------------------------------------------- 565*cdf0e10cSrcweir uno::Reference< io::XStream > SAL_CALL FSStorage::openEncryptedStreamElement( 566*cdf0e10cSrcweir const ::rtl::OUString&, sal_Int32, const ::rtl::OUString& ) 567*cdf0e10cSrcweir throw ( embed::InvalidStorageException, 568*cdf0e10cSrcweir lang::IllegalArgumentException, 569*cdf0e10cSrcweir packages::NoEncryptionException, 570*cdf0e10cSrcweir packages::WrongPasswordException, 571*cdf0e10cSrcweir io::IOException, 572*cdf0e10cSrcweir embed::StorageWrappedTargetException, 573*cdf0e10cSrcweir uno::RuntimeException ) 574*cdf0e10cSrcweir { 575*cdf0e10cSrcweir throw packages::NoEncryptionException(); 576*cdf0e10cSrcweir } 577*cdf0e10cSrcweir 578*cdf0e10cSrcweir //----------------------------------------------- 579*cdf0e10cSrcweir uno::Reference< embed::XStorage > SAL_CALL FSStorage::openStorageElement( 580*cdf0e10cSrcweir const ::rtl::OUString& aStorName, sal_Int32 nStorageMode ) 581*cdf0e10cSrcweir throw ( embed::InvalidStorageException, 582*cdf0e10cSrcweir lang::IllegalArgumentException, 583*cdf0e10cSrcweir io::IOException, 584*cdf0e10cSrcweir embed::StorageWrappedTargetException, 585*cdf0e10cSrcweir uno::RuntimeException ) 586*cdf0e10cSrcweir { 587*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 588*cdf0e10cSrcweir 589*cdf0e10cSrcweir if ( !m_pImpl ) 590*cdf0e10cSrcweir throw lang::DisposedException(); 591*cdf0e10cSrcweir 592*cdf0e10cSrcweir if ( !GetContent() ) 593*cdf0e10cSrcweir throw io::IOException(); // TODO: error handling 594*cdf0e10cSrcweir 595*cdf0e10cSrcweir if ( ( nStorageMode & embed::ElementModes::WRITE ) 596*cdf0e10cSrcweir && !( m_pImpl->m_nMode & embed::ElementModes::WRITE ) ) 597*cdf0e10cSrcweir throw io::IOException(); // TODO: error handling 598*cdf0e10cSrcweir 599*cdf0e10cSrcweir // TODO/LATER: may need possibility to create folder if it was removed, since the folder can not be locked 600*cdf0e10cSrcweir INetURLObject aFolderURL( m_pImpl->m_aURL ); 601*cdf0e10cSrcweir aFolderURL.Append( aStorName ); 602*cdf0e10cSrcweir 603*cdf0e10cSrcweir sal_Bool bFolderExists = ::utl::UCBContentHelper::IsFolder( aFolderURL.GetMainURL( INetURLObject::NO_DECODE ) ); 604*cdf0e10cSrcweir if ( !bFolderExists && ::utl::UCBContentHelper::IsDocument( aFolderURL.GetMainURL( INetURLObject::NO_DECODE ) ) ) 605*cdf0e10cSrcweir throw io::IOException(); // TODO: 606*cdf0e10cSrcweir 607*cdf0e10cSrcweir if ( ( nStorageMode & embed::ElementModes::NOCREATE ) && !bFolderExists ) 608*cdf0e10cSrcweir throw io::IOException(); // TODO: 609*cdf0e10cSrcweir 610*cdf0e10cSrcweir uno::Reference< ucb::XCommandEnvironment > xDummyEnv; // TODO: provide InteractionHandler if any 611*cdf0e10cSrcweir uno::Reference< embed::XStorage > xResult; 612*cdf0e10cSrcweir try 613*cdf0e10cSrcweir { 614*cdf0e10cSrcweir if ( nStorageMode & embed::ElementModes::WRITE ) 615*cdf0e10cSrcweir { 616*cdf0e10cSrcweir if ( ( nStorageMode & embed::ElementModes::TRUNCATE ) && bFolderExists ) 617*cdf0e10cSrcweir { 618*cdf0e10cSrcweir ::utl::UCBContentHelper::Kill( aFolderURL.GetMainURL( INetURLObject::NO_DECODE ) ); 619*cdf0e10cSrcweir bFolderExists = 620*cdf0e10cSrcweir MakeFolderNoUI( aFolderURL.GetMainURL( INetURLObject::NO_DECODE ), sal_True ); // TODO: not atomar :( 621*cdf0e10cSrcweir } 622*cdf0e10cSrcweir else if ( !bFolderExists ) 623*cdf0e10cSrcweir { 624*cdf0e10cSrcweir bFolderExists = 625*cdf0e10cSrcweir MakeFolderNoUI( aFolderURL.GetMainURL( INetURLObject::NO_DECODE ), sal_True ); // TODO: not atomar :( 626*cdf0e10cSrcweir } 627*cdf0e10cSrcweir } 628*cdf0e10cSrcweir else if ( ( nStorageMode & embed::ElementModes::TRUNCATE ) ) 629*cdf0e10cSrcweir throw io::IOException(); // TODO: access denied 630*cdf0e10cSrcweir 631*cdf0e10cSrcweir if ( !bFolderExists ) 632*cdf0e10cSrcweir throw io::IOException(); // there is no such folder 633*cdf0e10cSrcweir 634*cdf0e10cSrcweir ::ucbhelper::Content aResultContent( aFolderURL.GetMainURL( INetURLObject::NO_DECODE ), xDummyEnv ); 635*cdf0e10cSrcweir xResult = uno::Reference< embed::XStorage >( 636*cdf0e10cSrcweir static_cast< OWeakObject* >( new FSStorage( aResultContent, 637*cdf0e10cSrcweir nStorageMode, 638*cdf0e10cSrcweir uno::Sequence< beans::PropertyValue >(), 639*cdf0e10cSrcweir m_pImpl->m_xFactory ) ), 640*cdf0e10cSrcweir uno::UNO_QUERY ); 641*cdf0e10cSrcweir } 642*cdf0e10cSrcweir catch( embed::InvalidStorageException& ) 643*cdf0e10cSrcweir { 644*cdf0e10cSrcweir throw; 645*cdf0e10cSrcweir } 646*cdf0e10cSrcweir catch( lang::IllegalArgumentException& ) 647*cdf0e10cSrcweir { 648*cdf0e10cSrcweir throw; 649*cdf0e10cSrcweir } 650*cdf0e10cSrcweir catch( embed::StorageWrappedTargetException& ) 651*cdf0e10cSrcweir { 652*cdf0e10cSrcweir throw; 653*cdf0e10cSrcweir } 654*cdf0e10cSrcweir catch( io::IOException& ) 655*cdf0e10cSrcweir { 656*cdf0e10cSrcweir throw; 657*cdf0e10cSrcweir } 658*cdf0e10cSrcweir catch( uno::RuntimeException& ) 659*cdf0e10cSrcweir { 660*cdf0e10cSrcweir throw; 661*cdf0e10cSrcweir } 662*cdf0e10cSrcweir catch( uno::Exception& ) 663*cdf0e10cSrcweir { 664*cdf0e10cSrcweir uno::Any aCaught( ::cppu::getCaughtException() ); 665*cdf0e10cSrcweir throw embed::StorageWrappedTargetException( ::rtl::OUString::createFromAscii( "Can't copy raw stream" ), 666*cdf0e10cSrcweir uno::Reference< io::XInputStream >(), 667*cdf0e10cSrcweir aCaught ); 668*cdf0e10cSrcweir } 669*cdf0e10cSrcweir 670*cdf0e10cSrcweir return xResult; 671*cdf0e10cSrcweir } 672*cdf0e10cSrcweir 673*cdf0e10cSrcweir //----------------------------------------------- 674*cdf0e10cSrcweir uno::Reference< io::XStream > SAL_CALL FSStorage::cloneStreamElement( const ::rtl::OUString& aStreamName ) 675*cdf0e10cSrcweir throw ( embed::InvalidStorageException, 676*cdf0e10cSrcweir lang::IllegalArgumentException, 677*cdf0e10cSrcweir packages::WrongPasswordException, 678*cdf0e10cSrcweir io::IOException, 679*cdf0e10cSrcweir embed::StorageWrappedTargetException, 680*cdf0e10cSrcweir uno::RuntimeException ) 681*cdf0e10cSrcweir { 682*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 683*cdf0e10cSrcweir 684*cdf0e10cSrcweir if ( !m_pImpl ) 685*cdf0e10cSrcweir throw lang::DisposedException(); 686*cdf0e10cSrcweir 687*cdf0e10cSrcweir if ( !GetContent() ) 688*cdf0e10cSrcweir throw io::IOException(); // TODO: error handling 689*cdf0e10cSrcweir 690*cdf0e10cSrcweir // TODO/LATER: may need possibility to create folder if it was removed, since the folder can not be locked 691*cdf0e10cSrcweir INetURLObject aFileURL( m_pImpl->m_aURL ); 692*cdf0e10cSrcweir aFileURL.Append( aStreamName ); 693*cdf0e10cSrcweir 694*cdf0e10cSrcweir uno::Reference < io::XStream > xTempResult; 695*cdf0e10cSrcweir try 696*cdf0e10cSrcweir { 697*cdf0e10cSrcweir uno::Reference< ucb::XCommandEnvironment > xDummyEnv; 698*cdf0e10cSrcweir ::ucbhelper::Content aResultContent( aFileURL.GetMainURL( INetURLObject::NO_DECODE ), xDummyEnv ); 699*cdf0e10cSrcweir uno::Reference< io::XInputStream > xInStream = aResultContent.openStream(); 700*cdf0e10cSrcweir 701*cdf0e10cSrcweir xTempResult = uno::Reference < io::XStream >( 702*cdf0e10cSrcweir m_pImpl->m_xFactory->createInstance ( ::rtl::OUString::createFromAscii( "com.sun.star.io.TempFile" ) ), 703*cdf0e10cSrcweir uno::UNO_QUERY_THROW ); 704*cdf0e10cSrcweir uno::Reference < io::XOutputStream > xTempOut = xTempResult->getOutputStream(); 705*cdf0e10cSrcweir uno::Reference < io::XInputStream > xTempIn = xTempResult->getInputStream(); 706*cdf0e10cSrcweir 707*cdf0e10cSrcweir if ( !xTempOut.is() || !xTempIn.is() ) 708*cdf0e10cSrcweir throw io::IOException(); 709*cdf0e10cSrcweir 710*cdf0e10cSrcweir ::comphelper::OStorageHelper::CopyInputToOutput( xInStream, xTempOut ); 711*cdf0e10cSrcweir xTempOut->closeOutput(); 712*cdf0e10cSrcweir } 713*cdf0e10cSrcweir catch( embed::InvalidStorageException& ) 714*cdf0e10cSrcweir { 715*cdf0e10cSrcweir throw; 716*cdf0e10cSrcweir } 717*cdf0e10cSrcweir catch( lang::IllegalArgumentException& ) 718*cdf0e10cSrcweir { 719*cdf0e10cSrcweir throw; 720*cdf0e10cSrcweir } 721*cdf0e10cSrcweir catch( packages::WrongPasswordException& ) 722*cdf0e10cSrcweir { 723*cdf0e10cSrcweir throw; 724*cdf0e10cSrcweir } 725*cdf0e10cSrcweir catch( io::IOException& ) 726*cdf0e10cSrcweir { 727*cdf0e10cSrcweir throw; 728*cdf0e10cSrcweir } 729*cdf0e10cSrcweir catch( embed::StorageWrappedTargetException& ) 730*cdf0e10cSrcweir { 731*cdf0e10cSrcweir throw; 732*cdf0e10cSrcweir } 733*cdf0e10cSrcweir catch( uno::RuntimeException& ) 734*cdf0e10cSrcweir { 735*cdf0e10cSrcweir throw; 736*cdf0e10cSrcweir } 737*cdf0e10cSrcweir catch( uno::Exception& ) 738*cdf0e10cSrcweir { 739*cdf0e10cSrcweir uno::Any aCaught( ::cppu::getCaughtException() ); 740*cdf0e10cSrcweir throw embed::StorageWrappedTargetException( ::rtl::OUString::createFromAscii( "Can't copy raw stream" ), 741*cdf0e10cSrcweir uno::Reference< io::XInputStream >(), 742*cdf0e10cSrcweir aCaught ); 743*cdf0e10cSrcweir } 744*cdf0e10cSrcweir 745*cdf0e10cSrcweir return xTempResult; 746*cdf0e10cSrcweir } 747*cdf0e10cSrcweir 748*cdf0e10cSrcweir //----------------------------------------------- 749*cdf0e10cSrcweir uno::Reference< io::XStream > SAL_CALL FSStorage::cloneEncryptedStreamElement( 750*cdf0e10cSrcweir const ::rtl::OUString&, 751*cdf0e10cSrcweir const ::rtl::OUString& ) 752*cdf0e10cSrcweir throw ( embed::InvalidStorageException, 753*cdf0e10cSrcweir lang::IllegalArgumentException, 754*cdf0e10cSrcweir packages::NoEncryptionException, 755*cdf0e10cSrcweir packages::WrongPasswordException, 756*cdf0e10cSrcweir io::IOException, 757*cdf0e10cSrcweir embed::StorageWrappedTargetException, 758*cdf0e10cSrcweir uno::RuntimeException ) 759*cdf0e10cSrcweir { 760*cdf0e10cSrcweir throw packages::NoEncryptionException(); 761*cdf0e10cSrcweir } 762*cdf0e10cSrcweir 763*cdf0e10cSrcweir //----------------------------------------------- 764*cdf0e10cSrcweir void SAL_CALL FSStorage::copyLastCommitTo( 765*cdf0e10cSrcweir const uno::Reference< embed::XStorage >& xTargetStorage ) 766*cdf0e10cSrcweir throw ( embed::InvalidStorageException, 767*cdf0e10cSrcweir lang::IllegalArgumentException, 768*cdf0e10cSrcweir io::IOException, 769*cdf0e10cSrcweir embed::StorageWrappedTargetException, 770*cdf0e10cSrcweir uno::RuntimeException ) 771*cdf0e10cSrcweir { 772*cdf0e10cSrcweir copyToStorage( xTargetStorage ); 773*cdf0e10cSrcweir } 774*cdf0e10cSrcweir 775*cdf0e10cSrcweir //----------------------------------------------- 776*cdf0e10cSrcweir void SAL_CALL FSStorage::copyStorageElementLastCommitTo( 777*cdf0e10cSrcweir const ::rtl::OUString& aStorName, 778*cdf0e10cSrcweir const uno::Reference< embed::XStorage >& xTargetStorage ) 779*cdf0e10cSrcweir throw ( embed::InvalidStorageException, 780*cdf0e10cSrcweir lang::IllegalArgumentException, 781*cdf0e10cSrcweir io::IOException, 782*cdf0e10cSrcweir embed::StorageWrappedTargetException, 783*cdf0e10cSrcweir uno::RuntimeException ) 784*cdf0e10cSrcweir { 785*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 786*cdf0e10cSrcweir 787*cdf0e10cSrcweir if ( !m_pImpl ) 788*cdf0e10cSrcweir throw lang::DisposedException(); 789*cdf0e10cSrcweir 790*cdf0e10cSrcweir uno::Reference< embed::XStorage > xSourceStor( openStorageElement( aStorName, embed::ElementModes::READ ), 791*cdf0e10cSrcweir uno::UNO_QUERY_THROW ); 792*cdf0e10cSrcweir xSourceStor->copyToStorage( xTargetStorage ); 793*cdf0e10cSrcweir } 794*cdf0e10cSrcweir 795*cdf0e10cSrcweir //----------------------------------------------- 796*cdf0e10cSrcweir sal_Bool SAL_CALL FSStorage::isStreamElement( const ::rtl::OUString& aElementName ) 797*cdf0e10cSrcweir throw ( embed::InvalidStorageException, 798*cdf0e10cSrcweir lang::IllegalArgumentException, 799*cdf0e10cSrcweir container::NoSuchElementException, 800*cdf0e10cSrcweir uno::RuntimeException ) 801*cdf0e10cSrcweir { 802*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 803*cdf0e10cSrcweir 804*cdf0e10cSrcweir if ( !m_pImpl ) 805*cdf0e10cSrcweir throw lang::DisposedException(); 806*cdf0e10cSrcweir 807*cdf0e10cSrcweir if ( !GetContent() ) 808*cdf0e10cSrcweir throw embed::InvalidStorageException(); // TODO: error handling 809*cdf0e10cSrcweir 810*cdf0e10cSrcweir INetURLObject aURL( m_pImpl->m_aURL ); 811*cdf0e10cSrcweir aURL.Append( aElementName ); 812*cdf0e10cSrcweir 813*cdf0e10cSrcweir return !::utl::UCBContentHelper::IsFolder( aURL.GetMainURL( INetURLObject::NO_DECODE ) ); 814*cdf0e10cSrcweir } 815*cdf0e10cSrcweir 816*cdf0e10cSrcweir //----------------------------------------------- 817*cdf0e10cSrcweir sal_Bool SAL_CALL FSStorage::isStorageElement( const ::rtl::OUString& aElementName ) 818*cdf0e10cSrcweir throw ( embed::InvalidStorageException, 819*cdf0e10cSrcweir lang::IllegalArgumentException, 820*cdf0e10cSrcweir container::NoSuchElementException, 821*cdf0e10cSrcweir uno::RuntimeException ) 822*cdf0e10cSrcweir { 823*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 824*cdf0e10cSrcweir 825*cdf0e10cSrcweir if ( !m_pImpl ) 826*cdf0e10cSrcweir throw lang::DisposedException(); 827*cdf0e10cSrcweir 828*cdf0e10cSrcweir if ( !GetContent() ) 829*cdf0e10cSrcweir throw embed::InvalidStorageException(); // TODO: error handling 830*cdf0e10cSrcweir 831*cdf0e10cSrcweir INetURLObject aURL( m_pImpl->m_aURL ); 832*cdf0e10cSrcweir aURL.Append( aElementName ); 833*cdf0e10cSrcweir 834*cdf0e10cSrcweir return ::utl::UCBContentHelper::IsFolder( aURL.GetMainURL( INetURLObject::NO_DECODE ) ); 835*cdf0e10cSrcweir } 836*cdf0e10cSrcweir 837*cdf0e10cSrcweir //----------------------------------------------- 838*cdf0e10cSrcweir void SAL_CALL FSStorage::removeElement( const ::rtl::OUString& aElementName ) 839*cdf0e10cSrcweir throw ( embed::InvalidStorageException, 840*cdf0e10cSrcweir lang::IllegalArgumentException, 841*cdf0e10cSrcweir container::NoSuchElementException, 842*cdf0e10cSrcweir io::IOException, 843*cdf0e10cSrcweir embed::StorageWrappedTargetException, 844*cdf0e10cSrcweir uno::RuntimeException ) 845*cdf0e10cSrcweir { 846*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 847*cdf0e10cSrcweir 848*cdf0e10cSrcweir if ( !m_pImpl ) 849*cdf0e10cSrcweir throw lang::DisposedException(); 850*cdf0e10cSrcweir 851*cdf0e10cSrcweir if ( !GetContent() ) 852*cdf0e10cSrcweir throw io::IOException(); // TODO: error handling 853*cdf0e10cSrcweir 854*cdf0e10cSrcweir INetURLObject aURL( m_pImpl->m_aURL ); 855*cdf0e10cSrcweir aURL.Append( aElementName ); 856*cdf0e10cSrcweir 857*cdf0e10cSrcweir if ( !::utl::UCBContentHelper::IsFolder( aURL.GetMainURL( INetURLObject::NO_DECODE ) ) 858*cdf0e10cSrcweir && !::utl::UCBContentHelper::IsDocument( aURL.GetMainURL( INetURLObject::NO_DECODE ) ) ) 859*cdf0e10cSrcweir throw container::NoSuchElementException(); // TODO: 860*cdf0e10cSrcweir 861*cdf0e10cSrcweir ::utl::UCBContentHelper::Kill( aURL.GetMainURL( INetURLObject::NO_DECODE ) ); 862*cdf0e10cSrcweir } 863*cdf0e10cSrcweir 864*cdf0e10cSrcweir //----------------------------------------------- 865*cdf0e10cSrcweir void SAL_CALL FSStorage::renameElement( const ::rtl::OUString& aElementName, const ::rtl::OUString& aNewName ) 866*cdf0e10cSrcweir throw ( embed::InvalidStorageException, 867*cdf0e10cSrcweir lang::IllegalArgumentException, 868*cdf0e10cSrcweir container::NoSuchElementException, 869*cdf0e10cSrcweir container::ElementExistException, 870*cdf0e10cSrcweir io::IOException, 871*cdf0e10cSrcweir embed::StorageWrappedTargetException, 872*cdf0e10cSrcweir uno::RuntimeException ) 873*cdf0e10cSrcweir { 874*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 875*cdf0e10cSrcweir 876*cdf0e10cSrcweir if ( !m_pImpl ) 877*cdf0e10cSrcweir throw lang::DisposedException(); 878*cdf0e10cSrcweir 879*cdf0e10cSrcweir if ( !GetContent() ) 880*cdf0e10cSrcweir throw io::IOException(); // TODO: error handling 881*cdf0e10cSrcweir 882*cdf0e10cSrcweir INetURLObject aOldURL( m_pImpl->m_aURL ); 883*cdf0e10cSrcweir aOldURL.Append( aElementName ); 884*cdf0e10cSrcweir 885*cdf0e10cSrcweir INetURLObject aNewURL( m_pImpl->m_aURL ); 886*cdf0e10cSrcweir aNewURL.Append( aNewName ); 887*cdf0e10cSrcweir 888*cdf0e10cSrcweir if ( !::utl::UCBContentHelper::IsFolder( aOldURL.GetMainURL( INetURLObject::NO_DECODE ) ) 889*cdf0e10cSrcweir && !::utl::UCBContentHelper::IsDocument( aOldURL.GetMainURL( INetURLObject::NO_DECODE ) ) ) 890*cdf0e10cSrcweir throw container::NoSuchElementException(); // TODO: 891*cdf0e10cSrcweir 892*cdf0e10cSrcweir if ( ::utl::UCBContentHelper::IsFolder( aNewURL.GetMainURL( INetURLObject::NO_DECODE ) ) 893*cdf0e10cSrcweir || ::utl::UCBContentHelper::IsDocument( aNewURL.GetMainURL( INetURLObject::NO_DECODE ) ) ) 894*cdf0e10cSrcweir throw container::ElementExistException(); // TODO: 895*cdf0e10cSrcweir 896*cdf0e10cSrcweir try 897*cdf0e10cSrcweir { 898*cdf0e10cSrcweir uno::Reference< ucb::XCommandEnvironment > xDummyEnv; 899*cdf0e10cSrcweir ::ucbhelper::Content aSourceContent( aOldURL.GetMainURL( INetURLObject::NO_DECODE ), xDummyEnv ); 900*cdf0e10cSrcweir 901*cdf0e10cSrcweir if ( !GetContent()->transferContent( aSourceContent, 902*cdf0e10cSrcweir ::ucbhelper::InsertOperation_MOVE, 903*cdf0e10cSrcweir aNewName, 904*cdf0e10cSrcweir ucb::NameClash::ERROR ) ) 905*cdf0e10cSrcweir throw io::IOException(); // TODO: error handling 906*cdf0e10cSrcweir } 907*cdf0e10cSrcweir catch( embed::InvalidStorageException& ) 908*cdf0e10cSrcweir { 909*cdf0e10cSrcweir throw; 910*cdf0e10cSrcweir } 911*cdf0e10cSrcweir catch( lang::IllegalArgumentException& ) 912*cdf0e10cSrcweir { 913*cdf0e10cSrcweir throw; 914*cdf0e10cSrcweir } 915*cdf0e10cSrcweir catch( container::NoSuchElementException& ) 916*cdf0e10cSrcweir { 917*cdf0e10cSrcweir throw; 918*cdf0e10cSrcweir } 919*cdf0e10cSrcweir catch( container::ElementExistException& ) 920*cdf0e10cSrcweir { 921*cdf0e10cSrcweir throw; 922*cdf0e10cSrcweir } 923*cdf0e10cSrcweir catch( io::IOException& ) 924*cdf0e10cSrcweir { 925*cdf0e10cSrcweir throw; 926*cdf0e10cSrcweir } 927*cdf0e10cSrcweir catch( embed::StorageWrappedTargetException& ) 928*cdf0e10cSrcweir { 929*cdf0e10cSrcweir throw; 930*cdf0e10cSrcweir } 931*cdf0e10cSrcweir catch( uno::RuntimeException& ) 932*cdf0e10cSrcweir { 933*cdf0e10cSrcweir throw; 934*cdf0e10cSrcweir } 935*cdf0e10cSrcweir catch( uno::Exception& ) 936*cdf0e10cSrcweir { 937*cdf0e10cSrcweir uno::Any aCaught( ::cppu::getCaughtException() ); 938*cdf0e10cSrcweir throw embed::StorageWrappedTargetException( ::rtl::OUString::createFromAscii( "Can't copy raw stream" ), 939*cdf0e10cSrcweir uno::Reference< io::XInputStream >(), 940*cdf0e10cSrcweir aCaught ); 941*cdf0e10cSrcweir } 942*cdf0e10cSrcweir } 943*cdf0e10cSrcweir 944*cdf0e10cSrcweir //----------------------------------------------- 945*cdf0e10cSrcweir void SAL_CALL FSStorage::copyElementTo( const ::rtl::OUString& aElementName, 946*cdf0e10cSrcweir const uno::Reference< embed::XStorage >& xDest, 947*cdf0e10cSrcweir const ::rtl::OUString& aNewName ) 948*cdf0e10cSrcweir throw ( embed::InvalidStorageException, 949*cdf0e10cSrcweir lang::IllegalArgumentException, 950*cdf0e10cSrcweir container::NoSuchElementException, 951*cdf0e10cSrcweir container::ElementExistException, 952*cdf0e10cSrcweir io::IOException, 953*cdf0e10cSrcweir embed::StorageWrappedTargetException, 954*cdf0e10cSrcweir uno::RuntimeException ) 955*cdf0e10cSrcweir { 956*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 957*cdf0e10cSrcweir 958*cdf0e10cSrcweir if ( !m_pImpl ) 959*cdf0e10cSrcweir throw lang::DisposedException(); 960*cdf0e10cSrcweir 961*cdf0e10cSrcweir if ( !xDest.is() ) 962*cdf0e10cSrcweir throw uno::RuntimeException(); 963*cdf0e10cSrcweir 964*cdf0e10cSrcweir if ( !GetContent() ) 965*cdf0e10cSrcweir throw io::IOException(); // TODO: error handling 966*cdf0e10cSrcweir 967*cdf0e10cSrcweir INetURLObject aOwnURL( m_pImpl->m_aURL ); 968*cdf0e10cSrcweir aOwnURL.Append( aElementName ); 969*cdf0e10cSrcweir 970*cdf0e10cSrcweir if ( xDest->hasByName( aNewName ) ) 971*cdf0e10cSrcweir throw container::ElementExistException(); // TODO: 972*cdf0e10cSrcweir 973*cdf0e10cSrcweir try 974*cdf0e10cSrcweir { 975*cdf0e10cSrcweir uno::Reference< ucb::XCommandEnvironment > xDummyEnv; 976*cdf0e10cSrcweir if ( ::utl::UCBContentHelper::IsFolder( aOwnURL.GetMainURL( INetURLObject::NO_DECODE ) ) ) 977*cdf0e10cSrcweir { 978*cdf0e10cSrcweir ::ucbhelper::Content aSourceContent( aOwnURL.GetMainURL( INetURLObject::NO_DECODE ), xDummyEnv ); 979*cdf0e10cSrcweir uno::Reference< embed::XStorage > xDestSubStor( 980*cdf0e10cSrcweir xDest->openStorageElement( aNewName, embed::ElementModes::READWRITE ), 981*cdf0e10cSrcweir uno::UNO_QUERY_THROW ); 982*cdf0e10cSrcweir 983*cdf0e10cSrcweir CopyContentToStorage_Impl( &aSourceContent, xDestSubStor ); 984*cdf0e10cSrcweir } 985*cdf0e10cSrcweir else if ( ::utl::UCBContentHelper::IsDocument( aOwnURL.GetMainURL( INetURLObject::NO_DECODE ) ) ) 986*cdf0e10cSrcweir { 987*cdf0e10cSrcweir CopyStreamToSubStream( aOwnURL.GetMainURL( INetURLObject::NO_DECODE ), xDest, aNewName ); 988*cdf0e10cSrcweir } 989*cdf0e10cSrcweir else 990*cdf0e10cSrcweir throw container::NoSuchElementException(); // TODO: 991*cdf0e10cSrcweir } 992*cdf0e10cSrcweir catch( embed::InvalidStorageException& ) 993*cdf0e10cSrcweir { 994*cdf0e10cSrcweir throw; 995*cdf0e10cSrcweir } 996*cdf0e10cSrcweir catch( lang::IllegalArgumentException& ) 997*cdf0e10cSrcweir { 998*cdf0e10cSrcweir throw; 999*cdf0e10cSrcweir } 1000*cdf0e10cSrcweir catch( container::NoSuchElementException& ) 1001*cdf0e10cSrcweir { 1002*cdf0e10cSrcweir throw; 1003*cdf0e10cSrcweir } 1004*cdf0e10cSrcweir catch( container::ElementExistException& ) 1005*cdf0e10cSrcweir { 1006*cdf0e10cSrcweir throw; 1007*cdf0e10cSrcweir } 1008*cdf0e10cSrcweir catch( embed::StorageWrappedTargetException& ) 1009*cdf0e10cSrcweir { 1010*cdf0e10cSrcweir throw; 1011*cdf0e10cSrcweir } 1012*cdf0e10cSrcweir catch( io::IOException& ) 1013*cdf0e10cSrcweir { 1014*cdf0e10cSrcweir throw; 1015*cdf0e10cSrcweir } 1016*cdf0e10cSrcweir catch( uno::RuntimeException& ) 1017*cdf0e10cSrcweir { 1018*cdf0e10cSrcweir throw; 1019*cdf0e10cSrcweir } 1020*cdf0e10cSrcweir catch( uno::Exception& ) 1021*cdf0e10cSrcweir { 1022*cdf0e10cSrcweir uno::Any aCaught( ::cppu::getCaughtException() ); 1023*cdf0e10cSrcweir throw embed::StorageWrappedTargetException( ::rtl::OUString::createFromAscii( "Can't copy raw stream" ), 1024*cdf0e10cSrcweir uno::Reference< io::XInputStream >(), 1025*cdf0e10cSrcweir aCaught ); 1026*cdf0e10cSrcweir } 1027*cdf0e10cSrcweir } 1028*cdf0e10cSrcweir 1029*cdf0e10cSrcweir //----------------------------------------------- 1030*cdf0e10cSrcweir void SAL_CALL FSStorage::moveElementTo( const ::rtl::OUString& aElementName, 1031*cdf0e10cSrcweir const uno::Reference< embed::XStorage >& xDest, 1032*cdf0e10cSrcweir const ::rtl::OUString& aNewName ) 1033*cdf0e10cSrcweir throw ( embed::InvalidStorageException, 1034*cdf0e10cSrcweir lang::IllegalArgumentException, 1035*cdf0e10cSrcweir container::NoSuchElementException, 1036*cdf0e10cSrcweir container::ElementExistException, 1037*cdf0e10cSrcweir io::IOException, 1038*cdf0e10cSrcweir embed::StorageWrappedTargetException, 1039*cdf0e10cSrcweir uno::RuntimeException ) 1040*cdf0e10cSrcweir { 1041*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 1042*cdf0e10cSrcweir copyElementTo( aElementName, xDest, aNewName ); 1043*cdf0e10cSrcweir 1044*cdf0e10cSrcweir INetURLObject aOwnURL( m_pImpl->m_aURL ); 1045*cdf0e10cSrcweir aOwnURL.Append( aElementName ); 1046*cdf0e10cSrcweir if ( !::utl::UCBContentHelper::Kill( aOwnURL.GetMainURL( INetURLObject::NO_DECODE ) ) ) 1047*cdf0e10cSrcweir throw io::IOException(); // TODO: error handling 1048*cdf0e10cSrcweir } 1049*cdf0e10cSrcweir 1050*cdf0e10cSrcweir //____________________________________________________________________________________________________ 1051*cdf0e10cSrcweir // XNameAccess 1052*cdf0e10cSrcweir //____________________________________________________________________________________________________ 1053*cdf0e10cSrcweir 1054*cdf0e10cSrcweir //----------------------------------------------- 1055*cdf0e10cSrcweir uno::Any SAL_CALL FSStorage::getByName( const ::rtl::OUString& aName ) 1056*cdf0e10cSrcweir throw ( container::NoSuchElementException, 1057*cdf0e10cSrcweir lang::WrappedTargetException, 1058*cdf0e10cSrcweir uno::RuntimeException ) 1059*cdf0e10cSrcweir { 1060*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 1061*cdf0e10cSrcweir 1062*cdf0e10cSrcweir if ( !m_pImpl ) 1063*cdf0e10cSrcweir throw lang::DisposedException(); 1064*cdf0e10cSrcweir 1065*cdf0e10cSrcweir if ( !GetContent() ) 1066*cdf0e10cSrcweir throw io::IOException(); // TODO: error handling 1067*cdf0e10cSrcweir 1068*cdf0e10cSrcweir if ( !aName.getLength() ) 1069*cdf0e10cSrcweir throw lang::IllegalArgumentException(); 1070*cdf0e10cSrcweir 1071*cdf0e10cSrcweir INetURLObject aURL( m_pImpl->m_aURL ); 1072*cdf0e10cSrcweir aURL.Append( aName ); 1073*cdf0e10cSrcweir 1074*cdf0e10cSrcweir uno::Any aResult; 1075*cdf0e10cSrcweir try 1076*cdf0e10cSrcweir { 1077*cdf0e10cSrcweir if ( ::utl::UCBContentHelper::IsFolder( aURL.GetMainURL( INetURLObject::NO_DECODE ) ) ) 1078*cdf0e10cSrcweir { 1079*cdf0e10cSrcweir aResult <<= openStorageElement( aName, embed::ElementModes::READ ); 1080*cdf0e10cSrcweir } 1081*cdf0e10cSrcweir else if ( ::utl::UCBContentHelper::IsDocument( aURL.GetMainURL( INetURLObject::NO_DECODE ) ) ) 1082*cdf0e10cSrcweir { 1083*cdf0e10cSrcweir aResult <<= openStreamElement( aName, embed::ElementModes::READ ); 1084*cdf0e10cSrcweir } 1085*cdf0e10cSrcweir else 1086*cdf0e10cSrcweir throw container::NoSuchElementException(); // TODO: 1087*cdf0e10cSrcweir } 1088*cdf0e10cSrcweir catch( container::NoSuchElementException& ) 1089*cdf0e10cSrcweir { 1090*cdf0e10cSrcweir throw; 1091*cdf0e10cSrcweir } 1092*cdf0e10cSrcweir catch( lang::WrappedTargetException& ) 1093*cdf0e10cSrcweir { 1094*cdf0e10cSrcweir throw; 1095*cdf0e10cSrcweir } 1096*cdf0e10cSrcweir catch( uno::RuntimeException& ) 1097*cdf0e10cSrcweir { 1098*cdf0e10cSrcweir throw; 1099*cdf0e10cSrcweir } 1100*cdf0e10cSrcweir catch ( uno::Exception& ) 1101*cdf0e10cSrcweir { 1102*cdf0e10cSrcweir uno::Any aCaught( ::cppu::getCaughtException() ); 1103*cdf0e10cSrcweir throw lang::WrappedTargetException( ::rtl::OUString::createFromAscii( "Can not open element!\n" ), 1104*cdf0e10cSrcweir uno::Reference< uno::XInterface >( static_cast< OWeakObject* >( this ), 1105*cdf0e10cSrcweir uno::UNO_QUERY ), 1106*cdf0e10cSrcweir aCaught ); 1107*cdf0e10cSrcweir } 1108*cdf0e10cSrcweir 1109*cdf0e10cSrcweir return aResult; 1110*cdf0e10cSrcweir } 1111*cdf0e10cSrcweir 1112*cdf0e10cSrcweir 1113*cdf0e10cSrcweir //----------------------------------------------- 1114*cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > SAL_CALL FSStorage::getElementNames() 1115*cdf0e10cSrcweir throw ( uno::RuntimeException ) 1116*cdf0e10cSrcweir { 1117*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 1118*cdf0e10cSrcweir 1119*cdf0e10cSrcweir if ( !m_pImpl ) 1120*cdf0e10cSrcweir throw lang::DisposedException(); 1121*cdf0e10cSrcweir 1122*cdf0e10cSrcweir if ( !GetContent() ) 1123*cdf0e10cSrcweir throw io::IOException(); // TODO: error handling 1124*cdf0e10cSrcweir 1125*cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > aProps( 1 ); 1126*cdf0e10cSrcweir ::rtl::OUString* pProps = aProps.getArray(); 1127*cdf0e10cSrcweir pProps[0] = ::rtl::OUString::createFromAscii( "Title" ); 1128*cdf0e10cSrcweir ::ucbhelper::ResultSetInclude eInclude = ::ucbhelper::INCLUDE_FOLDERS_AND_DOCUMENTS; 1129*cdf0e10cSrcweir 1130*cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > aResult; 1131*cdf0e10cSrcweir sal_Int32 nSize = 0; 1132*cdf0e10cSrcweir 1133*cdf0e10cSrcweir try 1134*cdf0e10cSrcweir { 1135*cdf0e10cSrcweir uno::Reference< sdbc::XResultSet > xResultSet = GetContent()->createCursor( aProps, eInclude ); 1136*cdf0e10cSrcweir uno::Reference< ucb::XContentAccess > xContentAccess( xResultSet, uno::UNO_QUERY ); 1137*cdf0e10cSrcweir uno::Reference< sdbc::XRow > xRow( xResultSet, uno::UNO_QUERY ); 1138*cdf0e10cSrcweir if ( xResultSet.is() ) 1139*cdf0e10cSrcweir { 1140*cdf0e10cSrcweir // go through the list 1141*cdf0e10cSrcweir while ( xResultSet->next() ) 1142*cdf0e10cSrcweir { 1143*cdf0e10cSrcweir ::rtl::OUString aName( xRow->getString( 1 ) ); 1144*cdf0e10cSrcweir aResult.realloc( ++nSize ); 1145*cdf0e10cSrcweir aResult[nSize-1] = aName; 1146*cdf0e10cSrcweir } 1147*cdf0e10cSrcweir } 1148*cdf0e10cSrcweir } 1149*cdf0e10cSrcweir catch( ucb::InteractiveIOException& r ) 1150*cdf0e10cSrcweir { 1151*cdf0e10cSrcweir if ( r.Code == ucb::IOErrorCode_NOT_EXISTING ) 1152*cdf0e10cSrcweir OSL_ENSURE( sal_False, "The folder does not exist!\n" ); 1153*cdf0e10cSrcweir else 1154*cdf0e10cSrcweir { 1155*cdf0e10cSrcweir uno::Any aCaught( ::cppu::getCaughtException() ); 1156*cdf0e10cSrcweir throw lang::WrappedTargetRuntimeException( ::rtl::OUString::createFromAscii( "Can not open storage!\n" ), 1157*cdf0e10cSrcweir uno::Reference< uno::XInterface >( static_cast< OWeakObject* >( this ), 1158*cdf0e10cSrcweir uno::UNO_QUERY ), 1159*cdf0e10cSrcweir aCaught ); 1160*cdf0e10cSrcweir } 1161*cdf0e10cSrcweir } 1162*cdf0e10cSrcweir catch( uno::RuntimeException& ) 1163*cdf0e10cSrcweir { 1164*cdf0e10cSrcweir throw; 1165*cdf0e10cSrcweir } 1166*cdf0e10cSrcweir catch ( uno::Exception& ) 1167*cdf0e10cSrcweir { 1168*cdf0e10cSrcweir uno::Any aCaught( ::cppu::getCaughtException() ); 1169*cdf0e10cSrcweir throw lang::WrappedTargetRuntimeException( ::rtl::OUString::createFromAscii( "Can not open storage!\n" ), 1170*cdf0e10cSrcweir uno::Reference< uno::XInterface >( static_cast< OWeakObject* >( this ), 1171*cdf0e10cSrcweir uno::UNO_QUERY ), 1172*cdf0e10cSrcweir aCaught ); 1173*cdf0e10cSrcweir } 1174*cdf0e10cSrcweir 1175*cdf0e10cSrcweir return aResult; 1176*cdf0e10cSrcweir } 1177*cdf0e10cSrcweir 1178*cdf0e10cSrcweir 1179*cdf0e10cSrcweir //----------------------------------------------- 1180*cdf0e10cSrcweir sal_Bool SAL_CALL FSStorage::hasByName( const ::rtl::OUString& aName ) 1181*cdf0e10cSrcweir throw ( uno::RuntimeException ) 1182*cdf0e10cSrcweir { 1183*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 1184*cdf0e10cSrcweir 1185*cdf0e10cSrcweir if ( !m_pImpl ) 1186*cdf0e10cSrcweir throw lang::DisposedException(); 1187*cdf0e10cSrcweir 1188*cdf0e10cSrcweir try 1189*cdf0e10cSrcweir { 1190*cdf0e10cSrcweir if ( !GetContent() ) 1191*cdf0e10cSrcweir throw io::IOException(); // TODO: error handling 1192*cdf0e10cSrcweir 1193*cdf0e10cSrcweir if ( !aName.getLength() ) 1194*cdf0e10cSrcweir throw lang::IllegalArgumentException(); 1195*cdf0e10cSrcweir } 1196*cdf0e10cSrcweir catch( uno::RuntimeException& ) 1197*cdf0e10cSrcweir { 1198*cdf0e10cSrcweir throw; 1199*cdf0e10cSrcweir } 1200*cdf0e10cSrcweir catch ( uno::Exception& ) 1201*cdf0e10cSrcweir { 1202*cdf0e10cSrcweir uno::Any aCaught( ::cppu::getCaughtException() ); 1203*cdf0e10cSrcweir throw lang::WrappedTargetRuntimeException( ::rtl::OUString::createFromAscii( "Can not open storage!\n" ), 1204*cdf0e10cSrcweir uno::Reference< uno::XInterface >( static_cast< OWeakObject* >( this ), 1205*cdf0e10cSrcweir uno::UNO_QUERY ), 1206*cdf0e10cSrcweir aCaught ); 1207*cdf0e10cSrcweir } 1208*cdf0e10cSrcweir 1209*cdf0e10cSrcweir INetURLObject aURL( m_pImpl->m_aURL ); 1210*cdf0e10cSrcweir aURL.Append( aName ); 1211*cdf0e10cSrcweir 1212*cdf0e10cSrcweir return ( ::utl::UCBContentHelper::IsFolder( aURL.GetMainURL( INetURLObject::NO_DECODE ) ) 1213*cdf0e10cSrcweir || ::utl::UCBContentHelper::IsDocument( aURL.GetMainURL( INetURLObject::NO_DECODE ) ) ); 1214*cdf0e10cSrcweir } 1215*cdf0e10cSrcweir 1216*cdf0e10cSrcweir //----------------------------------------------- 1217*cdf0e10cSrcweir uno::Type SAL_CALL FSStorage::getElementType() 1218*cdf0e10cSrcweir throw ( uno::RuntimeException ) 1219*cdf0e10cSrcweir { 1220*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 1221*cdf0e10cSrcweir 1222*cdf0e10cSrcweir if ( !m_pImpl ) 1223*cdf0e10cSrcweir throw lang::DisposedException(); 1224*cdf0e10cSrcweir 1225*cdf0e10cSrcweir // it is a multitype container 1226*cdf0e10cSrcweir return uno::Type(); 1227*cdf0e10cSrcweir } 1228*cdf0e10cSrcweir 1229*cdf0e10cSrcweir //----------------------------------------------- 1230*cdf0e10cSrcweir sal_Bool SAL_CALL FSStorage::hasElements() 1231*cdf0e10cSrcweir throw ( uno::RuntimeException ) 1232*cdf0e10cSrcweir { 1233*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 1234*cdf0e10cSrcweir 1235*cdf0e10cSrcweir if ( !m_pImpl ) 1236*cdf0e10cSrcweir throw lang::DisposedException(); 1237*cdf0e10cSrcweir 1238*cdf0e10cSrcweir if ( !GetContent() ) 1239*cdf0e10cSrcweir throw io::IOException(); // TODO: error handling 1240*cdf0e10cSrcweir 1241*cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > aProps( 1 ); 1242*cdf0e10cSrcweir aProps[0] = ::rtl::OUString::createFromAscii( "TargetURL" ); 1243*cdf0e10cSrcweir ::ucbhelper::ResultSetInclude eInclude = ::ucbhelper::INCLUDE_FOLDERS_AND_DOCUMENTS; 1244*cdf0e10cSrcweir 1245*cdf0e10cSrcweir try 1246*cdf0e10cSrcweir { 1247*cdf0e10cSrcweir uno::Reference< sdbc::XResultSet > xResultSet = GetContent()->createCursor( aProps, eInclude ); 1248*cdf0e10cSrcweir return ( xResultSet.is() && xResultSet->next() ); 1249*cdf0e10cSrcweir } 1250*cdf0e10cSrcweir catch( uno::Exception& ) 1251*cdf0e10cSrcweir { 1252*cdf0e10cSrcweir throw uno::RuntimeException(); 1253*cdf0e10cSrcweir } 1254*cdf0e10cSrcweir } 1255*cdf0e10cSrcweir 1256*cdf0e10cSrcweir 1257*cdf0e10cSrcweir //____________________________________________________________________________________________________ 1258*cdf0e10cSrcweir // XDisposable 1259*cdf0e10cSrcweir //____________________________________________________________________________________________________ 1260*cdf0e10cSrcweir 1261*cdf0e10cSrcweir //----------------------------------------------- 1262*cdf0e10cSrcweir void SAL_CALL FSStorage::dispose() 1263*cdf0e10cSrcweir throw ( uno::RuntimeException ) 1264*cdf0e10cSrcweir { 1265*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 1266*cdf0e10cSrcweir 1267*cdf0e10cSrcweir if ( !m_pImpl ) 1268*cdf0e10cSrcweir throw lang::DisposedException(); 1269*cdf0e10cSrcweir 1270*cdf0e10cSrcweir if ( m_pImpl->m_pListenersContainer ) 1271*cdf0e10cSrcweir { 1272*cdf0e10cSrcweir lang::EventObject aSource( static_cast< ::cppu::OWeakObject* >(this) ); 1273*cdf0e10cSrcweir m_pImpl->m_pListenersContainer->disposeAndClear( aSource ); 1274*cdf0e10cSrcweir } 1275*cdf0e10cSrcweir 1276*cdf0e10cSrcweir delete m_pImpl; 1277*cdf0e10cSrcweir m_pImpl = NULL; 1278*cdf0e10cSrcweir } 1279*cdf0e10cSrcweir 1280*cdf0e10cSrcweir //----------------------------------------------- 1281*cdf0e10cSrcweir void SAL_CALL FSStorage::addEventListener( 1282*cdf0e10cSrcweir const uno::Reference< lang::XEventListener >& xListener ) 1283*cdf0e10cSrcweir throw ( uno::RuntimeException ) 1284*cdf0e10cSrcweir { 1285*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 1286*cdf0e10cSrcweir 1287*cdf0e10cSrcweir if ( !m_pImpl ) 1288*cdf0e10cSrcweir throw lang::DisposedException(); 1289*cdf0e10cSrcweir 1290*cdf0e10cSrcweir if ( !m_pImpl->m_pListenersContainer ) 1291*cdf0e10cSrcweir m_pImpl->m_pListenersContainer = new ::cppu::OInterfaceContainerHelper( m_aMutex ); 1292*cdf0e10cSrcweir 1293*cdf0e10cSrcweir m_pImpl->m_pListenersContainer->addInterface( xListener ); 1294*cdf0e10cSrcweir } 1295*cdf0e10cSrcweir 1296*cdf0e10cSrcweir //----------------------------------------------- 1297*cdf0e10cSrcweir void SAL_CALL FSStorage::removeEventListener( 1298*cdf0e10cSrcweir const uno::Reference< lang::XEventListener >& xListener ) 1299*cdf0e10cSrcweir throw ( uno::RuntimeException ) 1300*cdf0e10cSrcweir { 1301*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 1302*cdf0e10cSrcweir 1303*cdf0e10cSrcweir if ( !m_pImpl ) 1304*cdf0e10cSrcweir throw lang::DisposedException(); 1305*cdf0e10cSrcweir 1306*cdf0e10cSrcweir if ( m_pImpl->m_pListenersContainer ) 1307*cdf0e10cSrcweir m_pImpl->m_pListenersContainer->removeInterface( xListener ); 1308*cdf0e10cSrcweir } 1309*cdf0e10cSrcweir 1310*cdf0e10cSrcweir //____________________________________________________________________________________________________ 1311*cdf0e10cSrcweir // XPropertySet 1312*cdf0e10cSrcweir //____________________________________________________________________________________________________ 1313*cdf0e10cSrcweir 1314*cdf0e10cSrcweir //----------------------------------------------- 1315*cdf0e10cSrcweir uno::Reference< beans::XPropertySetInfo > SAL_CALL FSStorage::getPropertySetInfo() 1316*cdf0e10cSrcweir throw ( uno::RuntimeException ) 1317*cdf0e10cSrcweir { 1318*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 1319*cdf0e10cSrcweir 1320*cdf0e10cSrcweir if ( !m_pImpl ) 1321*cdf0e10cSrcweir throw lang::DisposedException(); 1322*cdf0e10cSrcweir 1323*cdf0e10cSrcweir //TODO: 1324*cdf0e10cSrcweir return uno::Reference< beans::XPropertySetInfo >(); 1325*cdf0e10cSrcweir } 1326*cdf0e10cSrcweir 1327*cdf0e10cSrcweir 1328*cdf0e10cSrcweir //----------------------------------------------- 1329*cdf0e10cSrcweir void SAL_CALL FSStorage::setPropertyValue( const ::rtl::OUString& aPropertyName, const uno::Any& ) 1330*cdf0e10cSrcweir throw ( beans::UnknownPropertyException, 1331*cdf0e10cSrcweir beans::PropertyVetoException, 1332*cdf0e10cSrcweir lang::IllegalArgumentException, 1333*cdf0e10cSrcweir lang::WrappedTargetException, 1334*cdf0e10cSrcweir uno::RuntimeException ) 1335*cdf0e10cSrcweir { 1336*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 1337*cdf0e10cSrcweir 1338*cdf0e10cSrcweir if ( !m_pImpl ) 1339*cdf0e10cSrcweir throw lang::DisposedException(); 1340*cdf0e10cSrcweir 1341*cdf0e10cSrcweir if ( aPropertyName.equalsAscii( "URL" ) || aPropertyName.equalsAscii( "OpenMode" ) ) 1342*cdf0e10cSrcweir throw beans::PropertyVetoException(); // TODO 1343*cdf0e10cSrcweir else 1344*cdf0e10cSrcweir throw beans::UnknownPropertyException(); // TODO 1345*cdf0e10cSrcweir } 1346*cdf0e10cSrcweir 1347*cdf0e10cSrcweir 1348*cdf0e10cSrcweir //----------------------------------------------- 1349*cdf0e10cSrcweir uno::Any SAL_CALL FSStorage::getPropertyValue( const ::rtl::OUString& aPropertyName ) 1350*cdf0e10cSrcweir throw ( beans::UnknownPropertyException, 1351*cdf0e10cSrcweir lang::WrappedTargetException, 1352*cdf0e10cSrcweir uno::RuntimeException ) 1353*cdf0e10cSrcweir { 1354*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 1355*cdf0e10cSrcweir 1356*cdf0e10cSrcweir if ( !m_pImpl ) 1357*cdf0e10cSrcweir throw lang::DisposedException(); 1358*cdf0e10cSrcweir 1359*cdf0e10cSrcweir if ( aPropertyName.equalsAscii( "URL" ) ) 1360*cdf0e10cSrcweir return uno::makeAny( m_pImpl->m_aURL ); 1361*cdf0e10cSrcweir else if ( aPropertyName.equalsAscii( "OpenMode" ) ) 1362*cdf0e10cSrcweir return uno::makeAny( m_pImpl->m_nMode ); 1363*cdf0e10cSrcweir 1364*cdf0e10cSrcweir throw beans::UnknownPropertyException(); // TODO 1365*cdf0e10cSrcweir } 1366*cdf0e10cSrcweir 1367*cdf0e10cSrcweir 1368*cdf0e10cSrcweir //----------------------------------------------- 1369*cdf0e10cSrcweir void SAL_CALL FSStorage::addPropertyChangeListener( 1370*cdf0e10cSrcweir const ::rtl::OUString& /*aPropertyName*/, 1371*cdf0e10cSrcweir const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/ ) 1372*cdf0e10cSrcweir throw ( beans::UnknownPropertyException, 1373*cdf0e10cSrcweir lang::WrappedTargetException, 1374*cdf0e10cSrcweir uno::RuntimeException ) 1375*cdf0e10cSrcweir { 1376*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 1377*cdf0e10cSrcweir 1378*cdf0e10cSrcweir if ( !m_pImpl ) 1379*cdf0e10cSrcweir throw lang::DisposedException(); 1380*cdf0e10cSrcweir 1381*cdf0e10cSrcweir //TODO: 1382*cdf0e10cSrcweir } 1383*cdf0e10cSrcweir 1384*cdf0e10cSrcweir 1385*cdf0e10cSrcweir //----------------------------------------------- 1386*cdf0e10cSrcweir void SAL_CALL FSStorage::removePropertyChangeListener( 1387*cdf0e10cSrcweir const ::rtl::OUString& /*aPropertyName*/, 1388*cdf0e10cSrcweir const uno::Reference< beans::XPropertyChangeListener >& /*aListener*/ ) 1389*cdf0e10cSrcweir throw ( beans::UnknownPropertyException, 1390*cdf0e10cSrcweir lang::WrappedTargetException, 1391*cdf0e10cSrcweir uno::RuntimeException ) 1392*cdf0e10cSrcweir { 1393*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 1394*cdf0e10cSrcweir 1395*cdf0e10cSrcweir if ( !m_pImpl ) 1396*cdf0e10cSrcweir throw lang::DisposedException(); 1397*cdf0e10cSrcweir 1398*cdf0e10cSrcweir //TODO: 1399*cdf0e10cSrcweir } 1400*cdf0e10cSrcweir 1401*cdf0e10cSrcweir 1402*cdf0e10cSrcweir //----------------------------------------------- 1403*cdf0e10cSrcweir void SAL_CALL FSStorage::addVetoableChangeListener( 1404*cdf0e10cSrcweir const ::rtl::OUString& /*PropertyName*/, 1405*cdf0e10cSrcweir const uno::Reference< beans::XVetoableChangeListener >& /*aListener*/ ) 1406*cdf0e10cSrcweir throw ( beans::UnknownPropertyException, 1407*cdf0e10cSrcweir lang::WrappedTargetException, 1408*cdf0e10cSrcweir uno::RuntimeException ) 1409*cdf0e10cSrcweir { 1410*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 1411*cdf0e10cSrcweir 1412*cdf0e10cSrcweir if ( !m_pImpl ) 1413*cdf0e10cSrcweir throw lang::DisposedException(); 1414*cdf0e10cSrcweir 1415*cdf0e10cSrcweir //TODO: 1416*cdf0e10cSrcweir } 1417*cdf0e10cSrcweir 1418*cdf0e10cSrcweir 1419*cdf0e10cSrcweir //----------------------------------------------- 1420*cdf0e10cSrcweir void SAL_CALL FSStorage::removeVetoableChangeListener( 1421*cdf0e10cSrcweir const ::rtl::OUString& /*PropertyName*/, 1422*cdf0e10cSrcweir const uno::Reference< beans::XVetoableChangeListener >& /*aListener*/ ) 1423*cdf0e10cSrcweir throw ( beans::UnknownPropertyException, 1424*cdf0e10cSrcweir lang::WrappedTargetException, 1425*cdf0e10cSrcweir uno::RuntimeException ) 1426*cdf0e10cSrcweir { 1427*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 1428*cdf0e10cSrcweir 1429*cdf0e10cSrcweir if ( !m_pImpl ) 1430*cdf0e10cSrcweir throw lang::DisposedException(); 1431*cdf0e10cSrcweir 1432*cdf0e10cSrcweir //TODO: 1433*cdf0e10cSrcweir } 1434*cdf0e10cSrcweir 1435*cdf0e10cSrcweir //____________________________________________________________________________________________________ 1436*cdf0e10cSrcweir // XHierarchicalStorageAccess 1437*cdf0e10cSrcweir //____________________________________________________________________________________________________ 1438*cdf0e10cSrcweir //----------------------------------------------- 1439*cdf0e10cSrcweir uno::Reference< embed::XExtendedStorageStream > SAL_CALL FSStorage::openStreamElementByHierarchicalName( const ::rtl::OUString& sStreamPath, ::sal_Int32 nOpenMode ) 1440*cdf0e10cSrcweir throw ( embed::InvalidStorageException, 1441*cdf0e10cSrcweir lang::IllegalArgumentException, 1442*cdf0e10cSrcweir packages::WrongPasswordException, 1443*cdf0e10cSrcweir io::IOException, 1444*cdf0e10cSrcweir embed::StorageWrappedTargetException, 1445*cdf0e10cSrcweir uno::RuntimeException ) 1446*cdf0e10cSrcweir { 1447*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 1448*cdf0e10cSrcweir 1449*cdf0e10cSrcweir if ( !m_pImpl ) 1450*cdf0e10cSrcweir throw lang::DisposedException(); 1451*cdf0e10cSrcweir 1452*cdf0e10cSrcweir if ( sStreamPath.toChar() == '/' ) 1453*cdf0e10cSrcweir throw lang::IllegalArgumentException(); 1454*cdf0e10cSrcweir 1455*cdf0e10cSrcweir if ( !GetContent() ) 1456*cdf0e10cSrcweir throw io::IOException(); // TODO: error handling 1457*cdf0e10cSrcweir 1458*cdf0e10cSrcweir INetURLObject aBaseURL( m_pImpl->m_aURL ); 1459*cdf0e10cSrcweir if ( !aBaseURL.setFinalSlash() ) 1460*cdf0e10cSrcweir throw uno::RuntimeException(); 1461*cdf0e10cSrcweir 1462*cdf0e10cSrcweir INetURLObject aFileURL = INetURLObject::GetAbsURL( 1463*cdf0e10cSrcweir aBaseURL.GetMainURL( INetURLObject::NO_DECODE ), 1464*cdf0e10cSrcweir sStreamPath ); 1465*cdf0e10cSrcweir 1466*cdf0e10cSrcweir if ( ::utl::UCBContentHelper::IsFolder( aFileURL.GetMainURL( INetURLObject::NO_DECODE ) ) ) 1467*cdf0e10cSrcweir throw io::IOException(); 1468*cdf0e10cSrcweir 1469*cdf0e10cSrcweir if ( ( nOpenMode & embed::ElementModes::NOCREATE ) 1470*cdf0e10cSrcweir && !::utl::UCBContentHelper::IsDocument( aFileURL.GetMainURL( INetURLObject::NO_DECODE ) ) ) 1471*cdf0e10cSrcweir throw io::IOException(); // TODO: 1472*cdf0e10cSrcweir 1473*cdf0e10cSrcweir uno::Reference< ucb::XCommandEnvironment > xDummyEnv; // TODO: provide InteractionHandler if any 1474*cdf0e10cSrcweir uno::Reference< io::XStream > xResult; 1475*cdf0e10cSrcweir try 1476*cdf0e10cSrcweir { 1477*cdf0e10cSrcweir if ( nOpenMode & embed::ElementModes::WRITE ) 1478*cdf0e10cSrcweir { 1479*cdf0e10cSrcweir if ( isLocalFile_Impl( aFileURL.GetMainURL( INetURLObject::NO_DECODE ) ) ) 1480*cdf0e10cSrcweir { 1481*cdf0e10cSrcweir uno::Reference< ucb::XSimpleFileAccess > xSimpleFileAccess( 1482*cdf0e10cSrcweir m_pImpl->m_xFactory->createInstance( 1483*cdf0e10cSrcweir ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ucb.SimpleFileAccess" ) ) ), 1484*cdf0e10cSrcweir uno::UNO_QUERY_THROW ); 1485*cdf0e10cSrcweir uno::Reference< io::XStream > xStream = 1486*cdf0e10cSrcweir xSimpleFileAccess->openFileReadWrite( aFileURL.GetMainURL( INetURLObject::NO_DECODE ) ); 1487*cdf0e10cSrcweir 1488*cdf0e10cSrcweir xResult = static_cast< io::XStream* >( new OFSStreamContainer( xStream ) ); 1489*cdf0e10cSrcweir } 1490*cdf0e10cSrcweir else 1491*cdf0e10cSrcweir { 1492*cdf0e10cSrcweir // TODO: test whether it really works for http and fwp 1493*cdf0e10cSrcweir SvStream* pStream = ::utl::UcbStreamHelper::CreateStream( aFileURL.GetMainURL( INetURLObject::NO_DECODE ), 1494*cdf0e10cSrcweir STREAM_STD_WRITE ); 1495*cdf0e10cSrcweir if ( pStream ) 1496*cdf0e10cSrcweir { 1497*cdf0e10cSrcweir if ( !pStream->GetError() ) 1498*cdf0e10cSrcweir { 1499*cdf0e10cSrcweir uno::Reference< io::XStream > xStream = 1500*cdf0e10cSrcweir uno::Reference < io::XStream >( new ::utl::OStreamWrapper( *pStream ) ); 1501*cdf0e10cSrcweir xResult = static_cast< io::XStream* >( new OFSStreamContainer( xStream ) ); 1502*cdf0e10cSrcweir } 1503*cdf0e10cSrcweir else 1504*cdf0e10cSrcweir delete pStream; 1505*cdf0e10cSrcweir } 1506*cdf0e10cSrcweir } 1507*cdf0e10cSrcweir 1508*cdf0e10cSrcweir if ( !xResult.is() ) 1509*cdf0e10cSrcweir throw io::IOException(); 1510*cdf0e10cSrcweir 1511*cdf0e10cSrcweir if ( ( nOpenMode & embed::ElementModes::TRUNCATE ) ) 1512*cdf0e10cSrcweir { 1513*cdf0e10cSrcweir uno::Reference< io::XTruncate > xTrunc( xResult->getOutputStream(), uno::UNO_QUERY_THROW ); 1514*cdf0e10cSrcweir xTrunc->truncate(); 1515*cdf0e10cSrcweir } 1516*cdf0e10cSrcweir } 1517*cdf0e10cSrcweir else 1518*cdf0e10cSrcweir { 1519*cdf0e10cSrcweir if ( ( nOpenMode & embed::ElementModes::TRUNCATE ) 1520*cdf0e10cSrcweir || !::utl::UCBContentHelper::IsDocument( aFileURL.GetMainURL( INetURLObject::NO_DECODE ) ) ) 1521*cdf0e10cSrcweir throw io::IOException(); // TODO: access denied 1522*cdf0e10cSrcweir 1523*cdf0e10cSrcweir ::ucbhelper::Content aResultContent( aFileURL.GetMainURL( INetURLObject::NO_DECODE ), xDummyEnv ); 1524*cdf0e10cSrcweir uno::Reference< io::XInputStream > xInStream = aResultContent.openStream(); 1525*cdf0e10cSrcweir xResult = static_cast< io::XStream* >( new OFSInputStreamContainer( xInStream ) ); 1526*cdf0e10cSrcweir } 1527*cdf0e10cSrcweir } 1528*cdf0e10cSrcweir catch( embed::InvalidStorageException& ) 1529*cdf0e10cSrcweir { 1530*cdf0e10cSrcweir throw; 1531*cdf0e10cSrcweir } 1532*cdf0e10cSrcweir catch( lang::IllegalArgumentException& ) 1533*cdf0e10cSrcweir { 1534*cdf0e10cSrcweir throw; 1535*cdf0e10cSrcweir } 1536*cdf0e10cSrcweir catch( packages::WrongPasswordException& ) 1537*cdf0e10cSrcweir { 1538*cdf0e10cSrcweir throw; 1539*cdf0e10cSrcweir } 1540*cdf0e10cSrcweir catch( embed::StorageWrappedTargetException& ) 1541*cdf0e10cSrcweir { 1542*cdf0e10cSrcweir throw; 1543*cdf0e10cSrcweir } 1544*cdf0e10cSrcweir catch( io::IOException& ) 1545*cdf0e10cSrcweir { 1546*cdf0e10cSrcweir throw; 1547*cdf0e10cSrcweir } 1548*cdf0e10cSrcweir catch( uno::RuntimeException& ) 1549*cdf0e10cSrcweir { 1550*cdf0e10cSrcweir throw; 1551*cdf0e10cSrcweir } 1552*cdf0e10cSrcweir catch( uno::Exception& ) 1553*cdf0e10cSrcweir { 1554*cdf0e10cSrcweir uno::Any aCaught( ::cppu::getCaughtException() ); 1555*cdf0e10cSrcweir throw embed::StorageWrappedTargetException( ::rtl::OUString::createFromAscii( "Can't copy raw stream" ), 1556*cdf0e10cSrcweir uno::Reference< io::XInputStream >(), 1557*cdf0e10cSrcweir aCaught ); 1558*cdf0e10cSrcweir } 1559*cdf0e10cSrcweir 1560*cdf0e10cSrcweir return uno::Reference< embed::XExtendedStorageStream >( xResult, uno::UNO_QUERY_THROW ); 1561*cdf0e10cSrcweir } 1562*cdf0e10cSrcweir 1563*cdf0e10cSrcweir //----------------------------------------------- 1564*cdf0e10cSrcweir uno::Reference< embed::XExtendedStorageStream > SAL_CALL FSStorage::openEncryptedStreamElementByHierarchicalName( const ::rtl::OUString& /*sStreamName*/, ::sal_Int32 /*nOpenMode*/, const ::rtl::OUString& /*sPassword*/ ) 1565*cdf0e10cSrcweir throw ( embed::InvalidStorageException, 1566*cdf0e10cSrcweir lang::IllegalArgumentException, 1567*cdf0e10cSrcweir packages::NoEncryptionException, 1568*cdf0e10cSrcweir packages::WrongPasswordException, 1569*cdf0e10cSrcweir io::IOException, 1570*cdf0e10cSrcweir embed::StorageWrappedTargetException, 1571*cdf0e10cSrcweir uno::RuntimeException ) 1572*cdf0e10cSrcweir { 1573*cdf0e10cSrcweir throw packages::NoEncryptionException(); 1574*cdf0e10cSrcweir } 1575*cdf0e10cSrcweir 1576*cdf0e10cSrcweir //----------------------------------------------- 1577*cdf0e10cSrcweir void SAL_CALL FSStorage::removeStreamElementByHierarchicalName( const ::rtl::OUString& sStreamPath ) 1578*cdf0e10cSrcweir throw ( embed::InvalidStorageException, 1579*cdf0e10cSrcweir lang::IllegalArgumentException, 1580*cdf0e10cSrcweir container::NoSuchElementException, 1581*cdf0e10cSrcweir io::IOException, 1582*cdf0e10cSrcweir embed::StorageWrappedTargetException, 1583*cdf0e10cSrcweir uno::RuntimeException ) 1584*cdf0e10cSrcweir { 1585*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 1586*cdf0e10cSrcweir 1587*cdf0e10cSrcweir if ( !m_pImpl ) 1588*cdf0e10cSrcweir throw lang::DisposedException(); 1589*cdf0e10cSrcweir 1590*cdf0e10cSrcweir if ( !GetContent() ) 1591*cdf0e10cSrcweir throw io::IOException(); // TODO: error handling 1592*cdf0e10cSrcweir 1593*cdf0e10cSrcweir // TODO/LATER: may need possibility to create folder if it was removed, since the folder can not be locked 1594*cdf0e10cSrcweir INetURLObject aBaseURL( m_pImpl->m_aURL ); 1595*cdf0e10cSrcweir if ( !aBaseURL.setFinalSlash() ) 1596*cdf0e10cSrcweir throw uno::RuntimeException(); 1597*cdf0e10cSrcweir 1598*cdf0e10cSrcweir INetURLObject aFileURL = INetURLObject::GetAbsURL( 1599*cdf0e10cSrcweir aBaseURL.GetMainURL( INetURLObject::NO_DECODE ), 1600*cdf0e10cSrcweir sStreamPath ); 1601*cdf0e10cSrcweir 1602*cdf0e10cSrcweir if ( !::utl::UCBContentHelper::IsDocument( aFileURL.GetMainURL( INetURLObject::NO_DECODE ) ) ) 1603*cdf0e10cSrcweir { 1604*cdf0e10cSrcweir if ( ::utl::UCBContentHelper::IsFolder( aFileURL.GetMainURL( INetURLObject::NO_DECODE ) ) ) 1605*cdf0e10cSrcweir throw lang::IllegalArgumentException(); 1606*cdf0e10cSrcweir else 1607*cdf0e10cSrcweir throw container::NoSuchElementException(); // TODO: 1608*cdf0e10cSrcweir } 1609*cdf0e10cSrcweir 1610*cdf0e10cSrcweir if ( !::utl::UCBContentHelper::Kill( aFileURL.GetMainURL( INetURLObject::NO_DECODE ) ) ) 1611*cdf0e10cSrcweir throw io::IOException(); // TODO: error handling 1612*cdf0e10cSrcweir } 1613*cdf0e10cSrcweir 1614*cdf0e10cSrcweir 1615