From cfc2376f804f13eb562f39182cb24fe7dc61d6ef Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Thu, 25 May 2023 13:41:16 +0200 Subject: Allow bootstrap variables in Java user classpath settings This allows for relative paths to be configured as Java class path. Change-Id: Ie3e6bc3836fb316457e5c9f11dfb77d2fcd49ad4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152271 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt --- cui/source/options/optjava.cxx | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'cui') diff --git a/cui/source/options/optjava.cxx b/cui/source/options/optjava.cxx index c1528138f326..631d085c3bfb 100644 --- a/cui/source/options/optjava.cxx +++ b/cui/source/options/optjava.cxx @@ -944,13 +944,30 @@ void SvxJavaClassPathDlg::SetClassPath( const OUString& _rPath ) sal_Int32 nIdx = 0; do { - OUString sToken = _rPath.getToken( 0, CLASSPATH_DELIMITER, nIdx ); + sal_Int32 nextColon = _rPath.indexOf(CLASSPATH_DELIMITER, nIdx); + OUString sToken( + _rPath.subView(nIdx, nextColon > 0 ? nextColon - nIdx : _rPath.getLength() - nIdx)); + + // Detect open bootstrap variables - they might contain colons - we need to skip those. + sal_Int32 nBootstrapVarStart = sToken.indexOf("${"); + if (nBootstrapVarStart >= 0) + { + sal_Int32 nBootstrapVarEnd = sToken.indexOf("}"); + if (nBootstrapVarEnd == -1) + { + // Current colon is part of bootstrap variable - skip it! + nextColon = _rPath.indexOf(CLASSPATH_DELIMITER, nextColon + 1); + sToken = _rPath.subView(nIdx, nextColon > 0 ? nextColon - nIdx + : _rPath.getLength() - nIdx); + } + } OUString sURL; osl::FileBase::getFileURLFromSystemPath(sToken, sURL); // best effort INetURLObject aURL( sURL ); m_xPathList->append("", sToken, SvFileInformationManager::GetImageId(aURL)); + nIdx = nextColon + 1; } - while (nIdx>=0); + while (nIdx > 0); // select first entry m_xPathList->select(0); } -- cgit