summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2017-08-22 17:53:33 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2017-08-22 17:53:51 +0200
commit54ad8ad0f0ce22299d28b4ec09eea26ad2691642 (patch)
tree7187c106ba7c775986e1a473c87bfa723b2b0d33
parent15253417276d3239a57b37dfa608f5b8eab9912a (diff)
EPUB export: initial table support
Focusing on just not loosing plain text content, no actual formatting yet. Change-Id: Ic242f849730e1eb174f621f2235fa04563024e4e
-rw-r--r--writerperfect/Library_wpftwriter.mk1
-rw-r--r--writerperfect/source/writer/exp/xmltbli.cxx117
-rw-r--r--writerperfect/source/writer/exp/xmltbli.hxx37
-rw-r--r--writerperfect/source/writer/exp/xmltext.cxx3
4 files changed, 158 insertions, 0 deletions
diff --git a/writerperfect/Library_wpftwriter.mk b/writerperfect/Library_wpftwriter.mk
index 1f28b440b05b..9cbef7f31309 100644
--- a/writerperfect/Library_wpftwriter.mk
+++ b/writerperfect/Library_wpftwriter.mk
@@ -81,6 +81,7 @@ $(eval $(call gb_Library_add_exception_objects,wpftwriter,\
writerperfect/source/writer/exp/xmlictxt \
writerperfect/source/writer/exp/xmlimp \
writerperfect/source/writer/exp/xmlmetai \
+ writerperfect/source/writer/exp/xmltbli \
writerperfect/source/writer/exp/xmltext \
))
diff --git a/writerperfect/source/writer/exp/xmltbli.cxx b/writerperfect/source/writer/exp/xmltbli.cxx
new file mode 100644
index 000000000000..bcdc4cb46220
--- /dev/null
+++ b/writerperfect/source/writer/exp/xmltbli.cxx
@@ -0,0 +1,117 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "xmltbli.hxx"
+
+#include "txtparai.hxx"
+#include "xmlimp.hxx"
+
+using namespace com::sun::star;
+
+namespace writerperfect
+{
+namespace exp
+{
+
+/// Handler for <table:cell>.
+class XMLTableCellContext : public XMLImportContext
+{
+public:
+ XMLTableCellContext(XMLImport &rImport);
+
+ XMLImportContext *CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override;
+
+ void SAL_CALL startElement(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override;
+ void SAL_CALL endElement(const OUString &rName) override;
+};
+
+XMLTableCellContext::XMLTableCellContext(XMLImport &rImport)
+ : XMLImportContext(rImport)
+{
+}
+
+XMLImportContext *XMLTableCellContext::CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &/*xAttribs*/)
+{
+ if (rName == "text:p" || rName == "text:h")
+ return new XMLParaContext(mrImport);
+ if (rName == "table:table")
+ return new XMLTableContext(mrImport);
+ return nullptr;
+}
+
+void XMLTableCellContext::startElement(const OUString &/*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList> &/*xAttribs*/)
+{
+ mrImport.GetGenerator().openTableCell(librevenge::RVNGPropertyList());
+}
+
+void XMLTableCellContext::endElement(const OUString &/*rName*/)
+{
+ mrImport.GetGenerator().closeTableCell();
+}
+
+/// Handler for <table:row>.
+class XMLTableRowContext : public XMLImportContext
+{
+public:
+ XMLTableRowContext(XMLImport &rImport);
+
+ XMLImportContext *CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override;
+
+ void SAL_CALL startElement(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override;
+ void SAL_CALL endElement(const OUString &rName) override;
+};
+
+XMLTableRowContext::XMLTableRowContext(XMLImport &rImport)
+ : XMLImportContext(rImport)
+{
+}
+
+XMLImportContext *XMLTableRowContext::CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &/*xAttribs*/)
+{
+ if (rName == "table:table-cell")
+ return new XMLTableCellContext(mrImport);
+ return nullptr;
+}
+
+void XMLTableRowContext::startElement(const OUString &/*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList> &/*xAttribs*/)
+{
+ mrImport.GetGenerator().openTableRow(librevenge::RVNGPropertyList());
+}
+
+void XMLTableRowContext::endElement(const OUString &/*rName*/)
+{
+ mrImport.GetGenerator().closeTableRow();
+}
+
+XMLTableContext::XMLTableContext(XMLImport &rImport)
+ : XMLImportContext(rImport)
+{
+}
+
+XMLImportContext *XMLTableContext::CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &/*xAttribs*/)
+{
+ if (rName == "table:table-row")
+ return new XMLTableRowContext(mrImport);
+ return nullptr;
+}
+
+void XMLTableContext::startElement(const OUString &/*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList> &/*xAttribs*/)
+{
+ mrImport.GetGenerator().openTable(librevenge::RVNGPropertyList());
+}
+
+void XMLTableContext::endElement(const OUString &/*rName*/)
+{
+ mrImport.GetGenerator().closeTable();
+}
+
+} // namespace exp
+} // namespace writerperfect
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerperfect/source/writer/exp/xmltbli.hxx b/writerperfect/source/writer/exp/xmltbli.hxx
new file mode 100644
index 000000000000..ceeb098c1f9c
--- /dev/null
+++ b/writerperfect/source/writer/exp/xmltbli.hxx
@@ -0,0 +1,37 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_WRITERPERFECT_SOURCE_WRITER_EXP_XMLTBLI_HXX
+#define INCLUDED_WRITERPERFECT_SOURCE_WRITER_EXP_XMLTBLI_HXX
+
+#include "xmlictxt.hxx"
+
+namespace writerperfect
+{
+namespace exp
+{
+
+/// Handler for <table:table>.
+class XMLTableContext : public XMLImportContext
+{
+public:
+ XMLTableContext(XMLImport &rImport);
+
+ XMLImportContext *CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override;
+
+ void SAL_CALL startElement(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override;
+ void SAL_CALL endElement(const OUString &rName) override;
+};
+
+} // namespace exp
+} // namespace writerperfect
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerperfect/source/writer/exp/xmltext.cxx b/writerperfect/source/writer/exp/xmltext.cxx
index 5560e7523a54..f2e47c18ecff 100644
--- a/writerperfect/source/writer/exp/xmltext.cxx
+++ b/writerperfect/source/writer/exp/xmltext.cxx
@@ -10,6 +10,7 @@
#include "xmltext.hxx"
#include "txtparai.hxx"
+#include "xmltbli.hxx"
using namespace com::sun::star;
@@ -27,6 +28,8 @@ XMLImportContext *XMLBodyContentContext::CreateChildContext(const OUString &rNam
{
if (rName == "text:p" || rName == "text:h")
return new XMLParaContext(mrImport);
+ if (rName == "table:table")
+ return new XMLTableContext(mrImport);
return nullptr;
}