[Libreoffice-commits] core.git: writerperfect/Library_wpftwriter.mk writerperfect/qa writerperfect/source

Miklos Vajna vmiklos at collabora.co.uk
Tue Sep 12 18:34:45 UTC 2017


 writerperfect/Library_wpftwriter.mk                        |    2 
 writerperfect/qa/unit/EPUBExportTest.cxx                   |   11 +++
 writerperfect/qa/unit/data/writer/epubexport/list.fodt     |   24 +++++++
 writerperfect/source/writer/exp/XMLTextListContext.cxx     |   36 +++++++++++
 writerperfect/source/writer/exp/XMLTextListContext.hxx     |   34 +++++++++++
 writerperfect/source/writer/exp/XMLTextListItemContext.cxx |   40 +++++++++++++
 writerperfect/source/writer/exp/XMLTextListItemContext.hxx |   34 +++++++++++
 writerperfect/source/writer/exp/xmltext.cxx                |    3 
 8 files changed, 184 insertions(+)

New commits:
commit c49fb2ffaf988b0f9a4480eba5960cc2de16797f
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Sep 12 17:21:53 2017 +0200

    EPUB export: handle list content
    
    Minimal effort to not loose content, no actual list formatting yet.
    
    Change-Id: Ic49ed2f1877c608fc4af5d4aa7ebb3b49908fd86
    Reviewed-on: https://gerrit.libreoffice.org/42214
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Jenkins <ci at libreoffice.org>

diff --git a/writerperfect/Library_wpftwriter.mk b/writerperfect/Library_wpftwriter.mk
index 94ad9a868796..d3d2cc9a209b 100644
--- a/writerperfect/Library_wpftwriter.mk
+++ b/writerperfect/Library_wpftwriter.mk
@@ -79,6 +79,8 @@ $(eval $(call gb_Library_add_exception_objects,wpftwriter,\
 	writerperfect/source/writer/exp/XMLBase64ImportContext \
 	writerperfect/source/writer/exp/XMLSectionContext \
 	writerperfect/source/writer/exp/XMLTextFrameContext \
+	writerperfect/source/writer/exp/XMLTextListContext \
+	writerperfect/source/writer/exp/XMLTextListItemContext \
 	writerperfect/source/writer/exp/txtparai \
 	writerperfect/source/writer/exp/txtstyli \
 	writerperfect/source/writer/exp/xmlfmt \
diff --git a/writerperfect/qa/unit/EPUBExportTest.cxx b/writerperfect/qa/unit/EPUBExportTest.cxx
index 706536c9423a..12f3c9d65f66 100644
--- a/writerperfect/qa/unit/EPUBExportTest.cxx
+++ b/writerperfect/qa/unit/EPUBExportTest.cxx
@@ -66,6 +66,7 @@ public:
     void testEscape();
     void testParaCharProps();
     void testSection();
+    void testList();
 
     CPPUNIT_TEST_SUITE(EPUBExportTest);
     CPPUNIT_TEST(testOutlineLevel);
@@ -83,6 +84,7 @@ public:
     CPPUNIT_TEST(testEscape);
     CPPUNIT_TEST(testParaCharProps);
     CPPUNIT_TEST(testSection);
+    CPPUNIT_TEST(testList);
     CPPUNIT_TEST_SUITE_END();
 };
 
@@ -373,6 +375,15 @@ void EPUBExportTest::testSection()
     assertXPathContent(mpXmlDoc, "//xhtml:p[2]/xhtml:span", "In section.");
 }
 
+void EPUBExportTest::testList()
+{
+    createDoc("list.fodt", {});
+
+    mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml");
+    // This was "C", i.e. in-list content was ignored.
+    assertXPathContent(mpXmlDoc, "//xhtml:p[2]/xhtml:span", "B");
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(EPUBExportTest);
 
 }
