Kaydet (Commit) 4f7034b6 authored tarafından Miklos Vajna's avatar Miklos Vajna

EPUB export: handle text properties from text styles

This is the last combination of style -> direct inheritance that was not
handled previously.

Change-Id: Ie92b38b89a13b81f09cd7300b0d1b939cda3d8ff
Reviewed-on: https://gerrit.libreoffice.org/41952Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
Tested-by: 's avatarJenkins <ci@libreoffice.org>
üst 8a85ed4c
......@@ -55,6 +55,7 @@ public:
void testParaAutostyleCharProps();
void testMeta();
void testParaNamedstyle();
void testCharNamedstyle();
CPPUNIT_TEST_SUITE(EPUBExportTest);
CPPUNIT_TEST(testOutlineLevel);
......@@ -65,6 +66,7 @@ public:
CPPUNIT_TEST(testParaAutostyleCharProps);
CPPUNIT_TEST(testMeta);
CPPUNIT_TEST(testParaNamedstyle);
CPPUNIT_TEST(testCharNamedstyle);
CPPUNIT_TEST_SUITE_END();
};
......@@ -232,6 +234,18 @@ void EPUBExportTest::testParaNamedstyle()
assertXPath(mpXmlDoc, "//xhtml:p[2]/xhtml:span", "class", "span1");
}
void EPUBExportTest::testCharNamedstyle()
{
createDoc("char-namedstyle.fodt", {});
mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml");
// Test character properties from named text style.
assertXPath(mpXmlDoc, "//xhtml:p/xhtml:span[1]", "class", "span0");
// This failed, character properties from text style were not exported.
assertXPath(mpXmlDoc, "//xhtml:p/xhtml:span[2]", "class", "span1");
}
CPPUNIT_TEST_SUITE_REGISTRATION(EPUBExportTest);
}
......
<?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" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" office:version="1.2" office:mimetype="application/vnd.oasis.opendocument.text">
<office:font-face-decls>
<style:font-face style:name="Liberation Mono" svg:font-family="&apos;Liberation Mono&apos;" style:font-family-generic="modern" style:font-pitch="fixed"/>
</office:font-face-decls>
<office:styles>
<style:style style:name="Source_20_Text" style:display-name="Source Text" style:family="text">
<style:text-properties style:font-name="Liberation Mono" fo:font-family="&apos;Liberation Mono&apos;" style:font-family-generic="modern" style:font-pitch="fixed"/>
</style:style>
</office:styles>
<office:body>
<office:text>
<text:p>Foo<text:span text:style-name="Source_20_Text">bar</text:span></text:p>
</office:text>
</office:body>
</office:document>
......@@ -55,13 +55,23 @@ void XMLSpanContext::startElement(const OUString &/*rName*/, const css::uno::Ref
{
// Reference to an automatic text style, try to look it up.
auto itStyle = mrImport.GetAutomaticTextStyles().find(rAttributeValue);
if (itStyle == mrImport.GetAutomaticTextStyles().end())
if (itStyle != mrImport.GetAutomaticTextStyles().end())
{
// Apply properties directly, librevenge has no notion of automatic styles.
librevenge::RVNGPropertyList::Iter itProp(itStyle->second);
for (itProp.rewind(); itProp.next();)
aPropertyList.insert(itProp.key(), itProp()->clone());
continue;
}
// Apply properties directly, librevenge has no notion of automatic styles.
librevenge::RVNGPropertyList::Iter itProp(itStyle->second);
for (itProp.rewind(); itProp.next();)
aPropertyList.insert(itProp.key(), itProp()->clone());
itStyle = mrImport.GetTextStyles().find(rAttributeValue);
if (itStyle != mrImport.GetTextStyles().end())
{
// Apply properties from text style.
librevenge::RVNGPropertyList::Iter itProp(itStyle->second);
for (itProp.rewind(); itProp.next();)
aPropertyList.insert(itProp.key(), itProp()->clone());
}
}
else
{
......
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