[Libreoffice-commits] .: 2 commits - i18npool/source writerperfect/Library_wpftdraw.mk writerperfect/source

Stephan Bergmann sbergmann at kemper.freedesktop.org
Thu Apr 19 11:57:11 PDT 2012


 i18npool/source/transliteration/transliterationImpl.cxx |   46 -------
 writerperfect/Library_wpftdraw.mk                       |    1 
 writerperfect/source/draw/CDRImportFilter.cxx           |    9 -
 writerperfect/source/draw/CDRImportFilter.hxx           |    9 -
 writerperfect/source/draw/CMXImportFilter.cxx           |    9 -
 writerperfect/source/draw/CMXImportFilter.hxx           |    9 -
 writerperfect/source/draw/VisioImportFilter.cxx         |    9 -
 writerperfect/source/draw/VisioImportFilter.hxx         |    9 -
 writerperfect/source/draw/WPGImportFilter.cxx           |    9 -
 writerperfect/source/draw/WPGImportFilter.hxx           |    9 -
 writerperfect/source/draw/wpftdraw_genericfilter.cxx    |   97 ++++------------
 11 files changed, 69 insertions(+), 147 deletions(-)

New commits:
commit 8e16c9fa498e61b00724cb44cb4470627014fc27
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Thu Apr 19 20:54:13 2012 +0200

    Cleaned up wpftdraw_component_getFactory
    
    ...which required switching service implementations from XMultiServiceManager-
    based to XComponentContext-based (using comphelper::ComponentContext convenience
    helper for the occasional service instantiation via the XComponentContext).

