[Libreoffice-commits] core.git: filter/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Sat Jul 11 19:52:24 UTC 2020


 filter/source/xsltfilter/LibXSLTTransformer.cxx |   23 +++++
 filter/source/xsltfilter/LibXSLTTransformer.hxx |    9 +-
 filter/source/xsltfilter/XSLTFilter.cxx         |  102 ++++++------------------
 filter/source/xsltfilter/xsltfilter.component   |    8 +
 4 files changed, 63 insertions(+), 79 deletions(-)

New commits:
commit 24e1ea0b29a145b89c61f8a73b4925db03de133c
Author:     Noel Grandin <noelgrandin at gmail.com>
AuthorDate: Sat Jul 11 19:31:38 2020 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Sat Jul 11 21:51:58 2020 +0200

    filter/xslt: create instances with uno constructors
    
    See tdf#74608 for motivation.
    
    Change-Id: I7aae8e370a31a69f84dcbb4372077e5b8e0781fe
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98566
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/filter/source/xsltfilter/LibXSLTTransformer.cxx b/filter/source/xsltfilter/LibXSLTTransformer.cxx
index 1403664d4331..c3fc742bae03 100644
--- a/filter/source/xsltfilter/LibXSLTTransformer.cxx
+++ b/filter/source/xsltfilter/LibXSLTTransformer.cxx
@@ -25,6 +25,7 @@
 #include <libexslt/exslt.h>
 
 #include <cppuhelper/factory.hxx>
+#include <cppuhelper/supportsservice.hxx>
 
 #include <osl/file.hxx>
 #include <com/sun/star/uno/Any.hxx>
@@ -373,6 +374,20 @@ namespace XSLT
     {
     }
 
+    //  XServiceInfo
+    sal_Bool LibXSLTTransformer::supportsService(const OUString& sServiceName)
+    {
+        return cppu::supportsService(this, sServiceName);
+    }
+    OUString LibXSLTTransformer::getImplementationName()
+    {
+        return "com.sun.star.comp.documentconversion.XSLTFilter";
+    }
+    css::uno::Sequence< OUString > LibXSLTTransformer::getSupportedServiceNames()
+    {
+        return { "com.sun.star.documentconversion.XSLTFilter" };
+    }
+
     void
     LibXSLTTransformer::setInputStream(
             const css::uno::Reference<XInputStream>& inputStream)
@@ -523,5 +538,13 @@ namespace XSLT
         }
     }
 }
