diff options
author | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2016-03-07 21:52:20 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2016-03-08 15:35:54 +0000 |
commit | 16fb0d3d0f68708c183c53bd18660a23970b77fe (patch) | |
tree | 8e86df69dcf4ab52368a0a1d767dff62930549fd /framework | |
parent | f9ddda353851b019c2eb8a427ee9f8042f8107b0 (diff) |
tdf#98407 PathSubstitution: Add substitution for $(username)
This allows to use the username as a placeholder in the config paths (Autotext, Gallery, etc)
Change-Id: I76434e980cd8ec8785a5587d0bc5fdd67dc42de2
Reviewed-on: https://gerrit.libreoffice.org/22901
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Tested-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'framework')
-rw-r--r-- | framework/qa/complex/path_substitution/PathSubstitutionTest.java | 1 | ||||
-rw-r--r-- | framework/source/services/substitutepathvars.cxx | 8 |
2 files changed, 9 insertions, 0 deletions
diff --git a/framework/qa/complex/path_substitution/PathSubstitutionTest.java b/framework/qa/complex/path_substitution/PathSubstitutionTest.java index 8d85ade376c0..abf83cdce99b 100644 --- a/framework/qa/complex/path_substitution/PathSubstitutionTest.java +++ b/framework/qa/complex/path_substitution/PathSubstitutionTest.java @@ -54,6 +54,7 @@ public class PathSubstitutionTest substVars.add("$(home)", true, true); substVars.add("$(temp)", true, true); substVars.add("$(lang)", false, false); + substVars.add("$(username)", false, false); substVars.add("$(langid)", false, false); substVars.add("$(vlang)", false, false); // path won't resubstitute diff --git a/framework/source/services/substitutepathvars.cxx b/framework/source/services/substitutepathvars.cxx index daeeb3d1c320..17375a4de32b 100644 --- a/framework/source/services/substitutepathvars.cxx +++ b/framework/source/services/substitutepathvars.cxx @@ -167,6 +167,7 @@ enum PreDefVariable PREDEFVAR_HOME, PREDEFVAR_TEMP, PREDEFVAR_PATH, + PREDEFVAR_USERNAME, PREDEFVAR_LANGID, PREDEFVAR_VLANG, PREDEFVAR_INSTPATH, @@ -350,6 +351,7 @@ static const FixedVariable aFixedVarTable[] = { "$(home)", PREDEFVAR_HOME, true }, { "$(temp)", PREDEFVAR_TEMP, true }, { "$(path)", PREDEFVAR_PATH, true }, + { "$(username)", PREDEFVAR_USERNAME, false }, { "$(langid)", PREDEFVAR_LANGID, false }, { "$(vlang)", PREDEFVAR_VLANG, false }, { "$(instpath)", PREDEFVAR_INSTPATH, true }, @@ -1239,6 +1241,12 @@ void SubstitutePathVariables::SetPredefinedPathVariables() m_aPreDefVars.m_FixedVar[ PREDEFVAR_PROG ] = m_aPreDefVars.m_FixedVar[ PREDEFVAR_PROGPATH ]; } + // Set $(username) + OUString aSystemUser; + ::osl::Security aSecurity; + aSecurity.getUserName( aSystemUser, false ); + m_aPreDefVars.m_FixedVar[ PREDEFVAR_USERNAME ] = aSystemUser; + // Detect the language type of the current office m_aPreDefVars.m_eLanguageType = LANGUAGE_ENGLISH_US; OUString aLocaleStr( utl::ConfigManager::getLocale() ); |