Commit f989fbf9 authored by 陈精华's avatar 陈精华 Committed by kl

优先使用自定义office.home

parent af8ddc10
......@@ -12,8 +12,11 @@
//
package org.artofsolving.jodconverter.office;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.Map;
import java.util.Properties;
import org.artofsolving.jodconverter.util.PlatformUtils;
......@@ -61,8 +64,14 @@ public class OfficeUtils {
}
public static File getDefaultOfficeHome() {
if (System.getProperty("office.home") != null) {
return new File(System.getProperty("office.home"));
Properties properties = new Properties();
String customizedConfigPath = getCustomizedConfigPath();
try {
BufferedReader bufferedReader = new BufferedReader(new FileReader(customizedConfigPath));
properties.load(bufferedReader);
} catch (Exception e) {}
if (properties.getProperty("office.home") != null) {
return new File(properties.getProperty("office.home"));
}
if (PlatformUtils.isWindows()) {
// %ProgramFiles(x86)% on 64-bit machines; %ProgramFiles% on 32-bit ones
......@@ -127,4 +136,11 @@ public class OfficeUtils {
return userDir;
}
public static String getCustomizedConfigPath() {
String homePath = OfficeUtils.getHomePath();
String separator = java.io.File.separator;
String configFilePath = homePath + separator + "conf" + separator + "application.properties";
return configFilePath;
}
}
......@@ -42,9 +42,7 @@ public class ConfigRefreshComponent {
String convertedFileCharset = sysProperties.getProperty("sun.jnu.encoding");
String[] textArray ;
String[] mediaArray;
String homePath = OfficeUtils.getHomePath();
String separator = java.io.File.separator;
String configFilePath = homePath + separator + "conf" + separator + "application.properties";
String configFilePath = OfficeUtils.getCustomizedConfigPath();
while (true) {
BufferedReader bufferedReader = new BufferedReader(new FileReader(configFilePath));
properties.load(bufferedReader);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment