[Libreoffice-commits] core.git: config_host.mk.in configure.ac download.lst libodfgen/ExternalPackage_libodfgen.mk libodfgen/ExternalProject_libodfgen.mk libodfgen/Makefile libodfgen/Module_libodfgen.mk libodfgen/README libodfgen/UnpackedTarball_odfgen.mk Makefile.fetch RepositoryExternal.mk RepositoryModule_host.mk writerperfect/Library_wpftdraw.mk writerperfect/Library_wpftwriter.mk writerperfect/Module_writerperfect.mk writerperfect/source writerperfect/StaticLibrary_writerperfect.mk
Fridrich Å trba
fridrich.strba at bluewin.ch
Thu May 2 11:49:39 PDT 2013
Makefile.fetch | 1
RepositoryExternal.mk | 30
RepositoryModule_host.mk | 1
config_host.mk.in | 15
configure.ac | 5
download.lst | 1
libodfgen/ExternalPackage_libodfgen.mk | 28
libodfgen/ExternalProject_libodfgen.mk | 40
libodfgen/Makefile | 7
libodfgen/Module_libodfgen.mk | 22
libodfgen/README | 1
libodfgen/UnpackedTarball_odfgen.mk | 14
writerperfect/Library_wpftdraw.mk | 15
writerperfect/Library_wpftwriter.mk | 3
writerperfect/Module_writerperfect.mk | 6
writerperfect/StaticLibrary_writerperfect.mk | 12
writerperfect/source/common/DocumentElement.cxx | 55
writerperfect/source/common/DocumentElement.hxx | 86
writerperfect/source/common/DocumentHandler.cxx | 2
writerperfect/source/common/DocumentHandler.hxx | 2
writerperfect/source/common/FilterInternal.cxx | 29
writerperfect/source/common/FilterInternal.hxx | 63
writerperfect/source/common/FontStyle.cxx | 74
writerperfect/source/common/FontStyle.hxx | 65
writerperfect/source/common/InternalHandler.cxx | 44
writerperfect/source/common/InternalHandler.hxx | 38
writerperfect/source/common/ListStyle.cxx | 178 -
writerperfect/source/common/ListStyle.hxx | 69
writerperfect/source/common/OdfDocumentHandler.hxx | 28
writerperfect/source/common/OdgGenerator.cxx | 1756 ----------------
writerperfect/source/common/OdgGenerator.hxx | 56
writerperfect/source/common/OdtGenerator.cxx | 1482 -------------
writerperfect/source/common/OdtGenerator.hxx | 105
writerperfect/source/common/PageSpan.cxx | 247 --
writerperfect/source/common/PageSpan.hxx | 48
writerperfect/source/common/SectionStyle.cxx | 75
writerperfect/source/common/SectionStyle.hxx | 35
writerperfect/source/common/Style.hxx | 77
writerperfect/source/common/TableStyle.cxx | 156 -
writerperfect/source/common/TableStyle.hxx | 78
writerperfect/source/common/TextRunStyle.cxx | 279 --
writerperfect/source/common/TextRunStyle.hxx | 116 -
writerperfect/source/common/WPXSvStream.cxx | 2
writerperfect/source/common/WriterPerfectDebug.hxx | 24
writerperfect/source/draw/CDRImportFilter.cxx | 5
writerperfect/source/draw/CMXImportFilter.cxx | 5
writerperfect/source/draw/MSPUBImportFilter.cxx | 5
writerperfect/source/draw/VisioImportFilter.cxx | 5
writerperfect/source/draw/WPGImportFilter.cxx | 5
writerperfect/source/writer/MSWorksImportFilter.cxx | 7
writerperfect/source/writer/MWAWImportFilter.cxx | 6
writerperfect/source/writer/WordPerfectImportFilter.cxx | 5
52 files changed, 227 insertions(+), 5286 deletions(-)
New commits:
commit 93848e11ec7d28ddef35ee165e12d847f2fafcea
Author: Fridrich Å trba <fridrich.strba at bluewin.ch>
Date: Thu May 2 20:25:51 2013 +0200
Splitting writerperfect into serializer and libodfgen
Change-Id: I69f12fb097dbc977e63463b6b764a3553bcf9271
diff --git a/Makefile.fetch b/Makefile.fetch
index e683f28..1381a37 100644
--- a/Makefile.fetch
+++ b/Makefile.fetch
@@ -141,6 +141,7 @@ $(WORKDIR)/download: $(BUILDDIR)/config_host.mk $(SRCDIR)/download.lst $(SRCDIR)
$(call fetch_Optional,NEON,$(NEON_TARBALL)) \
$(call fetch_Optional,NSS,$(NSS_TARBALL)) \
$(NUMBERTEXT_EXTENSION_PACK) \
+ $(call fetch_Optional,ODFGEN,$(ODFGEN_TARBALL)) \
$(call fetch_Optional,OPENLDAP,$(OPENLDAP_TARBALL)) \
$(call fetch_Optional,OPENSSL,$(OPENSSL_TARBALL)) \
$(call fetch_Optional,ORCUS,$(ORCUS_TARBALL)) \
diff --git a/RepositoryExternal.mk b/RepositoryExternal.mk
index a1d01cf..3acd501 100644
--- a/RepositoryExternal.mk
+++ b/RepositoryExternal.mk
@@ -1365,6 +1365,36 @@ endef
endif # SYSTEM_CDR
+ifeq ($(SYSTEM_ODFGEN),YES)
+
+define gb_LinkTarget__use_odfgen
+$(call gb_LinkTarget_set_include,$(1),\
+ $$(INCLUDE) \
+ $(ODFGEN_CFLAGS) \
+)
+$(call gb_LinkTarget_add_libs,$(1),$(ODFGEN_LIBS))
+
+endef
+
+else # !SYSTEM_ODFGEN
+
+$(eval $(call gb_Helper_register_static_libraries,PLAINLIBS, \
+ odfgen-0.0 \
+))
+
+define gb_LinkTarget__use_odfgen
+$(call gb_LinkTarget_use_package,$(1),\
+ libodfgen \
+)
+$(call gb_LinkTarget_use_static_libraries,$(1),\
+ odfgen-0.0 \
+)
+
+endef
+
+endif # SYSTEM_ODFGEN
+
+
ifeq ($(SYSTEM_MSPUB),YES)
define gb_LinkTarget__use_mspub
diff --git a/RepositoryModule_host.mk b/RepositoryModule_host.mk
index 1b939f1..d17a73b 100644
--- a/RepositoryModule_host.mk
+++ b/RepositoryModule_host.mk
@@ -102,6 +102,7 @@ $(eval $(call gb_Module_add_moduledirs,libreoffice,\
$(call gb_Helper_optional,LIBPNG,libpng) \
$(call gb_Helper_optional,MSPUB,libmspub) \
$(call gb_Helper_optional,MWAW,libmwaw) \
+ $(call gb_Helper_optional,ODFGEN,libodfgen) \
$(call gb_Helper_optional,ORCUS,liborcus) \
librelogo \
$(call gb_Helper_optional,VISIO,libvisio) \
diff --git a/config_host.mk.in b/config_host.mk.in
index 8696a92..7e469aa 100644
--- a/config_host.mk.in
+++ b/config_host.mk.in
@@ -385,6 +385,8 @@ export nodep=@nodep@
@x_OBJCXXFLAGS@ export OBJCXXFLAGS=@OBJCXXFLAGS@
export EXTRA_BUILDID=@EXTRA_BUILDID@
export OBJDUMP=@OBJDUMP@
+export ODFGEN_CFLAGS=$(gb_SPACE)@ODFGEN_CFLAGS@
+export ODFGEN_LIBS=$(gb_SPACE)@ODFGEN_LIBS@
export OOODMAKEMODE=YES
export OOOP_FONTS_PACK=@OOOP_FONTS_PACK@
export OOOP_GALLERY_PACK=@OOOP_GALLERY_PACK@
@@ -493,14 +495,8 @@ export SYSTEM_CMIS=@SYSTEM_CMIS@
export SYSTEM_LIBEXTTEXTCAT=@SYSTEM_LIBEXTTEXTCAT@
export SYSTEM_LIBEXTTEXTCAT_DATA=@SYSTEM_LIBEXTTEXTCAT_DATA@
export SYSTEM_LIBLANGTAG=@SYSTEM_LIBLANGTAG@
-export SYSTEM_MSPUB=@SYSTEM_MSPUB@
-export SYSTEM_MWAW=@SYSTEM_MWAW@
export SYSTEM_LIBORCUS=@SYSTEM_LIBORCUS@
export SYSTEM_LIBPNG=@SYSTEM_LIBPNG@
-export SYSTEM_VISIO=@SYSTEM_VISIO@
-export SYSTEM_WPD=@SYSTEM_WPD@
-export SYSTEM_WPG=@SYSTEM_WPG@
-export SYSTEM_WPS=@SYSTEM_WPS@
export SYSTEM_LIBXML=@SYSTEM_LIBXML@
export SYSTEM_LIBXSLT=@SYSTEM_LIBXSLT@
export SYSTEM_LIBXSLT_FOR_BUILD=@SYSTEM_LIBXSLT_FOR_BUILD@
@@ -508,12 +504,15 @@ export SYSTEM_LPSOLVE=@SYSTEM_LPSOLVE@
export SYSTEM_MDDS=@SYSTEM_MDDS@
export SYSTEM_MESA_HEADERS=@SYSTEM_MESA_HEADERS@
export SYSTEM_MARIADB=@SYSTEM_MARIADB@
+export SYSTEM_MSPUB=@SYSTEM_MSPUB@
+export SYSTEM_MWAW=@SYSTEM_MWAW@
export SYSTEM_MYSQL_CPPCONN=@SYSTEM_MYSQL_CPPCONN@
export SYSTEM_MYTHES=@SYSTEM_MYTHES@
export SYSTEM_NEON=@SYSTEM_NEON@
export SYSTEM_NPAPI_HEADERS=@SYSTEM_NPAPI_HEADERS@
export SYSTEM_NSS=@SYSTEM_NSS@
export SYSTEM_ODBC_HEADERS=@SYSTEM_ODBC_HEADERS@
+export SYSTEM_ODFGEN=@SYSTEM_ODFGEN@
export SYSTEM_OPENLDAP=@SYSTEM_OPENLDAP@
export SYSTEM_OPENSSL=@SYSTEM_OPENSSL@
export SYSTEM_POPPLER=@SYSTEM_POPPLER@
@@ -524,6 +523,10 @@ export SYSTEM_RHINO=@SYSTEM_RHINO@
export SYSTEM_SERVLETAPI=@SYSTEM_SERVLETAPI@
export SYSTEM_UCPP=@SYSTEM_UCPP@
export SYSTEM_VIGRA=@SYSTEM_VIGRA@
+export SYSTEM_VISIO=@SYSTEM_VISIO@
+export SYSTEM_WPD=@SYSTEM_WPD@
+export SYSTEM_WPG=@SYSTEM_WPG@
+export SYSTEM_WPS=@SYSTEM_WPS@
export SYSTEM_ZLIB=@SYSTEM_ZLIB@
export TARFILE_LOCATION=@TARFILE_LOCATION@
export TDE_CFLAGS=$(gb_SPACE)@TDE_CFLAGS@
diff --git a/configure.ac b/configure.ac
index 83b2d6a..4fc41e9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -7246,6 +7246,11 @@ fi
AC_SUBST(SYSTEM_EXPAT)
dnl ===================================================================
+dnl Check for system libodfgen
+dnl ===================================================================
+libo_CHECK_SYSTEM_MODULE([libodfgen],[ODFGEN],[libodfgen-0.0])
+
+dnl ===================================================================
dnl Check for system libcdr
dnl ===================================================================
libo_CHECK_SYSTEM_MODULE([libcdr],[CDR],[libcdr-0.0 >= 0.0.5])
diff --git a/download.lst b/download.lst
index ecc6d634..8839108 100644
--- a/download.lst
+++ b/download.lst
@@ -68,6 +68,7 @@ export MYTHES_TARBALL := 46e92b68e31e858512b680b3b61dc4c1-mythes-1.2.3.tar.gz
export NEON_TARBALL := ff369e69ef0f0143beb5626164e87ae2-neon-0.29.5.tar.gz
export NSS_TARBALL := a0a861f539f0e7a91d05e6b9457e4db1-nss-3.13.5-with-nspr-4.9.1.tar.gz
export OPENLDAP_TARBALL := 804c6cb5698db30b75ad0ff1c25baefd-openldap-2.4.31.tgz
+export ODFGEN_TARBALL := 396ac8b0a49175f7139e4aa8917e742e-libodfgen-0.0.0.tar.bz2
export OPENSSL_TARBALL := 51a40a81b3b7abe8a5c33670bd3da0ce-openssl-0.9.8v.tar.gz
export ORCUS_TARBALL := ea2acaf140ae40a87a952caa75184f4d-liborcus-0.5.1.tar.bz2
export PIXMAN_TARBALL := c63f411b3ad147db2bcce1bf262a0e02-pixman-0.24.4.tar.bz2
diff --git a/libodfgen/ExternalPackage_libodfgen.mk b/libodfgen/ExternalPackage_libodfgen.mk
new file mode 100644
index 0000000..0f9e7a0
--- /dev/null
+++ b/libodfgen/ExternalPackage_libodfgen.mk
@@ -0,0 +1,28 @@
+# -*- 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_ExternalPackage_ExternalPackage,libodfgen,odfgen))
+
+$(eval $(call gb_ExternalPackage_add_unpacked_files,libodfgen,inc/external/libodfgen,\
+ src/libodfgen.hxx \
+ src/OdfDocumentHandler.hxx \
+ src/OdtGenerator.hxx \
+ src/OdgGenerator.hxx \
+))
+
+$(eval $(call gb_ExternalPackage_use_external_project,libodfgen,libodfgen))
+
+ifeq ($(COM),MSC)
+$(eval $(call gb_ExternalPackage_add_file,libodfgen,lib/odfgen-0.0.lib,src/lib/.libs/libodfgen-0.0.lib))
+else
+$(eval $(call gb_ExternalPackage_add_file,libodfgen,lib/libodfgen-0.0.a,src/lib/.libs/libodfgen-0.0.a))
+endif
+
+
+# vim: set noet sw=4 ts=4:
diff --git a/libodfgen/ExternalProject_libodfgen.mk b/libodfgen/ExternalProject_libodfgen.mk
new file mode 100644
index 0000000..eb6e9c5
--- /dev/null
+++ b/libodfgen/ExternalProject_libodfgen.mk
@@ -0,0 +1,40 @@
+# -*- 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,libodfgen))
+
+$(eval $(call gb_ExternalProject_use_unpacked,libodfgen,odfgen))
+
+$(eval $(call gb_ExternalProject_use_autoconf,libodfgen,build))
+
+$(eval $(call gb_ExternalProject_register_targets,libodfgen,\
+ build \
+))
+
+$(eval $(call gb_ExternalProject_use_externals,libodfgen,\
+ boost_headers \
+ wpd \
+ wpg \
+))
+
+$(call gb_ExternalProject_get_state_target,libodfgen,build) :
+ $(call gb_ExternalProject_run,build,\
+ export PKG_CONFIG="" \
+ && ./configure \
+ --with-pic \
+ --enable-static \
+ --disable-shared \
+ --disable-debug \
+ --disable-werror \
+ CXXFLAGS="$(if $(filter NO,$(SYSTEM_BOOST)),-I$(call gb_UnpackedTarball_get_dir,boost),$(BOOST_CPPFLAGS))" \
+ $(if $(filter YES,$(CROSS_COMPILING)),--build=$(BUILD_PLATFORM) --host=$(HOST_PLATFORM)) \
+ && (cd $(EXTERNAL_WORKDIR)/src && $(MAKE)) \
+ )
+
+# vim: set noet sw=4 ts=4:
diff --git a/libodfgen/Makefile b/libodfgen/Makefile
new file mode 100644
index 0000000..ccb1c85
--- /dev/null
+++ b/libodfgen/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/libodfgen/Module_libodfgen.mk b/libodfgen/Module_libodfgen.mk
new file mode 100644
index 0000000..c88c4bf
--- /dev/null
+++ b/libodfgen/Module_libodfgen.mk
@@ -0,0 +1,22 @@
+# -*- 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,libodfgen))
+
+ifeq ($(SYSTEM_ODFGEN),NO)
+
+$(eval $(call gb_Module_add_targets,libodfgen,\
+ ExternalPackage_libodfgen \
+ ExternalProject_libodfgen \
+ UnpackedTarball_odfgen \
+))
+
+endif
+
+# vim: set noet sw=4 ts=4:
diff --git a/libodfgen/README b/libodfgen/README
new file mode 100644
index 0000000..efeffac
--- /dev/null
+++ b/libodfgen/README
@@ -0,0 +1 @@
+From [http://libwpg.sourceforge.net/]. Library to generate ODT and ODG documents from libwpd and libwpg API calls.
diff --git a/libodfgen/UnpackedTarball_odfgen.mk b/libodfgen/UnpackedTarball_odfgen.mk
new file mode 100644
index 0000000..45b8aaa
--- /dev/null
+++ b/libodfgen/UnpackedTarball_odfgen.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,odfgen))
+
+$(eval $(call gb_UnpackedTarball_set_tarball,odfgen,$(ODFGEN_TARBALL)))
+
+# vim: set noet sw=4 ts=4:
diff --git a/writerperfect/Library_wpftdraw.mk b/writerperfect/Library_wpftdraw.mk
index de2da7e..5bb7fda 100644
--- a/writerperfect/Library_wpftdraw.mk
+++ b/writerperfect/Library_wpftdraw.mk
@@ -45,17 +45,18 @@ $(eval $(call gb_Library_use_static_libraries,wpftdraw,\
))
$(eval $(call gb_Library_use_externals,wpftdraw,\
- wpd \
- wpg \
- visio \
cdr \
- mspub \
- lcms2 \
- libxml2 \
- zlib \
icui18n \
icuuc \
icudata \
+ lcms2 \
+ libxml2 \
+ mspub \
+ odfgen \
+ visio \
+ wpd \
+ wpg \
+ zlib \
))
$(eval $(call gb_Library_add_exception_objects,wpftdraw,\
diff --git a/writerperfect/Library_wpftwriter.mk b/writerperfect/Library_wpftwriter.mk
index 00d8107..7dc5203 100644
--- a/writerperfect/Library_wpftwriter.mk
+++ b/writerperfect/Library_wpftwriter.mk
@@ -49,10 +49,11 @@ $(eval $(call gb_Library_use_static_libraries,wpftwriter,\
$(eval $(call gb_Library_use_externals,wpftwriter,\
boost_headers \
+ mwaw \
+ odfgen \
wpd \
wpg \
wps \
- mwaw \
zlib \
))
diff --git a/writerperfect/Module_writerperfect.mk b/writerperfect/Module_writerperfect.mk
index 0a9b8b5..b6a3990 100644
--- a/writerperfect/Module_writerperfect.mk
+++ b/writerperfect/Module_writerperfect.mk
@@ -21,17 +21,20 @@ $(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_ODFGEN))
$(eval $(call gb_Module_add_targets,writerperfect,\
Library_wpftdraw \
))
@@ -40,13 +43,16 @@ endif
endif
endif
endif
+endif
ifneq (,$(SYSTEM_WPD))
ifneq (,$(SYSTEM_WPG))
+ifneq (,$(SYSTEM_ODFGEN))
$(eval $(call gb_Module_add_targets,writerperfect,\
StaticLibrary_writerperfect \
))
endif
endif
+endif
# vim: set noet sw=4 ts=4:
diff --git a/writerperfect/StaticLibrary_writerperfect.mk b/writerperfect/StaticLibrary_writerperfect.mk
index e82fd0e..5fcfb95 100644
--- a/writerperfect/StaticLibrary_writerperfect.mk
+++ b/writerperfect/StaticLibrary_writerperfect.mk
@@ -26,6 +26,7 @@ $(eval $(call gb_StaticLibrary_set_include,writerperfect,\
$(eval $(call gb_StaticLibrary_use_externals,writerperfect,\
boost_headers \
+ odfgen \
wpd \
wpg \
))
@@ -36,18 +37,7 @@ $(eval $(call gb_StaticLibrary_use_api,writerperfect,\
))
$(eval $(call gb_StaticLibrary_add_exception_objects,writerperfect,\
- writerperfect/source/common/DocumentElement \
writerperfect/source/common/DocumentHandler \
- writerperfect/source/common/FilterInternal \
- writerperfect/source/common/FontStyle \
- writerperfect/source/common/InternalHandler \
- writerperfect/source/common/ListStyle \
- writerperfect/source/common/OdgGenerator \
- writerperfect/source/common/OdtGenerator \
- writerperfect/source/common/PageSpan \
- writerperfect/source/common/SectionStyle \
- writerperfect/source/common/TableStyle \
- writerperfect/source/common/TextRunStyle \
writerperfect/source/common/WPXSvStream \
))
diff --git a/writerperfect/source/common/DocumentElement.cxx b/writerperfect/source/common/DocumentElement.cxx
deleted file mode 100644
index a396950..0000000
--- a/writerperfect/source/common/DocumentElement.cxx
+++ /dev/null
@@ -1,55 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* DocumentElement: The items we are collecting to be put into the Writer
- * document: paragraph and spans of text, as well as section breaks.
- *
- * 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 "DocumentElement.hxx"
-#include "OdfDocumentHandler.hxx"
-#include "FilterInternal.hxx"
-#include <string.h>
-
-void TagElement::print() const
-{
- WRITER_DEBUG_MSG(("%s\n", msTagName.cstr()));
-}
-
-void TagOpenElement::write(OdfDocumentHandler *pHandler) const
-{
- pHandler->startElement(getTagName().cstr(), maAttrList);
-}
-
-void TagOpenElement::print() const
-{
- TagElement::print();
-}
-
-void TagOpenElement::addAttribute(const WPXString &szAttributeName, const WPXString &sAttributeValue)
-{
- maAttrList.insert(szAttributeName.cstr(), sAttributeValue);
-}
-
-void TagCloseElement::write(OdfDocumentHandler *pHandler) const
-{
- WRITER_DEBUG_MSG(("TagCloseElement: write (%s)\n", getTagName().cstr()));
-
- pHandler->endElement(getTagName().cstr());
-}
-
-void CharDataElement::write(OdfDocumentHandler *pHandler) const
-{
- WRITER_DEBUG_MSG(("TextElement: write\n"));
- pHandler->characters(msData);
-}
-
-void TextElement::write(OdfDocumentHandler *pHandler) const
-{
- if (msTextBuf.len() <= 0)
- return;
- pHandler->characters(msTextBuf);
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerperfect/source/common/DocumentElement.hxx b/writerperfect/source/common/DocumentElement.hxx
deleted file mode 100644
index 3edf85e..0000000
--- a/writerperfect/source/common/DocumentElement.hxx
+++ /dev/null
@@ -1,86 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* DocumentElement: The items we are collecting to be put into the Writer
- * document: paragraph and spans of text, as well as section breaks.
- *
- * 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/.
- *
- * For further information visit http://libwpd.sourceforge.net
- */
-
-#ifndef _DOCUMENTELEMENT_H
-#define _DOCUMENTELEMENT_H
-#include <libwpd/libwpd.h>
-#include <libwpd/WPXProperty.h>
-#include <libwpd/WPXString.h>
-#include <vector>
-
-#include "OdfDocumentHandler.hxx"
-
-class DocumentElement
-{
-public:
- virtual ~DocumentElement() {}
- virtual void write(OdfDocumentHandler *pHandler) const = 0;
- virtual void print() const {}
-};
-
-class TagElement : public DocumentElement
-{
-public:
- virtual ~TagElement() {}
- TagElement(const WPXString &szTagName) : msTagName(szTagName) {}
- const WPXString &getTagName() const
- {
- return msTagName;
- }
- virtual void print() const;
-private:
- WPXString msTagName;
-};
-
-class TagOpenElement : public TagElement
-{
-public:
- TagOpenElement(const WPXString &szTagName) : TagElement(szTagName), maAttrList() {}
- virtual ~TagOpenElement() {}
- void addAttribute(const WPXString &szAttributeName, const WPXString &sAttributeValue);
- virtual void write(OdfDocumentHandler *pHandler) const;
- virtual void print () const;
-private:
- WPXPropertyList maAttrList;
-};
-
-class TagCloseElement : public TagElement
-{
-public:
- TagCloseElement(const WPXString &szTagName) : TagElement(szTagName) {}
- virtual ~TagCloseElement() {}
- virtual void write(OdfDocumentHandler *pHandler) const;
-};
-
-class CharDataElement : public DocumentElement
-{
-public:
- CharDataElement(const WPXString &sData) : DocumentElement(), msData(sData) {}
- virtual ~CharDataElement() {}
- virtual void write(OdfDocumentHandler *pHandler) const;
-private:
- WPXString msData;
-};
-
-class TextElement : public DocumentElement
-{
-public:
- TextElement(const WPXString &sTextBuf) : DocumentElement(), msTextBuf(sTextBuf, false) {}
- virtual ~TextElement() {}
- virtual void write(OdfDocumentHandler *pHandler) const;
-
-private:
- WPXString msTextBuf;
-};
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerperfect/source/common/DocumentHandler.cxx b/writerperfect/source/common/DocumentHandler.cxx
index 67d1b5e..eae820b 100644
--- a/writerperfect/source/common/DocumentHandler.cxx
+++ b/writerperfect/source/common/DocumentHandler.cxx
@@ -7,7 +7,7 @@
* For further information visit http://libwpd.sourceforge.net
*/
#include "DocumentHandler.hxx"
-#include "FilterInternal.hxx"
+#include "WriterPerfectDebug.hxx"
#include <string.h>
#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
diff --git a/writerperfect/source/common/DocumentHandler.hxx b/writerperfect/source/common/DocumentHandler.hxx
index 381b091..be1e1f1 100644
--- a/writerperfect/source/common/DocumentHandler.hxx
+++ b/writerperfect/source/common/DocumentHandler.hxx
@@ -24,7 +24,7 @@
#include <libwpd/libwpd.h>
-#include "OdfDocumentHandler.hxx"
+#include <libodfgen/libodfgen.hxx>
using com::sun::star::uno::Reference;
using com::sun::star::xml::sax::XDocumentHandler;
diff --git a/writerperfect/source/common/FilterInternal.cxx b/writerperfect/source/common/FilterInternal.cxx
deleted file mode 100644
index 4627473..0000000
--- a/writerperfect/source/common/FilterInternal.cxx
+++ /dev/null
@@ -1,29 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* FilterInternal.hxx: define basic functions for libwriterperfect/fileter
- *
- * 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/.
- *
- * For further information visit http://libwpd.sourceforge.net
- */
-
-#include <libwpd/WPXPropertyList.h>
-
-#include "FilterInternal.hxx"
-
-WPXString propListToStyleKey(const WPXPropertyList &xPropList)
-{
- WPXString sKey;
- WPXPropertyList::Iter i(xPropList);
- for (i.rewind(); i.next(); )
- {
- WPXString sProp;
- sProp.sprintf("[%s:%s]", i.key(), i()->getStr().cstr());
- sKey.append(sProp);
- }
-
- return sKey;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerperfect/source/common/FilterInternal.hxx b/writerperfect/source/common/FilterInternal.hxx
deleted file mode 100644
index 6b5b0ab..0000000
--- a/writerperfect/source/common/FilterInternal.hxx
+++ /dev/null
@@ -1,63 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* FilterInternal: Debugging information
- *
- * 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/.
- *
- * For further information visit http://libwpd.sourceforge.net
- */
-#ifndef __FILTERINTERNAL_HXX__
-#define __FILTERINTERNAL_HXX__
-
-#include <string.h> // for strcmp
-
-#include <libwpd/libwpd.h>
-#include <libwpd/WPXString.h>
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-// used by FontStyle.cxx
-#define IMP_DEFAULT_FONT_PITCH "variable"
-
-#if 0
-const double fDefaultSideMargin = 1.0; // inches
-const double fDefaultPageWidth = 8.5f; // inches (OOo required default: we will handle this later)
-const double fDefaultPageHeight = 11.0; // inches
-#endif
-
-#ifdef DEBUG
-#include <stdio.h>
-#define WRITER_DEBUG_MSG(M) printf M
-#else
-#define WRITER_DEBUG_MSG(M)
-#endif
-
-#if defined(SHAREDPTR_TR1)
-#include <tr1/memory>
-using std::tr1::shared_ptr;
-#elif defined(SHAREDPTR_STD)
-#include <memory>
-using std::shared_ptr;
-#else
-#include <boost/shared_ptr.hpp>
-using boost::shared_ptr;
-#endif
-
-
-class WPXPropertyList;
-WPXString propListToStyleKey(const WPXPropertyList &xPropList);
-
-struct ltstr
-{
- bool operator()(const WPXString &s1, const WPXString &s2) const
- {
- return strcmp(s1.cstr(), s2.cstr()) < 0;
- }
-};
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerperfect/source/common/FontStyle.cxx b/writerperfect/source/common/FontStyle.cxx
deleted file mode 100644
index bc1a8e3..0000000
--- a/writerperfect/source/common/FontStyle.cxx
+++ /dev/null
@@ -1,74 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* FontStyle: Stores (and writes) font-based information that is needed at
- * the head of an OO document.
- *
- * 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/.
- *
- * For further information visit http://libwpd.sourceforge.net
- */
-
-#include "FilterInternal.hxx"
-
-#include "FontStyle.hxx"
-
-#include "DocumentElement.hxx"
-
-FontStyle::FontStyle(const char *psName, const char *psFontFamily) : Style(psName),
- msFontFamily(psFontFamily, true),
- msFontPitch(IMP_DEFAULT_FONT_PITCH)
-{
-}
-
-FontStyle::~FontStyle()
-{
-}
-
-void FontStyle::write(OdfDocumentHandler *pHandler) const
-{
- TagOpenElement styleOpen("style:font-face");
- styleOpen.addAttribute("style:name", getName());
- styleOpen.addAttribute("svg:font-family", msFontFamily);
- styleOpen.write(pHandler);
- TagCloseElement styleClose("style:font-face");
- styleClose.write(pHandler);
-}
-
-void FontStyleManager::clean()
-{
- mStyleHash.clear();
-}
-
-void FontStyleManager::writeFontsDeclaration(OdfDocumentHandler *pHandler) const
-{
- TagOpenElement("office:font-face-decls").write(pHandler);
- std::map<WPXString, shared_ptr<FontStyle>, ltstr>::const_iterator iter;
- for (iter = mStyleHash.begin(); iter != mStyleHash.end(); ++iter)
- {
- (iter->second)->write(pHandler);
- }
-
- TagOpenElement symbolFontOpen("style:font-face");
- symbolFontOpen.addAttribute("style:name", "StarSymbol");
- symbolFontOpen.addAttribute("svg:font-family", "StarSymbol");
- symbolFontOpen.addAttribute("style:font-charset", "x-symbol");
- symbolFontOpen.write(pHandler);
- pHandler->endElement("style:font-face");
-
- pHandler->endElement("office:font-face-decls");
-}
-
-WPXString FontStyleManager::findOrAdd(const char *psFontFamily)
-{
- std::map<WPXString, shared_ptr<FontStyle>, ltstr>::const_iterator iter =
- mStyleHash.find(psFontFamily);
- if (iter!=mStyleHash.end()) return psFontFamily;
-
- // ok create a new font
- shared_ptr<FontStyle> font(new FontStyle(psFontFamily, psFontFamily));
- mStyleHash[psFontFamily] = font;
- return psFontFamily;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerperfect/source/common/FontStyle.hxx b/writerperfect/source/common/FontStyle.hxx
deleted file mode 100644
index b050cf6..0000000
--- a/writerperfect/source/common/FontStyle.hxx
+++ /dev/null
@@ -1,65 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* FontStyle: Stores (and writes) font-based information that is needed at
- * the head of an OO document.
- *
- * 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/.
- *
- * For further information visit http://libwpd.sourceforge.net
- */
-
-#ifndef _FONTSTYLE_H
-#define _FONTSTYLE_H
-#include <map>
-
-#include <libwpd/libwpd.h>
-
-#include "FilterInternal.hxx"
-
-#include "Style.hxx"
-
-class FontStyle : public Style
-{
-public:
- FontStyle(const char *psName, const char *psFontFamily);
- ~FontStyle();
- virtual void write(OdfDocumentHandler *pHandler) const;
- const WPXString &getFontFamily() const
- {
- return msFontFamily;
- }
-
-private:
- WPXString msFontFamily;
- WPXString msFontPitch;
-};
-
-class FontStyleManager : public StyleManager
-{
-public:
- FontStyleManager() : mStyleHash() {}
- virtual ~FontStyleManager()
- {
- clean();
- }
-
- /* create a new font if the font does not exists and returns a font name
-
- Note: the returned font name is actually equalled to psFontFamily
- */
- WPXString findOrAdd(const char *psFontFamily);
-
- virtual void clean();
- virtual void write(OdfDocumentHandler *) const {}
- virtual void writeFontsDeclaration(OdfDocumentHandler *) const;
-
-
-protected:
- // style name -> SpanStyle
- std::map<WPXString, shared_ptr<FontStyle>, ltstr> mStyleHash;
-};
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerperfect/source/common/InternalHandler.cxx b/writerperfect/source/common/InternalHandler.cxx
deleted file mode 100644
index a901336..0000000
--- a/writerperfect/source/common/InternalHandler.cxx
+++ /dev/null
@@ -1,44 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
-
-/* "This product is not manufactured, approved, or supported by
- * Corel Corporation or Corel Corporation Limited."
- */
-
-#include "InternalHandler.hxx"
-
-#include <string.h>
-
-InternalHandler::InternalHandler(std::vector<DocumentElement *> *elements):
- mpElements(elements)
-{
-}
-
-void InternalHandler::startElement(const char *psName, const WPXPropertyList &xPropList)
-{
- TagOpenElement *element = new TagOpenElement(psName);
- WPXPropertyList::Iter i(xPropList);
- for (i.rewind(); i.next(); )
- {
- // filter out libwpd elements
- if (strncmp(i.key(), "libwpd", 6) != 0)
- element->addAttribute(i.key(), i()->getStr());
- }
- mpElements->push_back(element);
-}
-
-void InternalHandler::endElement(const char *psName)
-{
- mpElements->push_back(new TagCloseElement(psName));
-}
-
-void InternalHandler::characters(const WPXString &sCharacters)
-{
- mpElements->push_back(new CharDataElement(sCharacters.cstr()));
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerperfect/source/common/InternalHandler.hxx b/writerperfect/source/common/InternalHandler.hxx
deleted file mode 100644
index a07e83a..0000000
--- a/writerperfect/source/common/InternalHandler.hxx
+++ /dev/null
@@ -1,38 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
-
-/* "This product is not manufactured, approved, or supported by
- * Corel Corporation or Corel Corporation Limited."
- */
-
-#ifndef _INTERNALHANDLER_H
-#define _INTERNALHANDLER_H
-#include <libwpd/libwpd.h>
-#include <libwpd/WPXProperty.h>
-#include <libwpd/WPXString.h>
-#include "DocumentElement.hxx"
-#include "OdfDocumentHandler.hxx"
-
-class InternalHandler : public OdfDocumentHandler
-{
-public:
- InternalHandler(std::vector<DocumentElement *> *elements);
- ~InternalHandler() {};
-
- void startDocument() {};
- void endDocument() {};
- void startElement(const char *psName, const WPXPropertyList &xPropList);
- void endElement(const char *psName);
- void characters(const WPXString &sCharacters);
-private:
- InternalHandler(const InternalHandler &);
- InternalHandler &operator=(const InternalHandler &);
- std::vector<DocumentElement *> *mpElements;
-};
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerperfect/source/common/ListStyle.cxx b/writerperfect/source/common/ListStyle.cxx
deleted file mode 100644
index 1b6cf5c..0000000
--- a/writerperfect/source/common/ListStyle.cxx
+++ /dev/null
@@ -1,178 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ListStyle: Stores (and writes) list-based information that is
- * needed at the head of an OO document.
- *
- * 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 product is not manufactured, approved, or supported by
- * Corel Corporation or Corel Corporation Limited."
- */
-#include "FilterInternal.hxx"
-#include "ListStyle.hxx"
-#include "DocumentElement.hxx"
-
-OrderedListLevelStyle::OrderedListLevelStyle(const WPXPropertyList &xPropList) :
- mPropList(xPropList)
-{
-}
-
-void OrderedListLevelStyle::write(OdfDocumentHandler *pHandler, int iLevel) const
-{
- WPXString sLevel;
- sLevel.sprintf("%i", (iLevel+1));
-
- TagOpenElement listLevelStyleOpen("text:list-level-style-number");
- listLevelStyleOpen.addAttribute("text:level", sLevel);
- listLevelStyleOpen.addAttribute("text:style-name", "Numbering_Symbols");
- if (mPropList["style:num-prefix"])
- {
- WPXString sEscapedString(mPropList["style:num-prefix"]->getStr(), true);
- listLevelStyleOpen.addAttribute("style:num-prefix", sEscapedString);
- }
- if (mPropList["style:num-suffix"])
- {
- WPXString sEscapedString(mPropList["style:num-suffix"]->getStr(), true);
- listLevelStyleOpen.addAttribute("style:num-suffix", sEscapedString);
- }
- if (mPropList["style:num-format"])
- listLevelStyleOpen.addAttribute("style:num-format", mPropList["style:num-format"]->getStr());
- if (mPropList["text:start-value"])
- {
- // ODF as to the version 1.1 does require the text:start-value to be a positive integer, means > 0
- if (mPropList["text:start-value"]->getInt() > 0)
- listLevelStyleOpen.addAttribute("text:start-value", mPropList["text:start-value"]->getStr());
- else
- listLevelStyleOpen.addAttribute("text:start-value", "1");
- }
- if (mPropList["text:display-levels"])
- listLevelStyleOpen.addAttribute("text:display-levels", mPropList["text:display-levels"]->getStr());
- listLevelStyleOpen.write(pHandler);
-
- TagOpenElement stylePropertiesOpen("style:list-level-properties");
- if (mPropList["text:space-before"] && mPropList["text:space-before"]->getDouble() > 0.0)
- stylePropertiesOpen.addAttribute("text:space-before", mPropList["text:space-before"]->getStr());
- if (mPropList["text:min-label-width"] && mPropList["text:min-label-width"]->getDouble() > 0.0)
- stylePropertiesOpen.addAttribute("text:min-label-width", mPropList["text:min-label-width"]->getStr());
- if (mPropList["text:min-label-distance"] && mPropList["text:min-label-distance"]->getDouble() > 0.0)
- stylePropertiesOpen.addAttribute("text:min-label-distance", mPropList["text:min-label-distance"]->getStr());
- if (mPropList["fo:text-align"])
- stylePropertiesOpen.addAttribute("fo:text-align", mPropList["fo:text-align"]->getStr());
- stylePropertiesOpen.write(pHandler);
-
- pHandler->endElement("style:list-level-properties");
- pHandler->endElement("text:list-level-style-number");
-}
-
-UnorderedListLevelStyle::UnorderedListLevelStyle(const WPXPropertyList &xPropList)
- : mPropList(xPropList)
-{
-}
-
-void UnorderedListLevelStyle::write(OdfDocumentHandler *pHandler, int iLevel) const
-{
- WPXString sLevel;
- sLevel.sprintf("%i", (iLevel+1));
- TagOpenElement listLevelStyleOpen("text:list-level-style-bullet");
- listLevelStyleOpen.addAttribute("text:level", sLevel);
- listLevelStyleOpen.addAttribute("text:style-name", "Bullet_Symbols");
- if (mPropList["text:bullet-char"] && (mPropList["text:bullet-char"]->getStr().len()))
- {
- // The following is needed because the ODF format does not accept bullet chars longer than one character
- WPXString::Iter i(mPropList["text:bullet-char"]->getStr());
- i.rewind();
- WPXString sEscapedString(".");
- if (i.next())
- sEscapedString = WPXString(i(), true);
- listLevelStyleOpen.addAttribute("text:bullet-char", sEscapedString);
-
- }
- else
- listLevelStyleOpen.addAttribute("text:bullet-char", ".");
- if (mPropList["text:display-levels"])
- listLevelStyleOpen.addAttribute("text:display-levels", mPropList["text:display-levels"]->getStr());
- listLevelStyleOpen.write(pHandler);
-
- TagOpenElement stylePropertiesOpen("style:list-level-properties");
- if (mPropList["text:space-before"] && mPropList["text:space-before"]->getDouble() > 0.0)
- stylePropertiesOpen.addAttribute("text:space-before", mPropList["text:space-before"]->getStr());
- if (mPropList["text:min-label-width"] && mPropList["text:min-label-width"]->getDouble() > 0.0)
- stylePropertiesOpen.addAttribute("text:min-label-width", mPropList["text:min-label-width"]->getStr());
- if (mPropList["text:min-label-distance"] && mPropList["text:min-label-distance"]->getDouble() > 0.0)
- stylePropertiesOpen.addAttribute("text:min-label-distance", mPropList["text:min-label-distance"]->getStr());
- if (mPropList["fo:text-align"])
- stylePropertiesOpen.addAttribute("fo:text-align", mPropList["fo:text-align"]->getStr());
- stylePropertiesOpen.addAttribute("style:font-name", "OpenSymbol");
- stylePropertiesOpen.write(pHandler);
-
- pHandler->endElement("style:list-level-properties");
- pHandler->endElement("text:list-level-style-bullet");
-}
-
-ListStyle::ListStyle(const char *psName, const int iListID) :
- Style(psName),
- miListID(iListID)
-{
- for (int i=0; i<WP6_NUM_LIST_LEVELS; ++i)
- mppListLevels[i] = 0;
-
-}
-
-ListStyle::~ListStyle()
-{
- for (int i=0; i<WP6_NUM_LIST_LEVELS; ++i)
- {
- if (mppListLevels[i])
- delete(mppListLevels[i]);
- }
-
-}
-
-bool ListStyle::isListLevelDefined(int iLevel) const
-{
- if (!mppListLevels[iLevel])
- return false;
-
- return true;
-}
-
-void ListStyle::setListLevel(int iLevel, ListLevelStyle *iListLevelStyle)
-{
- // can't uncomment this next line without adding some extra logic.
- // figure out which is best: use the initial message, or constantly
- // update?
- if (!mppListLevels[iLevel])
- mppListLevels[iLevel] = iListLevelStyle;
-}
-
-void ListStyle::updateListLevel(const int iLevel, const WPXPropertyList &xPropList, bool ordered)
-{
- if (iLevel < 0)
- return;
- if (!isListLevelDefined(iLevel))
- {
- if (ordered)
- setListLevel(iLevel, new OrderedListLevelStyle(xPropList));
- else
- setListLevel(iLevel, new UnorderedListLevelStyle(xPropList));
- }
-}
-
-void ListStyle::write(OdfDocumentHandler *pHandler) const
-{
- TagOpenElement listStyleOpenElement("text:list-style");
- listStyleOpenElement.addAttribute("style:name", getName());
- listStyleOpenElement.write(pHandler);
-
- for (int i=0; i<WP6_NUM_LIST_LEVELS; ++i)
- {
- if (mppListLevels[i])
- mppListLevels[i]->write(pHandler, i);
- }
-
- pHandler->endElement("text:list-style");
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerperfect/source/common/ListStyle.hxx b/writerperfect/source/common/ListStyle.hxx
deleted file mode 100644
index 53ee67e..0000000
--- a/writerperfect/source/common/ListStyle.hxx
+++ /dev/null
@@ -1,69 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ListStyle: Stores (and writes) list-based information that is
- * needed at the head of an OO document.
- *
- * 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 product is not manufactured, approved, or supported by
- * Corel Corporation or Corel Corporation Limited."
- */
-#ifndef _LISTSTYLE_H
-#define _LISTSTYLE_H
-#include <libwpd/libwpd.h>
-
-#define WP6_NUM_LIST_LEVELS 8 // see WP6FileStructure.h (we shouldn't need to reference this)
-
-#include "Style.hxx"
-
-class ListLevelStyle
-{
-public:
- virtual ~ListLevelStyle() {};
- virtual void write(OdfDocumentHandler *pHandler, int iLevel) const = 0;
-};
-
-class OrderedListLevelStyle : public ListLevelStyle
-{
-public:
- OrderedListLevelStyle(const WPXPropertyList &xPropList);
- void write(OdfDocumentHandler *pHandler, int iLevel) const;
-private:
- WPXPropertyList mPropList;
-};
-
-class UnorderedListLevelStyle : public ListLevelStyle
-{
-public:
- UnorderedListLevelStyle(const WPXPropertyList &xPropList);
- void write(OdfDocumentHandler *pHandler, int iLevel) const;
-private:
- WPXPropertyList mPropList;
-};
-
-class ListStyle : public Style
-{
-public:
- ListStyle(const char *psName, const int iListID);
- virtual ~ListStyle();
- void updateListLevel(const int iLevel, const WPXPropertyList &xPropList, bool ordered);
- virtual void write(OdfDocumentHandler *pHandler) const;
- int getListID()
- {
- return miListID;
- }
- bool isListLevelDefined(int iLevel) const;
-
-protected:
- void setListLevel(int iLevel, ListLevelStyle *iListLevelStyle);
-
-private:
- ListLevelStyle *mppListLevels[WP6_NUM_LIST_LEVELS];
- const int miListID;
-};
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerperfect/source/common/OdfDocumentHandler.hxx b/writerperfect/source/common/OdfDocumentHandler.hxx
deleted file mode 100644
index 886e9b7..0000000
--- a/writerperfect/source/common/OdfDocumentHandler.hxx
+++ /dev/null
@@ -1,28 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
-
-#ifndef _DOCUMENTHANDLER_H
-#define _DOCUMENTHANDLER_H
-#include <libwpd/libwpd.h>
-
-enum OdfStreamType { ODF_FLAT_XML, ODF_CONTENT_XML, ODF_STYLES_XML, ODF_SETTINGS_XML, ODF_META_XML };
-
-class OdfDocumentHandler
-{
-public:
- OdfDocumentHandler() {};
- virtual ~OdfDocumentHandler() {};
-
- virtual void startDocument() = 0;
- virtual void endDocument() = 0;
- virtual void startElement(const char *psName, const WPXPropertyList &xPropList) = 0;
- virtual void endElement(const char *psName) = 0;
- virtual void characters(const WPXString &sCharacters) = 0;
-};
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerperfect/source/common/OdgGenerator.cxx b/writerperfect/source/common/OdgGenerator.cxx
deleted file mode 100644
index d166a09..0000000
--- a/writerperfect/source/common/OdgGenerator.cxx
+++ /dev/null
@@ -1,1756 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * For further information visit http://libwpg.sourceforge.net
- */
-
-#include "FilterInternal.hxx"
-
-#include "OdgGenerator.hxx"
-#include "DocumentElement.hxx"
-#include "OdfDocumentHandler.hxx"
-#include "TextRunStyle.hxx"
-#include "FontStyle.hxx"
-#include <locale.h>
-#include <math.h>
-#include <string>
-#include <map>
-
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
-
-// Workaround for the incapacity of draw to have multiple page
-// sizes in the same document. Once that limitation is lifted,
-// remove this
-#define MULTIPAGE_WORKAROUND 1
-
-namespace
-{
-
-static inline double getAngle(double bx, double by)
-{
- return fmod(2*M_PI + (by > 0.0 ? 1.0 : -1.0) * acos( bx / sqrt(bx * bx + by * by) ), 2*M_PI);
-}
-
-static void getEllipticalArcBBox(double x0, double y0,
- double rx, double ry, double phi, bool largeArc, bool sweep, double x, double y,
- double &xmin, double &ymin, double &xmax, double &ymax)
-{
- phi *= M_PI/180;
- if (rx < 0.0)
- rx *= -1.0;
- if (ry < 0.0)
- ry *= -1.0;
-
- if (rx == 0.0 || ry == 0.0)
- {
- xmin = (x0 < x ? x0 : x);
- xmax = (x0 > x ? x0 : x);
- ymin = (y0 < y ? y0 : y);
- ymax = (y0 > y ? y0 : y);
- return;
- }
-
- // F.6.5.1
- const double x1prime = cos(phi)*(x0 - x)/2 + sin(phi)*(y0 - y)/2;
- const double y1prime = -sin(phi)*(x0 - x)/2 + cos(phi)*(y0 - y)/2;
-
- // F.6.5.2
- double radicant = (rx*rx*ry*ry - rx*rx*y1prime*y1prime - ry*ry*x1prime*x1prime)/(rx*rx*y1prime*y1prime + ry*ry*x1prime*x1prime);
- double cxprime = 0.0;
- double cyprime = 0.0;
- if (radicant < 0.0)
- {
- double ratio = rx/ry;
- radicant = y1prime*y1prime + x1prime*x1prime/(ratio*ratio);
- if (radicant < 0.0)
- {
- xmin = (x0 < x ? x0 : x);
- xmax = (x0 > x ? x0 : x);
- ymin = (y0 < y ? y0 : y);
- ymax = (y0 > y ? y0 : y);
- return;
- }
- ry=sqrt(radicant);
- rx=ratio*ry;
- }
- else
- {
- double factor = (largeArc==sweep ? -1.0 : 1.0)*sqrt(radicant);
-
- cxprime = factor*rx*y1prime/ry;
- cyprime = -factor*ry*x1prime/rx;
- }
-
- // F.6.5.3
- double cx = cxprime*cos(phi) - cyprime*sin(phi) + (x0 + x)/2;
- double cy = cxprime*sin(phi) + cyprime*cos(phi) + (y0 + y)/2;
-
- // now compute bounding box of the whole ellipse
-
- // Parametric equation of an ellipse:
- // x(theta) = cx + rx*cos(theta)*cos(phi) - ry*sin(theta)*sin(phi)
- // y(theta) = cy + rx*cos(theta)*sin(phi) + ry*sin(theta)*cos(phi)
-
- // Compute local extrems
- // 0 = -rx*sin(theta)*cos(phi) - ry*cos(theta)*sin(phi)
- // 0 = -rx*sin(theta)*sin(phi) - ry*cos(theta)*cos(phi)
-
- // Local extrems for X:
- // theta = -atan(ry*tan(phi)/rx)
- // and
- // theta = M_PI -atan(ry*tan(phi)/rx)
-
- // Local extrems for Y:
- // theta = atan(ry/(tan(phi)*rx))
- // and
- // theta = M_PI + atan(ry/(tan(phi)*rx))
-
- double txmin, txmax, tymin, tymax;
-
- // First handle special cases
- if (phi == 0 || phi == M_PI)
- {
- xmin = cx - rx;
- txmin = getAngle(-rx, 0);
- xmax = cx + rx;
- txmax = getAngle(rx, 0);
- ymin = cy - ry;
- tymin = getAngle(0, -ry);
- ymax = cy + ry;
- tymax = getAngle(0, ry);
- }
- else if (phi == M_PI / 2.0 || phi == 3.0*M_PI/2.0)
- {
- xmin = cx - ry;
- txmin = getAngle(-ry, 0);
- xmax = cx + ry;
- txmax = getAngle(ry, 0);
- ymin = cy - rx;
- tymin = getAngle(0, -rx);
- ymax = cy + rx;
- tymax = getAngle(0, rx);
- }
- else
- {
- txmin = -atan(ry*tan(phi)/rx);
- txmax = M_PI - atan (ry*tan(phi)/rx);
- xmin = cx + rx*cos(txmin)*cos(phi) - ry*sin(txmin)*sin(phi);
- xmax = cx + rx*cos(txmax)*cos(phi) - ry*sin(txmax)*sin(phi);
- double tmpY = cy + rx*cos(txmin)*sin(phi) + ry*sin(txmin)*cos(phi);
- txmin = getAngle(xmin - cx, tmpY - cy);
- tmpY = cy + rx*cos(txmax)*sin(phi) + ry*sin(txmax)*cos(phi);
- txmax = getAngle(xmax - cx, tmpY - cy);
-
- tymin = atan(ry/(tan(phi)*rx));
- tymax = atan(ry/(tan(phi)*rx))+M_PI;
- ymin = cy + rx*cos(tymin)*sin(phi) + ry*sin(tymin)*cos(phi);
- ymax = cy + rx*cos(tymax)*sin(phi) + ry*sin(tymax)*cos(phi);
- double tmpX = cx + rx*cos(tymin)*cos(phi) - ry*sin(tymin)*sin(phi);
- tymin = getAngle(tmpX - cx, ymin - cy);
- tmpX = cx + rx*cos(tymax)*cos(phi) - ry*sin(tymax)*sin(phi);
- tymax = getAngle(tmpX - cx, ymax - cy);
- }
- if (xmin > xmax)
- {
- std::swap(xmin,xmax);
- std::swap(txmin,txmax);
- }
- if (ymin > ymax)
- {
- std::swap(ymin,ymax);
- std::swap(tymin,tymax);
- }
- double angle1 = getAngle(x0 - cx, y0 - cy);
- double angle2 = getAngle(x - cx, y - cy);
-
- // for sweep == 0 it is normal to have delta theta < 0
- // but we don't care about the rotation direction for bounding box
- if (!sweep)
- std::swap(angle1, angle2);
-
- // We cannot check directly for whether an angle is included in
- // an interval of angles that cross the 360/0 degree boundary
- // So here we will have to check for their absence in the complementary
- // angle interval
- bool otherArc = false;
- if (angle1 > angle2)
- {
- std::swap(angle1, angle2);
- otherArc = true;
- }
-
- // Check txmin
- if ((!otherArc && (angle1 > txmin || angle2 < txmin)) || (otherArc && !(angle1 > txmin || angle2 < txmin)))
- xmin = x0 < x ? x0 : x;
- // Check txmax
- if ((!otherArc && (angle1 > txmax || angle2 < txmax)) || (otherArc && !(angle1 > txmax || angle2 < txmax)))
- xmax = x0 > x ? x0 : x;
- // Check tymin
- if ((!otherArc && (angle1 > tymin || angle2 < tymin)) || (otherArc && !(angle1 > tymin || angle2 < tymin)))
- ymin = y0 < y ? y0 : y;
- // Check tymax
- if ((!otherArc && (angle1 > tymax || angle2 < tymax)) || (otherArc && !(angle1 > tymax || angle2 < tymax)))
- ymax = y0 > y ? y0 : y;
-}
-
-static inline double quadraticExtreme(double t, double a, double b, double c)
-{
- return (1.0-t)*(1.0-t)*a + 2.0*(1.0-t)*t*b + t*t*c;
-}
-
-static inline double quadraticDerivative(double a, double b, double c)
-{
- double denominator = a - 2.0*b + c;
- if (fabs(denominator) != 0.0)
- return (a - b)/denominator;
- return -1.0;
-}
-
-static void getQuadraticBezierBBox(double x0, double y0, double x1, double y1, double x, double y,
- double &xmin, double &ymin, double &xmax, double &ymax)
-{
- xmin = x0 < x ? x0 : x;
- xmax = x0 > x ? x0 : x;
- ymin = y0 < y ? y0 : y;
- ymax = y0 > y ? y0 : y;
-
- double t = quadraticDerivative(x0, x1, x);
- if(t>=0 && t<=1)
- {
- double tmpx = quadraticExtreme(t, x0, x1, x);
- xmin = tmpx < xmin ? tmpx : xmin;
- xmax = tmpx > xmax ? tmpx : xmax;
- }
-
- t = quadraticDerivative(y0, y1, y);
- if(t>=0 && t<=1)
- {
- double tmpy = quadraticExtreme(t, y0, y1, y);
- ymin = tmpy < ymin ? tmpy : ymin;
- ymax = tmpy > ymax ? tmpy : ymax;
- }
-}
-
-static inline double cubicBase(double t, double a, double b, double c, double d)
-{
- return (1.0-t)*(1.0-t)*(1.0-t)*a + 3.0*(1.0-t)*(1.0-t)*t*b + 3.0*(1.0-t)*t*t*c + t*t*t*d;
-}
-
-static void getCubicBezierBBox(double x0, double y0, double x1, double y1, double x2, double y2, double x, double y,
- double &xmin, double &ymin, double &xmax, double &ymax)
-{
- xmin = x0 < x ? x0 : x;
- xmax = x0 > x ? x0 : x;
- ymin = y0 < y ? y0 : y;
- ymax = y0 > y ? y0 : y;
-
- for (double t = 0.0; t <= 1.0; t+=0.01)
- {
- double tmpx = cubicBase(t, x0, x1, x2, x);
- xmin = tmpx < xmin ? tmpx : xmin;
- xmax = tmpx > xmax ? tmpx : xmax;
- double tmpy = cubicBase(t, y0, y1, y2, y);
- ymin = tmpy < ymin ? tmpy : ymin;
- ymax = tmpy > ymax ? tmpy : ymax;
- }
-}
-
-
-static WPXString doubleToString(const double value)
-{
- WPXString tempString;
- tempString.sprintf("%.4f", value);
-#ifndef ANDROID
- std::string decimalPoint(localeconv()->decimal_point);
-#else
- std::string decimalPoint(".");
-#endif
- if (decimalPoint.empty() || (decimalPoint == "."))
- return tempString;
- std::string stringValue(tempString.cstr());
- if (!stringValue.empty())
- {
- std::string::size_type pos;
- while ((pos = stringValue.find(decimalPoint)) != std::string::npos)
- stringValue.replace(pos,decimalPoint.size(),".");
- }
- return WPXString(stringValue.c_str());
-}
-
-} // anonymous namespace
-
-class OdgGeneratorPrivate
-{
-public:
- OdgGeneratorPrivate(OdfDocumentHandler *pHandler, const OdfStreamType streamType);
- ~OdgGeneratorPrivate();
- void _writeGraphicsStyle();
- void _drawPolySomething(const ::WPXPropertyListVector &vertices, bool isClosed);
- void _drawPath(const WPXPropertyListVector &path);
- // body elements
- std::vector <DocumentElement *> mBodyElements;
-
- // graphics styles
- std::vector<DocumentElement *> mGraphicsStrokeDashStyles;
- std::vector<DocumentElement *> mGraphicsGradientStyles;
- std::vector<DocumentElement *> mGraphicsBitmapStyles;
- std::vector<DocumentElement *> mGraphicsMarkerStyles;
- std::vector<DocumentElement *> mGraphicsAutomaticStyles;
-
- // page styles
- std::vector<DocumentElement *> mPageAutomaticStyles;
- std::vector<DocumentElement *> mPageMasterStyles;
-
- // paragraph styles
- ParagraphStyleManager mParagraphManager;
-
- // span styles
- SpanStyleManager mSpanManager;
-
- // font styles
- FontStyleManager mFontManager;
-
- OdfDocumentHandler *mpHandler;
-
- ::WPXPropertyList mxStyle;
- ::WPXPropertyListVector mxGradient;
- ::WPXPropertyListVector mxMarker;
- int miGradientIndex;
- int miBitmapIndex;
- int miStartMarkerIndex;
- int miEndMarkerIndex;
- int miDashIndex;
- int miGraphicsStyleIndex;
- int miPageIndex;
- double mfWidth, mfMaxWidth;
- double mfHeight, mfMaxHeight;
-
- const OdfStreamType mxStreamType;
-
- bool mbIsTextBox;
- bool mbIsTextLine;
- bool mbIsTextOnPath;
-};
-
-OdgGeneratorPrivate::OdgGeneratorPrivate(OdfDocumentHandler *pHandler, const OdfStreamType streamType):
- mBodyElements(),
- mGraphicsStrokeDashStyles(),
- mGraphicsGradientStyles(),
- mGraphicsBitmapStyles(),
- mGraphicsAutomaticStyles(),
- mPageAutomaticStyles(),
- mPageMasterStyles(),
- mParagraphManager(),
- mSpanManager(),
- mFontManager(),
- mpHandler(pHandler),
- mxStyle(), mxGradient(),
- mxMarker(),
- miGradientIndex(1),
- miBitmapIndex(1),
- miStartMarkerIndex(1),
- miEndMarkerIndex(1),
- miDashIndex(1),
- miGraphicsStyleIndex(1),
- miPageIndex(1),
- mfWidth(0.0),
- mfMaxWidth(0.0),
- mfHeight(0.0),
- mfMaxHeight(0.0),
- mxStreamType(streamType),
- mbIsTextBox(false),
- mbIsTextLine(false),
- mbIsTextOnPath(false)
-{
-}
-
-OdgGeneratorPrivate::~OdgGeneratorPrivate()
-{
-
- for (std::vector<DocumentElement *>::iterator iterBody = mBodyElements.begin(); iterBody != mBodyElements.end(); ++iterBody)
- {
- delete (*iterBody);
- (*iterBody) = 0;
- }
-
- for (std::vector<DocumentElement *>::iterator iterGraphicsAutomaticStyles = mGraphicsAutomaticStyles.begin();
- iterGraphicsAutomaticStyles != mGraphicsAutomaticStyles.end(); ++iterGraphicsAutomaticStyles)
- {
- delete((*iterGraphicsAutomaticStyles));
- }
-
- for (std::vector<DocumentElement *>::iterator iterGraphicsStrokeDashStyles = mGraphicsStrokeDashStyles.begin();
- iterGraphicsStrokeDashStyles != mGraphicsStrokeDashStyles.end(); ++iterGraphicsStrokeDashStyles)
- {
- delete((*iterGraphicsStrokeDashStyles));
- }
-
- for (std::vector<DocumentElement *>::iterator iterGraphicsGradientStyles = mGraphicsGradientStyles.begin();
- iterGraphicsGradientStyles != mGraphicsGradientStyles.end(); ++iterGraphicsGradientStyles)
- {
- delete((*iterGraphicsGradientStyles));
- }
-
- for (std::vector<DocumentElement *>::iterator iterGraphicsBitmapStyles = mGraphicsBitmapStyles.begin();
- iterGraphicsBitmapStyles != mGraphicsBitmapStyles.end(); ++iterGraphicsBitmapStyles)
- {
- delete((*iterGraphicsBitmapStyles));
- }
-
- for (std::vector<DocumentElement *>::iterator iterGraphicsMarkerStyles = mGraphicsMarkerStyles.begin();
- iterGraphicsMarkerStyles != mGraphicsMarkerStyles.end(); ++iterGraphicsMarkerStyles)
- {
- delete((*iterGraphicsMarkerStyles));
- }
-
- for (std::vector<DocumentElement *>::iterator iterPageAutomaticStyles = mPageAutomaticStyles.begin();
- iterPageAutomaticStyles != mPageAutomaticStyles.end(); ++iterPageAutomaticStyles)
- {
- delete((*iterPageAutomaticStyles));
- }
-
- for (std::vector<DocumentElement *>::iterator iterPageMasterStyles = mPageMasterStyles.begin();
- iterPageMasterStyles != mPageMasterStyles.end(); ++iterPageMasterStyles)
- {
- delete((*iterPageMasterStyles));
- }
-
- mParagraphManager.clean();
- mSpanManager.clean();
- mFontManager.clean();
-}
-
-
-OdgGenerator::OdgGenerator(OdfDocumentHandler *pHandler, const OdfStreamType streamType):
- mpImpl(new OdgGeneratorPrivate(pHandler, streamType))
-{
- mpImpl->mpHandler->startDocument();
- TagOpenElement tmpOfficeDocumentContent(
- (mpImpl->mxStreamType == ODF_FLAT_XML) ? "office:document" : (
- (mpImpl->mxStreamType == ODF_CONTENT_XML) ? "office:document-content" : (
- (mpImpl->mxStreamType == ODF_STYLES_XML) ? "office:document-styles" : (
- (mpImpl->mxStreamType == ODF_SETTINGS_XML) ? "office:document-settings" : (
- (mpImpl->mxStreamType == ODF_META_XML) ? "office:document-meta" : "office:document" )))));
- tmpOfficeDocumentContent.addAttribute("xmlns:office", "urn:oasis:names:tc:opendocument:xmlns:office:1.0");
- tmpOfficeDocumentContent.addAttribute("xmlns:style", "urn:oasis:names:tc:opendocument:xmlns:style:1.0");
- tmpOfficeDocumentContent.addAttribute("xmlns:text", "urn:oasis:names:tc:opendocument:xmlns:text:1.0");
- tmpOfficeDocumentContent.addAttribute("xmlns:draw", "urn:oasis:names:tc:opendocument:xmlns:drawing:1.0");
- tmpOfficeDocumentContent.addAttribute("xmlns:dc", "http://purl.org/dc/elements/1.1/");
- tmpOfficeDocumentContent.addAttribute("xmlns:svg", "urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0");
- tmpOfficeDocumentContent.addAttribute("xmlns:fo", "urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0");
- tmpOfficeDocumentContent.addAttribute("xmlns:config", "urn:oasis:names:tc:opendocument:xmlns:config:1.0");
- tmpOfficeDocumentContent.addAttribute("xmlns:ooo", "http://openoffice.org/2004/office");
- tmpOfficeDocumentContent.addAttribute("office:version", "1.0");
- if (mpImpl->mxStreamType == ODF_FLAT_XML)
- tmpOfficeDocumentContent.addAttribute("office:mimetype", "application/vnd.oasis.opendocument.graphics");
- tmpOfficeDocumentContent.write(mpImpl->mpHandler);
-}
-
-OdgGenerator::~OdgGenerator()
-{
- if ((mpImpl->mxStreamType == ODF_FLAT_XML) || (mpImpl->mxStreamType == ODF_SETTINGS_XML))
- {
- TagOpenElement("office:settings").write(mpImpl->mpHandler);
-
- TagOpenElement configItemSetOpenElement("config:config-item-set");
- configItemSetOpenElement.addAttribute("config:name", "ooo:view-settings");
- configItemSetOpenElement.write(mpImpl->mpHandler);
-
- TagOpenElement configItemOpenElement("config:config-item");
-
- configItemOpenElement.addAttribute("config:name", "VisibleAreaTop");
- configItemOpenElement.addAttribute("config:type", "int");
- configItemOpenElement.write(mpImpl->mpHandler);
- mpImpl->mpHandler->characters("0");
- mpImpl->mpHandler->endElement("config:config-item");
-
- configItemOpenElement.addAttribute("config:name", "VisibleAreaLeft");
- configItemOpenElement.addAttribute("config:type", "int");
- configItemOpenElement.write(mpImpl->mpHandler);
- mpImpl->mpHandler->characters("0");
- mpImpl->mpHandler->endElement("config:config-item");
-
- configItemOpenElement.addAttribute("config:name", "VisibleAreaWidth");
- configItemOpenElement.addAttribute("config:type", "int");
- configItemOpenElement.write(mpImpl->mpHandler);
- WPXString sWidth;
- sWidth.sprintf("%li", (unsigned long)(2540 * mpImpl->mfMaxWidth));
- mpImpl->mpHandler->characters(sWidth);
- mpImpl->mpHandler->endElement("config:config-item");
-
- configItemOpenElement.addAttribute("config:name", "VisibleAreaHeight");
- configItemOpenElement.addAttribute("config:type", "int");
- configItemOpenElement.write(mpImpl->mpHandler);
- WPXString sHeight;
- sHeight.sprintf("%li", (unsigned long)(2540 * mpImpl->mfMaxHeight));
- mpImpl->mpHandler->characters(sHeight);
- mpImpl->mpHandler->endElement("config:config-item");
-
- mpImpl->mpHandler->endElement("config:config-item-set");
-
- mpImpl->mpHandler->endElement("office:settings");
- }
-
-
- if ((mpImpl->mxStreamType == ODF_FLAT_XML) || (mpImpl->mxStreamType == ODF_STYLES_XML))
- {
- TagOpenElement("office:styles").write(mpImpl->mpHandler);
-
- for (std::vector<DocumentElement *>::const_iterator iterGraphicsStrokeDashStyles = mpImpl->mGraphicsStrokeDashStyles.begin();
- iterGraphicsStrokeDashStyles != mpImpl->mGraphicsStrokeDashStyles.end(); ++iterGraphicsStrokeDashStyles)
- {
- (*iterGraphicsStrokeDashStyles)->write(mpImpl->mpHandler);
- }
-
- for (std::vector<DocumentElement *>::const_iterator iterGraphicsGradientStyles = mpImpl->mGraphicsGradientStyles.begin();
- iterGraphicsGradientStyles != mpImpl->mGraphicsGradientStyles.end(); ++iterGraphicsGradientStyles)
- {
- (*iterGraphicsGradientStyles)->write(mpImpl->mpHandler);
- }
-
- for (std::vector<DocumentElement *>::const_iterator iterGraphicsBitmapStyles = mpImpl->mGraphicsBitmapStyles.begin();
- iterGraphicsBitmapStyles != mpImpl->mGraphicsBitmapStyles.end(); ++iterGraphicsBitmapStyles)
- {
- (*iterGraphicsBitmapStyles)->write(mpImpl->mpHandler);
- }
-
- for (std::vector<DocumentElement *>::const_iterator iterGraphicsMarkerStyles = mpImpl->mGraphicsMarkerStyles.begin();
- iterGraphicsMarkerStyles != mpImpl->mGraphicsMarkerStyles.end(); ++iterGraphicsMarkerStyles)
- {
- (*iterGraphicsMarkerStyles)->write(mpImpl->mpHandler);
- }
- mpImpl->mpHandler->endElement("office:styles");
- }
-
-
- if ((mpImpl->mxStreamType == ODF_FLAT_XML) || (mpImpl->mxStreamType == ODF_CONTENT_XML) || (mpImpl->mxStreamType == ODF_STYLES_XML))
- {
- mpImpl->mFontManager.writeFontsDeclaration(mpImpl->mpHandler);
-
- TagOpenElement("office:automatic-styles").write(mpImpl->mpHandler);
- }
-
- if ((mpImpl->mxStreamType == ODF_FLAT_XML) || (mpImpl->mxStreamType == ODF_CONTENT_XML))
- {
- // writing out the graphics automatic styles
- for (std::vector<DocumentElement *>::iterator iterGraphicsAutomaticStyles = mpImpl->mGraphicsAutomaticStyles.begin();
- iterGraphicsAutomaticStyles != mpImpl->mGraphicsAutomaticStyles.end(); ++iterGraphicsAutomaticStyles)
- {
- (*iterGraphicsAutomaticStyles)->write(mpImpl->mpHandler);
- }
- mpImpl->mParagraphManager.write(mpImpl->mpHandler);
- mpImpl->mSpanManager.write(mpImpl->mpHandler);
- }
-#ifdef MULTIPAGE_WORKAROUND
- if ((mpImpl->mxStreamType == ODF_FLAT_XML) || (mpImpl->mxStreamType == ODF_STYLES_XML))
- {
- TagOpenElement tmpStylePageLayoutOpenElement("style:page-layout");
- tmpStylePageLayoutOpenElement.addAttribute("style:name", "PM0");
- tmpStylePageLayoutOpenElement.write(mpImpl->mpHandler);
-
- TagOpenElement tmpStylePageLayoutPropertiesOpenElement("style:page-layout-properties");
- tmpStylePageLayoutPropertiesOpenElement.addAttribute("fo:margin-top", "0in");
- tmpStylePageLayoutPropertiesOpenElement.addAttribute("fo:margin-bottom", "0in");
- tmpStylePageLayoutPropertiesOpenElement.addAttribute("fo:margin-left", "0in");
- tmpStylePageLayoutPropertiesOpenElement.addAttribute("fo:margin-right", "0in");
- WPXString sValue;
- sValue = doubleToString(mpImpl->mfMaxWidth);
- sValue.append("in");
- tmpStylePageLayoutPropertiesOpenElement.addAttribute("fo:page-width", sValue);
- sValue = doubleToString(mpImpl->mfMaxHeight);
- sValue.append("in");
- tmpStylePageLayoutPropertiesOpenElement.addAttribute("fo:page-height", sValue);
- tmpStylePageLayoutPropertiesOpenElement.addAttribute("style:print-orientation", "portrait");
- tmpStylePageLayoutPropertiesOpenElement.write(mpImpl->mpHandler);
-
- mpImpl->mpHandler->endElement("style:page-layout-properties");
-
- mpImpl->mpHandler->endElement("style:page-layout");
-
- TagOpenElement tmpStyleStyleOpenElement("style:style");
- tmpStyleStyleOpenElement.addAttribute("style:name", "dp1");
- tmpStyleStyleOpenElement.addAttribute("style:family", "drawing-page");
- tmpStyleStyleOpenElement.write(mpImpl->mpHandler);
-
- TagOpenElement tmpStyleDrawingPagePropertiesOpenElement("style:drawing-page-properties");
- // tmpStyleDrawingPagePropertiesOpenElement.addAttribute("draw:background-size", "border");
- tmpStyleDrawingPagePropertiesOpenElement.addAttribute("draw:fill", "none");
- tmpStyleDrawingPagePropertiesOpenElement.write(mpImpl->mpHandler);
-
- mpImpl->mpHandler->endElement("style:drawing-page-properties");
-
- mpImpl->mpHandler->endElement("style:style");
- }
-#else
- if ((mpImpl->mxStreamType == ODF_FLAT_XML) || (mpImpl->mxStreamType == ODF_STYLES_XML))
- {
- // writing out the page automatic styles
- for (std::vector<DocumentElement *>::iterator iterPageAutomaticStyles = mpImpl->mPageAutomaticStyles.begin();
- iterPageAutomaticStyles != mpImpl->mPageAutomaticStyles.end(); ++iterPageAutomaticStyles)
- {
- (*iterPageAutomaticStyles)->write(mpImpl->mpHandler);
- }
- }
-#endif
- if ((mpImpl->mxStreamType == ODF_FLAT_XML) || (mpImpl->mxStreamType == ODF_CONTENT_XML) || (mpImpl->mxStreamType == ODF_STYLES_XML))
- {
- mpImpl->mpHandler->endElement("office:automatic-styles");
- }
-
- if ((mpImpl->mxStreamType == ODF_FLAT_XML) || (mpImpl->mxStreamType == ODF_STYLES_XML))
- {
- TagOpenElement("office:master-styles").write(mpImpl->mpHandler);
-
- for (std::vector<DocumentElement *>::const_iterator pageMasterIter = mpImpl->mPageMasterStyles.begin();
- pageMasterIter != mpImpl->mPageMasterStyles.end(); ++pageMasterIter)
- {
- (*pageMasterIter)->write(mpImpl->mpHandler);
- }
- mpImpl->mpHandler->endElement("office:master-styles");
- }
-
- if ((mpImpl->mxStreamType == ODF_FLAT_XML) || (mpImpl->mxStreamType == ODF_CONTENT_XML))
- {
- TagOpenElement("office:body").write(mpImpl->mpHandler);
-
- TagOpenElement("office:drawing").write(mpImpl->mpHandler);
-
- for (std::vector<DocumentElement *>::const_iterator bodyIter = mpImpl->mBodyElements.begin();
- bodyIter != mpImpl->mBodyElements.end(); ++bodyIter)
- {
- (*bodyIter)->write(mpImpl->mpHandler);
- }
-
- mpImpl->mpHandler->endElement("office:drawing");
- mpImpl->mpHandler->endElement("office:body");
- }
-
- mpImpl->mpHandler->endElement(
- (mpImpl->mxStreamType == ODF_FLAT_XML) ? "office:document" : (
- (mpImpl->mxStreamType == ODF_CONTENT_XML) ? "office:document-content" : (
- (mpImpl->mxStreamType == ODF_STYLES_XML) ? "office:document-styles" : (
- (mpImpl->mxStreamType == ODF_SETTINGS_XML) ? "office:document-settings" : (
- (mpImpl->mxStreamType == ODF_META_XML) ? "office:document-meta" : "office:document" )))));
-
- mpImpl->mpHandler->endDocument();
-
- if (mpImpl)
- delete mpImpl;
-}
-
-void OdgGenerator::startGraphics(const ::WPXPropertyList &propList)
-{
- if (propList["svg:width"])
- {
- mpImpl->mfWidth = propList["svg:width"]->getDouble();
- mpImpl->mfMaxWidth = mpImpl->mfMaxWidth < mpImpl->mfWidth ? mpImpl->mfWidth : mpImpl->mfMaxWidth;
- }
-
- if (propList["svg:height"])
- {
- mpImpl->mfHeight = propList["svg:height"]->getDouble();
- mpImpl->mfMaxHeight = mpImpl->mfMaxHeight < mpImpl->mfHeight ? mpImpl->mfHeight : mpImpl->mfMaxHeight;
- }
-
- TagOpenElement *pStyleMasterPageOpenElement = new TagOpenElement("style:master-page");
-
- TagOpenElement *pDrawPageOpenElement = new TagOpenElement("draw:page");
-
- TagOpenElement *pStylePageLayoutOpenElement = new TagOpenElement("style:page-layout");
-
- WPXString sValue;
- if (propList["draw:name"])
- sValue = WPXString(propList["draw:name"]->getStr(), true); // escape special xml characters
- else
- sValue.sprintf("page%i", mpImpl->miPageIndex);
- pDrawPageOpenElement->addAttribute("draw:name", sValue);
-#ifdef MULTIPAGE_WORKAROUND
- pStyleMasterPageOpenElement->addAttribute("style:page-layout-name", "PM0");
- pStylePageLayoutOpenElement->addAttribute("style:page-layout-name", "PM0");
-#else
- sValue.sprintf("PM%i", mpImpl->miPageIndex);
- pStyleMasterPageOpenElement->addAttribute("style:page-layout-name", sValue);
- pStylePageLayoutOpenElement->addAttribute("style:name", sValue);
-#endif
-
- mpImpl->mPageAutomaticStyles.push_back(pStylePageLayoutOpenElement);
-
- TagOpenElement *pStylePageLayoutPropertiesOpenElement = new TagOpenElement("style:page-layout-properties");
- pStylePageLayoutPropertiesOpenElement->addAttribute("fo:margin-top", "0in");
- pStylePageLayoutPropertiesOpenElement->addAttribute("fo:margin-bottom", "0in");
- pStylePageLayoutPropertiesOpenElement->addAttribute("fo:margin-left", "0in");
- pStylePageLayoutPropertiesOpenElement->addAttribute("fo:margin-right", "0in");
- sValue.sprintf("%s%s", doubleToString(mpImpl->mfWidth).cstr(), "in");
- pStylePageLayoutPropertiesOpenElement->addAttribute("fo:page-width", sValue);
- sValue.sprintf("%s%s", doubleToString(mpImpl->mfHeight).cstr(), "in");
- pStylePageLayoutPropertiesOpenElement->addAttribute("fo:page-height", sValue);
- pStylePageLayoutPropertiesOpenElement->addAttribute("style:print-orientation", "portrait");
- mpImpl->mPageAutomaticStyles.push_back(pStylePageLayoutPropertiesOpenElement);
-
- mpImpl->mPageAutomaticStyles.push_back(new TagCloseElement("style:page-layout-properties"));
-
- mpImpl->mPageAutomaticStyles.push_back(new TagCloseElement("style:page-layout"));
-
-#ifdef MULTIPAGE_WORKAROUND
- pDrawPageOpenElement->addAttribute("draw:style-name", "dp1");
- pStyleMasterPageOpenElement->addAttribute("draw:style-name", "dp1");
-#else
- sValue.sprintf("dp%i", mpImpl->miPageIndex);
- pDrawPageOpenElement->addAttribute("draw:style-name", sValue);
- pStyleMasterPageOpenElement->addAttribute("draw:style-name", sValue);
-#endif
-
- TagOpenElement *pStyleStyleOpenElement = new TagOpenElement("style:style");
- pStyleStyleOpenElement->addAttribute("style:name", sValue);
- pStyleStyleOpenElement->addAttribute("style:family", "drawing-page");
- mpImpl->mPageAutomaticStyles.push_back(pStyleStyleOpenElement);
-
-#ifdef MULTIPAGE_WORKAROUND
- pDrawPageOpenElement->addAttribute("draw:master-page-name", "Default");
- pStyleMasterPageOpenElement->addAttribute("style:name", "Default");
-#else
- sValue.sprintf("Page%i", mpImpl->miPageIndex);
- pDrawPageOpenElement->addAttribute("draw:master-page-name", sValue);
- pStyleMasterPageOpenElement->addAttribute("style:name", sValue);
-#endif
-
- mpImpl->mBodyElements.push_back(pDrawPageOpenElement);
-
- mpImpl->mPageMasterStyles.push_back(pStyleMasterPageOpenElement);
- mpImpl->mPageMasterStyles.push_back(new TagCloseElement("style:master-page"));
-
-
- TagOpenElement *pStyleDrawingPagePropertiesOpenElement = new TagOpenElement("style:drawing-page-properties");
- pStyleDrawingPagePropertiesOpenElement->addAttribute("draw:fill", "none");
- mpImpl->mPageAutomaticStyles.push_back(pStyleDrawingPagePropertiesOpenElement);
-
- mpImpl->mPageAutomaticStyles.push_back(new TagCloseElement("style:drawing-page-properties"));
-
- mpImpl->mPageAutomaticStyles.push_back(new TagCloseElement("style:style"));
-}
-
-void OdgGenerator::endGraphics()
-{
- mpImpl->mBodyElements.push_back(new TagCloseElement("draw:page"));
- mpImpl->miPageIndex++;
-}
-
-void OdgGenerator::setStyle(const ::WPXPropertyList &propList, const ::WPXPropertyListVector &gradient)
-{
- mpImpl->mxStyle.clear();
- mpImpl->mxStyle = propList;
- mpImpl->mxGradient = gradient;
-}
-
-void OdgGenerator::startLayer(const ::WPXPropertyList & /* propList */)
-{
- mpImpl->mBodyElements.push_back(new TagOpenElement("draw:g"));
-}
-
-void OdgGenerator::endLayer()
-{
- mpImpl->mBodyElements.push_back(new TagCloseElement("draw:g"));
-}
-
-void OdgGenerator::drawRectangle(const ::WPXPropertyList &propList)
-{
- mpImpl->_writeGraphicsStyle();
- TagOpenElement *pDrawRectElement = new TagOpenElement("draw:rect");
- WPXString sValue;
- sValue.sprintf("gr%i", mpImpl->miGraphicsStyleIndex-1);
- pDrawRectElement->addAttribute("draw:style-name", sValue);
- pDrawRectElement->addAttribute("svg:x", propList["svg:x"]->getStr());
- pDrawRectElement->addAttribute("svg:y", propList["svg:y"]->getStr());
- pDrawRectElement->addAttribute("svg:width", propList["svg:width"]->getStr());
- pDrawRectElement->addAttribute("svg:height", propList["svg:height"]->getStr());
- // FIXME: what to do when rx != ry ?
- if (propList["svg:rx"])
- pDrawRectElement->addAttribute("draw:corner-radius", propList["svg:rx"]->getStr());
- else
- pDrawRectElement->addAttribute("draw:corner-radius", "0.0000in");
- mpImpl->mBodyElements.push_back(pDrawRectElement);
- mpImpl->mBodyElements.push_back(new TagCloseElement("draw:rect"));
-}
-
-void OdgGenerator::drawEllipse(const ::WPXPropertyList &propList)
-{
- mpImpl->_writeGraphicsStyle();
- TagOpenElement *pDrawEllipseElement = new TagOpenElement("draw:ellipse");
- WPXString sValue;
- sValue.sprintf("gr%i", mpImpl->miGraphicsStyleIndex-1);
- pDrawEllipseElement->addAttribute("draw:style-name", sValue);
- sValue = doubleToString(2 * propList["svg:rx"]->getDouble());
- sValue.append("in");
- pDrawEllipseElement->addAttribute("svg:width", sValue);
- sValue = doubleToString(2 * propList["svg:ry"]->getDouble());
- sValue.append("in");
- pDrawEllipseElement->addAttribute("svg:height", sValue);
- if (propList["libwpg:rotate"] && propList["libwpg:rotate"]->getDouble() != 0.0)
- {
- double rotation = propList["libwpg:rotate"]->getDouble();
- while(rotation < -180)
- rotation += 360;
- while(rotation > 180)
- rotation -= 360;
- double radrotation = rotation*M_PI/180.0;
- double deltax = sqrt(pow(propList["svg:rx"]->getDouble(), 2.0)
- + pow(propList["svg:ry"]->getDouble(), 2.0))*cos(atan(propList["svg:ry"]->getDouble()/propList["svg:rx"]->getDouble())
- - radrotation ) - propList["svg:rx"]->getDouble();
- double deltay = sqrt(pow(propList["svg:rx"]->getDouble(), 2.0)
- + pow(propList["svg:ry"]->getDouble(), 2.0))*sin(atan(propList["svg:ry"]->getDouble()/propList["svg:rx"]->getDouble())
- - radrotation ) - propList["svg:ry"]->getDouble();
- sValue = "rotate(";
- sValue.append(doubleToString(radrotation));
- sValue.append(") ");
- sValue.append("translate(");
- sValue.append(doubleToString(propList["svg:cx"]->getDouble() - propList["svg:rx"]->getDouble() - deltax));
- sValue.append("in, ");
- sValue.append(doubleToString(propList["svg:cy"]->getDouble() - propList["svg:ry"]->getDouble() - deltay));
- sValue.append("in)");
- pDrawEllipseElement->addAttribute("draw:transform", sValue);
- }
- else
- {
- sValue = doubleToString(propList["svg:cx"]->getDouble()-propList["svg:rx"]->getDouble());
- sValue.append("in");
- pDrawEllipseElement->addAttribute("svg:x", sValue);
- sValue = doubleToString(propList["svg:cy"]->getDouble()-propList["svg:ry"]->getDouble());
- sValue.append("in");
- pDrawEllipseElement->addAttribute("svg:y", sValue);
- }
- mpImpl->mBodyElements.push_back(pDrawEllipseElement);
- mpImpl->mBodyElements.push_back(new TagCloseElement("draw:ellipse"));
-}
-
-void OdgGenerator::drawPolyline(const ::WPXPropertyListVector &vertices)
-{
- mpImpl->_drawPolySomething(vertices, false);
-}
-
-void OdgGenerator::drawPolygon(const ::WPXPropertyListVector &vertices)
-{
- mpImpl->_drawPolySomething(vertices, true);
-}
-
-void OdgGeneratorPrivate::_drawPolySomething(const ::WPXPropertyListVector &vertices, bool isClosed)
-{
- if(vertices.count() < 2)
- return;
-
- if(vertices.count() == 2)
- {
- _writeGraphicsStyle();
- TagOpenElement *pDrawLineElement = new TagOpenElement("draw:line");
- WPXString sValue;
- sValue.sprintf("gr%i", miGraphicsStyleIndex-1);
- pDrawLineElement->addAttribute("draw:style-name", sValue);
- pDrawLineElement->addAttribute("draw:layer", "layout");
- pDrawLineElement->addAttribute("svg:x1", vertices[0]["svg:x"]->getStr());
- pDrawLineElement->addAttribute("svg:y1", vertices[0]["svg:y"]->getStr());
- pDrawLineElement->addAttribute("svg:x2", vertices[1]["svg:x"]->getStr());
- pDrawLineElement->addAttribute("svg:y2", vertices[1]["svg:y"]->getStr());
- mBodyElements.push_back(pDrawLineElement);
- mBodyElements.push_back(new TagCloseElement("draw:line"));
- }
- else
- {
- ::WPXPropertyListVector path;
- ::WPXPropertyList element;
-
- for (unsigned long ii = 0; ii < vertices.count(); ++ii)
- {
- element = vertices[ii];
- if (ii == 0)
- element.insert("libwpg:path-action", "M");
- else
- element.insert("libwpg:path-action", "L");
- path.append(element);
- element.clear();
- }
- if (isClosed)
- {
- element.insert("libwpg:path-action", "Z");
- path.append(element);
- }
- _drawPath(path);
- }
-}
-
-void OdgGeneratorPrivate::_drawPath(const WPXPropertyListVector &path)
-{
- if(path.count() == 0)
- return;
- // This must be a mistake and we do not want to crash lower
- if(path[0]["libwpg:path-action"]->getStr() == "Z")
- return;
-
- // try to find the bounding box
- // this is simple convex hull technique, the bounding box might not be
- // accurate but that should be enough for this purpose
- bool isFirstPoint = true;
-
- double px = 0.0, py = 0.0, qx = 0.0, qy = 0.0;
- double lastX = 0.0;
- double lastY = 0.0;
-
- for(unsigned k = 0; k < path.count(); ++k)
- {
- if (!path[k]["svg:x"] || !path[k]["svg:y"])
- continue;
- if (isFirstPoint)
- {
- px = path[k]["svg:x"]->getDouble();
- py = path[k]["svg:y"]->getDouble();
- qx = px;
- qy = py;
- lastX = px;
- lastY = py;
- isFirstPoint = false;
- }
- px = (px > path[k]["svg:x"]->getDouble()) ? path[k]["svg:x"]->getDouble() : px;
- py = (py > path[k]["svg:y"]->getDouble()) ? path[k]["svg:y"]->getDouble() : py;
- qx = (qx < path[k]["svg:x"]->getDouble()) ? path[k]["svg:x"]->getDouble() : qx;
- qy = (qy < path[k]["svg:y"]->getDouble()) ? path[k]["svg:y"]->getDouble() : qy;
-
- double xmin, xmax, ymin, ymax;
-
- if(path[k]["libwpg:path-action"]->getStr() == "C")
- {
- getCubicBezierBBox(lastX, lastY, path[k]["svg:x1"]->getDouble(), path[k]["svg:y1"]->getDouble(),
- path[k]["svg:x2"]->getDouble(), path[k]["svg:y2"]->getDouble(),
- path[k]["svg:x"]->getDouble(), path[k]["svg:y"]->getDouble(), xmin, ymin, xmax, ymax);
-
- px = (px > xmin ? xmin : px);
- py = (py > ymin ? ymin : py);
- qx = (qx < xmax ? xmax : qx);
- qy = (qy < ymax ? ymax : qy);
- }
- if(path[k]["libwpg:path-action"]->getStr() == "Q")
- {
- getQuadraticBezierBBox(lastX, lastY, path[k]["svg:x1"]->getDouble(), path[k]["svg:y1"]->getDouble(),
- path[k]["svg:x"]->getDouble(), path[k]["svg:y"]->getDouble(), xmin, ymin, xmax, ymax);
-
- px = (px > xmin ? xmin : px);
- py = (py > ymin ? ymin : py);
- qx = (qx < xmax ? xmax : qx);
- qy = (qy < ymax ? ymax : qy);
- }
- if(path[k]["libwpg:path-action"]->getStr() == "A")
- {
- getEllipticalArcBBox(lastX, lastY, path[k]["svg:rx"]->getDouble(), path[k]["svg:ry"]->getDouble(),
- path[k]["libwpg:rotate"] ? path[k]["libwpg:rotate"]->getDouble() : 0.0,
- path[k]["libwpg:large-arc"] ? path[k]["libwpg:large-arc"]->getInt() : 1,
- path[k]["libwpg:sweep"] ? path[k]["libwpg:sweep"]->getInt() : 1,
- path[k]["svg:x"]->getDouble(), path[k]["svg:y"]->getDouble(), xmin, ymin, xmax, ymax);
-
- px = (px > xmin ? xmin : px);
- py = (py > ymin ? ymin : py);
- qx = (qx < xmax ? xmax : qx);
- qy = (qy < ymax ? ymax : qy);
- }
- lastX = path[k]["svg:x"]->getDouble();
- lastY = path[k]["svg:y"]->getDouble();
- }
-
-
- WPXString sValue;
- _writeGraphicsStyle();
- TagOpenElement *pDrawPathElement = new TagOpenElement("draw:path");
- sValue.sprintf("gr%i", miGraphicsStyleIndex-1);
- pDrawPathElement->addAttribute("draw:style-name", sValue);
- pDrawPathElement->addAttribute("draw:layer", "layout");
- sValue = doubleToString(px);
- sValue.append("in");
- pDrawPathElement->addAttribute("svg:x", sValue);
- sValue = doubleToString(py);
- sValue.append("in");
- pDrawPathElement->addAttribute("svg:y", sValue);
- sValue = doubleToString((qx - px));
- sValue.append("in");
- pDrawPathElement->addAttribute("svg:width", sValue);
- sValue = doubleToString((qy - py));
- sValue.append("in");
- pDrawPathElement->addAttribute("svg:height", sValue);
- sValue.sprintf("%i %i %i %i", 0, 0, (unsigned)(2540*(qx - px)), (unsigned)(2540*(qy - py)));
- pDrawPathElement->addAttribute("svg:viewBox", sValue);
-
- sValue.clear();
- for(unsigned i = 0; i < path.count(); ++i)
- {
- WPXString sElement;
- if (path[i]["libwpg:path-action"]->getStr() == "M")
- {
- // 2540 is 2.54*1000, 2.54 in = 1 inch
- sElement.sprintf("M%i %i", (unsigned)((path[i]["svg:x"]->getDouble()-px)*2540),
- (unsigned)((path[i]["svg:y"]->getDouble()-py)*2540));
- sValue.append(sElement);
- }
- else if (path[i]["libwpg:path-action"]->getStr() == "L")
- {
- sElement.sprintf("L%i %i", (unsigned)((path[i]["svg:x"]->getDouble()-px)*2540),
- (unsigned)((path[i]["svg:y"]->getDouble()-py)*2540));
- sValue.append(sElement);
- }
- else if (path[i]["libwpg:path-action"]->getStr() == "C")
- {
- sElement.sprintf("C%i %i %i %i %i %i", (unsigned)((path[i]["svg:x1"]->getDouble()-px)*2540),
- (unsigned)((path[i]["svg:y1"]->getDouble()-py)*2540), (unsigned)((path[i]["svg:x2"]->getDouble()-px)*2540),
- (unsigned)((path[i]["svg:y2"]->getDouble()-py)*2540), (unsigned)((path[i]["svg:x"]->getDouble()-px)*2540),
- (unsigned)((path[i]["svg:y"]->getDouble()-py)*2540));
- sValue.append(sElement);
- }
- else if (path[i]["libwpg:path-action"]->getStr() == "Q")
- {
- sElement.sprintf("Q%i %i %i %i", (unsigned)((path[i]["svg:x1"]->getDouble()-px)*2540),
- (unsigned)((path[i]["svg:y1"]->getDouble()-py)*2540), (unsigned)((path[i]["svg:x"]->getDouble()-px)*2540),
- (unsigned)((path[i]["svg:y"]->getDouble()-py)*2540));
- sValue.append(sElement);
- }
- else if (path[i]["libwpg:path-action"]->getStr() == "A")
- {
- sElement.sprintf("A%i %i %i %i %i %i %i", (unsigned)((path[i]["svg:rx"]->getDouble())*2540),
- (unsigned)((path[i]["svg:ry"]->getDouble())*2540), (path[i]["libwpg:rotate"] ? path[i]["libwpg:rotate"]->getInt() : 0),
- (path[i]["libwpg:large-arc"] ? path[i]["libwpg:large-arc"]->getInt() : 1),
- (path[i]["libwpg:sweep"] ? path[i]["libwpg:sweep"]->getInt() : 1),
- (unsigned)((path[i]["svg:x"]->getDouble()-px)*2540), (unsigned)((path[i]["svg:y"]->getDouble()-py)*2540));
- sValue.append(sElement);
- }
- else if (path[i]["libwpg:path-action"]->getStr() == "Z")
- sValue.append(" Z");
- }
- pDrawPathElement->addAttribute("svg:d", sValue);
- mBodyElements.push_back(pDrawPathElement);
- mBodyElements.push_back(new TagCloseElement("draw:path"));
-}
-
-void OdgGenerator::drawPath(const WPXPropertyListVector &path)
-{
- mpImpl->_drawPath(path);
-}
-
-void OdgGenerator::drawGraphicObject(const ::WPXPropertyList &propList, const ::WPXBinaryData &binaryData)
-{
- if (!propList["libwpg:mime-type"] || propList["libwpg:mime-type"]->getStr().len() <= 0)
- return;
- if (!propList["svg:x"] || !propList["svg:y"] || !propList["svg:width"] || !propList["svg:height"])
- return;
-
- bool flipX(propList["draw:mirror-horizontal"] && propList["draw:mirror-horizontal"]->getInt());
- bool flipY(propList["draw:mirror-vertical"] && propList["draw:mirror-vertical"]->getInt());
- if ((flipX && !flipY) || (!flipX && flipY))
- mpImpl->mxStyle.insert("style:mirror", "horizontal");
- else
- mpImpl->mxStyle.insert("style:mirror", "none");
- if (propList["draw:color-mode"])
- mpImpl->mxStyle.insert("draw:color-mode", propList["draw:color-mode"]->getStr());
- if (propList["draw:luminance"])
- mpImpl->mxStyle.insert("draw:luminance", propList["draw:luminance"]->getStr());
- if (propList["draw:contrast"])
- mpImpl->mxStyle.insert("draw:contrast", propList["draw:contrast"]->getStr());
- if (propList["draw:gamma"])
- mpImpl->mxStyle.insert("draw:gamma", propList["draw:gamma"]->getStr());
- if (propList["draw:red"])
- mpImpl->mxStyle.insert("draw:red", propList["draw:red"]->getStr());
- if (propList["draw:green"])
- mpImpl->mxStyle.insert("draw:green", propList["draw:green"]->getStr());
- if (propList["draw:blue"])
- mpImpl->mxStyle.insert("draw:blue", propList["draw:blue"]->getStr());
-
-
- mpImpl->_writeGraphicsStyle();
-
- double x = propList["svg:x"]->getDouble();
- double y = propList["svg:y"]->getDouble();
- double height = propList["svg:height"]->getDouble();
- double width = propList["svg:width"]->getDouble();
-
- if (flipY)
- {
- x += width;
- y += height;
- width *= -1.0;
- height *= -1.0;
- }
-
- double angle(propList["libwpg:rotate"] ? - M_PI * propList["libwpg:rotate"]->getDouble() / 180.0 : 0.0);
- if (angle != 0.0)
- {
- double deltax((width*cos(angle)+height*sin(angle)-width)/2.0);
- double deltay((-width*sin(angle)+height*cos(angle)-height)/2.0);
- x -= deltax;
- y -= deltay;
- }
-
- WPXPropertyList framePropList;
-
- framePropList.insert("svg:x", x);
- framePropList.insert("svg:y", y);
- framePropList.insert("svg:height", height);
- framePropList.insert("svg:width", width);
-
- TagOpenElement *pDrawFrameElement = new TagOpenElement("draw:frame");
-
- WPXString sValue;
- sValue.sprintf("gr%i", mpImpl->miGraphicsStyleIndex-1);
- pDrawFrameElement->addAttribute("draw:style-name", sValue);
-
- pDrawFrameElement->addAttribute("svg:height", framePropList["svg:height"]->getStr());
- pDrawFrameElement->addAttribute("svg:width", framePropList["svg:width"]->getStr());
-
- if (angle != 0.0)
- {
- framePropList.insert("libwpg:rotate", angle, WPX_GENERIC);
- sValue.sprintf("rotate (%s) translate(%s, %s)",
- framePropList["libwpg:rotate"]->getStr().cstr(),
- framePropList["svg:x"]->getStr().cstr(),
- framePropList["svg:y"]->getStr().cstr());
- pDrawFrameElement->addAttribute("draw:transform", sValue);
- }
- else
- {
- pDrawFrameElement->addAttribute("svg:x", framePropList["svg:x"]->getStr());
- pDrawFrameElement->addAttribute("svg:y", framePropList["svg:y"]->getStr());
- }
- mpImpl->mBodyElements.push_back(pDrawFrameElement);
-
- if (propList["libwpg:mime-type"]->getStr() == "object/ole")
- mpImpl->mBodyElements.push_back(new TagOpenElement("draw:object-ole"));
- else
- mpImpl->mBodyElements.push_back(new TagOpenElement("draw:image"));
-
- mpImpl->mBodyElements.push_back(new TagOpenElement("office:binary-data"));
-
- ::WPXString base64Binary = binaryData.getBase64Data();
- mpImpl->mBodyElements.push_back(new CharDataElement(base64Binary.cstr()));
-
- mpImpl->mBodyElements.push_back(new TagCloseElement("office:binary-data"));
-
- if (propList["libwpg:mime-type"]->getStr() == "object/ole")
- mpImpl->mBodyElements.push_back(new TagCloseElement("draw:object-ole"));
- else
- mpImpl->mBodyElements.push_back(new TagCloseElement("draw:image"));
-
- mpImpl->mBodyElements.push_back(new TagCloseElement("draw:frame"));
-}
-
-void OdgGeneratorPrivate::_writeGraphicsStyle()
-{
- bool bUseOpacityGradient = false;
-
- if (mxStyle["draw:stroke"] && mxStyle["draw:stroke"]->getStr() == "dash")
- {
- TagOpenElement *pDrawStrokeDashElement = new TagOpenElement("draw:stroke-dash");
- WPXString sValue;
- sValue.sprintf("Dash_%i", miDashIndex++);
- pDrawStrokeDashElement->addAttribute("draw:name", sValue);
- if (mxStyle["svg:stoke-linecap"])
- pDrawStrokeDashElement->addAttribute("draw:style", mxStyle["svg:stroke-linecap"]->getStr());
- else
- pDrawStrokeDashElement->addAttribute("draw:style", "rect");
- if (mxStyle["draw:distance"])
- pDrawStrokeDashElement->addAttribute("draw:distance", mxStyle["draw:distance"]->getStr());
- if (mxStyle["draw:dots1"])
- pDrawStrokeDashElement->addAttribute("draw:dots1", mxStyle["draw:dots1"]->getStr());
- if (mxStyle["draw:dots1-length"])
- pDrawStrokeDashElement->addAttribute("draw:dots1-length", mxStyle["draw:dots1-length"]->getStr());
- if (mxStyle["draw:dots2"])
- pDrawStrokeDashElement->addAttribute("draw:dots2", mxStyle["draw:dots2"]->getStr());
- if (mxStyle["draw:dots2-length"])
- pDrawStrokeDashElement->addAttribute("draw:dots2-length", mxStyle["draw:dots2-length"]->getStr());
- mGraphicsStrokeDashStyles.push_back(pDrawStrokeDashElement);
- mGraphicsStrokeDashStyles.push_back(new TagCloseElement("draw:stroke-dash"));
- }
-
- if (mxStyle["draw:marker-start-path"])
- {
- WPXString sValue;
- TagOpenElement *pDrawMarkerElement = new TagOpenElement("draw:marker");
- sValue.sprintf("StartMarker_%i", miStartMarkerIndex);
- pDrawMarkerElement->addAttribute("draw:name", sValue);
- if (mxStyle["draw:marker-start-viewbox"])
- pDrawMarkerElement->addAttribute("svg:viewBox", mxStyle["draw:marker-start-viewbox"]->getStr());
- pDrawMarkerElement->addAttribute("svg:d", mxStyle["draw:marker-start-path"]->getStr());
- mGraphicsMarkerStyles.push_back(pDrawMarkerElement);
- mGraphicsMarkerStyles.push_back(new TagCloseElement("draw:marker"));
- }
- if(mxStyle["draw:marker-end-path"])
- {
- WPXString sValue;
- TagOpenElement *pDrawMarkerElement = new TagOpenElement("draw:marker");
- sValue.sprintf("EndMarker_%i", miEndMarkerIndex);
- pDrawMarkerElement->addAttribute("draw:name", sValue);
- if (mxStyle["draw:marker-end-viewbox"])
- pDrawMarkerElement->addAttribute("svg:viewBox", mxStyle["draw:marker-end-viewbox"]->getStr());
- pDrawMarkerElement->addAttribute("svg:d", mxStyle["draw:marker-end-path"]->getStr());
- mGraphicsMarkerStyles.push_back(pDrawMarkerElement);
- mGraphicsMarkerStyles.push_back(new TagCloseElement("draw:marker"));
- }
-
- if(mxStyle["draw:fill"] && mxStyle["draw:fill"]->getStr() == "gradient")
- {
- TagOpenElement *pDrawGradientElement = new TagOpenElement("draw:gradient");
- TagOpenElement *pDrawOpacityElement = new TagOpenElement("draw:opacity");
- if (mxStyle["draw:style"])
- {
- pDrawGradientElement->addAttribute("draw:style", mxStyle["draw:style"]->getStr());
- pDrawOpacityElement->addAttribute("draw:style", mxStyle["draw:style"]->getStr());
- }
- else
- {
- pDrawGradientElement->addAttribute("draw:style", "linear");
- pDrawOpacityElement->addAttribute("draw:style", "linear");
- }
- WPXString sValue;
- sValue.sprintf("Gradient_%i", miGradientIndex);
- pDrawGradientElement->addAttribute("draw:name", sValue);
- sValue.sprintf("Transparency_%i", miGradientIndex++);
- pDrawOpacityElement->addAttribute("draw:name", sValue);
-
- // ODG angle unit is 0.1 degree
- double angle = mxStyle["draw:angle"] ? mxStyle["draw:angle"]->getDouble() : 0.0;
- while(angle < 0)
- angle += 360;
- while(angle > 360)
- angle -= 360;
- sValue.sprintf("%i", (unsigned)(angle*10));
- pDrawGradientElement->addAttribute("draw:angle", sValue);
- pDrawOpacityElement->addAttribute("draw:angle", sValue);
-
- if (!mxGradient.count())
- {
- if (mxStyle["draw:start-color"])
- pDrawGradientElement->addAttribute("draw:start-color", mxStyle["draw:start-color"]->getStr());
- if (mxStyle["draw:end-color"])
- pDrawGradientElement->addAttribute("draw:end-color", mxStyle["draw:end-color"]->getStr());
-
- if (mxStyle["draw:border"])
- {
- pDrawGradientElement->addAttribute("draw:border", mxStyle["draw:border"]->getStr());
- pDrawOpacityElement->addAttribute("draw:border", mxStyle["draw:border"]->getStr());
- }
- else
- {
- pDrawGradientElement->addAttribute("draw:border", "0%");
- pDrawOpacityElement->addAttribute("draw:border", "0%");
- }
-
- if (mxStyle["svg:cx"])
- {
- pDrawGradientElement->addAttribute("draw:cx", mxStyle["svg:cx"]->getStr());
- pDrawOpacityElement->addAttribute("draw:cx", mxStyle["svg:cx"]->getStr());
- }
- else if (mxStyle["draw:cx"])
- {
- pDrawGradientElement->addAttribute("draw:cx", mxStyle["draw:cx"]->getStr());
- pDrawOpacityElement->addAttribute("draw:cx", mxStyle["draw:cx"]->getStr());
- }
-
- if (mxStyle["svg:cy"])
- {
- pDrawGradientElement->addAttribute("draw:cy", mxStyle["svg:cy"]->getStr());
- pDrawOpacityElement->addAttribute("draw:cy", mxStyle["svg:cy"]->getStr());
- }
- else if (mxStyle["draw:cx"])
- {
- pDrawGradientElement->addAttribute("draw:cx", mxStyle["svg:cx"]->getStr());
- pDrawOpacityElement->addAttribute("draw:cx", mxStyle["svg:cx"]->getStr());
- }
-
- if (mxStyle["draw:start-intensity"])
- pDrawGradientElement->addAttribute("draw:start-intensity", mxStyle["draw:start-intensity"]->getStr());
- else
- pDrawGradientElement->addAttribute("draw:start-intensity", "100%");
-
- if (mxStyle["draw:end-intensity"])
- pDrawGradientElement->addAttribute("draw:end-intensity", mxStyle["draw:end-intensity"]->getStr());
- else
- pDrawGradientElement->addAttribute("draw:end-intensity", "100%");
-
- if (mxStyle["libwpg:start-opacity"])
- pDrawOpacityElement->addAttribute("draw:start", mxStyle["libwpg:start-opacity"]->getStr());
- else
- pDrawOpacityElement->addAttribute("draw:start", "100%");
-
- if (mxStyle["libwpg:end-opacity"])
- pDrawOpacityElement->addAttribute("draw:end", mxStyle["libwpg:end-opacity"]->getStr());
- else
- pDrawOpacityElement->addAttribute("draw:end", "100%");
-
- mGraphicsGradientStyles.push_back(pDrawGradientElement);
- mGraphicsGradientStyles.push_back(new TagCloseElement("draw:gradient"));
-
- // Work around a mess in LibreOffice where both opacities of 100% are interpreted as complete transparency
- // Nevertheless, when one is different, immediately, they are interpreted correctly
- if (mxStyle["libwpg:start-opacity"] && mxStyle["libwpg:end-opacity"]
- && (mxStyle["libwpg:start-opacity"]->getDouble() != 1.0 || mxStyle["libwpg:end-opacity"]->getDouble() != 1.0))
- {
- bUseOpacityGradient = true;
- mGraphicsGradientStyles.push_back(pDrawOpacityElement);
- mGraphicsGradientStyles.push_back(new TagCloseElement("draw:opacity"));
- }
- }
- else if(mxGradient.count() >= 2)
- {
- sValue.sprintf("%i", (unsigned)(angle*10));
- pDrawGradientElement->addAttribute("draw:angle", sValue);
-
- pDrawGradientElement->addAttribute("draw:start-color", mxGradient[1]["svg:stop-color"]->getStr());
- pDrawGradientElement->addAttribute("draw:end-color", mxGradient[0]["svg:stop-color"]->getStr());
- if (mxStyle["svg:cx"])
- pDrawGradientElement->addAttribute("draw:cx", mxStyle["svg:cx"]->getStr());
- if (mxStyle["svg:cy"])
- pDrawGradientElement->addAttribute("draw:cy", mxStyle["svg:cy"]->getStr());
- if (mxGradient[1]["svg:stop-opacity"])
- {
- pDrawOpacityElement->addAttribute("draw:start", mxGradient[1]["svg:stop-opacity"]->getStr());
- bUseOpacityGradient = true;
- }
- else
- pDrawOpacityElement->addAttribute("draw:start", "100%");
- if (mxGradient[0]["svg:stop-opacity"])
- {
- pDrawOpacityElement->addAttribute("draw:end", mxGradient[0]["svg:stop-opacity"]->getStr());
- bUseOpacityGradient = true;
- }
- else
- pDrawOpacityElement->addAttribute("draw:end", "100%");
- pDrawGradientElement->addAttribute("draw:border", "0%");
- mGraphicsGradientStyles.push_back(pDrawGradientElement);
- mGraphicsGradientStyles.push_back(new TagCloseElement("draw:gradient"));
- if (bUseOpacityGradient)
- {
- mGraphicsGradientStyles.push_back(pDrawOpacityElement);
- mGraphicsGradientStyles.push_back(new TagCloseElement("draw:opacity"));
- }
- }
- else
- {
- /* if mxGradient.count() == 1 for some reason we would leak
- * pDrawGradientElement
- */
- delete pDrawGradientElement;
- }
- if(!bUseOpacityGradient)
- delete pDrawOpacityElement;
- }
-
- if(mxStyle["draw:fill"] && mxStyle["draw:fill"]->getStr() == "bitmap" &&
- mxStyle["draw:fill-image"] && mxStyle["libwpg:mime-type"])
- {
- TagOpenElement *pDrawBitmapElement = new TagOpenElement("draw:fill-image");
- WPXString sValue;
- sValue.sprintf("Bitmap_%i", miBitmapIndex++);
- pDrawBitmapElement->addAttribute("draw:name", sValue);
- mGraphicsBitmapStyles.push_back(pDrawBitmapElement);
- mGraphicsBitmapStyles.push_back(new TagOpenElement("office:binary-data"));
- mGraphicsBitmapStyles.push_back(new CharDataElement(mxStyle["draw:fill-image"]->getStr()));
- mGraphicsBitmapStyles.push_back(new TagCloseElement("office:binary-data"));
- mGraphicsBitmapStyles.push_back(new TagCloseElement("draw:fill-image"));
- }
-
- TagOpenElement *pStyleStyleElement = new TagOpenElement("style:style");
- WPXString sValue;
- sValue.sprintf("gr%i", miGraphicsStyleIndex);
- pStyleStyleElement->addAttribute("style:name", sValue);
- pStyleStyleElement->addAttribute("style:family", "graphic");
- pStyleStyleElement->addAttribute("style:parent-style-name", "standard");
- mGraphicsAutomaticStyles.push_back(pStyleStyleElement);
-
- TagOpenElement *pStyleGraphicsPropertiesElement = new TagOpenElement("style:graphic-properties");
-
- if (mxStyle["draw:color-mode"] && mxStyle["draw:color-mode"]->getStr().len() > 0)
- pStyleGraphicsPropertiesElement->addAttribute("draw:color-mode", mxStyle["draw:color-mode"]->getStr());
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list