Hello
I have switched to oo-2 and find that the package deployer pushes
deployed files one level deeper than was the case for oo-1. Since I use
an XCS/XCU setup to locate out suites of custom macros, I need to know
the version (1 or 2) in spite of 'masterly advice'. In the spirit of the
Pitonyak OO-Basic version getter, I offer this subset of my helper class
(don't know how to make snippets):
==
public final class NxCallHelper {
private XComponentContext myContext = null;
private XMultiComponentFactory myServiceManager = null;
private String myOVer = null;
// == primed from successful access to OO via normal means
public NxCallHelper(XMultiComponentFactory xServiceManager,
XComponentContext xContext) {
myContext = xContext;
myServiceManager = xServiceManager;
}
// == used in many other places in this helper
public XInterface accessConfig(String sConfigPath) throws Exception {
XInterface xInt = null;
// creation arguments: nodepath
com.sun.star.beans.PropertyValue aPathArg = new
com.sun.star.beans.PropertyValue();
aPathArg.Name = "nodepath";
aPathArg.Value = sConfigPath;
Object[] aArgs = new Object[] {aPathArg};
// get ro access
xInt =
(XInterface)createConfigProvider().createInstanceWithArguments("com.sun.
star.configuration.ConfigurationAccess", aArgs);
if (xInt == null) {
throw new java.lang.InstantiationError("failed to accessCfg");
}
return xInt;
}
// == get version
public String officeVersion() {
if (myOVer == null) {
String sVersion = "??";
try {
XInterface xInt = accessConfig("/org.openoffice.Setup/Product");
XNameAccess xAccess =
(XNameAccess)UnoRuntime.queryInterface(XNameAccess.class, xInt);
boolean bVer = xAccess.hasByName("ooSetupVersion");
if (bVer) {
Object obj = xAccess.getByName("ooSetupVersion");
if (obj instanceof String) {
sVersion = (String)obj;
}
}
}
catch(Exception e) {
// nada
}
finally {
myOVer = sVersion;
}
}
return myOVer;
}
// == used to provide the XCU key for oo-1 or oo-2
public String getMacroUrlKey() throws Exception {
switch(officeVersion().charAt(0)) {
case '1':
return "OoMacroLibsVer1/Url";
case '2':
return "OoMacroLibsVer2/Url";
default:
throw new java.lang.InstantiationError("failed to determine
office version");
}
}
} //endclass
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]