diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2020-01-16 02:04:53 +0000 |
---|---|---|
committer | Ashod Nakashian <ashnakash@gmail.com> | 2020-01-16 04:43:59 +0100 |
commit | 9a224357cba5dfe5376cab9791ffccb6c089d8a6 (patch) | |
tree | 6e6f07f20a86ea2f171fd297ffe824c85d4de165 /unoxml | |
parent | 0c2e3408ae74ae40ac69a8eb963103a917739006 (diff) |
unoxml: CDocumentBuilder::parseURI should handle non-file:/// URIs.
The proximate symptom of this is of only some of the slide layouts
applying in impress on Android. This is caused by not parsing the
file:///assets/.../layoutlist.xml - which needs to use UCB and its
cleverer osl/ file APIs.
Change-Id: I22ed77170891c0ec136caaa29da69987a0e51a73
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86899
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
Diffstat (limited to 'unoxml')
-rw-r--r-- | unoxml/source/dom/documentbuilder.cxx | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/unoxml/source/dom/documentbuilder.cxx b/unoxml/source/dom/documentbuilder.cxx index 8d244ab6d6e9..9bf3154ce9aa 100644 --- a/unoxml/source/dom/documentbuilder.cxx +++ b/unoxml/source/dom/documentbuilder.cxx @@ -40,6 +40,7 @@ #include <com/sun/star/xml/sax/SAXParseException.hpp> #include <com/sun/star/ucb/XCommandEnvironment.hpp> #include <com/sun/star/task/XInteractionHandler.hpp> +#include <com/sun/star/ucb/SimpleFileAccess.hpp> #include <ucbhelper/content.hxx> #include <ucbhelper/commandenvironment.hxx> @@ -401,11 +402,25 @@ namespace DOM OString oUri = OUStringToOString(sUri, RTL_TEXTENCODING_UTF8); char *uri = const_cast<char*>(oUri.getStr()); xmlDocPtr pDoc = xmlCtxtReadFile(pContext.get(), uri, nullptr, 0); + + Reference< XDocument > xRet; + + // if we failed to parse the URI as a simple file, lets try via a ucb stream. + // For Android file:///assets/ URLs which must go via the osl/ file API. if (pDoc == nullptr) { - throwEx(pContext.get()); - } - Reference< XDocument > const xRet( - CDocument::CreateCDocument(pDoc).get()); + Reference < XSimpleFileAccess3 > xStreamAccess( + SimpleFileAccess::create( comphelper::getProcessComponentContext() ) ); + Reference< XInputStream > xInStream(xStreamAccess->openFileRead( sUri ), UNO_QUERY_THROW); + + // loop over every layout entry in current file + xRet = parse( xInStream ); + + xInStream->closeInput(); + xInStream.clear(); + + } else + xRet = CDocument::CreateCDocument(pDoc).get(); + return xRet; } |