[Libreoffice-commits] core.git: 4 commits - filter/Configuration_filter.mk filter/source postprocess/Rdb_services.mk Repository.mk writerperfect/CppunitTest_writerperfect_calc.mk writerperfect/Library_wpftcalc.mk writerperfect/Module_writerperfect.mk writerperfect/qa writerperfect/source

David Tardon dtardon at redhat.com
Thu May 29 06:37:10 PDT 2014


 Repository.mk                                                   |    1 
 filter/Configuration_filter.mk                                  |    2 
 filter/source/config/fragments/filters/Great_Works_Draw.xcu     |    2 
 filter/source/config/fragments/filters/MS_Works_Calc.xcu        |   30 +
 filter/source/config/fragments/types/calc_MS_Works_Document.xcu |   29 +
 postprocess/Rdb_services.mk                                     |    1 
 writerperfect/CppunitTest_writerperfect_calc.mk                 |   46 ++
 writerperfect/Library_wpftcalc.mk                               |   56 +++
 writerperfect/Module_writerperfect.mk                           |    2 
 writerperfect/qa/unit/WpftCalcFilterTest.cxx                    |   43 ++
 writerperfect/source/calc/ImportFilterBase.cxx                  |  182 ++++++++++
 writerperfect/source/calc/ImportFilterBase.hxx                  |  103 +++++
 writerperfect/source/calc/MSWorksCalcImportFilter.cxx           |   91 +++++
 writerperfect/source/calc/MSWorksCalcImportFilter.hxx           |   53 ++
 writerperfect/source/calc/wpftcalc.component                    |   16 
 writerperfect/source/calc/wpftcalc_genericfilter.cxx            |   51 ++
 writerperfect/source/impress/KeynoteImportFilter.cxx            |    2 
 17 files changed, 708 insertions(+), 2 deletions(-)

New commits:
commit b6ea5de5eda77fa1bb0b7ee8248f001d58bae6be
Author: David Tardon <dtardon at redhat.com>
Date:   Thu May 29 15:35:15 2014 +0200

    add writerperfect calc integration test
    
    Change-Id: I3ce072f5f7d54b063988f8413251eab00f5321e4

