diff options
author | Caolán McNamara <caolan.mcnamara@collabora.com> | 2024-11-02 20:37:02 +0000 |
---|---|---|
committer | Caolán McNamara <caolan.mcnamara@collabora.com> | 2024-11-24 15:14:48 +0100 |
commit | aed4e00c4f5788253d68502f7d957dbb08f4555b (patch) | |
tree | 4c258a11e28367482333c4e6977bfae23d2863b7 | |
parent | 53d54929b518e48b307611bb0e2209629a17395f (diff) |
UserInstallation may change in kit-mode
So the setting fetched at ctor time for UserInstallation (and
BRAND_BASE_DIR) may no longer be true, so expanding variables based
on those earlier seen values results in unwanted paths.
add XInitialization to SubstitutePathVariables (like done for
PathSettings) to allow reiniting these explicitly once.
Change-Id: Ia930ea71cb09adc91d6d47ee047c44b24222e8a2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175961
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
(cherry picked from commit 410f6b50eb44276b1d2095c844244ef4d0ddefaa)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177109
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
-rw-r--r-- | desktop/source/lib/init.cxx | 19 | ||||
-rw-r--r-- | framework/source/services/substitutepathvars.cxx | 23 |
2 files changed, 34 insertions, 8 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index f4e2c39f6d07..4842a9732cee 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -107,6 +107,7 @@ #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/style/XStyleFamiliesSupplier.hpp> #include <com/sun/star/util/thePathSettings.hpp> +#include <com/sun/star/util/PathSubstitution.hpp> #include <com/sun/star/util/URLTransformer.hpp> #include <com/sun/star/util/XFlushable.hpp> #include <com/sun/star/configuration/theDefaultProvider.hpp> @@ -8237,12 +8238,20 @@ static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath, const char utl::Bootstrap::reloadData(); // Now that bootstrap User/Shared installation paths have been (re)set to the final - // location, reinitialize the PathSettings so $(userurl)/$(instdir) path variables - // will be expanded using these newly set paths and not the paths detected during - // preinit which used unorthodox throwaway temp locations + // location, reinitialize the PathSubstitution rules and PathSettings so that + // $(userurl)/$(instdir) path variables will be expanded using these newly set + // paths and not the paths detected during preinit which used unorthodox throwaway + // temp locations + + // First reinitialize the PathSubstitution rules + uno::Reference<css::util::XStringSubstitution> xPathSubst(util::PathSubstitution::create(xContext)); + uno::Reference<lang::XInitialization> xReInitSubstitution(xPathSubst, uno::UNO_QUERY_THROW); + xReInitSubstitution->initialize({}); + + // PathSettings depend on PathSubstitution rules uno::Reference<css::util::XPathSettings> xPathSettings = util::thePathSettings::get(xContext); - uno::Reference<lang::XInitialization> xReInit(xPathSettings, uno::UNO_QUERY_THROW); - xReInit->initialize({}); + uno::Reference<lang::XInitialization> xReInitSettings(xPathSettings, uno::UNO_QUERY_THROW); + xReInitSettings->initialize({}); } } diff --git a/framework/source/services/substitutepathvars.cxx b/framework/source/services/substitutepathvars.cxx index 3d84cb619384..febece5e6040 100644 --- a/framework/source/services/substitutepathvars.cxx +++ b/framework/source/services/substitutepathvars.cxx @@ -35,6 +35,7 @@ #include <officecfg/Office/Paths.hxx> +#include <com/sun/star/lang/XInitialization.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/container/NoSuchElementException.hpp> #include <com/sun/star/container/XHierarchicalNameAccess.hpp> @@ -130,7 +131,8 @@ struct ReSubstFixedVarOrder typedef comphelper::WeakComponentImplHelper< css::util::XStringSubstitution, - css::lang::XServiceInfo > SubstitutePathVariables_BASE; + css::lang::XServiceInfo, + css::lang::XInitialization > SubstitutePathVariables_BASE; class SubstitutePathVariables : public SubstitutePathVariables_BASE { @@ -157,7 +159,12 @@ public: virtual OUString SAL_CALL reSubstituteVariables( const OUString& aText ) override; virtual OUString SAL_CALL getSubstituteVariableValue( const OUString& variable ) override; -protected: + // XInitialization + virtual void SAL_CALL initialize(const css::uno::Sequence<css::uno::Any>& /*rArguments*/) override; + +private: + void impl_initialize(); + void SetPredefinedPathVariables(); // Special case (transient) values can change during runtime! @@ -189,6 +196,11 @@ private: SubstitutePathVariables::SubstitutePathVariables() { + impl_initialize(); +} + +void SubstitutePathVariables::impl_initialize() +{ SetPredefinedPathVariables(); // Init the predefined/fixed variable to index hash map @@ -219,6 +231,12 @@ SubstitutePathVariables::SubstitutePathVariables() sort(m_aReSubstFixedVarOrder.begin(),m_aReSubstFixedVarOrder.end()); } +void SAL_CALL SubstitutePathVariables::initialize(const css::uno::Sequence<css::uno::Any>& /*rArguments*/) +{ + std::unique_lock g(m_aMutex); + impl_initialize(); +} + // XStringSubstitution OUString SAL_CALL SubstitutePathVariables::substituteVariables( const OUString& aText, sal_Bool bSubstRequired ) { @@ -598,7 +616,6 @@ OUString const & SubstitutePathVariables::impl_getSubstituteVariableValue( const void SubstitutePathVariables::SetPredefinedPathVariables() { - m_aPreDefVars.m_FixedVar[PREDEFVAR_BRANDBASEURL] = "$BRAND_BASE_DIR"; rtl::Bootstrap::expandMacros( m_aPreDefVars.m_FixedVar[PREDEFVAR_BRANDBASEURL]); |