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

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Sun Jul 12 12:21:45 UTC 2020


 filter/Library_t602filter.mk            |    1 
 filter/source/t602/filterenv.cxx        |   74 --------------------------------
 filter/source/t602/t602filter.component |    8 ++-
 filter/source/t602/t602filter.cxx       |   44 ++++++-------------
 filter/source/t602/t602filter.hxx       |   25 +---------
 5 files changed, 22 insertions(+), 130 deletions(-)

New commits:
commit 58b4ea44865cb7a058c35edaef62576e1bbebfc7
Author:     Noel Grandin <noelgrandin at gmail.com>
AuthorDate: Sat Jul 11 20:19:28 2020 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Sun Jul 12 14:21:06 2020 +0200

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

diff --git a/filter/Library_t602filter.mk b/filter/Library_t602filter.mk
index 82b616434e47..90f834e1238d 100644
--- a/filter/Library_t602filter.mk
+++ b/filter/Library_t602filter.mk
@@ -41,7 +41,6 @@ $(eval $(call gb_Library_use_libraries,t602filter,\
 ))
 
 $(eval $(call gb_Library_add_exception_objects,t602filter,\
-	filter/source/t602/filterenv \
 	filter/source/t602/t602filter \
 ))
 
diff --git a/filter/source/t602/filterenv.cxx b/filter/source/t602/filterenv.cxx
deleted file mode 100644
index 1dd00aee80a0..000000000000
--- a/filter/source/t602/filterenv.cxx
+++ /dev/null
@@ -1,74 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements. See the NOTICE file distributed
- *   with this work for additional information regarding copyright
- *   ownership. The ASF licenses this file to you under the Apache
- *   License, Version 2.0 (the "License"); you may not use this file
- *   except in compliance with the License. You may obtain a copy of
- *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include <cppuhelper/factory.hxx>
-
-#include <com/sun/star/lang/XSingleServiceFactory.hpp>
-
-#include "t602filter.hxx"
-
-using namespace ::cppu;
-using namespace ::com::sun::star::uno;
-using namespace ::com::sun::star::lang;
-using namespace ::com::sun::star::registry;
-
-using namespace T602ImportFilter;
-
-extern "C"
-{
-SAL_DLLPUBLIC_EXPORT void * t602filter_component_getFactory(
-    const char * pImplName, void * pServiceManager, void * /* pRegistryKey */ )
-{
-    void * pRet = nullptr;
-
-    OUString implName = OUString::createFromAscii( pImplName );
-    if ( pServiceManager && implName == T602ImportFilter_getImplementationName() )
-    {
-        Reference< XSingleServiceFactory > xFactory( createSingleFactory(
-            static_cast< XMultiServiceFactory * >( pServiceManager ),
-            OUString::createFromAscii( pImplName ),
-            T602ImportFilter_createInstance, T602ImportFilter_getSupportedServiceNames() ) );
-
-        if (xFactory.is())
-        {
-            xFactory->acquire();
-            pRet = xFactory.get();
-        }
-    }
-    else if ( pServiceManager && implName == T602ImportFilterDialog_getImplementationName() )
-    {
-        Reference< XSingleServiceFactory > xFactory( createSingleFactory(
-            static_cast< XMultiServiceFactory * >( pServiceManager ),
-            OUString::createFromAscii( pImplName ),
-            T602ImportFilterDialog_createInstance, T602ImportFilterDialog_getSupportedServiceNames() ) );
-
-        if (xFactory.is())
-        {
-            xFactory->acquire();
-            pRet = xFactory.get();
-        }
-    }
-
-
-    return pRet;
-}
-}
-
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/filter/source/t602/t602filter.component b/filter/source/t602/t602filter.component
index dcd30b0f9244..49b355f67197 100644
--- a/filter/source/t602/t602filter.component
+++ b/filter/source/t602/t602filter.component
@@ -18,12 +18,14 @@
  -->
 
 <component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@"