diff --git a/writerperfect/Library_wpftdraw.mk b/writerperfect/Library_wpftdraw.mk
index e4c3b51..15c1492 100644
--- a/writerperfect/Library_wpftdraw.mk
+++ b/writerperfect/Library_wpftdraw.mk
@@ -41,6 +41,7 @@ $(eval $(call gb_Library_use_api,wpftdraw,\
 ))
 
 $(eval $(call gb_Library_use_libraries,wpftdraw,\
+	comphelper \
 	cppu \
 	cppuhelper \
 	sal \
diff --git a/writerperfect/source/draw/CDRImportFilter.cxx b/writerperfect/source/draw/CDRImportFilter.cxx
index 2476a55..7a2538b 100644
--- a/writerperfect/source/draw/CDRImportFilter.cxx
+++ b/writerperfect/source/draw/CDRImportFilter.cxx
@@ -33,7 +33,6 @@
 #include <osl/diagnose.h>
 #include <rtl/tencinfo.h>
 
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
 #include <com/sun/star/io/XInputStream.hpp>
 #include <com/sun/star/xml/sax/XAttributeList.hpp>
 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
@@ -42,6 +41,7 @@
 #include <com/sun/star/io/XSeekable.hpp>
 #include <com/sun/star/uno/Reference.h>
 
+#include <comphelper/componentcontext.hxx>
 #include <xmloff/attrlist.hxx>
 
 #include <libcdr/libcdr.h>
@@ -67,7 +67,6 @@ using com::sun::star::uno::UNO_QUERY;
 using com::sun::star::uno::XInterface;
 using com::sun::star::uno::Exception;
 using com::sun::star::uno::RuntimeException;
-using com::sun::star::lang::XMultiServiceFactory;
 using com::sun::star::beans::PropertyValue;
 using com::sun::star::document::XFilter;
 using com::sun::star::document::XExtendedFilterDetection;
@@ -107,7 +106,7 @@ throw (RuntimeException)
 
     // An XML import service: what we push sax messages to..
     OUString sXMLImportService ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Draw.XMLOasisImporter" ) );
-    Reference < XDocumentHandler > xInternalHandler( mxMSF->createInstance( sXMLImportService ), UNO_QUERY );
+    Reference < XDocumentHandler > xInternalHandler( comphelper::ComponentContext( mxContext ).createComponent( sXMLImportService ), UNO_QUERY );
 
     // The XImporter sets up an empty target document for XDocumentHandler to write to..
     Reference < XImporter > xImporter(xInternalHandler, UNO_QUERY);
@@ -238,13 +237,13 @@ throw (RuntimeException)
 #undef SERVICE_NAME2
 #undef SERVICE_NAME1
 
-Reference< XInterface > SAL_CALL CDRImportFilter_createInstance( const Reference< XMultiServiceFactory > & rSMgr)
+Reference< XInterface > SAL_CALL CDRImportFilter_createInstance( const Reference< XComponentContext > & rContext)
 throw( Exception )
 {
 #ifdef DEBUG
     std::cerr << "CDRImportFilter_createInstance" << std::endl;
 #endif
-    return (cppu::OWeakObject *) new CDRImportFilter( rSMgr );
+    return (cppu::OWeakObject *) new CDRImportFilter( rContext );
 }
 
 // XServiceInfo
diff --git a/writerperfect/source/draw/CDRImportFilter.hxx b/writerperfect/source/draw/CDRImportFilter.hxx
index 56f124e..9dbb945 100644
--- a/writerperfect/source/draw/CDRImportFilter.hxx
+++ b/writerperfect/source/draw/CDRImportFilter.hxx
@@ -35,6 +35,7 @@
 #include <com/sun/star/document/XExtendedFilterDetection.hpp>
 #include <com/sun/star/lang/XInitialization.hpp>
 #include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
 #include <cppuhelper/implbase5.hxx>
 
@@ -54,14 +55,14 @@ class CDRImportFilter : public cppu::WeakImplHelper5
 {
 protected:
     // oo.org declares
-    ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMSF;
+    ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > mxContext;
     ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > mxDoc;
     ::rtl::OUString msFilterName;
     ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > mxHandler;
 
 public:
-    CDRImportFilter( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > &rxMSF)
-        : mxMSF( rxMSF ) {}
+    CDRImportFilter( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &rxContext)
+        : mxContext( rxContext ) {}
     virtual ~CDRImportFilter() {}
 
     // XFilter
@@ -102,7 +103,7 @@ throw ( ::com::sun::star::uno::RuntimeException );
 throw ( ::com::sun::star::uno::RuntimeException );
 
 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
-SAL_CALL CDRImportFilter_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rSMgr)
+SAL_CALL CDRImportFilter_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & rContext)
 throw ( ::com::sun::star::uno::Exception );
 
 #endif
diff --git a/writerperfect/source/draw/CMXImportFilter.cxx b/writerperfect/source/draw/CMXImportFilter.cxx
index 76a9d06..83f161b 100644
--- a/writerperfect/source/draw/CMXImportFilter.cxx
+++ b/writerperfect/source/draw/CMXImportFilter.cxx
@@ -33,7 +33,6 @@
 #include <osl/diagnose.h>
 #include <rtl/tencinfo.h>
 
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
 #include <com/sun/star/io/XInputStream.hpp>
 #include <com/sun/star/xml/sax/XAttributeList.hpp>
 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
@@ -42,6 +41,7 @@
 #include <com/sun/star/io/XSeekable.hpp>
 #include <com/sun/star/uno/Reference.h>
 
+#include <comphelper/componentcontext.hxx>
 #include <xmloff/attrlist.hxx>
 
 #include <libcdr/libcdr.h>
@@ -67,7 +67,6 @@ using com::sun::star::uno::UNO_QUERY;
 using com::sun::star::uno::XInterface;
 using com::sun::star::uno::Exception;
 using com::sun::star::uno::RuntimeException;
-using com::sun::star::lang::XMultiServiceFactory;
 using com::sun::star::beans::PropertyValue;
 using com::sun::star::document::XFilter;
 using com::sun::star::document::XExtendedFilterDetection;
@@ -107,7 +106,7 @@ throw (RuntimeException)
 
     // An XML import service: what we push sax messages to..
     OUString sXMLImportService ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Draw.XMLOasisImporter" ) );
-    Reference < XDocumentHandler > xInternalHandler( mxMSF->createInstance( sXMLImportService ), UNO_QUERY );
+    Reference < XDocumentHandler > xInternalHandler( comphelper::ComponentContext( mxContext ).createComponent( sXMLImportService ), UNO_QUERY );
 
     // The XImporter sets up an empty target document for XDocumentHandler to write to..
     Reference < XImporter > xImporter(xInternalHandler, UNO_QUERY);
@@ -238,13 +237,13 @@ throw (RuntimeException)
 #undef SERVICE_NAME2
 #undef SERVICE_NAME1
 
-Reference< XInterface > SAL_CALL CMXImportFilter_createInstance( const Reference< XMultiServiceFactory > & rSMgr)
+Reference< XInterface > SAL_CALL CMXImportFilter_createInstance( const Reference< XComponentContext > & rContext)
 throw( Exception )
 {
 #ifdef DEBUG
     std::cerr << "CMXImportFilter_createInstance" << std::endl;
 #endif
-    return (cppu::OWeakObject *) new CMXImportFilter( rSMgr );
+    return (cppu::OWeakObject *) new CMXImportFilter( rContext );
 }
 
 // XServiceInfo
diff --git a/writerperfect/source/draw/CMXImportFilter.hxx b/writerperfect/source/draw/CMXImportFilter.hxx
index a9ec8f4..5637bd9 100644
--- a/writerperfect/source/draw/CMXImportFilter.hxx
+++ b/writerperfect/source/draw/CMXImportFilter.hxx
@@ -35,6 +35,7 @@
 #include <com/sun/star/document/XExtendedFilterDetection.hpp>
 #include <com/sun/star/lang/XInitialization.hpp>
 #include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
 #include <cppuhelper/implbase5.hxx>
 
@@ -54,14 +55,14 @@ class CMXImportFilter : public cppu::WeakImplHelper5
 {
 protected:
     // oo.org declares
-    ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMSF;
+    ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > mxContext;
     ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > mxDoc;
     ::rtl::OUString msFilterName;
     ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > mxHandler;
 
 public:
-    CMXImportFilter( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > &rxMSF)
-        : mxMSF( rxMSF ) {}
+    CMXImportFilter( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &rxContext)
+        : mxContext( rxContext ) {}
     virtual ~CMXImportFilter() {}
 
     // XFilter
@@ -102,7 +103,7 @@ throw ( ::com::sun::star::uno::RuntimeException );
 throw ( ::com::sun::star::uno::RuntimeException );
 
 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
-SAL_CALL CMXImportFilter_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rSMgr)
+SAL_CALL CMXImportFilter_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & rContext)
 throw ( ::com::sun::star::uno::Exception );
 
 #endif
