summaryrefslogtreecommitdiff
path: root/comphelper
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2012-12-10 14:39:29 +0200
committerNoel Grandin <noel@peralex.com>2012-12-13 05:20:57 +0200
commit2f998bdf8f5c504f09833febe0cd16ce743f57a5 (patch)
tree77e69afc15cb85acff9b56c62b1947f5edd48aca /comphelper
parent90a0116ccb48388d91b21128fcac2e4609838581 (diff)
fdo#46808, use service constructor for embed::FileSystemStorageFactory
Change-Id: Ic523e4b0a662a68a1a222b7697fcdae56d69903c
Diffstat (limited to 'comphelper')
-rw-r--r--comphelper/inc/comphelper/storagehelper.hxx10
-rw-r--r--comphelper/source/misc/storagehelper.cxx27
2 files changed, 12 insertions, 25 deletions
diff --git a/comphelper/inc/comphelper/storagehelper.hxx b/comphelper/inc/comphelper/storagehelper.hxx
index e98a40727688..2c0a45518b02 100644
--- a/comphelper/inc/comphelper/storagehelper.hxx
+++ b/comphelper/inc/comphelper/storagehelper.hxx
@@ -77,8 +77,8 @@ public:
static ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory >
GetFileSystemStorageFactory(
- const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xSF
- = ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >() )
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext
+ = ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >() )
throw ( ::com::sun::star::uno::Exception );
static ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >
@@ -92,7 +92,7 @@ public:
GetStorageFromURL(
const ::rtl::OUString& aURL,
sal_Int32 nStorageMode,
- const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xrxContext
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext
= ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >() )
throw ( ::com::sun::star::uno::Exception );
@@ -101,8 +101,8 @@ public:
GetStorageFromURL2(
const ::rtl::OUString& aURL,
sal_Int32 nStorageMode,
- const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory
- = ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >() )
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext
+ = ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >() )
throw ( ::com::sun::star::uno::Exception );
diff --git a/comphelper/source/misc/storagehelper.cxx b/comphelper/source/misc/storagehelper.cxx
index 888a8b3596f0..b7190663a7e0 100644
--- a/comphelper/source/misc/storagehelper.cxx
+++ b/comphelper/source/misc/storagehelper.cxx
@@ -22,6 +22,7 @@
#include <com/sun/star/embed/XStorage.hpp>
#include <com/sun/star/embed/XTransactedObject.hpp>
#include <com/sun/star/embed/StorageFactory.hpp>
+#include <com/sun/star/embed/FileSystemStorageFactory.hpp>
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
#include <com/sun/star/ucb/SimpleFileAccess.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
@@ -60,26 +61,12 @@ uno::Reference< lang::XSingleServiceFactory > OStorageHelper::GetStorageFactory(
// ----------------------------------------------------------------------
uno::Reference< lang::XSingleServiceFactory > OStorageHelper::GetFileSystemStorageFactory(
- const uno::Reference< lang::XMultiServiceFactory >& xSF )
+ const uno::Reference< uno::XComponentContext >& rxContext )
throw ( uno::Exception )
{
- uno::Reference< lang::XMultiServiceFactory > xFactory = xSF.is() ? xSF : ::comphelper::getProcessServiceFactory();
- if ( !xFactory.is() )
- throw uno::RuntimeException();
-
- rtl::OUString sService(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.embed.FileSystemStorageFactory"));
-
- uno::Reference < lang::XSingleServiceFactory > xStorageFactory(
- xFactory->createInstance(sService), uno::UNO_QUERY);
-
- if ( !xStorageFactory.is() )
- {
- throw uno::RuntimeException(rtl::OUString(
- RTL_CONSTASCII_USTRINGPARAM("Could not load: ")) + sService,
- uno::Reference< uno::XInterface >());
- }
+ uno::Reference< uno::XComponentContext> xContext = rxContext.is() ? rxContext : ::comphelper::getProcessComponentContext();
- return xStorageFactory;
+ return embed::FileSystemStorageFactory::create(rxContext);
}
// ----------------------------------------------------------------------
@@ -118,7 +105,7 @@ 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 )
+ const uno::Reference< uno::XComponentContext >& rxContext )
throw ( uno::Exception )
{
uno::Sequence< uno::Any > aArgs( 2 );
@@ -131,9 +118,9 @@ uno::Reference< embed::XStorage > OStorageHelper::GetStorageFromURL2(
uno::Reference< ::com::sun::star::ucb::XCommandEnvironment > (),
getProcessComponentContext() );
if (aCntnt.isDocument()) {
- xFact = GetStorageFactory( comphelper::getComponentContext(xFactory) );
+ xFact = GetStorageFactory( rxContext );
} else {
- xFact = GetFileSystemStorageFactory( xFactory );
+ xFact = GetFileSystemStorageFactory( rxContext );
}
} catch (uno::Exception &) { }