[Libreoffice-commits] .: writerperfect/Library_wpftwriter.mk writerperfect/source

Fridrich Strba fridrich at kemper.freedesktop.org
Fri Apr 20 06:38:03 PDT 2012


 writerperfect/Library_wpftwriter.mk                      |    1 
 writerperfect/source/writer/MSWorksImportFilter.cxx      |   19 ++--
 writerperfect/source/writer/MSWorksImportFilter.hxx      |   11 +-
 writerperfect/source/writer/WordPerfectImportFilter.cxx  |   47 ++++-------
 writerperfect/source/writer/WordPerfectImportFilter.hxx  |   21 +---
 writerperfect/source/writer/wpftwriter_genericfilter.cxx |   64 ++++-----------
 6 files changed, 65 insertions(+), 98 deletions(-)

New commits:
commit 0853a4d868bd2dff171c73cc1e495fa03320f7b1
Author: Fridrich Å trba <fridrich.strba at bluewin.ch>
Date:   Fri Apr 20 15:37:25 2012 +0200

    Monkey sberg's work for the other writerperfect library

diff --git a/writerperfect/Library_wpftwriter.mk b/writerperfect/Library_wpftwriter.mk
index 6110035..047f2cf 100644
--- a/writerperfect/Library_wpftwriter.mk
+++ b/writerperfect/Library_wpftwriter.mk
@@ -41,6 +41,7 @@ $(eval $(call gb_Library_use_api,wpftwriter,\
 ))
 
 $(eval $(call gb_Library_use_libraries,wpftwriter,\
+	comphelper \
 	cppu \
 	cppuhelper \
 	vcl \
diff --git a/writerperfect/source/writer/MSWorksImportFilter.cxx b/writerperfect/source/writer/MSWorksImportFilter.cxx
index 2cca078..5712703 100644
--- a/writerperfect/source/writer/MSWorksImportFilter.cxx
+++ b/writerperfect/source/writer/MSWorksImportFilter.cxx
@@ -32,26 +32,30 @@
 #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>
 #include <com/sun/star/xml/sax/InputSource.hpp>
 #include <com/sun/star/xml/sax/XParser.hpp>
+#include <com/sun/star/io/XSeekable.hpp>
+#include <com/sun/star/uno/Reference.h>
 #include <com/sun/star/ucb/XCommandEnvironment.hpp>
 
+#include <comphelper/componentcontext.hxx>
 #include <xmloff/attrlist.hxx>
 #include <ucbhelper/content.hxx>
 
+#include <libwps/libwps.h>
+
 #include "filter/FilterInternal.hxx"
 #include "filter/DocumentHandler.hxx"
 #include "filter/OdtGenerator.hxx"
+#include "MSWorksImportFilter.hxx"
 #include "stream/WPXSvStream.h"
 
-#include <libwps/WPSDocument.h>
-#include "MSWorksImportFilter.hxx"
+#include <iostream>
 
-// using namespace ::rtl;
+using namespace ::com::sun::star::uno;
 using rtl::OString;
 using rtl::OUString;
 using com::sun::star::uno::Sequence;
@@ -61,7 +65,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;
@@ -102,7 +105,7 @@ throw (RuntimeException)
 
     // An XML import service: what we push sax messages to..
     OUString sXMLImportService ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Writer.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);
@@ -251,10 +254,10 @@ throw (RuntimeException)
 #undef SERVICE_NAME2
 #undef SERVICE_NAME1
 
-Reference< XInterface > SAL_CALL MSWorksImportFilter_createInstance( const Reference< XMultiServiceFactory > & rSMgr)
+Reference< XInterface > SAL_CALL MSWorksImportFilter_createInstance( const Reference< XComponentContext > & rContext)
 throw( Exception )
 {
-    return (cppu::OWeakObject *) new MSWorksImportFilter( rSMgr );
+    return (cppu::OWeakObject *) new MSWorksImportFilter( rContext );
 }
 
 // XServiceInfo
diff --git a/writerperfect/source/writer/MSWorksImportFilter.hxx b/writerperfect/source/writer/MSWorksImportFilter.hxx
index 6ef5485..db679eb 100644
--- a/writerperfect/source/writer/MSWorksImportFilter.hxx
+++ b/writerperfect/source/writer/MSWorksImportFilter.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>
 
@@ -51,8 +52,7 @@ class MSWorksImportFilter : 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;
@@ -61,9 +61,8 @@ protected:
     throw (::com::sun::star::uno::RuntimeException);
 
 public:
-    MSWorksImportFilter( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > &rxMSF)
-        : mxMSF( rxMSF )
-    {}
+    MSWorksImportFilter( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &rxContext )
+        : mxContext( rxContext ) {}
     virtual ~MSWorksImportFilter() {}
 
     // XFilter
@@ -104,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 MSWorksImportFilter_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rSMgr)
+SAL_CALL MSWorksImportFilter_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/writer/WordPerfectImportFilter.cxx b/writerperfect/source/writer/WordPerfectImportFilter.cxx
index f98d65e..b0d33bd 100644
--- a/writerperfect/source/writer/WordPerfectImportFilter.cxx
+++ b/writerperfect/source/writer/WordPerfectImportFilter.cxx
@@ -29,35 +29,31 @@
 
 #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>
 #include <com/sun/star/xml/sax/InputSource.hpp>
 #include <com/sun/star/xml/sax/XParser.hpp>
