if (docpth.equals("unknown")) {
System.out.println("try to get tDoc from $SRC_ROOT/qadevOOo");
String srcRoot = System.getProperty(PropertyName.SRC_ROOT); if (srcRoot != null) {
File srcR = new File(srcRoot);
String[] list = srcR.list(new FilenameFilter() {
if (fullDocPath.startsWith("http:")) { return fullDocPath;
} if (fullDocPath.startsWith("ftp:")) { return fullDocPath;
}
String prefix = ""; if (!fullDocPath.startsWith("file:///")) { if (fullDocPath.startsWith("//")) {
prefix = "file:";
} else { if (fullDocPath.startsWith("/")) {
prefix = "file://";
} else
{
prefix = "file:///";
}
}
} if (!fullDocPath.endsWith("/")) {
File aFile = new File(fullDocPath); if (aFile.isDirectory()) {
fullDocPath += "/";
}
}
String fulldocURL = prefix + fullDocPath;
return fulldocURL;
}
/** * *Thismethodgetstheuserdiroftheconnectedoffice *
*/ publicstatic String getOfficeUserPath(XMultiServiceFactory msf) { // get a folder located in the user dir
String userPath = getOfficeSettingsValue(msf, "UserConfig");
// strip the returned folder to the user dir if (userPath.charAt(userPath.length() - 1) == '/') {
userPath = userPath.substring(0, userPath.length() - 1);
} int index = userPath.lastIndexOf('/'); if (index != -1) {
userPath = userPath.substring(0, index);
}
String dir = getOfficeTemp(msf);
String sysDir = "";
int idx = dir.indexOf("file://");
// remove leading 'file://' if (idx < 0) {
sysDir = dir;
} else {
sysDir = dir.substring("file://".length());
}
// append '/' if not there (e.g. linux) if (sysDir.charAt(sysDir.length() - 1) != '/') {
sysDir += "/";
}
// remove leading '/' and replace others with '\' on windows machines if (sysDir.indexOf(':') != -1) {
sysDir = sysDir.substring(1);
sysDir = sysDir.replace('/', '\\');
} return sysDir;
}
// remove leading 'file://' if (idx < 0) {
sysDir = fileURL;
} else {
sysDir = fileURL.substring("file://".length());
}
// remove leading '/' and replace others with '\' on windows machines if (sysDir.indexOf(':') != -1) {
sysDir = sysDir.substring(1);
sysDir = sysDir.replace('/', '\\');
} return sysDir;
}
/** *Getanarrayofallpropertynamesfromthepropertyset.Withtheinclude *andexcludeparametersthepropertiescanbefiltered.<br> *SetexcludePropertyAttribute=0andincludePropertyAttribute=0 *toincludeallandexcludenone. *@parampropsTheinstanceofXPropertySet *@paramincludePropertyAttributePropertieswithouttheseattributesarefilteredandwillnotbereturned. *@paramexcludePropertyAttributePropertieswiththeseattributesarefilteredandwillnotbereturned. *@paramarrayofstringnamesofpropertiesthatwillbeskipped *@returnAStringarraywithallpropertynames. *@seecom.sun.star.beans.XPropertySet *@seecom.sun.star.beans.Property *@seecom.sun.star.beans.PropertyAttribute
*/ publicstatic String[] getFilteredPropertyNames(XPropertySet props, short includePropertyAttribute, short excludePropertyAttribute, String[] skipList) {
Property[] the_props = props.getPropertySetInfo().getProperties();
ArrayList<String> l = new ArrayList<String>(); for (int i = 0; i < the_props.length; i++) { if (Arrays.asList(skipList).contains(the_props[i].Name)) continue; boolean exclude = ((the_props[i].Attributes & excludePropertyAttribute) != 0); boolean include = (includePropertyAttribute == 0) ||
((the_props[i].Attributes & includePropertyAttribute) != 0); if (include && !exclude) {
l.add(the_props[i].Name);
}
}
Collections.sort(l);
String[] names = new String[l.size()];
names = l.toArray(names); return names;
}
/** Causes the thread to sleep some time. *Thisisthedefaultcall,whichwaitsfor500ms.
*/ publicstaticvoid shortWait() {
pause(utils.DEFAULT_SHORT_WAIT_MS);
}
/** Causes the thread to sleep some time.
*/ publicstaticvoid pause(int milliseconds) { try { Thread.sleep(milliseconds);
} catch (InterruptedException e) {
System.out.println("While waiting :" + e);
}
}
/** *ValidatetheAppExecutionCommand.Returnedisanerrormessage,starting *with"Error:",orawarning,ifthecommandmightwork. *@paramappExecCommandTheapplicationexecutioncommandthatischecked. *@paramosTheoperatingsystemwherethecheckruns. *@returnTheerrormessage,orOK,ifnoerrorwasdetected.
*/ publicstatic String validateAppExecutionCommand(String appExecCommand, String os) {
String errorMessage = "OK";
appExecCommand = appExecCommand.replace("\"", "");
appExecCommand = appExecCommand.replace("'", "");
StringTokenizer commandTokens = new StringTokenizer(appExecCommand, " \t");
String officeExecCommand = "soffice";
StringBuilder sb = new StringBuilder(); // is there a 'soffice' in the command? 2do: eliminate case sensitivity on windows int index = -1; while (commandTokens.hasMoreTokens() && index == -1) {
sb.append(commandTokens.nextToken()).append(" ");
index = sb.indexOf(officeExecCommand);
} if (index == -1) {
errorMessage = "Error: Your 'AppExecutionCommand' parameter does not " + "contain '" + officeExecCommand + "'.";
} else {
String officeExecutable = sb.toString(); // does the directory exist?
officeExecutable = officeExecutable.trim();
String officePath = officeExecutable.substring(0, index);
File f = new File(officePath); if (!f.exists() || !f.isDirectory()) {
errorMessage = "Error: Your 'AppExecutionCommand' parameter does not " + "point to a valid system directory: " + officePath;
} else { // is it an office installation?
f = new File(officeExecutable); // one try for windows platform can't be wrong... if (!f.exists() || !f.isFile()) {
f = new File(officeExecutable + ".exe");
} if (!f.exists() || !f.isFile()) {
errorMessage = "Error: Your 'AppExecutionCommand' parameter does not " + "point to a valid office installation.";
} else { // do we have the accept parameter? boolean gotNoAccept = true; while (commandTokens.hasMoreElements()) {
String officeParam = commandTokens.nextToken(); if (officeParam.indexOf("--accept=") != -1) {
gotNoAccept = false;
errorMessage = validateConnectString(officeParam, true);
}
} if (gotNoAccept) {
errorMessage = "Error: Your 'AppExecutionCommand' parameter does not " + "contain a '--accept' parameter for connecting the office.";
}
}
}
} return errorMessage;
}
String errorMessage = "OK"; // a warning, if an unknown connection method is used if (connectString.indexOf("socket") != -1) { if (connectString.indexOf(acceptPrefix + "socket,host=") == -1 ||
connectString.indexOf("port=") == -1) { if (checkAppExecutionCommand) {
errorMessage = "Error: The '--accept' parameter contains a syntax error: It should be like: '--accept=socket,host=localhost,port=8100;urp;";
} else {
errorMessage = "Error: The 'ConnectionString' parameter contains a syntax error: It should be like: 'socket,host=localhost,port=8100'";
}
}
} elseif (connectString.indexOf("pipe") != -1) { if (connectString.indexOf(acceptPrefix + "pipe,name=") == -1) { if (checkAppExecutionCommand) {
errorMessage = "Error: The '--accept' parameter contains a syntax error: It should be like: '--accept=pipe,name=myuniquename;urp;'";
} else {
errorMessage = "Error: The 'ConnectionString' parameter contains a syntax error: It should be like: 'pipe,name=myuniquename'";
}
}
} else { if (checkAppExecutionCommand) {
errorMessage = "Warning: The '--accept' parameter contains an unknown connection method.";
} else {
errorMessage = "Warning: The 'ConnectionString' parameter contains an unknown connection method.";
}
} return errorMessage;
}
// Because it's an in/out parameter we must use an array of URL objects.
URL[] aParseURL = new URL[1];
aParseURL[0] = new URL();
aParseURL[0].Complete = URL;
xParser.parseStrict(aParseURL);
/** returns a String which contains the current date and time<br> *format:[DD.MM.YYYY-HH:MM:SS::mm] * **@returnaStringwhichcontainsthecurrentdateandtime
*/ publicstatic String getDateTime() {
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.