diff --git a/writerperfect/source/draw/VisioImportFilter.cxx b/writerperfect/source/draw/VisioImportFilter.cxx
index 13bf089..12337dd 100644
--- a/writerperfect/source/draw/VisioImportFilter.cxx
+++ b/writerperfect/source/draw/VisioImportFilter.cxx
@@ -33,7 +33,6 @@
 #include <osl/diagnose.h>
 #include <rtl/tencinfo.h>
 
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
 #include <com/sun/star/io/XInputStream.hpp>
 #include <com/sun/star/xml/sax/XAttributeList.hpp>
 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
@@ -42,6 +41,7 @@
 #include <com/sun/star/io/XSeekable.hpp>
 #include <com/sun/star/uno/Reference.h>
 
+#include <comphelper/componentcontext.hxx>
 #include <xmloff/attrlist.hxx>
 
 #include <libvisio/libvisio.h>
@@ -67,7 +67,6 @@ using com::sun::star::uno::UNO_QUERY;
 using com::sun::star::uno::XInterface;
 using com::sun::star::uno::Exception;
 using com::sun::star::uno::RuntimeException;
-using com::sun::star::lang::XMultiServiceFactory;
 using com::sun::star::beans::PropertyValue;
 using com::sun::star::document::XFilter;
 using com::sun::star::document::XExtendedFilterDetection;
