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

EPUB export: handle char format of hyperlinks

<text:a> child elements were not handled.

Change-Id: I7db9c005869934456ffbe5c36347b01cc76645b6
Reviewed-on: https://gerrit.libreoffice.org/43462Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
Tested-by: 's avatarJenkins <ci@libreoffice.org>
üst 66b3970c
......@@ -72,6 +72,7 @@ public:
void testImage();
void testTable();
void testLink();
void testLinkCharFormat();
CPPUNIT_TEST_SUITE(EPUBExportTest);
CPPUNIT_TEST(testOutlineLevel);
......@@ -93,6 +94,7 @@ public:
CPPUNIT_TEST(testImage);
CPPUNIT_TEST(testTable);
CPPUNIT_TEST(testLink);
CPPUNIT_TEST(testLinkCharFormat);
CPPUNIT_TEST_SUITE_END();
};
......@@ -466,6 +468,16 @@ void EPUBExportTest::testLink()
assertXPath(mpXmlDoc, "//xhtml:p/xhtml:a", "href", "https://libreoffice.org/");
}
void EPUBExportTest::testLinkCharFormat()
{
createDoc("link-charformat.fodt", {});
mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml");
// <span> was lost, link text having a char format was missing.
assertXPathContent(mpXmlDoc, "//xhtml:p/xhtml:a/xhtml:span", "https://libreoffice.org/");
assertXPath(mpXmlDoc, "//xhtml:p/xhtml:a", "href", "https://libreoffice.org/");
}
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:xlink="http://www.w3.org/1999/xlink" 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 fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold"/>
</style:style>
</office:automatic-styles>
<office:body>
<office:text>
<text:p>Before <text:a xlink:type="simple" xlink:href="https://libreoffice.org/"><text:span text:style-name="T1">https://libreoffice.org/</text:span></text:a> after.</text:p>
</office:text>
</office:body>
</office:document>
......@@ -214,16 +214,29 @@ void XMLTabContext::startElement(const OUString &/*rName*/, const css::uno::Refe
class XMLHyperlinkContext : public XMLImportContext
{
public:
XMLHyperlinkContext(XMLImport &rImport);
XMLHyperlinkContext(XMLImport &rImport, const librevenge::RVNGPropertyList &rPropertyList);
rtl::Reference<XMLImportContext> CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override;
void SAL_CALL startElement(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override;
void SAL_CALL endElement(const OUString &rName) override;
void SAL_CALL characters(const OUString &rChars) override;
private:
librevenge::RVNGPropertyList m_aPropertyList;
};
XMLHyperlinkContext::XMLHyperlinkContext(XMLImport &rImport)
XMLHyperlinkContext::XMLHyperlinkContext(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());
}
rtl::Reference<XMLImportContext> XMLHyperlinkContext::CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &/*xAttribs*/)
{
return CreateParagraphOrSpanChildContext(mrImport, rName, m_aPropertyList);
}
void XMLHyperlinkContext::startElement(const OUString &/*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs)
......@@ -262,7 +275,7 @@ XMLParaContext::XMLParaContext(XMLImport &rImport)
rtl::Reference<XMLImportContext> XMLParaContext::CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &/*xAttribs*/)
{
if (rName == "text:a")
return new XMLHyperlinkContext(mrImport);
return new XMLHyperlinkContext(mrImport, m_aTextPropertyList);
return CreateParagraphOrSpanChildContext(mrImport, rName, m_aTextPropertyList);
}
......
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