summaryrefslogtreecommitdiff
path: root/writerperfect/source/writer/exp/xmltbli.cxx
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 /writerperfect/source/writer/exp/xmltbli.cxx
parent15253417276d3239a57b37dfa608f5b8eab9912a (diff)
EPUB export: initial table support
Focusing on just not loosing plain text content, no actual formatting yet. Change-Id: Ic242f849730e1eb174f621f2235fa04563024e4e
Diffstat (limited to 'writerperfect/source/writer/exp/xmltbli.cxx')
-rw-r--r--writerperfect/source/writer/exp/xmltbli.cxx117
1 files changed, 117 insertions, 0 deletions
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: */