[Libreoffice-commits] core.git: writerperfect/source
Miklos Vajna
vmiklos at collabora.co.uk
Thu Aug 17 12:11:48 UTC 2017
writerperfect/source/writer/exp/txtparai.cxx | 46 +++++++++++++++++++++++++++
1 file changed, 46 insertions(+)
New commits:
commit 9480ff6a2b6057410940ff5c40828d5746898a0e
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Thu Aug 17 10:58:33 2017 +0200
EPUB export: implement link support
Not only the link but the text of it was also unhandled, add code for
both.
Change-Id: Ic3a26db64a10d44f1f94b7358ed9103bb68bbe95
Reviewed-on: https://gerrit.libreoffice.org/41245
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
diff --git a/writerperfect/source/writer/exp/txtparai.cxx b/writerperfect/source/writer/exp/txtparai.cxx
index 02e4f78c1ef5..72cc401ceb91 100644
--- a/writerperfect/source/writer/exp/txtparai.cxx
+++ b/writerperfect/source/writer/exp/txtparai.cxx
@@ -50,6 +50,50 @@ void XMLSpanContext::characters(const OUString &rChars)
mrImport.GetGenerator().insertText(librevenge::RVNGString(sCharU8.getStr()));
}
+/// Handler for <text:a>.
+class XMLHyperlinkContext : public XMLImportContext
+{
+public:
+ XMLHyperlinkContext(XMLImport &rImport);
+
+ 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;
+};
+
+XMLHyperlinkContext::XMLHyperlinkContext(XMLImport &rImport)
+ : XMLImportContext(rImport)
+{
+}
+
+void XMLHyperlinkContext::startElement(const OUString &/*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs)
+{
+ librevenge::RVNGPropertyList aPropertyList;
+ for (sal_Int16 i = 0; i < xAttribs->getLength(); ++i)
+ {
+ const OUString &rAttributeName = xAttribs->getNameByIndex(i);
+ if (rAttributeName == "xlink:href")
+ {
+ OString sName = OUStringToOString(rAttributeName, RTL_TEXTENCODING_UTF8);
+ OString sValue = OUStringToOString(xAttribs->getValueByIndex(i), RTL_TEXTENCODING_UTF8);
+ aPropertyList.insert(sName.getStr(), sValue.getStr());
+ }
+ }
+
+ mrImport.GetGenerator().openLink(aPropertyList);
+}
+
+void XMLHyperlinkContext::endElement(const OUString &/*rName*/)
+{
+ mrImport.GetGenerator().closeLink();
+}
+
+void XMLHyperlinkContext::characters(const OUString &rChars)
+{
+ OString sCharU8 = OUStringToOString(rChars, RTL_TEXTENCODING_UTF8);
+ mrImport.GetGenerator().insertText(librevenge::RVNGString(sCharU8.getStr()));
+}
+
XMLParaContext::XMLParaContext(XMLImport &rImport)
: XMLImportContext(rImport)
{
@@ -59,6 +103,8 @@ XMLImportContext *XMLParaContext::CreateChildContext(const OUString &rName, cons
{
if (rName == "text:span")
return new XMLSpanContext(mrImport);
+ if (rName == "text:a")
+ return new XMLHyperlinkContext(mrImport);
return nullptr;
}
More information about the Libreoffice-commits
mailing list