diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2020-07-13 22:30:36 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-07-14 18:31:18 +0200 |
commit | 7256ff08bc46840bb85fa255ace6541dca91329e (patch) | |
tree | c36e5d8c65b2915b7d812dcc02cb16b72c8fde93 /svl | |
parent | 17363342935e38f463cf879682009534aab9fa7e (diff) |
svl/passwordcontainer: create instances with uno constructors
See tdf#74608 for motivation.
Change-Id: Ib543223f87e1773645ff6063e7f9f902ff408f33
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98701
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svl')
-rw-r--r-- | svl/source/passwordcontainer/passwordcontainer.component | 4 | ||||
-rw-r--r-- | svl/source/passwordcontainer/passwordcontainer.cxx | 58 | ||||
-rw-r--r-- | svl/source/passwordcontainer/passwordcontainer.hxx | 17 |
3 files changed, 11 insertions, 68 deletions
diff --git a/svl/source/passwordcontainer/passwordcontainer.component b/svl/source/passwordcontainer/passwordcontainer.component index 165efbe7d1f7..e928461fa96b 100644 --- a/svl/source/passwordcontainer/passwordcontainer.component +++ b/svl/source/passwordcontainer/passwordcontainer.component @@ -18,9 +18,9 @@ --> <component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@" - prefix="passwordcontainer" xmlns="http://openoffice.org/2010/uno-components"> - <implementation name="stardiv.svl.PasswordContainer"> + <implementation name="stardiv.svl.PasswordContainer" + constructor="svl_PasswordContainer_get_implementation"> <service name="com.sun.star.task.PasswordContainer"/> </implementation> </component> diff --git a/svl/source/passwordcontainer/passwordcontainer.cxx b/svl/source/passwordcontainer/passwordcontainer.cxx index 506772366e87..fe90321e6398 100644 --- a/svl/source/passwordcontainer/passwordcontainer.cxx +++ b/svl/source/passwordcontainer/passwordcontainer.cxx @@ -366,12 +366,12 @@ void StorageItem::ImplCommit() } -PasswordContainer::PasswordContainer( const Reference<XMultiServiceFactory>& xServiceFactory ) +PasswordContainer::PasswordContainer( const Reference<XComponentContext>& rxContext ) { // m_pStorageFile->Notify() can be called ::osl::MutexGuard aGuard( mMutex ); - mComponent.set( xServiceFactory, UNO_QUERY ); + mComponent.set( rxContext->getServiceManager(), UNO_QUERY ); mComponent->addEventListener( this ); m_pStorageFile.reset( new StorageItem( this, "Office.Common/Passwords" ) ); @@ -1294,7 +1294,7 @@ void PasswordContainer::Notify() OUString SAL_CALL PasswordContainer::getImplementationName( ) { - return impl_getStaticImplementationName(); + return "stardiv.svl.PasswordContainer"; } sal_Bool SAL_CALL PasswordContainer::supportsService( const OUString& ServiceName ) @@ -1304,32 +1304,14 @@ sal_Bool SAL_CALL PasswordContainer::supportsService( const OUString& ServiceNam Sequence< OUString > SAL_CALL PasswordContainer::getSupportedServiceNames( ) { - return impl_getStaticSupportedServiceNames(); -} - -Sequence< OUString > PasswordContainer::impl_getStaticSupportedServiceNames( ) -{ return { "com.sun.star.task.PasswordContainer" }; } -OUString PasswordContainer::impl_getStaticImplementationName() -{ - return "stardiv.svl.PasswordContainer"; -} - -Reference< XInterface > SAL_CALL PasswordContainer::impl_createInstance( const Reference< XMultiServiceFactory >& xServiceManager ) -{ - return Reference< XInterface >( *new PasswordContainer( xServiceManager ) ); -} - -Reference< XSingleServiceFactory > PasswordContainer::impl_createFactory( const Reference< XMultiServiceFactory >& ServiceManager ) +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +svl_PasswordContainer_get_implementation( + css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&) { - Reference< XSingleServiceFactory > xReturn( ::cppu::createOneInstanceFactory( ServiceManager, - PasswordContainer::impl_getStaticImplementationName(), - PasswordContainer::impl_createInstance, - PasswordContainer::impl_getStaticSupportedServiceNames())); - return xReturn ; - + return cppu::acquire(new PasswordContainer(context)); } @@ -1370,31 +1352,5 @@ MasterPasswordRequest_Impl::MasterPasswordRequest_Impl( PasswordRequestMode Mode } -extern "C" -{ -SAL_DLLPUBLIC_EXPORT void * passwordcontainer_component_getFactory ( - const char * pImplementationName, - SAL_UNUSED_PARAMETER void * pServiceManager, - SAL_UNUSED_PARAMETER void * /* pRegistryKey */) -{ - void * pResult = nullptr; - if (pServiceManager) - { - Reference< XSingleServiceFactory > xFactory; - if (PasswordContainer::impl_getStaticImplementationName().equalsAscii(pImplementationName)) - { - xFactory = PasswordContainer::impl_createFactory ( - static_cast< XMultiServiceFactory* >(pServiceManager)); - } - if (xFactory.is()) - { - xFactory->acquire(); - pResult = xFactory.get(); - } - } - return pResult; -} - -} // extern "C" /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svl/source/passwordcontainer/passwordcontainer.hxx b/svl/source/passwordcontainer/passwordcontainer.hxx index 09fb7e03629d..65c7bbf4efa8 100644 --- a/svl/source/passwordcontainer/passwordcontainer.hxx +++ b/svl/source/passwordcontainer/passwordcontainer.hxx @@ -28,6 +28,7 @@ #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/lang/XEventListener.hpp> #include <com/sun/star/lang/XComponent.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> #include <cppuhelper/implbase.hxx> #include <unotools/configitem.hxx> @@ -273,7 +274,7 @@ css::task::UrlRecord find( static OUString EncodePasswords(const std::vector< OUString >& lines, const OUString& aMasterPassword ); public: - PasswordContainer( const css::uno::Reference< css::lang::XMultiServiceFactory >& ); + PasswordContainer( const css::uno::Reference< css::uno::XComponentContext >& ); virtual ~PasswordContainer() override; virtual void SAL_CALL add( const OUString& aUrl, @@ -306,20 +307,6 @@ public: virtual css::uno::Sequence< css::task::UrlRecord > SAL_CALL getAllPersistent( const css::uno::Reference< css::task::XInteractionHandler >& Handler ) override; - - // provide factory - /// @throws css::uno::RuntimeException - static OUString impl_getStaticImplementationName( ); - /// @throws css::uno::RuntimeException - static css::uno::Sequence< OUString > - impl_getStaticSupportedServiceNames( ); - /// @throws css::uno::RuntimeException - static css::uno::Reference< css::lang::XSingleServiceFactory > - impl_createFactory( const css::uno::Reference< css::lang::XMultiServiceFactory >& ServiceManager ); - /// @throws css::uno::RuntimeException - static css::uno::Reference< css::uno::XInterface > SAL_CALL - impl_createInstance( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ); - // XServiceInfo virtual OUString SAL_CALL getImplementationName( ) override; virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; |