summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorChristian Lohmaier <lohmaier+LibreOffice@googlemail.com>2019-11-18 17:08:00 +0100
committerMichael Meeks <michael.meeks@collabora.com>2020-05-13 20:04:03 +0100
commitd28d47b1bf02c8385c988388ee01726f61d17693 (patch)
treede7d54919c5c4a094b965d0a7aff6730f6a997bf /sal
parent60ac97df116da5f2d8e405509161ee4ac3167b00 (diff)
tdf#128101 android: fix documents with manual page break
code reads a .ui file to show a menu to edit/delete that pagebreak. That file was not packaged in the Android viewer and causes an exception that is not handled and ultimately results in a crash. Change-Id: Ie73d886daf9202ba12e1b5a241bc7b6d184ae770 Reviewed-on: https://gerrit.libreoffice.org/83104 Tested-by: Jenkins Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86165 Reviewed-by: Michael Meeks <michael.meeks@collabora.com> Tested-by: Michael Meeks <michael.meeks@collabora.com>
Diffstat (limited to 'sal')
-rw-r--r--sal/osl/unx/file.cxx24
1 files changed, 17 insertions, 7 deletions
diff --git a/sal/osl/unx/file.cxx b/sal/osl/unx/file.cxx
index 2ca6b8c06ff3..10dcf74a0ab3 100644
--- a/sal/osl/unx/file.cxx
+++ b/sal/osl/unx/file.cxx
@@ -890,13 +890,23 @@ oslFileError openFilePath(const char *cpFilePath, oslFileHandle* pHandle,
{
OString aData;
bool bCache = true;
- AndroidFileCache::Entry *pHit = AndroidFileCache::getHitCache().find(cpFilePath);
+
+ const char *cpAssetsPath = cpFilePath + sizeof("/assets/") - 1;
+ // some requests are /assets//foo...
+ if (cpAssetsPath[0] == '/')
+ {
+ __android_log_print(ANDROID_LOG_DEBUG,"libo:sal/osl/unx/file", "double-slash in path: %s", cpFilePath);
+ cpAssetsPath++;
+ }
+
+ AndroidFileCache::Entry *pHit = AndroidFileCache::getHitCache().find(cpAssetsPath);
if (pHit)
aData = pHit->maData;
+
else
{
bCache = false;
- AndroidFileCache::Entry *pMiss = AndroidFileCache::getMissCache().find(cpFilePath);
+ AndroidFileCache::Entry *pMiss = AndroidFileCache::getMissCache().find(cpAssetsPath);
if (pMiss)
{
errno = ENOENT;
@@ -904,10 +914,10 @@ oslFileError openFilePath(const char *cpFilePath, oslFileHandle* pHandle,
return osl_File_E_NOENT;
}
AAssetManager* mgr = lo_get_native_assetmgr();
- AAsset* asset = AAssetManager_open(mgr, cpFilePath + sizeof("/assets/")-1, AASSET_MODE_BUFFER);
+ AAsset* asset = AAssetManager_open(mgr, cpAssetsPath, AASSET_MODE_BUFFER);
if (!asset)
{
- AndroidFileCache::getMissCache().insert(cpFilePath, aData);
+ AndroidFileCache::getMissCache().insert(cpAssetsPath, aData);
errno = ENOENT;
__android_log_print(ANDROID_LOG_ERROR,"libo:sal/osl/unx/file", "failed to open %s", cpFilePath);
return osl_File_E_NOENT;
@@ -924,7 +934,7 @@ oslFileError openFilePath(const char *cpFilePath, oslFileHandle* pHandle,
aData = OString(pData, SAL_NO_ACQUIRE);
if (pData->length < 50 * 1024)
- AndroidFileCache::getHitCache().insert(cpFilePath, aData);
+ AndroidFileCache::getHitCache().insert(cpAssetsPath, aData);
}
}
@@ -935,8 +945,8 @@ oslFileError openFilePath(const char *cpFilePath, oslFileHandle* pHandle,
// loading a document from /assets fails with that idiotic
// "General Error" dialog...
}
- SAL_WARN("sal.file", "osl_openFile(" << cpFilePath << ") => " << aData.getLength() <<
- " bytes from file " << (bCache ? "cache" : "system"));
+ SAL_INFO("sal.file", "osl_openFile(" << cpFilePath << ") => '" << cpAssetsPath << "'"
+ << aData.getLength() << " bytes from file " << (bCache ? "cache" : "system"));
return openMemoryAsFile(aData, pHandle, cpFilePath);
}
#endif