diff --git a/writerperfect/qa/unit/data/writer/epubexport/list.fodt b/writerperfect/qa/unit/data/writer/epubexport/list.fodt
new file mode 100644
index 000000000000..399ce78b2247
--- /dev/null
+++ b/writerperfect/qa/unit/data/writer/epubexport/list.fodt
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" office:version="1.2" office:mimetype="application/vnd.oasis.opendocument.text">
+  <office:automatic-styles>
+    <style:style style:name="P1" style:family="paragraph" style:list-style-name="L1"/>
+    <text:list-style style:name="L1">
+      <text:list-level-style-bullet text:level="1" text:bullet-char="•">
+        <style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
+          <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.27cm" fo:text-indent="-0.635cm" fo:margin-left="1.27cm"/>
+        </style:list-level-properties>
+      </text:list-level-style-bullet>
+    </text:list-style>
+  </office:automatic-styles>
+  <office:body>
+    <office:text>
+      <text:p>A</text:p>
+      <text:list xml:id="list1647378619" text:style-name="L1">
+        <text:list-item>
+          <text:p text:style-name="P1">B</text:p>
+        </text:list-item>
+      </text:list>
+      <text:p>C</text:p>
+    </office:text>
+  </office:body>
+</office:document>
diff --git a/writerperfect/source/writer/exp/XMLTextListContext.cxx b/writerperfect/source/writer/exp/XMLTextListContext.cxx
new file mode 100644
index 000000000000..edfd7371b15e
--- /dev/null
+++ b/writerperfect/source/writer/exp/XMLTextListContext.cxx
@@ -0,0 +1,36 @@
+/* -*- 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 "XMLTextListContext.hxx"
+
+#include "XMLTextListItemContext.hxx"
+
+using namespace com::sun::star;
+
+namespace writerperfect
+{
+namespace exp
+{
+
+XMLTextListContext::XMLTextListContext(XMLImport &rImport)
+    : XMLImportContext(rImport)
+{
+}
+
+XMLImportContext *XMLTextListContext::CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &/*xAttribs*/)
+{
+    if (rName == "text:list-item")
+        return new XMLTextListItemContext(mrImport);
+    return nullptr;
+}
+
+} // namespace exp
+} // namespace writerperfect
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerperfect/source/writer/exp/XMLTextListContext.hxx b/writerperfect/source/writer/exp/XMLTextListContext.hxx
new file mode 100644
index 000000000000..533257228fbb
--- /dev/null
+++ b/writerperfect/source/writer/exp/XMLTextListContext.hxx
@@ -0,0 +1,34 @@
+/* -*- 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_XMLTEXTLISTCONTEXT_HXX
+#define INCLUDED_WRITERPERFECT_SOURCE_WRITER_EXP_XMLTEXTLISTCONTEXT_HXX
+
+#include "xmlictxt.hxx"
+
+namespace writerperfect
+{
+namespace exp
+{
+
+/// Handler for <text:list>.
+class XMLTextListContext : public XMLImportContext
+{
+public:
+    XMLTextListContext(XMLImport &rImport);
+
+    XMLImportContext *CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override;
+};
+
+} // namespace exp
+} // namespace writerperfect
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerperfect/source/writer/exp/XMLTextListItemContext.cxx b/writerperfect/source/writer/exp/XMLTextListItemContext.cxx
new file mode 100644
index 000000000000..7b166d52fb42
--- /dev/null
+++ b/writerperfect/source/writer/exp/XMLTextListItemContext.cxx
@@ -0,0 +1,40 @@
+/* -*- 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 "XMLTextListItemContext.hxx"
+
+#include "XMLTextListContext.hxx"
+#include "txtparai.hxx"
+#include "xmlimp.hxx"
+
+using namespace com::sun::star;
+
+namespace writerperfect
+{
+namespace exp
+{
+
+XMLTextListItemContext::XMLTextListItemContext(XMLImport &rImport)
+    : XMLImportContext(rImport)
+{
+}
+
+XMLImportContext *XMLTextListItemContext::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 == "text:list")
+        return new XMLTextListContext(mrImport);
+    return nullptr;
+}
+
+} // namespace exp
+} // namespace writerperfect
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerperfect/source/writer/exp/XMLTextListItemContext.hxx b/writerperfect/source/writer/exp/XMLTextListItemContext.hxx
new file mode 100644
index 000000000000..cb6a68aedf5a
--- /dev/null
+++ b/writerperfect/source/writer/exp/XMLTextListItemContext.hxx
@@ -0,0 +1,34 @@
+/* -*- 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_XMLTEXTLISTITEMCONTEXT_HXX
+#define INCLUDED_WRITERPERFECT_SOURCE_WRITER_EXP_XMLTEXTLISTITEMCONTEXT_HXX
+
+#include "xmlictxt.hxx"
+
+namespace writerperfect
+{
+namespace exp
+{
+
+/// Handler for <text:list-item>.
+class XMLTextListItemContext : public XMLImportContext
+{
+public:
+    XMLTextListItemContext(XMLImport &rImport);
+
+    XMLImportContext *CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) 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 73a6f5e73465..14c5b306dd99 100644
--- a/writerperfect/source/writer/exp/xmltext.cxx
+++ b/writerperfect/source/writer/exp/xmltext.cxx
@@ -12,6 +12,7 @@
 #include "txtparai.hxx"
 #include "xmltbli.hxx"
 #include "XMLSectionContext.hxx"
+#include "XMLTextListContext.hxx"
 
 using namespace com::sun::star;
 
@@ -38,6 +39,8 @@ XMLImportContext *CreateTextChildContext(XMLImport &rImport, const OUString &rNa
         return new XMLSectionContext(rImport);
     if (rName == "table:table")
         return new XMLTableContext(rImport);
+    if (rName == "text:list")
+        return new XMLTextListContext(rImport);
     return nullptr;
 }
 


More information about the Libreoffice-commits mailing list