Skip to content
This repository was archived by the owner on Sep 17, 2024. It is now read-only.

Commit 37f8bf8

Browse files
author
Emmanuel Hugonnet
committed
Trying to launch Ms Office on Mac
git-svn-id: https://www.silverpeas.org/svn/silverpeas/services/office-online/trunk@694 a8e77078-a1c7-4fa5-b8fc-53c5178a176c
1 parent 539a10a commit 37f8bf8

File tree

4 files changed

+16
-7
lines changed

4 files changed

+16
-7
lines changed

src/main/java/com/silverpeas/openoffice/Launcher.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public class Launcher {
5353
/**
5454
* @param args the command line arguments
5555
*/
56-
public static void main(String[] args) throws OfficeNotFoundException {
56+
public static void main(final String[] args) throws OfficeNotFoundException {
5757
logger.log(Level.INFO,
5858
MessageUtil.getMessage("app.title") + " version " + LAUNCHER_VERSION);
5959
logger.log(Level.INFO, MessageUtil.getMessage("info.url.encoded") + args[0]);

src/main/java/com/silverpeas/openoffice/OfficeLauncher.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,13 @@ public static int launch(String path, String url, boolean modeDisconnected,
8282
logger.log(Level.INFO, "The command line: " + path + ' ' + url);
8383
if (modeDisconnected) {
8484
try {
85-
FileWebDavAccessManager webdavAccessManager = new FileWebDavAccessManager(auth);
86-
url = url.substring(1, url.length() - 1);
87-
String tmpFilePath = webdavAccessManager.retrieveFile(url);
85+
String webdavUrl = url;
86+
final FileWebDavAccessManager webdavAccessManager = new FileWebDavAccessManager(auth);
87+
if ('"' == url.charAt(0)) {
88+
webdavUrl = url.substring(1, url.length() - 1);
89+
}
90+
String tmpFilePath = webdavAccessManager.retrieveFile(webdavUrl);
91+
logger.log(Level.INFO, "The exact exec line: " + path + ' ' + tmpFilePath);
8892
Process process = Runtime.getRuntime().exec(path + ' ' + tmpFilePath);
8993
process.waitFor();
9094
webdavAccessManager.pushFile(tmpFilePath, url);

src/main/java/com/silverpeas/openoffice/macosx/MacOsOfficeFinder.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,16 @@
3131
import com.silverpeas.openoffice.OfficeNotFoundException;
3232
import com.silverpeas.openoffice.OpenOfficeFinder;
3333
import java.io.File;
34+
import java.util.logging.Level;
35+
import java.util.logging.Logger;
3436

3537
/**
3638
* @author ehugonnet
3739
*/
3840
public class MacOsOfficeFinder implements OfficeFinder {
3941

42+
static Logger logger = Logger.getLogger(MacOsOfficeFinder.class.getName());
43+
4044
protected static final OpenOfficeFinder finder = new WhereisMacHelper();
4145
protected static final String OFFICE_PATH =
4246
"/Applications/Microsoft Office 2008/";
@@ -73,7 +77,7 @@ public String findWordEditor() throws OfficeNotFoundException {
7377

7478
@Override
7579
public String findOther() throws OfficeNotFoundException {
76-
throw new UnsupportedOperationException("Not supported yet.");
80+
return finder.findOther();
7781
}
7882

7983
@Override
@@ -83,6 +87,7 @@ public boolean isMicrosoftOffice2007() {
8387

8488
protected boolean isMsOfficePresent() {
8589
File officeDir = new File(OFFICE_PATH);
90+
logger.log(Level.INFO, "Looking for file " + OFFICE_PATH + " but found " + officeDir.exists());
8691
return officeDir.exists();
8792
}
8893

src/main/java/com/silverpeas/openoffice/util/FinderFactory.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
*/
4040
public class FinderFactory {
4141

42-
public static OfficeFinder getFinder(MsOfficeType contentType) {
42+
public static OfficeFinder getFinder(final MsOfficeType contentType) {
4343
OsEnum os = OsEnum.getOS(System.getProperty("os.name"));
4444
switch (os) {
4545
case WINDOWS_XP:
@@ -51,7 +51,7 @@ public static OfficeFinder getFinder(MsOfficeType contentType) {
5151
case LINUX:
5252
return new WhereisHelper();
5353
case MAC_OSX:
54-
return new WhereisMacHelper();
54+
return new MacOsOfficeFinder();
5555
default:
5656
return new WhereisHelper();
5757
}

0 commit comments

Comments
 (0)