List Info

Thread: Getting OOo Version via API




Getting OOo Version via API
user name
2007-10-22 09:15:44
Hi together,

is it possible to retrieve the OpenOffice version via API?

Greetings, Tobias

------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribeapi.openoffice.org
For additional commands, e-mail: dev-helpapi.openoffice.org


Re: Getting OOo Version via API
user name
2007-10-22 09:24:25
Hi

> 
> is it possible to retrieve the OpenOffice version via
API?

sure, reading the config registry Setup

in what language do yo need it ?
I have it OOoBasic and Java

Laurent

-- 
Laurent Godard <lgodardindesko.com> -
Ingénierie OpenOffice.org - 
http://www.indesko.com
Nuxeo Enterprise Content Management >> http://www.nuxeo.com - 
http://www.nuxeo.org
Livre "Programmation OpenOffice.org", Eyrolles
2004-2006

------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribeapi.openoffice.org
For additional commands, e-mail: dev-helpapi.openoffice.org


Re: Getting OOo Version via API
user name
2007-10-22 09:29:33
Hi Laurant,

>> is it possible to retrieve the OpenOffice version
via API?
> 
> sure, reading the config registry Setup
> 
> in what language do yo need it ?
> I have it OOoBasic and Java

I need it in Java.

Greetings, Tobias

------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribeapi.openoffice.org
For additional commands, e-mail: dev-helpapi.openoffice.org


Re: Getting OOo Version via API
user name
2007-10-22 09:33:50
Hi again

> in what language do yo need it ?
> I have it OOoBasic and Java

a first link in basic
http://codesnippets.services.openoffice.or
g/Office/Office.Version.snip

in java at the end

you may also consider using ooSetupVersionAboutBox instead
of ooSetupVersion

Laurent
'---------------------------
     public String getOpenOfficeVersion(){
     	return 
getOpenOfficeProperty("org.openoffice.Setup/Product&quo
t;,"ooSetupVersionAboutBox");
     }

     public String getOpenOfficeProperty(String nodePath,
String node){
     	if (!nodePath.startsWith("/")){
     		nodePath = "/" + nodePath;
     	}
     	String property = "";
     	// create the provider and remember it as a
XMultiServiceFactory
     	try {
         	final String sProviderService = 
"com.sun.star.configuration.ConfigurationProvider"
;
             Object configProvider = 
connection.getRemoteServiceManager().createInstanceWithConte
xt(
             		sProviderService,
connection.getComponentContext());
             XMultiServiceFactory  xConfigProvider = 
(XMultiServiceFactory) UnoRuntime.queryInterface(
                    
com.sun.star.lang.XMultiServiceFactory.class, 
configProvider);

             // The service name: Need only read access:
             final String sReadOnlyView = 
"com.sun.star.configuration.ConfigurationAccess";
             // creation arguments: nodepath
             PropertyValue aPathArgument = new
PropertyValue();
             aPathArgument.Name = "nodepath";
             aPathArgument.Value = nodePath;
             Object[] aArguments = new Object[1];
             aArguments[0] = aPathArgument;

             // create the view
             XInterface xElement = (XInterface) 
xConfigProvider.createInstanceWithArguments(sReadOnlyView,
aArguments);
             XNameAccess xChildAccess =
                 (XNameAccess) 
UnoRuntime.queryInterface(XNameAccess.class, xElement);

             // get the value
             property = (String)
xChildAccess.getByName(node);
     	} catch (Exception exception){
     		throw new OpenOfficeException("Error retreiving
property", 
exception);
     	}
     	return property;
     }




-- 
Laurent Godard <lgodardindesko.com> -
Ingénierie OpenOffice.org - 
http://www.indesko.com
Nuxeo Enterprise Content Management >> http://www.nuxeo.com - 
http://www.nuxeo.org
Livre "Programmation OpenOffice.org", Eyrolles
2004-2006

------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribeapi.openoffice.org
For additional commands, e-mail: dev-helpapi.openoffice.org


Re: Getting OOo Version via API
user name
2007-10-23 04:36:18
Hi Laurant,

thanks a lot for your solution. It works perfect!

> you may also consider using ooSetupVersionAboutBox
instead of
> ooSetupVersion

ooSetupVersion returns "2.3" and
ooSetupVersionAboutBox returns "2.3.0".
My version comparison method works with both, so it doesn't
matter.

Thanks a lot for your help!

Greetings, Tobias

------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribeapi.openoffice.org
For additional commands, e-mail: dev-helpapi.openoffice.org


[1-5]

about | contact  Other archives ( Real Estate discussion Medical topics )