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

Commit ef34dcb

Browse files
author
Emmanuel Hugonnet
committed
Upload Progress Bar is active for Vista/Office 2007
git-svn-id: https://www.silverpeas.org/svn/silverpeas/services/office-online/trunk@518 a8e77078-a1c7-4fa5-b8fc-53c5178a176c
1 parent 67e3c0f commit ef34dcb

36 files changed

+1749
-1430
lines changed

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@
2525

2626
/**
2727
* Authentication information.
28-
*
2928
* @author Ludovic Bertin
30-
*
3129
*/
3230
public class AuthenticationInfo {
3331

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

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,14 @@
3434
import javax.activation.MimetypesFileTypeMap;
3535

3636
import com.silverpeas.openoffice.util.MsOfficeType;
37+
import com.silverpeas.openoffice.util.OsEnum;
3738
import com.silverpeas.openoffice.util.PasswordManager;
3839
import com.silverpeas.openoffice.util.UrlExtractor;
3940
import com.silverpeas.openoffice.windows.MsOfficePathFinder;
41+
import javax.swing.UIManager;
42+
import javax.swing.UnsupportedLookAndFeelException;
4043

4144
/**
42-
*
4345
* @author Emmanuel Hugonnet
4446
*/
4547
public class Launcher {
@@ -49,8 +51,7 @@ public class Launcher {
4951
static Logger logger = Logger.getLogger(Launcher.class.getName());
5052

5153
/**
52-
* @param args
53-
* the command line arguments
54+
* @param args the command line arguments
5455
*/
5556
public static void main(String[] args) throws OfficeNotFoundException {
5657
logger.log(Level.INFO,
@@ -60,7 +61,7 @@ public static void main(String[] args) throws OfficeNotFoundException {
6061
String url = UrlExtractor.extractUrl(args[0]);
6162
logger.log(Level.INFO, MessageUtil.getMessage("info.url.decoded") + url);
6263
if (args[1] != null && !"".equals(args[1].trim())) {
63-
logger.log(Level.INFO,MessageUtil.getMessage("info.default.path")
64+
logger.log(Level.INFO, MessageUtil.getMessage("info.default.path")
6465
+ ' ' + UrlExtractor.decodePath(args[1]));
6566
MsOfficePathFinder.basePath = UrlExtractor.decodePath(args[1]);
6667
}
@@ -69,8 +70,9 @@ public static void main(String[] args) throws OfficeNotFoundException {
6970
authInfo = PasswordManager.extractAuthenticationInfo(args[2], args[3]);
7071
}
7172
MsOfficeType contentType = getContentType(UrlExtractor.decodeUrl(args[0]));
72-
logger.log(Level.FINE, MessageUtil.getMessage("info.document.type") +
73-
contentType);
73+
logger.log(Level.FINE, MessageUtil.getMessage("info.document.type")
74+
+ contentType);
75+
defineLookAndFeel();
7476
System.exit(OfficeLauncher.launch(contentType, url, authInfo));
7577
} catch (IOException ex) {
7678
logger.log(Level.SEVERE, MessageUtil.getMessage("error.message.general"),
@@ -89,6 +91,24 @@ public static void main(String[] args) throws OfficeNotFoundException {
8991
}
9092
}
9193

94+
protected static void defineLookAndFeel() {
95+
try {
96+
try {
97+
if (OsEnum.getOS() == OsEnum.WINDOWS_VISTA || OsEnum.getOS() == OsEnum.WINDOWS_XP) {
98+
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
99+
}
100+
} catch (ClassNotFoundException ex) {
101+
logger.log(Level.INFO, null, ex);
102+
} catch (InstantiationException ex) {
103+
logger.log(Level.INFO, null, ex);
104+
} catch (IllegalAccessException ex) {
105+
logger.log(Level.INFO, null, ex);
106+
}
107+
} catch (UnsupportedLookAndFeelException ex) {
108+
logger.log(Level.INFO, "Unable to load native look and feel");
109+
}
110+
}
111+
92112
protected static MsOfficeType getContentType(String url)
93113
throws MalformedURLException {
94114
String fileName = new URL(url).getFile();
Lines changed: 52 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,52 @@
1-
/**
2-
* Copyright (C) 2000 - 2009 Silverpeas
3-
*
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.
8-
*
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 recieved a copy of the text describing
13-
* the FLOSS exception, and it is also available here:
14-
* "http://repository.silverpeas.com/legal/licensing"
15-
*
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.
20-
*
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-
* To change this template, choose Tools | Templates
26-
* and open the template in the editor.
27-
*/
28-
package com.silverpeas.openoffice;
29-
30-
/**
31-
*
32-
* @author Emmanuel Hugonnet
33-
*/
34-
public class MsOfficeNotFoundException extends Exception {
35-
36-
private static final long serialVersionUID = 10l;
37-
38-
public MsOfficeNotFoundException() {
39-
super();
40-
}
41-
42-
public MsOfficeNotFoundException(String message) {
43-
super(message);
44-
}
45-
46-
public MsOfficeNotFoundException(Throwable cause) {
47-
super(cause);
48-
}
49-
50-
public MsOfficeNotFoundException(String message, Throwable cause) {
51-
super(message, cause);
52-
}
53-
}
1+
/**
2+
* Copyright (C) 2000 - 2009 Silverpeas
3+
*
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.
8+
*
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 recieved a copy of the text describing
13+
* the FLOSS exception, and it is also available here:
14+
* "http://repository.silverpeas.com/legal/licensing"
15+
*
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.
20+
*
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+
* To change this template, choose Tools | Templates
26+
* and open the template in the editor.
27+
*/
28+
package com.silverpeas.openoffice;
29+
30+
/**
31+
* @author Emmanuel Hugonnet
32+
*/
33+
public class MsOfficeNotFoundException extends Exception {
34+
35+
private static final long serialVersionUID = 10l;
36+
37+
public MsOfficeNotFoundException() {
38+
super();
39+
}
40+
41+
public MsOfficeNotFoundException(String message) {
42+
super(message);
43+
}
44+
45+
public MsOfficeNotFoundException(Throwable cause) {
46+
super(cause);
47+
}
48+
49+
public MsOfficeNotFoundException(String message, Throwable cause) {
50+
super(message, cause);
51+
}
52+
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
package com.silverpeas.openoffice;
2929

3030
/**
31-
*
3231
* @author Emmanuel Hugonnet
3332
*/
3433
public interface OfficeFinder {
@@ -40,6 +39,6 @@ public interface OfficeFinder {
4039
public String findWordEditor() throws OfficeNotFoundException;
4140

4241
public String findOther() throws OfficeNotFoundException;
43-
42+
4443
public boolean isMicrosoftOffice2007();
4544
}

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

Lines changed: 17 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@
2424
package com.silverpeas.openoffice;
2525

2626
import com.silverpeas.openoffice.windows.FileWebDavAccessManager;
27+
import com.silverpeas.openoffice.util.MessageUtil;
28+
import com.silverpeas.openoffice.util.MessageDisplayer;
2729
import java.io.IOException;
28-
import java.net.URISyntaxException;
2930
import java.util.logging.Level;
3031
import java.util.logging.Logger;
3132

@@ -35,30 +36,22 @@
3536
import org.apache.commons.httpclient.HttpException;
3637

3738
/**
38-
*
3939
* @author Emmanuel Hugonnet
4040
*/
4141
public class OfficeLauncher {
4242

4343
static Logger logger = Logger.getLogger(OfficeLauncher.class.getName());
4444

4545
/*
46-
* If user is under Windows vista and use MS Office 2007.
47-
* Disconnected mode must be activated :
48-
*
49-
* 1) download file using webdav to local temp directory
50-
* 2) open it
51-
* 3) after close, send it back to silverpeas, still using webdav
52-
* 4) delete temp file locally
53-
*
46+
* If user is under Windows vista and use MS Office 2007. Disconnected mode must be activated : 1)
47+
* download file using webdav to local temp directory 2) open it 3) after close, send it back to
48+
* silverpeas, still using webdav 4) delete temp file locally
5449
*/
55-
public static int launch(MsOfficeType type, String url,
56-
AuthenticationInfo authInfo) throws IOException,
57-
InterruptedException, OfficeNotFoundException {
58-
OfficeFinder finder = FinderFactory.getFinder(type);
59-
boolean modeDisconnected = (OsEnum.getOS() ==
60-
OsEnum.WINDOWS_VISTA || OsEnum.getOS() ==
61-
OsEnum.MAC_OSX) && (finder.isMicrosoftOffice2007());
50+
public static int launch(MsOfficeType type, String url, AuthenticationInfo authInfo)
51+
throws IOException, InterruptedException, OfficeNotFoundException {
52+
OfficeFinder finder = FinderFactory.getFinder(type);
53+
boolean modeDisconnected = (OsEnum.getOS() == OsEnum.WINDOWS_VISTA ||
54+
OsEnum.getOS() == OsEnum.MAC_OSX) && (finder.isMicrosoftOffice2007());
6255
switch (type) {
6356
case EXCEL:
6457
return launch(finder.findSpreadsheet(), url, modeDisconnected, authInfo);
@@ -74,43 +67,38 @@ public static int launch(MsOfficeType type, String url,
7467

7568
/**
7669
* Launch document edition
77-
*
7870
* @param path path to editor
7971
* @param url document url
8072
* @param modeDisconnected disconnected mode (used under vista + MS Office 2007)
8173
* @param auth authentication info
82-
*
8374
* @return status
84-
*
8575
* @throws IOException
8676
* @throws InterruptedException
8777
*/
8878
public static int launch(String path, String url, boolean modeDisconnected,
89-
AuthenticationInfo auth)
90-
throws IOException, InterruptedException {
79+
AuthenticationInfo auth) throws IOException, InterruptedException {
9180
logger.log(Level.INFO, "The path: " + path);
9281
logger.log(Level.INFO, "The url: " + url);
9382
logger.log(Level.INFO, "The command line: " + path + ' ' + url);
9483
if (modeDisconnected) {
9584
try {
96-
FileWebDavAccessManager webdavAccessManager =
97-
new FileWebDavAccessManager(auth);
85+
FileWebDavAccessManager webdavAccessManager = new FileWebDavAccessManager(auth);
9886
url = url.substring(1, url.length() - 1);
9987
String tmpFilePath = webdavAccessManager.retrieveFile(url);
100-
Process process =
101-
Runtime.getRuntime().exec(path + ' ' + tmpFilePath);
88+
Process process = Runtime.getRuntime().exec(path + ' ' + tmpFilePath);
10289
process.waitFor();
10390
webdavAccessManager.pushFile(tmpFilePath, url);
91+
MessageDisplayer.displayMessage(MessageUtil.getMessage("info.ok"));
10492
return 0;
10593
} catch (HttpException ex) {
10694
logger.log(Level.SEVERE, null, ex);
10795
throw new IOException(ex);
108-
} catch (URISyntaxException ex) {
96+
} catch (IOException ex) {
10997
logger.log(Level.SEVERE, null, ex);
110-
throw new IOException(ex);
98+
throw ex;
11199
}
112100
} else {
113-
//Standard mode : just open it
101+
// Standard mode : just open it
114102
logger.log(Level.INFO, "The exact exec line: " + path + ' ' + url);
115103
Process process = Runtime.getRuntime().exec(path + ' ' + url);
116104
return process.waitFor();

0 commit comments

Comments
 (0)