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

Commit 4973b32

Browse files
author
Emmanuel Hugonnet
committed
Fixing bug #4346 Taking Ms Office and Windows version into account when choosing the webdav url.
1 parent 4931089 commit 4973b32

File tree

3 files changed

+33
-44
lines changed

3 files changed

+33
-44
lines changed

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,26 +43,25 @@ public class OfficeLauncher {
4343

4444
/**
4545
* Launch the document editor.
46+
*
4647
* @param type type of editor for the document (word editor, presentation editor, etc.)
4748
* @param url the url to the document.
4849
* @param authInfo authentication parameters
49-
* @param useDeconnectedMode : set to true if you want to activate the Disconnected mode :
50-
* 1) download file using webdav to local temp directory
51-
* 2) open it
52-
* 3) after close, send it back to silverpeas, still using webdav
53-
* 4) delete temp file locally
50+
* @param useDeconnectedMode : set to true if you want to activate the Disconnected mode : 1)
51+
* download file using webdav to local temp directory 2) open it 3) after close, send it back to
52+
* silverpeas, still using webdav 4) delete temp file locally
5453
* @return the result of the process.
5554
* @throws IOException
5655
* @throws InterruptedException
57-
* @throws OfficeNotFoundException
56+
* @throws OfficeNotFoundException
5857
*/
5958
public static int launch(MsOfficeType type, String url, AuthenticationInfo authInfo,
6059
boolean useDeconnectedMode) throws IOException, InterruptedException, OfficeNotFoundException {
6160
OfficeFinder finder = FinderFactory.getFinder(type);
6261
logger.log(Level.INFO, "Are we using Office : {0}", finder.isMicrosoftOffice());
6362
logger.log(Level.INFO, "We are on {0} OS", OsEnum.getOS());
6463
boolean modeDisconnected = ((OsEnum.isWindows() && useDeconnectedMode) || OsEnum.getOS()
65-
== OsEnum.MAC_OSX) && finder.isMicrosoftOffice();
64+
== OsEnum.MAC_OSX) && finder.isMicrosoftOffice();
6665
switch (type) {
6766
case EXCEL:
6867
return launch(type, finder.findSpreadsheet(), url, modeDisconnected, authInfo);
@@ -116,7 +115,8 @@ protected static int launch(MsOfficeType type, String path, String url, boolean
116115
} else {
117116
// Standard mode : just open it
118117
String webdavUrl = url;
119-
if(OsEnum.isWindows() && MsOfficeVersion.isOldOffice(type)) {
118+
if (OsEnum.getOS() == OsEnum.WINDOWS_XP || (OsEnum.isWindows() && MsOfficeVersion.isOldOffice(
119+
type))) {
120120
webdavUrl = webdavUrl.replace("/repository/", "/repository2000/");
121121
}
122122
logger.log(Level.INFO, "The exact exec line: {0} {2}", new Object[]{path, webdavUrl});

src/main/java/org/silverpeas/openoffice/util/OsEnum.java

Lines changed: 24 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,33 @@
11
/**
22
* Copyright (C) 2000 - 2009 Silverpeas
33
*
4-
* This program is free software: you can redistribute it and/or modify
5-
* it under the terms of the GNU Affero General Public License as
6-
* published by the Free Software Foundation, either version 3 of the
7-
* License, or (at your option) any later version.
4+
* This program is free software: you can redistribute it and/or modify it under the terms of the
5+
* GNU Affero General Public License as published by the Free Software Foundation, either version 3
6+
* of the License, or (at your option) any later version.
87
*
9-
* As a special exception to the terms and conditions of version 3.0 of
10-
* the GPL, you may redistribute this Program in connection with Free/Libre
11-
* Open Source Software ("FLOSS") applications as described in Silverpeas's
12-
* FLOSS exception. You should have received a copy of the text describing
13-
* the FLOSS exception, and it is also available here:
8+
* As a special exception to the terms and conditions of version 3.0 of the GPL, you may
9+
* redistribute this Program in connection with Free/Libre Open Source Software ("FLOSS")
10+
* applications as described in Silverpeas's FLOSS exception. You should have received a copy of the
11+
* text describing the FLOSS exception, and it is also available here:
1412
* "http://repository.silverpeas.com/legal/licensing"
1513
*
16-
* This program is distributed in the hope that it will be useful,
17-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19-
* GNU Affero General Public License for more details.
14+
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
15+
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16+
* Affero General Public License for more details.
2017
*
21-
* You should have received a copy of the GNU Affero General Public License
22-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
23-
*/
24-
25-
/*
26-
* To change this template, choose Tools | Templates
27-
* and open the template in the editor.
18+
* You should have received a copy of the GNU Affero General Public License along with this program.
19+
* If not, see <http://www.gnu.org/licenses/>.
2820
*/
2921
package org.silverpeas.openoffice.util;
3022

31-
import java.io.File;
32-
3323
/**
34-
* @author Emmanuel Hugonnet
24+
* Enumeration of supported OS type.
3525
*/
3626
public enum OsEnum {
3727

38-
WINDOWS_XP("Application Data\\Mozilla\\Firefox\\Profiles"), WINDOWS_VISTA(
39-
"Appdata\\Roaming\\Mozilla\\Firefox"), WINDOWS_SEVEN("Appdata\\Roaming\\Mozilla\\Firefox"), LINUX(
40-
".mozilla/firefox"), MAC_OSX(".mozilla/firefox");
41-
protected String profilesDir;
28+
WINDOWS_XP, WINDOWS_VISTA, WINDOWS_SEVEN, WINDOWS_8, LINUX, MAC_OSX;
4229

43-
OsEnum(String profilesDir) {
44-
this.profilesDir = profilesDir;
30+
OsEnum() {
4531
}
4632

4733
public static OsEnum getOS(String value) {
@@ -51,6 +37,9 @@ public static OsEnum getOS(String value) {
5137
if ("Windows 7".equalsIgnoreCase(value)) {
5238
return WINDOWS_SEVEN;
5339
}
40+
if ("Windows 8".equalsIgnoreCase(value)) {
41+
return WINDOWS_8;
42+
}
5443
if ("Windows XP".equalsIgnoreCase(value) || value.startsWith("Windows ")) {
5544
return WINDOWS_XP;
5645
}
@@ -60,20 +49,20 @@ public static OsEnum getOS(String value) {
6049
return MAC_OSX;
6150
}
6251

52+
/**
53+
* Detect the local OS.
54+
*
55+
* @return the OS on which the code is running.
56+
*/
6357
public static OsEnum getOS() {
6458
return getOS(System.getProperty("os.name"));
6559
}
6660

67-
public String getProfilesDirectory() {
68-
return System.getProperty("user.home") + File.separator + profilesDir;
69-
}
70-
71-
7261
public static boolean isWindows() {
7362
OsEnum currentOS = getOS();
7463
return currentOS == WINDOWS_SEVEN || currentOS == WINDOWS_XP || currentOS == WINDOWS_VISTA;
7564
}
76-
65+
7766
public static boolean isLinux() {
7867
return getOS() == LINUX;
7968
}

src/main/java/org/silverpeas/openoffice/windows/MsOfficeRegistryHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ protected String getPath(RegistryApplicationKey type) {
5858
path = RegistryKeyReader.readKey(BASE_KEY_64_CLSID + clsid + "\\LocalServer32\"");
5959
}
6060
if (path != null) {
61-
String extractedPath = extractPath(path);
61+
String extractedPath = extractPath(path).trim();
6262
if (!extractedPath.startsWith("\"")) {
6363
extractedPath = '"' + extractedPath + '"';
6464
}

0 commit comments

Comments
 (0)