diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-09-07 15:26:21 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-09-07 17:27:55 +0200 |
commit | bf3a87d1ee9106161d26f33c1ccb6b7b0d0aa0b9 (patch) | |
tree | d099d9dcbc59742a4caf947c11b36e27e320d843 /writerperfect | |
parent | dd89afa6ee8166b69e7a1e86f22616ca8fc122c9 (diff) |
EPUB export: handle line break
When it's directly under <text:p>, as a start.
Change-Id: I05e7decbcfa2f4dae36c01179d7efd7c8645a26b
Reviewed-on: https://gerrit.libreoffice.org/42059
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'writerperfect')
-rw-r--r-- | writerperfect/qa/unit/EPUBExportTest.cxx | 11 | ||||
-rw-r--r-- | writerperfect/qa/unit/data/writer/epubexport/line-break.fodt | 8 | ||||
-rw-r--r-- | writerperfect/source/writer/exp/txtparai.cxx | 21 |
3 files changed, 40 insertions, 0 deletions
diff --git a/writerperfect/qa/unit/EPUBExportTest.cxx b/writerperfect/qa/unit/EPUBExportTest.cxx index a7bb9c322c5e..3bce1b5a9ba5 100644 --- a/writerperfect/qa/unit/EPUBExportTest.cxx +++ b/writerperfect/qa/unit/EPUBExportTest.cxx @@ -62,6 +62,7 @@ public: void testCharNamedstyle(); void testNamedStyleInheritance(); void testNestedSpan(); + void testLineBreak(); CPPUNIT_TEST_SUITE(EPUBExportTest); CPPUNIT_TEST(testOutlineLevel); @@ -75,6 +76,7 @@ public: CPPUNIT_TEST(testCharNamedstyle); CPPUNIT_TEST(testNamedStyleInheritance); CPPUNIT_TEST(testNestedSpan); + CPPUNIT_TEST(testLineBreak); CPPUNIT_TEST_SUITE_END(); }; @@ -317,6 +319,15 @@ void EPUBExportTest::testNestedSpan() assertCss(aCssDoc, aRed, " font-family: 'Liberation Mono';"); } +void EPUBExportTest::testLineBreak() +{ + createDoc("line-break.fodt", {}); + + mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml"); + // This was 0, line break was not handled. + assertXPath(mpXmlDoc, "//xhtml:p/xhtml:br", 1); +} + CPPUNIT_TEST_SUITE_REGISTRATION(EPUBExportTest); } diff --git a/writerperfect/qa/unit/data/writer/epubexport/line-break.fodt b/writerperfect/qa/unit/data/writer/epubexport/line-break.fodt new file mode 100644 index 000000000000..c380f6df0063 --- /dev/null +++ b/writerperfect/qa/unit/data/writer/epubexport/line-break.fodt @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<office:document office:mimetype="application/vnd.oasis.opendocument.text" office:version="1.2" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"> + <office:body> + <office:text> + <text:p>a<text:line-break/>b</text:p> + </office:text> + </office:body> +</office:document> diff --git a/writerperfect/source/writer/exp/txtparai.cxx b/writerperfect/source/writer/exp/txtparai.cxx index 984070ba7fc4..c476904277e2 100644 --- a/writerperfect/source/writer/exp/txtparai.cxx +++ b/writerperfect/source/writer/exp/txtparai.cxx @@ -133,6 +133,25 @@ void XMLSpanContext::characters(const OUString &rChars) mrImport.GetGenerator().closeSpan(); } +/// Handler for <text:line-break>. +class XMLLineBreakContext : public XMLImportContext +{ +public: + XMLLineBreakContext(XMLImport &rImport); + + void SAL_CALL startElement(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override; +}; + +XMLLineBreakContext::XMLLineBreakContext(XMLImport &rImport) + : XMLImportContext(rImport) +{ +} + +void XMLLineBreakContext::startElement(const OUString &/*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList> &/*xAttribs*/) +{ + mrImport.GetGenerator().insertLineBreak(); +} + /// Handler for <text:a>. class XMLHyperlinkContext : public XMLImportContext { @@ -188,6 +207,8 @@ XMLImportContext *XMLParaContext::CreateChildContext(const OUString &rName, cons return new XMLSpanContext(mrImport, nullptr); if (rName == "text:a") return new XMLHyperlinkContext(mrImport); + if (rName == "text:line-break") + return new XMLLineBreakContext(mrImport); return nullptr; } |