diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2020-07-13 22:39:10 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-07-15 08:45:06 +0200 |
commit | 3e50a3023535d4e9e365db046442df1a758e70c4 (patch) | |
tree | 13e5f6943f75a8b5171494143631fe48ff845d90 /svl/source/fsstor | |
parent | 0bca30bff7d9e49c81459122735565ff0d9816c3 (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/source/fsstor')
-rw-r--r-- | svl/source/fsstor/fsfactory.cxx | 56 | ||||
-rw-r--r-- | svl/source/fsstor/fsstorage.component | 5 |
2 files changed, 13 insertions, 48 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> |