-    prefix="t602filter" xmlns="http://openoffice.org/2010/uno-components">
-  <implementation name="com.sun.star.comp.Writer.T602ImportFilter">
+    xmlns="http://openoffice.org/2010/uno-components">
+  <implementation name="com.sun.star.comp.Writer.T602ImportFilter"
+    constructor="filter_T602ImportFilter_get_implementation">
     <service name="com.sun.star.document.ExtendedTypeDetection"/>
     <service name="com.sun.star.document.ImportFilter"/>
   </implementation>
-  <implementation name="com.sun.star.comp.Writer.T602ImportFilterDialog">
+  <implementation name="com.sun.star.comp.Writer.T602ImportFilterDialog"
+    constructor="filter_T602ImportFilterDialog_get_implementation">
     <service name="com.sun.star.ui.dialogs.FilterOptionsDialog"/>
   </implementation>
 </component>
diff --git a/filter/source/t602/t602filter.cxx b/filter/source/t602/t602filter.cxx
index 1c2c453c0135..19500d6093a5 100644
--- a/filter/source/t602/t602filter.cxx
+++ b/filter/source/t602/t602filter.cxx
@@ -130,8 +130,8 @@ namespace T602ImportFilter {
 
 static inistruct ini;
 
-T602ImportFilter::T602ImportFilter(const css::uno::Reference<css::lang::XMultiServiceFactory > &r )
-    : mxMSF(r)
+T602ImportFilter::T602ImportFilter(const css::uno::Reference<css::uno::XComponentContext > &r )
+    : mxContext(r)
     , mpAttrList(nullptr)
     , node(tnode::START)
 {
@@ -244,7 +244,7 @@ bool T602ImportFilter::importImpl( const Sequence< css::beans::PropertyValue >&
     }
 
     // An XML import service: what we push sax messages to...
-    mxHandler.set( mxMSF->createInstance( "com.sun.star.comp.Writer.XMLImporter" ), UNO_QUERY );
+    mxHandler.set( mxContext->getServiceManager()->createInstanceWithContext( "com.sun.star.comp.Writer.XMLImporter", mxContext ), UNO_QUERY );
 
     // The XImporter sets up an empty target document for XDocumentHandler to write to...
     Reference < XImporter > xImporter(mxHandler, UNO_QUERY);
@@ -847,7 +847,7 @@ void T602ImportFilter::Read602()
 // XServiceInfo
 OUString SAL_CALL T602ImportFilter::getImplementationName(  )
 {
-    return T602ImportFilter_getImplementationName();
+    return "com.sun.star.comp.Writer.T602ImportFilter";
 }
 
 sal_Bool SAL_CALL T602ImportFilter::supportsService( const OUString& rServiceName )
@@ -856,25 +856,10 @@ sal_Bool SAL_CALL T602ImportFilter::supportsService( const OUString& rServiceNam
 }
 
 Sequence< OUString > SAL_CALL T602ImportFilter::getSupportedServiceNames(  )
-{
-    return T602ImportFilter_getSupportedServiceNames();
-}
-
-OUString T602ImportFilter_getImplementationName ()
-{
-    return "com.sun.star.comp.Writer.T602ImportFilter";
-}
-
-Sequence< OUString > T602ImportFilter_getSupportedServiceNames(  )
 {
     return { "com.sun.star.document.ImportFilter", "com.sun.star.document.ExtendedTypeDetection" };
 }
 
-Reference< XInterface > T602ImportFilter_createInstance( const Reference< XMultiServiceFactory > & rSMgr)
-{
-    return static_cast<cppu::OWeakObject*>(new T602ImportFilter( rSMgr ));
-}
-
 T602ImportFilterDialog::T602ImportFilterDialog()
     : maLocale(SvtSysLocale().GetUILanguageTag())
     , maResLocale(Translate::Create("flt"))
@@ -1113,7 +1098,7 @@ void SAL_CALL T602ImportFilterDialog::setPropertyValues( const uno::Sequence<bea
 // XServiceInfo
 OUString SAL_CALL T602ImportFilterDialog::getImplementationName(  )
 {
-    return T602ImportFilterDialog_getImplementationName();
+    return "com.sun.star.comp.Writer.T602ImportFilterDialog";
 }
 
 sal_Bool SAL_CALL T602ImportFilterDialog::supportsService( const OUString& rServiceName )
@@ -1123,24 +1108,23 @@ sal_Bool SAL_CALL T602ImportFilterDialog::supportsService( const OUString& rServ
 
 Sequence< OUString > SAL_CALL T602ImportFilterDialog::getSupportedServiceNames(  )
 {
-    return T602ImportFilterDialog_getSupportedServiceNames();
+    return { "com.sun.star.ui.dialogs.FilterOptionsDialog" };
 }
 
-OUString T602ImportFilterDialog_getImplementationName ()
-{
-    return "com.sun.star.comp.Writer.T602ImportFilterDialog";
 }
 
-Sequence< OUString > T602ImportFilterDialog_getSupportedServiceNames(  )
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
+filter_T602ImportFilterDialog_get_implementation(
+    css::uno::XComponentContext* , css::uno::Sequence<css::uno::Any> const&)
 {
-    return { "com.sun.star.ui.dialogs.FilterOptionsDialog" };
+    return cppu::acquire(new T602ImportFilter::T602ImportFilterDialog());
 }
 
-Reference< XInterface > T602ImportFilterDialog_createInstance( const Reference< XMultiServiceFactory > & )
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
+filter_T602ImportFilter_get_implementation(
+    css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&)
 {
-    return static_cast<cppu::OWeakObject*>(new T602ImportFilterDialog);
-}
-
+    return cppu::acquire(new T602ImportFilter::T602ImportFilter(context));
 }
 
 extern "C" SAL_DLLPUBLIC_EXPORT bool TestImport602(SvStream &rStream)
diff --git a/filter/source/t602/t602filter.hxx b/filter/source/t602/t602filter.hxx
index d8ebcd258cd2..5a1bfa513e13 100644
--- a/filter/source/t602/t602filter.hxx
+++ b/filter/source/t602/t602filter.hxx
@@ -31,6 +31,7 @@
 #include <com/sun/star/beans/XPropertyAccess.hpp>
 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
 #include <cppuhelper/implbase.hxx>
 #include <xmloff/attrlist.hxx>
 #include <i18nlangtag/languagetag.hxx>
@@ -124,7 +125,7 @@ class T602ImportFilter : public cppu::WeakImplHelper <
 {
 private:
     css::uno::Reference<css::xml::sax::XDocumentHandler> mxHandler;
-    css::uno::Reference< css::lang::XMultiServiceFactory > mxMSF;
+    css::uno::Reference< css::uno::XComponentContext >   mxContext;
     css::uno::Reference< css::lang::XComponent >         mxDoc;
     css::uno::Reference < css::io::XInputStream >        mxInputStream;
 
@@ -223,7 +224,7 @@ private:
     bool importImpl( const css::uno::Sequence< css::beans::PropertyValue >& aDescriptor );
 
     public:
-        explicit T602ImportFilter(const css::uno::Reference<css::lang::XMultiServiceFactory > &r );
+        explicit T602ImportFilter(const css::uno::Reference<css::uno::XComponentContext > &r );
         explicit T602ImportFilter(css::uno::Reference<css::io::XInputStream> const & xInputStream);
         virtual ~T602ImportFilter() override;
 
@@ -249,26 +250,6 @@ private:
         void test();
 };
 
-/// @throws css::uno::RuntimeException
-OUString T602ImportFilter_getImplementationName();
-
-/// @throws css::uno::RuntimeException
-css::uno::Sequence< OUString > T602ImportFilter_getSupportedServiceNames(  );
-
-/// @throws css::uno::Exception
-css::uno::Reference< css::uno::XInterface >
-T602ImportFilter_createInstance( const css::uno::Reference< css::lang::XMultiServiceFactory > & rSMgr);
-
-/// @throws css::uno::RuntimeException
-OUString T602ImportFilterDialog_getImplementationName();
-
-/// @throws css::uno::RuntimeException
-css::uno::Sequence< OUString > T602ImportFilterDialog_getSupportedServiceNames(  );
-
-/// @throws css::uno::Exception
-css::uno::Reference< css::uno::XInterface >
-T602ImportFilterDialog_createInstance( const css::uno::Reference< css::lang::XMultiServiceFactory > & rSMgr);
-
 }
 
 #endif


More information about the Libreoffice-commits mailing list