1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <com/sun/star/beans/PropertyValue.hpp>
21 #include <com/sun/star/embed/ElementModes.hpp>
22 #include <com/sun/star/embed/XTransactedObject.hpp>
23 #include <com/sun/star/ucb/NameClash.hpp>
24 #include <com/sun/star/ucb/UniversalContentBroker.hpp>
25 #include <com/sun/star/ucb/XProgressHandler.hpp>
26 #include <com/sun/star/ucb/XContentAccess.hpp>
27 #include <com/sun/star/ucb/SimpleFileAccess.hpp>
29 #include <com/sun/star/ucb/InteractiveIOException.hpp>
30 #include <com/sun/star/ucb/IOErrorCode.hpp>
31 #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
32 #include <com/sun/star/container/XEnumerationAccess.hpp>
33 #include <com/sun/star/container/XNamed.hpp>
34 #include <com/sun/star/util/XChangesBatch.hpp>
35 #include <com/sun/star/util/XCloneable.hpp>
36 #include <com/sun/star/lang/XUnoTunnel.hpp>
37 #include <com/sun/star/lang/XComponent.hpp>
38 #include <com/sun/star/lang/DisposedException.hpp>
39 #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
40 #include <com/sun/star/io/IOException.hpp>
41 #include <com/sun/star/io/XTruncate.hpp>
42 #include <com/sun/star/io/TempFile.hpp>
43 #include <com/sun/star/sdbc/XResultSet.hpp>
44 #include <com/sun/star/sdbc/XRow.hpp>
47 #include <comphelper/processfactory.hxx>
48 #include <comphelper/storagehelper.hxx>
49 #include <cppuhelper/typeprovider.hxx>
50 #include <cppuhelper/exc_hlp.hxx>
52 #include <tools/urlobj.hxx>
53 #include <unotools/ucbhelper.hxx>
54 #include <unotools/ucbstreamhelper.hxx>
55 #include <unotools/streamwrap.hxx>
56 #include <ucbhelper/fileidentifierconverter.hxx>
57 #include <ucbhelper/content.hxx>
59 #include "fsstorage.hxx"
60 #include "oinputstreamcontainer.hxx"
61 #include "ostreamcontainer.hxx"
63 using namespace ::com::sun::star
;
65 //=========================================================
67 // TODO: move to a standard helper
68 sal_Bool
isLocalFile_Impl( OUString aURL
)
74 aSystemPath
= ::ucbhelper::getSystemPathFromFileURL(
75 ucb::UniversalContentBroker::create(
76 comphelper::getProcessComponentContext() ),
79 catch ( uno::Exception
& )
83 return ( !aSystemPath
.isEmpty() );
87 //=========================================================
93 ::ucbhelper::Content
* m_pContent
;
96 ::cppu::OInterfaceContainerHelper
* m_pListenersContainer
; // list of listeners
97 ::cppu::OTypeCollection
* m_pTypeCollection
;
99 uno::Reference
< lang::XMultiServiceFactory
> m_xFactory
;
102 FSStorage_Impl( const OUString
& aURL
, sal_Int32 nMode
, uno::Reference
< lang::XMultiServiceFactory
> xFactory
)
106 , m_pListenersContainer( NULL
)
107 , m_pTypeCollection( NULL
)
108 , m_xFactory( xFactory
)
110 OSL_ENSURE( !m_aURL
.isEmpty(), "The URL must not be empty" );
113 FSStorage_Impl( const ::ucbhelper::Content
& aContent
, sal_Int32 nMode
, uno::Reference
< lang::XMultiServiceFactory
> xFactory
)
114 : m_aURL( aContent
.getURL() )
115 , m_pContent( new ::ucbhelper::Content( aContent
) )
117 , m_pListenersContainer( NULL
)
118 , m_pTypeCollection( NULL
)
119 , m_xFactory( xFactory
)
121 OSL_ENSURE( !m_aURL
.isEmpty(), "The URL must not be empty" );
127 //=========================================================
129 FSStorage_Impl::~FSStorage_Impl()
131 if ( m_pListenersContainer
)
132 delete m_pListenersContainer
;
133 if ( m_pTypeCollection
)
134 delete m_pTypeCollection
;
139 //=====================================================
140 // FSStorage implementation
141 //=====================================================
143 //-----------------------------------------------
144 FSStorage::FSStorage( const ::ucbhelper::Content
& aContent
,
146 uno::Reference
< lang::XMultiServiceFactory
> xFactory
)
147 : m_pImpl( new FSStorage_Impl( aContent
, nMode
, xFactory
) )
149 // TODO: use properties
150 if ( !xFactory
.is() )
151 throw uno::RuntimeException();
156 //-----------------------------------------------
157 FSStorage::~FSStorage()
160 ::osl::MutexGuard
aGuard( m_aMutex
);
161 m_refCount
++; // to call dispose
165 catch( uno::RuntimeException
& )
170 //-----------------------------------------------
171 sal_Bool
FSStorage::MakeFolderNoUI( const OUString
& rFolder
)
173 INetURLObject
aURL( rFolder
);
174 OUString aTitle
= aURL
.getName( INetURLObject::LAST_SEGMENT
, true, INetURLObject::DECODE_WITH_CHARSET
);
175 aURL
.removeSegment();
176 ::ucbhelper::Content aParent
;
177 ::ucbhelper::Content aResultContent
;
179 if ( ::ucbhelper::Content::create( aURL
.GetMainURL( INetURLObject::NO_DECODE
),
180 uno::Reference
< ucb::XCommandEnvironment
>(),
181 comphelper::getProcessComponentContext(),
183 return ::utl::UCBContentHelper::MakeFolder( aParent
, aTitle
, aResultContent
, sal_False
);
188 //-----------------------------------------------
189 ::ucbhelper::Content
* FSStorage::GetContent()
191 ::osl::MutexGuard
aGuard( m_aMutex
);
192 if ( !m_pImpl
->m_pContent
)
194 uno::Reference
< ucb::XCommandEnvironment
> xDummyEnv
;
198 m_pImpl
->m_pContent
= new ::ucbhelper::Content( m_pImpl
->m_aURL
, xDummyEnv
, comphelper::getProcessComponentContext() );
200 catch( uno::Exception
& )
205 return m_pImpl
->m_pContent
;
208 //-----------------------------------------------
209 void FSStorage::CopyStreamToSubStream( const OUString
& aSourceURL
,
210 const uno::Reference
< embed::XStorage
>& xDest
,
211 const OUString
& aNewEntryName
)
214 throw uno::RuntimeException();
216 uno::Reference
< ucb::XCommandEnvironment
> xDummyEnv
;
217 ::ucbhelper::Content
aSourceContent( aSourceURL
, xDummyEnv
, comphelper::getProcessComponentContext() );
218 uno::Reference
< io::XInputStream
> xSourceInput
= aSourceContent
.openStream();
220 if ( !xSourceInput
.is() )
221 throw io::IOException(); // TODO: error handling
223 uno::Reference
< io::XStream
> xSubStream
= xDest
->openStreamElement(
225 embed::ElementModes::READWRITE
| embed::ElementModes::TRUNCATE
);
226 if ( !xSubStream
.is() )
227 throw uno::RuntimeException();
229 uno::Reference
< io::XOutputStream
> xDestOutput
= xSubStream
->getOutputStream();
230 if ( !xDestOutput
.is() )
231 throw uno::RuntimeException();
233 ::comphelper::OStorageHelper::CopyInputToOutput( xSourceInput
, xDestOutput
);
234 xDestOutput
->closeOutput();
237 //-----------------------------------------------
238 void FSStorage::CopyContentToStorage_Impl( ::ucbhelper::Content
* pContent
, const uno::Reference
< embed::XStorage
>& xDest
)
241 throw uno::RuntimeException();
243 // get list of contents of the Content
244 // create cursor for access to children
245 uno::Sequence
< OUString
> aProps( 2 );
246 OUString
* pProps
= aProps
.getArray();
247 pProps
[0] = OUString("TargetURL");
248 pProps
[1] = OUString("IsFolder");
249 ::ucbhelper::ResultSetInclude eInclude
= ::ucbhelper::INCLUDE_FOLDERS_AND_DOCUMENTS
;
253 uno::Reference
< sdbc::XResultSet
> xResultSet
= pContent
->createCursor( aProps
, eInclude
);
254 uno::Reference
< ucb::XContentAccess
> xContentAccess( xResultSet
, uno::UNO_QUERY
);
255 uno::Reference
< sdbc::XRow
> xRow( xResultSet
, uno::UNO_QUERY
);
256 if ( xResultSet
.is() )
258 // go through the list: insert files as streams, insert folders as substorages using recursion
259 while ( xResultSet
->next() )
261 OUString
aSourceURL( xRow
->getString( 1 ) );
262 sal_Bool
bIsFolder( xRow
->getBoolean(2) );
264 // TODO/LATER: not sure whether the entry name must be encoded
265 OUString
aNewEntryName( INetURLObject( aSourceURL
).getName( INetURLObject::LAST_SEGMENT
,
267 INetURLObject::NO_DECODE
) );
270 uno::Reference
< embed::XStorage
> xSubStorage
= xDest
->openStorageElement( aNewEntryName
,
271 embed::ElementModes::READWRITE
);
272 if ( !xSubStorage
.is() )
273 throw uno::RuntimeException();
275 uno::Reference
< ucb::XCommandEnvironment
> xDummyEnv
;
276 ::ucbhelper::Content
aSourceContent( aSourceURL
, xDummyEnv
, comphelper::getProcessComponentContext() );
277 CopyContentToStorage_Impl( &aSourceContent
, xSubStorage
);
281 CopyStreamToSubStream( aSourceURL
, xDest
, aNewEntryName
);
286 uno::Reference
< embed::XTransactedObject
> xTransact( xDest
, uno::UNO_QUERY
);
287 if ( xTransact
.is() )
290 catch( ucb::InteractiveIOException
& r
)
292 if ( r
.Code
== ucb::IOErrorCode_NOT_EXISTING
)
293 OSL_FAIL( "The folder does not exist!\n" );
299 //____________________________________________________________________________________________________
301 //____________________________________________________________________________________________________
303 //-----------------------------------------------
304 uno::Any SAL_CALL
FSStorage::queryInterface( const uno::Type
& rType
)
305 throw( uno::RuntimeException
)
308 aReturn
<<= ::cppu::queryInterface
310 , static_cast<lang::XTypeProvider
*> ( this )
311 , static_cast<embed::XStorage
*> ( this )
312 , static_cast<embed::XHierarchicalStorageAccess
*> ( this )
313 , static_cast<container::XNameAccess
*> ( this )
314 , static_cast<container::XElementAccess
*> ( this )
315 , static_cast<lang::XComponent
*> ( this )
316 , static_cast<beans::XPropertySet
*> ( this ) );
318 if ( aReturn
.hasValue() == sal_True
)
321 return OWeakObject::queryInterface( rType
);
324 //-----------------------------------------------
325 void SAL_CALL
FSStorage::acquire() throw()
327 OWeakObject::acquire();
330 //-----------------------------------------------
331 void SAL_CALL
FSStorage::release() throw()
333 OWeakObject::release();
336 //____________________________________________________________________________________________________
338 //____________________________________________________________________________________________________
340 //-----------------------------------------------
341 uno::Sequence
< uno::Type
> SAL_CALL
FSStorage::getTypes()
342 throw( uno::RuntimeException
)
344 if ( m_pImpl
->m_pTypeCollection
== NULL
)
346 ::osl::MutexGuard
aGuard( m_aMutex
);
348 if ( m_pImpl
->m_pTypeCollection
== NULL
)
350 m_pImpl
->m_pTypeCollection
= new ::cppu::OTypeCollection
351 ( ::getCppuType( ( const uno::Reference
< lang::XTypeProvider
>* )NULL
)
352 , ::getCppuType( ( const uno::Reference
< embed::XStorage
>* )NULL
)
353 , ::getCppuType( ( const uno::Reference
< embed::XHierarchicalStorageAccess
>* )NULL
)
354 , ::getCppuType( ( const uno::Reference
< beans::XPropertySet
>* )NULL
) );
358 return m_pImpl
->m_pTypeCollection
->getTypes() ;
361 //-----------------------------------------------
362 uno::Sequence
< sal_Int8
> SAL_CALL
FSStorage::getImplementationId()
363 throw( uno::RuntimeException
)
365 static ::cppu::OImplementationId
* pID
= NULL
;
369 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() ) ;
373 static ::cppu::OImplementationId
aID( sal_False
) ;
378 return pID
->getImplementationId() ;
382 //____________________________________________________________________________________________________
384 //____________________________________________________________________________________________________
386 //-----------------------------------------------
387 void SAL_CALL
FSStorage::copyToStorage( const uno::Reference
< embed::XStorage
>& xDest
)
388 throw ( embed::InvalidStorageException
,
390 lang::IllegalArgumentException
,
391 embed::StorageWrappedTargetException
,
392 uno::RuntimeException
)
394 ::osl::MutexGuard
aGuard( m_aMutex
);
397 throw lang::DisposedException();
399 if ( !xDest
.is() || xDest
== uno::Reference
< uno::XInterface
>( static_cast< OWeakObject
*> ( this ), uno::UNO_QUERY
) )
400 throw lang::IllegalArgumentException(); // TODO:
403 throw io::IOException(); // TODO: error handling
407 CopyContentToStorage_Impl( GetContent(), xDest
);
409 catch( embed::InvalidStorageException
& )
413 catch( lang::IllegalArgumentException
& )
417 catch( embed::StorageWrappedTargetException
& )
421 catch( io::IOException
& )
425 catch( uno::RuntimeException
& )
429 catch( uno::Exception
& )
431 uno::Any
aCaught( ::cppu::getCaughtException() );
432 throw embed::StorageWrappedTargetException( OUString("Can't copy raw stream"),
433 uno::Reference
< io::XInputStream
>(),
438 //-----------------------------------------------
439 uno::Reference
< io::XStream
> SAL_CALL
FSStorage::openStreamElement(
440 const OUString
& aStreamName
, sal_Int32 nOpenMode
)
441 throw ( embed::InvalidStorageException
,
442 lang::IllegalArgumentException
,
443 packages::WrongPasswordException
,
445 embed::StorageWrappedTargetException
,
446 uno::RuntimeException
)
448 ::osl::MutexGuard
aGuard( m_aMutex
);
451 throw lang::DisposedException();
454 throw io::IOException(); // TODO: error handling
456 // TODO/LATER: may need possibility to create folder if it was removed, since the folder can not be locked
457 INetURLObject
aFileURL( m_pImpl
->m_aURL
);
458 aFileURL
.Append( aStreamName
);
460 if ( ::utl::UCBContentHelper::IsFolder( aFileURL
.GetMainURL( INetURLObject::NO_DECODE
) ) )
461 throw io::IOException();
463 if ( ( nOpenMode
& embed::ElementModes::NOCREATE
)
464 && !::utl::UCBContentHelper::IsDocument( aFileURL
.GetMainURL( INetURLObject::NO_DECODE
) ) )
465 throw io::IOException(); // TODO:
467 uno::Reference
< ucb::XCommandEnvironment
> xDummyEnv
; // TODO: provide InteractionHandler if any
468 uno::Reference
< io::XStream
> xResult
;
471 if ( nOpenMode
& embed::ElementModes::WRITE
)
473 if ( isLocalFile_Impl( aFileURL
.GetMainURL( INetURLObject::NO_DECODE
) ) )
475 uno::Reference
<ucb::XSimpleFileAccess3
> xSimpleFileAccess(
476 ucb::SimpleFileAccess::create(
477 comphelper::getComponentContext(m_pImpl
->m_xFactory
) ) );
478 xResult
= xSimpleFileAccess
->openFileReadWrite( aFileURL
.GetMainURL( INetURLObject::NO_DECODE
) );
482 // TODO: test whether it really works for http and fwp
483 SvStream
* pStream
= ::utl::UcbStreamHelper::CreateStream( aFileURL
.GetMainURL( INetURLObject::NO_DECODE
),
487 if ( !pStream
->GetError() )
488 xResult
= uno::Reference
< io::XStream
>( new ::utl::OStreamWrapper( *pStream
) );
495 throw io::IOException();
497 if ( ( nOpenMode
& embed::ElementModes::TRUNCATE
) )
499 uno::Reference
< io::XTruncate
> xTrunc( xResult
->getOutputStream(), uno::UNO_QUERY_THROW
);
505 if ( ( nOpenMode
& embed::ElementModes::TRUNCATE
)
506 || !::utl::UCBContentHelper::IsDocument( aFileURL
.GetMainURL( INetURLObject::NO_DECODE
) ) )
507 throw io::IOException(); // TODO: access denied
509 ::ucbhelper::Content
aResultContent( aFileURL
.GetMainURL( INetURLObject::NO_DECODE
), xDummyEnv
, comphelper::getProcessComponentContext() );
510 uno::Reference
< io::XInputStream
> xInStream
= aResultContent
.openStream();
511 xResult
= static_cast< io::XStream
* >( new OFSInputStreamContainer( xInStream
) );
514 catch( embed::InvalidStorageException
& )
518 catch( lang::IllegalArgumentException
& )
522 catch( packages::WrongPasswordException
& )
526 catch( embed::StorageWrappedTargetException
& )
530 catch( io::IOException
& )
534 catch( uno::RuntimeException
& )
538 catch( uno::Exception
& )
540 uno::Any
aCaught( ::cppu::getCaughtException() );
541 throw embed::StorageWrappedTargetException( OUString("Can't copy raw stream"),
542 uno::Reference
< io::XInputStream
>(),
549 //-----------------------------------------------
550 uno::Reference
< io::XStream
> SAL_CALL
FSStorage::openEncryptedStreamElement(
551 const OUString
&, sal_Int32
, const OUString
& )
552 throw ( embed::InvalidStorageException
,
553 lang::IllegalArgumentException
,
554 packages::NoEncryptionException
,
555 packages::WrongPasswordException
,
557 embed::StorageWrappedTargetException
,
558 uno::RuntimeException
)
560 throw packages::NoEncryptionException();
563 //-----------------------------------------------
564 uno::Reference
< embed::XStorage
> SAL_CALL
FSStorage::openStorageElement(
565 const OUString
& aStorName
, sal_Int32 nStorageMode
)
566 throw ( embed::InvalidStorageException
,
567 lang::IllegalArgumentException
,
569 embed::StorageWrappedTargetException
,
570 uno::RuntimeException
)
572 ::osl::MutexGuard
aGuard( m_aMutex
);
575 throw lang::DisposedException();
578 throw io::IOException(); // TODO: error handling
580 if ( ( nStorageMode
& embed::ElementModes::WRITE
)
581 && !( m_pImpl
->m_nMode
& embed::ElementModes::WRITE
) )
582 throw io::IOException(); // TODO: error handling
584 // TODO/LATER: may need possibility to create folder if it was removed, since the folder can not be locked
585 INetURLObject
aFolderURL( m_pImpl
->m_aURL
);
586 aFolderURL
.Append( aStorName
);
588 sal_Bool bFolderExists
= ::utl::UCBContentHelper::IsFolder( aFolderURL
.GetMainURL( INetURLObject::NO_DECODE
) );
589 if ( !bFolderExists
&& ::utl::UCBContentHelper::IsDocument( aFolderURL
.GetMainURL( INetURLObject::NO_DECODE
) ) )
590 throw io::IOException(); // TODO:
592 if ( ( nStorageMode
& embed::ElementModes::NOCREATE
) && !bFolderExists
)
593 throw io::IOException(); // TODO:
595 uno::Reference
< ucb::XCommandEnvironment
> xDummyEnv
; // TODO: provide InteractionHandler if any
596 uno::Reference
< embed::XStorage
> xResult
;
599 if ( nStorageMode
& embed::ElementModes::WRITE
)
601 if ( ( nStorageMode
& embed::ElementModes::TRUNCATE
) && bFolderExists
)
603 ::utl::UCBContentHelper::Kill( aFolderURL
.GetMainURL( INetURLObject::NO_DECODE
) );
605 MakeFolderNoUI( aFolderURL
.GetMainURL( INetURLObject::NO_DECODE
) ); // TODO: not atomic :(
607 else if ( !bFolderExists
)
610 MakeFolderNoUI( aFolderURL
.GetMainURL( INetURLObject::NO_DECODE
) ); // TODO: not atomic :(
613 else if ( ( nStorageMode
& embed::ElementModes::TRUNCATE
) )
614 throw io::IOException(); // TODO: access denied
616 if ( !bFolderExists
)
617 throw io::IOException(); // there is no such folder
619 ::ucbhelper::Content
aResultContent( aFolderURL
.GetMainURL( INetURLObject::NO_DECODE
), xDummyEnv
, comphelper::getProcessComponentContext() );
620 xResult
= uno::Reference
< embed::XStorage
>(
621 static_cast< OWeakObject
* >( new FSStorage( aResultContent
,
623 m_pImpl
->m_xFactory
) ),
626 catch( embed::InvalidStorageException
& )
630 catch( lang::IllegalArgumentException
& )
634 catch( embed::StorageWrappedTargetException
& )
638 catch( io::IOException
& )
642 catch( uno::RuntimeException
& )
646 catch( uno::Exception
& )
648 uno::Any
aCaught( ::cppu::getCaughtException() );
649 throw embed::StorageWrappedTargetException( OUString("Can't copy raw stream"),
650 uno::Reference
< io::XInputStream
>(),
657 //-----------------------------------------------
658 uno::Reference
< io::XStream
> SAL_CALL
FSStorage::cloneStreamElement( const OUString
& aStreamName
)
659 throw ( embed::InvalidStorageException
,
660 lang::IllegalArgumentException
,
661 packages::WrongPasswordException
,
663 embed::StorageWrappedTargetException
,
664 uno::RuntimeException
)
666 ::osl::MutexGuard
aGuard( m_aMutex
);
669 throw lang::DisposedException();
672 throw io::IOException(); // TODO: error handling
674 // TODO/LATER: may need possibility to create folder if it was removed, since the folder can not be locked
675 INetURLObject
aFileURL( m_pImpl
->m_aURL
);
676 aFileURL
.Append( aStreamName
);
678 uno::Reference
< io::XStream
> xTempResult
;
681 uno::Reference
< ucb::XCommandEnvironment
> xDummyEnv
;
682 ::ucbhelper::Content
aResultContent( aFileURL
.GetMainURL( INetURLObject::NO_DECODE
), xDummyEnv
, comphelper::getProcessComponentContext() );
683 uno::Reference
< io::XInputStream
> xInStream
= aResultContent
.openStream();
685 xTempResult
= uno::Reference
< io::XStream
>(
686 io::TempFile::create(comphelper::getComponentContext(m_pImpl
->m_xFactory
)),
687 uno::UNO_QUERY_THROW
);
688 uno::Reference
< io::XOutputStream
> xTempOut
= xTempResult
->getOutputStream();
689 uno::Reference
< io::XInputStream
> xTempIn
= xTempResult
->getInputStream();
691 if ( !xTempOut
.is() || !xTempIn
.is() )
692 throw io::IOException();
694 ::comphelper::OStorageHelper::CopyInputToOutput( xInStream
, xTempOut
);
695 xTempOut
->closeOutput();
697 catch( embed::InvalidStorageException
& )
701 catch( lang::IllegalArgumentException
& )
705 catch( packages::WrongPasswordException
& )
709 catch( io::IOException
& )
713 catch( embed::StorageWrappedTargetException
& )
717 catch( uno::RuntimeException
& )
721 catch( uno::Exception
& )
723 uno::Any
aCaught( ::cppu::getCaughtException() );
724 throw embed::StorageWrappedTargetException( OUString("Can't copy raw stream"),
725 uno::Reference
< io::XInputStream
>(),
732 //-----------------------------------------------
733 uno::Reference
< io::XStream
> SAL_CALL
FSStorage::cloneEncryptedStreamElement(
736 throw ( embed::InvalidStorageException
,
737 lang::IllegalArgumentException
,
738 packages::NoEncryptionException
,
739 packages::WrongPasswordException
,
741 embed::StorageWrappedTargetException
,
742 uno::RuntimeException
)
744 throw packages::NoEncryptionException();
747 //-----------------------------------------------
748 void SAL_CALL
FSStorage::copyLastCommitTo(
749 const uno::Reference
< embed::XStorage
>& xTargetStorage
)
750 throw ( embed::InvalidStorageException
,
751 lang::IllegalArgumentException
,
753 embed::StorageWrappedTargetException
,
754 uno::RuntimeException
)
756 copyToStorage( xTargetStorage
);
759 //-----------------------------------------------
760 void SAL_CALL
FSStorage::copyStorageElementLastCommitTo(
761 const OUString
& aStorName
,
762 const uno::Reference
< embed::XStorage
>& xTargetStorage
)
763 throw ( embed::InvalidStorageException
,
764 lang::IllegalArgumentException
,
766 embed::StorageWrappedTargetException
,
767 uno::RuntimeException
)
769 ::osl::MutexGuard
aGuard( m_aMutex
);
772 throw lang::DisposedException();
774 uno::Reference
< embed::XStorage
> xSourceStor( openStorageElement( aStorName
, embed::ElementModes::READ
),
775 uno::UNO_QUERY_THROW
);
776 xSourceStor
->copyToStorage( xTargetStorage
);
779 //-----------------------------------------------
780 sal_Bool SAL_CALL
FSStorage::isStreamElement( const OUString
& aElementName
)
781 throw ( embed::InvalidStorageException
,
782 lang::IllegalArgumentException
,
783 container::NoSuchElementException
,
784 uno::RuntimeException
)
786 ::osl::MutexGuard
aGuard( m_aMutex
);
789 throw lang::DisposedException();
792 throw embed::InvalidStorageException(); // TODO: error handling
794 INetURLObject
aURL( m_pImpl
->m_aURL
);
795 aURL
.Append( aElementName
);
797 return !::utl::UCBContentHelper::IsFolder( aURL
.GetMainURL( INetURLObject::NO_DECODE
) );
800 //-----------------------------------------------
801 sal_Bool SAL_CALL
FSStorage::isStorageElement( const OUString
& aElementName
)
802 throw ( embed::InvalidStorageException
,
803 lang::IllegalArgumentException
,
804 container::NoSuchElementException
,
805 uno::RuntimeException
)
807 ::osl::MutexGuard
aGuard( m_aMutex
);
810 throw lang::DisposedException();
813 throw embed::InvalidStorageException(); // TODO: error handling
815 INetURLObject
aURL( m_pImpl
->m_aURL
);
816 aURL
.Append( aElementName
);
818 return ::utl::UCBContentHelper::IsFolder( aURL
.GetMainURL( INetURLObject::NO_DECODE
) );
821 //-----------------------------------------------
822 void SAL_CALL
FSStorage::removeElement( const OUString
& aElementName
)
823 throw ( embed::InvalidStorageException
,
824 lang::IllegalArgumentException
,
825 container::NoSuchElementException
,
827 embed::StorageWrappedTargetException
,
828 uno::RuntimeException
)
830 ::osl::MutexGuard
aGuard( m_aMutex
);
833 throw lang::DisposedException();
836 throw io::IOException(); // TODO: error handling
838 INetURLObject
aURL( m_pImpl
->m_aURL
);
839 aURL
.Append( aElementName
);
841 if ( !::utl::UCBContentHelper::IsFolder( aURL
.GetMainURL( INetURLObject::NO_DECODE
) )
842 && !::utl::UCBContentHelper::IsDocument( aURL
.GetMainURL( INetURLObject::NO_DECODE
) ) )
843 throw container::NoSuchElementException(); // TODO:
845 ::utl::UCBContentHelper::Kill( aURL
.GetMainURL( INetURLObject::NO_DECODE
) );
848 //-----------------------------------------------
849 void SAL_CALL
FSStorage::renameElement( const OUString
& aElementName
, const OUString
& aNewName
)
850 throw ( embed::InvalidStorageException
,
851 lang::IllegalArgumentException
,
852 container::NoSuchElementException
,
853 container::ElementExistException
,
855 embed::StorageWrappedTargetException
,
856 uno::RuntimeException
)
858 ::osl::MutexGuard
aGuard( m_aMutex
);
861 throw lang::DisposedException();
864 throw io::IOException(); // TODO: error handling
866 INetURLObject
aOldURL( m_pImpl
->m_aURL
);
867 aOldURL
.Append( aElementName
);
869 INetURLObject
aNewURL( m_pImpl
->m_aURL
);
870 aNewURL
.Append( aNewName
);
872 if ( !::utl::UCBContentHelper::IsFolder( aOldURL
.GetMainURL( INetURLObject::NO_DECODE
) )
873 && !::utl::UCBContentHelper::IsDocument( aOldURL
.GetMainURL( INetURLObject::NO_DECODE
) ) )
874 throw container::NoSuchElementException(); // TODO:
876 if ( ::utl::UCBContentHelper::IsFolder( aNewURL
.GetMainURL( INetURLObject::NO_DECODE
) )
877 || ::utl::UCBContentHelper::IsDocument( aNewURL
.GetMainURL( INetURLObject::NO_DECODE
) ) )
878 throw container::ElementExistException(); // TODO:
882 uno::Reference
< ucb::XCommandEnvironment
> xDummyEnv
;
883 ::ucbhelper::Content
aSourceContent( aOldURL
.GetMainURL( INetURLObject::NO_DECODE
), xDummyEnv
, comphelper::getProcessComponentContext() );
885 if ( !GetContent()->transferContent( aSourceContent
,
886 ::ucbhelper::InsertOperation_MOVE
,
888 ucb::NameClash::ERROR
) )
889 throw io::IOException(); // TODO: error handling
891 catch( embed::InvalidStorageException
& )
895 catch( lang::IllegalArgumentException
& )
899 catch( container::NoSuchElementException
& )
903 catch( container::ElementExistException
& )
907 catch( io::IOException
& )
911 catch( embed::StorageWrappedTargetException
& )
915 catch( uno::RuntimeException
& )
919 catch( uno::Exception
& )
921 uno::Any
aCaught( ::cppu::getCaughtException() );
922 throw embed::StorageWrappedTargetException( OUString("Can't copy raw stream"),
923 uno::Reference
< io::XInputStream
>(),
928 //-----------------------------------------------
929 void SAL_CALL
FSStorage::copyElementTo( const OUString
& aElementName
,
930 const uno::Reference
< embed::XStorage
>& xDest
,
931 const OUString
& aNewName
)
932 throw ( embed::InvalidStorageException
,
933 lang::IllegalArgumentException
,
934 container::NoSuchElementException
,
935 container::ElementExistException
,
937 embed::StorageWrappedTargetException
,
938 uno::RuntimeException
)
940 ::osl::MutexGuard
aGuard( m_aMutex
);
943 throw lang::DisposedException();
946 throw uno::RuntimeException();
949 throw io::IOException(); // TODO: error handling
951 INetURLObject
aOwnURL( m_pImpl
->m_aURL
);
952 aOwnURL
.Append( aElementName
);
954 if ( xDest
->hasByName( aNewName
) )
955 throw container::ElementExistException(); // TODO:
959 uno::Reference
< ucb::XCommandEnvironment
> xDummyEnv
;
960 if ( ::utl::UCBContentHelper::IsFolder( aOwnURL
.GetMainURL( INetURLObject::NO_DECODE
) ) )
962 ::ucbhelper::Content
aSourceContent( aOwnURL
.GetMainURL( INetURLObject::NO_DECODE
), xDummyEnv
, comphelper::getProcessComponentContext() );
963 uno::Reference
< embed::XStorage
> xDestSubStor(
964 xDest
->openStorageElement( aNewName
, embed::ElementModes::READWRITE
),
965 uno::UNO_QUERY_THROW
);
967 CopyContentToStorage_Impl( &aSourceContent
, xDestSubStor
);
969 else if ( ::utl::UCBContentHelper::IsDocument( aOwnURL
.GetMainURL( INetURLObject::NO_DECODE
) ) )
971 CopyStreamToSubStream( aOwnURL
.GetMainURL( INetURLObject::NO_DECODE
), xDest
, aNewName
);
974 throw container::NoSuchElementException(); // TODO:
976 catch( embed::InvalidStorageException
& )
980 catch( lang::IllegalArgumentException
& )
984 catch( container::NoSuchElementException
& )
988 catch( container::ElementExistException
& )
992 catch( embed::StorageWrappedTargetException
& )
996 catch( io::IOException
& )
1000 catch( uno::RuntimeException
& )
1004 catch( uno::Exception
& )
1006 uno::Any
aCaught( ::cppu::getCaughtException() );
1007 throw embed::StorageWrappedTargetException( OUString("Can't copy raw stream"),
1008 uno::Reference
< io::XInputStream
>(),
1013 //-----------------------------------------------
1014 void SAL_CALL
FSStorage::moveElementTo( const OUString
& aElementName
,
1015 const uno::Reference
< embed::XStorage
>& xDest
,
1016 const OUString
& aNewName
)
1017 throw ( embed::InvalidStorageException
,
1018 lang::IllegalArgumentException
,
1019 container::NoSuchElementException
,
1020 container::ElementExistException
,
1022 embed::StorageWrappedTargetException
,
1023 uno::RuntimeException
)
1025 ::osl::MutexGuard
aGuard( m_aMutex
);
1026 copyElementTo( aElementName
, xDest
, aNewName
);
1028 INetURLObject
aOwnURL( m_pImpl
->m_aURL
);
1029 aOwnURL
.Append( aElementName
);
1030 if ( !::utl::UCBContentHelper::Kill( aOwnURL
.GetMainURL( INetURLObject::NO_DECODE
) ) )
1031 throw io::IOException(); // TODO: error handling
1034 //____________________________________________________________________________________________________
1036 //____________________________________________________________________________________________________
1038 //-----------------------------------------------
1039 uno::Any SAL_CALL
FSStorage::getByName( const OUString
& aName
)
1040 throw ( container::NoSuchElementException
,
1041 lang::WrappedTargetException
,
1042 uno::RuntimeException
)
1044 ::osl::MutexGuard
aGuard( m_aMutex
);
1047 throw lang::DisposedException();
1049 if ( !GetContent() )
1050 throw io::IOException(); // TODO: error handling
1052 if ( aName
.isEmpty() )
1053 throw lang::IllegalArgumentException();
1055 INetURLObject
aURL( m_pImpl
->m_aURL
);
1056 aURL
.Append( aName
);
1061 if ( ::utl::UCBContentHelper::IsFolder( aURL
.GetMainURL( INetURLObject::NO_DECODE
) ) )
1063 aResult
<<= openStorageElement( aName
, embed::ElementModes::READ
);
1065 else if ( ::utl::UCBContentHelper::IsDocument( aURL
.GetMainURL( INetURLObject::NO_DECODE
) ) )
1067 aResult
<<= openStreamElement( aName
, embed::ElementModes::READ
);
1070 throw container::NoSuchElementException(); // TODO:
1072 catch( container::NoSuchElementException
& )
1076 catch( lang::WrappedTargetException
& )
1080 catch( uno::RuntimeException
& )
1084 catch ( uno::Exception
& )
1086 uno::Any
aCaught( ::cppu::getCaughtException() );
1087 throw lang::WrappedTargetException( OUString("Can not open element!\n"),
1088 uno::Reference
< uno::XInterface
>( static_cast< OWeakObject
* >( this ),
1097 //-----------------------------------------------
1098 uno::Sequence
< OUString
> SAL_CALL
FSStorage::getElementNames()
1099 throw ( uno::RuntimeException
)
1101 ::osl::MutexGuard
aGuard( m_aMutex
);
1104 throw lang::DisposedException();
1106 if ( !GetContent() )
1107 throw io::IOException(); // TODO: error handling
1109 uno::Sequence
< OUString
> aProps( 1 );
1110 OUString
* pProps
= aProps
.getArray();
1111 pProps
[0] = OUString("Title");
1112 ::ucbhelper::ResultSetInclude eInclude
= ::ucbhelper::INCLUDE_FOLDERS_AND_DOCUMENTS
;
1114 uno::Sequence
< OUString
> aResult
;
1115 sal_Int32 nSize
= 0;
1119 uno::Reference
< sdbc::XResultSet
> xResultSet
= GetContent()->createCursor( aProps
, eInclude
);
1120 uno::Reference
< ucb::XContentAccess
> xContentAccess( xResultSet
, uno::UNO_QUERY
);
1121 uno::Reference
< sdbc::XRow
> xRow( xResultSet
, uno::UNO_QUERY
);
1122 if ( xResultSet
.is() )
1124 // go through the list
1125 while ( xResultSet
->next() )
1127 OUString
aName( xRow
->getString( 1 ) );
1128 aResult
.realloc( ++nSize
);
1129 aResult
[nSize
-1] = aName
;
1133 catch( const ucb::InteractiveIOException
& r
)
1135 if ( r
.Code
== ucb::IOErrorCode_NOT_EXISTING
)
1136 OSL_FAIL( "The folder does not exist!\n" );
1139 uno::Any
aCaught( ::cppu::getCaughtException() );
1140 throw lang::WrappedTargetRuntimeException( OUString("Can not open storage!\n"),
1141 uno::Reference
< uno::XInterface
>( static_cast< OWeakObject
* >( this ),
1146 catch( uno::RuntimeException
& )
1150 catch ( uno::Exception
& )
1152 uno::Any
aCaught( ::cppu::getCaughtException() );
1153 throw lang::WrappedTargetRuntimeException( OUString("Can not open storage!\n"),
1154 uno::Reference
< uno::XInterface
>( static_cast< OWeakObject
* >( this ),
1163 //-----------------------------------------------
1164 sal_Bool SAL_CALL
FSStorage::hasByName( const OUString
& aName
)
1165 throw ( uno::RuntimeException
)
1167 ::osl::MutexGuard
aGuard( m_aMutex
);
1170 throw lang::DisposedException();
1174 if ( !GetContent() )
1175 throw io::IOException(); // TODO: error handling
1177 if ( aName
.isEmpty() )
1178 throw lang::IllegalArgumentException();
1180 catch( uno::RuntimeException
& )
1184 catch ( uno::Exception
& )
1186 uno::Any
aCaught( ::cppu::getCaughtException() );
1187 throw lang::WrappedTargetRuntimeException( OUString("Can not open storage!\n"),
1188 uno::Reference
< uno::XInterface
>( static_cast< OWeakObject
* >( this ),
1193 INetURLObject
aURL( m_pImpl
->m_aURL
);
1194 aURL
.Append( aName
);
1196 return ( ::utl::UCBContentHelper::IsFolder( aURL
.GetMainURL( INetURLObject::NO_DECODE
) )
1197 || ::utl::UCBContentHelper::IsDocument( aURL
.GetMainURL( INetURLObject::NO_DECODE
) ) );
1200 //-----------------------------------------------
1201 uno::Type SAL_CALL
FSStorage::getElementType()
1202 throw ( uno::RuntimeException
)
1204 ::osl::MutexGuard
aGuard( m_aMutex
);
1207 throw lang::DisposedException();
1209 // it is a multitype container
1213 //-----------------------------------------------
1214 sal_Bool SAL_CALL
FSStorage::hasElements()
1215 throw ( uno::RuntimeException
)
1217 ::osl::MutexGuard
aGuard( m_aMutex
);
1220 throw lang::DisposedException();
1222 if ( !GetContent() )
1223 throw io::IOException(); // TODO: error handling
1225 uno::Sequence
< OUString
> aProps( 1 );
1226 aProps
[0] = OUString("TargetURL");
1227 ::ucbhelper::ResultSetInclude eInclude
= ::ucbhelper::INCLUDE_FOLDERS_AND_DOCUMENTS
;
1231 uno::Reference
< sdbc::XResultSet
> xResultSet
= GetContent()->createCursor( aProps
, eInclude
);
1232 return ( xResultSet
.is() && xResultSet
->next() );
1234 catch( uno::Exception
& )
1236 throw uno::RuntimeException();
1241 //____________________________________________________________________________________________________
1243 //____________________________________________________________________________________________________
1245 //-----------------------------------------------
1246 void SAL_CALL
FSStorage::dispose()
1247 throw ( uno::RuntimeException
)
1249 ::osl::MutexGuard
aGuard( m_aMutex
);
1252 throw lang::DisposedException();
1254 if ( m_pImpl
->m_pListenersContainer
)
1256 lang::EventObject
aSource( static_cast< ::cppu::OWeakObject
* >(this) );
1257 m_pImpl
->m_pListenersContainer
->disposeAndClear( aSource
);
1264 //-----------------------------------------------
1265 void SAL_CALL
FSStorage::addEventListener(
1266 const uno::Reference
< lang::XEventListener
>& xListener
)
1267 throw ( uno::RuntimeException
)
1269 ::osl::MutexGuard
aGuard( m_aMutex
);
1272 throw lang::DisposedException();
1274 if ( !m_pImpl
->m_pListenersContainer
)
1275 m_pImpl
->m_pListenersContainer
= new ::cppu::OInterfaceContainerHelper( m_aMutex
);
1277 m_pImpl
->m_pListenersContainer
->addInterface( xListener
);
1280 //-----------------------------------------------
1281 void SAL_CALL
FSStorage::removeEventListener(
1282 const uno::Reference
< lang::XEventListener
>& xListener
)
1283 throw ( uno::RuntimeException
)
1285 ::osl::MutexGuard
aGuard( m_aMutex
);
1288 throw lang::DisposedException();
1290 if ( m_pImpl
->m_pListenersContainer
)
1291 m_pImpl
->m_pListenersContainer
->removeInterface( xListener
);
1294 //____________________________________________________________________________________________________
1296 //____________________________________________________________________________________________________
1298 //-----------------------------------------------
1299 uno::Reference
< beans::XPropertySetInfo
> SAL_CALL
FSStorage::getPropertySetInfo()
1300 throw ( uno::RuntimeException
)
1302 ::osl::MutexGuard
aGuard( m_aMutex
);
1305 throw lang::DisposedException();
1308 return uno::Reference
< beans::XPropertySetInfo
>();
1312 //-----------------------------------------------
1313 void SAL_CALL
FSStorage::setPropertyValue( const OUString
& aPropertyName
, const uno::Any
& )
1314 throw ( beans::UnknownPropertyException
,
1315 beans::PropertyVetoException
,
1316 lang::IllegalArgumentException
,
1317 lang::WrappedTargetException
,
1318 uno::RuntimeException
)
1320 ::osl::MutexGuard
aGuard( m_aMutex
);
1323 throw lang::DisposedException();
1325 if ( aPropertyName
== "URL" || aPropertyName
== "OpenMode" )
1326 throw beans::PropertyVetoException(); // TODO
1328 throw beans::UnknownPropertyException(); // TODO
1332 //-----------------------------------------------
1333 uno::Any SAL_CALL
FSStorage::getPropertyValue( const OUString
& aPropertyName
)
1334 throw ( beans::UnknownPropertyException
,
1335 lang::WrappedTargetException
,
1336 uno::RuntimeException
)
1338 ::osl::MutexGuard
aGuard( m_aMutex
);
1341 throw lang::DisposedException();
1343 if ( aPropertyName
== "URL" )
1344 return uno::makeAny( m_pImpl
->m_aURL
);
1345 else if ( aPropertyName
== "OpenMode" )
1346 return uno::makeAny( m_pImpl
->m_nMode
);
1348 throw beans::UnknownPropertyException(); // TODO
1352 //-----------------------------------------------
1353 void SAL_CALL
FSStorage::addPropertyChangeListener(
1354 const OUString
& /*aPropertyName*/,
1355 const uno::Reference
< beans::XPropertyChangeListener
>& /*xListener*/ )
1356 throw ( beans::UnknownPropertyException
,
1357 lang::WrappedTargetException
,
1358 uno::RuntimeException
)
1360 ::osl::MutexGuard
aGuard( m_aMutex
);
1363 throw lang::DisposedException();
1369 //-----------------------------------------------
1370 void SAL_CALL
FSStorage::removePropertyChangeListener(
1371 const OUString
& /*aPropertyName*/,
1372 const uno::Reference
< beans::XPropertyChangeListener
>& /*aListener*/ )
1373 throw ( beans::UnknownPropertyException
,
1374 lang::WrappedTargetException
,
1375 uno::RuntimeException
)
1377 ::osl::MutexGuard
aGuard( m_aMutex
);
1380 throw lang::DisposedException();
1386 //-----------------------------------------------
1387 void SAL_CALL
FSStorage::addVetoableChangeListener(
1388 const OUString
& /*PropertyName*/,
1389 const uno::Reference
< beans::XVetoableChangeListener
>& /*aListener*/ )
1390 throw ( beans::UnknownPropertyException
,
1391 lang::WrappedTargetException
,
1392 uno::RuntimeException
)
1394 ::osl::MutexGuard
aGuard( m_aMutex
);
1397 throw lang::DisposedException();
1403 //-----------------------------------------------
1404 void SAL_CALL
FSStorage::removeVetoableChangeListener(
1405 const OUString
& /*PropertyName*/,
1406 const uno::Reference
< beans::XVetoableChangeListener
>& /*aListener*/ )
1407 throw ( beans::UnknownPropertyException
,
1408 lang::WrappedTargetException
,
1409 uno::RuntimeException
)
1411 ::osl::MutexGuard
aGuard( m_aMutex
);
1414 throw lang::DisposedException();
1419 //____________________________________________________________________________________________________
1420 // XHierarchicalStorageAccess
1421 //____________________________________________________________________________________________________
1422 //-----------------------------------------------
1423 uno::Reference
< embed::XExtendedStorageStream
> SAL_CALL
FSStorage::openStreamElementByHierarchicalName( const OUString
& sStreamPath
, ::sal_Int32 nOpenMode
)
1424 throw ( embed::InvalidStorageException
,
1425 lang::IllegalArgumentException
,
1426 packages::WrongPasswordException
,
1428 embed::StorageWrappedTargetException
,
1429 uno::RuntimeException
)
1431 ::osl::MutexGuard
aGuard( m_aMutex
);
1434 throw lang::DisposedException();
1436 if ( sStreamPath
.toChar() == '/' )
1437 throw lang::IllegalArgumentException();
1439 if ( !GetContent() )
1440 throw io::IOException(); // TODO: error handling
1442 INetURLObject
aBaseURL( m_pImpl
->m_aURL
);
1443 if ( !aBaseURL
.setFinalSlash() )
1444 throw uno::RuntimeException();
1446 INetURLObject aFileURL
= INetURLObject::GetAbsURL(
1447 aBaseURL
.GetMainURL( INetURLObject::NO_DECODE
),
1450 if ( ::utl::UCBContentHelper::IsFolder( aFileURL
.GetMainURL( INetURLObject::NO_DECODE
) ) )
1451 throw io::IOException();
1453 if ( ( nOpenMode
& embed::ElementModes::NOCREATE
)
1454 && !::utl::UCBContentHelper::IsDocument( aFileURL
.GetMainURL( INetURLObject::NO_DECODE
) ) )
1455 throw io::IOException(); // TODO:
1457 uno::Reference
< ucb::XCommandEnvironment
> xDummyEnv
; // TODO: provide InteractionHandler if any
1458 uno::Reference
< io::XStream
> xResult
;
1461 if ( nOpenMode
& embed::ElementModes::WRITE
)
1463 if ( isLocalFile_Impl( aFileURL
.GetMainURL( INetURLObject::NO_DECODE
) ) )
1465 uno::Reference
<ucb::XSimpleFileAccess3
> xSimpleFileAccess(
1466 ucb::SimpleFileAccess::create(
1467 comphelper::getComponentContext(m_pImpl
->m_xFactory
) ) );
1468 uno::Reference
< io::XStream
> xStream
=
1469 xSimpleFileAccess
->openFileReadWrite( aFileURL
.GetMainURL( INetURLObject::NO_DECODE
) );
1471 xResult
= static_cast< io::XStream
* >( new OFSStreamContainer( xStream
) );
1475 // TODO: test whether it really works for http and fwp
1476 SvStream
* pStream
= ::utl::UcbStreamHelper::CreateStream( aFileURL
.GetMainURL( INetURLObject::NO_DECODE
),
1480 if ( !pStream
->GetError() )
1482 uno::Reference
< io::XStream
> xStream
=
1483 uno::Reference
< io::XStream
>( new ::utl::OStreamWrapper( *pStream
) );
1484 xResult
= static_cast< io::XStream
* >( new OFSStreamContainer( xStream
) );
1491 if ( !xResult
.is() )
1492 throw io::IOException();
1494 if ( ( nOpenMode
& embed::ElementModes::TRUNCATE
) )
1496 uno::Reference
< io::XTruncate
> xTrunc( xResult
->getOutputStream(), uno::UNO_QUERY_THROW
);
1502 if ( ( nOpenMode
& embed::ElementModes::TRUNCATE
)
1503 || !::utl::UCBContentHelper::IsDocument( aFileURL
.GetMainURL( INetURLObject::NO_DECODE
) ) )
1504 throw io::IOException(); // TODO: access denied
1506 ::ucbhelper::Content
aResultContent( aFileURL
.GetMainURL( INetURLObject::NO_DECODE
), xDummyEnv
, comphelper::getProcessComponentContext() );
1507 uno::Reference
< io::XInputStream
> xInStream
= aResultContent
.openStream();
1508 xResult
= static_cast< io::XStream
* >( new OFSInputStreamContainer( xInStream
) );
1511 catch( embed::InvalidStorageException
& )
1515 catch( lang::IllegalArgumentException
& )
1519 catch( packages::WrongPasswordException
& )
1523 catch( embed::StorageWrappedTargetException
& )
1527 catch( io::IOException
& )
1531 catch( uno::RuntimeException
& )
1535 catch( uno::Exception
& )
1537 uno::Any
aCaught( ::cppu::getCaughtException() );
1538 throw embed::StorageWrappedTargetException( OUString("Can't copy raw stream"),
1539 uno::Reference
< io::XInputStream
>(),
1543 return uno::Reference
< embed::XExtendedStorageStream
>( xResult
, uno::UNO_QUERY_THROW
);
1546 //-----------------------------------------------
1547 uno::Reference
< embed::XExtendedStorageStream
> SAL_CALL
FSStorage::openEncryptedStreamElementByHierarchicalName( const OUString
& /*sStreamName*/, ::sal_Int32
/*nOpenMode*/, const OUString
& /*sPassword*/ )
1548 throw ( embed::InvalidStorageException
,
1549 lang::IllegalArgumentException
,
1550 packages::NoEncryptionException
,
1551 packages::WrongPasswordException
,
1553 embed::StorageWrappedTargetException
,
1554 uno::RuntimeException
)
1556 throw packages::NoEncryptionException();
1559 //-----------------------------------------------
1560 void SAL_CALL
FSStorage::removeStreamElementByHierarchicalName( const OUString
& sStreamPath
)
1561 throw ( embed::InvalidStorageException
,
1562 lang::IllegalArgumentException
,
1563 container::NoSuchElementException
,
1565 embed::StorageWrappedTargetException
,
1566 uno::RuntimeException
)
1568 ::osl::MutexGuard
aGuard( m_aMutex
);
1571 throw lang::DisposedException();
1573 if ( !GetContent() )
1574 throw io::IOException(); // TODO: error handling
1576 // TODO/LATER: may need possibility to create folder if it was removed, since the folder can not be locked
1577 INetURLObject
aBaseURL( m_pImpl
->m_aURL
);
1578 if ( !aBaseURL
.setFinalSlash() )
1579 throw uno::RuntimeException();
1581 INetURLObject aFileURL
= INetURLObject::GetAbsURL(
1582 aBaseURL
.GetMainURL( INetURLObject::NO_DECODE
),
1585 if ( !::utl::UCBContentHelper::IsDocument( aFileURL
.GetMainURL( INetURLObject::NO_DECODE
) ) )
1587 if ( ::utl::UCBContentHelper::IsFolder( aFileURL
.GetMainURL( INetURLObject::NO_DECODE
) ) )
1588 throw lang::IllegalArgumentException();
1590 throw container::NoSuchElementException(); // TODO:
1593 if ( !::utl::UCBContentHelper::Kill( aFileURL
.GetMainURL( INetURLObject::NO_DECODE
) ) )
1594 throw io::IOException(); // TODO: error handling
1598 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */