-
Notifications
You must be signed in to change notification settings - Fork 24
where
Jochen Staerk edited this page Dec 21, 2015
·
1 revision
This will look for OpenOffice in it's default locations and print where it has been found.
import ag.ion.bion.officelayer.application.IApplicationAssistant;
import ag.ion.bion.officelayer.application.ILazyApplicationInfo;
//...
IApplicationAssistant applicationAssistant = new ApplicationAssistant();
ILazyApplicationInfo appInfo = applicationAssistant.getLatestLocalApplication();
if (appInfo!=null) { // A Openoffice.org was found
System.out.println(appInfo.getHome());
}
Please note in noa-libre getLatestLocalApplication has to be replaced by getLatestLocalLibreOfficeApplication respectively getLatestLocalOpenOfficeOrgApplication.
This is some source code which should obtain the libreoffice/openoffice installation with the highest version number:
public static ILazyApplicationInfo getOfficeInfo() {
IApplicationAssistant applicationAssistant;
ILazyApplicationInfo appInfo=null, LappInfo=null, OappInfo=null;
try {
applicationAssistant = new ApplicationAssistant();
LappInfo = applicationAssistant.getLatestLocalLibreOfficeApplication();
OappInfo = applicationAssistant.getLatestLocalOpenOfficeOrgApplication();
appInfo=LappInfo;// take the latest libreoffice installation unless openoffice is also installed in a higher version
if (appInfo==null) {
appInfo=OappInfo;
}
if ((LappInfo!=null)&&(OappInfo!=null)) {
if (LappInfo.getMajorVersion()>OappInfo.getMajorVersion()) {
appInfo=LappInfo;
}
if (LappInfo.getMajorVersion()==OappInfo.getMajorVersion()) {
if (LappInfo.getMinorVersion()>OappInfo.getMinorVersion()) {
appInfo=LappInfo;
}
}
}
} catch (OfficeApplicationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return appInfo;
}