diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-09-07 17:29:18 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-09-07 20:59:10 +0200 |
commit | 01cc6e5107c706760939c2331ca57247bd02cb77 (patch) | |
tree | de627ff1d2d1038a656c5a759702d7ad2f74c5c6 /writerperfect | |
parent | 5ffe8f05590e43eb8a668bb6da1f2e2ce0a7f713 (diff) |
EPUB export: handle span-level line break
By pulling out common part of the paragraph/span context factory.
Change-Id: If5fda87ce9f60e7e10d7f9406c30740bc8707143
Reviewed-on: https://gerrit.libreoffice.org/42064
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 | 4 | ||||
-rw-r--r-- | writerperfect/qa/unit/data/writer/epubexport/line-break.fodt | 14 | ||||
-rw-r--r-- | writerperfect/source/writer/exp/txtparai.cxx | 13 | ||||
-rw-r--r-- | writerperfect/source/writer/exp/txtparai.hxx | 3 |
4 files changed, 28 insertions, 6 deletions
diff --git a/writerperfect/qa/unit/EPUBExportTest.cxx b/writerperfect/qa/unit/EPUBExportTest.cxx index 3bce1b5a9ba5..0d869737fc8e 100644 --- a/writerperfect/qa/unit/EPUBExportTest.cxx +++ b/writerperfect/qa/unit/EPUBExportTest.cxx @@ -325,7 +325,9 @@ void EPUBExportTest::testLineBreak() mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml"); // This was 0, line break was not handled. - assertXPath(mpXmlDoc, "//xhtml:p/xhtml:br", 1); + assertXPath(mpXmlDoc, "//xhtml:p[1]/xhtml:br", 1); + // This was 0, line break inside span was not handled. + assertXPath(mpXmlDoc, "//xhtml:p[2]/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 index c380f6df0063..1a6fca72b08a 100644 --- a/writerperfect/qa/unit/data/writer/epubexport/line-break.fodt +++ b/writerperfect/qa/unit/data/writer/epubexport/line-break.fodt @@ -1,8 +1,20 @@ <?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: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" xmlns:officeooo="http://openoffice.org/2009/office" office:version="1.2" office:mimetype="application/vnd.oasis.opendocument.text"> + <office:automatic-styles> + <style:style style:name="T1" style:family="text"> + <style:text-properties officeooo:rsid="000075b1"/> + </style:style> + <style:style style:name="T2" style:family="text"> + <style:text-properties fo:font-weight="bold"/> + </style:style> + <style:style style:name="T3" style:family="text"> + <style:text-properties fo:font-weight="bold" officeooo:rsid="000075b1"/> + </style:style> + </office:automatic-styles> <office:body> <office:text> <text:p>a<text:line-break/>b</text:p> + <text:p><text:span text:style-name="T1">a</text:span><text:span text:style-name="T2">a<text:line-break/></text:span><text:span text:style-name="T3">b</text:span>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 c476904277e2..b085537cf106 100644 --- a/writerperfect/source/writer/exp/txtparai.cxx +++ b/writerperfect/source/writer/exp/txtparai.cxx @@ -103,7 +103,7 @@ XMLImportContext *XMLSpanContext::CreateChildContext(const OUString &rName, cons return new XMLTextFrameContext(mrImport); if (rName == "text:span") return new XMLSpanContext(mrImport, &m_aPropertyList); - return nullptr; + return writerperfect::exp::CreateChildContext(mrImport, rName); } void XMLSpanContext::startElement(const OUString &/*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) @@ -207,9 +207,7 @@ 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; + return writerperfect::exp::CreateChildContext(mrImport, rName); } void XMLParaContext::startElement(const OUString &/*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) @@ -253,6 +251,13 @@ void XMLParaContext::characters(const OUString &rChars) mrImport.GetGenerator().closeSpan(); } +XMLImportContext *CreateChildContext(XMLImport &rImport, const OUString &rName) +{ + if (rName == "text:line-break") + return new XMLLineBreakContext(rImport); + return nullptr; +} + } // namespace exp } // namespace writerperfect diff --git a/writerperfect/source/writer/exp/txtparai.hxx b/writerperfect/source/writer/exp/txtparai.hxx index 61c3fc5bfc73..52543ffeadde 100644 --- a/writerperfect/source/writer/exp/txtparai.hxx +++ b/writerperfect/source/writer/exp/txtparai.hxx @@ -33,6 +33,9 @@ private: OUString m_aStyleName; }; +/// Shared child context factory for paragraph and span contexts. +XMLImportContext *CreateChildContext(XMLImport &rImport, const OUString &rName); + } // namespace exp } // namespace writerperfect |