+#include <com/sun/star/io/XSeekable.hpp>
+#include <com/sun/star/uno/Reference.h>
 #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
 #include <com/sun/star/ucb/XCommandEnvironment.hpp>
 
+#include <comphelper/componentcontext.hxx>
 #include <xmloff/attrlist.hxx>
-#include <ucbhelper/content.hxx>
 #include <sfx2/passwd.hxx>
+#include <ucbhelper/content.hxx>
+
+#include <libwpd/libwpd.h>
 
 #include "filter/FilterInternal.hxx"
 #include "filter/DocumentHandler.hxx"
-#include "stream/WPXSvStream.h"
-
-#if defined _MSC_VER
-#pragma warning( push, 1 )
-#endif
-#include <libwpd/WPDocument.h>
-#if defined _MSC_VER
-#pragma warning( pop )
-#endif
-
-#include "filter/OdtGenerator.hxx"
 #include "filter/OdgGenerator.hxx"
+#include "filter/OdtGenerator.hxx"
+#include "stream/WPXSvStream.h"
 #include "WordPerfectImportFilter.hxx"
 
-using namespace ::rtl;
 using namespace ::com::sun::star;
 
 using rtl::OString;
@@ -69,7 +65,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;
@@ -164,7 +159,7 @@ throw (RuntimeException)
 
     // An XML import service: what we push sax messages to..
     OUString sXMLImportService ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Writer.XMLOasisImporter" ) );
-    uno::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..
     uno::Reference < XImporter > xImporter(xInternalHandler, UNO_QUERY);
@@ -203,8 +198,8 @@ throw (::com::sun::star::lang::IllegalArgumentException, RuntimeException)
 }
 
 // XExtendedFilterDetection
-OUString SAL_CALL WordPerfectImportFilter::detect( com::sun::star::uno::Sequence< PropertyValue >& Descriptor )
-throw( com::sun::star::uno::RuntimeException )
+OUString SAL_CALL WordPerfectImportFilter::detect( uno::Sequence< PropertyValue >& Descriptor )
+throw( uno::RuntimeException )
 {
     WRITER_DEBUG_MSG(("WordPerfectImportFilter::detect: Got here!\n"));
 
@@ -313,10 +308,10 @@ throw (RuntimeException)
 #undef SERVICE_NAME2
 #undef SERVICE_NAME1
 
-uno::Reference< XInterface > SAL_CALL WordPerfectImportFilter_createInstance( const uno::Reference< XMultiServiceFactory > & rSMgr)
+uno::Reference< XInterface > SAL_CALL WordPerfectImportFilter_createInstance( const uno::Reference< uno::XComponentContext > & rContext)
 throw( Exception )
 {
-    return (cppu::OWeakObject *) new WordPerfectImportFilter( rSMgr );
+    return (cppu::OWeakObject *) new WordPerfectImportFilter( rContext );
 }
 
 // XServiceInfo
@@ -337,20 +332,20 @@ throw (RuntimeException)
 }
 
 
