diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-07-14 12:13:10 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-07-15 09:47:26 +0200 |
commit | fd5531534dc1e2f90d33f1d0cf9c0fe2cb9fd6f5 (patch) | |
tree | fceb0fe5d1cf522b3822aa00e61e01426a9ff2fc /scripting | |
parent | 244de1fc0f3f201f56e739401ee3cc52f35deab4 (diff) |
scripting/stringresource: create instances with uno constructors
See tdf#74608 for motivation.
Change-Id: I3ad9af6cff62ee822ac5f0cfd4da12eb36bfb50f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98739
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'scripting')
-rw-r--r-- | scripting/source/stringresource/stringresource.component | 11 | ||||
-rw-r--r-- | scripting/source/stringresource/stringresource.cxx | 112 |
2 files changed, 25 insertions, 98 deletions
diff --git a/scripting/source/stringresource/stringresource.component b/scripting/source/stringresource/stringresource.component index e39e0f908882..a2b2a24f33b5 100644 --- a/scripting/source/stringresource/stringresource.component +++ b/scripting/source/stringresource/stringresource.component @@ -18,14 +18,17 @@ --> <component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@" - prefix="stringresource" xmlns="http://openoffice.org/2010/uno-components"> - <implementation name="com.sun.star.comp.scripting.StringResource"> + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="com.sun.star.comp.scripting.StringResource" + constructor="scripting_StringResourcePersistenceImpl_implementation"> <service name="com.sun.star.resource.StringResource"/> </implementation> - <implementation name="com.sun.star.comp.scripting.StringResourceWithLocation"> + <implementation name="com.sun.star.comp.scripting.StringResourceWithLocation" + constructor="scripting_StringResourceWithLocationImpl_get_implementation"> <service name="com.sun.star.resource.StringResourceWithLocation"/> </implementation> - <implementation name="com.sun.star.comp.scripting.StringResourceWithStorage"> + <implementation name="com.sun.star.comp.scripting.StringResourceWithStorage" + constructor="scripting_StringResourceWithStorageImpl_get_implementation"> <service name="com.sun.star.resource.StringResourceWithStorage"/> </implementation> </component> diff --git a/scripting/source/stringresource/stringresource.cxx b/scripting/source/stringresource/stringresource.cxx index dc8b38466416..217536d66c55 100644 --- a/scripting/source/stringresource/stringresource.cxx +++ b/scripting/source/stringresource/stringresource.cxx @@ -65,23 +65,11 @@ namespace stringresource // StringResourceImpl - -// component operations -static Sequence< OUString > getSupportedServiceNames_StringResourceImpl() +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +scripting_StringResourcePersistenceImpl_implementation( + css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&) { - Sequence< OUString > names { "com.sun.star.resource.StringResource" }; - return names; -} - -static OUString getImplementationName_StringResourceImpl() -{ - return "com.sun.star.comp.scripting.StringResource"; -} - -static Reference< XInterface > create_StringResourceImpl( - Reference< XComponentContext > const & xContext ) -{ - return static_cast< ::cppu::OWeakObject * >( new StringResourcePersistenceImpl( xContext ) ); + return cppu::acquire(new StringResourcePersistenceImpl(context)); } @@ -107,7 +95,7 @@ StringResourceImpl::~StringResourceImpl() OUString StringResourceImpl::getImplementationName( ) { - return getImplementationName_StringResourceImpl(); + return "com.sun.star.comp.scripting.StringResource"; } sal_Bool StringResourceImpl::supportsService( const OUString& rServiceName ) @@ -117,7 +105,7 @@ sal_Bool StringResourceImpl::supportsService( const OUString& rServiceName ) Sequence< OUString > StringResourceImpl::getSupportedServiceNames( ) { - return getSupportedServiceNames_StringResourceImpl(); + return { "com.sun.star.resource.StringResource" }; } @@ -2047,23 +2035,11 @@ bool StringResourcePersistenceImpl::implWritePropertiesFile( LocaleItem const * // StringResourceWithStorageImpl - -// component operations -static Sequence< OUString > getSupportedServiceNames_StringResourceWithStorageImpl() +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +scripting_StringResourceWithStorageImpl_get_implementation( + css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&) { - Sequence< OUString > names { "com.sun.star.resource.StringResourceWithStorage" }; - return names; -} - -static OUString getImplementationName_StringResourceWithStorageImpl() -{ - return "com.sun.star.comp.scripting.StringResourceWithStorage"; -} - -static Reference< XInterface > create_StringResourceWithStorageImpl( - Reference< XComponentContext > const & xContext ) -{ - return static_cast< ::cppu::OWeakObject * >( new StringResourceWithStorageImpl( xContext ) ); + return cppu::acquire(new StringResourceWithStorageImpl(context)); } @@ -2084,7 +2060,7 @@ StringResourceWithStorageImpl::~StringResourceWithStorageImpl() OUString StringResourceWithStorageImpl::getImplementationName( ) { - return getImplementationName_StringResourceWithStorageImpl(); + return "com.sun.star.comp.scripting.StringResourceWithStorage"; } sal_Bool StringResourceWithStorageImpl::supportsService( const OUString& rServiceName ) @@ -2094,7 +2070,7 @@ sal_Bool StringResourceWithStorageImpl::supportsService( const OUString& rServic Sequence< OUString > StringResourceWithStorageImpl::getSupportedServiceNames( ) { - return getSupportedServiceNames_StringResourceWithStorageImpl(); + return { "com.sun.star.resource.StringResourceWithStorage" }; } @@ -2333,23 +2309,13 @@ bool StringResourceWithStorageImpl::implLoadLocale( LocaleItem* pLocaleItem ) // StringResourceWithLocationImpl -// component operations -static Sequence< OUString > getSupportedServiceNames_StringResourceWithLocationImpl() -{ - Sequence< OUString > names { "com.sun.star.resource.StringResourceWithLocation" }; - return names; -} - -static OUString getImplementationName_StringResourceWithLocationImpl() +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +scripting_StringResourceWithLocationImpl_get_implementation( + css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&) { - return "com.sun.star.comp.scripting.StringResourceWithLocation"; + return cppu::acquire(new StringResourceWithLocationImpl(context)); } -static Reference< XInterface > create_StringResourceWithLocationImpl( - Reference< XComponentContext > const & xContext ) -{ - return static_cast< ::cppu::OWeakObject * >( new StringResourceWithLocationImpl( xContext ) ); -} StringResourceWithLocationImpl::StringResourceWithLocationImpl( const Reference< XComponentContext >& rxContext ) @@ -2369,7 +2335,7 @@ StringResourceWithLocationImpl::~StringResourceWithLocationImpl() OUString StringResourceWithLocationImpl::getImplementationName( ) { - return getImplementationName_StringResourceWithLocationImpl(); + return "com.sun.star.comp.scripting.StringResourceWithLocation"; } sal_Bool StringResourceWithLocationImpl::supportsService( const OUString& rServiceName ) @@ -2379,7 +2345,7 @@ sal_Bool StringResourceWithLocationImpl::supportsService( const OUString& rServi Sequence< OUString > StringResourceWithLocationImpl::getSupportedServiceNames( ) { - return getSupportedServiceNames_StringResourceWithLocationImpl(); + return { "com.sun.star.resource.StringResourceWithLocation" }; } @@ -2652,49 +2618,7 @@ const Reference< ucb::XSimpleFileAccess3 > & StringResourceWithLocationImpl::get return m_xSFI; } - -// component export operations - - -const struct ::cppu::ImplementationEntry s_component_entries [] = -{ - { - create_StringResourceImpl, getImplementationName_StringResourceImpl, - getSupportedServiceNames_StringResourceImpl, - ::cppu::createSingleComponentFactory, - nullptr, 0 - }, - { - create_StringResourceWithLocationImpl, getImplementationName_StringResourceWithLocationImpl, - getSupportedServiceNames_StringResourceWithLocationImpl, - ::cppu::createSingleComponentFactory, - nullptr, 0 - }, - { - create_StringResourceWithStorageImpl, getImplementationName_StringResourceWithStorageImpl, - getSupportedServiceNames_StringResourceWithStorageImpl, - ::cppu::createSingleComponentFactory, - nullptr, 0 - }, - { nullptr, nullptr, nullptr, nullptr, nullptr, 0 } -}; - - } // namespace stringresource -// component exports - - -extern "C" -{ - SAL_DLLPUBLIC_EXPORT void * stringresource_component_getFactory( - const char * pImplName, void * pServiceManager, - void * pRegistryKey ) - { - return ::cppu::component_getFactoryHelper( - pImplName, pServiceManager, pRegistryKey, ::stringresource::s_component_entries ); - } -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |