Bug 98407 - API PathSubstitution: Add substition for username
Summary: API PathSubstitution: Add substition for username
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: sdk (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium enhancement
Assignee: Samuel Mehrbrodt (allotropia)
URL:
Whiteboard: target:5.2.0
Keywords:
Depends on:
Blocks:
 
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:


Attachments

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
http://api.libreoffice.org/docs/idl/ref/servicecom_1_1sun_1_1star_1_1util_1_1PathSubstitution.html

Add a substitution $(username) which is replaced with the current system user.
Comment 1 Samuel Mehrbrodt (allotropia) 2016-03-04 13:31:30 UTC
https://gerrit.libreoffice.org/#/c/22901
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 
D:\DATA\<username>\Office\…

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":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=16fb0d3d0f68708c183c53bd18660a23970b77fe

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:
http://wiki.documentfoundation.org/Testing_Daily_Builds

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.)