优先使用自定义office.home

pull/9/head
陈精华 2019-04-18 11:49:29 +08:00 committed by kl
parent af8ddc10da
commit f989fbf9c9
2 changed files with 19 additions and 5 deletions

View File

@ -12,8 +12,11 @@
// //
package org.artofsolving.jodconverter.office; package org.artofsolving.jodconverter.office;
import java.io.BufferedReader;
import java.io.File; import java.io.File;
import java.io.FileReader;
import java.util.Map; import java.util.Map;
import java.util.Properties;
import org.artofsolving.jodconverter.util.PlatformUtils; import org.artofsolving.jodconverter.util.PlatformUtils;
@ -61,8 +64,14 @@ public class OfficeUtils {
} }
public static File getDefaultOfficeHome() { public static File getDefaultOfficeHome() {
if (System.getProperty("office.home") != null) { Properties properties = new Properties();
return new File(System.getProperty("office.home")); 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()) { if (PlatformUtils.isWindows()) {
// %ProgramFiles(x86)% on 64-bit machines; %ProgramFiles% on 32-bit ones // %ProgramFiles(x86)% on 64-bit machines; %ProgramFiles% on 32-bit ones
@ -127,4 +136,11 @@ public class OfficeUtils {
return userDir; 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;
}
} }

View File

@ -42,9 +42,7 @@ public class ConfigRefreshComponent {
String convertedFileCharset = sysProperties.getProperty("sun.jnu.encoding"); String convertedFileCharset = sysProperties.getProperty("sun.jnu.encoding");
String[] textArray ; String[] textArray ;
String[] mediaArray; String[] mediaArray;
String homePath = OfficeUtils.getHomePath(); String configFilePath = OfficeUtils.getCustomizedConfigPath();
String separator = java.io.File.separator;
String configFilePath = homePath + separator + "conf" + separator + "application.properties";
while (true) { while (true) {
BufferedReader bufferedReader = new BufferedReader(new FileReader(configFilePath)); BufferedReader bufferedReader = new BufferedReader(new FileReader(configFilePath));
properties.load(bufferedReader); properties.load(bufferedReader);