@@ -107,7 +106,7 @@ throw (RuntimeException)
 
     // An XML import service: what we push sax messages to..
     OUString sXMLImportService ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Draw.XMLOasisImporter" ) );
-    Reference < XDocumentHandler > xInternalHandler( mxMSF->createInstance( sXMLImportService ), UNO_QUERY );
+    Reference < XDocumentHandler > xInternalHandler( comphelper::ComponentContext( mxContext ).createComponent( sXMLImportService ), UNO_QUERY );
 
     // The XImporter sets up an empty target document for XDocumentHandler to write to..
     Reference < XImporter > xImporter(xInternalHandler, UNO_QUERY);
@@ -238,13 +237,13 @@ throw (RuntimeException)
 #undef SERVICE_NAME2
 #undef SERVICE_NAME1
 
-Reference< XInterface > SAL_CALL VisioImportFilter_createInstance( const Reference< XMultiServiceFactory > & rSMgr)
+Reference< XInterface > SAL_CALL VisioImportFilter_createInstance( const Reference< XComponentContext > & rContext)
 throw( Exception )
 {
 #ifdef DEBUG
     std::cerr << "VisioImportFilter_createInstance" << std::endl;
 #endif
-    return (cppu::OWeakObject *) new VisioImportFilter( rSMgr );
+    return (cppu::OWeakObject *) new VisioImportFilter( rContext );
 }
 
 // XServiceInfo
diff --git a/writerperfect/source/draw/VisioImportFilter.hxx b/writerperfect/source/draw/VisioImportFilter.hxx
index 377c007..333ad52 100644
--- a/writerperfect/source/draw/VisioImportFilter.hxx
+++ b/writerperfect/source/draw/VisioImportFilter.hxx
@@ -35,6 +35,7 @@
 #include <com/sun/star/document/XExtendedFilterDetection.hpp>
 #include <com/sun/star/lang/XInitialization.hpp>
 #include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
 #include <cppuhelper/implbase5.hxx>
 
@@ -54,14 +55,14 @@ class VisioImportFilter : public cppu::WeakImplHelper5
 {
 protected:
     // oo.org declares
-    ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMSF;
+    ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > mxContext;
     ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > mxDoc;
     ::rtl::OUString msFilterName;
     ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > mxHandler;
 
 public:
-    VisioImportFilter( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > &rxMSF)
-        : mxMSF( rxMSF ) {}
+    VisioImportFilter( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &rxContext)
+        : mxContext( rxContext ) {}
     virtual ~VisioImportFilter() {}
 
     // XFilter
@@ -102,7 +103,7 @@ throw ( ::com::sun::star::uno::RuntimeException );
 throw ( ::com::sun::star::uno::RuntimeException );
 
 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
-SAL_CALL VisioImportFilter_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rSMgr)
+SAL_CALL VisioImportFilter_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & rContext)
 throw ( ::com::sun::star::uno::Exception );
 
 #endif
diff --git a/writerperfect/source/draw/WPGImportFilter.cxx b/writerperfect/source/draw/WPGImportFilter.cxx
index ff7612b..4c6586b 100644
--- a/writerperfect/source/draw/WPGImportFilter.cxx
+++ b/writerperfect/source/draw/WPGImportFilter.cxx
@@ -33,7 +33,6 @@
 #include <osl/diagnose.h>
 #include <rtl/tencinfo.h>
 
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
 #include <com/sun/star/io/XInputStream.hpp>
 #include <com/sun/star/xml/sax/XAttributeList.hpp>
 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
@@ -42,6 +41,7 @@
 #include <com/sun/star/io/XSeekable.hpp>
 #include <com/sun/star/uno/Reference.h>
 