+
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
+filter_LibXSLTTransformer_get_implementation(
+    css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&)
+{
+    return cppu::acquire(new XSLT::LibXSLTTransformer(context));
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
 
diff --git a/filter/source/xsltfilter/LibXSLTTransformer.hxx b/filter/source/xsltfilter/LibXSLTTransformer.hxx
index d646d5dbfc43..ac922a4598f5 100644
--- a/filter/source/xsltfilter/LibXSLTTransformer.hxx
+++ b/filter/source/xsltfilter/LibXSLTTransformer.hxx
@@ -27,7 +27,7 @@
 
 #include <salhelper/thread.hxx>
 
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
 #include <com/sun/star/io/XInputStream.hpp>
 #include <com/sun/star/io/XOutputStream.hpp>
 #include <com/sun/star/io/XStreamListener.hpp>
@@ -93,7 +93,7 @@ namespace XSLT
      *
      * See Reader below.
      */
-    class LibXSLTTransformer : public WeakImplHelper<css::xml::xslt::XXSLTTransformer>
+    class LibXSLTTransformer : public WeakImplHelper<css::xml::xslt::XXSLTTransformer, css::lang::XServiceInfo>
     {
     private:
         static const char* const PARAM_SOURCE_URL;
@@ -133,6 +133,11 @@ namespace XSLT
         // ctor...
         LibXSLTTransformer(const css::uno::Reference<css::uno::XComponentContext> &r);
 
+        //  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;
+
         // XActiveDataSink
         virtual void SAL_CALL
         setInputStream(const css::uno::Reference<XInputStream>& inputStream) override;
diff --git a/filter/source/xsltfilter/XSLTFilter.cxx b/filter/source/xsltfilter/XSLTFilter.cxx
index bbe848ad9cc3..207d44e63685 100644
--- a/filter/source/xsltfilter/XSLTFilter.cxx
+++ b/filter/source/xsltfilter/XSLTFilter.cxx
@@ -20,6 +20,7 @@
 
 #include <cppuhelper/factory.hxx>
 #include <cppuhelper/implbase.hxx>
+#include <cppuhelper/supportsservice.hxx>
 
 #include <sax/tools/documenthandleradapter.hxx>
 
@@ -31,10 +32,9 @@
 #include <sal/log.hxx>
 
 #include <comphelper/interaction.hxx>
-#include <comphelper/processfactory.hxx>
 
 #include <com/sun/star/lang/EventObject.hpp>
-#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
 
 #include <com/sun/star/uno/Any.hxx>
 
@@ -98,7 +98,7 @@ namespace XSLT
      * service must support com.sun.star.xml.xslt.XSLT2Transformer.
      */
     class XSLTFilter : public WeakImplHelper<XImportFilter, XExportFilter,
-            XStreamListener, ExtendedDocumentHandlerAdapter>
+            XStreamListener, ExtendedDocumentHandlerAdapter, XServiceInfo>
     {
     private:
 
@@ -128,6 +128,11 @@ namespace XSLT
         // ctor...
         explicit XSLTFilter(const css::uno::Reference<XComponentContext> &r);
 
+        //  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;
+
         // XStreamListener
         virtual void SAL_CALL
         error(const Any& a) override;
@@ -169,6 +174,20 @@ namespace XSLT
     {
     }
 
+    //  XServiceInfo
+    sal_Bool XSLTFilter::supportsService(const OUString& sServiceName)
+    {
+        return cppu::supportsService(this, sServiceName);
+    }
+    OUString XSLTFilter::getImplementationName()
+    {
+        return "com.sun.star.comp.documentconversion.XSLTFilter";
+    }
+    css::uno::Sequence< OUString > XSLTFilter::getSupportedServiceNames()
+    {
+        return { "com.sun.star.documentconversion.XSLTFilter" };
+    }
+
     OUString
     XSLTFilter::expandUrl(const OUString& sUrl)
     {
@@ -517,80 +536,15 @@ namespace XSLT
     }
 
 
-    // Component management
-
-#define FILTER_SERVICE_NAME "com.sun.star.documentconversion.XSLTFilter"
-#define FILTER_IMPL_NAME "com.sun.star.comp.documentconversion.XSLTFilter"
-#define TRANSFORMER_SERVICE_NAME "com.sun.star.xml.xslt.XSLTTransformer"
-#define TRANSFORMER_IMPL_NAME "com.sun.star.comp.documentconversion.LibXSLTTransformer"
-
-    static css::uno::Reference<XInterface>
-    CreateTransformerInstance(const css::uno::Reference<XMultiServiceFactory> &r)
-    {
-        return css::uno::Reference<XInterface> (static_cast<OWeakObject *>(new LibXSLTTransformer( comphelper::getComponentContext(r) )));
-    }
-
-    static css::uno::Reference<XInterface>
-    CreateFilterInstance(const css::uno::Reference<XMultiServiceFactory> &r)
-    {
-        return css::uno::Reference<XInterface> (static_cast<OWeakObject *>(new XSLTFilter( comphelper::getComponentContext(r) )));
-    }
-
 }
 
-using namespace XSLT;
+// Component management
 
-extern "C"
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
+filter_XSLTFilter_get_implementation(
+    css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&)
 {
-    SAL_DLLPUBLIC_EXPORT void * xsltfilter_component_getFactory(const char * pImplName,
-            void * pServiceManager, void * /* pRegistryKey */)
-    {
-        void * pRet = nullptr;
-
-        if (pServiceManager)
-            {
-                if (rtl_str_compare(pImplName, FILTER_IMPL_NAME) == 0)
-                    {
-                        Sequence<OUString> serviceNames { FILTER_SERVICE_NAME };
-
-                        css::uno::Reference<XSingleServiceFactory>
-                                xFactory(
-                                        createSingleFactory(
-                                                static_cast<XMultiServiceFactory *> (pServiceManager),
-                                                OUString::createFromAscii(
-                                                        pImplName),
-                                                CreateFilterInstance,
-                                                serviceNames));
-
-                        if (xFactory.is())
-                            {
-                                xFactory->acquire();
-                                pRet = xFactory.get();
-                            }
-                    }
-                else if (rtl_str_compare(pImplName, TRANSFORMER_IMPL_NAME) == 0)
-                    {
-                        Sequence<OUString> serviceNames { TRANSFORMER_SERVICE_NAME };
-                        css::uno::Reference<XSingleServiceFactory>
-                                xFactory(
-                                        createSingleFactory(
-                                                static_cast<XMultiServiceFactory *> (pServiceManager),
-                                                OUString::createFromAscii(
-                                                        pImplName),
-                                                CreateTransformerInstance,
-                                                serviceNames));
-
-                        if (xFactory.is())
-                            {
-                                xFactory->acquire();
-                                pRet = xFactory.get();
-                            }
-
-                    }
-            }
-        return pRet;
-    }
-
-} // extern "C"
+    return cppu::acquire(new XSLT::XSLTFilter(context));
+}
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/filter/source/xsltfilter/xsltfilter.component b/filter/source/xsltfilter/xsltfilter.component
index 6a91d87c2c19..e4298a7a0bb3 100644
--- a/filter/source/xsltfilter/xsltfilter.component
+++ b/filter/source/xsltfilter/xsltfilter.component
@@ -18,11 +18,13 @@
  -->
 
 <component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@"
-    prefix="xsltfilter" xmlns="http://openoffice.org/2010/uno-components">
-  <implementation name="com.sun.star.comp.documentconversion.XSLTFilter">
+    xmlns="http://openoffice.org/2010/uno-components">
+  <implementation name="com.sun.star.comp.documentconversion.XSLTFilter"
+    constructor="filter_XSLTFilter_get_implementation">
     <service name="com.sun.star.documentconversion.XSLTFilter"/>
   </implementation>
-  <implementation name="com.sun.star.comp.documentconversion.LibXSLTTransformer">
+  <implementation name="com.sun.star.comp.documentconversion.LibXSLTTransformer"
+    constructor="filter_LibXSLTTransformer_get_implementation">
     <service name="com.sun.star.xml.xslt.XSLTTransformer"/>
   </implementation>
 </component>


More information about the Libreoffice-commits mailing list