Bug 98407 - API PathSubstitution: Add substition for username
Summary: API PathSubstitution: Add substition for username
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: sdk (show other bugs)
(earliest affected)
Inherited From OOo
Hardware: All All
: medium enhancement
Assignee: Samuel Mehrbrodt (allotropia)
Whiteboard: target:5.2.0
Depends on:
Reported: 2016-03-04 10:05 UTC by Samuel Mehrbrodt (allotropia)
Modified: 2016-09-27 07:37 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Note You need to log in before you can comment on or make changes to this bug.
Description Samuel Mehrbrodt (allotropia) 2016-03-04 10:05:10 UTC

Add a substitution $(username) which is replaced with the current system user.
Comment 1 Samuel Mehrbrodt (allotropia) 2016-03-04 13:31:30 UTC
Comment 2 Samuel Mehrbrodt (allotropia) 2016-03-07 11:46:41 UTC
To try it out, the following snippet should print the currently logged in user:

Sub Main
 xsubst = createUnoService("com.sun.star.comp.framework.PathSubstitution")
 print xSubst.getSubstituteVariableValue( "$(username)")
End Sub
Comment 3 Stephan Bergmann 2016-03-08 11:22:05 UTC
Where is this supposed to be used?
Comment 4 Samuel Mehrbrodt (allotropia) 2016-03-08 11:33:06 UTC
(In reply to Stephan Bergmann from comment #3)
> Where is this supposed to be used?

We have a client who wants to set some paths to be not in the user profile, but in a separate directory on another hard drive (because of backup strategy).

So for example have the autocorrect data in a folder like 

Since multiple people use the same pc, the path needs to be individual for each person. Thus the need to replace $(username) with the currently logged in user.
Comment 5 Commit Notification 2016-03-08 15:37:38 UTC
Samuel Mehrbrodt committed a patch related to this issue.
It has been pushed to "master":


tdf#98407 PathSubstitution: Add substitution for $(username)

It will be available in 5.2.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:

Affected users are encouraged to test the fix and report feedback.
Comment 6 Stephan Bergmann 2016-09-27 07:37:58 UTC
(Starting with the fix from issue 101898 comment 33, "$(username)" will be substituted for the username only if the username is a complete URL segment.  That is, if the username is "USER", <file:///data/USER/office> will be substituted
to <file:///data/$(username)/office>, but <file:///data/USERSPACE/office> will remain unchanged.)