summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFridrich Štrba <fridrich.strba@bluewin.ch>2014-01-13 17:01:32 +0100
committerTor Lillqvist <tml@collabora.com>2014-01-16 19:36:51 +0000
commit6c5709cc3cb54d8f3b2c6428fb8528c2f1799de1 (patch)
tree37b38b720111b27c97435b5f5cfba715cc235257
parent14d1995e2f26af5362be97059674eb01bd946455 (diff)
AbiWord Import filter
Reviewed-on: https://gerrit.libreoffice.org/7411 Reviewed-by: Fridrich Strba <fridrich@documentfoundation.org> Tested-by: Fridrich Strba <fridrich@documentfoundation.org> (cherry picked from commit 10eaaac020e32f0bbb3869cecee94df0955b6a3b) Conflicts: external/Module_external.mk writerperfect/util/wpftwriter.component Change-Id: I90dc115044e5f81fa3a2b105d30d7d39e438b086 Fix a silly with ABW footnotes/endnotes Change-Id: I026f9c664ff7dec51e511ad439ab563d2cc0c201 (cherry picked from commit 766f718ebb4deda1a294cc1cfe137a75dfb0f6f8) Fix ABW list shapes Change-Id: Ibbbfddf10677e8c5b654cee9c5fda1603a298a67 (cherry picked from commit f8bf3e3cd4b55099a1427d611af06a45460034e7) Fix ABW embedded images Change-Id: Ifd33ea9c1f91865d5ae5175eefa9b65107404bf0 (cherry picked from commit 7c3ca696543d0e9d6771d53f386086086d8b8643) Uploading libabw-0.0.1 (support of zabw files too) Change-Id: Ie04cae9b9a362cb43b671fe8986545865822a953 (cherry picked from commit 838c8889491b7e5b08f681b7f85740784c0c1a3b) (cherry picked from commit 1c0bf579b5051e18dfaeeef5a9f64548bf63e9e1) Reviewed-on: https://gerrit.libreoffice.org/7479 Reviewed-by: David Tardon <dtardon@redhat.com> Reviewed-by: Thorsten Behrens <thb@documentfoundation.org> Tested-by: Thorsten Behrens <thb@documentfoundation.org> Reviewed-by: Tor Lillqvist <tml@collabora.com> Tested-by: Tor Lillqvist <tml@collabora.com>
-rw-r--r--Makefile.fetch1
-rw-r--r--RepositoryExternal.mk33
-rw-r--r--config_host.mk.in3
-rw-r--r--configure.ac5
-rw-r--r--download.lst2
-rw-r--r--external/Module_external.mk1
-rw-r--r--external/libabw/ExternalProject_libabw.mk44
-rw-r--r--external/libabw/Makefile7
-rw-r--r--external/libabw/Module_libabw.mk17
-rw-r--r--external/libabw/README3
-rw-r--r--external/libabw/UnpackedTarball_libabw.mk18
-rw-r--r--external/libabw/libabw-0.0.1-inttypes.patch.136
-rw-r--r--filter/Configuration_filter.mk2
-rw-r--r--filter/source/config/fragments/filters/AbiWord.xcu30
-rw-r--r--filter/source/config/fragments/types/writer_AbiWord_Document.xcu29
-rw-r--r--writerperfect/Library_wpftwriter.mk2
-rw-r--r--writerperfect/Module_writerperfect.mk28
-rw-r--r--writerperfect/source/writer/AbiWordImportFilter.cxx223
-rw-r--r--writerperfect/source/writer/AbiWordImportFilter.hxx88
-rw-r--r--writerperfect/source/writer/wpftwriter_genericfilter.cxx4
-rw-r--r--writerperfect/util/wpftwriter.component4
21 files changed, 552 insertions, 28 deletions
diff --git a/Makefile.fetch b/Makefile.fetch
index ae76cf73701c..530ee0fc7305 100644
--- a/Makefile.fetch
+++ b/Makefile.fetch
@@ -75,6 +75,7 @@ $(WORKDIR)/download: $(BUILDDIR)/config_host.mk $(SRCDIR)/download.lst $(SRCDIR)
@date >> $(fetch_LOGFILE)
$(foreach item, \
$(call fetch_Optional,LIBATOMIC_OPS,LIBATOMIC_OPS_TARBALL) \
+ $(call fetch_Optional,ABW,ABW_TARBALL) \
$(call fetch_Optional,CDR,CDR_TARBALL) \
$(call fetch_Optional,EBOOK,EBOOK_TARBALL) \
$(call fetch_Optional,FREEHAND,FREEHAND_TARBALL) \
diff --git a/RepositoryExternal.mk b/RepositoryExternal.mk
index 689b5f595b73..4a4ce6e80b24 100644
--- a/RepositoryExternal.mk
+++ b/RepositoryExternal.mk
@@ -1535,6 +1535,39 @@ endef
endif # SYSTEM_ODFGEN
+ifeq ($(SYSTEM_ABW),YES)
+
+define gb_LinkTarget__use_abw
+$(call gb_LinkTarget_set_include,$(1),\
+ $$(INCLUDE) \
+ $(ABW_CFLAGS) \
+)
+$(call gb_LinkTarget_add_libs,$(1),$(ABW_LIBS))
+
+endef
+gb_ExternalProject__use_abw :=
+
+else # !SYSTEM_ABW
+
+define gb_LinkTarget__use_abw
+$(call gb_LinkTarget_set_include,$(1),\
+ -I$(call gb_UnpackedTarball_get_dir,libabw)/inc \
+ $$(INCLUDE) \
+)
+$(call gb_LinkTarget_add_libs,$(1),\
+ $(call gb_UnpackedTarball_get_dir,libabw)/src/lib/.libs/libabw-0.0$(gb_StaticLibrary_PLAINEXT) \
+)
+$(call gb_LinkTarget_use_external_project,$(1),libabw)
+
+endef
+define gb_ExternalProject__use_abw
+$(call gb_ExternalProject_use_external_project,$(1),libabw)
+
+endef
+
+endif # SYSTEM_ABW
+
+
ifeq ($(SYSTEM_MSPUB),YES)
define gb_LinkTarget__use_mspub
diff --git a/config_host.mk.in b/config_host.mk.in
index 49977f1833ca..5bc7b1455721 100644
--- a/config_host.mk.in
+++ b/config_host.mk.in
@@ -13,6 +13,8 @@ export SRC_ROOT=@SRC_ROOT@
export BUILDDIR=@BUILDDIR@
@x_AFLAGS@ export AFLAGS=@AFLAGS@
+export ABW_CFLAGS=$(gb_SPACE)@ABW_CFLAGS@
+export ABW_LIBS=$(gb_SPACE)@ABW_LIBS@
export ALLOC=@ALLOC@
export ALL_LANGS=@ALL_LANGS@
export ANDROID_APP_ABI=@ANDROID_APP_ABI@
@@ -481,6 +483,7 @@ export SUNTEMPLATES_FR_PACK=@SUNTEMPLATES_FR_PACK@
export SUNTEMPLATES_HU_PACK=@SUNTEMPLATES_HU_PACK@
export SUNTEMPLATES_IT_PACK=@SUNTEMPLATES_IT_PACK@
export SYSBASE=@SYSBASE@
+export SYSTEM_ABW=@SYSTEM_ABW@
export SYSTEM_APACHE_COMMONS=@SYSTEM_APACHE_COMMONS@
export SYSTEM_BOOST=@SYSTEM_BOOST@
export SYSTEM_BSH=@SYSTEM_BSH@
diff --git a/configure.ac b/configure.ac
index 2094c194045c..706147480dc0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -7815,6 +7815,11 @@ AC_SUBST(FREETYPE_LIBS)
AC_SUBST([SYSTEM_FREETYPE])
dnl ===================================================================
+dnl Check for system libabw
+dnl ===================================================================
+libo_CHECK_SYSTEM_MODULE([libabw],[ABW],[libabw-0.0],["-I${WORKDIR}/UnpackedTarball/libabw/inc"],["-L${WORKDIR}/UnpackedTarball/libabw/src/lib/.libs -labw-0.0"])
+
+dnl ===================================================================
dnl Check for system libwps
dnl ===================================================================
libo_CHECK_SYSTEM_MODULE([libwps],[WPS],[libwps-0.2],["-I${WORKDIR}/UnpackedTarball/libwps/inc"],["-L${WORKDIR}/UnpackedTarball/libwps/src/lib/.libs -lwps-0.2"])
diff --git a/download.lst b/download.lst
index 1cf422496ebd..99e91fd13ae1 100644
--- a/download.lst
+++ b/download.lst
@@ -1,3 +1,5 @@
+ABW_MD5SUM := af3ccc1f1884e68389088d490d596409
+export ABW_TARBALL := libabw-0.0.1.tar.bz2
CDR_MD5SUM := d88f9b94df880d2c05be943b000ca112
export CDR_TARBALL := libcdr-0.0.14.tar.bz2
EBOOK_MD5SUM := 3a62e10c57270718cabfdfc4b7b4e095
diff --git a/external/Module_external.mk b/external/Module_external.mk
index dcd5b0822271..2d64d5297bda 100644
--- a/external/Module_external.mk
+++ b/external/Module_external.mk
@@ -21,6 +21,7 @@ $(eval $(call gb_Module_add_moduledirs,external,\
accessories \
libxmlsec \
np_sdk \
+ $(call gb_Helper_optional,ABW,libabw) \
$(call gb_Helper_optional,AFMS,afms) \
$(call gb_Helper_optional,APACHE_COMMONS,apache-commons) \
$(call gb_Helper_optional,BOOST,boost) \
diff --git a/external/libabw/ExternalProject_libabw.mk b/external/libabw/ExternalProject_libabw.mk
new file mode 100644
index 000000000000..d3b3b9f97caf
--- /dev/null
+++ b/external/libabw/ExternalProject_libabw.mk
@@ -0,0 +1,44 @@
+# -*- 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_ExternalProject_ExternalProject,libabw))
+
+$(eval $(call gb_ExternalProject_use_autoconf,libabw,build))
+
+$(eval $(call gb_ExternalProject_register_targets,libabw,\
+ build \
+))
+
+$(eval $(call gb_ExternalProject_use_externals,libabw,\
+ boost_headers \
+ libxml2 \
+ wpd \
+ zlib \
+))
+
+$(call gb_ExternalProject_get_state_target,libabw,build) :
+ $(call gb_ExternalProject_run,build,\
+ export PKG_CONFIG="" \
+ && ./configure \
+ --with-pic \
+ --enable-static \
+ --disable-shared \
+ --without-docs \
+ --disable-tools \
+ --disable-debug \
+ --disable-werror \
+ CXXFLAGS="$(if $(filter NO,$(SYSTEM_BOOST)),-I$(call gb_UnpackedTarball_get_dir,boost) -I$(BUILDDIR)/config_$(gb_Side),$(BOOST_CPPFLAGS)) \
+ $(if $(filter NO,$(SYSTEM_LIBXML)),-I$(call gb_UnpackedTarball_get_dir,xml2)/include)" \
+ $(if $(filter YES,$(CROSS_COMPILING)),--build=$(BUILD_PLATFORM) --host=$(HOST_PLATFORM)) \
+ && (cd $(EXTERNAL_WORKDIR)/src/lib && \
+ $(if $(VERBOSE)$(verbose),V=1) \
+ $(MAKE)) \
+ )
+
+# vim: set noet sw=4 ts=4:
diff --git a/external/libabw/Makefile b/external/libabw/Makefile
new file mode 100644
index 000000000000..e4968cf85fb6
--- /dev/null
+++ b/external/libabw/Makefile
@@ -0,0 +1,7 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+
+module_directory:=$(dir $(realpath $(firstword $(MAKEFILE_LIST))))
+
+include $(module_directory)/../../solenv/gbuild/partial_build.mk
+
+# vim: set noet sw=4 ts=4:
diff --git a/external/libabw/Module_libabw.mk b/external/libabw/Module_libabw.mk
new file mode 100644
index 000000000000..0961506138cd
--- /dev/null
+++ b/external/libabw/Module_libabw.mk
@@ -0,0 +1,17 @@
+# -*- 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_Module_Module,libabw))
+
+$(eval $(call gb_Module_add_targets,libabw,\
+ ExternalProject_libabw \
+ UnpackedTarball_libabw \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/external/libabw/README b/external/libabw/README
new file mode 100644
index 000000000000..96432f43e923
--- /dev/null
+++ b/external/libabw/README
@@ -0,0 +1,3 @@
+AbiWord file word processor format import library from
+
+I couldn't find an upstream for this library - although I did only try a primitive Google search.
diff --git a/external/libabw/UnpackedTarball_libabw.mk b/external/libabw/UnpackedTarball_libabw.mk
new file mode 100644
index 000000000000..c61f2d55924b
--- /dev/null
+++ b/external/libabw/UnpackedTarball_libabw.mk
@@ -0,0 +1,18 @@
+# -*- 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_UnpackedTarball_UnpackedTarball,libabw))
+
+$(eval $(call gb_UnpackedTarball_set_tarball,libabw,$(ABW_TARBALL)))
+
+$(eval $(call gb_UnpackedTarball_add_patches,libabw,\
+ external/libabw/libabw-0.0.1-inttypes.patch.1 \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/external/libabw/libabw-0.0.1-inttypes.patch.1 b/external/libabw/libabw-0.0.1-inttypes.patch.1
new file mode 100644
index 000000000000..7c136900a694
--- /dev/null
+++ b/external/libabw/libabw-0.0.1-inttypes.patch.1
@@ -0,0 +1,36 @@
+diff --git a/src/lib/ABWStylesCollector.cpp b/src/lib/ABWStylesCollector.cpp
+index e422b6d..beb4cb9 100644
+--- a/src/lib/ABWStylesCollector.cpp
++++ b/src/lib/ABWStylesCollector.cpp
+@@ -49,10 +49,10 @@ enum ABWListType
+ NOT_A_LIST = 0xff
+ };
+
+-static int abw_unichar_to_utf8(uint32_t c, char *outbuf)
++static int abw_unichar_to_utf8(unsigned c, char *outbuf)
+ {
+- uint8_t len = 1;
+- uint8_t first = 0;
++ unsigned char len = 1;
++ unsigned char first = 0;
+
+ if (c < 0x80)
+ {
+@@ -87,7 +87,7 @@ static int abw_unichar_to_utf8(uint32_t c, char *outbuf)
+
+ if (outbuf)
+ {
+- for (uint8_t i = (uint8_t)(len - 1); i > 0; --i)
++ for (unsigned char i = (unsigned char)(len - 1); i > 0; --i)
+ {
+ outbuf[i] = (char)((c & 0x3f) | 0x80);
+ c >>= 6;
+@@ -98,7 +98,7 @@ static int abw_unichar_to_utf8(uint32_t c, char *outbuf)
+ return len;
+ }
+
+-static void appendUCS4(WPXString &str, uint32_t ucs4)
++static void appendUCS4(WPXString &str, unsigned ucs4)
+ {
+ int charLength = abw_unichar_to_utf8(ucs4, 0);
+ char *utf8 = new char[charLength+1];
diff --git a/filter/Configuration_filter.mk b/filter/Configuration_filter.mk
index 347d00c365dc..847db50fd14d 100644
--- a/filter/Configuration_filter.mk
+++ b/filter/Configuration_filter.mk
@@ -346,6 +346,7 @@ $(call filter_Configuration_add_types,fcfg_langpack,fcfg_writer_types.xcu,filter
writer_WriteNow \
writer_WriterPlus \
writer_ZWrite \
+ writer_AbiWord_Document \
writer_T602_Document \
writer_LotusWordPro_Document \
generic_Text \
@@ -405,6 +406,7 @@ $(call filter_Configuration_add_filters,fcfg_langpack,fcfg_writer_filters.xcu,fi
WriteNow \
WriterPlus \
ZWrite \
+ AbiWord \
T602Document \
LotusWordPro \
Text \
diff --git a/filter/source/config/fragments/filters/AbiWord.xcu b/filter/source/config/fragments/filters/AbiWord.xcu
new file mode 100644
index 000000000000..f61ac01e59a8
--- /dev/null
+++ b/filter/source/config/fragments/filters/AbiWord.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="AbiWord" 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.Writer.AbiWordImportFilter</value></prop>
+ <prop oor:name="UserData"><value>ABW</value></prop>
+ <prop oor:name="UIName">
+ <value xml:lang="x-default">AbiWord Document</value>
+ </prop>
+ <prop oor:name="FileFormatVersion"><value>0</value></prop>
+ <prop oor:name="Type"><value>writer_AbiWord_Document</value></prop>
+ <prop oor:name="TemplateName"/>
+ <prop oor:name="DocumentService"><value>com.sun.star.text.TextDocument</value></prop>
+ </node>
diff --git a/filter/source/config/fragments/types/writer_AbiWord_Document.xcu b/filter/source/config/fragments/types/writer_AbiWord_Document.xcu
new file mode 100644
index 000000000000..c16d4bb46329
--- /dev/null
+++ b/filter/source/config/fragments/types/writer_AbiWord_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="writer_AbiWord_Document" oor:op="replace" >
+ <prop oor:name="DetectService"><value>com.sun.star.comp.Writer.AbiWordImportFilter</value></prop>
+ <prop oor:name="URLPattern"/>
+ <prop oor:name="Extensions"><value>abw zabw</value></prop>
+ <prop oor:name="MediaType"><value>application/x-abiword</value></prop>
+ <prop oor:name="Preferred"><value>true</value></prop>
+ <prop oor:name="PreferredFilter"><value>AbiWord</value></prop>
+ <prop oor:name="UIName">
+ <value>Microsoft Works Document</value>
+ </prop>
+ <prop oor:name="ClipboardFormat"/>
+ </node>
diff --git a/writerperfect/Library_wpftwriter.mk b/writerperfect/Library_wpftwriter.mk
index cc69e9d95ec7..cfcdf5da69cd 100644
--- a/writerperfect/Library_wpftwriter.mk
+++ b/writerperfect/Library_wpftwriter.mk
@@ -48,6 +48,7 @@ $(eval $(call gb_Library_use_static_libraries,wpftwriter,\
))
$(eval $(call gb_Library_use_externals,wpftwriter,\
+ abw \
boost_headers \
ebook \
etonyek \
@@ -64,6 +65,7 @@ $(eval $(call gb_Library_use_externals,wpftwriter,\
))
$(eval $(call gb_Library_add_exception_objects,wpftwriter,\
+ writerperfect/source/writer/AbiWordImportFilter \
writerperfect/source/writer/EBookImportFilter \
writerperfect/source/writer/MSWorksImportFilter \
writerperfect/source/writer/MWAWImportFilter \
diff --git a/writerperfect/Module_writerperfect.mk b/writerperfect/Module_writerperfect.mk
index 06115f24873d..0b4979c2b2ae 100644
--- a/writerperfect/Module_writerperfect.mk
+++ b/writerperfect/Module_writerperfect.mk
@@ -19,52 +19,24 @@
$(eval $(call gb_Module_Module,writerperfect))
-ifneq (,$(SYSTEM_WPD))
-ifneq (,$(SYSTEM_WPS))
-ifneq (,$(SYSTEM_ODFGEN))
$(eval $(call gb_Module_add_targets,writerperfect,\
Library_wpftwriter \
))
-endif
-endif
-endif
-ifneq (,$(SYSTEM_WPD))
-ifneq (,$(SYSTEM_WPG))
-ifneq (,$(SYSTEM_VISIO))
-ifneq (,$(SYSTEM_CDR))
-ifneq (,$(SYSTEM_MSPUB))
-ifneq (,$(SYSTEM_FREEHAND))
-ifneq (,$(SYSTEM_ODFGEN))
$(eval $(call gb_Module_add_targets,writerperfect,\
Library_wpftdraw \
))
-endif
-endif
-endif
-endif
-endif
-endif
-endif
$(eval $(call gb_Module_add_targets,writerperfect,\
Library_wpftimpress \
))
-ifneq (,$(SYSTEM_WPD))
-ifneq (,$(SYSTEM_WPG))
-ifneq (,$(SYSTEM_ODFGEN))
$(eval $(call gb_Module_add_targets,writerperfect,\
StaticLibrary_writerperfect \
))
-endif
-endif
-endif
-ifneq (,$(SYSTEM_WPD))
$(eval $(call gb_Module_add_check_targets,writerperfect,\
CppunitTest_writerperfect_stream \
))
-endif
# vim: set noet sw=4 ts=4:
diff --git a/writerperfect/source/writer/AbiWordImportFilter.cxx b/writerperfect/source/writer/AbiWordImportFilter.cxx
new file mode 100644
index 000000000000..5cbefd6aff5d
--- /dev/null
+++ b/writerperfect/source/writer/AbiWordImportFilter.cxx
@@ -0,0 +1,223 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* AbiWordImportFilter: 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 <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 <cppuhelper/supportsservice.hxx>
+
+#include <xmloff/attrlist.hxx>
+#include <ucbhelper/content.hxx>
+
+#include <libabw/libabw.h>
+
+#include <libodfgen/libodfgen.hxx>
+
+#include "common/DocumentHandler.hxx"
+#include "common/WPXSvStream.hxx"
+#include "AbiWordImportFilter.hxx"
+
+#include <iostream>
+
+using namespace ::com::sun::star::uno;
+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::ucb::XCommandEnvironment;
+
+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 AbiWordImportFilter::importImpl( const Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor )
+throw (RuntimeException)
+{
+ SAL_INFO("writerperfect", "AbiWordImportFilter::importImpl");
+
+ 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( 0 );
+ return sal_False;
+ }
+
+ // An XML import service: what we push sax messages to..
+ Reference < XDocumentHandler > xInternalHandler(
+ mxContext->getServiceManager()->createInstanceWithContext(
+ "com.sun.star.comp.Writer.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 Document Handler: abstract class to handle document SAX messages, concrete implementation here
+ // writes to in-memory target doc
+ DocumentHandler xHandler(xInternalHandler);
+
+ WPXSvInputStream input( xInputStream );
+
+ OdtGenerator collector(&xHandler, ODF_FLAT_XML);
+ if (libabw::AbiDocument::parse(&input, &collector))
+ return sal_True;
+ return sal_False;
+}
+
+sal_Bool SAL_CALL AbiWordImportFilter::filter( const Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor )
+throw (RuntimeException)
+{
+ SAL_INFO("writerperfect", "AbiWordImportFilter::filter");
+ return importImpl ( aDescriptor );
+}
+void SAL_CALL AbiWordImportFilter::cancel( )
+throw (RuntimeException)
+{
+ SAL_INFO("writerperfect", "AbiWordImportFilter::cancel");
+}
+
+// XImporter
+void SAL_CALL AbiWordImportFilter::setTargetDocument( const Reference< ::com::sun::star::lang::XComponent >& xDoc )
+throw (::com::sun::star::lang::IllegalArgumentException, RuntimeException)
+{
+ SAL_INFO("writerperfect", "AbiWordImportFilter::getTargetDocument");
+ mxDoc = xDoc;
+}
+
+// XExtendedFilterDetection
+OUString SAL_CALL AbiWordImportFilter::detect( com::sun::star::uno::Sequence< PropertyValue >& Descriptor )
+throw( com::sun::star::uno::RuntimeException )
+{
+ SAL_INFO("writerperfect", "AbiWordImportFilter::detect");
+
+ 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 (libabw::AbiDocument::isFileFormatSupported(&input))
+ sTypeName = "writer_AbiWord_Document";
+
+ if (!sTypeName.isEmpty())
+ {
+ if ( location == nLength )
+ {
+ Descriptor.realloc(nLength+1);
+ Descriptor[location].Name = "TypeName";
+ }
+
+ Descriptor[location].Value <<=sTypeName;
+ }
+
+ return sTypeName;
+}
+
+
+// XInitialization
+void SAL_CALL AbiWordImportFilter::initialize( const Sequence< Any >& aArguments )
+throw (Exception, RuntimeException)
+{
+ SAL_INFO("writerperfect", "AbiWordImportFilter::initialize");
+ 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 AbiWordImportFilter_getImplementationName ()
+throw (RuntimeException)
+{
+ return OUString ( "com.sun.star.comp.Writer.AbiWordImportFilter" );
+}
+
+Sequence< OUString > SAL_CALL AbiWordImportFilter_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 AbiWordImportFilter_createInstance( const Reference< XComponentContext > & rContext)
+throw( Exception )
+{
+ return (cppu::OWeakObject *) new AbiWordImportFilter( rContext );
+}
+
+// XServiceInfo
+OUString SAL_CALL AbiWordImportFilter::getImplementationName( )
+throw (RuntimeException)
+{
+ return AbiWordImportFilter_getImplementationName();
+}
+sal_Bool SAL_CALL AbiWordImportFilter::supportsService( const OUString &rServiceName )
+throw (RuntimeException)
+{
+ return cppu::supportsService( this, rServiceName );
+}
+Sequence< OUString > SAL_CALL AbiWordImportFilter::getSupportedServiceNames( )
+throw (RuntimeException)
+{
+ return AbiWordImportFilter_getSupportedServiceNames();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerperfect/source/writer/AbiWordImportFilter.hxx b/writerperfect/source/writer/AbiWordImportFilter.hxx
new file mode 100644
index 000000000000..dec139276dd2
--- /dev/null
+++ b/writerperfect/source/writer/AbiWordImportFilter.hxx
@@ -0,0 +1,88 @@
+/* -*- 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 _ABIWORDIMPORTFILTER_HXX
+#define _ABIWORDIMPORTFILTER_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>
+
+/* 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 AbiWordImportFilter : 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:
+ ::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;
+
+ sal_Bool SAL_CALL importImpl( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor )
+ throw (::com::sun::star::uno::RuntimeException);
+
+public:
+ AbiWordImportFilter( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &rxContext )
+ : mxContext( rxContext ) {}
+ virtual ~AbiWordImportFilter() {}
+
+ // 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 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 OUString SAL_CALL getImplementationName( )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const OUString &ServiceName )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+};
+
+OUString AbiWordImportFilter_getImplementationName()
+throw ( ::com::sun::star::uno::RuntimeException );
+
+::com::sun::star::uno::Sequence< OUString > SAL_CALL AbiWordImportFilter_getSupportedServiceNames( )
+throw ( ::com::sun::star::uno::RuntimeException );
+
+::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+SAL_CALL AbiWordImportFilter_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/writer/wpftwriter_genericfilter.cxx b/writerperfect/source/writer/wpftwriter_genericfilter.cxx
index e163f5d0c13b..05f654254e05 100644
--- a/writerperfect/source/writer/wpftwriter_genericfilter.cxx
+++ b/writerperfect/source/writer/wpftwriter_genericfilter.cxx
@@ -31,6 +31,7 @@
#include "cppuhelper/implementationentry.hxx"
#include "sal/types.h"
+#include "AbiWordImportFilter.hxx"
#include "EBookImportFilter.hxx"
#include "WordPerfectImportFilter.hxx"
#include "MSWorksImportFilter.hxx"
@@ -39,6 +40,9 @@
namespace {
static cppu::ImplementationEntry const services[] = {
+ { &AbiWordImportFilter_createInstance, &AbiWordImportFilter_getImplementationName,
+ &AbiWordImportFilter_getSupportedServiceNames,
+ &cppu::createSingleComponentFactory, 0, 0 },
{ &WordPerfectImportFilter_createInstance, &WordPerfectImportFilter_getImplementationName,
&WordPerfectImportFilter_getSupportedServiceNames,
&cppu::createSingleComponentFactory, 0, 0 },
diff --git a/writerperfect/util/wpftwriter.component b/writerperfect/util/wpftwriter.component
index e36d8675801e..730cf6236eb3 100644
--- a/writerperfect/util/wpftwriter.component
+++ b/writerperfect/util/wpftwriter.component
@@ -18,6 +18,10 @@
-->
<component loader="com.sun.star.loader.SharedLibrary" prefix="wpftwriter"
xmlns="http://openoffice.org/2010/uno-components">
+ <implementation name="com.sun.star.comp.Writer.AbiWordImportFilter">
+ <service name="com.sun.star.document.ImportFilter"/>
+ <service name="com.sun.star.document.ExtendedTypeDetection"/>
+ </implementation>
<implementation name="com.sun.star.comp.Writer.MSWorksImportFilter">
<service name="com.sun.star.document.ImportFilter"/>
<service name="com.sun.star.document.ExtendedTypeDetection"/>