EPUB export: handle span-level line break
By pulling out common part of the paragraph/span context factory. Change-Id: If5fda87ce9f60e7e10d7f9406c30740bc8707143 Reviewed-on: https://gerrit.libreoffice.org/42064 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org>
This commit is contained in:
parent
5ffe8f0559
commit
01cc6e5107
@ -325,7 +325,9 @@ void EPUBExportTest::testLineBreak()
|
||||
|
||||
mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml");
|
||||
// This was 0, line break was not handled.
|
||||
assertXPath(mpXmlDoc, "//xhtml:p/xhtml:br", 1);
|
||||
assertXPath(mpXmlDoc, "//xhtml:p[1]/xhtml:br", 1);
|
||||
// This was 0, line break inside span was not handled.
|
||||
assertXPath(mpXmlDoc, "//xhtml:p[2]/xhtml:br", 1);
|
||||
}
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(EPUBExportTest);
|
||||
|
@ -1,8 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<office:document office:mimetype="application/vnd.oasis.opendocument.text" office:version="1.2" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0">
|
||||
<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:officeooo="http://openoffice.org/2009/office" 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 officeooo:rsid="000075b1"/>
|
||||
</style:style>
|
||||
<style:style style:name="T2" style:family="text">
|
||||
<style:text-properties fo:font-weight="bold"/>
|
||||
</style:style>
|
||||
<style:style style:name="T3" style:family="text">
|
||||
<style:text-properties fo:font-weight="bold" officeooo:rsid="000075b1"/>
|
||||
</style:style>
|
||||
</office:automatic-styles>
|
||||
<office:body>
|
||||
<office:text>
|
||||
<text:p>a<text:line-break/>b</text:p>
|
||||
<text:p><text:span text:style-name="T1">a</text:span><text:span text:style-name="T2">a<text:line-break/></text:span><text:span text:style-name="T3">b</text:span>b</text:p>
|
||||
</office:text>
|
||||
</office:body>
|
||||
</office:document>
|
||||
|
@ -103,7 +103,7 @@ XMLImportContext *XMLSpanContext::CreateChildContext(const OUString &rName, cons
|
||||
return new XMLTextFrameContext(mrImport);
|
||||
if (rName == "text:span")
|
||||
return new XMLSpanContext(mrImport, &m_aPropertyList);
|
||||
return nullptr;
|
||||
return writerperfect::exp::CreateChildContext(mrImport, rName);
|
||||
}
|
||||
|
||||
void XMLSpanContext::startElement(const OUString &/*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs)
|
||||
@ -207,9 +207,7 @@ XMLImportContext *XMLParaContext::CreateChildContext(const OUString &rName, cons
|
||||
return new XMLSpanContext(mrImport, nullptr);
|
||||
if (rName == "text:a")
|
||||
return new XMLHyperlinkContext(mrImport);
|
||||
if (rName == "text:line-break")
|
||||
return new XMLLineBreakContext(mrImport);
|
||||
return nullptr;
|
||||
return writerperfect::exp::CreateChildContext(mrImport, rName);
|
||||
}
|
||||
|
||||
void XMLParaContext::startElement(const OUString &/*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs)
|
||||
@ -253,6 +251,13 @@ void XMLParaContext::characters(const OUString &rChars)
|
||||
mrImport.GetGenerator().closeSpan();
|
||||
}
|
||||
|
||||
XMLImportContext *CreateChildContext(XMLImport &rImport, const OUString &rName)
|
||||
{
|
||||
if (rName == "text:line-break")
|
||||
return new XMLLineBreakContext(rImport);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} // namespace exp
|
||||
} // namespace writerperfect
|
||||
|
||||
|
@ -33,6 +33,9 @@ private:
|
||||
OUString m_aStyleName;
|
||||
};
|
||||
|
||||
/// Shared child context factory for paragraph and span contexts.
|
||||
XMLImportContext *CreateChildContext(XMLImport &rImport, const OUString &rName);
|
||||
|
||||
} // namespace exp
|
||||
} // namespace writerperfect
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user