fdo#46808, use service constructor for embed::FileSystemStorageFactory
Change-Id: Ic523e4b0a662a68a1a222b7697fcdae56d69903c
This commit is contained in:
@@ -77,8 +77,8 @@ public:
|
|||||||
|
|
||||||
static ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory >
|
static ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory >
|
||||||
GetFileSystemStorageFactory(
|
GetFileSystemStorageFactory(
|
||||||
const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xSF
|
const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext
|
||||||
= ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >() )
|
= ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >() )
|
||||||
throw ( ::com::sun::star::uno::Exception );
|
throw ( ::com::sun::star::uno::Exception );
|
||||||
|
|
||||||
static ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >
|
static ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >
|
||||||
@@ -92,7 +92,7 @@ public:
|
|||||||
GetStorageFromURL(
|
GetStorageFromURL(
|
||||||
const ::rtl::OUString& aURL,
|
const ::rtl::OUString& aURL,
|
||||||
sal_Int32 nStorageMode,
|
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 >() )
|
= ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >() )
|
||||||
throw ( ::com::sun::star::uno::Exception );
|
throw ( ::com::sun::star::uno::Exception );
|
||||||
|
|
||||||
@@ -101,8 +101,8 @@ public:
|
|||||||
GetStorageFromURL2(
|
GetStorageFromURL2(
|
||||||
const ::rtl::OUString& aURL,
|
const ::rtl::OUString& aURL,
|
||||||
sal_Int32 nStorageMode,
|
sal_Int32 nStorageMode,
|
||||||
const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory
|
const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext
|
||||||
= ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >() )
|
= ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >() )
|
||||||
|
|
||||||
throw ( ::com::sun::star::uno::Exception );
|
throw ( ::com::sun::star::uno::Exception );
|
||||||
|
|
||||||
|
@@ -22,6 +22,7 @@
|
|||||||
#include <com/sun/star/embed/XStorage.hpp>
|
#include <com/sun/star/embed/XStorage.hpp>
|
||||||
#include <com/sun/star/embed/XTransactedObject.hpp>
|
#include <com/sun/star/embed/XTransactedObject.hpp>
|
||||||
#include <com/sun/star/embed/StorageFactory.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/lang/XSingleServiceFactory.hpp>
|
||||||
#include <com/sun/star/ucb/SimpleFileAccess.hpp>
|
#include <com/sun/star/ucb/SimpleFileAccess.hpp>
|
||||||
#include <com/sun/star/beans/XPropertySet.hpp>
|
#include <com/sun/star/beans/XPropertySet.hpp>
|
||||||
@@ -60,26 +61,12 @@ uno::Reference< lang::XSingleServiceFactory > OStorageHelper::GetStorageFactory(
|
|||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
uno::Reference< lang::XSingleServiceFactory > OStorageHelper::GetFileSystemStorageFactory(
|
uno::Reference< lang::XSingleServiceFactory > OStorageHelper::GetFileSystemStorageFactory(
|
||||||
const uno::Reference< lang::XMultiServiceFactory >& xSF )
|
const uno::Reference< uno::XComponentContext >& rxContext )
|
||||||
throw ( uno::Exception )
|
throw ( uno::Exception )
|
||||||
{
|
{
|
||||||
uno::Reference< lang::XMultiServiceFactory > xFactory = xSF.is() ? xSF : ::comphelper::getProcessServiceFactory();
|
uno::Reference< uno::XComponentContext> xContext = rxContext.is() ? rxContext : ::comphelper::getProcessComponentContext();
|
||||||
if ( !xFactory.is() )
|
|
||||||
throw uno::RuntimeException();
|
|
||||||
|
|
||||||
rtl::OUString sService(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.embed.FileSystemStorageFactory"));
|
return embed::FileSystemStorageFactory::create(rxContext);
|
||||||
|
|
||||||
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 >());
|
|
||||||
}
|
|
||||||
|
|
||||||
return xStorageFactory;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
@@ -118,7 +105,7 @@ uno::Reference< embed::XStorage > OStorageHelper::GetStorageFromURL(
|
|||||||
uno::Reference< embed::XStorage > OStorageHelper::GetStorageFromURL2(
|
uno::Reference< embed::XStorage > OStorageHelper::GetStorageFromURL2(
|
||||||
const ::rtl::OUString& aURL,
|
const ::rtl::OUString& aURL,
|
||||||
sal_Int32 nStorageMode,
|
sal_Int32 nStorageMode,
|
||||||
const uno::Reference< lang::XMultiServiceFactory >& xFactory )
|
const uno::Reference< uno::XComponentContext >& rxContext )
|
||||||
throw ( uno::Exception )
|
throw ( uno::Exception )
|
||||||
{
|
{
|
||||||
uno::Sequence< uno::Any > aArgs( 2 );
|
uno::Sequence< uno::Any > aArgs( 2 );
|
||||||
@@ -131,9 +118,9 @@ uno::Reference< embed::XStorage > OStorageHelper::GetStorageFromURL2(
|
|||||||
uno::Reference< ::com::sun::star::ucb::XCommandEnvironment > (),
|
uno::Reference< ::com::sun::star::ucb::XCommandEnvironment > (),
|
||||||
getProcessComponentContext() );
|
getProcessComponentContext() );
|
||||||
if (aCntnt.isDocument()) {
|
if (aCntnt.isDocument()) {
|
||||||
xFact = GetStorageFactory( comphelper::getComponentContext(xFactory) );
|
xFact = GetStorageFactory( rxContext );
|
||||||
} else {
|
} else {
|
||||||
xFact = GetFileSystemStorageFactory( xFactory );
|
xFact = GetFileSystemStorageFactory( rxContext );
|
||||||
}
|
}
|
||||||
} catch (uno::Exception &) { }
|
} catch (uno::Exception &) { }
|
||||||
|
|
||||||
|
@@ -68,7 +68,6 @@ namespace framework{
|
|||||||
#define SERVICENAME_GLOBALACCELERATORCONFIGURATION DECLARE_ASCII("com.sun.star.ui.GlobalAcceleratorConfiguration")
|
#define SERVICENAME_GLOBALACCELERATORCONFIGURATION DECLARE_ASCII("com.sun.star.ui.GlobalAcceleratorConfiguration")
|
||||||
#define SERVICENAME_MODULEACCELERATORCONFIGURATION DECLARE_ASCII("com.sun.star.ui.ModuleAcceleratorConfiguration")
|
#define SERVICENAME_MODULEACCELERATORCONFIGURATION DECLARE_ASCII("com.sun.star.ui.ModuleAcceleratorConfiguration")
|
||||||
#define SERVICENAME_DOCUMENTACCELERATORCONFIGURATION DECLARE_ASCII("com.sun.star.ui.DocumentAcceleratorConfiguration")
|
#define SERVICENAME_DOCUMENTACCELERATORCONFIGURATION DECLARE_ASCII("com.sun.star.ui.DocumentAcceleratorConfiguration")
|
||||||
#define SERVICENAME_FILESYSTEMSTORAGEFACTORY DECLARE_ASCII("com.sun.star.embed.FileSystemStorageFactory" )
|
|
||||||
#define SERVICENAME_PACKAGESTRUCTURECREATOR DECLARE_ASCII("com.sun.star.embed.PackageStructureCreator" )
|
#define SERVICENAME_PACKAGESTRUCTURECREATOR DECLARE_ASCII("com.sun.star.embed.PackageStructureCreator" )
|
||||||
#define SERVICENAME_TOOLBARFACTORY DECLARE_ASCII("com.sun.star.ui.ToolBarFactory" )
|
#define SERVICENAME_TOOLBARFACTORY DECLARE_ASCII("com.sun.star.ui.ToolBarFactory" )
|
||||||
#define SERVICENAME_TOOLBARCONTROLLERFACTORY DECLARE_ASCII("com.sun.star.frame.ToolBarControllerFactory" )
|
#define SERVICENAME_TOOLBARCONTROLLERFACTORY DECLARE_ASCII("com.sun.star.frame.ToolBarControllerFactory" )
|
||||||
|
@@ -32,6 +32,7 @@
|
|||||||
#include <com/sun/star/beans/XPropertySet.hpp>
|
#include <com/sun/star/beans/XPropertySet.hpp>
|
||||||
#include <com/sun/star/embed/ElementModes.hpp>
|
#include <com/sun/star/embed/ElementModes.hpp>
|
||||||
#include <com/sun/star/embed/XTransactedObject.hpp>
|
#include <com/sun/star/embed/XTransactedObject.hpp>
|
||||||
|
#include <com/sun/star/embed/FileSystemStorageFactory.hpp>
|
||||||
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
|
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
|
||||||
|
|
||||||
#include <vcl/svapp.hxx>
|
#include <vcl/svapp.hxx>
|
||||||
@@ -254,7 +255,7 @@ css::uno::Reference< css::embed::XStorage > PresetHandler::getOrCreateRootStorag
|
|||||||
lArgs[0] <<= sShareLayer;
|
lArgs[0] <<= sShareLayer;
|
||||||
lArgs[1] <<= css::embed::ElementModes::READ | css::embed::ElementModes::NOCREATE;
|
lArgs[1] <<= css::embed::ElementModes::READ | css::embed::ElementModes::NOCREATE;
|
||||||
|
|
||||||
css::uno::Reference< css::lang::XSingleServiceFactory > xStorageFactory(xSMGR->createInstance(SERVICENAME_FILESYSTEMSTORAGEFACTORY) , css::uno::UNO_QUERY_THROW);
|
css::uno::Reference< css::lang::XSingleServiceFactory > xStorageFactory = css::embed::FileSystemStorageFactory::create( comphelper::getComponentContext(xSMGR) );
|
||||||
css::uno::Reference< css::embed::XStorage > xStorage;
|
css::uno::Reference< css::embed::XStorage > xStorage;
|
||||||
|
|
||||||
try
|
try
|
||||||
@@ -304,7 +305,7 @@ css::uno::Reference< css::embed::XStorage > PresetHandler::getOrCreateRootStorag
|
|||||||
lArgs[0] <<= sUserLayer;
|
lArgs[0] <<= sUserLayer;
|
||||||
lArgs[1] <<= css::embed::ElementModes::READWRITE;
|
lArgs[1] <<= css::embed::ElementModes::READWRITE;
|
||||||
|
|
||||||
css::uno::Reference< css::lang::XSingleServiceFactory > xStorageFactory(xSMGR->createInstance(SERVICENAME_FILESYSTEMSTORAGEFACTORY) , css::uno::UNO_QUERY_THROW);
|
css::uno::Reference< css::lang::XSingleServiceFactory > xStorageFactory = css::embed::FileSystemStorageFactory::create( comphelper::getComponentContext(xSMGR) );
|
||||||
css::uno::Reference< css::embed::XStorage > xStorage;
|
css::uno::Reference< css::embed::XStorage > xStorage;
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@@ -1294,10 +1294,8 @@ throw (uno::RuntimeException, lang::IllegalArgumentException,
|
|||||||
xStorage = ::comphelper::OStorageHelper::GetStorageFromInputStream(
|
xStorage = ::comphelper::OStorageHelper::GetStorageFromInputStream(
|
||||||
xIn, m_pImpl->m_xContext);
|
xIn, m_pImpl->m_xContext);
|
||||||
} else { // fallback to url
|
} else { // fallback to url
|
||||||
const uno::Reference<lang::XMultiServiceFactory> xMsf (
|
|
||||||
m_pImpl->m_xContext->getServiceManager(), uno::UNO_QUERY_THROW);
|
|
||||||
xStorage = ::comphelper::OStorageHelper::GetStorageFromURL2(
|
xStorage = ::comphelper::OStorageHelper::GetStorageFromURL2(
|
||||||
URL, embed::ElementModes::READ, xMsf);
|
URL, embed::ElementModes::READ, m_pImpl->m_xContext);
|
||||||
}
|
}
|
||||||
} catch (const uno::RuntimeException &) {
|
} catch (const uno::RuntimeException &) {
|
||||||
throw;
|
throw;
|
||||||
@@ -1352,10 +1350,8 @@ throw (uno::RuntimeException, lang::IllegalArgumentException,
|
|||||||
if (xStorage.is()) {
|
if (xStorage.is()) {
|
||||||
sfx = true;
|
sfx = true;
|
||||||
} else {
|
} else {
|
||||||
const uno::Reference<lang::XMultiServiceFactory> xMsf (
|
|
||||||
m_pImpl->m_xContext->getServiceManager(), uno::UNO_QUERY_THROW);
|
|
||||||
xStorage = ::comphelper::OStorageHelper::GetStorageFromURL2(
|
xStorage = ::comphelper::OStorageHelper::GetStorageFromURL2(
|
||||||
URL, embed::ElementModes::WRITE, xMsf);
|
URL, embed::ElementModes::WRITE, m_pImpl->m_xContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!xStorage.is()) {
|
if (!xStorage.is()) {
|
||||||
|
Reference in New Issue
Block a user