Download it now!
Bug 101661 - UnoService com.sun.star.util.PathSubstitution returns non existing path for $work
Summary: UnoService com.sun.star.util.PathSubstitution returns non existing path for $...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: framework (show other bugs)
Version:
(earliest affected)
5.2.0.4 release
Hardware: All Linux (All)
: medium normal
Assignee: Stephan Bergmann
URL:
Whiteboard: target:5.3.0 target:5.2.2 target:5.2.1
Keywords:
Depends on:
Blocks:
 
Reported: 2016-08-22 13:42 UTC by Cor Nouws
Modified: 2016-08-24 23:31 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 Cor Nouws 2016-08-22 13:42:00 UTC
Run the basic below.
In 5.1.x both $work and $home return file:///home/<name>

In 5.2.x and master $home returns file:///home/<name> and $work returns file:///home/<name>/Documents. This last path is non existing.

$workdirurl returns the same in 5.1 and 5.2: $(work)/Documenten
Even if the default wrong path in Options > LibreOffice > Paths is /home/<name>/Documents (5.2.x) or /home/<name> (5.1.x)

$workdirurl returns just $(work) in master.



Sub Main

msgbox "work = " & GetFrameworkPath("work") & " "& chr(13) & "home = " &
GetFrameworkPath("home")

End Sub


'predefinedPathVariables : home, inst, prog, temp, user, work, path,
lang, langid, vlang
'instpath, progpath, userpath, insturl, progurl, userurl,
workdirurl,baseinsturl, userdataurl, brandbaseurl
' user == userprofile; home == work; workdirurl = myDocuments from
LibreOffice
Function GetFrameworkPath (sItem$) as String
	Dim oPathSubst
	oPathSubst = createUnoService("com.sun.star.util.PathSubstitution")
	GetFrameworkPath =  oPathSubst.getSubstituteVariableValue(sItem)
End Function
Comment 1 Cor Nouws 2016-08-22 13:51:45 UTC
Needless to say that this default setting causes an non existing path error now and then (iirc I had one when loading templates or so.)
Comment 2 Stephan Bergmann 2016-08-22 15:35:37 UTC
The value of $(work) is taken from the /org.openoffice.Office/Paths/Variables/Work configuration property (defaulting to the home dir if that property is not set; cf. SubstitutePathVariables::GetWorkVariableValue in framework/source/services/substitutepathvars.cxx).

On Linux, that configuration property is an "external" property, querying a value from a desktop backend (oor:external="com.sun.star.configuration.backend.DesktopBackend WorkPathVariable", officecfg/registry/data/org/openoffice/Office/Paths.xcu).

For GNOME-based desktops:

* Until LO 5.0 there was a GConf-based desktop backend that returned the value of XDG_DOCUMENTS_DIR *if that value denoted an existing directory*.  (And otherwise, the fallback to the home dir would kick in.)

* In LO 5.1, that GConf-based desktop backend has been removed, without replacement (3cf557c12d27f1b2250e69a543136da098112d80 "drop gconf integration as per ESC decision").  So the fallback to the home dir always kicks in.

* In LO 5.2, support for XDG_DOCUMENTS_DIR (and XDG_TEMPLATES_DIR) has been added back into the generic Linux desktop backend code (i.e., the code that isn't specific to GNOME but also handles KDE etc.; b5c05876f73c31270bc374e4f481ef1d09a42e5f "Related: rhbz#1065807 recover using xdg templates and documents settings"), *but in a way so that the value of XDG_DOCUMENTS_DIR is always returned, regardless of whether that value denotes an existing directory or not.*  (So the home dir fallback does not kick in.)

(For KDE-based desktops, prior to LO 5.2 the value had been obtained through a call to KGlobalSettings::documentPath(), and reported back regardless of whether the dir would exist; presumably, the net effect of reading KGlobalSettings::documentPath() vs. XDG_DOCUMENTS_DIR is the same.)
Comment 3 Stephan Bergmann 2016-08-22 15:42:49 UTC
Cor, do you observe this in GNOME-based environments?  If yes, backporting the master fix to LO 5.2 is probably useful.
Comment 4 Cor Nouws 2016-08-22 22:06:21 UTC
(In reply to Stephan Bergmann from comment #3)
> Cor, do you observe this in GNOME-based environments?  If yes, backporting
> the master fix to LO 5.2 is probably useful.

Working with Unity here. That uses quite some from GNOME, so I guess the answer is 'yes'.
Thanks for your explanation and fix, Stephan!
Comment 5 Stephan Bergmann 2016-08-23 08:25:20 UTC
(In reply to Stephan Bergmann from comment #2)
> (For KDE-based desktops, prior to LO 5.2 the value had been obtained through
> a call to KGlobalSettings::documentPath(), and reported back regardless of
> whether the dir would exist; presumably, the net effect of reading
> KGlobalSettings::documentPath() vs. XDG_DOCUMENTS_DIR is the same.)

This claim is wrong.  The behavior for KDE-based desktops was not affected.
Comment 6 Commit Notification 2016-08-23 14:02:40 UTC
Stephan Bergmann committed a patch related to this issue.
It has been pushed to "libreoffice-5-2":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=15a504308d27dfcb605da320c9231227aca415e1&h=libreoffice-5-2

tdf#101661: Report XDG_{DOCUMENTS,TEMPLATES}_DIR only when it exists

It will be available in 5.2.2.

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 7 Commit Notification 2016-08-24 23:31:04 UTC
Stephan Bergmann committed a patch related to this issue.
It has been pushed to "libreoffice-5-2-1":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=16d5b5195c2550aaec856376b7016d723f6950b6&h=libreoffice-5-2-1

tdf#101661: Report XDG_{DOCUMENTS,TEMPLATES}_DIR only when it exists

It will be available in 5.2.1.

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.