summaryrefslogtreecommitdiff
path: root/svl
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2020-07-13 22:39:10 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-07-15 08:45:06 +0200
commit3e50a3023535d4e9e365db046442df1a758e70c4 (patch)
tree13e5f6943f75a8b5171494143631fe48ff845d90 /svl
parent0bca30bff7d9e49c81459122735565ff0d9816c3 (diff)
svl/fsstorage: create instances with uno constructors
See tdf#74608 for motivation. Change-Id: If5eec92f2c7707bd0c44b80d352d78a84962ff74 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98702 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svl')
-rw-r--r--svl/source/fsstor/fsfactory.cxx56
-rw-r--r--svl/source/fsstor/fsstorage.component5
-rw-r--r--svl/source/inc/fsfactory.hxx10
3 files changed, 13 insertions, 58 deletions
diff --git a/svl/source/fsstor/fsfactory.cxx b/svl/source/fsstor/fsfactory.cxx
index 0fec0cefefd6..2b596f1a7cc4 100644
--- a/svl/source/fsstor/fsfactory.cxx
+++ b/svl/source/fsstor/fsfactory.cxx
@@ -35,24 +35,6 @@
using namespace ::com::sun::star;
-uno::Sequence< OUString > FSStorageFactory::impl_staticGetSupportedServiceNames()
-{
- uno::Sequence< OUString > aRet(2);
- aRet[0] = "com.sun.star.embed.FileSystemStorageFactory";
- aRet[1] = "com.sun.star.comp.embed.FileSystemStorageFactory";
- return aRet;
-}
-
-OUString FSStorageFactory::impl_staticGetImplementationName()
-{
- return "com.sun.star.comp.embed.FileSystemStorageFactory";
-}
-
-uno::Reference< uno::XInterface > SAL_CALL FSStorageFactory::impl_staticCreateSelfInstance(
- const uno::Reference< lang::XMultiServiceFactory >& xServiceManager )
-{
- return uno::Reference< uno::XInterface >( *new FSStorageFactory( comphelper::getComponentContext(xServiceManager) ) );
-}
uno::Reference< uno::XInterface > SAL_CALL FSStorageFactory::createInstance()
{
@@ -153,7 +135,7 @@ uno::Reference< uno::XInterface > SAL_CALL FSStorageFactory::createInstanceWithA
OUString SAL_CALL FSStorageFactory::getImplementationName()
{
- return impl_staticGetImplementationName();
+ return "com.sun.star.comp.embed.FileSystemStorageFactory";
}
sal_Bool SAL_CALL FSStorageFactory::supportsService( const OUString& ServiceName )
@@ -163,37 +145,19 @@ sal_Bool SAL_CALL FSStorageFactory::supportsService( const OUString& ServiceName
uno::Sequence< OUString > SAL_CALL FSStorageFactory::getSupportedServiceNames()
{
- return impl_staticGetSupportedServiceNames();
+ return { "com.sun.star.embed.FileSystemStorageFactory",
+ "com.sun.star.comp.embed.FileSystemStorageFactory" };
}
-extern "C"
-{
-SAL_DLLPUBLIC_EXPORT void * fsstorage_component_getFactory (
- const char * pImplementationName, void * pServiceManager,
- SAL_UNUSED_PARAMETER void * /* pRegistryKey */)
+
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
+svl_FSStorageFactory_get_implementation(
+ css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&)
{
- void * pResult = nullptr;
- if (pServiceManager)
- {
- uno::Reference< lang::XSingleServiceFactory > xFactory;
- if (FSStorageFactory::impl_staticGetImplementationName().equalsAscii(pImplementationName))
- {
- xFactory = cppu::createOneInstanceFactory (
- static_cast< lang::XMultiServiceFactory* >(pServiceManager),
- FSStorageFactory::impl_staticGetImplementationName(),
- FSStorageFactory::impl_staticCreateSelfInstance,
- FSStorageFactory::impl_staticGetSupportedServiceNames() );
- }
- if (xFactory.is())
- {
- xFactory->acquire();
- pResult = xFactory.get();
- }
- }
- return pResult;
+ static rtl::Reference<FSStorageFactory> g_Instance(new FSStorageFactory(context));
+ g_Instance->acquire();
+ return static_cast<cppu::OWeakObject*>(g_Instance.get());
}
-} // extern "C"
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svl/source/fsstor/fsstorage.component b/svl/source/fsstor/fsstorage.component
index 6bbb59eade6e..915850bab86d 100644
--- a/svl/source/fsstor/fsstorage.component
+++ b/svl/source/fsstor/fsstorage.component
@@ -18,8 +18,9 @@
-->
<component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@"
- prefix="fsstorage" xmlns="http://openoffice.org/2010/uno-components">
- <implementation name="com.sun.star.comp.embed.FileSystemStorageFactory">
+ xmlns="http://openoffice.org/2010/uno-components">
+ <implementation name="com.sun.star.comp.embed.FileSystemStorageFactory"
+ constructor="svl_FSStorageFactory_get_implementation">
<service name="com.sun.star.comp.embed.FileSystemStorageFactory"/>
<service name="com.sun.star.embed.FileSystemStorageFactory"/>
</implementation>
diff --git a/svl/source/inc/fsfactory.hxx b/svl/source/inc/fsfactory.hxx
index 579ab67ece54..5bec28898588 100644
--- a/svl/source/inc/fsfactory.hxx
+++ b/svl/source/inc/fsfactory.hxx
@@ -39,16 +39,6 @@ public:
OSL_ENSURE( xContext.is(), "No service manager is provided!" );
}
- static css::uno::Sequence< OUString >
- impl_staticGetSupportedServiceNames();
-
- static OUString impl_staticGetImplementationName();
-
- static css::uno::Reference< css::uno::XInterface > SAL_CALL
- impl_staticCreateSelfInstance(
- const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager );
-
-
// XSingleServiceFactory
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstance() override;
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstanceWithArguments( const css::uno::Sequence< css::uno::Any >& aArguments ) override;