 | OO-Snippets: Get Open Office version and languageCommons| Keywords | language, locale, version, open, office |
|---|
| Language | ooRexx |
|---|
| Application | Office |
|---|
| Authors | Josef Frysak (initial)
|
|---|
| Supported Versions | 2.4.1 |
|---|
| Supported OS | All |
|---|
| Question | How to get the Version and the language of Open Office?
|
|---|
| Answer | Create a "ConfigurationProvider" service and get its "XMultiServiceFactory" interface. With this interface one is able to create "ConfigurationAccess" objects, which grant read access to the configuration of Open Office. Send the location of the configuration as a parameter when creating an "ConfigurationAccess" object in order to determine the information, which shall be accessed. For further details see http://wi.wu-wien.ac.at/rgf/diplomarbeiten/BakkStuff/2008/200809_Frysak/200809_Frysak_Automating_OOo_ooRexx_Nutshells.pdf. |
|---|
x_ScriptContext = uno.getScriptContext()
if (x_ScriptContext <> .nil) then
do
x_ComponentContext = x_ScriptContext~getComponentContext
x_Desktop = x_ScriptContext~getDesktop
x_Document = x_ScriptContext~getDocument
end
else
do
x_ComponentContext = UNO.connect()
service = "com.sun.star.frame.Desktop"
s_Desktop = x_ComponentContext~getServiceManager~XMultiServiceFactory~createInstance(service)
x_Desktop = s_Desktop~XDesktop
x_Document = x_Desktop~getCurrentComponent()
end
x_MultiServiceFactory = x_ComponentContext~getServiceManager()~XMultiServiceFactory
configprovider = "com.sun.star.configuration.ConfigurationProvider"
s_ConfigProvider = x_MultiServiceFactory~createInstance(configprovider)
x_ConfigFactory = s_ConfigProvider~XMultiServiceFactory
conf = "com.sun.star.configuration.ConfigurationAccess"
args = uno.CreateArray(.UNO~PROPERTYVALUE, 1)
args[1] = uno.createProperty("nodepath", "/org.openoffice.Setup/L10N")
s_ConfigurationAccess = x_ConfigFactory~createInstanceWithArguments(conf, args)
x_NameAccess = s_ConfigurationAccess~XNameAccess
locale = x_NameAccess~getByName("ooLocale")
args[1]~value = "/org.openoffice.Setup/Product"
s_ConfigurationAccess = x_ConfigFactory~createInstanceWithArguments(conf, args)
x_NameAccess = s_ConfigurationAccess~XNameAccess
version = x_NameAccess~getByName("ooSetupVersion")
crlf = "13"~d2c || "10"~d2c
output = "Open Office: " || crlf || "Version: " || version || crlf || "Language: " || locale
.bsf.dialog~messageBox(output, "About:", "information")
::requires UNO.CLS
|
Changelog| Date | User | Modification |
|---|
| 2008-10-13 | 1 | Initial version |
|