diff options
31 files changed, 906 insertions, 0 deletions
diff --git a/Makefile.fetch b/Makefile.fetch index 81acd0f73c3c..752a93404da4 100644 --- a/Makefile.fetch +++ b/Makefile.fetch @@ -76,6 +76,7 @@ $(WORKDIR)/download: $(BUILDDIR)/config_host.mk $(SRCDIR)/download.lst $(SRCDIR) $(foreach item, \ $(call fetch_Optional,LIBATOMIC_OPS,LIBATOMIC_OPS_TARBALL) \ $(call fetch_Optional,CDR,CDR_TARBALL) \ + $(call fetch_Optional,EBOOK,EBOOK_TARBALL) \ $(call fetch_Optional,FREEHAND,FREEHAND_TARBALL) \ $(call fetch_Optional,ETONYEK,ETONYEK_TARBALL) \ $(call fetch_Optional,FIREBIRD,FIREBIRD_TARBALL) \ diff --git a/RepositoryExternal.mk b/RepositoryExternal.mk index 4228803fae33..1fd0850b8bb0 100644 --- a/RepositoryExternal.mk +++ b/RepositoryExternal.mk @@ -1402,6 +1402,41 @@ endef endif # SYSTEM_CDR +ifeq ($(SYSTEM_EBOOK),YES) + +define gb_LinkTarget__use_ebook +$(call gb_LinkTarget_set_include,$(1),\ + $$(INCLUDE) \ + $(EBOOK_CFLAGS) \ +) +$(call gb_LinkTarget_add_libs,$(1),$(EBOOK_LIBS)) + +endef + +gb_ExternalProject__use_ebook := + +else # !SYSTEM_EBOOK + +define gb_LinkTarget__use_ebook +$(call gb_LinkTarget_set_include,$(1),\ + $(EBOOK_CFLAGS) \ + $$(INCLUDE) \ +) +$(call gb_LinkTarget_add_libs,$(1),\ + $(call gb_UnpackedTarball_get_dir,libebook)/src/lib/.libs/libe-book-0.0$(gb_StaticLibrary_PLAINEXT) \ +) +$(call gb_LinkTarget_use_external_project,$(1),libebook) + +endef + +define gb_ExternalProject__use_ebook +$(call gb_ExternalProject_use_external_project,$(1),libebook) + +endef + +endif # SYSTEM_EBOOK + + ifeq ($(SYSTEM_ETONYEK),YES) define gb_LinkTarget__use_etonyek diff --git a/config_host.mk.in b/config_host.mk.in index 1ec3268a0719..30df49c7e83c 100644 --- a/config_host.mk.in +++ b/config_host.mk.in @@ -102,6 +102,8 @@ export DOCDIR=@DOCDIR@ export DOXYGEN=@DOXYGEN@ export DO_FETCH_TARBALLS=@DO_FETCH_TARBALLS@ export DPKG=@DPKG@ +export EBOOK_CFLAGS=$(gb_SPACE)@EBOOK_CFLAGS@ +export EBOOK_LIBS=$(gb_SPACE)@EBOOK_LIBS@ export ENABLE_AVAHI=@ENABLE_AVAHI@ export ENABLE_CAIRO_CANVAS=@ENABLE_CAIRO_CANVAS@ export ENABLE_CORETEXT=@ENABLE_CORETEXT@ @@ -504,6 +506,7 @@ export SYSTEM_JPEG=@SYSTEM_JPEG@ export SYSTEM_LCMS2=@SYSTEM_LCMS2@ export SYSTEM_CDR=@SYSTEM_CDR@ export SYSTEM_CMIS=@SYSTEM_CMIS@ +export SYSTEM_EBOOK=@SYSTEM_EBOOK@ export SYSTEM_ETONYEK=@SYSTEM_ETONYEK@ export SYSTEM_FREEHAND=@SYSTEM_FREEHAND@ export SYSTEM_LIBATOMIC_OPS=@SYSTEM_LIBATOMIC_OPS@ diff --git a/configure.ac b/configure.ac index 6f579834d622..817e4dae3052 100644 --- a/configure.ac +++ b/configure.ac @@ -7655,6 +7655,11 @@ fi AC_SUBST(SYSTEM_EXPAT) dnl =================================================================== +dnl Check for system libebook +dnl =================================================================== +libo_CHECK_SYSTEM_MODULE([libebook],[EBOOK],[libe-book-0.0],["-I${WORKDIR}/UnpackedTarball/libebook/inc"],["-L${WORKDIR}/UnpackedTarball/libebook/src/lib/.libs -le-book-0.0"]) + +dnl =================================================================== dnl Check for system libetonyek dnl =================================================================== libo_CHECK_SYSTEM_MODULE([libetonyek],[ETONYEK],[libetonyek-0.0],["-I${WORKDIR}/UnpackedTarball/libetonyek/inc"],["-L${WORKDIR}/UnpackedTarball/libetonyek/src/lib/.libs -letonyek-0.0"]) diff --git a/download.lst b/download.lst index 554358d91529..7714de14e56f 100644 --- a/download.lst +++ b/download.lst @@ -1,5 +1,7 @@ CDR_MD5SUM := d88f9b94df880d2c05be943b000ca112 export CDR_TARBALL := libcdr-0.0.14.tar.bz2 +EBOOK_MD5SUM := 74524e1eecc8ab3ac2e8e8a8bb75d6e4 +export EBOOK_TARBALL := libe-book-0.0.1.tar.bz2 ETONYEK_MD5SUM := 040e0d7ce0cc0eb3a016964699d54a6c export ETONYEK_TARBALL := libetonyek-0.0.1.tar.bz2 FREEHAND_MD5SUM := 496dd00028afcc19f896b01394769043 diff --git a/external/Module_external.mk b/external/Module_external.mk index d2225dde7e99..8ea0f112effc 100644 --- a/external/Module_external.mk +++ b/external/Module_external.mk @@ -32,6 +32,7 @@ $(eval $(call gb_Module_add_moduledirs,external,\ $(call gb_Helper_optional,CPPUNIT,cppunit) \ $(call gb_Helper_optional,CT2N,ct2n) \ $(call gb_Helper_optional,CURL,curl) \ + $(call gb_Helper_optional,EBOOK,libebook) \ $(call gb_Helper_optional,EPM,epm) \ $(call gb_Helper_optional,ETONYEK,libetonyek) \ $(call gb_Helper_optional,EXPAT,expat) \ diff --git a/external/libebook/ExternalProject_libebook.mk b/external/libebook/ExternalProject_libebook.mk new file mode 100644 index 000000000000..dbb7d2b87dfa --- /dev/null +++ b/external/libebook/ExternalProject_libebook.mk @@ -0,0 +1,45 @@ +# -*- 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,libebook)) + +$(eval $(call gb_ExternalProject_use_autoconf,libebook,build)) + +$(eval $(call gb_ExternalProject_register_targets,libebook,\ + build \ +)) + +$(eval $(call gb_ExternalProject_use_externals,libebook,\ + boost_headers \ + icu \ + libxml2 \ + wpd \ + zlib \ +)) + +$(call gb_ExternalProject_get_state_target,libebook,build) : + $(call gb_ExternalProject_run,build,\ + export PKG_CONFIG="" \ + && ./configure \ + --with-pic \ + --enable-static \ + --disable-shared \ + --without-docs \ + --disable-debug \ + --disable-werror \ + --disable-weffc \ + CXXFLAGS="$(if $(filter NO,$(SYSTEM_BOOST)),-I$(call gb_UnpackedTarball_get_dir,boost),$(BOOST_CPPFLAGS))" \ + XML_CFLAGS="$(if $(filter NO,$(SYSTEM_LIBXML)),-I$(call gb_UnpackedTarball_get_dir,xml2)/include,$(LIBXML_CFLAGS))" \ + XML_LIBS="$(LIBXML_LIBS)" \ + $(if $(filter YES,$(CROSS_COMPILING)),--build=$(BUILD_PLATFORM) --host=$(HOST_PLATFORM)) \ + && cd src/lib \ + && $(MAKE) $(if $(VERBOSE)$(verbose),V=1) \ + ) + +# vim: set noet sw=4 ts=4: diff --git a/external/libebook/Makefile b/external/libebook/Makefile new file mode 100644 index 000000000000..e4968cf85fb6 --- /dev/null +++ b/external/libebook/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/libebook/Module_libebook.mk b/external/libebook/Module_libebook.mk new file mode 100644 index 000000000000..cbc74f109868 --- /dev/null +++ b/external/libebook/Module_libebook.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,libebook)) + +$(eval $(call gb_Module_add_targets,libebook,\ + ExternalProject_libebook \ + UnpackedTarball_libebook \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/external/libebook/README b/external/libebook/README new file mode 100644 index 000000000000..440db7dfb425 --- /dev/null +++ b/external/libebook/README @@ -0,0 +1 @@ +Library for import of various non-HTML reflowable e-book formats. diff --git a/external/libebook/UnpackedTarball_libebook.mk b/external/libebook/UnpackedTarball_libebook.mk new file mode 100644 index 000000000000..555837beb701 --- /dev/null +++ b/external/libebook/UnpackedTarball_libebook.mk @@ -0,0 +1,14 @@ +# -*- 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,libebook)) + +$(eval $(call gb_UnpackedTarball_set_tarball,libebook,$(EBOOK_TARBALL))) + +# vim: set noet sw=4 ts=4: diff --git a/filter/Configuration_filter.mk b/filter/Configuration_filter.mk index 4f7af962e199..bace5972628c 100644 --- a/filter/Configuration_filter.mk +++ b/filter/Configuration_filter.mk @@ -357,6 +357,13 @@ $(call filter_Configuration_add_types,fcfg_langpack,fcfg_writer_types.xcu,filter writer_OOXML \ writer_OOXML_Template \ writer_layout_dump_xml \ + writer_BroadBand_eBook \ + writer_eReader_eBook \ + writer_FictionBook_2 \ + writer_PalmDoc \ + writer_Plucker_eBook \ + writer_TealDoc \ + writer_zTXT \ ) $(call filter_Configuration_add_filters,fcfg_langpack,fcfg_writer_filters.xcu,filter/source/config/fragments/filters,\ @@ -407,6 +414,13 @@ $(call filter_Configuration_add_filters,fcfg_langpack,fcfg_writer_filters.xcu,fi OOXML_Text \ OOXML_Text_Template \ writer_layout_dump \ + BroadBand_eBook \ + eReader_eBook \ + FictionBook_2 \ + PalmDoc \ + Plucker_eBook \ + TealDoc \ + zTXT \ ) $(call filter_Configuration_add_ui_filters,fcfg_langpack,filter/source/config/fragments/filters,\ diff --git a/filter/source/config/fragments/filters/BroadBand_eBook.xcu b/filter/source/config/fragments/filters/BroadBand_eBook.xcu new file mode 100644 index 000000000000..128dc2998d1e --- /dev/null +++ b/filter/source/config/fragments/filters/BroadBand_eBook.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/. + * +--> + +<node oor:name="BroadBand eBook" oor:op="replace"> + <prop oor:name="Flags"> + <value>IMPORT ALIEN USESOPTIONS 3RDPARTYFILTER PREFERRED</value> + </prop> + <prop oor:name="FilterService"> + <value>org.libreoffice.comp.Writer.EBookImportFilter</value> + </prop> + <prop oor:name="UIName"> + <value xml:lang="x-default">BroadBand eBook</value> + </prop> + <prop oor:name="FileFormatVersion"> + <value>0</value> + </prop> + <prop oor:name="Type"> + <value>writer_BroadBand_eBook</value> + </prop> + <prop oor:name="DocumentService"> + <value>com.sun.star.text.TextDocument</value> + </prop> +</node> diff --git a/filter/source/config/fragments/filters/FictionBook_2.xcu b/filter/source/config/fragments/filters/FictionBook_2.xcu new file mode 100644 index 000000000000..d4e9ecd29c9d --- /dev/null +++ b/filter/source/config/fragments/filters/FictionBook_2.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/. + * +--> + +<node oor:name="FictionBook 2" oor:op="replace"> + <prop oor:name="Flags"> + <value>IMPORT ALIEN USESOPTIONS 3RDPARTYFILTER PREFERRED</value> + </prop> + <prop oor:name="FilterService"> + <value>org.libreoffice.comp.Writer.EBookImportFilter</value> + </prop> + <prop oor:name="UIName"> + <value xml:lang="x-default">FictionBook 2.0</value> + </prop> + <prop oor:name="FileFormatVersion"> + <value>0</value> + </prop> + <prop oor:name="Type"> + <value>writer_FictionBook_2</value> + </prop> + <prop oor:name="DocumentService"> + <value>com.sun.star.text.TextDocument</value> + </prop> +</node> diff --git a/filter/source/config/fragments/filters/PalmDoc.xcu b/filter/source/config/fragments/filters/PalmDoc.xcu new file mode 100644 index 000000000000..2f2bc338f1f1 --- /dev/null +++ b/filter/source/config/fragments/filters/PalmDoc.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/. + * +--> + +<node oor:name="PalmDoc" oor:op="replace"> + <prop oor:name="Flags"> + <value>IMPORT ALIEN USESOPTIONS 3RDPARTYFILTER PREFERRED</value> + </prop> + <prop oor:name="FilterService"> + <value>org.libreoffice.comp.Writer.EBookImportFilter</value> + </prop> + <prop oor:name="UIName"> + <value xml:lang="x-default">PalmDoc eBook</value> + </prop> + <prop oor:name="FileFormatVersion"> + <value>0</value> + </prop> + <prop oor:name="Type"> + <value>writer_PalmDoc</value> + </prop> + <prop oor:name="DocumentService"> + <value>com.sun.star.text.TextDocument</value> + </prop> +</node> diff --git a/filter/source/config/fragments/filters/Plucker_eBook.xcu b/filter/source/config/fragments/filters/Plucker_eBook.xcu new file mode 100644 index 000000000000..d953b1210c84 --- /dev/null +++ b/filter/source/config/fragments/filters/Plucker_eBook.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/. + * +--> + +<node oor:name="Plucker eBook" oor:op="replace"> + <prop oor:name="Flags"> + <value>IMPORT ALIEN USESOPTIONS 3RDPARTYFILTER PREFERRED</value> + </prop> + <prop oor:name="FilterService"> + <value>org.libreoffice.comp.Writer.EBookImportFilter</value> + </prop> + <prop oor:name="UIName"> + <value xml:lang="x-default">Plucker eBook</value> + </prop> + <prop oor:name="FileFormatVersion"> + <value>0</value> + </prop> + <prop oor:name="Type"> + <value>writer_Plucker_eBook</value> + </prop> + <prop oor:name="DocumentService"> + <value>com.sun.star.text.TextDocument</value> + </prop> +</node> diff --git a/filter/source/config/fragments/filters/TealDoc.xcu b/filter/source/config/fragments/filters/TealDoc.xcu new file mode 100644 index 000000000000..749b00dd561b --- /dev/null +++ b/filter/source/config/fragments/filters/TealDoc.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/. + * +--> + +<node oor:name="TealDoc" oor:op="replace"> + <prop oor:name="Flags"> + <value>IMPORT ALIEN USESOPTIONS 3RDPARTYFILTER PREFERRED</value> + </prop> + <prop oor:name="FilterService"> + <value>org.libreoffice.comp.Writer.EBookImportFilter</value> + </prop> + <prop oor:name="UIName"> + <value xml:lang="x-default">TealDoc eBook</value> + </prop> + <prop oor:name="FileFormatVersion"> + <value>0</value> + </prop> + <prop oor:name="Type"> + <value>writer_TealDoc</value> + </prop> + <prop oor:name="DocumentService"> + <value>com.sun.star.text.TextDocument</value> + </prop> +</node> diff --git a/filter/source/config/fragments/filters/eReader_eBook.xcu b/filter/source/config/fragments/filters/eReader_eBook.xcu new file mode 100644 index 000000000000..306866cbef4d --- /dev/null +++ b/filter/source/config/fragments/filters/eReader_eBook.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/. + * +--> + +<node oor:name="eReader eBook" oor:op="replace"> + <prop oor:name="Flags"> + <value>IMPORT ALIEN USESOPTIONS 3RDPARTYFILTER PREFERRED</value> + </prop> + <prop oor:name="FilterService"> + <value>org.libreoffice.comp.Writer.EBookImportFilter</value> + </prop> + <prop oor:name="UIName"> + <value xml:lang="x-default">eReader eBook</value> + </prop> + <prop oor:name="FileFormatVersion"> + <value>0</value> + </prop> + <prop oor:name="Type"> + <value>writer_eReader_eBook</value> + </prop> + <prop oor:name="DocumentService"> + <value>com.sun.star.text.TextDocument</value> + </prop> +</node> diff --git a/filter/source/config/fragments/filters/zTXT.xcu b/filter/source/config/fragments/filters/zTXT.xcu new file mode 100644 index 000000000000..0b7a0519405a --- /dev/null +++ b/filter/source/config/fragments/filters/zTXT.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/. + * +--> + +<node oor:name="zTXT" oor:op="replace"> + <prop oor:name="Flags"> + <value>IMPORT ALIEN USESOPTIONS 3RDPARTYFILTER PREFERRED</value> + </prop> + <prop oor:name="FilterService"> + <value>org.libreoffice.comp.Writer.EBookImportFilter</value> + </prop> + <prop oor:name="UIName"> + <value xml:lang="x-default">zTXT eBook</value> + </prop> + <prop oor:name="FileFormatVersion"> + <value>0</value> + </prop> + <prop oor:name="Type"> + <value>writer_zTXT</value> + </prop> + <prop oor:name="DocumentService"> + <value>com.sun.star.text.TextDocument</value> + </prop> +</node> diff --git a/filter/source/config/fragments/types/writer_BroadBand_eBook.xcu b/filter/source/config/fragments/types/writer_BroadBand_eBook.xcu new file mode 100644 index 000000000000..129f330050ff --- /dev/null +++ b/filter/source/config/fragments/types/writer_BroadBand_eBook.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/. + * +--> + +<node oor:name="writer_BroadBand_eBook" oor:op="replace"> + <prop oor:name="DetectService"> + <value>org.libreoffice.comp.Writer.EBookImportFilter</value> + </prop> + <prop oor:name="Extensions"> + <value>lrf</value> + </prop> + <prop oor:name="MediaType"> + <value>application/x-sony-bbeb</value> + </prop> + <prop oor:name="Preferred"> + <value>true</value> + </prop> + <prop oor:name="PreferredFilter"> + <value>BroadBand eBook</value> + </prop> + <prop oor:name="UIName"> + <value>BroadBand eBook</value> + </prop> +</node> diff --git a/filter/source/config/fragments/types/writer_FictionBook_2.xcu b/filter/source/config/fragments/types/writer_FictionBook_2.xcu new file mode 100644 index 000000000000..3b49a6133535 --- /dev/null +++ b/filter/source/config/fragments/types/writer_FictionBook_2.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/. + * +--> + +<node oor:name="writer_FictionBook_2" oor:op="replace"> + <prop oor:name="DetectService"> + <value>org.libreoffice.comp.Writer.EBookImportFilter</value> + </prop> + <prop oor:name="Extensions"> + <value>fb2 zip</value> + </prop> + <prop oor:name="MediaType"> + <value>text/xml</value> + </prop> + <prop oor:name="Preferred"> + <value>true</value> + </prop> + <prop oor:name="PreferredFilter"> + <value>FictionBook 2</value> + </prop> + <prop oor:name="UIName"> + <value>FictionBook 2.0</value> + </prop> +</node> diff --git a/filter/source/config/fragments/types/writer_PalmDoc.xcu b/filter/source/config/fragments/types/writer_PalmDoc.xcu new file mode 100644 index 000000000000..8f91f7e18760 --- /dev/null +++ b/filter/source/config/fragments/types/writer_PalmDoc.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/. + * +--> + +<node oor:name="writer_PalmDoc" oor:op="replace"> + <prop oor:name="DetectService"> + <value>org.libreoffice.comp.Writer.EBookImportFilter</value> + </prop> + <prop oor:name="Extensions"> + <value>pdb</value> + </prop> + <prop oor:name="MediaType"> + <value>application/vnd.palm</value> + </prop> + <prop oor:name="Preferred"> + <value>true</value> + </prop> + <prop oor:name="PreferredFilter"> + <value>PalmDoc</value> + </prop> + <prop oor:name="UIName"> + <value>PalmDoc eBook</value> + </prop> +</node> diff --git a/filter/source/config/fragments/types/writer_Plucker_eBook.xcu b/filter/source/config/fragments/types/writer_Plucker_eBook.xcu new file mode 100644 index 000000000000..000d872a5b60 --- /dev/null +++ b/filter/source/config/fragments/types/writer_Plucker_eBook.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/. + * +--> + +<node oor:name="writer_Plucker_eBook" oor:op="replace"> + <prop oor:name="DetectService"> + <value>org.libreoffice.comp.Writer.EBookImportFilter</value> + </prop> + <prop oor:name="Extensions"> + <value>pdb</value> + </prop> + <prop oor:name="MediaType"> + <value>application/prs.plucker</value> + </prop> + <prop oor:name="Preferred"> + <value>true</value> + </prop> + <prop oor:name="PreferredFilter"> + <value>Plucker eBook</value> + </prop> + <prop oor:name="UIName"> + <value>Plucker eBook</value> + </prop> +</node> diff --git a/filter/source/config/fragments/types/writer_TealDoc.xcu b/filter/source/config/fragments/types/writer_TealDoc.xcu new file mode 100644 index 000000000000..26c13da3c485 --- /dev/null +++ b/filter/source/config/fragments/types/writer_TealDoc.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/. + * +--> + +<node oor:name="writer_TealDoc" oor:op="replace"> + <prop oor:name="DetectService"> + <value>org.libreoffice.comp.Writer.EBookImportFilter</value> + </prop> + <prop oor:name="Extensions"> + <value>pdb</value> + </prop> + <prop oor:name="MediaType"> + <value>application/vnd.palm</value> + </prop> + <prop oor:name="Preferred"> + <value>true</value> + </prop> + <prop oor:name="PreferredFilter"> + <value>TealDoc</value> + </prop> + <prop oor:name="UIName"> + <value>TealDoc eBook</value> + </prop> +</node> diff --git a/filter/source/config/fragments/types/writer_eReader_eBook.xcu b/filter/source/config/fragments/types/writer_eReader_eBook.xcu new file mode 100644 index 000000000000..e0908720b616 --- /dev/null +++ b/filter/source/config/fragments/types/writer_eReader_eBook.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/. + * +--> + +<node oor:name="writer_eReader_eBook" oor:op="replace"> + <prop oor:name="DetectService"> + <value>org.libreoffice.comp.Writer.EBookImportFilter</value> + </prop> + <prop oor:name="Extensions"> + <value>pdb</value> + </prop> + <prop oor:name="MediaType"> + <value>application/vnd.palm</value> + </prop> + <prop oor:name="Preferred"> + <value>true</value> + </prop> + <prop oor:name="PreferredFilter"> + <value>eReader eBook</value> + </prop> + <prop oor:name="UIName"> + <value>eReader eBook</value> + </prop> +</node> diff --git a/filter/source/config/fragments/types/writer_zTXT.xcu b/filter/source/config/fragments/types/writer_zTXT.xcu new file mode 100644 index 000000000000..95cbc08abf91 --- /dev/null +++ b/filter/source/config/fragments/types/writer_zTXT.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/. + * +--> + +<node oor:name="writer_zTXT" oor:op="replace"> + <prop oor:name="DetectService"> + <value>org.libreoffice.comp.Writer.EBookImportFilter</value> + </prop> + <prop oor:name="Extensions"> + <value>pdb</value> + </prop> + <prop oor:name="MediaType"> + <value>application/vnd.palm</value> + </prop> + <prop oor:name="Preferred"> + <value>true</value> + </prop> + <prop oor:name="PreferredFilter"> + <value>zTXT</value> + </prop> + <prop oor:name="UIName"> + <value>zTXT eBook</value> + </prop> +</node> diff --git a/writerperfect/Library_wpftwriter.mk b/writerperfect/Library_wpftwriter.mk index 6f5dafae4572..cc69e9d95ec7 100644 --- a/writerperfect/Library_wpftwriter.mk +++ b/writerperfect/Library_wpftwriter.mk @@ -49,7 +49,12 @@ $(eval $(call gb_Library_use_static_libraries,wpftwriter,\ $(eval $(call gb_Library_use_externals,wpftwriter,\ boost_headers \ + ebook \ etonyek \ + icui18n \ + icudata \ + icuuc \ + libxml2 \ mwaw \ odfgen \ wps \ @@ -59,6 +64,7 @@ $(eval $(call gb_Library_use_externals,wpftwriter,\ )) $(eval $(call gb_Library_add_exception_objects,wpftwriter,\ + writerperfect/source/writer/EBookImportFilter \ writerperfect/source/writer/MSWorksImportFilter \ writerperfect/source/writer/MWAWImportFilter \ writerperfect/source/writer/WordPerfectImportFilter \ diff --git a/writerperfect/source/writer/EBookImportFilter.cxx b/writerperfect/source/writer/EBookImportFilter.cxx new file mode 100644 index 000000000000..aa0232947b57 --- /dev/null +++ b/writerperfect/source/writer/EBookImportFilter.cxx @@ -0,0 +1,253 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* EBookImportFilter: 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 <libe-book/libe-book.h> + +#include <libodfgen/libodfgen.hxx> + +#include "common/DocumentHandler.hxx" +#include "common/WPXSvStream.hxx" +#include "EBookImportFilter.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 EBookImportFilter::importImpl( const Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor ) +throw (RuntimeException) +{ + SAL_INFO("writerperfect", "EBookImportFilter::importImpl"); + + sal_Int32 nLength = aDescriptor.getLength(); + const PropertyValue *pValue = aDescriptor.getConstArray(); + Reference < XInputStream > xInputStream; + rtl::OUString sFilterName; + for ( sal_Int32 i = 0 ; i < nLength; i++) + { + if ( pValue[i].Name == "FilterName" ) + pValue[i].Value >>= sFilterName; + else if ( pValue[i].Name == "InputStream" ) + pValue[i].Value >>= xInputStream; + } + if ( sFilterName.isEmpty() ) + { + OSL_ASSERT( 0 ); + return sal_False; + } + 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 (sFilterName == "FictionBook 2") + return libebook::FB2Document::parse(&input, &collector); + else if (sFilterName == "PalmDoc") + return libebook::PDBDocument::parse(&input, &collector); + else if (sFilterName == "Plucker eBook") + return libebook::PLKRDocument::parse(&input, &collector); + else if (sFilterName == "eReader eBook") + return libebook::PMLDocument::parse(&input, &collector); + else if (sFilterName == "TealDoc") + return libebook::TDDocument::parse(&input, &collector); + else if (sFilterName == "zTXT") + return libebook::ZTXTDocument::parse(&input, &collector); + + return sal_False; +} + +sal_Bool SAL_CALL EBookImportFilter::filter( const Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor ) +throw (RuntimeException) +{ + SAL_INFO("writerperfect", "EBookImportFilter::filter"); + return importImpl ( aDescriptor ); +} +void SAL_CALL EBookImportFilter::cancel( ) +throw (RuntimeException) +{ + SAL_INFO("writerperfect", "EBookImportFilter::cancel"); +} + +// XImporter +void SAL_CALL EBookImportFilter::setTargetDocument( const Reference< ::com::sun::star::lang::XComponent >& xDoc ) +throw (::com::sun::star::lang::IllegalArgumentException, RuntimeException) +{ + SAL_INFO("writerperfect", "EBookImportFilter::getTargetDocument"); + mxDoc = xDoc; +} + +// XExtendedFilterDetection +OUString SAL_CALL EBookImportFilter::detect( com::sun::star::uno::Sequence< PropertyValue >& Descriptor ) +throw( com::sun::star::uno::RuntimeException ) +{ + SAL_INFO("writerperfect", "EBookImportFilter::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 (libebook::FB2Document::isSupported(&input)) + sTypeName = "writer_FictionBook_2"; + else if (libebook::PDBDocument::isSupported(&input)) + sTypeName = "writer_PalmDoc"; + else if (libebook::PLKRDocument::isSupported(&input)) + sTypeName = "writer_Plucker_eBook"; + else if (libebook::PMLDocument::isSupported(&input)) + sTypeName = "writer_eReader_eBook"; + else if (libebook::TDDocument::isSupported(&input)) + sTypeName = "writer_TealDoc"; + else if (libebook::ZTXTDocument::isSupported(&input)) + sTypeName = "writer_zTXT"; + + if (!sTypeName.isEmpty()) + { + if ( location == nLength ) + { + Descriptor.realloc(nLength+1); + Descriptor[location].Name = "TypeName"; + } + + Descriptor[location].Value <<=sTypeName; + } + + return sTypeName; +} + + +// XInitialization +void SAL_CALL EBookImportFilter::initialize( const Sequence< Any >& aArguments ) +throw (Exception, RuntimeException) +{ + SAL_INFO("writerperfect", "EBookImportFilter::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 EBookImportFilter_getImplementationName () +throw (RuntimeException) +{ + return OUString ( "org.libreoffice.comp.Writer.EBookImportFilter" ); +} + +Sequence< OUString > SAL_CALL EBookImportFilter_getSupportedServiceNames( ) +throw (RuntimeException) +{ + Sequence < OUString > aRet(2); + OUString *pArray = aRet.getArray(); + pArray[0] = OUString ( "com.sun.star.document.ImportFilter" ); + pArray[1] = OUString ( "com.sun.star.document.ExtendedTypeDetection" ); + return aRet; +} +#undef SERVICE_NAME2 +#undef SERVICE_NAME1 + +Reference< XInterface > SAL_CALL EBookImportFilter_createInstance( const Reference< XComponentContext > & rContext) +throw( Exception ) +{ + return (cppu::OWeakObject *) new EBookImportFilter( rContext ); +} + +// XServiceInfo +OUString SAL_CALL EBookImportFilter::getImplementationName( ) +throw (RuntimeException) +{ + return EBookImportFilter_getImplementationName(); +} +sal_Bool SAL_CALL EBookImportFilter::supportsService( const OUString &rServiceName ) +throw (RuntimeException) +{ + return cppu::supportsService( this, rServiceName ); +} +Sequence< OUString > SAL_CALL EBookImportFilter::getSupportedServiceNames( ) +throw (RuntimeException) +{ + return EBookImportFilter_getSupportedServiceNames(); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerperfect/source/writer/EBookImportFilter.hxx b/writerperfect/source/writer/EBookImportFilter.hxx new file mode 100644 index 000000000000..3e844d78b49f --- /dev/null +++ b/writerperfect/source/writer/EBookImportFilter.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 EBOOKIMPORTFILTER_HXX +#define EBOOKIMPORTFILTER_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 EBookImportFilter : 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: + EBookImportFilter( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &rxContext ) + : mxContext( rxContext ) {} + virtual ~EBookImportFilter() {} + + // 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 EBookImportFilter_getImplementationName() +throw ( ::com::sun::star::uno::RuntimeException ); + +::com::sun::star::uno::Sequence< OUString > SAL_CALL EBookImportFilter_getSupportedServiceNames( ) +throw ( ::com::sun::star::uno::RuntimeException ); + +::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > +SAL_CALL EBookImportFilter_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 0361dd203774..e163f5d0c13b 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 "EBookImportFilter.hxx" #include "WordPerfectImportFilter.hxx" #include "MSWorksImportFilter.hxx" #include "MWAWImportFilter.hxx" @@ -47,6 +48,9 @@ static cppu::ImplementationEntry const services[] = { { &MWAWImportFilter_createInstance, &MWAWImportFilter_getImplementationName, &MWAWImportFilter_getSupportedServiceNames, &cppu::createSingleComponentFactory, 0, 0 }, + { &EBookImportFilter_createInstance, &EBookImportFilter_getImplementationName, + &EBookImportFilter_getSupportedServiceNames, + &cppu::createSingleComponentFactory, 0, 0 }, { 0, 0, 0, 0, 0, 0 } }; } diff --git a/writerperfect/util/wpftwriter.component b/writerperfect/util/wpftwriter.component index f243d5c96257..e36d8675801e 100644 --- a/writerperfect/util/wpftwriter.component +++ b/writerperfect/util/wpftwriter.component @@ -30,4 +30,8 @@ <service name="com.sun.star.document.ExtendedTypeDetection"/> <service name="com.sun.star.document.ImportFilter"/> </implementation> + <implementation name="org.libreoffice.comp.Writer.EBookImportFilter"> + <service name="com.sun.star.document.ExtendedTypeDetection"/> + <service name="com.sun.star.document.ImportFilter"/> + </implementation> </component> |