summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFridrich Štrba <fridrich.strba@bluewin.ch>2012-05-24 11:59:16 +0200
committerFridrich Štrba <fridrich.strba@bluewin.ch>2012-06-05 14:04:07 +0200
commitdc4b91d310b3b4c9b826345df5babc33cad46ba3 (patch)
tree700c545e7e576558b940eb26d181893a86266767
parent4190e9351e69730f0097e6cdf4dad2fafa10577e (diff)
Adding Microsoft Publisher Import filter
Change-Id: Iec9c9c5419a40e7ad64af057f1bbb426ca3163b0
-rw-r--r--Makefile.top2
-rw-r--r--RepositoryExternal.mk27
-rw-r--r--config_host.mk.in3
-rw-r--r--configure.in25
-rw-r--r--filter/Configuration_filter.mk2
-rw-r--r--filter/source/config/fragments/filters/PublisherDocument.xcu13
-rw-r--r--filter/source/config/fragments/types/draw_Publisher_Document.xcu12
-rw-r--r--libmspub/README1
-rw-r--r--libmspub/makefile.mk72
-rw-r--r--libmspub/prj/build.lst3
-rw-r--r--libmspub/prj/d.lst6
-rw-r--r--libmspub/prj/dmake0
-rw-r--r--ooo.lst.in1
-rw-r--r--tail_build/prj/build.lst2
-rw-r--r--writerperfect/Library_wpftdraw.mk2
-rw-r--r--writerperfect/Module_writerperfect.mk2
-rw-r--r--writerperfect/prj/build.lst2
-rw-r--r--writerperfect/source/draw/MSPUBImportFilter.cxx275
-rw-r--r--writerperfect/source/draw/MSPUBImportFilter.hxx111
-rw-r--r--writerperfect/source/draw/wpftdraw_genericfilter.cxx5
-rw-r--r--writerperfect/util/wpftdraw.component4
21 files changed, 568 insertions, 2 deletions
diff --git a/Makefile.top b/Makefile.top
index 7362bbcd306c..a560236443a6 100644
--- a/Makefile.top
+++ b/Makefile.top
@@ -198,6 +198,7 @@ libcmis\
libcroco\
libexttextcat\
libgsf\
+libmspub\
libpng\
librsvg\
libvisio\
@@ -465,6 +466,7 @@ findunusedcode:
| grep -v ^jvmaccess:: \
| grep -v ^libcdr:: \
| grep -v ^libcmis:: \
+ | grep -v ^libmspub:: \
| grep -v ^libvisio:: \
| grep -v ^libwpg:: \
| grep -v ^libwps_tools_win:: \
diff --git a/RepositoryExternal.mk b/RepositoryExternal.mk
index 57b72498172c..613cf39622bf 100644
--- a/RepositoryExternal.mk
+++ b/RepositoryExternal.mk
@@ -809,6 +809,33 @@ endef
endif # SYSTEM_LIBCDR
+ifeq ($(SYSTEM_LIBMSPUB),YES)
+
+define gb_LinkTarget__use_mspub
+$(call gb_LinkTarget_set_include,$(1),\
+ $$(INCLUDE) \
+ $(MSPUB_CFLAGS) \
+)
+$(call gb_LinkTarget_add_libs,$(1),$(MSPUB_LIBS))
+
+endef
+
+else # !SYSTEM_LIBMSPUB
+
+$(eval $(call gb_Helper_register_static_libraries,PLAINLIBS, \
+ mspublib \
+))
+
+define gb_LinkTarget__use_mspub
+$(call gb_LinkTarget_use_static_libraries,$(1),\
+ mspublib \
+)
+
+endef
+
+endif # SYSTEM_LIBMSPUB
+
+
ifeq ($(SYSTEM_LIBVISIO),YES)
define gb_LinkTarget__use_visio
diff --git a/config_host.mk.in b/config_host.mk.in
index 6d45f5081ecf..76e398c4b034 100644
--- a/config_host.mk.in
+++ b/config_host.mk.in
@@ -362,6 +362,8 @@ export MOZ_INC=@MOZ_INC@
export MOZ_LDAP_CFLAGS=@MOZ_LDAP_CFLAGS@
export MOZ_LIB=@MOZ_LIB@
export MOZ_LIB_XPCOM=@MOZ_LIB_XPCOM@
+export MSPUB_CFLAGS=@MSPUB_CFLAGS@
+export MSPUB_LIBS=@MSPUB_LIBS@
export MYSQL_DEFINES=@MYSQL_DEFINES@
export MYSQL_INC=@MYSQL_INC@
export MYSQL_LIB=@MYSQL_LIB@
@@ -497,6 +499,7 @@ export SYSTEM_LIBCROCO=@SYSTEM_LIBCROCO@
export SYSTEM_LIBEXTTEXTCAT=@SYSTEM_LIBEXTTEXTCAT@
export SYSTEM_LIBEXTTEXTCAT_DATA=@SYSTEM_LIBEXTTEXTCAT_DATA@
export SYSTEM_LIBGSF=@SYSTEM_LIBGSF@
+export SYSTEM_LIBMSPUB=@SYSTEM_LIBMSPUB@
export SYSTEM_LIBPNG=@SYSTEM_LIBPNG@
export SYSTEM_LIBRSVG=@SYSTEM_LIBRSVG@
export SYSTEM_LIBVISIO=@SYSTEM_LIBVISIO@
diff --git a/configure.in b/configure.in
index aa907d08fdad..ec4461d85e1a 100644
--- a/configure.in
+++ b/configure.in
@@ -1215,6 +1215,11 @@ AC_ARG_WITH(system-libcdr,
[Use libcdr already on system.]),,
[with_system_libcdr="$with_system_libs"])
+AC_ARG_WITH(system-libmspub,
+ AS_HELP_STRING([--with-system-libmspub],
+ [Use libmspub already on system.]),,
+ [with_system_libmspub="$with_system_libs"])
+
AC_ARG_WITH(system-libvisio,
AS_HELP_STRING([--with-system-libvisio],
[Use libvisio already on system.]),,
@@ -6247,6 +6252,26 @@ AC_SUBST(CDR_CFLAGS)
AC_SUBST(CDR_LIBS)
dnl ===================================================================
+dnl Check for system libmspub
+dnl ===================================================================
+AC_MSG_CHECKING([which libmspub to use])
+if test "$with_system_libmspub" = "yes"; then
+ AC_MSG_RESULT([external])
+ SYSTEM_LIBMSPUB=YES
+ PKG_CHECK_MODULES( MSPUB, libmspub-0.0 )
+elif test $_os = iOS; then
+ # libmspub depends on libwpd and libwpg and those are LGPL
+ AC_MSG_RESULT([none])
+else
+ AC_MSG_RESULT([internal])
+ SYSTEM_LIBMSPUB=NO
+ BUILD_TYPE="$BUILD_TYPE LIBMSPUB"
+fi
+AC_SUBST(SYSTEM_LIBMSPUB)
+AC_SUBST(MSPUB_CFLAGS)
+AC_SUBST(MSPUB_LIBS)
+
+dnl ===================================================================
dnl Check for system libvisio
dnl ===================================================================
AC_MSG_CHECKING([which libvisio to use])
diff --git a/filter/Configuration_filter.mk b/filter/Configuration_filter.mk
index 95e6a62d01d6..928e7f3c4cb4 100644
--- a/filter/Configuration_filter.mk
+++ b/filter/Configuration_filter.mk
@@ -537,6 +537,7 @@ $(call filter_Configuration_add_types,fcfg_langpack,fcfg_draw_types.xcu,filter/s
draw8_template \
draw_WordPerfect_Graphics \
draw_Visio_Document \
+ draw_Publisher_Document \
draw_CorelDraw_Document \
draw_Corel_Presentation_Exchange \
)
@@ -549,6 +550,7 @@ $(call filter_Configuration_add_filters,fcfg_langpack,fcfg_draw_filters.xcu,filt
draw8_template \
WordPerfectGraphics \
VisioDocument \
+ PublisherDocument \
CorelDrawDocument \
CorelPresentationExchange \
)
diff --git a/filter/source/config/fragments/filters/PublisherDocument.xcu b/filter/source/config/fragments/filters/PublisherDocument.xcu
new file mode 100644
index 000000000000..bb53e9447444
--- /dev/null
+++ b/filter/source/config/fragments/filters/PublisherDocument.xcu
@@ -0,0 +1,13 @@
+ <node oor:name="Publisher Document" oor:op="replace">
+ <prop oor:name="Flags"><value>IMPORT ALIEN USESOPTIONS 3RDPARTYFILTER PREFERRED</value></prop>
+ <prop oor:name="UIComponent"/>
+ <prop oor:name="FilterService"><value>com.sun.star.comp.Draw.MSPUBImportFilter</value></prop>
+ <prop oor:name="UserData"><value></value></prop>
+ <prop oor:name="UIName">
+ <value xml:lang="x-default">Microsoft Publisher 2003</value>
+ </prop>
+ <prop oor:name="FileFormatVersion"><value>0</value></prop>
+ <prop oor:name="Type"><value>draw_Publisher_Document</value></prop>
+ <prop oor:name="TemplateName"/>
+ <prop oor:name="DocumentService"><value>com.sun.star.drawing.DrawingDocument</value></prop>
+ </node>
diff --git a/filter/source/config/fragments/types/draw_Publisher_Document.xcu b/filter/source/config/fragments/types/draw_Publisher_Document.xcu
new file mode 100644
index 000000000000..8a253a39f758
--- /dev/null
+++ b/filter/source/config/fragments/types/draw_Publisher_Document.xcu
@@ -0,0 +1,12 @@
+ <node oor:name="draw_Publisher_Document" oor:op="replace" >
+ <prop oor:name="DetectService"><value>com.sun.star.comp.Draw.MSPUBImportFilter</value></prop>
+ <prop oor:name="URLPattern"/>
+ <prop oor:name="Extensions"><value>pub</value></prop>
+ <prop oor:name="MediaType"><value>application/x-mspublisher</value></prop>
+ <prop oor:name="Preferred"><value>true</value></prop>
+ <prop oor:name="PreferredFilter"><value>Publisher Document</value></prop>
+ <prop oor:name="UIName">
+ <value>Microsoft Publisher 2003</value>
+ </prop>
+ <prop oor:name="ClipboardFormat"/>
+ </node>
diff --git a/libmspub/README b/libmspub/README
new file mode 100644
index 000000000000..6d2765a1e7f2
--- /dev/null
+++ b/libmspub/README
@@ -0,0 +1 @@
+Library parsing the Microsoft Publisher documents.
diff --git a/libmspub/makefile.mk b/libmspub/makefile.mk
new file mode 100644
index 000000000000..66dbe016d805
--- /dev/null
+++ b/libmspub/makefile.mk
@@ -0,0 +1,72 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=.
+
+PRJNAME=mspub
+TARGET=mspub
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+
+.IF "$(SYSTEM_LIBMSPUB)" == "YES"
+@all:
+ @echo "Using system libmspub..."
+.ENDIF
+
+# libcdr depends on the libwpd, libwpg and zlib
+.IF "$(SYSTEM_LIBWPD)" == "YES"
+INCPRE+=$(WPD_CFLAGS)
+.ELSE
+INCPRE+=$(SOLARVER)$/$(INPATH)$/inc$/libwpd
+INCPRE+=$(SOLARVER)$/$(INPATH)$/inc$/libwpd-stream
+.ENDIF
+.IF "$(SYSTEM_LIBWPG)" == "YES"
+INCPRE+=$(WPG_CFLAGS)
+.ELSE
+INCPRE+=$(SOLARVER)$/$(INPATH)$/inc$/libwpg
+.ENDIF
+.IF "$(SYSTEM_ZLIB)" == "YES"
+INCPRE+=$(ZLIB_CFLAGS)
+.ELSE
+INCPRE+=$(SOLARVER)$/$(INPATH)$/inc$/zlib
+.ENDIF
+
+TARFILE_NAME=libmspub-0.0.0
+TARFILE_MD5=fb1f3777d6562b7ba8c09ac1cfc329e6
+
+BUILD_ACTION=dmake $(MFLAGS) $(CALLMACROS)
+BUILD_DIR=src$/lib
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : set_ext.mk
+.INCLUDE : target.mk
+.INCLUDE : tg_ext.mk
diff --git a/libmspub/prj/build.lst b/libmspub/prj/build.lst
new file mode 100644
index 000000000000..597c5740b50c
--- /dev/null
+++ b/libmspub/prj/build.lst
@@ -0,0 +1,3 @@
+mspub libmspub : LIBWPD:libwpd LIBWPG:libwpg ZLIB:zlib BOOST:boost soltools NULL
+mspub libmspub usr1 - all mspub_mkout NULL
+mspub libmspub nmake - all mspub_libmspub NULL
diff --git a/libmspub/prj/d.lst b/libmspub/prj/d.lst
new file mode 100644
index 000000000000..3a8654ef36ef
--- /dev/null
+++ b/libmspub/prj/d.lst
@@ -0,0 +1,6 @@
+mkdir: %_DEST%\inc\libmspub
+..\%__SRC%\misc\build\libmspub*\src\lib\libmspub.h %_DEST%\inc\libmspub
+..\%__SRC%\misc\build\libmspub*\src\lib\MSPUBDocument.h %_DEST%\inc\libmspub\
+..\%__SRC%\misc\build\libmspub*\src\lib\MSPUBStringVector.h %_DEST%\inc\libmspub\
+..\%__SRC%\lib\*.a %_DEST%\lib\*.a
+..\%__SRC%\slb\*.lib %_DEST%\lib\*.lib
diff --git a/libmspub/prj/dmake b/libmspub/prj/dmake
new file mode 100644
index 000000000000..e69de29bb2d1
--- /dev/null
+++ b/libmspub/prj/dmake
diff --git a/ooo.lst.in b/ooo.lst.in
index a49e66c3211c..2d6e570fb2ad 100644
--- a/ooo.lst.in
+++ b/ooo.lst.in
@@ -91,6 +91,7 @@ e7a384790b13c29113e22e596ade9687-LinLibertineG-20120116.zip
ce31ac7b92cb5e66459f67213bbb6168-libcmis-0.2.2.tar.gz
c216ded0275129ccfef44fbc236ac16a-libcdr-0.0.7.tar.bz2
327348d67c979c88c2dec59a23a17d85-lcms2-2.3.tar.gz
+fb1f3777d6562b7ba8c09ac1cfc329e6-libmspub-0.0.0.tar.bz2
@GOOGLE_DOCS_EXTENSION_PACK@
@FREETYPE_TARBALL@
@FONTCONFIG_TARBALL@
diff --git a/tail_build/prj/build.lst b/tail_build/prj/build.lst
index c96ae744f0e6..2222f7ee07cc 100644
--- a/tail_build/prj/build.lst
+++ b/tail_build/prj/build.lst
@@ -1,2 +1,2 @@
-tb tail_build : AFMS:afms APACHE_COMMONS:apache-commons BSH:beanshell BERKELEYDB:berkeleydb BOOST:boost CAIRO:cairo CPPUNIT:cppunit DESKTOP:codemaker CURL:curl EXPAT:expat FONTCONFIG:fontconfig FREETYPE:freetype GRAPHITE:graphite HSQLDB:hsqldb HUNSPELL:hunspell HYPHEN:hyphen ICU:icu DESKTOP:l10ntools JFREEREPORT:jfreereport JPEG:jpeg LCMS2:lcms2 LIBCDR:libcdr LIBCMIS:libcmis LIBEXTTEXTCAT:libexttextcat LIBXML2:libxml2 LIBXMLSEC:libxmlsec LIBXSLT:libxslt LIBWPG:libwpg LIBWPS:libwps LIBWPD:libwpd LIBVISIO:libvisio LPSOLVE:lpsolve MDDS:mdds MOZ:moz MYTHES:mythes NEON:neon NSS:nss OPENSSL:openssl POSTGRESQL:postgresql PYTHON:python REDLAND:redland SAXON:saxon DESKTOP:setup_native TRANSLATIONS:translations VIGRA:vigra XPDF:xpdf ZLIB:zlib bridges cli_ure comphelper cppu cppuhelper external jurt jvmaccess jvmfwk offapi officecfg DESKTOP:rdbmaker readlicense_oo remotebridges RHINO:rhino ridljar sal salhelper solenv soltools stoc sysui ucbhelper udkapi xmlreader xsltml NULL
+tb tail_build : AFMS:afms APACHE_COMMONS:apache-commons BSH:beanshell BERKELEYDB:berkeleydb BOOST:boost CAIRO:cairo CPPUNIT:cppunit DESKTOP:codemaker CURL:curl EXPAT:expat FONTCONFIG:fontconfig FREETYPE:freetype GRAPHITE:graphite HSQLDB:hsqldb HUNSPELL:hunspell HYPHEN:hyphen ICU:icu DESKTOP:l10ntools JFREEREPORT:jfreereport JPEG:jpeg LCMS2:lcms2 LIBCDR:libcdr LIBCMIS:libcmis LIBEXTTEXTCAT:libexttextcat LIBMSPUB:libmspub LIBXML2:libxml2 LIBXMLSEC:libxmlsec LIBXSLT:libxslt LIBWPG:libwpg LIBWPS:libwps LIBWPD:libwpd LIBVISIO:libvisio LPSOLVE:lpsolve MDDS:mdds MOZ:moz MYTHES:mythes NEON:neon NSS:nss OPENSSL:openssl POSTGRESQL:postgresql PYTHON:python REDLAND:redland SAXON:saxon DESKTOP:setup_native TRANSLATIONS:translations VIGRA:vigra XPDF:xpdf ZLIB:zlib bridges cli_ure comphelper cppu cppuhelper external icc jurt jvmaccess jvmfwk offapi officecfg DESKTOP:rdbmaker readlicense_oo remotebridges RHINO:rhino ridljar sal salhelper solenv soltools stoc sysui ucbhelper udkapi xmlreader xsltml NULL
tb tail_build\prj nmake - all tb_prj NULL
diff --git a/writerperfect/Library_wpftdraw.mk b/writerperfect/Library_wpftdraw.mk
index 15c1492e7b69..bd792f759455 100644
--- a/writerperfect/Library_wpftdraw.mk
+++ b/writerperfect/Library_wpftdraw.mk
@@ -61,6 +61,7 @@ $(eval $(call gb_Library_use_externals,wpftdraw,\
wpg \
visio \
cdr \
+ mspub \
lcms2 \
zlib \
))
@@ -68,6 +69,7 @@ $(eval $(call gb_Library_use_externals,wpftdraw,\
$(eval $(call gb_Library_add_exception_objects,wpftdraw,\
writerperfect/source/draw/CDRImportFilter \
writerperfect/source/draw/CMXImportFilter \
+ writerperfect/source/draw/MSPUBImportFilter \
writerperfect/source/draw/VisioImportFilter \
writerperfect/source/draw/WPGImportFilter \
writerperfect/source/draw/wpftdraw_genericfilter \
diff --git a/writerperfect/Module_writerperfect.mk b/writerperfect/Module_writerperfect.mk
index 0e1bee0f2188..deb006836ac5 100644
--- a/writerperfect/Module_writerperfect.mk
+++ b/writerperfect/Module_writerperfect.mk
@@ -40,6 +40,7 @@ ifneq (,$(filter YES,$(SYSTEM_LIBWPD))$(filter LIBWPD,$(BUILD_TYPE)))
ifneq (,$(filter YES,$(SYSTEM_LIBWPG))$(filter LIBWPG,$(BUILD_TYPE)))
ifneq (,$(filter YES,$(SYSTEM_LIBVISIO))$(filter LIBVISIO,$(BUILD_TYPE)))
ifneq (,$(filter YES,$(SYSTEM_LIBCDR))$(filter LIBCDR,$(BUILD_TYPE)))
+ifneq (,$(filter YES,$(SYSTEM_LIBMSPUB))$(filter LIBMSPUB,$(BUILD_TYPE)))
$(eval $(call gb_Module_add_targets,writerperfect,\
Library_wpftdraw \
))
@@ -47,6 +48,7 @@ endif
endif
endif
endif
+endif
ifneq (,$(filter YES,$(SYSTEM_LIBWPD))$(filter LIBWPD,$(BUILD_TYPE)))
ifneq (,$(filter YES,$(SYSTEM_LIBWPG))$(filter LIBWPG,$(BUILD_TYPE)))
diff --git a/writerperfect/prj/build.lst b/writerperfect/prj/build.lst
index 22a822ebfedf..e70c3e74f84a 100644
--- a/writerperfect/prj/build.lst
+++ b/writerperfect/prj/build.lst
@@ -1,3 +1,3 @@
-wp writerperfect : LIBWPG:libwpg LIBWPS:libwps LIBWPD:libwpd LIBVISIO:libvisio LIBCDR:libcdr LCMS2:lcms2 ZLIB:zlib sot comphelper xmloff svtools sfx2 LIBXSLT:libxslt NULL
+wp writerperfect : LIBWPG:libwpg LIBWPS:libwps LIBWPD:libwpd LIBVISIO:libvisio LIBCDR:libcdr LIBMSPUB:libmspub LCMS2:lcms2 ZLIB:zlib sot comphelper xmloff svtools sfx2 LIBXSLT:libxslt NULL
wp writerperfect usr1 - all wp_mkout NULL
wp writerperfect\prj nmake - all wp_prj NULL
diff --git a/writerperfect/source/draw/MSPUBImportFilter.cxx b/writerperfect/source/draw/MSPUBImportFilter.cxx
new file mode 100644
index 000000000000..7a762d2b2794
--- /dev/null
+++ b/writerperfect/source/draw/MSPUBImportFilter.cxx
@@ -0,0 +1,275 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* MSPUBImportFilter: Sets up the filter, and calls OdgExporter
+ * to do the actual filtering
+ *
+ * Copyright (C) 2000 by Sun Microsystems, Inc.
+ * Copyright (C) 2002-2004 William Lachance (wlach@interlog.com)
+ * Copyright (C) 2004 Net Integration Technologies (http://www.net-itech.com)
+ * Copyright (C) 2004-2006 Fridrich Strba <fridrich.strba@bluewin.ch>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * Contributor(s): Martin Gallwey (gallwey@sun.com)
+ *
+ */
+
+/* "This product is not manufactured, approved, or supported by
+ * Corel Corporation or Corel Corporation Limited."
+ */
+
+#include <osl/diagnose.h>
+#include <rtl/tencinfo.h>
+
+#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 <comphelper/componentcontext.hxx>
+#include <xmloff/attrlist.hxx>
+
+#include <libmspub/libmspub.h>
+#include "filter/DocumentHandler.hxx"
+#include "filter/OdgGenerator.hxx"
+#include "MSPUBImportFilter.hxx"
+#include "stream/WPXSvStream.h"
+
+#include <iostream>
+
+using namespace ::com::sun::star::uno;
+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 namespace ::rtl;
+using rtl::OString;
+using rtl::OUString;
+using com::sun::star::uno::Sequence;
+using com::sun::star::uno::Reference;
+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::io::XInputStream;
+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;
+
+
+sal_Bool SAL_CALL MSPUBImportFilter::filter( const Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor )
+throw (RuntimeException)
+{
+#ifdef DEBUG
+ std::cerr << "MSPUBImportFilter::filter" << std::endl;
+#endif
+ sal_Int32 nLength = aDescriptor.getLength();
+ const PropertyValue *pValue = aDescriptor.getConstArray();
+ OUString sURL;
+ Reference < XInputStream > xInputStream;
+ for ( sal_Int32 i = 0 ; i < nLength; i++)
+ {
+ if ( pValue[i].Name == "InputStream" )
+ pValue[i].Value >>= xInputStream;
+ else if ( pValue[i].Name == "URL" )
+ pValue[i].Value >>= sURL;
+ }
+ if ( !xInputStream.is() )
+ {
+ OSL_ASSERT( 0 );
+ return sal_False;
+ }
+ OString sFileName;
+ sFileName = OUStringToOString(sURL, RTL_TEXTENCODING_INFO_ASCII);
+
+ // An XML import service: what we push sax messages to..
+ OUString sXMLImportService ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Draw.XMLOasisImporter" ) );
+ 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);
+ 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 );
+
+ OdgGenerator exporter(&xHandler, ODF_FLAT_XML);
+ bool tmpParseResult = libmspub::MSPUBDocument::parse(&input, &exporter);
+ return tmpParseResult;
+}
+
+void SAL_CALL MSPUBImportFilter::cancel( )
+throw (RuntimeException)
+{
+#ifdef DEBUG
+ std::cerr << "MSPUBImportFilter::cancel" << std::endl;
+#endif
+}
+
+// XImporter
+void SAL_CALL MSPUBImportFilter::setTargetDocument( const Reference< ::com::sun::star::lang::XComponent >& xDoc )
+throw (::com::sun::star::lang::IllegalArgumentException, RuntimeException)
+{
+#ifdef DEBUG
+ std::cerr << "MSPUBImportFilter::setTargetDocument" << std::endl;
+#endif
+ mxDoc = xDoc;
+}
+
+// XExtendedFilterDetection
+OUString SAL_CALL MSPUBImportFilter::detect( com::sun::star::uno::Sequence< PropertyValue >& Descriptor )
+throw( com::sun::star::uno::RuntimeException )
+{
+#ifdef DEBUG
+ std::cerr << "MSPUBImportFilter::detect" << std::endl;
+#endif
+ 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;
+ }
+
+ WPXSvInputStream input( xInputStream );
+
+ if (libmspub::MSPUBDocument::isSupported(&input))
+ sTypeName = OUString( RTL_CONSTASCII_USTRINGPARAM ( "draw_Publisher_Document" ) );
+
+ if (sTypeName.getLength())
+ {
+ if ( location == Descriptor.getLength() )
+ {
+ Descriptor.realloc(nLength+1);
+ Descriptor[location].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TypeName"));
+ }
+
+ Descriptor[location].Value <<=sTypeName;
+ }
+ return sTypeName;
+}
+
+
+// XInitialization
+void SAL_CALL MSPUBImportFilter::initialize( const Sequence< Any >& aArguments )
+throw (Exception, RuntimeException)
+{
+#ifdef DEBUG
+ std::cerr << "MSPUBImportFilter::initialize" << std::endl;
+#endif
+ 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;
+ }
+ }
+ }
+}
+OUString MSPUBImportFilter_getImplementationName ()
+throw (RuntimeException)
+{
+#ifdef DEBUG
+ std::cerr << "MSPUBImportFilter_getImplementationName" << std::endl;
+#endif
+ return OUString ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Draw.MSPUBImportFilter" ) );
+}
+
+#define SERVICE_NAME1 "com.sun.star.document.ImportFilter"
+#define SERVICE_NAME2 "com.sun.star.document.ExtendedTypeDetection"
+sal_Bool SAL_CALL MSPUBImportFilter_supportsService( const OUString &ServiceName )
+throw (RuntimeException)
+{
+#ifdef DEBUG
+ std::cerr << "MSPUBImportFilter_supportsService" << std::endl;
+#endif
+ return ( ServiceName == SERVICE_NAME1 || ServiceName == SERVICE_NAME2 );
+}
+Sequence< OUString > SAL_CALL MSPUBImportFilter_getSupportedServiceNames( )
+throw (RuntimeException)
+{
+#ifdef DEBUG
+ std::cerr << "MSPUBImportFilter_getSupportedServiceNames" << std::endl;
+#endif
+ Sequence < OUString > aRet(2);
+ OUString *pArray = aRet.getArray();
+ pArray[0] = OUString ( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME1 ) );
+ pArray[1] = OUString ( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME2 ) );
+ return aRet;
+}
+#undef SERVICE_NAME2
+#undef SERVICE_NAME1
+
+Reference< XInterface > SAL_CALL MSPUBImportFilter_createInstance( const Reference< XComponentContext > & rContext)
+throw( Exception )
+{
+#ifdef DEBUG
+ std::cerr << "MSPUBImportFilter_createInstance" << std::endl;
+#endif
+ return (cppu::OWeakObject *) new MSPUBImportFilter( rContext );
+}
+
+// XServiceInfo
+OUString SAL_CALL MSPUBImportFilter::getImplementationName( )
+throw (RuntimeException)
+{
+#ifdef DEBUG
+ std::cerr << "MSPUBImportFilter::getImplementationName" << std::endl;
+#endif
+ return MSPUBImportFilter_getImplementationName();
+}
+sal_Bool SAL_CALL MSPUBImportFilter::supportsService( const OUString &rServiceName )
+throw (RuntimeException)
+{
+#ifdef DEBUG
+ std::cerr << "MSPUBImportFilter::supportsService" << std::endl;
+#endif
+ return MSPUBImportFilter_supportsService( rServiceName );
+}
+Sequence< OUString > SAL_CALL MSPUBImportFilter::getSupportedServiceNames( )
+throw (RuntimeException)
+{
+#ifdef DEBUG
+ std::cerr << "MSPUBImportFilter::getSupportedServiceNames" << std::endl;
+#endif
+ return MSPUBImportFilter_getSupportedServiceNames();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerperfect/source/draw/MSPUBImportFilter.hxx b/writerperfect/source/draw/MSPUBImportFilter.hxx
new file mode 100644
index 000000000000..ed459a146893
--- /dev/null
+++ b/writerperfect/source/draw/MSPUBImportFilter.hxx
@@ -0,0 +1,111 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Copyright (C) 2000 by Sun Microsystems, Inc.
+ * Copyright (C) 2002-2004 William Lachance (wlach@interlog.com)
+ * Copyright (C) 2004 Net Integration Technologies (http://www.net-itech.com)
+ * Copyright (C) 2004 Fridrich Strba <fridrich.strba@bluewin.ch>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * Contributor(s): Martin Gallwey (gallwey@sun.com)
+ *
+ */
+
+/* "This product is not manufactured, approved, or supported by
+ * Corel Corporation or Corel Corporation Limited."
+ */
+#ifndef _MSPUBIMPORTFILTER_HXX
+#define _MSPUBIMPORTFILTER_HXX
+
+#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 <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
+#include <cppuhelper/implbase5.hxx>
+
+#include <stdio.h>
+
+/* 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 MSPUBImportFilter : public cppu::WeakImplHelper5
+ <
+ com::sun::star::document::XFilter,
+ com::sun::star::document::XImporter,
+ com::sun::star::document::XExtendedFilterDetection,
+ com::sun::star::lang::XInitialization,
+ com::sun::star::lang::XServiceInfo
+ >
+{
+protected:
+ // oo.org declares
+ ::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:
+ MSPUBImportFilter( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &rxContext)
+ : mxContext( rxContext ) {}
+ virtual ~MSPUBImportFilter() {}
+
+ // 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);
+ virtual void SAL_CALL cancel( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ // 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);
+
+ //XExtendedFilterDetection
+ virtual ::rtl::OUString SAL_CALL detect( com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& Descriptor )
+ throw( com::sun::star::uno::RuntimeException );
+
+ // 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);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString &ServiceName )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+};
+
+::rtl::OUString MSPUBImportFilter_getImplementationName()
+throw ( ::com::sun::star::uno::RuntimeException );
+
+sal_Bool SAL_CALL MSPUBImportFilter_supportsService( const ::rtl::OUString &ServiceName )
+throw ( ::com::sun::star::uno::RuntimeException );
+
+::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL MSPUBImportFilter_getSupportedServiceNames( )
+throw ( ::com::sun::star::uno::RuntimeException );
+
+::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+SAL_CALL MSPUBImportFilter_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/draw/wpftdraw_genericfilter.cxx b/writerperfect/source/draw/wpftdraw_genericfilter.cxx
index fdfe1efae827..3a36bcf588f3 100644
--- a/writerperfect/source/draw/wpftdraw_genericfilter.cxx
+++ b/writerperfect/source/draw/wpftdraw_genericfilter.cxx
@@ -32,6 +32,7 @@
#include "CDRImportFilter.hxx"
#include "CMXImportFilter.hxx"
+#include "MSPUBImportFilter.hxx"
#include "VisioImportFilter.hxx"
#include "WPGImportFilter.hxx"
@@ -44,6 +45,10 @@ static cppu::ImplementationEntry const services[] = {
{ &CMXImportFilter_createInstance, &CMXImportFilter_getImplementationName,
&CMXImportFilter_getSupportedServiceNames,
&cppu::createSingleComponentFactory, 0, 0 },
+ { &MSPUBImportFilter_createInstance,
+ &MSPUBImportFilter_getImplementationName,
+ &MSPUBImportFilter_getSupportedServiceNames,
+ &cppu::createSingleComponentFactory, 0, 0 },
{ &VisioImportFilter_createInstance,
&VisioImportFilter_getImplementationName,
&VisioImportFilter_getSupportedServiceNames,
diff --git a/writerperfect/util/wpftdraw.component b/writerperfect/util/wpftdraw.component
index a8a262467231..c0cb8f9fe92a 100644
--- a/writerperfect/util/wpftdraw.component
+++ b/writerperfect/util/wpftdraw.component
@@ -9,6 +9,10 @@
<service name="com.sun.star.document.ImportFilter"/>
<service name="com.sun.star.document.ExtendedTypeDetection"/>
</implementation>
+ <implementation name="com.sun.star.comp.Draw.MSPUBImportFilter">
+ <service name="com.sun.star.document.ImportFilter"/>
+ <service name="com.sun.star.document.ExtendedTypeDetection"/>
+ </implementation>
<implementation name="com.sun.star.comp.Draw.VisioImportFilter">
<service name="com.sun.star.document.ImportFilter"/>
<service name="com.sun.star.document.ExtendedTypeDetection"/>