-WordPerfectImportFilterDialog::WordPerfectImportFilterDialog(const ::com::sun::star::uno::Reference<com::sun::star::lang::XMultiServiceFactory > &r ) :
-    mxMSF( r ) {}
+WordPerfectImportFilterDialog::WordPerfectImportFilterDialog( const uno::Reference< uno::XComponentContext > & rContext) :
+    mxContext( rContext ) {}
 
 WordPerfectImportFilterDialog::~WordPerfectImportFilterDialog()
 {
 }
 
 void SAL_CALL WordPerfectImportFilterDialog::setTitle( const ::rtl::OUString & )
-throw (::com::sun::star::uno::RuntimeException)
+throw (uno::RuntimeException)
 {
 }
 
 sal_Int16 SAL_CALL WordPerfectImportFilterDialog::execute()
-throw (::com::sun::star::uno::RuntimeException)
+throw (uno::RuntimeException)
 {
     WPXSvInputStream input( mxInputStream );
 
@@ -452,10 +447,10 @@ throw (RuntimeException)
 }
 #undef SERVICE_NAME
 
-uno::Reference< XInterface > SAL_CALL WordPerfectImportFilterDialog_createInstance( const uno::Reference< XMultiServiceFactory > & rSMgr)
+uno::Reference< XInterface > SAL_CALL WordPerfectImportFilterDialog_createInstance( const uno::Reference< uno::XComponentContext > & rContext)
 throw( Exception )
 {
-    return (cppu::OWeakObject *) new WordPerfectImportFilterDialog( rSMgr );
+    return (cppu::OWeakObject *) new WordPerfectImportFilterDialog( rContext );
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerperfect/source/writer/WordPerfectImportFilter.hxx b/writerperfect/source/writer/WordPerfectImportFilter.hxx
index 777be1d..d49b0f1 100644
--- a/writerperfect/source/writer/WordPerfectImportFilter.hxx
+++ b/writerperfect/source/writer/WordPerfectImportFilter.hxx
@@ -37,16 +37,12 @@
 #include <com/sun/star/ui/dialogs/XExecutableDialog.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 <com/sun/star/io/XInputStream.hpp>
 #include <cppuhelper/implbase3.hxx>
 #include <cppuhelper/implbase5.hxx>
 
-enum FilterType
-{
-    FILTER_IMPORT,
-    FILTER_EXPORT
-};
 /* This component will be instantiated for both import or export. Whether it calls
  * setSourceDocument or setTargetDocument determines which Impl function the filter
  * member calls */
@@ -60,8 +56,7 @@ class WordPerfectImportFilter : 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;
@@ -70,8 +65,8 @@ protected:
     throw (::com::sun::star::uno::RuntimeException);
 
 public:
-    WordPerfectImportFilter( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > &rxMSF)
-        : mxMSF( rxMSF ) {}
+    WordPerfectImportFilter( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &rxContext )
+        : mxContext( rxContext ) {}
     virtual ~WordPerfectImportFilter() {}
 
     // XFilter
@@ -112,7 +107,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 WordPerfectImportFilter_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rSMgr)
+SAL_CALL WordPerfectImportFilter_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & rContext)
 throw ( ::com::sun::star::uno::Exception );
 
 
