Kaydet (Commit) 944cc09c authored tarafından Miklos Vajna's avatar Miklos Vajna

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/45314Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
üst cb682e03
...@@ -578,6 +578,7 @@ void EPUBExportTest::testTextBox() ...@@ -578,6 +578,7 @@ void EPUBExportTest::testTextBox()
createDoc("text-box.fodt", {}); createDoc("text-box.fodt", {});
mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml"); 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. // This failed, image with caption was lost.
assertXPath(mpXmlDoc, "//xhtml:img", "class", "frame1"); assertXPath(mpXmlDoc, "//xhtml:img", "class", "frame1");
...@@ -586,6 +587,10 @@ void EPUBExportTest::testTextBox() ...@@ -586,6 +587,10 @@ void EPUBExportTest::testTextBox()
// 2) "Illustration " // 2) "Illustration "
// 3) The sequence field, this was missing (was ": foo" instead). // 3) The sequence field, this was missing (was ": foo" instead).
assertXPathContent(mpXmlDoc, "//xhtml:div/xhtml:p/xhtml:span[3]", "1"); 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); CPPUNIT_TEST_SUITE_REGISTRATION(EPUBExportTest);
......
...@@ -9,6 +9,9 @@ ...@@ -9,6 +9,9 @@
</style:style> </style:style>
</office:styles> </office:styles>
<office:automatic-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: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: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> </style:style>
...@@ -24,7 +27,7 @@ ...@@ -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="Text"/>
<text:sequence-decl text:display-outline-level="0" text:name="Drawing"/> <text:sequence-decl text:display-outline-level="0" text:name="Drawing"/>
</text:sequence-decls> </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 UkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAA
AAJiS0dEAACqjSMyAAAACW9GRnMAAAAGAAAAAAAMc1XTAAAACXBIWXMAAA3XAAAN1wFCKJt4 AAJiS0dEAACqjSMyAAAACW9GRnMAAAAGAAAAAAAMc1XTAAAACXBIWXMAAA3XAAAN1wFCKJt4
AAAACXZwQWcAAABMAAAAQACdMTgbAAABzUlEQVRo3u3ZPU/CQBjA8X+Jxs3ESUDj4iK+LA5+ AAAACXZwQWcAAABMAAAAQACdMTgbAAABzUlEQVRo3u3ZPU/CQBjA8X+Jxs3ESUDj4iK+LA5+
...@@ -39,7 +42,7 @@ ...@@ -39,7 +42,7 @@
hOCNQr34oD4AAAAldEVYdGNyZWF0ZS1kYXRlADIwMTAtMTItMjBUMTc6MDg6MzYrMDE6MDB6 hOCNQr34oD4AAAAldEVYdGNyZWF0ZS1kYXRlADIwMTAtMTItMjBUMTc6MDg6MzYrMDE6MDB6
5RscAAAAJXRFWHRtb2RpZnktZGF0ZQAyMDEwLTEyLTIwVDE3OjA4OjM3KzAxOjAwgyNmnAAA 5RscAAAAJXRFWHRtb2RpZnktZGF0ZQAyMDEwLTEyLTIwVDE3OjA4OjM3KzAxOjAwgyNmnAAA
AABJRU5ErkJggg== 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:text>
</office:body> </office:body>
</office:document> </office:document>
...@@ -58,19 +58,26 @@ namespace exp ...@@ -58,19 +58,26 @@ namespace exp
class XMLTextSequenceContext : public XMLImportContext class XMLTextSequenceContext : public XMLImportContext
{ {
public: public:
XMLTextSequenceContext(XMLImport &rImport); XMLTextSequenceContext(XMLImport &rImport, const librevenge::RVNGPropertyList &rPropertyList);
void SAL_CALL characters(const OUString &rChars) override; 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) : 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) void XMLTextSequenceContext::characters(const OUString &rChars)
{ {
mrImport.GetGenerator().openSpan(librevenge::RVNGPropertyList()); mrImport.GetGenerator().openSpan(m_aPropertyList);
OString sCharU8 = OUStringToOString(rChars, RTL_TEXTENCODING_UTF8); OString sCharU8 = OUStringToOString(rChars, RTL_TEXTENCODING_UTF8);
mrImport.GetGenerator().insertText(librevenge::RVNGString(sCharU8.getStr())); mrImport.GetGenerator().insertText(librevenge::RVNGString(sCharU8.getStr()));
...@@ -349,7 +356,7 @@ rtl::Reference<XMLImportContext> CreateParagraphOrSpanChildContext(XMLImport &rI ...@@ -349,7 +356,7 @@ rtl::Reference<XMLImportContext> CreateParagraphOrSpanChildContext(XMLImport &rI
if (rName == "draw:frame") if (rName == "draw:frame")
return new XMLTextFrameContext(rImport); return new XMLTextFrameContext(rImport);
if (rName == "text:sequence") if (rName == "text:sequence")
return new XMLTextSequenceContext(rImport); return new XMLTextSequenceContext(rImport, rTextPropertyList);
return nullptr; return nullptr;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment