Bug 70949 - Please provide utility functions to get the current product (Office Suite) name, version, etc.
Summary: Please provide utility functions to get the current product (Office Suite) na...
Status: RESOLVED WORKSFORME
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
4.2.0.0.alpha0+ Master
Hardware: All All
: medium enhancement
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 70947
  Show dependency treegraph
 
Reported: 2013-10-28 09:11 UTC by Lionel Elie Mamane
Modified: 2022-08-01 16:24 UTC (History)
4 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 Lionel Elie Mamane 2013-10-28 09:11:10 UTC
Although it is possible from Basic script to get the version of LibrOffice it is running under, the way to do so is rather baroque and (worse!) undocumented. It should just be a call to a utility function, like e.g.

 getOfficeVersion
 getOfficeProductName
 ...

For reference, that's how one can do it now:

Sub Main
    Dim cfgProv As Object
    Set cfgProv = CreateUnoService("com.sun.star.configuration.ConfigurationProvider")
    Dim arg1 as new "com.sun.star.beans.PropertyValue"
    Dim args(1) as new "com.sun.star.beans.PropertyValue"
    arg1.Name = "nodepath"
    arg1.Value="/org.openoffice.Setup/Product"
    args(0) = arg1
    Dim cfgAccess As Object
    Set cfgAccess = cfgProv.createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", args)
    MsgBox cfgAccess.ooName & " version " & cfgAccess.ooSetupVersion & ", provided by """ & cfgAccess.ooVendor & """"
End Sub

This provides a string; it would be better if the version were provided as a (set of) _number_s.
Comment 1 pierre-yves samyn 2013-10-31 07:28:25 UTC
Hello

I completely agree with this request.

Only slight attenuation: the current procedure for obtaining this information is a *little* documented (see GetRegistryKeyContent and GetProductname examples in the Misc module of Tools library).

I also agree with the "type" request for ooSetupxxx properties(Extension, Version, ooSetupVersionAboutBox...).

Could we not add to request a getBuildID utility function equivalent to:

sub GetBuildID
dim sID as string
   FA = createunoservice("com.sun.star.sheet.FunctionAccess")
     sID = FA.callFunction("INFO", array("Release")
     msgbox "Build ID: " & sID
end sub

Regards
Pierre-Yves
Comment 2 LibreOfficiant 2017-02-21 17:27:02 UTC
Hi,

While I also greatly support the above requests, I would to comment it further:

With regards to LibreOffice Basic coding consistency, I may object that Basic may end up with dozens of getThis() & getThat() functions all over the place. They may possibly collide with hundreds of existing Basic code modules already produced.

In order to limit the number of Basic language reserved statement to a reasonable amount, may I recommend we are provided with a class/service, named 'myLibreOffice' per se or anything else, that holds the requested attributes & that can be extended at will to any new properties/methods/.. of of future taste.

Furthermore, a built-in class/service paradigm would be distributable to Python, JavaScript & BeanShell all together.

Regards
Alain
Comment 3 Gerhard Weydt 2017-07-04 10:27:21 UTC
As Pierre-Yves remarked, LibreOffice Macros -> Tools -> Misc -> GetProductname provides the information called for, both the product name and the version. Starting from this you can write your own routine providing the information fitting to your taste in less than five minutes.
So why should someone bother to do this for you?
Comment 4 Rafael Lima 2022-07-30 18:12:25 UTC
I would say this bug has been fixed indirectly by the introduction of the Platform service of the ScriptForge library since LO 7.1 IIRC.

Here's the help page for the Platform service:

https://help.libreoffice.org/latest/en-US/text/sbasic/shared/03/sf_platform.html?DbPAR=BASIC#bm_id501600788076381
Comment 5 Andreas Heinisch 2022-08-01 16:24:27 UTC
Then lets close it with WFM since all the information can be retrieved using the platform service using the scriptforge library pointed out by comment 4.