Bug 102630 - Useless /org.openoffice.Office/Substitution feature
Summary: Useless /org.openoffice.Office/Substitution feature
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: framework (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium normal
Assignee: Stephan Bergmann
QA Contact:
URL:
Whiteboard: target:5.3.0
Keywords:
Depends on:
Blocks:
 
Reported: 2016-09-27 16:09 UTC by Stephan Bergmann
Modified: 2016-09-28 06:30 UTC (History)
0 users

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 Stephan Bergmann 2016-09-27 16:09:19 UTC
There is an /org.openoffice.Office/Substitution configuration tree (defined in officecfg/registry/schema/org/openoffice/Office/Substitution.xcs) offering a "SharePoints" set of variable replacements, and the implementation of the com.sun.star.util.PathSubstitution UNO service (in framework/source/services/substitutepathvars.cxx) is designed to support those "SharePoints" variable replacements (though in a broken way).

However:

For one, there is no sign in the git logs that that "SharePoints" configuration set was ever non-empty, in neither LO nor OOo times.

For another, the PathSubstitution UNO service intends to support those "SharePoints" variable replacements both when resolving strings containing such variable names (substituteVariables, getSubstituteVariableValue) and when introducing variable names into strings (reSubstituteVariables).  However, the latter is implemented (ever since <https://cgit.freedesktop.org/libreoffice/core/commit/?id=a56ebe278ae13de0a2baa821e30c16b4f06a4191> "#100825# New services for path settings and path substitution", in SubstitutePathVariables::impl_reSubstituteVariables, framework/source/services/substitutepathvars.cxx) in such a way that it tries to introduce "$(var-name)" as a replacement for "$(var-name)" (i.e., as a replacement for the variable's name, instead of the variable's content), so will never introduce such a variable name into a string.  And when such a variable name is never introduced into a string via reSubstituteVariables, it's unlikely that it will ever appear in a string passed to substituteVariables or getSubstituteVariableValue (given that the normal use of this UNO service is to introduce variable names when saving a document, and then converting back when loading the document).

In short, this feature looks both unused and broken "since forever".  (It may have been used in some way in StarOffice-only code.)  Theoretically, an extension or external application could populate that "SharePoints" configuration set and cause strings passed to the UNO services substituteVariables or getSubstituteVariableValue methods to contain matching variable names, but that's probably unlikely.

(For completeness, a way to try this out is to place a share/registry/data/Substitution.xcu file into a LO installation with content

> <?xml version="1.0" encoding="UTF-8"?>
> <oor:component-data oor:name="Substitution" oor:package="org.openoffice.Office"
>   xmlns:oor="http://openoffice.org/2001/registry">
>  <node oor:name="SharePoints">
>   <node oor:name="test" oor:op="fuse">
>    <node oor:name="item" oor:op="replace">
>     <prop oor:name="Directory"><value>file:///dummy</value></prop>
>     <node oor:name="Environment">
>      <prop oor:name="Host"><value>*</value></prop>
>     </node>
>    </node>
>   </node>
>  </node>
> </oor:component-data>

If you replace oor:name="test" with oor:name="inst" and try to save an Impress document, it will cause an endless loop in SubstitutePathVariables::impl_reSubstituteVariables (framework/source/services/substitutepathvars.cxx), as it will keep replacing "$(inst)" with "$(inst)" in the (already partly re-substituted) URL <$(inst)/share/palette%3B$(user)/config/standard.sob>.)
Comment 1 Commit Notification 2016-09-27 16:15:24 UTC
Stephan Bergmann committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=47f7e30f3584cbccd02cf3748399079778facd0d

tdf#102630: [API CHANGE] Remove SharePoints support from PathSubstitution

It will be available in 5.3.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 2 Commit Notification 2016-09-28 06:29:02 UTC
Stephan Bergmann committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=62b2d8ff356e7ac74dc0a66f1630e704af270356

tdf#102630: [API CHANGE] Remove /org.openoffice.Office/Substitution tree

It will be available in 5.3.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.