summaryrefslogtreecommitdiff
path: root/unoxml
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2020-01-16 02:04:53 +0000
committerMichael Meeks <michael.meeks@collabora.com>2020-05-08 21:47:46 +0100
commitca674521744541651fbacd6e414708a0b9453fa7 (patch)
tree05cf5a313f950de7c17827a02c90d38e54ab6ec9 /unoxml
parentf371c2d09909dd7713d12f8f97e0d78985aa4622 (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/+/86900 Tested-by: Jenkins Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Diffstat (limited to 'unoxml')
-rw-r--r--unoxml/source/dom/documentbuilder.cxx25
1 files changed, 21 insertions, 4 deletions
diff --git a/unoxml/source/dom/documentbuilder.cxx b/unoxml/source/dom/documentbuilder.cxx
index 5a03cf0bcf2d..3a66b08e89d1 100644
--- a/unoxml/source/dom/documentbuilder.cxx
+++ b/unoxml/source/dom/documentbuilder.cxx
@@ -41,6 +41,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>
@@ -391,11 +392,27 @@ 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 );
+ if (!xInStream.is())
+ throwEx(pContext.get());
+
+ // loop over every layout entry in current file
+ xRet = parse( xInStream );
+
+ xInStream->closeInput();
+ xInStream.clear();
+
+ } else
+ xRet = CDocument::CreateCDocument(pDoc).get();
+
return xRet;
}