@@ -122,7 +117,7 @@ class WordPerfectImportFilterDialog : public cppu::WeakImplHelper3 <
     com::sun::star::beans::XPropertyAccess
     >
 {
-    ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMSF;
+    ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > mxContext;
     ::rtl::OUString msPassword;
     ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > mxInputStream;
 
@@ -154,7 +149,7 @@ class WordPerfectImportFilterDialog : public cppu::WeakImplHelper3 <
            ::com::sun::star::uno::RuntimeException);
 
 public:
-    WordPerfectImportFilterDialog(const ::com::sun::star::uno::Reference<com::sun::star::lang::XMultiServiceFactory > &r );
+    WordPerfectImportFilterDialog( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & rContext);
 
 };
 
@@ -168,7 +163,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 WordPerfectImportFilterDialog_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rSMgr)
+SAL_CALL WordPerfectImportFilterDialog_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/writer/wpftwriter_genericfilter.cxx b/writerperfect/source/writer/wpftwriter_genericfilter.cxx
index 75f53f3..9491b5c 100644
--- a/writerperfect/source/writer/wpftwriter_genericfilter.cxx
+++ b/writerperfect/source/writer/wpftwriter_genericfilter.cxx
@@ -23,59 +23,33 @@
 /* "This product is not manufactured, approved, or supported by
  * Corel Corporation or Corel Corporation Limited."
  */
-#include <stdio.h>
+#include "sal/config.h"
 
-#include <osl/mutex.hxx>
-#include <osl/thread.h>
-#include <cppuhelper/factory.hxx>
-#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include "cppuhelper/factory.hxx"
+#include "cppuhelper/implementationentry.hxx"
+#include "sal/types.h"
 
 #include "WordPerfectImportFilter.hxx"
 #include "MSWorksImportFilter.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 wpftwriter_component_getFactory(
-        const sal_Char *pImplName, void *pServiceManager, void * /* pRegistryKey */ )
-    {
-        void *pRet = 0;
-
-        OUString implName = OUString::createFromAscii( pImplName );
-        if ( pServiceManager && implName.equals(WordPerfectImportFilter_getImplementationName()) )
-        {
-            Reference< XSingleServiceFactory > xFactory( createSingleFactory(
-                        reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
-                        OUString::createFromAscii( pImplName ),
-                        WordPerfectImportFilter_createInstance, WordPerfectImportFilter_getSupportedServiceNames() ) );
-
-            if (xFactory.is())
-            {
-                xFactory->acquire();
-                pRet = xFactory.get();
-            }
-        }
-        if ( pServiceManager && implName.equals(MSWorksImportFilter_getImplementationName()) )
-        {
-            Reference< XSingleServiceFactory > xFactory( createSingleFactory(
-                        reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
-                        OUString::createFromAscii( pImplName ),
-                        MSWorksImportFilter_createInstance, MSWorksImportFilter_getSupportedServiceNames() ) );
+static cppu::ImplementationEntry const services[] = {
+    { &WordPerfectImportFilter_createInstance, &WordPerfectImportFilter_getImplementationName,
+      &WordPerfectImportFilter_getSupportedServiceNames,
+      &cppu::createSingleComponentFactory, 0, 0 },
+    { &MSWorksImportFilter_createInstance, &MSWorksImportFilter_getImplementationName,
+      &MSWorksImportFilter_getSupportedServiceNames,
+      &cppu::createSingleComponentFactory, 0, 0 },
+    { 0, 0, 0, 0, 0, 0 } };
 
-            if (xFactory.is())
-            {
-                xFactory->acquire();
-                pRet = xFactory.get();
-            }
-        }
+}
 
-        return pRet;
-    }
+extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL wpftwriter_component_getFactory(
+    char const * pImplName, void * pServiceManager, void * pRegistryKey)
+{
+    return cppu::component_getFactoryHelper(
+        pImplName, pServiceManager, pRegistryKey, services);
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list