Révision 3895
TXM/trunk/bundles/org.txm.core/src/java/org/txm/scripts/importer/StaxStackWriter.java (revision 3895) | ||
---|---|---|
213 | 213 |
events.add(new ArrayList(Arrays.asList(localName, new ArrayList()))); // must be done or else writeAttribute will insert the attribute in the previous element |
214 | 214 |
|
215 | 215 |
for (Object key : map.keySet()) { |
216 |
if (map.get(key) == null) { // avoid NPE
|
|
217 |
map.put(key, "");
|
|
216 |
if (map.get(key) != null) { // avoid NPE
|
|
217 |
writeAttribute(key.toString(), map.get(key).toString());
|
|
218 | 218 |
} |
219 |
|
|
220 |
writeAttribute(key.toString(), map.get(key).toString()); |
|
221 | 219 |
} |
222 | 220 |
writer.writeCharacters(text); |
223 | 221 |
writer.writeEndElement(); |
... | ... | |
237 | 235 |
writer.writeEmptyElement(localName); |
238 | 236 |
events.add(new ArrayList(Arrays.asList(localName, new ArrayList()))); // must be done or else writeAttribute will insert the attribute in the previous element |
239 | 237 |
for (Object key : map.keySet()) { |
240 |
if (map.get(key) == null) { // avoid NPE
|
|
241 |
map.put(key, "");
|
|
238 |
if (map.get(key) != null) { // avoid NPE
|
|
239 |
writeAttribute(key.toString(), map.get(key).toString());
|
|
242 | 240 |
} |
243 |
writeAttribute(key.toString(), map.get(key).toString()); |
|
244 | 241 |
} |
245 | 242 |
events.remove(events.size()-1); |
246 | 243 |
} |
... | ... | |
319 | 316 |
|
320 | 317 |
for (Object key : map.keySet()) { |
321 | 318 |
|
322 |
if (map.get(key) == null) { // avoid NPE
|
|
323 |
map.put(key, "");
|
|
319 |
if (map.get(key) != null) { // avoid NPE
|
|
320 |
writeAttribute(key.toString(), map.get(key).toString());
|
|
324 | 321 |
} |
325 |
|
|
326 |
writeAttribute(key.toString(), map.get(key).toString()); |
|
327 | 322 |
} |
328 | 323 |
} |
329 | 324 |
|
TXM/trunk/bundles/org.txm.core/src/java/org/txm/importer/ConvertDocument.java (revision 3895) | ||
---|---|---|
3 | 3 |
import java.util.Arrays; |
4 | 4 |
import java.util.List; |
5 | 5 |
|
6 |
import org.artofsolving.jodconverter.OfficeDocumentConverter;
|
|
7 |
import org.artofsolving.jodconverter.office.DefaultOfficeManagerConfiguration;
|
|
8 |
import org.artofsolving.jodconverter.office.OfficeException;
|
|
9 |
import org.artofsolving.jodconverter.office.OfficeManager;
|
|
6 |
import org.jodconverter.core.office.OfficeException;
|
|
7 |
import org.jodconverter.core.office.OfficeManager;
|
|
8 |
import org.jodconverter.local.JodConverter;
|
|
9 |
import org.jodconverter.local.office.LocalOfficeManager;
|
|
10 | 10 |
|
11 |
|
|
12 | 11 |
public class ConvertDocument { |
13 | 12 |
|
14 | 13 |
boolean DEBUG = false; |
15 | 14 |
List<String> supportedInput = Arrays.asList("odt", "doc", "docx", "html", "pdf"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ |
16 |
List<String> supportedOutput = Arrays.asList("odt", "doc", "html", "pdf"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
|
15 |
List<String> supportedOutput = Arrays.asList("odt", "doc", "pdf"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ |
|
17 | 16 |
OfficeManager officeManager = null; |
18 | 17 |
|
19 |
public ConvertDocument(String officeHome) { |
|
20 |
DefaultOfficeManagerConfiguration office = new DefaultOfficeManagerConfiguration(); |
|
21 |
office.setOfficeHome(officeHome); |
|
18 |
public ConvertDocument(String officeHome) throws OfficeException { |
|
22 | 19 |
//officeManager.setConnectionProtocol(OfficeConnectionProtocol.PIPE); |
23 | 20 |
//officeManager.setPipeNames("office1", "office2"); |
24 | 21 |
//officeManager.setTaskExecutionTimeout(30000L); |
25 |
officeManager = office.buildOfficeManager(); |
|
22 |
officeManager = LocalOfficeManager.builder().build(); |
|
23 |
|
|
26 | 24 |
try { |
27 | 25 |
officeManager.start(); |
28 | 26 |
} catch(Exception e) { |
... | ... | |
31 | 29 |
} |
32 | 30 |
} |
33 | 31 |
|
34 |
public ConvertDocument() { |
|
35 |
DefaultOfficeManagerConfiguration office = new DefaultOfficeManagerConfiguration(); |
|
36 |
//office.setOfficeHome("/usr/lib/openoffice"); |
|
37 |
//officeManager.setConnectionProtocol(OfficeConnectionProtocol.PIPE); |
|
38 |
//officeManager.setPipeNames("office1", "office2"); |
|
39 |
//officeManager.setTaskExecutionTimeout(30000L); |
|
40 |
officeManager = office.buildOfficeManager(); |
|
32 |
public ConvertDocument() throws OfficeException { |
|
33 |
|
|
34 |
officeManager = LocalOfficeManager.builder().build(); |
|
41 | 35 |
try { |
42 | 36 |
officeManager.start(); |
43 | 37 |
} catch(Exception e) { |
... | ... | |
48 | 42 |
|
49 | 43 |
public void setDebug(boolean b) { |
50 | 44 |
DEBUG = b; |
51 |
DefaultOfficeManagerConfiguration.DEBUG = DEBUG; |
|
52 | 45 |
} |
53 | 46 |
|
54 |
public void stop() { |
|
47 |
public void stop() throws OfficeException {
|
|
55 | 48 |
officeManager.stop(); |
56 | 49 |
} |
57 | 50 |
|
... | ... | |
95 | 88 |
} |
96 | 89 |
} |
97 | 90 |
|
98 |
public File autoFile(File document, File outfile, String ext) throws Exception { |
|
99 |
OfficeDocumentConverter converter = new OfficeDocumentConverter(officeManager); |
|
100 |
converter.convert(document, outfile, converter.getFormatRegistry().getFormatByExtension(ext)); |
|
91 |
public File autoFile(File document, File outdir, String ext) throws Exception { |
|
101 | 92 |
|
102 |
if (outfile.exists()) |
|
103 |
return outfile; |
|
104 |
else |
|
93 |
ConvertDocument converter = new ConvertDocument(); |
|
94 |
if ("doc".equals(ext.toLowerCase())) { |
|
95 |
return converter.toDOC(document, outdir); |
|
96 |
} else if ("odt".equals(ext.toLowerCase())) { |
|
97 |
return converter.toODT(document, outdir); |
|
98 |
} if ("pdf".equals(ext.toLowerCase())) { |
|
99 |
return converter.toPDF(document, outdir); |
|
100 |
} else { |
|
105 | 101 |
return null; |
102 |
} |
|
106 | 103 |
} |
107 | 104 |
|
108 | 105 |
/** |
109 | 106 |
* @param args |
107 |
* @throws OfficeException |
|
110 | 108 |
*/ |
111 |
public static void main(String[] args) { |
|
109 |
public static void main(String[] args) throws OfficeException {
|
|
112 | 110 |
//converter.convert(infile, outfile, new ) |
113 | 111 |
// String[] srcexts = { "doc" }; |
114 | 112 |
// String[] exts = { "odt" };//, "odt", "doc", "docx", "html", "pdf"}; // html pdf |
... | ... | |
136 | 134 |
|
137 | 135 |
File infile = new File("/home/mdecorde/TEMP/Corpus_Riverains_TXM/EP27_txm.doc"); //$NON-NLS-1$ |
138 | 136 |
File outdir = new File("/home/mdecorde/TEMP"); //$NON-NLS-1$ |
139 |
|
|
137 |
JodConverter.convert(infile).to(new File(outdir, "test.odt")); |
|
140 | 138 |
//System.out.println("result: "+ConvertDocument.toODT(infile, outdir)); |
141 | 139 |
ConvertDocument convert = new ConvertDocument(); |
142 | 140 |
try { |
TXM/trunk/bundles/org.txm.core/.classpath (revision 3895) | ||
---|---|---|
44 | 44 |
</accessrules> |
45 | 45 |
</classpathentry> |
46 | 46 |
<classpathentry kind="con" path="GROOVY_DSL_SUPPORT"/> |
47 |
<classpathentry kind="lib" path="lib/jodconverter-core-3.1-beta.jar"/> |
|
48 | 47 |
<classpathentry kind="output" path="bin"/> |
49 | 48 |
</classpath> |
TXM/trunk/bundles/org.txm.core/META-INF/MANIFEST.MF (revision 3895) | ||
---|---|---|
244 | 244 |
org.apache.tools.mail, |
245 | 245 |
org.apache.tools.tar, |
246 | 246 |
org.apache.tools.zip, |
247 |
org.artofsolving.jodconverter, |
|
248 |
org.artofsolving.jodconverter.cli, |
|
249 |
org.artofsolving.jodconverter.document, |
|
250 |
org.artofsolving.jodconverter.office, |
|
251 |
org.artofsolving.jodconverter.process, |
|
252 |
org.artofsolving.jodconverter.util, |
|
253 | 247 |
org.dom4j, |
254 | 248 |
org.dom4j.bean, |
255 | 249 |
org.dom4j.datatype, |
... | ... | |
431 | 425 |
org.txm.xml.xsl.tei.tools.ImageInfo, |
432 | 426 |
org.txm.xml.xsl.tei.txt, |
433 | 427 |
org.txm.xml.xsl.tei.xhtml2, |
434 |
org.txm.xml.xsl.tei.xsd, |
|
435 |
resources, |
|
436 |
resources.documents, |
|
437 |
src.main.assembly, |
|
438 |
target |
|
428 |
org.txm.xml.xsl.tei.xsd |
|
439 | 429 |
Bundle-SymbolicName: org.txm.core;singleton:=true |
440 | 430 |
Bundle-Version: 0.8.3.qualifier |
441 | 431 |
Bundle-Name: TXM Core Toolbox |
... | ... | |
468 | 458 |
lib/unoil-3.2.1.jar, |
469 | 459 |
lib/sqlite-jdbc-3.8.11.2.jar, |
470 | 460 |
lib/postgresql-9.4.1207.jre6.jar, |
471 |
lib/jodconverter-core-3.1-beta.jar, |
|
472 | 461 |
lib/jsoup-1.11.3.jar |
473 | 462 |
Require-Bundle: org.eclipse.core.runtime;bundle-version="3.10.0";visibility:=reexport, |
474 | 463 |
org.eclipse.osgi.util;bundle-version="3.2.0";visibility:=reexport, |
... | ... | |
482 | 471 |
org.txm.libs.office;bundle-version="0.0.0";visibility:=reexport, |
483 | 472 |
org.txm.libs.msoffice;bundle-version="0.0.0";visibility:=reexport, |
484 | 473 |
org.txm.libs.hsqldb;bundle-version="1.0.0";visibility:=reexport, |
485 |
org.txm.tokenizer.core;bundle-version="1.0.0";visibility:=reexport |
|
474 |
org.txm.tokenizer.core;bundle-version="1.0.0";visibility:=reexport, |
|
475 |
org.txm.libs.jodconverter;bundle-version="1.0.0" |
|
486 | 476 |
Bundle-ActivationPolicy: lazy |
487 | 477 |
Bundle-ManifestVersion: 2 |
488 | 478 |
Bundle-Activator: org.txm.core.Activator |
TXM/trunk/bundles/org.txm.rcp/src/main/java/org/txm/rcp/swt/dialog/UpdateCorpusDialog.java (revision 3895) | ||
---|---|---|
105 | 105 |
corpusList.setSelection(new StructuredSelection(corpusToUpdate)); |
106 | 106 |
} |
107 | 107 |
else if (corpora.size() > 0) { |
108 |
corpusList.getList().select(0);
|
|
108 |
corpusList.getList().deselectAll();
|
|
109 | 109 |
} |
110 | 110 |
} |
111 | 111 |
|
TXM/trunk/bundles/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/commands/SaveAnnotationsAndUpdateCorpus.java (revision 3895) | ||
---|---|---|
110 | 110 |
|
111 | 111 |
final MainCorpus fcorpus = corpus[0]; |
112 | 112 |
|
113 |
if (fcorpus == null) { |
|
114 |
Log.warning("No corpus selected. Aborting."); |
|
115 |
return null; |
|
116 |
} |
|
117 |
|
|
113 | 118 |
Log.info(NLS.bind(Messages.SaveP0Annotations, fcorpus.getName())); |
114 | 119 |
JobHandler job = SaveAnnotations.save(fcorpus); |
115 | 120 |
if (job == null) { |
... | ... | |
161 | 166 |
return fcorpus; |
162 | 167 |
} |
163 | 168 |
catch (Exception e) { |
164 |
// TODO Auto-generated catch block |
|
165 | 169 |
e.printStackTrace(); |
166 | 170 |
return null; |
167 | 171 |
} |
TXM/trunk/bundles/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/doc/docLoader.groovy (revision 3895) | ||
---|---|---|
117 | 117 |
println "-- CONVERTER - Converting source files" |
118 | 118 |
File xsldir = new File(Toolbox.getTxmHomePath(), "xsl") |
119 | 119 |
if (!DocumentToTei.processFiles(srcfiles, txmDir, xsldir)) { |
120 |
println "Abord import"
|
|
120 |
println "Abort import"
|
|
121 | 121 |
return; |
122 | 122 |
} |
123 |
println "" |
|
124 |
return; |
|
123 |
|
|
125 | 124 |
// move data folders and build css file |
126 | 125 |
if (MONITOR != null && MONITOR.isCanceled()) { return MONITOR.done(); } |
127 | 126 |
if (MONITOR != null) MONITOR.worked(20, "RETRIEVE STYLES") |
TXM/trunk/bundles/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xtz/XTZDefaultPagerStep.groovy (revision 3895) | ||
---|---|---|
384 | 384 |
} |
385 | 385 |
|
386 | 386 |
rend = getAttributeValue(parser, null, "rend") |
387 |
if (rend == "") rend = null |
|
387 | 388 |
type = getAttributeValue(parser, null, "type") |
389 |
if (type == "") type = null |
|
388 | 390 |
//if (rend == null) rend = localname; |
389 | 391 |
|
390 | 392 |
switch (localname) { |
TXM/trunk/bundles/org.txm.libs.jodconverter/.settings/org.eclipse.core.resources.prefs (revision 3895) | ||
---|---|---|
1 |
eclipse.preferences.version=1 |
|
2 |
encoding/<project>=UTF-8 |
TXM/trunk/bundles/org.txm.libs.jodconverter/.settings/org.eclipse.jdt.core.prefs (revision 3895) | ||
---|---|---|
1 |
eclipse.preferences.version=1 |
|
2 |
org.eclipse.jdt.core.compiler.codegen.targetPlatform=16 |
|
3 |
org.eclipse.jdt.core.compiler.compliance=16 |
|
4 |
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error |
|
5 |
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled |
|
6 |
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error |
|
7 |
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning |
|
8 |
org.eclipse.jdt.core.compiler.release=enabled |
|
9 |
org.eclipse.jdt.core.compiler.source=16 |
TXM/trunk/bundles/org.txm.libs.jodconverter/.project (revision 3895) | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<projectDescription> |
|
3 |
<name>org.txm.libs.jodconverter</name> |
|
4 |
<comment></comment> |
|
5 |
<projects> |
|
6 |
</projects> |
|
7 |
<buildSpec> |
|
8 |
<buildCommand> |
|
9 |
<name>org.eclipse.jdt.core.javabuilder</name> |
|
10 |
<arguments> |
|
11 |
</arguments> |
|
12 |
</buildCommand> |
|
13 |
<buildCommand> |
|
14 |
<name>org.eclipse.pde.ManifestBuilder</name> |
|
15 |
<arguments> |
|
16 |
</arguments> |
|
17 |
</buildCommand> |
|
18 |
<buildCommand> |
|
19 |
<name>org.eclipse.pde.SchemaBuilder</name> |
|
20 |
<arguments> |
|
21 |
</arguments> |
|
22 |
</buildCommand> |
|
23 |
</buildSpec> |
|
24 |
<natures> |
|
25 |
<nature>org.eclipse.pde.PluginNature</nature> |
|
26 |
<nature>org.eclipse.jdt.core.javanature</nature> |
|
27 |
</natures> |
|
28 |
</projectDescription> |
TXM/trunk/bundles/org.txm.libs.jodconverter/src/org/txm/libs/jodconverter/ConvertDocument.java (revision 3895) | ||
---|---|---|
1 |
package org.txm.libs.jodconverter; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
|
|
5 |
import org.jodconverter.core.office.OfficeException; |
|
6 |
import org.jodconverter.core.office.OfficeManager; |
|
7 |
import org.jodconverter.core.office.OfficeUtils; |
|
8 |
import org.jodconverter.local.JodConverter; |
|
9 |
import org.jodconverter.local.office.LocalOfficeManager; |
|
10 |
|
|
11 |
public class ConvertDocument { |
|
12 |
|
|
13 |
public static void test2(File inputFile, File outputFile) throws OfficeException { |
|
14 |
// Create an office manager using the default configuration. |
|
15 |
// The default port is 2002. Note that when an office manager |
|
16 |
// is installed, it will be the one used by default when |
|
17 |
// a converter is created. |
|
18 |
final LocalOfficeManager officeManager = LocalOfficeManager.install(); |
|
19 |
try { |
|
20 |
|
|
21 |
// Start an office process and connect to the started instance (on port 2002). |
|
22 |
officeManager.start(); |
|
23 |
|
|
24 |
// Convert |
|
25 |
JodConverter |
|
26 |
.convert(inputFile) |
|
27 |
.to(outputFile) |
|
28 |
.execute(); |
|
29 |
} finally { |
|
30 |
// Stop the office process |
|
31 |
OfficeUtils.stopQuietly(officeManager); |
|
32 |
} |
|
33 |
} |
|
34 |
|
|
35 |
public static void test1(File inputFile, File outputFile) throws OfficeException { |
|
36 |
|
|
37 |
OfficeManager officeManager = LocalOfficeManager.builder() |
|
38 |
.install() |
|
39 |
.officeHome("/opt/libreoffice7.5") |
|
40 |
.build(); |
|
41 |
try { |
|
42 |
// Start an office process and connect to the started instance (on port 2002). |
|
43 |
officeManager.start(); |
|
44 |
// Convert |
|
45 |
JodConverter |
|
46 |
.convert(inputFile) |
|
47 |
.to(outputFile) |
|
48 |
.execute(); |
|
49 |
} finally { |
|
50 |
// Stop the office process |
|
51 |
OfficeUtils.stopQuietly(officeManager); |
|
52 |
} |
|
53 |
} |
|
54 |
|
|
55 |
public static void main(String[] args) throws OfficeException { |
|
56 |
|
|
57 |
File inputFile = new File("/home/mdecorde/Documents/FICHE d'inscription à une formation ENS - DECORDE.doc"); |
|
58 |
File outputFile = new File("/home/mdecorde/Documents/FICHE d'inscription à une formation ENS - DECORDE.odt"); |
|
59 |
|
|
60 |
test2(inputFile, outputFile); |
|
61 |
} |
|
62 |
} |
TXM/trunk/bundles/org.txm.libs.jodconverter/build.properties (revision 3895) | ||
---|---|---|
1 |
source.. = src/ |
|
2 |
output.. = bin/ |
|
3 |
bin.includes = META-INF/,\ |
|
4 |
.,\ |
|
5 |
jodconverter-core-4.4.6.jar,\ |
|
6 |
jodconverter-local-4.4.6.jar,\ |
|
7 |
slf4j-api-2.0.7.jar,\ |
|
8 |
jurt-4.1.2.jar,\ |
|
9 |
unoil-4.1.2.jar,\ |
|
10 |
juh-4.1.2.jar,\ |
|
11 |
ridl-4.1.2.jar |
TXM/trunk/bundles/org.txm.libs.jodconverter/.classpath (revision 3895) | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<classpath> |
|
3 |
<classpathentry exported="true" kind="lib" path="juh-4.1.2.jar"/> |
|
4 |
<classpathentry exported="true" kind="lib" path="ridl-4.1.2.jar"/> |
|
5 |
<classpathentry exported="true" kind="lib" path="unoil-4.1.2.jar"/> |
|
6 |
<classpathentry exported="true" kind="lib" path="jurt-4.1.2.jar"/> |
|
7 |
<classpathentry exported="true" kind="lib" path="slf4j-api-2.0.7.jar"/> |
|
8 |
<classpathentry exported="true" kind="lib" path="jodconverter-core-4.4.6.jar"/> |
|
9 |
<classpathentry exported="true" kind="lib" path="jodconverter-local-4.4.6.jar"/> |
|
10 |
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-16"/> |
|
11 |
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> |
|
12 |
<classpathentry kind="src" path="src"/> |
|
13 |
<classpathentry kind="output" path="bin"/> |
|
14 |
</classpath> |
TXM/trunk/bundles/org.txm.libs.jodconverter/META-INF/MANIFEST.MF (revision 3895) | ||
---|---|---|
1 |
Manifest-Version: 1.0 |
|
2 |
Bundle-ManifestVersion: 2 |
|
3 |
Bundle-Name: org.txm.libs.jodconverter |
|
4 |
Bundle-SymbolicName: org.txm.libs.jodconverter |
|
5 |
Bundle-Version: 4.4.6.qualifier |
|
6 |
Export-Package: org.jodconverter.core, |
|
7 |
org.jodconverter.core.document, |
|
8 |
org.jodconverter.core.job, |
|
9 |
org.jodconverter.core.office, |
|
10 |
org.jodconverter.core.task, |
|
11 |
org.jodconverter.core.util, |
|
12 |
org.jodconverter.local, |
|
13 |
org.jodconverter.local.filter, |
|
14 |
org.jodconverter.local.filter.text, |
|
15 |
org.jodconverter.local.office, |
|
16 |
org.jodconverter.local.office.utils, |
|
17 |
org.jodconverter.local.process, |
|
18 |
org.jodconverter.local.task |
|
19 |
Require-Bundle: org.txm.libs.gson;bundle-version="2.8.6" |
|
20 |
Bundle-Vendor: JodConverter |
|
21 |
Automatic-Module-Name: org.txm.libs.jodconverter |
|
22 |
Bundle-ClassPath: jodconverter-core-4.4.6.jar, |
|
23 |
jodconverter-local-4.4.6.jar, |
|
24 |
slf4j-api-2.0.7.jar, |
|
25 |
jurt-4.1.2.jar, |
|
26 |
., |
|
27 |
unoil-4.1.2.jar, |
|
28 |
juh-4.1.2.jar, |
|
29 |
ridl-4.1.2.jar |
|
30 |
Bundle-RequiredExecutionEnvironment: JavaSE-16 |
Formats disponibles : Unified diff