Kaydet (Commit) 93848e11 authored tarafından Fridrich Štrba's avatar Fridrich Štrba

Splitting writerperfect into serializer and libodfgen

Change-Id: I69f12fb097dbc977e63463b6b764a3553bcf9271
üst 7de37ac7
......@@ -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)) \
......
......@@ -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
......
......@@ -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) \
......
......@@ -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@
......
......@@ -7245,6 +7245,11 @@ else
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 ===================================================================
......
......@@ -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
......
# -*- 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:
# -*- 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:
# -*- 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:
# -*- 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:
From [http://libwpg.sourceforge.net/]. Library to generate ODT and ODG documents from libwpd and libwpg API calls.
# -*- 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:
......@@ -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,\
......
......@@ -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 \
))
......
......@@ -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:
......@@ -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 \
))
......
/* -*- 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: */
/* -*- 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: */
......@@ -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>
......
......@@ -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;
......
/* -*- 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: */
/* -*- 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: */
/* -*- 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: */
/* -*- 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: */
/* -*- 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: */
/* -*- 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: */
/* -*- 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: */
/* -*- 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: */
/* -*- 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
*/
#ifndef __ODGEXPORTER_HXX__
#define __ODGEXPORTER_HXX__
#include <libwpd/libwpd.h>
#include <libwpg/libwpg.h>
#include "OdfDocumentHandler.hxx"
class OdgGeneratorPrivate;
class OdgGenerator : public libwpg::WPGPaintInterface
{
public:
OdgGenerator(OdfDocumentHandler *pHandler, const OdfStreamType streamType);
~OdgGenerator();
void startGraphics(const ::WPXPropertyList &propList);
void endGraphics();
void startLayer(const ::WPXPropertyList &propList);
void endLayer();
void startEmbeddedGraphics(const ::WPXPropertyList &propList);
void endEmbeddedGraphics();
void setStyle(const ::WPXPropertyList &propList, const ::WPXPropertyListVector &gradient);
void drawRectangle(const ::WPXPropertyList &propList);
void drawEllipse(const ::WPXPropertyList &propList);
void drawPolyline(const ::WPXPropertyListVector &vertices);
void drawPolygon(const ::WPXPropertyListVector &vertices);
void drawPath(const ::WPXPropertyListVector &path);
void drawGraphicObject(const ::WPXPropertyList &propList, const ::WPXBinaryData &binaryData);
void startTextObject(const ::WPXPropertyList &propList, const ::WPXPropertyListVector &path);
void endTextObject();
void startTextLine(const ::WPXPropertyList &propList);
void endTextLine();
void startTextSpan(const ::WPXPropertyList &propList);
void endTextSpan();
void insertText(const ::WPXString &str);
private:
OdgGeneratorPrivate *mpImpl;
};
#endif // __ODGEXPORTER_HXX__
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* OdtGenerator: Collects sections and runs of text from a
* wordperfect file (and styles to go along with them) and writes them
* to a target file
*
* 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 _ODTGENERATOR_H
#define _ODTGENERATOR_H
#include <libwpd/libwpd.h>
#include "OdfDocumentHandler.hxx"
typedef bool (*OdfEmbeddedObject)(const WPXBinaryData &data, OdfDocumentHandler *pHandler, const OdfStreamType streamType);
typedef bool (*OdfEmbeddedImage)(const WPXBinaryData &input, WPXBinaryData &output);
class OdtGeneratorPrivate;
class OdtGenerator : public WPXDocumentInterface
{
public:
OdtGenerator(OdfDocumentHandler *pHandler, const OdfStreamType streamType);
~OdtGenerator();
// WPXDocumentInterface's implementation
void setDocumentMetaData(const WPXPropertyList &propList);
void startDocument();
void endDocument();
void definePageStyle(const WPXPropertyList &);
void openPageSpan(const WPXPropertyList &propList);
void closePageSpan();
void defineSectionStyle(const WPXPropertyList &, const WPXPropertyListVector &);
void openSection(const WPXPropertyList &propList, const WPXPropertyListVector &columns);
void closeSection();
void openHeader(const WPXPropertyList &propList);
void closeHeader();
void openFooter(const WPXPropertyList &propList);
void closeFooter();
void defineParagraphStyle(const WPXPropertyList &, const WPXPropertyListVector &);
void openParagraph(const WPXPropertyList &propList, const WPXPropertyListVector &tabStops);
void closeParagraph();
void defineCharacterStyle(const WPXPropertyList &);
void openSpan(const WPXPropertyList &propList);
void closeSpan();
void insertTab();
void insertSpace();
void insertText(const WPXString &text);
void insertLineBreak();
void insertField(const WPXString &type, const WPXPropertyList &propList);
void defineOrderedListLevel(const WPXPropertyList &propList);
void defineUnorderedListLevel(const WPXPropertyList &propList);
void openOrderedListLevel(const WPXPropertyList &propList);
void openUnorderedListLevel(const WPXPropertyList &propList);
void closeOrderedListLevel();
void closeUnorderedListLevel();
void openListElement(const WPXPropertyList &propList, const WPXPropertyListVector &tabStops);
void closeListElement();
void openFootnote(const WPXPropertyList &propList);
void closeFootnote();
void openEndnote(const WPXPropertyList &propList);
void closeEndnote();
void openComment(const WPXPropertyList &propList);
void closeComment();
void openTextBox(const WPXPropertyList &propList);
void closeTextBox();
void openTable(const WPXPropertyList &propList, const WPXPropertyListVector &columns);
void openTableRow(const WPXPropertyList &propList);
void closeTableRow();
void openTableCell(const WPXPropertyList &propList);
void closeTableCell();
void insertCoveredTableCell(const WPXPropertyList &propList);
void closeTable();
void openFrame(const WPXPropertyList &propList);
void closeFrame();
void insertBinaryObject(const WPXPropertyList &propList, const WPXBinaryData &data);
void insertEquation(const WPXPropertyList &propList, const WPXString &data);
// Register special converter for certain embedded binary objects
void registerEmbeddedObjectHandler(const WPXString &mimeType, OdfEmbeddedObject objectHandler);
void registerEmbeddedImageHandler(const WPXString &mimeType, OdfEmbeddedImage imageHandler);
private:
OdtGeneratorPrivate *mpImpl;
};
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* SectionStyle: Stores (and writes) section-based information (e.g.: a column
* break needs a new section) that is needed at the head of an OO document and
* is referenced throughout the entire 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
*/
/* "This product is not manufactured, approved, or supported by
* Corel Corporation or Corel Corporation Limited."
*/
#include "FilterInternal.hxx"
#include "PageSpan.hxx"
#include "DocumentElement.hxx"
PageSpan::PageSpan(const WPXPropertyList &xPropList) :
mxPropList(xPropList),
mpHeaderContent(0),
mpFooterContent(0),
mpHeaderLeftContent(0),
mpFooterLeftContent(0)
{
}
namespace
{
typedef std::vector<DocumentElement *>::iterator DEVIter;
}
PageSpan::~PageSpan()
{
if (mpHeaderContent)
{
for (DEVIter iterHeaderContent = mpHeaderContent->begin();
iterHeaderContent != mpHeaderContent->end();
++iterHeaderContent)
delete(*iterHeaderContent);
delete mpHeaderContent;
}
if (mpHeaderLeftContent)
{
for (DEVIter iterHeaderLeftContent = mpHeaderLeftContent->begin();
iterHeaderLeftContent != mpHeaderLeftContent->end();
++iterHeaderLeftContent)
delete(*iterHeaderLeftContent);
delete mpHeaderLeftContent;
}
if (mpFooterContent)
{
for (DEVIter iterFooterContent = mpFooterContent->begin();
iterFooterContent != mpFooterContent->end();
++iterFooterContent)
delete(*iterFooterContent);
delete mpFooterContent;
}
if (mpFooterLeftContent)
{
for (DEVIter iterFooterLeftContent = mpFooterLeftContent->begin();
iterFooterLeftContent != mpFooterLeftContent->end();
++iterFooterLeftContent)
delete(*iterFooterLeftContent);
delete mpFooterLeftContent;
}
}
int PageSpan::getSpan() const
{
if (mxPropList["libwpd:num-pages"])
return mxPropList["libwpd:num-pages"]->getInt();
return 0; // should never happen
}
void PageSpan::setHeaderContent(std::vector<DocumentElement *> * pHeaderContent)
{
if (mpHeaderContent)
{
for (DEVIter iterHeaderContent = mpHeaderContent->begin();
iterHeaderContent != mpHeaderContent->end();
++iterHeaderContent)
delete(*iterHeaderContent);
delete mpHeaderContent;
}
mpHeaderContent = pHeaderContent;
}
void PageSpan::setFooterContent(std::vector<DocumentElement *> * pFooterContent)
{
if (mpFooterContent)
{
for (DEVIter iterFooterContent = mpFooterContent->begin();
iterFooterContent != mpFooterContent->end();
++iterFooterContent)
delete(*iterFooterContent);
delete mpFooterContent;
}
mpFooterContent = pFooterContent;
}
void PageSpan::setHeaderLeftContent(std::vector<DocumentElement *> * pHeaderContent)
{
if (mpHeaderLeftContent)
{
for (DEVIter iterHeaderLeftContent = mpHeaderLeftContent->begin();
iterHeaderLeftContent != mpHeaderLeftContent->end();
++iterHeaderLeftContent)
delete(*iterHeaderLeftContent);
delete mpHeaderLeftContent;
}
mpHeaderLeftContent = pHeaderContent;
}
void PageSpan::setFooterLeftContent(std::vector<DocumentElement *> * pFooterContent)
{
if (mpFooterLeftContent)
{
for (DEVIter iterFooterLeftContent = mpFooterLeftContent->begin();
iterFooterLeftContent != mpFooterLeftContent->end();
++iterFooterLeftContent)
delete(*iterFooterLeftContent);
delete mpFooterLeftContent;
}
mpFooterLeftContent = pFooterContent;
}
void PageSpan::writePageLayout(const int iNum, OdfDocumentHandler *pHandler) const
{
WPXPropertyList propList;
WPXString sPageLayoutName;
sPageLayoutName.sprintf("PM%i", iNum+2);
propList.insert("style:name", sPageLayoutName);
pHandler->startElement("style:page-layout", propList);
WPXPropertyList tempPropList = mxPropList;
if (!tempPropList["style:writing-mode"])
tempPropList.insert("style:writing-mode", WPXString("lr-tb"));
if (!tempPropList["style:footnote-max-height"])
tempPropList.insert("style:footnote-max-height", WPXString("0in"));
pHandler->startElement("style:page-layout-properties", tempPropList);
WPXPropertyList footnoteSepPropList;
footnoteSepPropList.insert("style:width", WPXString("0.0071in"));
footnoteSepPropList.insert("style:distance-before-sep", WPXString("0.0398in"));
footnoteSepPropList.insert("style:distance-after-sep", WPXString("0.0398in"));
footnoteSepPropList.insert("style:adjustment", WPXString("left"));
footnoteSepPropList.insert("style:rel-width", WPXString("25%"));
footnoteSepPropList.insert("style:color", WPXString("#000000"));
pHandler->startElement("style:footnote-sep", footnoteSepPropList);
pHandler->endElement("style:footnote-sep");
pHandler->endElement("style:page-layout-properties");
pHandler->endElement("style:page-layout");
}
void PageSpan::writeMasterPages(const int iStartingNum, const int iPageLayoutNum, const bool bLastPageSpan,
OdfDocumentHandler *pHandler) const
{
int iSpan = 0;
(bLastPageSpan) ? iSpan = 1 : iSpan = getSpan();
for (int i=iStartingNum; i<(iStartingNum+iSpan); ++i)
{
TagOpenElement masterPageOpen("style:master-page");
WPXString sMasterPageName, sMasterPageDisplayName;
sMasterPageName.sprintf("Page_Style_%i", i);
sMasterPageDisplayName.sprintf("Page Style %i", i);
WPXString sPageLayoutName;
WPXPropertyList propList;
sPageLayoutName.sprintf("PM%i", iPageLayoutNum+2);
propList.insert("style:name", sMasterPageName);
propList.insert("style:display-name", sMasterPageDisplayName);
propList.insert("style:page-layout-name", sPageLayoutName);
if (!bLastPageSpan)
{
WPXString sNextMasterPageName;
sNextMasterPageName.sprintf("Page_Style_%i", (i+1));
propList.insert("style:next-style-name", sNextMasterPageName);
}
pHandler->startElement("style:master-page", propList);
if (mpHeaderContent)
{
_writeHeaderFooter("style:header", *mpHeaderContent, pHandler);
pHandler->endElement("style:header");
if (mpHeaderLeftContent)
{
_writeHeaderFooter("style:header-left", *mpHeaderLeftContent, pHandler);
pHandler->endElement("style:header-left");
}
}
else if (mpHeaderLeftContent)
{
TagOpenElement("style:header").write(pHandler);
pHandler->endElement("style:header");
_writeHeaderFooter("style:header-left", *mpHeaderLeftContent, pHandler);
pHandler->endElement("style:header-left");
}
if (mpFooterContent)
{
_writeHeaderFooter("style:footer", *mpFooterContent, pHandler);
pHandler->endElement("style:footer");
if (mpFooterLeftContent)
{
_writeHeaderFooter("style:footer-left", *mpFooterLeftContent, pHandler);
pHandler->endElement("style:footer-left");
}
}
else if (mpFooterLeftContent)
{
TagOpenElement("style:footer").write(pHandler);
pHandler->endElement("style:footer");
_writeHeaderFooter("style:footer-left", *mpFooterLeftContent, pHandler);
pHandler->endElement("style:footer-left");
}
pHandler->endElement("style:master-page");
}
}
void PageSpan::_writeHeaderFooter(const char *headerFooterTagName,
const std::vector<DocumentElement *> & headerFooterContent,
OdfDocumentHandler *pHandler) const
{
TagOpenElement headerFooterOpen(headerFooterTagName);
headerFooterOpen.write(pHandler);
for (std::vector<DocumentElement *>::const_iterator iter = headerFooterContent.begin();
iter != headerFooterContent.end();
++iter)
{
(*iter)->write(pHandler);
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* PageSpan: Stores (and writes) page-based information (e.g.: margins,
* headers/footers)
*
* 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
*/
/* "This product is not manufactured, approved, or supported by
* Corel Corporation or Corel Corporation Limited."
*/
#ifndef _PAGESPAN_H
#define _PAGESPAN_H
#include <libwpd/libwpd.h>
#include <vector>
class DocumentElement;
class OdfDocumentHandler;
class PageSpan
{
public:
PageSpan(const WPXPropertyList &xPropList);
virtual ~PageSpan();
void writePageLayout(const int iNum, OdfDocumentHandler *pHandler) const;
void writeMasterPages(const int iStartingNum, const int iPageLayoutNum, const bool bLastPageSpan, OdfDocumentHandler *pHandler) const;
int getSpan() const;
void setHeaderContent(std::vector<DocumentElement *> * pHeaderContent);
void setFooterContent(std::vector<DocumentElement *> * pFooterContent);
void setHeaderLeftContent(std::vector<DocumentElement *> * pHeaderContent);
void setFooterLeftContent(std::vector<DocumentElement *> * pFooterContent);
protected:
void _writeHeaderFooter(const char *headerFooterTagName, const std::vector<DocumentElement *> & headerFooterContent,
OdfDocumentHandler *pHandler) const;
private:
WPXPropertyList mxPropList;
std::vector<DocumentElement *> * mpHeaderContent;
std::vector<DocumentElement *> * mpFooterContent;
std::vector<DocumentElement *> * mpHeaderLeftContent;
std::vector<DocumentElement *> * mpFooterLeftContent;
};
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* SectionStyle: Stores (and writes) section-based information (e.g.: a column
* break needs a new section) that is needed at the head of an OO document and
* is referenced throughout the entire 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
*/
/* "This product is not manufactured, approved, or supported by
* Corel Corporation or Corel Corporation Limited."
*/
#include "FilterInternal.hxx"
#include "SectionStyle.hxx"
#include "DocumentElement.hxx"
#include <math.h>
#ifdef _MSC_VER
double rint(double x);
#endif /* _WIN32 */
SectionStyle::SectionStyle(const WPXPropertyList &xPropList,
const WPXPropertyListVector &xColumns,
const char *psName) :
Style(psName),
mPropList(xPropList),
mColumns(xColumns)
{
}
void SectionStyle::write(OdfDocumentHandler *pHandler) const
{
TagOpenElement styleOpen("style:style");
styleOpen.addAttribute("style:name", getName());
styleOpen.addAttribute("style:family", "section");
styleOpen.write(pHandler);
// if the number of columns is <= 1, we will never come here. This is only an additional check
// style properties
pHandler->startElement("style:section-properties", mPropList);
// column properties
WPXPropertyList columnProps;
if (mColumns.count() > 1)
{
columnProps.insert("fo:column-count", (int)mColumns.count());
pHandler->startElement("style:columns", columnProps);
WPXPropertyListVector::Iter i(mColumns);
for (i.rewind(); i.next();)
{
pHandler->startElement("style:column", i());
pHandler->endElement("style:column");
}
}
else
{
columnProps.insert("fo:column-count", 0);
columnProps.insert("fo:column-gap", 0.0);
pHandler->startElement("style:columns", columnProps);
}
pHandler->endElement("style:columns");
pHandler->endElement("style:section-properties");
pHandler->endElement("style:style");
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* SectionStyle: Stores (and writes) section-based information (e.g.: a column
* change needs a new section) 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
*/
/* "This product is not manufactured, approved, or supported by
* Corel Corporation or Corel Corporation Limited."
*/
#ifndef _SECTIONSTYLE_H
#define _SECTIONSTYLE_H
#include <libwpd/libwpd.h>
#include <libwpd/WPXPropertyListVector.h>
#include "Style.hxx"
class SectionStyle : public Style
{
public:
SectionStyle(const WPXPropertyList &xPropList, const WPXPropertyListVector &xColumns, const char *psName);
virtual void write(OdfDocumentHandler *pHandler) const;
private:
WPXPropertyList mPropList;
WPXPropertyListVector mColumns;
};
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* Style: A base class from which all other styles are inherited, includes
* a name.
*
* 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
*/
/* "This product is not manufactured, approved, or supported by
* Corel Corporation or Corel Corporation Limited."
*/
#ifndef _STYLE_H
#define _STYLE_H
#include <libwpd/libwpd.h>
#include "DocumentElement.hxx"
class TopLevelElementStyle
{
public:
TopLevelElementStyle() : mpsMasterPageName(0) {}
virtual ~TopLevelElementStyle()
{
if (mpsMasterPageName) delete mpsMasterPageName;
}
void setMasterPageName(WPXString &sMasterPageName)
{
mpsMasterPageName = new WPXString(sMasterPageName);
}
const WPXString *getMasterPageName() const
{
return mpsMasterPageName;
}
private:
TopLevelElementStyle(const TopLevelElementStyle &);
TopLevelElementStyle &operator=(const TopLevelElementStyle &);
WPXString *mpsMasterPageName;
};
class Style
{
public:
Style(const WPXString &psName) : msName(psName) {}
virtual ~Style() {}
virtual void write(OdfDocumentHandler *) const {};
const WPXString &getName() const
{
return msName;
}
private:
WPXString msName;
};
class StyleManager
{
public:
StyleManager() {}
virtual ~StyleManager() {}
virtual void clean() {};
virtual void write(OdfDocumentHandler *) const = 0;
private:
// forbide copy constructor/operator
StyleManager(const StyleManager &);
StyleManager &operator=(const StyleManager &);
};
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
This diff is collapsed.
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* TableStyle: Stores (and writes) table-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
*/
/* "This product is not manufactured, approved, or supported by
* Corel Corporation or Corel Corporation Limited."
*/
#ifndef _TABLESTYLE_H
#define _TABLESTYLE_H
#include <libwpd/libwpd.h>
#include <vector>
#include "Style.hxx"
class OdfDocumentHandler;
class TableCellStyle : public Style
{
public:
virtual ~TableCellStyle() {};
TableCellStyle(const WPXPropertyList &xPropList, const char *psName);
virtual void write(OdfDocumentHandler *pHandler) const;
private:
WPXPropertyList mPropList;
};
class TableRowStyle : public Style
{
public:
virtual ~TableRowStyle() {};
TableRowStyle(const WPXPropertyList &propList, const char *psName);
virtual void write(OdfDocumentHandler *pHandler) const;
private:
WPXPropertyList mPropList;
};
class TableStyle : public Style, public TopLevelElementStyle
{
public:
TableStyle(const WPXPropertyList &xPropList, const WPXPropertyListVector &columns, const char *psName);
virtual ~TableStyle();
virtual void write(OdfDocumentHandler *pHandler) const;
int getNumColumns() const
{
return mColumns.count();
}
void addTableCellStyle(TableCellStyle *pTableCellStyle)
{
mTableCellStyles.push_back(pTableCellStyle);
}
int getNumTableCellStyles()
{
return mTableCellStyles.size();
}
void addTableRowStyle(TableRowStyle *pTableRowStyle)
{
mTableRowStyles.push_back(pTableRowStyle);
}
int getNumTableRowStyles()
{
return mTableRowStyles.size();
}
private:
WPXPropertyList mPropList;
WPXPropertyListVector mColumns;
std::vector<TableCellStyle *> mTableCellStyles;
std::vector<TableRowStyle *> mTableRowStyles;
};
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment