From 74f4a1e4a8898b87e4b90804d369f1bfa49e6cbb Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Sat, 11 Jul 2020 20:37:10 +0200 Subject: filter/svg: create instances with uno constructors See tdf#74608 for motivation. Change-Id: I6a049364726327d1be10f72174aced5bade271a4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98571 Tested-by: Jenkins Reviewed-by: Noel Grandin --- filter/source/svg/svgfilter.component | 8 ++++-- filter/source/svg/svgfilter.cxx | 54 +++++++++++++++-------------------- filter/source/svg/svgfilter.hxx | 8 +++++- filter/source/svg/svgwriter.cxx | 22 ++++++++++++++ filter/source/svg/svgwriter.hxx | 7 ++++- solenv/bin/native-code.py | 4 ++- 6 files changed, 66 insertions(+), 37 deletions(-) diff --git a/filter/source/svg/svgfilter.component b/filter/source/svg/svgfilter.component index 612d523502c9..479748f38655 100644 --- a/filter/source/svg/svgfilter.component +++ b/filter/source/svg/svgfilter.component @@ -18,13 +18,15 @@ --> - + xmlns="http://openoffice.org/2010/uno-components"> + - + diff --git a/filter/source/svg/svgfilter.cxx b/filter/source/svg/svgfilter.cxx index 1757fa42f758..41cd98e4dbf7 100644 --- a/filter/source/svg/svgfilter.cxx +++ b/filter/source/svg/svgfilter.cxx @@ -21,7 +21,7 @@ #include #include -#include +#include #include #include #include @@ -825,37 +825,29 @@ OUString SAL_CALL SVGFilter::detect(Sequence& rDescriptor) return aRetval; } -#define SVG_FILTER_IMPL_NAME "com.sun.star.comp.Draw.SVGFilter" -#define SVG_WRITER_IMPL_NAME "com.sun.star.comp.Draw.SVGWriter" - -namespace sdecl = comphelper::service_decl; - sdecl::class_ const serviceFilterImpl; - const sdecl::ServiceDecl svgFilter( - serviceFilterImpl, - SVG_FILTER_IMPL_NAME, - "com.sun.star.document.ImportFilter;" - "com.sun.star.document.ExportFilter;" - "com.sun.star.document.ExtendedTypeDetection" ); - - sdecl::class_ > const serviceWriterImpl; - const sdecl::ServiceDecl svgWriter( - serviceWriterImpl, - SVG_WRITER_IMPL_NAME, - "com.sun.star.svg.SVGWriter" ); - -// The C shared lib entry points -extern "C" SAL_DLLPUBLIC_EXPORT void* svgfilter_component_getFactory( - char const* pImplName, void*, void*) +// XServiceInfo +sal_Bool SVGFilter::supportsService(const OUString& sServiceName) { - if ( rtl_str_compare (pImplName, SVG_FILTER_IMPL_NAME) == 0 ) - { - return sdecl::component_getFactoryHelper( pImplName, {&svgFilter} ); - } - else if ( rtl_str_compare (pImplName, SVG_WRITER_IMPL_NAME) == 0 ) - { - return sdecl::component_getFactoryHelper( pImplName, {&svgWriter} ); - } - return nullptr; + return cppu::supportsService(this, sServiceName); } +OUString SVGFilter::getImplementationName() +{ + return "com.sun.star.comp.Draw.SVGFilter"; +} +css::uno::Sequence< OUString > SVGFilter::getSupportedServiceNames() +{ + return { "com.sun.star.document.ImportFilter", + "com.sun.star.document.ExportFilter", + "com.sun.star.document.ExtendedTypeDetection" }; +} + + +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +filter_SVGFilter_get_implementation( + css::uno::XComponentContext* context, css::uno::Sequence const&) +{ + return cppu::acquire(new SVGFilter(context)); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/filter/source/svg/svgfilter.hxx b/filter/source/svg/svgfilter.hxx index 6ad17b1f6732..b06889a1a489 100644 --- a/filter/source/svg/svgfilter.hxx +++ b/filter/source/svg/svgfilter.hxx @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -158,7 +159,7 @@ class EditFieldInfo; class SVGFilter : public cppu::WeakImplHelper < XFilter, XImporter, XExporter, - XExtendedFilterDetection > + XExtendedFilterDetection, XServiceInfo > { public: typedef std::unordered_map< Reference< XInterface >, ObjectRepresentation > ObjectMap; @@ -287,6 +288,11 @@ public: explicit SVGFilter( const Reference< XComponentContext >& rxCtx ); virtual ~SVGFilter() override; + + // XServiceInfo + virtual sal_Bool SAL_CALL supportsService(const OUString& sServiceName) override; + virtual OUString SAL_CALL getImplementationName() override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; }; #endif // INCLUDED_FILTER_SOURCE_SVG_SVGFILTER_HXX diff --git a/filter/source/svg/svgwriter.cxx b/filter/source/svg/svgwriter.cxx index 4baddb4743e9..d46c77ff37ea 100644 --- a/filter/source/svg/svgwriter.cxx +++ b/filter/source/svg/svgwriter.cxx @@ -22,6 +22,7 @@ #include "svgwriter.hxx" #include +#include #include #include #include @@ -3839,4 +3840,25 @@ void SAL_CALL SVGWriter::write( const Reference& rxDocHandler, pWriter->writeMtf( aMtf ); } +// XServiceInfo +sal_Bool SVGWriter::supportsService(const OUString& sServiceName) +{ + return cppu::supportsService(this, sServiceName); +} +OUString SVGWriter::getImplementationName() +{ + return "com.sun.star.comp.Draw.SVGWriter"; +} +css::uno::Sequence< OUString > SVGWriter::getSupportedServiceNames() +{ + return { "com.sun.star.svg.SVGWriter" }; +} + +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +filter_SVGWriter_get_implementation( + css::uno::XComponentContext* context, css::uno::Sequence const& args) +{ + return cppu::acquire(new SVGWriter(args, context)); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/filter/source/svg/svgwriter.hxx b/filter/source/svg/svgwriter.hxx index 065d0585bb88..b3070d758ab2 100644 --- a/filter/source/svg/svgwriter.hxx +++ b/filter/source/svg/svgwriter.hxx @@ -369,7 +369,7 @@ public: }; -class SVGWriter : public cppu::WeakImplHelper< XSVGWriter > +class SVGWriter : public cppu::WeakImplHelper< XSVGWriter, XServiceInfo > { private: Reference< XComponentContext > mxContext; @@ -383,6 +383,11 @@ public: // XSVGWriter virtual void SAL_CALL write( const Reference& rxDocHandler, const Sequence& rMtfSeq ) override; + + // XServiceInfo + virtual sal_Bool SAL_CALL supportsService(const OUString& sServiceName) override; + virtual OUString SAL_CALL getImplementationName() override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; }; #endif // INCLUDED_FILTER_SOURCE_SVG_SVGWRITER_HXX diff --git a/solenv/bin/native-code.py b/solenv/bin/native-code.py index b2a0aed722ad..e7394bf01852 100755 --- a/solenv/bin/native-code.py +++ b/solenv/bin/native-code.py @@ -505,7 +505,6 @@ calc_constructor_list = [ draw_factory_list = [ ("libsdlo.a", "sd_component_getFactory"), - ("libsvgfilterlo.a", "svgfilter_component_getFactory"), ("libemboleobj.a", "emboleobj_component_getFactory"), ] @@ -533,6 +532,9 @@ draw_constructor_list = [ "com_sun_star_comp_deployment_help_PackageRegistryBackend_get_implementation", "com_sun_star_comp_deployment_script_PackageRegistryBackend_get_implementation", "com_sun_star_comp_deployment_sfwk_PackageRegistryBackend_get_implementation", +# filter/source/svg/svgfilter.component + "filter_SVGFilter_get_implementation", + "filter_SVGWriter_get_implementation", # sd/util/sd.component "RandomAnimationNode_get_implementation", "com_sun_star_comp_Draw_framework_BasicPaneFactory_get_implementation", -- cgit