summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2017-11-27 08:27:05 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2017-11-27 12:39:58 +0100
commit944cc09cf76cea46d9f6bd7be14c64f74fe64403 (patch)
tree948168ace52e54e96b1d8de9c8146409e016b35e
parentcb682e03bd8f1ae852135dc7a68d6926d9356405 (diff)
EPUB export: fix char props of <text:sequence> characters
These are typically inherited from parent, <text:sequence> is similar to e.g. <text:span> in this regard. Change-Id: Ic84f6e2e4fc6866ffca23eef2c932ee63e6978ca Reviewed-on: https://gerrit.libreoffice.org/45314 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r--writerperfect/qa/unit/EPUBExportTest.cxx5
-rw-r--r--writerperfect/qa/unit/data/writer/epubexport/text-box.fodt7
-rw-r--r--writerperfect/source/writer/exp/txtparai.cxx15
3 files changed, 21 insertions, 6 deletions
diff --git a/writerperfect/qa/unit/EPUBExportTest.cxx b/writerperfect/qa/unit/EPUBExportTest.cxx
index 25d1a35c1873..fb54f5ab25d7 100644
--- a/writerperfect/qa/unit/EPUBExportTest.cxx
+++ b/writerperfect/qa/unit/EPUBExportTest.cxx
@@ -578,6 +578,7 @@ void EPUBExportTest::testTextBox()
createDoc("text-box.fodt", {});
mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml");
+ std::map< OUString, std::vector<OUString> > aCssDoc = parseCss("OEBPS/styles/stylesheet.css");
// This failed, image with caption was lost.
assertXPath(mpXmlDoc, "//xhtml:img", "class", "frame1");
@@ -586,6 +587,10 @@ void EPUBExportTest::testTextBox()
// 2) "Illustration "
// 3) The sequence field, this was missing (was ": foo" instead).
assertXPathContent(mpXmlDoc, "//xhtml:div/xhtml:p/xhtml:span[3]", "1");
+
+ OUString aClass = getXPath(mpXmlDoc, "//xhtml:div/xhtml:p/xhtml:span[3]", "class");
+ // This failed, the 3rd span was not italic.
+ CPPUNIT_ASSERT_EQUAL(OUString("italic"), EPUBExportTest::getCss(aCssDoc, aClass, "font-style"));
}
CPPUNIT_TEST_SUITE_REGISTRATION(EPUBExportTest);
diff --git a/writerperfect/qa/unit/data/writer/epubexport/text-box.fodt b/writerperfect/qa/unit/data/writer/epubexport/text-box.fodt
index dad8d20b149b..d3a1786821f8 100644
--- a/writerperfect/qa/unit/data/writer/epubexport/text-box.fodt
+++ b/writerperfect/qa/unit/data/writer/epubexport/text-box.fodt
@@ -9,6 +9,9 @@
</style:style>
</office:styles>
<office:automatic-styles>
+ <style:style style:name="T1" style:family="text">
+ <style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic"/>
+ </style:style>
<style:style style:name="fr1" style:family="graphic" style:parent-style-name="Frame">
<style:graphic-properties fo:margin-left="0cm" fo:margin-right="0cm" fo:margin-top="0cm" fo:margin-bottom="0cm" style:wrap="none" style:vertical-pos="top" style:vertical-rel="paragraph" style:horizontal-pos="center" style:horizontal-rel="paragraph" fo:padding="0.049cm" fo:border="0.99pt dashed #ed1c24" style:shadow="none" draw:shadow-opacity="100%"/>
</style:style>
@@ -24,7 +27,7 @@
<text:sequence-decl text:display-outline-level="0" text:name="Text"/>
<text:sequence-decl text:display-outline-level="0" text:name="Drawing"/>
</text:sequence-decls>
- <text:p><draw:frame draw:style-name="fr1" draw:name="Frame1" text:anchor-type="char" svg:width="5.674cm" draw:z-index="0"><draw:text-box fo:min-height="3.336cm"><text:p><draw:frame draw:style-name="fr2" draw:name="Object0" text:anchor-type="as-char" svg:width="1.663cm" style:rel-width="100%" svg:height="1.663cm" style:rel-height="scale" draw:z-index="1"><draw:image><office:binary-data>iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAQAAAAAYLlVAAAABGdBTUEAALGPC/xhBQAAAAFz
+ <text:p text:style-name="Standard"><draw:frame draw:style-name="fr1" draw:name="Frame1" text:anchor-type="char" svg:width="5.674cm" draw:z-index="0"><draw:text-box fo:min-height="3.336cm"><text:p text:style-name="Frame_20_contents"><draw:frame draw:style-name="fr2" draw:name="Object0" text:anchor-type="as-char" svg:width="1.663cm" style:rel-width="100%" svg:height="1.663cm" style:rel-height="scale" draw:z-index="1"><draw:image loext:mime-type="image/png"><office:binary-data>iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAQAAAAAYLlVAAAABGdBTUEAALGPC/xhBQAAAAFz
UkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAA
AAJiS0dEAACqjSMyAAAACW9GRnMAAAAGAAAAAAAMc1XTAAAACXBIWXMAAA3XAAAN1wFCKJt4
AAAACXZwQWcAAABMAAAAQACdMTgbAAABzUlEQVRo3u3ZPU/CQBjA8X+Jxs3ESUDj4iK+LA5+
@@ -39,7 +42,7 @@
hOCNQr34oD4AAAAldEVYdGNyZWF0ZS1kYXRlADIwMTAtMTItMjBUMTc6MDg6MzYrMDE6MDB6
5RscAAAAJXRFWHRtb2RpZnktZGF0ZQAyMDEwLTEyLTIwVDE3OjA4OjM3KzAxOjAwgyNmnAAA
AABJRU5ErkJggg==
- </office:binary-data></draw:image></draw:frame><text:span><text:line-break/></text:span><text:span>Illustration </text:span><text:span><text:sequence text:ref-name="refIllustration0" text:name="Illustration" text:formula="ooow:Illustration+1" style:num-format="1">1</text:sequence></text:span><text:span>: foo</text:span></text:p></draw:text-box></draw:frame>bar</text:p>
+ </office:binary-data></draw:image></draw:frame><text:line-break/><text:span text:style-name="T1">Illustration </text:span><text:span text:style-name="T1"><text:sequence text:ref-name="refIllustration0" text:name="Illustration" text:formula="ooow:Illustration+1" style:num-format="1">1</text:sequence></text:span><text:span text:style-name="T1">: foo</text:span></text:p></draw:text-box></draw:frame>bar</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 75144f5a1f19..b1359953e325 100644
--- a/writerperfect/source/writer/exp/txtparai.cxx
+++ b/writerperfect/source/writer/exp/txtparai.cxx
@@ -58,19 +58,26 @@ namespace exp
class XMLTextSequenceContext : public XMLImportContext
{
public:
- XMLTextSequenceContext(XMLImport &rImport);
+ XMLTextSequenceContext(XMLImport &rImport, const librevenge::RVNGPropertyList &rPropertyList);
void SAL_CALL characters(const OUString &rChars) override;
+
+private:
+ librevenge::RVNGPropertyList m_aPropertyList;
};
-XMLTextSequenceContext::XMLTextSequenceContext(XMLImport &rImport)
+XMLTextSequenceContext::XMLTextSequenceContext(XMLImport &rImport, const librevenge::RVNGPropertyList &rPropertyList)
: XMLImportContext(rImport)
{
+ // Inherit properties from parent.
+ librevenge::RVNGPropertyList::Iter itProp(rPropertyList);
+ for (itProp.rewind(); itProp.next();)
+ m_aPropertyList.insert(itProp.key(), itProp()->clone());
}
void XMLTextSequenceContext::characters(const OUString &rChars)
{
- mrImport.GetGenerator().openSpan(librevenge::RVNGPropertyList());
+ mrImport.GetGenerator().openSpan(m_aPropertyList);
OString sCharU8 = OUStringToOString(rChars, RTL_TEXTENCODING_UTF8);
mrImport.GetGenerator().insertText(librevenge::RVNGString(sCharU8.getStr()));
@@ -349,7 +356,7 @@ rtl::Reference<XMLImportContext> CreateParagraphOrSpanChildContext(XMLImport &rI
if (rName == "draw:frame")
return new XMLTextFrameContext(rImport);
if (rName == "text:sequence")
- return new XMLTextSequenceContext(rImport);
+ return new XMLTextSequenceContext(rImport, rTextPropertyList);
return nullptr;
}