Révision 3788
TXM/trunk/bundles/org.txm.libs.office/.classpath (revision 3788) | ||
---|---|---|
1 | 1 |
<?xml version="1.0" encoding="UTF-8"?> |
2 | 2 |
<classpath> |
3 |
<classpathentry exported="true" kind="lib" path="lib/simple-odf-0.9.0.jar"/> |
|
4 | 3 |
<classpathentry exported="true" kind="lib" path="lib/odfdom-java-0.10.0-jar-with-dependencies.jar"/> |
5 | 4 |
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> |
6 | 5 |
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> |
TXM/trunk/bundles/org.txm.libs.office/META-INF/MANIFEST.MF (revision 3788) | ||
---|---|---|
1 | 1 |
Manifest-Version: 1.0 |
2 | 2 |
Automatic-Module-Name: org.txm.libs.office |
3 | 3 |
Bundle-SymbolicName: org.txm.libs.office |
4 |
Export-Package: org.odftoolkit.odfdom, |
|
4 |
Export-Package: |
|
5 |
org.odftoolkit.odfdom, |
|
5 | 6 |
org.odftoolkit.odfdom.changes, |
6 | 7 |
org.odftoolkit.odfdom.doc, |
7 | 8 |
org.odftoolkit.odfdom.doc.presentation, |
... | ... | |
65 | 66 |
org.odftoolkit.odfdom.pkg.manifest, |
66 | 67 |
org.odftoolkit.odfdom.pkg.rdfa, |
67 | 68 |
org.odftoolkit.odfdom.type, |
68 |
org.odftoolkit.simple, |
|
69 |
org.odftoolkit.simple.chart, |
|
70 |
org.odftoolkit.simple.common, |
|
71 |
org.odftoolkit.simple.common.field, |
|
72 |
org.odftoolkit.simple.common.navigation, |
|
73 |
org.odftoolkit.simple.draw, |
|
74 |
org.odftoolkit.simple.form, |
|
75 |
org.odftoolkit.simple.meta, |
|
76 |
org.odftoolkit.simple.presentation, |
|
77 |
org.odftoolkit.simple.style, |
|
78 |
org.odftoolkit.simple.table, |
|
79 |
org.odftoolkit.simple.text, |
|
80 |
org.odftoolkit.simple.text.list, |
|
81 | 69 |
org.txm.libs.office |
82 | 70 |
Bundle-Name: org.txm.libs.office |
83 | 71 |
Bundle-Version: 0.8.2.qualifier |
84 | 72 |
Bundle-ClassPath: ., |
85 |
lib/odfdom-java-0.10.0-jar-with-dependencies.jar, |
|
86 |
lib/simple-odf-0.9.0.jar |
|
73 |
lib/odfdom-java-0.10.0-jar-with-dependencies.jar |
|
87 | 74 |
Require-Bundle: org.apache.xerces;bundle-version="2.9.0" |
88 | 75 |
Bundle-ManifestVersion: 2 |
89 | 76 |
Bundle-RequiredExecutionEnvironment: JavaSE-16 |
TXM/trunk/bundles/org.txm.libs.office/src/org/txm/libs/office/WriteODS.java (revision 3788) | ||
---|---|---|
3 | 3 |
import java.io.File; |
4 | 4 |
import java.util.ArrayList; |
5 | 5 |
|
6 |
import org.odftoolkit.simple.SpreadsheetDocument; |
|
7 |
import org.odftoolkit.simple.table.Cell; |
|
8 |
import org.odftoolkit.simple.table.Row; |
|
9 |
import org.odftoolkit.simple.table.Table; |
|
6 |
import org.odftoolkit.odfdom.changes.Table; |
|
7 |
import org.odftoolkit.odfdom.doc.OdfSpreadsheetDocument; |
|
8 |
import org.odftoolkit.odfdom.doc.table.OdfTable; |
|
9 |
import org.odftoolkit.odfdom.doc.table.OdfTableCell; |
|
10 |
import org.odftoolkit.odfdom.doc.table.OdfTableRow; |
|
10 | 11 |
|
12 |
//import org.odftoolkit.simple.SpreadsheetDocument; |
|
13 |
//import org.odftoolkit.simple.table.Cell; |
|
14 |
//import org.odftoolkit.simple.table.Row; |
|
15 |
//import org.odftoolkit.simple.table.Table; |
|
16 |
|
|
11 | 17 |
public class WriteODS { |
12 | 18 |
|
13 | 19 |
static { // set Log level to WARNING |
14 | 20 |
try { |
15 |
SpreadsheetDocument.newSpreadsheetDocument().close(); |
|
21 |
OdfSpreadsheetDocument.newSpreadsheetDocument().close();
|
|
16 | 22 |
ReadODS.static_set_log_level(); |
17 | 23 |
} |
18 | 24 |
catch (Exception e) { |
... | ... | |
21 | 27 |
} |
22 | 28 |
} |
23 | 29 |
|
24 |
SpreadsheetDocument spreadsheet; |
|
30 |
OdfSpreadsheetDocument spreadsheet;
|
|
25 | 31 |
|
26 |
Table table; |
|
32 |
OdfTable table;
|
|
27 | 33 |
|
28 | 34 |
File newODSFile; |
29 | 35 |
|
30 | 36 |
public WriteODS(File newODSFile) throws Exception { |
31 | 37 |
this.newODSFile = newODSFile; |
32 |
this.spreadsheet = SpreadsheetDocument.newSpreadsheetDocument(); |
|
38 |
this.spreadsheet = OdfSpreadsheetDocument.newSpreadsheetDocument();
|
|
33 | 39 |
this.table = spreadsheet.getTableList().get(0); |
34 | 40 |
} |
35 | 41 |
|
36 | 42 |
public void newTable(String name) { |
37 | 43 |
if (name != null && name.length() > 0) { |
38 |
this.table = spreadsheet.appendSheet(name); |
|
44 |
this.table = OdfTable.newTable(spreadsheet); |
|
45 |
table.setTableName(name); |
|
39 | 46 |
} |
40 | 47 |
else { |
41 |
this.table = spreadsheet.addTable();
|
|
48 |
this.table = OdfTable.newTable(spreadsheet);
|
|
42 | 49 |
} |
43 | 50 |
} |
44 | 51 |
|
... | ... | |
58 | 65 |
} |
59 | 66 |
} |
60 | 67 |
|
61 |
protected void writeLine(Object[] line, Row row) { |
|
68 |
protected void writeLine(Object[] line, OdfTableRow row) {
|
|
62 | 69 |
if (table == null) throw new IllegalStateException("no table set with 'newTable(...)'"); |
63 | 70 |
for (int iCol = 0; iCol < line.length; iCol++) { |
64 |
Cell cell = row.getCellByIndex(iCol); |
|
71 |
OdfTableCell cell = row.getCellByIndex(iCol);
|
|
65 | 72 |
if (cell != null) { |
66 | 73 |
writeCell(cell, line[iCol]); |
67 | 74 |
} |
... | ... | |
71 | 78 |
} |
72 | 79 |
} |
73 | 80 |
|
74 |
public Row writeLine(Object[] line, int iRow) { |
|
81 |
public OdfTableRow writeLine(Object[] line, int iRow) {
|
|
75 | 82 |
if (table == null) throw new IllegalStateException("no table set with 'newtTable(...)'"); |
76 |
Row row = table.getRowByIndex(iRow); |
|
83 |
OdfTableRow row = table.getRowByIndex(iRow);
|
|
77 | 84 |
if (row != null) { |
78 | 85 |
writeLine(line, row); |
79 | 86 |
} |
... | ... | |
83 | 90 |
return row; |
84 | 91 |
} |
85 | 92 |
|
86 |
public Row writeLine(ArrayList<?> line, int iRow) { |
|
93 |
public OdfTableRow writeLine(ArrayList<?> line, int iRow) {
|
|
87 | 94 |
|
88 | 95 |
if (table == null) throw new IllegalStateException("no table set with 'newtTable(...)'"); |
89 | 96 |
|
90 |
Row row = table.getRowByIndex(iRow); |
|
97 |
OdfTableRow row = table.getRowByIndex(iRow);
|
|
91 | 98 |
if (row != null) { |
92 | 99 |
writeLine(line.toArray(), row); |
93 | 100 |
} |
... | ... | |
97 | 104 |
return row; |
98 | 105 |
} |
99 | 106 |
|
100 |
public Row writeLine(Object[] line) { |
|
107 |
public OdfTableRow writeLine(Object[] line) {
|
|
101 | 108 |
|
102 | 109 |
if (table == null) throw new IllegalStateException("no table set with 'newTable(...)'"); |
103 | 110 |
|
104 |
Row row = table.appendRow(); |
|
111 |
OdfTableRow row = table.appendRow();
|
|
105 | 112 |
writeLine(line, row); |
106 | 113 |
return row; |
107 | 114 |
} |
108 | 115 |
|
109 |
public Row writeLine(ArrayList<?> line) { |
|
116 |
public OdfTableRow writeLine(ArrayList<?> line) {
|
|
110 | 117 |
|
111 | 118 |
if (table == null) throw new IllegalStateException("no table set with 'newTable(...)'"); |
112 | 119 |
|
113 |
Row row = table.appendRow(); |
|
120 |
OdfTableRow row = table.appendRow();
|
|
114 | 121 |
writeLine(line.toArray(), row); |
115 | 122 |
return row; |
116 | 123 |
} |
... | ... | |
123 | 130 |
|
124 | 131 |
if (data.length == 0) throw new IllegalArgumentException("no data to write in " + newODFFile); |
125 | 132 |
|
126 |
SpreadsheetDocument spreadsheet = SpreadsheetDocument.newSpreadsheetDocument();
|
|
133 |
OdfSpreadsheetDocument spreadsheet = OdfSpreadsheetDocument.newSpreadsheetDocument();
|
|
127 | 134 |
Object[] firstLine = data[0]; |
128 |
Table table = spreadsheet.addTable();
|
|
135 |
OdfTable table = OdfTable.newTable(spreadsheet);
|
|
129 | 136 |
table.appendRows(data.length); |
130 | 137 |
table.appendColumns(firstLine.length); |
131 | 138 |
|
132 | 139 |
for (int iRow = 0; iRow < data.length; iRow++) { |
133 |
Row row = table.appendRow(); |
|
140 |
OdfTableRow row = table.appendRow();
|
|
134 | 141 |
Object[] line = data[iRow]; |
135 | 142 |
for (int iCol = 0; iCol < line.length; iCol++) { |
136 |
Cell cell = row.getCellByIndex(iCol); |
|
143 |
OdfTableCell cell = row.getCellByIndex(iCol);
|
|
137 | 144 |
writeCell(cell, line[iCol]); |
138 | 145 |
} |
139 | 146 |
} |
... | ... | |
145 | 152 |
|
146 | 153 |
if (data.size() == 0) throw new IllegalArgumentException("no data to write in " + newODFFile); |
147 | 154 |
|
148 |
SpreadsheetDocument spreadsheet = SpreadsheetDocument.newSpreadsheetDocument();
|
|
155 |
OdfSpreadsheetDocument spreadsheet = OdfSpreadsheetDocument.newSpreadsheetDocument();
|
|
149 | 156 |
ArrayList<?> firstLine = data.get(0); |
150 |
Table table = spreadsheet.addTable();
|
|
157 |
OdfTable table = OdfTable.newTable(spreadsheet);
|
|
151 | 158 |
table.appendRows(data.size()); |
152 | 159 |
table.appendColumns(firstLine.size()); |
153 | 160 |
|
154 | 161 |
for (int iRow = 0; iRow < data.size(); iRow++) { |
155 |
Row row = table.appendRow(); |
|
162 |
OdfTableRow row = table.appendRow();
|
|
156 | 163 |
ArrayList<?> line = data.get(iRow); |
157 | 164 |
for (int iCol = 0; iCol < line.size(); iCol++) { |
158 |
Cell cell = row.getCellByIndex(iCol); |
|
165 |
OdfTableCell cell = row.getCellByIndex(iCol);
|
|
159 | 166 |
writeCell(cell, line.get(iCol)); |
160 | 167 |
} |
161 | 168 |
} |
... | ... | |
163 | 170 |
spreadsheet.save(newODFFile); |
164 | 171 |
} |
165 | 172 |
|
166 |
private static void writeCell(Cell cell, Object object) { |
|
173 |
private static void writeCell(OdfTableCell cell, Object object) {
|
|
167 | 174 |
|
168 | 175 |
if (object == null) cell.removeContent(); |
169 | 176 |
|
TXM/trunk/bundles/org.txm.libs.office/src/org/txm/libs/office/ReadODS.java (revision 3788) | ||
---|---|---|
8 | 8 |
import java.util.logging.Level; |
9 | 9 |
import java.util.logging.Logger; |
10 | 10 |
|
11 |
import org.odftoolkit.odfdom.doc.OdfSpreadsheetDocument; |
|
12 |
import org.odftoolkit.odfdom.doc.table.OdfTable; |
|
13 |
import org.odftoolkit.odfdom.doc.table.OdfTableCell; |
|
14 |
import org.odftoolkit.odfdom.doc.table.OdfTableRow; |
|
11 | 15 |
import org.odftoolkit.odfdom.dom.element.table.TableTableRowElement; |
12 | 16 |
import org.odftoolkit.odfdom.pkg.OdfXMLFactory; |
13 |
import org.odftoolkit.simple.SpreadsheetDocument; |
|
14 |
import org.odftoolkit.simple.table.Cell; |
|
15 |
import org.odftoolkit.simple.table.Row; |
|
16 |
import org.odftoolkit.simple.table.Table; |
|
17 | 17 |
import org.w3c.dom.NodeList; |
18 | 18 |
|
19 | 19 |
public class ReadODS { |
20 | 20 |
|
21 | 21 |
static { // set Log level to WARNING |
22 | 22 |
try { |
23 |
SpreadsheetDocument.newSpreadsheetDocument().close(); |
|
23 |
OdfSpreadsheetDocument.newSpreadsheetDocument().close();
|
|
24 | 24 |
static_set_log_level(); |
25 | 25 |
} |
26 | 26 |
catch (Exception e) { |
... | ... | |
29 | 29 |
} |
30 | 30 |
} |
31 | 31 |
|
32 |
SpreadsheetDocument spreadsheet = null; |
|
32 |
OdfSpreadsheetDocument spreadsheet = null;
|
|
33 | 33 |
|
34 |
Table table = null; |
|
34 |
OdfTable table = null;
|
|
35 | 35 |
|
36 | 36 |
String[] headers; |
37 | 37 |
|
... | ... | |
44 | 44 |
public ReadODS(File tableFile, String sheetname) throws Exception { |
45 | 45 |
|
46 | 46 |
static_set_log_level(); |
47 |
spreadsheet = SpreadsheetDocument.loadDocument(tableFile); |
|
47 |
spreadsheet = OdfSpreadsheetDocument.loadDocument(tableFile);
|
|
48 | 48 |
|
49 | 49 |
// the first access to the document causes a very long process |
50 |
int sheetCount = spreadsheet.getSheetCount();
|
|
50 |
int sheetCount = spreadsheet.getTableList(false).size();
|
|
51 | 51 |
if (sheetCount < 1) { |
52 | 52 |
System.out.println("** ReadODS: no sheet found in file. Aborting."); |
53 | 53 |
return; |
54 | 54 |
} |
55 | 55 |
|
56 | 56 |
if (sheetname != null) { |
57 |
table = spreadsheet.getSheetByName(sheetname);
|
|
57 |
table = spreadsheet.getTableByName(sheetname);
|
|
58 | 58 |
} |
59 | 59 |
if (table == null) { |
60 |
table = spreadsheet.getSheetByIndex(0);
|
|
60 |
table = spreadsheet.getTableList(false).get(0);
|
|
61 | 61 |
} |
62 | 62 |
nRows = table.getRowCount(); |
63 | 63 |
nCols = table.getColumnCount(); |
... | ... | |
88 | 88 |
|
89 | 89 |
public boolean readHeaders() { |
90 | 90 |
|
91 |
Row row = table.getRowByIndex(0); |
|
91 |
OdfTableRow row = table.getRowByIndex(0);
|
|
92 | 92 |
if (row == null) return false; |
93 | 93 |
|
94 | 94 |
int ncolumns = row.getCellCount(); |
... | ... | |
126 | 126 |
|
127 | 127 |
protected void _getRecord() { |
128 | 128 |
record = new HashMap<>(); |
129 |
Row row = table.getRowByIndex(iRow); |
|
129 |
OdfTableRow row = table.getRowByIndex(iRow);
|
|
130 | 130 |
|
131 | 131 |
for (int colIndex = 0; colIndex < headers.length; colIndex++) { |
132 | 132 |
String col = headers[colIndex]; |
133 |
Cell cell = row.getCellByIndex(colIndex); |
|
133 |
OdfTableCell cell = row.getCellByIndex(colIndex);
|
|
134 | 134 |
if (cell != null) { |
135 | 135 |
String value = cell.getStringValue(); |
136 | 136 |
if (value == null) { |
... | ... | |
160 | 160 |
|
161 | 161 |
static_set_log_level(); |
162 | 162 |
|
163 |
SpreadsheetDocument spreadsheet = SpreadsheetDocument.loadDocument(inputFile);
|
|
163 |
OdfSpreadsheetDocument spreadsheet = OdfSpreadsheetDocument.loadDocument(inputFile);
|
|
164 | 164 |
|
165 | 165 |
// the first access to the document causes a very long process |
166 |
int sheetCount = spreadsheet.getSheetCount();
|
|
166 |
int sheetCount = spreadsheet.getTableList(false).size();
|
|
167 | 167 |
if (sheetCount < 1) { |
168 | 168 |
System.out.println("** ReadODS: no sheet found in file. Aborting."); |
169 | 169 |
return null; |
170 | 170 |
} |
171 | 171 |
|
172 |
Table table = null; |
|
172 |
OdfTable table = null;
|
|
173 | 173 |
if (sheetname != null) { |
174 |
table = spreadsheet.getSheetByName(sheetname);
|
|
174 |
table = spreadsheet.getTableByName(sheetname);
|
|
175 | 175 |
} |
176 | 176 |
if (table == null) { |
177 |
table = spreadsheet.getSheetByIndex(0);
|
|
177 |
table = spreadsheet.getTableList(false).get(0);
|
|
178 | 178 |
} |
179 | 179 |
|
180 | 180 |
ArrayList<HashMap<String, String>> data = new ArrayList<>(); |
181 | 181 |
|
182 |
List<Row> rows = table.getRowList(); |
|
182 |
List<OdfTableRow> rows = table.getRowList();
|
|
183 | 183 |
ArrayList<String> cols = new ArrayList<>(); |
184 | 184 |
int ncolumns = rows.get(0).getCellCount(); |
185 | 185 |
for (int i = 0; i < ncolumns; i++) { |
... | ... | |
188 | 188 |
|
189 | 189 |
// int rowCount = table.getRowCount(); |
190 | 190 |
for (int iRow = 1; iRow < rows.size(); iRow++) { |
191 |
Row row = rows.get(iRow); |
|
191 |
OdfTableRow row = rows.get(iRow);
|
|
192 | 192 |
HashMap<String, String> dataline = new HashMap<>(); |
193 | 193 |
data.add(dataline); |
194 | 194 |
|
... | ... | |
217 | 217 |
|
218 | 218 |
static_set_log_level(); |
219 | 219 |
|
220 |
SpreadsheetDocument spreadsheet = SpreadsheetDocument.loadDocument(inputFile);
|
|
220 |
OdfSpreadsheetDocument spreadsheet = OdfSpreadsheetDocument.loadDocument(inputFile);
|
|
221 | 221 |
|
222 | 222 |
// the first access to the document causes a very long process |
223 |
int sheetCount = spreadsheet.getSheetCount();
|
|
223 |
int sheetCount = spreadsheet.getTableList(false).size();
|
|
224 | 224 |
if (sheetCount < 1) { |
225 | 225 |
System.out.println("** ReadODS: no sheet found in file. Aborting."); |
226 | 226 |
return null; |
227 | 227 |
} |
228 | 228 |
|
229 |
Table table = null; |
|
229 |
OdfTable table = null;
|
|
230 | 230 |
if (sheetname != null) { |
231 |
table = spreadsheet.getSheetByName(sheetname);
|
|
231 |
table = spreadsheet.getTableByName(sheetname);
|
|
232 | 232 |
} |
233 | 233 |
if (table == null) { |
234 |
table = spreadsheet.getSheetByIndex(0);
|
|
234 |
table = spreadsheet.getTableList(false).get(0);
|
|
235 | 235 |
} |
236 | 236 |
|
237 | 237 |
ArrayList<ArrayList<String>> data = new ArrayList<>(); |
... | ... | |
240 | 240 |
|
241 | 241 |
// findout maximum line length |
242 | 242 |
int sMax = 0; |
243 |
for (Row row : table.getRowList()) { |
|
243 |
for (OdfTableRow row : table.getRowList()) {
|
|
244 | 244 |
TableTableRowElement elem = row.getOdfElement(); |
245 | 245 |
NodeList children = elem.getChildNodes(); |
246 | 246 |
int s = children.getLength(); // FIXME row.getCellCount() takes too much time |
247 | 247 |
if (sMax < s) sMax = s; |
248 | 248 |
} |
249 |
for (Row row : table.getRowList()) { |
|
249 |
for (OdfTableRow row : table.getRowList()) {
|
|
250 | 250 |
ArrayList<String> dataline = new ArrayList<>(); |
251 | 251 |
data.add(dataline); |
252 | 252 |
// Row row = table.getRowByIndex(it); |
TXM/trunk/bundles/org.txm.libs.office/build.properties (revision 3788) | ||
---|---|---|
2 | 2 |
bin.includes = META-INF/,\ |
3 | 3 |
OSGI-INF/,\ |
4 | 4 |
.,\ |
5 |
lib/odfdom-java-0.10.0-jar-with-dependencies.jar,\ |
|
6 |
lib/simple-odf-0.9.0.jar |
|
5 |
lib/odfdom-java-0.10.0-jar-with-dependencies.jar |
|
7 | 6 |
#qualifier=svn |
8 | 7 |
source.. = src/ |
TXM/trunk/bundles/org.txm.groovy.core/src/groovy/org/txm/macro/edition/RebuildTRSEditionMacro.groovy (revision 3788) | ||
---|---|---|
18 | 18 |
import org.txm.importer.* |
19 | 19 |
import org.txm.Toolbox |
20 | 20 |
import java.io.* |
21 |
|
|
21 |
import groovy.xml.XmlSlurper |
|
22 | 22 |
import org.w3c.dom.Document; |
23 | 23 |
import org.xml.sax.SAXException; |
24 | 24 |
import org.txm.rcpapplication.commands.* |
TXM/trunk/bundles/org.txm.groovy.core/src/groovy/org/txm/macro/commands/StructuresIndexMacro.groovy (revision 3788) | ||
---|---|---|
77 | 77 |
// Déclarations |
78 | 78 |
|
79 | 79 |
import org.kohsuke.args4j.* |
80 |
|
|
81 | 80 |
import groovy.transform.Field |
82 | 81 |
|
83 | 82 |
import org.txm.rcp.swt.widget.parameters.* |
... | ... | |
121 | 120 |
def wordProperty |
122 | 121 |
@Field @Option(name="displayIndex", usage="display a hierarchical index", widget="Boolean", required=true, def="true") |
123 | 122 |
def displayIndex |
124 |
@Field @Option(name="Vmax", usage="size of index", widget="Integer", required=false, def="20") |
|
125 |
def Vmax |
|
123 |
//@Field @Option(name="Vmax", usage="size of index", widget="Integer", required=false, def="20")
|
|
124 |
// def Vmax
|
|
126 | 125 |
// END OF PARAMETERS |
127 | 126 |
|
128 | 127 |
// Open the parameters input dialog box |
... | ... | |
162 | 161 |
} |
163 | 162 |
|
164 | 163 |
// function to print the statistics of an index of a query |
165 |
def print_freq = { CQPCorpus c, q, p -> |
|
164 |
def print_freq = { CQPCorpus c, q, p, max ->
|
|
166 | 165 |
|
167 | 166 |
// appel du moteur |
168 | 167 |
//println "QUERY=$q" |
... | ... | |
207 | 206 |
print sprintf("%d\t%d\t%d\t%d", tC, v, fmin, fmax) |
208 | 207 |
// afficher les valeurs des occurrences de la propriété du résultat |
209 | 208 |
if (displayIndex) { |
210 |
heads = index.sort { -it.value }.take(Vmax).keySet()
|
|
209 |
heads = index.sort { -it.value }.take(max).keySet() |
|
211 | 210 |
println "\t"+heads.collect { CQI.id2Str(p.getQualifiedName(), it)[0] } |
212 | 211 |
} else { |
213 | 212 |
println "" |
... | ... | |
456 | 455 |
def struct_name = "${mainCorpusName}.${it.name}" |
457 | 456 |
print sprintf("%s\t%d\t%d\t%d\t", it.name, it.start, it.end, it.end-it.start) |
458 | 457 |
} |
459 |
print_freq(corpus, sprintf("a:%s :: a>=%d & a<=%d", query, it.start, it.end), wordProperty) |
|
458 |
print_freq(corpus, sprintf("a:%s :: a>=%d & a<=%d", query, it.start, it.end), wordProperty, 10000)
|
|
460 | 459 |
} |
461 | 460 |
|
462 | 461 |
textDivPropVals.push(divPropVals) |
... | ... | |
499 | 498 |
try { |
500 | 499 |
r.eval(script+"ggsave(file=\"${PNGFilePath}\", plot=p)") |
501 | 500 |
r.eval(script+"ggsave(file=\"${SVGFilePath}\", plot=p)") |
502 |
|
|
501 |
|
|
503 | 502 |
//display the SVG results graphic |
504 | 503 |
monitor.syncExec(new Runnable() { |
505 | 504 |
@Override |
TXM/trunk/bundles/org.txm.groovy.core/src/groovy/org/txm/macro/corpus/TruncateTextsAtFirstWordsMacro.groovy (revision 3788) | ||
---|---|---|
32 | 32 |
Project project = mcorpus.getProject() |
33 | 33 |
File txmDir = new File(project.getProjectDirectory(), "txm/"+mcorpus.getName()) |
34 | 34 |
|
35 |
@Field @Option(name="nWordsPerText", usage="the number of words per text", widget="Integer", required=true, def="") |
|
35 |
@Field @Option(name="nWordsPerText", usage="the number of words per text", widget="Integer", required=true, def="5000")
|
|
36 | 36 |
File nWordsPerText |
37 | 37 |
|
38 | 38 |
|
TXM/trunk/bundles/org.txm.groovy.core/src/groovy/org/txm/macro/export/ExportCAInfosMacro.groovy (revision 3788) | ||
---|---|---|
19 | 19 |
|
20 | 20 |
// END OF PARAMETERS |
21 | 21 |
|
22 |
def scriptName = this.class.getSimpleName() |
|
23 |
|
|
22 | 24 |
if (!(corpusViewSelection instanceof CA)) { |
23 | 25 |
println "** $scriptName: please select a CA in the Corpus view." |
24 | 26 |
return 0 |
TXM/trunk/bundles/org.txm.groovy.core/src/groovy/org/txm/macro/cqp/StructIndexMacro.groovy (revision 3788) | ||
---|---|---|
27 | 27 |
// Open the parameters input dialog box |
28 | 28 |
if (!ParametersDialog.open(this)) return |
29 | 29 |
|
30 |
// END OF PARAMETERS |
|
30 |
// END OF PARAMETERS
|
|
31 | 31 |
|
32 |
utils = new CQPUtils() |
|
33 |
corpusEngine = CQPSearchEngine.getCqiClient() |
|
32 |
utils = new CQPUtils()
|
|
33 |
corpusEngine = CQPSearchEngine.getCqiClient()
|
|
34 | 34 |
|
35 |
// check for a corpus selection |
|
36 |
corpora = utils.getCorpora(this) |
|
35 |
// check for a corpus selection
|
|
36 |
corpora = utils.getCorpora(this)
|
|
37 | 37 |
|
38 |
if ((corpora == null) || corpora.size() > 1) { |
|
39 |
println "** $scriptName: please select a corpus in the Corpus view or provide a corpus name. Aborting." |
|
40 |
return false |
|
41 |
} |
|
38 |
if ((corpora == null) || corpora.size() > 1) {
|
|
39 |
println "** $scriptName: please select a corpus in the Corpus view or provide a corpus name. Aborting."
|
|
40 |
return false
|
|
41 |
}
|
|
42 | 42 |
|
43 | 43 |
if ((struct_props == null) || struct_props.size() == 0) { |
44 | 44 |
println "** $scriptName: please set the 'struct_props' parameter. Aborting." |
... | ... | |
50 | 50 |
globalVmax = Vmax |
51 | 51 |
|
52 | 52 |
(struct, prop) = struct_props.tokenize('@')*.trim() |
53 |
|
|
54 |
if ((prop == null) || prop.size() == 0) { |
|
55 |
println "** $scriptName: please set @properties in the 'struct_props' parameter." |
|
56 |
} else { |
|
57 | 53 |
|
58 |
if (prop.indexOf(',') == -1) { |
|
59 |
prop = [prop] |
|
60 |
} else { |
|
61 |
prop = prop.tokenize(',')*.trim() |
|
62 |
} |
|
54 |
if ((prop == null) || prop.size() == 0) { |
|
55 |
println "** $scriptName: please set @properties in the 'struct_props' parameter." |
|
56 |
} else { |
|
63 | 57 |
|
64 |
occs = (0..corpusEngine.attributeSize("$corpus.${struct}_${prop[0]}")-1).collect { cpos -> |
|
65 |
prop.collect { prop -> |
|
66 |
corpusEngine.struc2Str("$corpus.${struct}_$prop", [cpos] as int[])[0] |
|
67 |
}.join('_') |
|
68 |
} |
|
69 |
|
|
70 |
if (groupByValue) { |
|
71 |
occs = occs.sort().countBy { it }.sort { a,b -> b.value <=> a.value ?: a.key <=> b.key } |
|
72 |
if (globalVmax == 0) { |
|
73 |
occs.each { println sprintf("%s\t%d", it.key, it.value) } |
|
74 |
} else { |
|
75 |
occs.take(globalVmax).each { println sprintf("%s\t%d", it.key, it.value) } |
|
76 |
} |
|
77 |
} else { |
|
78 |
if (globalVmax == 0) { |
|
79 |
occs.each { println it } |
|
80 |
} else { |
|
81 |
occs.take(globalVmax).each { println it } |
|
82 |
} |
|
83 |
} |
|
84 |
} |
|
58 |
if (prop.indexOf(',') == -1) { |
|
59 |
prop = [prop] |
|
60 |
} else { |
|
61 |
prop = prop.tokenize(',')*.trim() |
|
62 |
} |
|
85 | 63 |
|
64 |
occs = (0..corpusEngine.attributeSize("$corpus.${struct}_${prop[0]}")-1).collect { cpos -> |
|
65 |
prop.collect { prop -> |
|
66 |
corpusEngine.struc2Str("$corpus.${struct}_$prop", [cpos] as int[])[0] |
|
67 |
}.join('_') |
|
68 |
} |
|
69 |
|
|
70 |
if (groupByValue) { |
|
71 |
occs = occs.sort().countBy { it }.sort { a,b -> b.value <=> a.value ?: a.key <=> b.key } |
|
72 |
if (globalVmax == 0) { |
|
73 |
occs.each { println sprintf("%s\t%d", it.key, it.value) } |
|
74 |
} else { |
|
75 |
occs.take(globalVmax).each { println sprintf("%s\t%d", it.key, it.value) } |
|
76 |
} |
|
77 |
} else { |
|
78 |
if (globalVmax == 0) { |
|
79 |
occs.each { println it } |
|
80 |
} else { |
|
81 |
occs.take(globalVmax).each { println it } |
|
82 |
} |
|
83 |
} |
|
84 |
} |
|
85 |
|
TXM/trunk/bundles/org.txm.groovy.core/src/groovy/org/txm/macro/cqp/StructsIndexMacro.groovy (revision 3788) | ||
---|---|---|
16 | 16 |
// BEGINNING OF PARAMETERS |
17 | 17 |
|
18 | 18 |
@Field @Option(name = "structs_props", usage = "struct1@prop1_prop2,struct2@prop3_prop4...", widget |
19 |
= "String", required = true, def = "")
|
|
19 |
= "String", required = true, def = "") |
|
20 | 20 |
def structs_props |
21 | 21 |
|
22 | 22 |
@Field @Option(name = "Vmax", usage = "maximum number of values displayed (use '0' to display all)", widget = "Integer", required = true, |
23 |
def = "0")
|
|
23 |
def = "0") |
|
24 | 24 |
def Vmax |
25 | 25 |
|
26 | 26 |
// Open the parameters input dialog box |
27 | 27 |
if (!ParametersDialog.open(this)) { |
28 |
return
|
|
28 |
return
|
|
29 | 29 |
} |
30 | 30 |
|
31 | 31 |
// END OF PARAMETERS |
... | ... | |
37 | 37 |
corpora = utils.getCorpora(this) |
38 | 38 |
|
39 | 39 |
if ((corpora == null) || corpora.size() > 1) { |
40 |
println "** $scriptName: please select a corpus in the Corpus view or provide a corpus name. Aborting."
|
|
41 |
return false
|
|
40 |
println "** $scriptName: please select a corpus in the Corpus view or provide a corpus name. Aborting."
|
|
41 |
return false
|
|
42 | 42 |
} |
43 | 43 |
|
44 | 44 |
// check for structs_props parameter |
45 | 45 |
if ((structs_props == null) || structs_props.size() == 0) { |
46 |
println "** $scriptName: please set the 'structs_props' parameter. Aborting."
|
|
47 |
return false
|
|
46 |
println "** $scriptName: please set the 'structs_props' parameter. Aborting."
|
|
47 |
return false
|
|
48 | 48 |
} |
49 | 49 |
|
50 | 50 |
corpus_name = corpora[0].getMainCorpus().getName() |
51 | 51 |
corpus_size = corpora[0].getMainCorpus().getSize() |
52 | 52 |
|
53 | 53 |
if (structs_props.indexOf(',') == -1) { |
54 |
struct_props = [structs_props]
|
|
54 |
struct_props = [structs_props]
|
|
55 | 55 |
} else { |
56 |
struct_props = structs_props.tokenize(',')*.trim()
|
|
56 |
struct_props = structs_props.tokenize(',')*.trim()
|
|
57 | 57 |
} |
58 | 58 |
|
59 | 59 |
globalVmax = Vmax |
60 | 60 |
|
61 | 61 |
def printPropValues(start, end, struct_prop, output) { |
62 | 62 |
|
63 |
if (struct_prop.size() > 0) {
|
|
64 |
|
|
65 |
curr_struct_prop = struct_prop[0]
|
|
66 |
s_p = curr_struct_prop.tokenize('@')*.trim()
|
|
67 |
def struct = s_p[0]
|
|
68 |
def prop = s_p[1]
|
|
69 |
|
|
70 |
if ((prop == null) || prop.size() == 0) {
|
|
71 |
println "** $scriptName: please set @properties in the 'structs_props' parameter."
|
|
72 |
} else {
|
|
73 |
|
|
74 |
if (prop.indexOf('_') == -1) {
|
|
75 |
prop = [prop]
|
|
76 |
} else {
|
|
77 |
prop = prop.tokenize('_')*.trim()
|
|
78 |
}
|
|
79 |
|
|
80 |
occs = (0..corpusEngine.attributeSize("$corpus_name.${struct}_${prop[0]}")-1).collect {
|
|
81 |
idx -> curr_start = corpusEngine.struc2Cpos("$corpus_name.${struct}_${prop[0]}", idx as int)[0]
|
|
82 |
curr_end = corpusEngine.struc2Cpos("$corpus_name.${struct}_${prop[0]}", idx as int)[1]
|
|
83 |
if (curr_start >= start && curr_end <= end) {
|
|
84 |
[
|
|
85 |
curr_start,
|
|
86 |
curr_end,
|
|
87 |
prop.collect {
|
|
88 |
curr_prop -> corpusEngine.struc2Str("$corpus_name.${struct}_$curr_prop", [idx] as int [])[0]
|
|
89 |
}.join('_')
|
|
90 |
]
|
|
91 |
} else null
|
|
92 |
}
|
|
93 |
def n = 0
|
|
94 |
occs.each {
|
|
95 |
if (it != null && (globalVmax == 0 || n < globalVmax)) {
|
|
96 |
(start, end, value) = it
|
|
97 |
// println prefix+value // struct+"@"+prop[0]+"="+
|
|
98 |
if (output.length() > 0) {
|
|
99 |
printPropValues(start, end, struct_prop.tail(), output + "\t" + value)
|
|
100 |
} else {
|
|
101 |
printPropValues(start, end, struct_prop.tail(), value)
|
|
102 |
}
|
|
103 |
n++
|
|
104 |
}
|
|
105 |
}
|
|
106 |
}
|
|
107 |
} else println output
|
|
63 |
if (struct_prop.size() > 0) {
|
|
64 |
|
|
65 |
curr_struct_prop = struct_prop[0]
|
|
66 |
s_p = curr_struct_prop.tokenize('@')*.trim()
|
|
67 |
def struct = s_p[0]
|
|
68 |
def prop = s_p[1]
|
|
69 |
|
|
70 |
if ((prop == null) || prop.size() == 0) {
|
|
71 |
println "** $scriptName: please set @properties in the 'structs_props' parameter."
|
|
72 |
} else {
|
|
73 |
|
|
74 |
if (prop.indexOf('_') == -1) {
|
|
75 |
prop = [prop]
|
|
76 |
} else {
|
|
77 |
prop = prop.tokenize('_')*.trim()
|
|
78 |
}
|
|
79 |
|
|
80 |
occs = (0..corpusEngine.attributeSize("$corpus_name.${struct}_${prop[0]}")-1).collect {
|
|
81 |
idx -> curr_start = corpusEngine.struc2Cpos("$corpus_name.${struct}_${prop[0]}", idx as int)[0]
|
|
82 |
curr_end = corpusEngine.struc2Cpos("$corpus_name.${struct}_${prop[0]}", idx as int)[1]
|
|
83 |
if (curr_start >= start && curr_end <= end) {
|
|
84 |
[
|
|
85 |
curr_start,
|
|
86 |
curr_end,
|
|
87 |
prop.collect {
|
|
88 |
curr_prop -> corpusEngine.struc2Str("$corpus_name.${struct}_$curr_prop", [idx] as int [])[0]
|
|
89 |
}.join('_')
|
|
90 |
]
|
|
91 |
} else null
|
|
92 |
}
|
|
93 |
def n = 0
|
|
94 |
occs.each {
|
|
95 |
if (it != null && (globalVmax == 0 || n < globalVmax)) {
|
|
96 |
(start, end, value) = it
|
|
97 |
// println prefix+value // struct+"@"+prop[0]+"="+
|
|
98 |
if (output.length() > 0) {
|
|
99 |
printPropValues(start, end, struct_prop.tail(), output + "\t" + value)
|
|
100 |
} else {
|
|
101 |
printPropValues(start, end, struct_prop.tail(), value)
|
|
102 |
}
|
|
103 |
n++
|
|
104 |
}
|
|
105 |
}
|
|
106 |
}
|
|
107 |
} else println output
|
|
108 | 108 |
} |
109 | 109 |
|
110 | 110 |
printPropValues(0, corpus_size, struct_props, "") |
TXM/trunk/bundles/org.txm.groovy.core/src/groovy/org/txm/macro/conversion/EuroPressToXML2018Macro.groovy (revision 3788) | ||
---|---|---|
1 | 1 |
package org.txm.macro.conversion |
2 | 2 |
// STANDARD DECLARATIONS |
3 | 3 |
|
4 |
import groovy.xml.QName |
|
4 |
import groovy.namespace.QName |
|
5 |
import groovy.xml.XmlNodePrinter |
|
5 | 6 |
import java.text.DecimalFormat |
6 | 7 |
import org.txm.utils.xml.DomUtils |
7 | 8 |
import org.txm.importer.ValidateXml |
TXM/trunk/bundles/org.txm.groovy.core/src/groovy/org/txm/macro/debug/JavascriptVersionMacro.groovy (revision 3788) | ||
---|---|---|
5 | 5 |
import javax.script.* |
6 | 6 |
|
7 | 7 |
manager = new ScriptEngineManager() |
8 |
engine = manager.getEngineByName("JavaScript") |
|
9 |
factory = engine.getFactory() |
|
10 |
|
|
11 |
println factory.getLanguageName()+" "+factory.getLanguageVersion()+" ("+factory.getEngineName()+" "+factory.getEngineVersion()+")" |
|
8 |
for (def factory : manager.getEngineFactories()) { |
|
9 |
println factory.getLanguageName()+" "+factory.getLanguageVersion()+" ("+factory.getEngineName()+" "+factory.getEngineVersion()+")" |
|
10 |
} |
TXM/trunk/bundles/org.txm.groovy.core/src/groovy/org/txm/macro/debug/XSLTVersionMacro.groovy (revision 3788) | ||
---|---|---|
4 | 4 |
package org.txm.macro.debug |
5 | 5 |
import net.sf.saxon.Version |
6 | 6 |
|
7 |
println "XSLT "+Version.getXSLVersionString()+" ("+Version.getProductTitle()+" - "+Version.getReleaseDate()+")" |
|
8 | 7 |
|
8 |
|
|
9 |
println "XSLT "+Version.getSoftwarePlatform()+" ("+Version.getProductTitle()+" - "+Version.getReleaseDate()+")" |
|
10 |
|
|
9 | 11 |
Class c = net.sf.saxon.Version.class |
10 | 12 |
println c.getProtectionDomain().getCodeSource().getLocation().getFile() |
TXM/trunk/bundles/org.txm.groovy.core/src/groovy/org/txm/macro/debug/RVersionMacro.groovy (revision 3788) | ||
---|---|---|
13 | 13 |
|
14 | 14 |
println ".libPaths="+r.eval(".libPaths()").asString() |
15 | 15 |
println ".Library="+r.eval(".Library").asString() |
16 |
println ".Library.site="+r.eval(".Library.site").asString()
|
|
16 |
//println ".Library.site="+r.eval(".Library.site").asString() // no more available ?
|
|
17 | 17 |
|
18 | 18 |
println "R.home()="+r.eval("R.home()").asString() |
19 | 19 |
rez = r.eval("options()") |
TXM/trunk/bundles/org.txm.searchengine.cqp.core/src/org/txm/importer/cwb/CompressCQPIndexes.java (revision 3788) | ||
---|---|---|
101 | 101 |
Process process = processBuilder.start(); |
102 | 102 |
String messages = CwbProcess.getOutputMessages(process); |
103 | 103 |
System.out.println(messages); |
104 |
process.waitFor(); |
|
104 | 105 |
if (process.exitValue() != 0) { |
105 | 106 |
System.out.println("Error while compressing with huff"); |
106 | 107 |
return false; |
TXM/trunk/bundles/org.txm.translate.rcp/src/org/txm/rcp/translate/devtools/CreateMessagesTable.java (revision 3788) | ||
---|---|---|
1 | 1 |
package org.txm.rcp.translate.devtools; |
2 | 2 |
|
3 | 3 |
import java.io.File; |
4 |
import java.io.FileNotFoundException; |
|
5 |
import java.io.IOException; |
|
6 |
import java.io.UnsupportedEncodingException; |
|
7 | 4 |
import java.util.Properties; |
8 | 5 |
import java.util.TreeSet; |
9 | 6 |
|
10 |
import org.odftoolkit.simple.Document; |
|
11 |
import org.odftoolkit.simple.SpreadsheetDocument; |
|
12 |
import org.odftoolkit.simple.TextDocument; |
|
13 |
import org.odftoolkit.simple.table.Cell; |
|
14 |
import org.odftoolkit.simple.table.Row; |
|
15 |
import org.odftoolkit.simple.table.Table; |
|
7 |
import org.odftoolkit.odfdom.doc.OdfDocument; |
|
8 |
import org.odftoolkit.odfdom.doc.OdfSpreadsheetDocument; |
|
9 |
import org.odftoolkit.odfdom.doc.OdfTextDocument; |
|
10 |
import org.odftoolkit.odfdom.doc.table.OdfTable; |
|
16 | 11 |
import org.txm.rcp.translate.i18n.PluginMessagesManager; |
17 | 12 |
import org.txm.utils.io.IOUtils; |
18 | 13 |
|
... | ... | |
45 | 40 |
Properties slave = new Properties(); |
46 | 41 |
slave.load(IOUtils.getReader(langPropertiesFile, "UTF-8")); |
47 | 42 |
|
48 |
TextDocument doc = org.odftoolkit.simple.TextDocument.newTextDocument();
|
|
43 |
OdfTextDocument doc = OdfTextDocument.newTextDocument();
|
|
49 | 44 |
|
50 | 45 |
TreeSet<Object> keys = new TreeSet<Object>(PluginMessagesManager.comp); |
51 | 46 |
keys.addAll(master.keySet()); |
52 | 47 |
|
53 |
Table table = doc.addTable(keys.size()+1,4);
|
|
48 |
OdfTable table = OdfTable.newTable(doc, keys.size()+1,4);// doc.addTable(keys.size()+1,4);
|
|
54 | 49 |
editTable(doc, table, keys, master, slave); |
55 | 50 |
|
56 | 51 |
System.out.println("Saving..."); |
... | ... | |
60 | 55 |
return true; |
61 | 56 |
} |
62 | 57 |
|
63 |
private void editTable(Document doc, Table table, TreeSet<Object> keys,Properties master, Properties slave ) {
|
|
58 |
private void editTable(OdfDocument doc, OdfTable table, TreeSet<Object> keys,Properties master, Properties slave ) {
|
|
64 | 59 |
|
65 | 60 |
table.getCellByPosition(0, 0).setStringValue("N"); |
66 | 61 |
table.getCellByPosition(1, 0).setStringValue("KEY"); |
... | ... | |
91 | 86 |
Properties slave = new Properties(); |
92 | 87 |
slave.load(IOUtils.getReader(langPropertiesFile, "UTF-8")); |
93 | 88 |
|
94 |
SpreadsheetDocument spreadsheet = SpreadsheetDocument.newSpreadsheetDocument();
|
|
89 |
OdfSpreadsheetDocument spreadsheet = OdfSpreadsheetDocument.newSpreadsheetDocument();
|
|
95 | 90 |
|
96 | 91 |
TreeSet<Object> keys = new TreeSet<Object>(PluginMessagesManager.comp); |
97 | 92 |
keys.addAll(master.keySet()); |
... | ... | |
99 | 94 |
//Cell cell = table.getCellByPosition(0, 0); |
100 | 95 |
// cell.setStringValue("Hello World!"); |
101 | 96 |
|
102 |
Table table = spreadsheet.getTableList().get(0); |
|
97 |
OdfTable table = spreadsheet.getTableList().get(0);
|
|
103 | 98 |
table.appendRows(keys.size()+1); |
104 | 99 |
table.appendColumns(4); |
105 | 100 |
editTable(spreadsheet, table, keys, master, slave); |
TXM/trunk/bundles/org.txm.translate.rcp/src/org/txm/rcp/translate/devtools/TableToProperties.java (revision 3788) | ||
---|---|---|
5 | 5 |
import java.io.PrintWriter; |
6 | 6 |
import java.util.Properties; |
7 | 7 |
|
8 |
import org.odftoolkit.simple.TextDocument;
|
|
9 |
import org.odftoolkit.simple.table.Cell;
|
|
10 |
import org.odftoolkit.simple.table.Row;
|
|
11 |
import org.odftoolkit.simple.table.Table;
|
|
8 |
import org.odftoolkit.odfdom.doc.OdfTextDocument;
|
|
9 |
import org.odftoolkit.odfdom.doc.table.OdfTable;
|
|
10 |
import org.odftoolkit.odfdom.doc.table.OdfTableCell;
|
|
11 |
import org.odftoolkit.odfdom.doc.table.OdfTableRow;
|
|
12 | 12 |
import org.txm.utils.io.IOUtils; |
13 | 13 |
|
14 | 14 |
public class TableToProperties { |
... | ... | |
25 | 25 |
|
26 | 26 |
Properties slave = new Properties(); |
27 | 27 |
|
28 |
TextDocument doc = TextDocument.loadDocument(tableFile);
|
|
29 |
Table table = doc.getTableList().get(0);
|
|
28 |
OdfTextDocument doc = OdfTextDocument.loadDocument(tableFile);
|
|
29 |
OdfTable table = doc.getTableList(false).get(0);
|
|
30 | 30 |
|
31 |
Row headerRow = table.getRowList().get(0); |
|
31 |
OdfTableRow headerRow = table.getRowList().get(0);
|
|
32 | 32 |
int ncol = headerRow.getCellCount(); |
33 | 33 |
int keyIndex = -1; |
34 | 34 |
int langIndex = -1; |
35 | 35 |
int defaultIndex = -1; |
36 | 36 |
String str = ""; |
37 | 37 |
for (int c = 0; c < ncol; c++) { |
38 |
Cell cell = headerRow.getCellByIndex(c); |
|
38 |
OdfTableCell cell = headerRow.getCellByIndex(c);
|
|
39 | 39 |
String s = cell.getDisplayText(); |
40 | 40 |
if ("KEY".equals(s)) { |
41 | 41 |
keyIndex = c; |
... | ... | |
62 | 62 |
return null; |
63 | 63 |
} |
64 | 64 |
|
65 |
for (Row h : table.getRowList()) { |
|
65 |
for (OdfTableRow h : table.getRowList()) {
|
|
66 | 66 |
|
67 | 67 |
String key = h.getCellByIndex(keyIndex).getDisplayText(); |
68 | 68 |
if (key != null) { |
TXM/trunk/bundles/org.txm.translate.rcp/src/org/txm/rcp/translate/devtools/ImportMessagesTable.java (revision 3788) | ||
---|---|---|
6 | 6 |
import java.util.Properties; |
7 | 7 |
import java.util.TreeSet; |
8 | 8 |
|
9 |
import org.odftoolkit.simple.TextDocument;
|
|
10 |
import org.odftoolkit.simple.table.Cell;
|
|
11 |
import org.odftoolkit.simple.table.Row;
|
|
12 |
import org.odftoolkit.simple.table.Table;
|
|
9 |
import org.odftoolkit.odfdom.doc.OdfTextDocument;
|
|
10 |
import org.odftoolkit.odfdom.doc.table.OdfTable;
|
|
11 |
import org.odftoolkit.odfdom.doc.table.OdfTableCell;
|
|
12 |
import org.odftoolkit.odfdom.doc.table.OdfTableRow;
|
|
13 | 13 |
import org.txm.rcp.translate.i18n.PluginMessagesManager; |
14 | 14 |
import org.txm.utils.io.IOUtils; |
15 | 15 |
|
... | ... | |
62 | 62 |
|
63 | 63 |
slave.load(IOUtils.getReader(langPropertiesFile, "UTF-8")); |
64 | 64 |
|
65 |
TextDocument doc = TextDocument.loadDocument(tableFile);
|
|
66 |
Table table = doc.getTableList().get(0);
|
|
65 |
OdfTextDocument doc = OdfTextDocument.loadDocument(tableFile);
|
|
66 |
OdfTable table = doc.getTableList(false).get(0);
|
|
67 | 67 |
|
68 |
Row headerRow = table.getRowList().get(0); |
|
68 |
OdfTableRow headerRow = table.getRowList().get(0);
|
|
69 | 69 |
int ncol = headerRow.getCellCount(); |
70 | 70 |
int keyIndex = -1; |
71 | 71 |
int langIndex = -1; |
72 | 72 |
int defaultIndex = -1; |
73 | 73 |
for (int c = 0; c < ncol; c++) { |
74 |
Cell cell = headerRow.getCellByIndex(c); |
|
74 |
OdfTableCell cell = headerRow.getCellByIndex(c);
|
|
75 | 75 |
if ("KEY".equals(cell.getDisplayText())) { |
76 | 76 |
keyIndex = c; |
77 | 77 |
} |
... | ... | |
96 | 96 |
return false; |
97 | 97 |
} |
98 | 98 |
|
99 |
for (Row h : table.getRowList()) { |
|
99 |
for (OdfTableRow h : table.getRowList()) {
|
|
100 | 100 |
|
101 | 101 |
String key = h.getCellByIndex(keyIndex).getDisplayText(); |
102 | 102 |
if (key != null) { |
Formats disponibles : Unified diff