+#include <comphelper/componentcontext.hxx>
 #include <xmloff/attrlist.hxx>
 
 #include "filter/DocumentHandler.hxx"
@@ -66,7 +66,6 @@ using com::sun::star::uno::UNO_QUERY;
 using com::sun::star::uno::XInterface;
 using com::sun::star::uno::Exception;
 using com::sun::star::uno::RuntimeException;
-using com::sun::star::lang::XMultiServiceFactory;
 using com::sun::star::beans::PropertyValue;
 using com::sun::star::document::XFilter;
 using com::sun::star::document::XExtendedFilterDetection;
@@ -106,7 +105,7 @@ throw (RuntimeException)
 
     // An XML import service: what we push sax messages to..
     OUString sXMLImportService ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Draw.XMLOasisImporter" ) );
-    Reference < XDocumentHandler > xInternalHandler( mxMSF->createInstance( sXMLImportService ), UNO_QUERY );
+    Reference < XDocumentHandler > xInternalHandler( comphelper::ComponentContext( mxContext ).createComponent( sXMLImportService ), UNO_QUERY );
 
     // The XImporter sets up an empty target document for XDocumentHandler to write to..
     Reference < XImporter > xImporter(xInternalHandler, UNO_QUERY);
@@ -237,13 +236,13 @@ throw (RuntimeException)
 #undef SERVICE_NAME2
 #undef SERVICE_NAME1
 
-Reference< XInterface > SAL_CALL WPGImportFilter_createInstance( const Reference< XMultiServiceFactory > & rSMgr)
+Reference< XInterface > SAL_CALL WPGImportFilter_createInstance( const Reference< XComponentContext > & rContext)
 throw( Exception )
 {
 #ifdef DEBUG
     std::cerr << "WPGImportFilter_createInstance" << std::endl;
 #endif
-    return (cppu::OWeakObject *) new WPGImportFilter( rSMgr );
+    return (cppu::OWeakObject *) new WPGImportFilter( rContext );
 }
 
 // XServiceInfo
diff --git a/writerperfect/source/draw/WPGImportFilter.hxx b/writerperfect/source/draw/WPGImportFilter.hxx
index 091c821..1f3367f 100644
--- a/writerperfect/source/draw/WPGImportFilter.hxx
+++ b/writerperfect/source/draw/WPGImportFilter.hxx
@@ -35,6 +35,7 @@
 #include <com/sun/star/document/XExtendedFilterDetection.hpp>
 #include <com/sun/star/lang/XInitialization.hpp>
 #include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
 #include <cppuhelper/implbase5.hxx>
 
@@ -54,14 +55,14 @@ class WPGImportFilter : public cppu::WeakImplHelper5
 {
 protected:
     // oo.org declares
-    ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMSF;
+    ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > mxContext;
     ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > mxDoc;
     ::rtl::OUString msFilterName;
     ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > mxHandler;
 
 public:
-    WPGImportFilter( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > &rxMSF)
-        : mxMSF( rxMSF ) {}
+    WPGImportFilter( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &rxContext)
+        : mxContext( rxContext ) {}
     virtual ~WPGImportFilter() {}
 
     // XFilter
@@ -102,7 +103,7 @@ throw ( ::com::sun::star::uno::RuntimeException );
 throw ( ::com::sun::star::uno::RuntimeException );
 
 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
-SAL_CALL WPGImportFilter_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rSMgr)
+SAL_CALL WPGImportFilter_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & rContext)
 throw ( ::com::sun::star::uno::Exception );
 
 #endif
diff --git a/writerperfect/source/draw/wpftdraw_genericfilter.cxx b/writerperfect/source/draw/wpftdraw_genericfilter.cxx
index cbecb4f..fdfe1ef 100644
--- a/writerperfect/source/draw/wpftdraw_genericfilter.cxx
+++ b/writerperfect/source/draw/wpftdraw_genericfilter.cxx
@@ -23,88 +23,43 @@
 /* "This product is not manufactured, approved, or supported by
  * Corel Corporation or Corel Corporation Limited."
  */
