diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-09-08 15:55:03 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-09-08 17:56:22 +0200 |
commit | 687fdc5750ac756f157c663197b998eb471612ef (patch) | |
tree | 23b0ecc6c37a540400ec28f9bcb71f9c1e3e4574 /writerperfect/qa | |
parent | 8d1c4032ed284e656300801b62c982e212315a07 (diff) |
EPUB export: inherit text properties in spans from paragraph
This is similar to nested spans, but here the outer element is a
paragraph.
Change-Id: Ibcdfe5aac54a44797067b06d319d19d2d47d5dd1
Reviewed-on: https://gerrit.libreoffice.org/42104
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'writerperfect/qa')
-rw-r--r-- | writerperfect/qa/unit/EPUBExportTest.cxx | 21 | ||||
-rw-r--r-- | writerperfect/qa/unit/data/writer/epubexport/para-char-props.fodt | 16 |
2 files changed, 35 insertions, 2 deletions
diff --git a/writerperfect/qa/unit/EPUBExportTest.cxx b/writerperfect/qa/unit/EPUBExportTest.cxx index 10fd5eb5a94a..06278d19eb81 100644 --- a/writerperfect/qa/unit/EPUBExportTest.cxx +++ b/writerperfect/qa/unit/EPUBExportTest.cxx @@ -64,6 +64,7 @@ public: void testNestedSpan(); void testLineBreak(); void testEscape(); + void testParaCharProps(); CPPUNIT_TEST_SUITE(EPUBExportTest); CPPUNIT_TEST(testOutlineLevel); @@ -79,6 +80,7 @@ public: CPPUNIT_TEST(testNestedSpan); CPPUNIT_TEST(testLineBreak); CPPUNIT_TEST(testEscape); + CPPUNIT_TEST(testParaCharProps); CPPUNIT_TEST_SUITE_END(); }; @@ -327,9 +329,9 @@ void EPUBExportTest::testLineBreak() mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml"); // This was 0, line break was not handled. - assertXPath(mpXmlDoc, "//xhtml:p[1]/xhtml:br", 1); + assertXPath(mpXmlDoc, "//xhtml:p[1]/xhtml:span/xhtml:br", 1); // This was 0, line break inside span was not handled. - assertXPath(mpXmlDoc, "//xhtml:p[2]/xhtml:br", 1); + assertXPath(mpXmlDoc, "//xhtml:p[2]/xhtml:span/xhtml:br", 1); } void EPUBExportTest::testEscape() @@ -345,6 +347,21 @@ void EPUBExportTest::testEscape() assertXPathContent(mpXmlDoc, "//xhtml:p[1]/xhtml:span[3]", "\t"); } +void EPUBExportTest::testParaCharProps() +{ + createDoc("para-char-props.fodt", {}); + + mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml"); + // Check formatting of the middle span. + OString aMiddle = getXPath(mpXmlDoc, "//xhtml:p/xhtml:span[2]", "class").toUtf8(); + std::map< OString, std::vector<OString> > aCssDoc; + parseCssExport("OEBPS/styles/stylesheet.css", aCssDoc); + assertCss(aCssDoc, aMiddle, " font-style: italic;"); + // Direct para formatting was lost, only direct char formatting was + // written, so this failed. + assertCss(aCssDoc, aMiddle, " font-weight: bold;"); +} + CPPUNIT_TEST_SUITE_REGISTRATION(EPUBExportTest); } diff --git a/writerperfect/qa/unit/data/writer/epubexport/para-char-props.fodt b/writerperfect/qa/unit/data/writer/epubexport/para-char-props.fodt new file mode 100644 index 000000000000..67fe02db2bc5 --- /dev/null +++ b/writerperfect/qa/unit/data/writer/epubexport/para-char-props.fodt @@ -0,0 +1,16 @@ +<?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:text-properties fo:font-weight="bold" /> + </style:style> + <style:style style:name="T1" style:family="text"> + <style:text-properties fo:font-style="italic"/> + </style:style> + </office:automatic-styles> + <office:body> + <office:text> + <text:p text:style-name="P1">a<text:span text:style-name="T1">b</text:span>c</text:p> + </office:text> + </office:body> +</office:document> |