summaryrefslogtreecommitdiff
path: root/comphelper/source/misc/storagehelper.cxx
diff options
context:
space:
mode:
authorVladimir Glazounov <vg@openoffice.org>2008-07-01 15:28:43 +0000
committerVladimir Glazounov <vg@openoffice.org>2008-07-01 15:28:43 +0000
commit7055b132690aea4dcec7971f5c4b7dd2d91be130 (patch)
treeea4a67e9827886b408d98840d09f25ff5ea23dc1 /comphelper/source/misc/storagehelper.cxx
parentf2f25eacd6d9e23f1158afb9c3891ad65d3805d8 (diff)
INTEGRATION: CWS odfmetadata (1.12.34); FILE MERGED
2008/06/11 16:26:59 mst 1.12.34.1: - comphelper/inc/comphelper/storagehelper.hxx, comphelper/source/misc/storagehelper.cxx: + new static methods GetFileSystemStorageFactory, GetStorageFromURL2
Diffstat (limited to 'comphelper/source/misc/storagehelper.cxx')
-rw-r--r--comphelper/source/misc/storagehelper.cxx56
1 files changed, 55 insertions, 1 deletions
diff --git a/comphelper/source/misc/storagehelper.cxx b/comphelper/source/misc/storagehelper.cxx
index bd1e1ac48d17..177d974f8cb4 100644
--- a/comphelper/source/misc/storagehelper.cxx
+++ b/comphelper/source/misc/storagehelper.cxx
@@ -7,7 +7,7 @@
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: storagehelper.cxx,v $
- * $Revision: 1.12 $
+ * $Revision: 1.13 $
*
* This file is part of OpenOffice.org.
*
@@ -37,12 +37,15 @@
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/beans/IllegalTypeException.hpp>
+#include <ucbhelper/content.hxx>
+
#include <comphelper/fileformat.h>
#include <comphelper/processfactory.hxx>
#include <comphelper/documentconstants.hxx>
#include <comphelper/storagehelper.hxx>
+
using namespace ::com::sun::star;
namespace comphelper {
@@ -67,6 +70,25 @@ uno::Reference< lang::XSingleServiceFactory > OStorageHelper::GetStorageFactory(
}
// ----------------------------------------------------------------------
+uno::Reference< lang::XSingleServiceFactory > OStorageHelper::GetFileSystemStorageFactory(
+ const uno::Reference< lang::XMultiServiceFactory >& xSF )
+ throw ( uno::Exception )
+{
+ uno::Reference< lang::XMultiServiceFactory > xFactory = xSF.is() ? xSF : ::comphelper::getProcessServiceFactory();
+ if ( !xFactory.is() )
+ throw uno::RuntimeException();
+
+ uno::Reference < lang::XSingleServiceFactory > xStorageFactory(
+ xFactory->createInstance ( ::rtl::OUString::createFromAscii( "com.sun.star.embed.FileSystemStorageFactory" ) ),
+ uno::UNO_QUERY );
+
+ if ( !xStorageFactory.is() )
+ throw uno::RuntimeException();
+
+ return xStorageFactory;
+}
+
+// ----------------------------------------------------------------------
uno::Reference< embed::XStorage > OStorageHelper::GetTemporaryStorage(
const uno::Reference< lang::XMultiServiceFactory >& xFactory )
throw ( uno::Exception )
@@ -99,6 +121,38 @@ uno::Reference< embed::XStorage > OStorageHelper::GetStorageFromURL(
}
// ----------------------------------------------------------------------
+uno::Reference< embed::XStorage > OStorageHelper::GetStorageFromURL2(
+ const ::rtl::OUString& aURL,
+ sal_Int32 nStorageMode,
+ const uno::Reference< lang::XMultiServiceFactory >& xFactory )
+ throw ( uno::Exception )
+{
+ uno::Sequence< uno::Any > aArgs( 2 );
+ aArgs[0] <<= aURL;
+ aArgs[1] <<= nStorageMode;
+
+ uno::Reference< lang::XSingleServiceFactory > xFact;
+ try {
+ ::ucbhelper::Content aCntnt( aURL,
+ uno::Reference< ::com::sun::star::ucb::XCommandEnvironment > () );
+ if (aCntnt.isDocument()) {
+ xFact = GetStorageFactory( xFactory );
+ } else {
+ xFact = GetFileSystemStorageFactory( xFactory );
+ }
+ } catch (uno::Exception &) { }
+
+ if (!xFact.is()) throw uno::RuntimeException();
+
+ uno::Reference< embed::XStorage > xTempStorage(
+ xFact->createInstanceWithArguments( aArgs ), uno::UNO_QUERY );
+ if ( !xTempStorage.is() )
+ throw uno::RuntimeException();
+
+ return xTempStorage;
+}
+
+// ----------------------------------------------------------------------
uno::Reference< embed::XStorage > OStorageHelper::GetStorageFromInputStream(
const uno::Reference < io::XInputStream >& xStream,
const uno::Reference< lang::XMultiServiceFactory >& xFactory )