Bonjour,

Je travaille sur un site web et je dois réaliser une partie dans laquelle on convertit un fichier PowerPoint en SWF

J'ai deja une classe qui permet de faire ça :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
package org.openoffice.ppt2flash.comp;
 
 
import java.io.File;
import java.net.MalformedURLException;
 
import com.sun.star.beans.PropertyValue;
import com.sun.star.comp.helper.Bootstrap;
import com.sun.star.frame.XComponentLoader;
import com.sun.star.frame.XStorable;
import com.sun.star.io.IOException;
import com.sun.star.lang.IllegalArgumentException;
import com.sun.star.lang.XMultiComponentFactory;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext;
import com.sun.star.uri.ExternalUriReferenceTranslator;
 
public class ppt2flash {
 
public static void main(String[] args) {
try {
new ppt2flash().convert("C:\\chapitre1.ppt");
} catch (Exception e) {
e.printStackTrace();
} finally {
System.exit(0);
}
}
 
private XComponentContext xContext;
private Object component;
private Object desktop;
 
/**
* Convertit un fichier en flash
* 
* @param filename
* @throws Exception
*/
public void convert(String filename) throws Exception {
 
startOpenOffice();
String unoUrl = loadDocument(filename);
generatePdf(unoUrl);
}
 
private void generatePdf(String unoUrl) throws IOException {
XStorable xStorable = (XStorable) UnoRuntime.queryInterface(
XStorable.class, component);
 
// Set properties for conversions
PropertyValue[] convertProperties = new PropertyValue[2];
 
convertProperties[0] = new PropertyValue();
convertProperties[0].Name = "Overwrite";
convertProperties[0].Value = new Boolean(true);
 
convertProperties[1] = new PropertyValue();
convertProperties[1].Name = "FilterName";
convertProperties[1].Value = "draw_flash_Export";
 
xStorable.storeToURL(unoUrl.substring(0, unoUrl.lastIndexOf('.')) + ".swf", convertProperties);
}
 
/**
* Chargement d'un fichier OpenOffice
* 
* @param filename
* @return
* @throws MalformedURLException
* @throws IOException
* @throws IllegalArgumentException
*/
private String loadDocument(String filename)
throws MalformedURLException, IOException, IllegalArgumentException {
XComponentLoader loader = (XComponentLoader) UnoRuntime.queryInterface(
XComponentLoader.class, desktop);
 
String unoUrl = formatUnoUrl(filename);
 
// Value=true => pas d'interface graphique
PropertyValue[] loadProperties = new PropertyValue[1];
loadProperties[0] = new PropertyValue();
loadProperties[0].Name = "Hidden";
loadProperties[0].Value = new Boolean(true);
 
component = loader.loadComponentFromURL(unoUrl, "_blank", 0,
loadProperties);
return unoUrl;
}
 
/**
* Démarrage d'OpenOffice
* 
* @return Instance d'OOo avec contexte
* @throws Exception
*/
private Object startOpenOffice() throws Exception {
xContext = Bootstrap.bootstrap();
XMultiComponentFactory xMCF = xContext.getServiceManager();
 
desktop = xMCF.createInstanceWithContext(
"com.sun.star.frame.Desktop", xContext);
return desktop;
}
 
/**
* Formatte un chemin traditionnel en chemin compatible UNO 
* 
* @param filename Chemin du fichier, au format traditionnel
* @return Chemin du fichier, au format UNO
* @throws MalformedURLException 
*/
private String formatUnoUrl(String filename)
throws MalformedURLException {
String unoUrl = ExternalUriReferenceTranslator.create(xContext)
.translateToInternal(new File(filename).toURL().toExternalForm());
return unoUrl;
}
 
}
Le problème c'est que j'essaye de l'utiliser dans une servlet mai jarrive pas, voila la servlet que j'ai fait :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
 
 
import java.io.IOException;
import java.io.PrintWriter;
import java.net.MalformedURLException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
 
import com.sun.star.beans.PropertyValue;
import com.sun.star.comp.helper.Bootstrap;
import com.sun.star.frame.XComponentLoader;
import com.sun.star.frame.XStorable;
import com.sun.star.*;
import com.sun.star.lang.IllegalArgumentException;
import com.sun.star.lang.XMultiComponentFactory;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext;
import com.sun.star.uri.ExternalUriReferenceTranslator;
 
 
public class ServFlash extends HttpServlet {
 
public ServFlash() {
super();
}
 
public void destroy() {
super.destroy(); 
}
 
 
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
try {
new ppt2flash().convert("C:\\chapitre1.ppt");
} catch (Exception e) {
e.printStackTrace(); }
}
 
 
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
 
doGet(request,response);
}
public void init() throws ServletException {
// Put your code here
}
 
}
lorsqe j'execute la servlet j'ai le message d'erreur suivant :

com.sun.star.comp.helper.BootstrapException: no office executable found!
at com.sun.star.comp.helper.Bootstrap.bootstrap(Bootstrap.java:253)

est ce que la façon que j'ai utilisé n'est pa correcte, veuillez m'aider svp , commenet utiliser une classe qui fonctionne sous forme d'une servlet ?!!