https://bugs.documentfoundation.org/show_bug.cgi?id=165944
Bug ID: 165944
Summary: The $(userurl) variable is not documented
Product: LibreOffice
Version: unspecified
Hardware: All
OS: All
Status: UNCONFIRMED
Severity: normal
Priority: medium
Component: Documentation
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected]
Created attachment 200059
--> https://bugs.documentfoundation.org/attachment.cgi?id=200059&action=edit
Test file demonstratiing the $(userurl) variable behavior
Hi,
The "com.sun.star.sdb.DatabaseContext" UNO service has a
.getRegisteredObject(pDBName).URL method that may contain an internal variable
named "$(userurl)".
You may test with the "Bibliography" dataset using this code (run the test
sub):
8< ------------------------------------------
Function SubstitutePath(ByRef pVar As String) As String
Dim lo_Subst As Object
Dim l_Str As String
lo_Subst = CreateUnoService("com.sun.star.util.PathSubstitution")
l_Str = lo_Subst.getSubstituteVariableValue(pVar)
SubstitutePath = l_Str
End Function 'SubstitutePath
Function GetDatabaseLocationURL(ByRef pDBName As String) As String
Dim lo_DBContext As Object
Dim l_URL As String
lo_DBContext = CreateUnoService("com.sun.star.sdb.DatabaseContext")
If lo_DBContext.hasByName(pDBName) Then
l_URL = lo_DBContext.getRegisteredObject(pDBName).URL
End If
GetDatabaseLocationURL = l_URL
End Function 'GetDatabaseLocationURL
sub test
dim str
str = GetDatabaseLocationURL("Bibliography")
'-> str contains "sdbc:dbase:$(userurl)/database/biblio"
' ^^^^^^^^^^
msgbox str
str = SubstitutePath("$(userurl)")
'-> returns "file:///home/jfn/.config/libreoffice/4/user"
'( just like "$(user) )"
msgbox str
end sub
------------------------------------------ >8
See results in the code above. The attached test_var.ods implements this code.
Click the Button to see the results.
TTBOMK, the $(userurl) variable is not listed anywhere.
In particular, I have checked the list here:
https://api.libreoffice.org/docs/idl/ref/servicecom_1_1sun_1_1star_1_1util_1_1PathSubstitution.html
To-date, I've never met this variable in any other context than datasets. Note
that it behaves like $(user): the PathSubstitution service returns the same
string (change the var name accordingly in the test sub).
I think this should be documented, and perhaps both variables should be merged
(but, yes, this is another subject on its own).
--
You are receiving this mail because:
You are the assignee for the bug.