[Solved] Get OOo version programatically

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
Anderl.Heckmaier
Posts: 2
Joined: Sat Apr 16, 2011 1:04 am

[Solved] Get OOo version programatically

Post by Anderl.Heckmaier »

I have inherited some code that uses the Ooo SDK and am very new with this stuff. Anyone know how I can get the version of the Ooo app that I am hooked into?

thanks,
AH
Last edited by Anderl.Heckmaier on Mon Apr 18, 2011 4:42 pm, edited 1 time in total.
Open Office 3.3 Win 7
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Get Ooo version programatically

Post by Villeroy »

A set of Basic functions to get/set values from the OOo registry.

Code: Select all

Function getOOoVersion() As String

  getOOoVersion = getOOoSetupValue("/org.openoffice.Setup/Product","ooSetupVersion")
end Function

Function getOOoSetupNode(sNodePath$)
Dim aConfigProvider, oNode, args(0) As new com.sun.star.beans.PropertyValue
	aConfigProvider = createUnoService("com.sun.star.configuration.ConfigurationProvider")
	args(0).Name = "nodepath"
	args(0).Value = sNodePath
	getOOoSetupNode = aConfigProvider.createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", args())
End Function

Function getOOoSetupValue(sNodePath$,sProperty$)
Dim oNode
	oNode = getOOoSetupNode(sNodePath)
	getOOoSetupValue = oNode.getbyname(sProperty)
End Function

Function setOOoSetupValue(sNodePath$, sProperty$, sValue$) as Boolean
on error goto exitErr
Dim bReturn as Boolean, xconfig, xAccess
dim aArgs(0) as  Object
dim aPropValue as new  com.sun.star.beans.PropertyValue
	xconfig = CreateUnoService("com.sun.star.configuration.ConfigurationProvider")
	aPropValue.Name = "nodepath"
	aPropValue.Value = sNodePath
	aArgs(0) = aPropValue
	xAccess = xconfig.createInstanceWithArguments("com.sun.star.configuration.ConfigurationUpdateAccess",aArgs())
	xAccess.setPropertyValue(sProperty, sValue)
	xAccess.commitChanges()
	bReturn = True
exitErr:
	setOOoSetupValue = bReturn
End Function
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Post Reply