diff --git a/writerperfect/CppunitTest_writerperfect_calc.mk b/writerperfect/CppunitTest_writerperfect_calc.mk
new file mode 100644
index 0000000..1a05595
--- /dev/null
+++ b/writerperfect/CppunitTest_writerperfect_calc.mk
@@ -0,0 +1,46 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# 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/.
+#
+
+$(eval $(call gb_CppunitTest_CppunitTest,writerperfect_calc))
+
+$(eval $(call gb_CppunitTest_use_externals,writerperfect_calc,\
+	boost_headers \
+))
+
+$(eval $(call gb_CppunitTest_use_api,writerperfect_calc,\
+	offapi \
+	udkapi \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,writerperfect_calc,\
+	comphelper \
+	cppu \
+	cppuhelper \
+	sal \
+	test \
+	ucbhelper \
+	unotest \
+	$(gb_UWINAPI) \
+))
+
+$(eval $(call gb_CppunitTest_use_static_libraries,writerperfect_calc,\
+	writerperfect_importtestbase \
+))
+
+$(eval $(call gb_CppunitTest_use_ure,writerperfect_calc))
+
+$(eval $(call gb_CppunitTest_use_rdb,writerperfect_calc,services))
+
+$(eval $(call gb_CppunitTest_use_configuration,writerperfect_calc))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,writerperfect_calc,\
+	writerperfect/qa/unit/WpftCalcFilterTest \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/writerperfect/Module_writerperfect.mk b/writerperfect/Module_writerperfect.mk
index 37da37c..9c30697 100644
--- a/writerperfect/Module_writerperfect.mk
+++ b/writerperfect/Module_writerperfect.mk
@@ -32,6 +32,7 @@ $(eval $(call gb_Module_add_check_targets,writerperfect,\
 ))
 
 $(eval $(call gb_Module_add_slowcheck_targets,writerperfect,\
+	CppunitTest_writerperfect_calc \
 	CppunitTest_writerperfect_draw \
 	CppunitTest_writerperfect_impress \
 	CppunitTest_writerperfect_writer \
diff --git a/writerperfect/qa/unit/WpftCalcFilterTest.cxx b/writerperfect/qa/unit/WpftCalcFilterTest.cxx
new file mode 100644
index 0000000..ba1ed1e
--- /dev/null
+++ b/writerperfect/qa/unit/WpftCalcFilterTest.cxx
@@ -0,0 +1,43 @@
+/* -*- 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/.
+ */
+
+#include "WpftImportTestBase.hxx"
+
+namespace
+{
+
+class WpftCalcFilterTest : public writerperfect::test::WpftImportTestBase
+{
+public:
+    WpftCalcFilterTest();
+
+    void test();
+
+    CPPUNIT_TEST_SUITE(WpftCalcFilterTest);
+    CPPUNIT_TEST(test);
+    CPPUNIT_TEST_SUITE_END();
+};
+
+WpftCalcFilterTest::WpftCalcFilterTest()
+    : writerperfect::test::WpftImportTestBase("private:factory/scalc")
+{
+}
+
+void WpftCalcFilterTest::test()
+{
+    doTest("com.sun.star.comp.Calc.MSWorksCalcImportFilter", "/writerperfect/qa/unit/data/calc/libwps/");
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(WpftCalcFilterTest);
+
+}
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerperfect/qa/unit/data/calc/libwps/fail/.gitignore b/writerperfect/qa/unit/data/calc/libwps/fail/.gitignore
new file mode 100644
index 0000000..e69de29
diff --git a/writerperfect/qa/unit/data/calc/libwps/indeterminate/.gitignore b/writerperfect/qa/unit/data/calc/libwps/indeterminate/.gitignore
new file mode 100644
index 0000000..e69de29
diff --git a/writerperfect/qa/unit/data/calc/libwps/pass/.gitignore b/writerperfect/qa/unit/data/calc/libwps/pass/.gitignore
new file mode 100644
index 0000000..e69de29
commit eccfc72781dfa485c94b251e81718bdddd544606
Author: osnola <alonso at loria.fr>
Date:   Thu May 29 14:29:45 2014 +0200

    Make the wdb/wks and GreatWorks(draw) work
    
    Change-Id: I1a736a511e6007a4ed6413eb8d9b8e364d73f765

diff --git a/filter/source/config/fragments/filters/Great_Works_Draw.xcu b/filter/source/config/fragments/filters/Great_Works_Draw.xcu
index 4bb0667..8153102 100644
--- a/filter/source/config/fragments/filters/Great_Works_Draw.xcu
+++ b/filter/source/config/fragments/filters/Great_Works_Draw.xcu
@@ -12,7 +12,7 @@
         <value>IMPORT ALIEN USESOPTIONS 3RDPARTYFILTER PREFERRED</value>
     </prop>
     <prop oor:name="FilterService">
-        <value>com.sun.star.comp.Draaw.MWAWDrawImportFilter</value>
+        <value>com.sun.star.comp.Draw.MWAWDrawImportFilter</value>
     </prop>
     <prop oor:name="UIName">
         <value xml:lang="en-US">GreatWorks Document</value>
diff --git a/filter/source/config/fragments/types/calc_MS_Works_Document.xcu b/filter/source/config/fragments/types/calc_MS_Works_Document.xcu
index d409be8..8785a32 100644
--- a/filter/source/config/fragments/types/calc_MS_Works_Document.xcu
+++ b/filter/source/config/fragments/types/calc_MS_Works_Document.xcu
@@ -18,8 +18,8 @@
     <node oor:name="calc_MS_Works_Document" oor:op="replace" >
         <prop oor:name="DetectService"><value>com.sun.star.comp.Calc.MSWorksCalcImportFilter</value></prop>
         <prop oor:name="URLPattern"/>
-        <prop oor:name="Extensions"><value>wps</value></prop>
-        <prop oor:name="MediaType"><value>application/vnd.ms-works</value></prop>
+        <prop oor:name="Extensions"><value>wks/wdb</value></prop>
+        <prop oor:name="MediaType"></prop>
         <prop oor:name="Preferred"><value>true</value></prop>
         <prop oor:name="PreferredFilter"><value>MS_Works_Calc</value></prop>
         <prop oor:name="UIName">
diff --git a/postprocess/Rdb_services.mk b/postprocess/Rdb_services.mk
index 9ebe6d2..a1fe9bc 100644
--- a/postprocess/Rdb_services.mk
+++ b/postprocess/Rdb_services.mk
@@ -120,6 +120,7 @@ $(eval $(call gb_Rdb_add_components,services,\
 	writerperfect/source/draw/wpftdraw \
 	writerperfect/source/impress/wpftimpress \
 	writerperfect/source/writer/wpftwriter \
+	writerperfect/source/calc/wpftcalc \
 	$(if $(filter MACOSX,$(OS)), \
 		$(if $(filter 1060,$(MACOSX_SDK_VERSION)),, \
 			$(call gb_Helper_optional,AVMEDIA,avmedia/source/macavf/avmediaMacAVF) \
commit e1fa08fe92d7d3f89f5f75cb67f17bb491c42361
Author: osnola <alonso at loria.fr>
Date:   Thu May 29 10:26:28 2014 +0200

    Try to add support for WKS/WDB files...
    
    Change-Id: I0ff1cd35be0e1546a156bc673770a920ad2ca444

diff --git a/Repository.mk b/Repository.mk
index 1e6745a..700d9f5 100644
--- a/Repository.mk
+++ b/Repository.mk
@@ -162,6 +162,7 @@ $(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,calc, \
 	scd \
 	scfilt \
 	scui \
+	wpftcalc \
 	$(if $(ENABLE_OPENCL),scopencl) \
 	$(if $(ENABLE_COINMP)$(ENABLE_LPSOLVE),solver) \
 	$(if $(DISABLE_SCRIPTING),,vbaobj) \
diff --git a/filter/Configuration_filter.mk b/filter/Configuration_filter.mk
index 9783f50..ebd9bf2 100644
--- a/filter/Configuration_filter.mk
+++ b/filter/Configuration_filter.mk
@@ -537,6 +537,7 @@ $(call filter_Configuration_add_types,fcfg_langpack,fcfg_calc_types.xcu,filter/s
 	MS_Excel_2007_Binary \
 	calc_OOXML \
 	calc_OOXML_Template \
+	calc_MS_Works_Document \
 )
 
 $(call filter_Configuration_add_filters,fcfg_langpack,fcfg_calc_filters.xcu,filter/source/config/fragments/filters,\
@@ -568,6 +569,7 @@ $(call filter_Configuration_add_filters,fcfg_langpack,fcfg_calc_filters.xcu,filt
 	calc_MS_Excel_2007_Binary \
 	calc_OOXML \
 	calc_OOXML_Template \
+	MS_Works_Calc \
 )
 
 $(call filter_Configuration_add_ui_filters,fcfg_langpack,filter/source/config/fragments/filters,\
diff --git a/filter/source/config/fragments/filters/MS_Works_Calc.xcu b/filter/source/config/fragments/filters/MS_Works_Calc.xcu
new file mode 100644
index 0000000..a8222a7
--- /dev/null
+++ b/filter/source/config/fragments/filters/MS_Works_Calc.xcu
@@ -0,0 +1,30 @@
+<!--
+ * 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 .
+-->
+    <node oor:name="MS_Works_Calc" oor:op="replace">
+        <prop oor:name="Flags"><value>IMPORT ALIEN USESOPTIONS 3RDPARTYFILTER</value></prop>
+        <prop oor:name="UIComponent"/>
+        <prop oor:name="FilterService"><value>com.sun.star.comp.Calc.MSWorksCalcImportFilter</value></prop>
+        <prop oor:name="UserData"><value></value></prop>
+        <prop oor:name="UIName">
+            <value xml:lang="en-US">Microsoft Works Document</value>
+        </prop>
+        <prop oor:name="FileFormatVersion"><value>0</value></prop>
+        <prop oor:name="Type"><value>calc_MS_Works_Document</value></prop>
+        <prop oor:name="TemplateName"/>
+        <prop oor:name="DocumentService"><value>com.sun.star.sheet.SpreadsheetDocument</value></prop>
+    </node>
diff --git a/filter/source/config/fragments/types/calc_MS_Works_Document.xcu b/filter/source/config/fragments/types/calc_MS_Works_Document.xcu
new file mode 100644
index 0000000..d409be8
--- /dev/null
+++ b/filter/source/config/fragments/types/calc_MS_Works_Document.xcu
@@ -0,0 +1,29 @@
+<!--
+ * 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 .
+-->
+    <node oor:name="calc_MS_Works_Document" oor:op="replace" >
+        <prop oor:name="DetectService"><value>com.sun.star.comp.Calc.MSWorksCalcImportFilter</value></prop>
+        <prop oor:name="URLPattern"/>
+        <prop oor:name="Extensions"><value>wps</value></prop>
+        <prop oor:name="MediaType"><value>application/vnd.ms-works</value></prop>
+        <prop oor:name="Preferred"><value>true</value></prop>
+        <prop oor:name="PreferredFilter"><value>MS_Works_Calc</value></prop>
+        <prop oor:name="UIName">
+            <value>Microsoft Works Document</value>
+        </prop>
+        <prop oor:name="ClipboardFormat"/>
+    </node>
diff --git a/writerperfect/Library_wpftcalc.mk b/writerperfect/Library_wpftcalc.mk
new file mode 100644
index 0000000..2e69c3b
--- /dev/null
+++ b/writerperfect/Library_wpftcalc.mk
@@ -0,0 +1,56 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# 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 .
+#
+
+$(eval $(call gb_Library_Library,wpftcalc))
+
+$(eval $(call gb_Library_set_componentfile,wpftcalc,writerperfect/source/calc/wpftcalc))
+
+$(eval $(call gb_Library_use_sdk_api,wpftcalc))
+
+$(eval $(call gb_Library_use_libraries,wpftcalc,\
+	comphelper \
+	cppu \
+	cppuhelper \
+	sal \
+	sot \
+	tl \
+	utl \
+	writerperfect \
+	xo \
+	$(gb_UWINAPI) \
+))
+
+$(eval $(call gb_Library_use_externals,wpftcalc,\
+	odfgen \
+	revenge \
+	wps \
+	zlib \
+	lcms2 \
+	libxml2 \
+	icui18n \
+	icuuc \
+))
+
+$(eval $(call gb_Library_add_exception_objects,wpftcalc,\
+	writerperfect/source/calc/ImportFilterBase \
+	writerperfect/source/calc/MSWorksCalcImportFilter \
+	writerperfect/source/calc/wpftcalc_genericfilter \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/writerperfect/Module_writerperfect.mk b/writerperfect/Module_writerperfect.mk
index 24decb4..37da37c 100644
--- a/writerperfect/Module_writerperfect.mk
+++ b/writerperfect/Module_writerperfect.mk
@@ -20,6 +20,7 @@
 $(eval $(call gb_Module_Module,writerperfect))
 
 $(eval $(call gb_Module_add_targets,writerperfect,\
+	Library_wpftcalc \
 	Library_wpftdraw \
 	Library_wpftimpress \
 	Library_wpftwriter \
diff --git a/writerperfect/source/calc/ImportFilterBase.cxx b/writerperfect/source/calc/ImportFilterBase.cxx
new file mode 100644
index 0000000..ef36746
--- /dev/null
+++ b/writerperfect/source/calc/ImportFilterBase.cxx
@@ -0,0 +1,182 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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/.
+ */
+
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/io/XInputStream.hpp>
+#include <com/sun/star/uno/XComponentContext.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 <writerperfect/DocumentHandler.hxx>
+#include <writerperfect/WPXSvInputStream.hxx>
+
+#include <xmloff/attrlist.hxx>
+
+#include <libodfgen/libodfgen.hxx>
+
+#include "ImportFilterBase.hxx"
+
+namespace writerperfect
+{
+namespace calc
+{
+
+using com::sun::star::uno::Reference;
+using com::sun::star::io::XInputStream;
+using com::sun::star::io::XSeekable;
+using com::sun::star::uno::Sequence;
+using com::sun::star::uno::Any;
+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::beans::PropertyValue;
+using com::sun::star::document::XFilter;
+using com::sun::star::document::XExtendedFilterDetection;
+using com::sun::star::document::XImporter;
+using com::sun::star::xml::sax::InputSource;
+using com::sun::star::xml::sax::XAttributeList;
+using com::sun::star::xml::sax::XDocumentHandler;
+using com::sun::star::xml::sax::XParser;
+
+using writerperfect::DocumentHandler;
+using writerperfect::WPXSvInputStream;
+
+ImportFilterImpl::ImportFilterImpl( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &rxContext )
+    : mxContext( rxContext )
+{
+}
+
+ImportFilterImpl::~ImportFilterImpl()
+{
+}
+
+sal_Bool SAL_CALL ImportFilterImpl::filter( const Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor )
+throw (RuntimeException, std::exception)
+{
+    sal_Int32 nLength = aDescriptor.getLength();
+    const PropertyValue *pValue = aDescriptor.getConstArray();
+    Reference < XInputStream > xInputStream;
+    for ( sal_Int32 i = 0 ; i < nLength; i++)
+    {
+        if ( pValue[i].Name == "InputStream" )
+            pValue[i].Value >>= xInputStream;
+    }
+    if ( !xInputStream.is() )
+    {
+        OSL_ASSERT( false );
+        return sal_False;
+    }
+
+    // An XML import service: what we push sax messages to..
+    Reference < XDocumentHandler > xInternalHandler(
+        mxContext->getServiceManager()->createInstanceWithContext(
+            "com.sun.star.comp.Calc.XMLOasisImporter", mxContext),
+        css::uno::UNO_QUERY_THROW);
+
+    // The XImporter sets up an empty target document for XDocumentHandler to write to..
+    Reference < XImporter > xImporter(xInternalHandler, UNO_QUERY);
+    xImporter->setTargetDocument( mxDoc );
+
+    // OO Graphics Handler: abstract class to handle document SAX messages, concrete implementation here
+    // writes to in-memory target doc
+    DocumentHandler xHandler(xInternalHandler);
+
+    WPXSvInputStream input( xInputStream );
+
+    OdsGenerator exporter;
+    exporter.addDocumentHandler(&xHandler, ODF_FLAT_XML);
+
+    doRegisterHandlers(exporter);
+
+    return doImportDocument(input, exporter);
+}
+
+void SAL_CALL ImportFilterImpl::cancel(  )
+throw (RuntimeException, std::exception)
+{
+}
+
+// XImporter
+void SAL_CALL ImportFilterImpl::setTargetDocument( const Reference< ::com::sun::star::lang::XComponent >& xDoc )
+throw (::com::sun::star::lang::IllegalArgumentException, RuntimeException, std::exception)
+{
+    mxDoc = xDoc;
+}
+
+// XExtendedFilterDetection
+OUString SAL_CALL ImportFilterImpl::detect( com::sun::star::uno::Sequence< PropertyValue >& Descriptor )
+throw( com::sun::star::uno::RuntimeException, std::exception )
+{
+    OUString sTypeName;
+    sal_Int32 nLength = Descriptor.getLength();
+    sal_Int32 location = nLength;
+    const PropertyValue *pValue = Descriptor.getConstArray();
+    Reference < XInputStream > xInputStream;
+    for ( sal_Int32 i = 0 ; i < nLength; i++)
+    {
+        if ( pValue[i].Name == "TypeName" )
+            location=i;
+        else if ( pValue[i].Name == "InputStream" )
+            pValue[i].Value >>= xInputStream;
+    }
+
+    if (!xInputStream.is())
+        return OUString();
+
+    WPXSvInputStream input( xInputStream );
+
+    if ( doDetectFormat( input, sTypeName ) )
+    {
+        assert (!sTypeName.isEmpty());
+
+        if ( location == nLength )
+        {
+            Descriptor.realloc(nLength+1);
+            Descriptor[location].Name = "TypeName";
+        }
+
+        Descriptor[location].Value <<=sTypeName;
+    }
+
+    return sTypeName;
+}
+
+
+// XInitialization
+void SAL_CALL ImportFilterImpl::initialize( const Sequence< Any >& aArguments )
+throw (Exception, RuntimeException, std::exception)
+{
+    Sequence < PropertyValue > aAnySeq;
+    sal_Int32 nLength = aArguments.getLength();
+    if ( nLength && ( aArguments[0] >>= aAnySeq ) )
+    {
+        const PropertyValue *pValue = aAnySeq.getConstArray();
+        nLength = aAnySeq.getLength();
+        for ( sal_Int32 i = 0 ; i < nLength; i++)
+        {
+            if ( pValue[i].Name == "Type" )
+            {
+                pValue[i].Value >>= msFilterName;
+                break;
+            }
+        }
+    }
+}
+
+void ImportFilterImpl::doRegisterHandlers( OdsGenerator & )
+{
+}
+
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerperfect/source/calc/ImportFilterBase.hxx b/writerperfect/source/calc/ImportFilterBase.hxx
new file mode 100644
index 0000000..d6ef454
--- /dev/null
+++ b/writerperfect/source/calc/ImportFilterBase.hxx
@@ -0,0 +1,103 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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/.
+ */
+
+#ifndef INCLUDED_WRITERPERFECT_SOURCE_CALC_IMPORTFILTERBASE_HXX
+#define INCLUDED_WRITERPERFECT_SOURCE_CALC_IMPORTFILTERBASE_HXX
+
+#include <librevenge/librevenge.h>
+
+#include <librevenge-stream/librevenge-stream.h>
+
+#include <com/sun/star/document/XFilter.hpp>
+#include <com/sun/star/document/XImporter.hpp>
+#include <com/sun/star/document/XExtendedFilterDetection.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <cppuhelper/implbase1.hxx>
+#include <cppuhelper/implbase4.hxx>
+
+namespace com { namespace sun { namespace star {
+namespace beans
+{
+    struct PropertyValue;
+}
+namespace lang
+{
+    class XComponent;
+}
+namespace uno
+{
+    class XComponentContext;
+}
+namespace xml { namespace sax {
+    class XDocumentHandler;
+}
+}
+} } }
+
+class OdsGenerator;
+
+namespace writerperfect
+{
+namespace calc
+{
+
+/* This component will be instantiated for both import or export. Whether it calls
+ * setSourceDocument or setTargetDocument determines which Impl function the filter
+ * member calls */
+class ImportFilterImpl : public cppu::WeakImplHelper4
+    <
+    com::sun::star::document::XFilter,
+    com::sun::star::document::XImporter,
+    com::sun::star::document::XExtendedFilterDetection,
+    com::sun::star::lang::XInitialization
+    >
+{
+public:
+    ImportFilterImpl( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &rxContext );
+    virtual ~ImportFilterImpl();
+
+    // XFilter
+    virtual sal_Bool SAL_CALL filter( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor )
+    throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
+    virtual void SAL_CALL cancel(  )
+    throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
+
+    // XImporter
+    virtual void SAL_CALL setTargetDocument( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& xDoc )
+    throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
+
+    //XExtendedFilterDetection
+    virtual OUString SAL_CALL detect( com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& Descriptor )
+    throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
+
+    // XInitialization
+    virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
+    throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
+
+private:
+    virtual bool doDetectFormat( librevenge::RVNGInputStream &rInput, OUString &rTypeName ) = 0;
+    virtual bool doImportDocument( librevenge::RVNGInputStream &rInput, librevenge::RVNGSpreadsheetInterface &rGenerator ) = 0;
+    virtual void doRegisterHandlers( OdsGenerator &rGenerator );
+
+private:
+    ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > mxContext;
+    ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > mxDoc;
+    OUString msFilterName;
+    ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > mxHandler;
+};
+
+/** A base class for import filters.
+ */
+typedef cppu::ImplInheritanceHelper1<ImportFilterImpl, com::sun::star::lang::XServiceInfo> ImportFilterBase;
+
+}
+}
+
+#endif // INCLUDED_WRITERPERFECT_SOURCE_CALC_IMPORTFILTERBASE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerperfect/source/calc/MSWorksCalcImportFilter.cxx b/writerperfect/source/calc/MSWorksCalcImportFilter.cxx
new file mode 100644
index 0000000..1c38f4c
--- /dev/null
+++ b/writerperfect/source/calc/MSWorksCalcImportFilter.cxx
@@ -0,0 +1,91 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* MSWorksCalcImportFilter: Sets up the filter, and calls DocumentCollector
+ * to do the actual filtering
+ *
+ * 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/.
+ */
+
+#include <com/sun/star/uno/Reference.h>
+#include <cppuhelper/supportsservice.hxx>
+
+#include <libwps/libwps.h>
+
+#include "MSWorksCalcImportFilter.hxx"
+
+using com::sun::star::uno::Sequence;
+using com::sun::star::uno::Reference;
+using com::sun::star::uno::Any;
+using com::sun::star::uno::XInterface;
+using com::sun::star::uno::Exception;
+using com::sun::star::uno::RuntimeException;
+using com::sun::star::uno::XComponentContext;
+
+bool MSWorksCalcImportFilter::doImportDocument( librevenge::RVNGInputStream &rInput, librevenge::RVNGSpreadsheetInterface &rGenerator )
+{
+    return libwps::WPS_OK == libwps::WPSDocument::parse(&rInput, &rGenerator);
+}
+
+bool MSWorksCalcImportFilter::doDetectFormat( librevenge::RVNGInputStream &rInput, OUString &rTypeName )
+{
+    libwps::WPSKind kind = libwps::WPS_TEXT;
+    const libwps::WPSConfidence confidence = libwps::WPSDocument::isFileFormatSupported(&rInput, kind);
+
+    if ((kind == libwps::WPS_SPREADSHEET || kind == libwps::WPS_DATABASE) && (confidence == libwps::WPS_CONFIDENCE_EXCELLENT))
+    {
+        rTypeName = "calc_MS_Works_Document";
+        return true;
+    }
+
+    return false;
+}
+
+void MSWorksCalcImportFilter::doRegisterHandlers( OdsGenerator & )
+{
+}
+
+OUString MSWorksCalcImportFilter_getImplementationName ()
+throw (RuntimeException)
+{
+    return OUString (  "com.sun.star.comp.Calc.MSWorksCalcImportFilter"  );
+}
+
+Sequence< OUString > SAL_CALL MSWorksCalcImportFilter_getSupportedServiceNames(  )
+throw (RuntimeException)
+{
+    Sequence < OUString > aRet(2);
+    OUString *pArray = aRet.getArray();
+    pArray[0] =  "com.sun.star.document.ImportFilter";
+    pArray[1] =  "com.sun.star.document.ExtendedTypeDetection";
+    return aRet;
+}
+#undef SERVICE_NAME2
+#undef SERVICE_NAME1
+
+Reference< XInterface > SAL_CALL MSWorksCalcImportFilter_createInstance( const Reference< XComponentContext > & rContext)
+throw( Exception )
+{
+    return (cppu::OWeakObject *) new MSWorksCalcImportFilter( rContext );
+}
+
+// XServiceInfo
+OUString SAL_CALL MSWorksCalcImportFilter::getImplementationName(  )
+throw (RuntimeException, std::exception)
+{
+    return MSWorksCalcImportFilter_getImplementationName();
+}
+sal_Bool SAL_CALL MSWorksCalcImportFilter::supportsService( const OUString &rServiceName )
+throw (RuntimeException, std::exception)
+{
+    return cppu::supportsService( this, rServiceName );
+}
+Sequence< OUString > SAL_CALL MSWorksCalcImportFilter::getSupportedServiceNames(  )
+throw (RuntimeException, std::exception)
+{
+    return MSWorksCalcImportFilter_getSupportedServiceNames();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerperfect/source/calc/MSWorksCalcImportFilter.hxx b/writerperfect/source/calc/MSWorksCalcImportFilter.hxx
new file mode 100644
index 0000000..2487c50
--- /dev/null
+++ b/writerperfect/source/calc/MSWorksCalcImportFilter.hxx
@@ -0,0 +1,53 @@
+/* -*- 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/.
+ */
+
+#ifndef _MSWORKSCALCIMPORTFILTER_HXX
+#define _MSWORKSCALCIMPORTFILTER_HXX
+
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+
+#include "ImportFilterBase.hxx"
+
+/* This component will be instantiated for both import or export. Whether it calls
+ * setSourceDocument or setTargetDocument determines which Impl function the filter
+ * member calls */
+class MSWorksCalcImportFilter : public writerperfect::calc::ImportFilterBase
+{
+public:
+    MSWorksCalcImportFilter( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &rxContext )
+        : writerperfect::calc::ImportFilterBase( rxContext ) {}
+
+    // XServiceInfo
+    virtual OUString SAL_CALL getImplementationName(  )
+    throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
+    virtual sal_Bool SAL_CALL supportsService( const OUString &ServiceName )
+    throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
+    virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames(  )
+    throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
+
+private:
+    virtual bool doDetectFormat( librevenge::RVNGInputStream &rInput, OUString &rTypeName ) SAL_OVERRIDE;
+    virtual bool doImportDocument( librevenge::RVNGInputStream &rInput, librevenge::RVNGSpreadsheetInterface &rGenerator ) SAL_OVERRIDE;
+    virtual void doRegisterHandlers( OdsGenerator &rGenerator ) SAL_OVERRIDE;
+};
+
+OUString MSWorksCalcImportFilter_getImplementationName()
+throw ( ::com::sun::star::uno::RuntimeException );
+
+::com::sun::star::uno::Sequence< OUString > SAL_CALL MSWorksCalcImportFilter_getSupportedServiceNames(  )
+throw ( ::com::sun::star::uno::RuntimeException );
+
+::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+SAL_CALL MSWorksCalcImportFilter_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & rContext)
+throw ( ::com::sun::star::uno::Exception );
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerperfect/source/calc/wpftcalc.component b/writerperfect/source/calc/wpftcalc.component
new file mode 100644
index 0000000..c2def1e
--- /dev/null
+++ b/writerperfect/source/calc/wpftcalc.component
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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/.
+ *
+-->
+<component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@"
+    prefix="wpftcalc" xmlns="http://openoffice.org/2010/uno-components">
+  <implementation name="com.sun.star.comp.Calc.MSWorksCalcImportFilter">
+    <service name="com.sun.star.document.ImportFilter"/>
+    <service name="com.sun.star.document.ExtendedTypeDetection"/>
+  </implementation>
+</component>
diff --git a/writerperfect/source/calc/wpftcalc_genericfilter.cxx b/writerperfect/source/calc/wpftcalc_genericfilter.cxx
new file mode 100644
index 0000000..eecd0b0
--- /dev/null
+++ b/writerperfect/source/calc/wpftcalc_genericfilter.cxx
@@ -0,0 +1,51 @@
+/* -*- 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 .
+ */
+
+/* genericfilter: mostly generic code for registering the filter */
+
+/* "This product is not manufactured, approved, or supported by
+ * Corel Corporation or Corel Corporation Limited."
+ */
+
+#include "sal/config.h"
+
+#include "cppuhelper/factory.hxx"
+#include "cppuhelper/implementationentry.hxx"
+#include "sal/types.h"
+
+#include "MSWorksCalcImportFilter.hxx"
+
+namespace {
+
+static cppu::ImplementationEntry const services[] = {
+    { &MSWorksCalcImportFilter_createInstance, &MSWorksCalcImportFilter_getImplementationName,
+      &MSWorksCalcImportFilter_getSupportedServiceNames,
+      &cppu::createSingleComponentFactory, 0, 0 },
+    { 0, 0, 0, 0, 0, 0 } };
+
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL wpftcalc_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 243e6a98d80ed896686b4486b4e675ffb2cc1f59
Author: David Tardon <dtardon at redhat.com>
Date:   Thu May 29 15:10:33 2014 +0200

    use the right XML import service
    
    Change-Id: I45637984f02e3363812ff8c9f0cbd3464786f4de

diff --git a/writerperfect/source/impress/KeynoteImportFilter.cxx b/writerperfect/source/impress/KeynoteImportFilter.cxx
index 236e5d9..5edbfa9 100644
--- a/writerperfect/source/impress/KeynoteImportFilter.cxx
+++ b/writerperfect/source/impress/KeynoteImportFilter.cxx
@@ -133,7 +133,7 @@ throw (RuntimeException, std::exception)
     // An XML import service: what we push sax messages to..
     Reference < XDocumentHandler > xInternalHandler(
         mxContext->getServiceManager()->createInstanceWithContext(
-            "com.sun.star.comp.Draw.XMLOasisImporter", mxContext),
+            "com.sun.star.comp.Impress.XMLOasisImporter", mxContext),
         css::uno::UNO_QUERY_THROW);
 
     // The XImporter sets up an empty target document for XDocumentHandler to write to..


More information about the Libreoffice-commits mailing list