-#include <stdio.h>
 
-#include <osl/mutex.hxx>
-#include <osl/thread.h>
-#include <cppuhelper/factory.hxx>
+#include "sal/config.h"
 
-#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include "cppuhelper/factory.hxx"
+#include "cppuhelper/implementationentry.hxx"
+#include "sal/types.h"
 
 #include "CDRImportFilter.hxx"
 #include "CMXImportFilter.hxx"
 #include "VisioImportFilter.hxx"
 #include "WPGImportFilter.hxx"
 
-using namespace ::rtl;
-using namespace ::cppu;
-using namespace ::com::sun::star::uno;
-using namespace ::com::sun::star::lang;
-using namespace ::com::sun::star::registry;
+namespace {
 
-extern "C"
-{
-    SAL_DLLPUBLIC_EXPORT void *SAL_CALL wpftdraw_component_getFactory(
-        const sal_Char *pImplName, void *pServiceManager, void * /* pRegistryKey */ )
-    {
-        void *pRet = 0;
-
-        OUString implName = OUString::createFromAscii( pImplName );
-        if ( pServiceManager && implName.equals(CDRImportFilter_getImplementationName()) )
-        {
-            Reference< XSingleServiceFactory > xFactory( createSingleFactory(
-                        reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
-                        OUString::createFromAscii( pImplName ),
-                        CDRImportFilter_createInstance, CDRImportFilter_getSupportedServiceNames() ) );
-
-            if (xFactory.is())
-            {
-                xFactory->acquire();
-                pRet = xFactory.get();
-            }
-        }
-        if ( pServiceManager && implName.equals(CMXImportFilter_getImplementationName()) )
-        {
-            Reference< XSingleServiceFactory > xFactory( createSingleFactory(
-                        reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
-                        OUString::createFromAscii( pImplName ),
-                        CMXImportFilter_createInstance, CMXImportFilter_getSupportedServiceNames() ) );
-
-            if (xFactory.is())
-            {
-                xFactory->acquire();
-                pRet = xFactory.get();
-            }
-        }
-        if ( pServiceManager && implName.equals(WPGImportFilter_getImplementationName()) )
-        {
-            Reference< XSingleServiceFactory > xFactory( createSingleFactory(
-                        reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
-                        OUString::createFromAscii( pImplName ),
-                        WPGImportFilter_createInstance, WPGImportFilter_getSupportedServiceNames() ) );
+static cppu::ImplementationEntry const services[] = {
+    { &CDRImportFilter_createInstance, &CDRImportFilter_getImplementationName,
+      &CDRImportFilter_getSupportedServiceNames,
+      &cppu::createSingleComponentFactory, 0, 0 },
+    { &CMXImportFilter_createInstance, &CMXImportFilter_getImplementationName,
+      &CMXImportFilter_getSupportedServiceNames,
+      &cppu::createSingleComponentFactory, 0, 0 },
+    { &VisioImportFilter_createInstance,
+      &VisioImportFilter_getImplementationName,
+      &VisioImportFilter_getSupportedServiceNames,
+      &cppu::createSingleComponentFactory, 0, 0 },
+    { &WPGImportFilter_createInstance, &WPGImportFilter_getImplementationName,
+      &WPGImportFilter_getSupportedServiceNames,
+      &cppu::createSingleComponentFactory, 0, 0 },
+    { 0, 0, 0, 0, 0, 0 } };
 
-            if (xFactory.is())
-            {
-                xFactory->acquire();
-                pRet = xFactory.get();
-            }
-        }
-        if ( pServiceManager && implName.equals(VisioImportFilter_getImplementationName()) )
-        {
-            Reference< XSingleServiceFactory > xFactory( createSingleFactory(
-                        reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
-                        OUString::createFromAscii( pImplName ),
-                        VisioImportFilter_createInstance, VisioImportFilter_getSupportedServiceNames() ) );
-
-            if (xFactory.is())
-            {
-                xFactory->acquire();
-                pRet = xFactory.get();
-            }
-        }
+}
 
-        return pRet;
-    }
+extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL wpftdraw_component_getFactory(
+    char const * pImplName, void * pServiceManager, void * pRegistryKey)
+{
+    return cppu::component_getFactoryHelper(
+        pImplName, pServiceManager, pRegistryKey, services);
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit c85ed498bd32733cc9e4574635abbdba40f2aa7c
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Thu Apr 19 16:59:57 2012 +0200

    Simplify TransliterationImpl::loadBody
    
    its not evident to me why the original code needed to be so complicated.

diff --git a/i18npool/source/transliteration/transliterationImpl.cxx b/i18npool/source/transliteration/transliterationImpl.cxx
index eae43fd..5e9f621 100644
--- a/i18npool/source/transliteration/transliterationImpl.cxx
+++ b/i18npool/source/transliteration/transliterationImpl.cxx
@@ -32,10 +32,6 @@
 
 #include <com/sun/star/i18n/TransliterationType.hpp>
 #include <com/sun/star/lang/XComponent.hpp>
-#include <com/sun/star/container/XContentEnumerationAccess.hpp>
-#include <com/sun/star/container/XEnumeration.hpp>
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/lang/XSingleServiceFactory.hpp>
 
 #include <comphelper/processfactory.hxx>
 #include <rtl/string.h>
@@ -50,7 +46,6 @@
 
 using namespace com::sun::star::uno;
 using namespace com::sun::star::lang;
-using namespace com::sun::star::container;
 
 using ::rtl::OUString;
 
@@ -595,44 +590,15 @@ TransliterationImpl::clear()
 void TransliterationImpl::loadBody( OUString &implName, Reference<XExtendedTransliteration>& body )
     throw (RuntimeException)
 {
+    assert(!implName.isEmpty());
     ::osl::MutexGuard guard(lastTransBody.mutex);
-
-    if (implName.equals(lastTransBody.Name))
+    if (implName != lastTransBody.Name)
     {
-        // Use the cached body instead of going through the expensive looping again.
-        body = lastTransBody.Body;
-        return;
-    }
-
-    Reference< XContentEnumerationAccess > xEnumAccess( xSMgr, UNO_QUERY );
-    Reference< XEnumeration > xEnum(xEnumAccess->createContentEnumeration(
-                                    OUString(RTL_CONSTASCII_USTRINGPARAM(TRLT_SERVICELNAME_L10N))));
-    if (xEnum.is()) {
-        while (xEnum->hasMoreElements()) {
-            Any a = xEnum->nextElement();
-            Reference< XServiceInfo > xsInfo;
-            if (a >>= xsInfo) {
-                if (implName.equals(xsInfo->getImplementationName())) {
-                    Reference< XSingleServiceFactory > xFactory;
-                    if (a >>= xFactory) {
-                        Reference< XInterface > xI = xFactory->createInstance();
-                        if (xI.is()) {
-                            a = xI->queryInterface(::getCppuType((
-                                        const Reference<XExtendedTransliteration>*)0));
-                            a >>= body;
-                            lastTransBody.Name = implName;
-                            lastTransBody.Body = body;
-                            return;
-                        }
-                    }
-                }
-            }
-        }
+        lastTransBody.Body.set(
+            xSMgr->createInstance(implName), UNO_QUERY_THROW);
+        lastTransBody.Name = implName;
     }
-    throw RuntimeException(
-        ("cannot find " TRLT_SERVICELNAME_L10N " service implementation named "
-         + implName),
-        Reference< XInterface >());
+    body = lastTransBody.Body;
 }
 
 sal_Bool SAL_CALL


More information about the Libreoffice-commits mailing list