Line 1... |
Line 1... |
1 |
/*
|
1 |
/*
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
3 |
*
|
3 |
*
|
4 |
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
|
4 |
* Copyright 2011-2019 OpenConcerto, by ILM Informatique. All rights reserved.
|
5 |
*
|
5 |
*
|
6 |
* The contents of this file are subject to the terms of the GNU General Public License Version 3
|
6 |
* The contents of this file are subject to the terms of the GNU General Public License Version 3
|
7 |
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
|
7 |
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
|
8 |
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
|
8 |
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
|
9 |
* language governing permissions and limitations under the License.
|
9 |
* language governing permissions and limitations under the License.
|
Line 255... |
Line 255... |
255 |
int endPageLine = Integer.parseInt(tableau.getAttributeValue("endPageLine"));
|
255 |
int endPageLine = Integer.parseInt(tableau.getAttributeValue("endPageLine"));
|
256 |
if (oLastColTmp != null) {
|
256 |
if (oLastColTmp != null) {
|
257 |
lastColumn = sheet.resolveHint(oLastColTmp.toString() + 1).x + 1;
|
257 |
lastColumn = sheet.resolveHint(oLastColTmp.toString() + 1).x + 1;
|
258 |
}
|
258 |
}
|
259 |
|
259 |
|
- |
|
260 |
int firstLine = Integer.parseInt(tableau.getAttributeValue("firstLine"));
|
- |
|
261 |
int endLine = Integer.parseInt(tableau.getAttributeValue("endLine"));
|
- |
|
262 |
Object printRangeObj = sheet.getPrintRanges();
|
- |
|
263 |
|
260 |
Map<String, Map<Integer, String>> mapStyle = searchStyle(sheet, lastColumn, endPageLine);
|
264 |
final Map<String, Map<Integer, String>> mapStyle;
|
261 |
|
265 |
|
262 |
if (tableau.getAttributeValue("table").equalsIgnoreCase("TVA")) {
|
266 |
if (tableau.getAttributeValue("table").equalsIgnoreCase("TVA")) {
|
- |
|
267 |
mapStyle = null;
|
263 |
fillTaxeDocumentMap(tableau, sheet, mapStyle, false);
|
268 |
fillTaxeDocumentMap(tableau, sheet, false);
|
264 |
return;
|
269 |
return;
|
- |
|
270 |
} else {
|
- |
|
271 |
mapStyle = searchStyle(sheet, firstLine, lastColumn, endLine);
|
265 |
}
|
272 |
}
|
- |
|
273 |
|
266 |
int nbPage = fillTable(tableau, row, sheet, mapStyle, true, rowLanguage);
|
274 |
int nbPage = fillTable(tableau, row, sheet, mapStyle, true, rowLanguage);
|
267 |
int firstLine = Integer.parseInt(tableau.getAttributeValue("firstLine"));
|
- |
|
268 |
int endLine = Integer.parseInt(tableau.getAttributeValue("endLine"));
|
- |
|
269 |
Object printRangeObj = sheet.getPrintRanges();
|
- |
|
270 |
|
275 |
|
271 |
System.err.println("Nombre de page == " + nbPage);
|
276 |
System.err.println("Nombre de page == " + nbPage);
|
272 |
if (nbPage == 1) {
|
277 |
if (nbPage == 1) {
|
273 |
fillTable(tableau, row, sheet, mapStyle, false, rowLanguage);
|
278 |
fillTable(tableau, row, sheet, mapStyle, false, rowLanguage);
|
274 |
} else {
|
279 |
} else {
|
Line 279... |
Line 284... |
279 |
for (int i = 0; i < range.length; i++) {
|
284 |
for (int i = 0; i < range.length; i++) {
|
280 |
String string = range[i];
|
285 |
String string = range[i];
|
281 |
range[i] = string.subSequence(string.indexOf('.') + 1, string.length()).toString();
|
286 |
range[i] = string.subSequence(string.indexOf('.') + 1, string.length()).toString();
|
282 |
}
|
287 |
}
|
283 |
|
288 |
|
284 |
int rowEnd = -1;
|
- |
|
285 |
if (range.length > 1) {
|
289 |
if (range.length > 1) {
|
286 |
rowEnd = sheet.resolveHint(range[1]).y + 1;
|
290 |
int rowEnd = sheet.resolveHint(range[1]).y + 1;
|
287 |
int rowEndNew = rowEnd * (nbPage);
|
291 |
int rowEndNew = rowEnd * nbPage;
|
288 |
String sNew = s.replaceAll(String.valueOf(rowEnd), String.valueOf(rowEndNew));
|
292 |
String sNew = s.replaceAll(String.valueOf(rowEnd), String.valueOf(rowEndNew));
|
289 |
sheet.setPrintRanges(sNew);
|
293 |
sheet.setPrintRanges(sNew);
|
290 |
System.err.println(" ****** Replace print ranges; Old:" + rowEnd + "--" + s + " New:" + rowEndNew + "--" + sNew);
|
294 |
System.err.println(" ****** Replace print ranges; Old:" + rowEnd + "--" + s + " New:" + rowEndNew + "--" + sNew);
|
291 |
}
|
295 |
}
|
292 |
}
|
296 |
}
|
Line 750... |
Line 754... |
750 |
mapNbCel.put(e.getAttributeValue("location").trim(), nbCellule);
|
754 |
mapNbCel.put(e.getAttributeValue("location").trim(), nbCellule);
|
751 |
}
|
755 |
}
|
752 |
return nbCellule;
|
756 |
return nbCellule;
|
753 |
}
|
757 |
}
|
754 |
|
758 |
|
755 |
private void fillTaxeDocumentMap(Element tableau, Sheet sheet, Map<String, Map<Integer, String>> mapStyle, boolean test) {
|
759 |
private void fillTaxeDocumentMap(Element tableau, Sheet sheet, boolean test) {
|
756 |
|
760 |
|
757 |
int line = Integer.parseInt(tableau.getAttributeValue("firstLine"));
|
761 |
int line = Integer.parseInt(tableau.getAttributeValue("firstLine"));
|
758 |
List<Element> listElts = tableau.getChildren("element");
|
762 |
List<Element> listElts = tableau.getChildren("element");
|
759 |
|
763 |
|
760 |
for (SQLRowAccessor rowTaxe : taxe.keySet()) {
|
764 |
for (SQLRowAccessor rowTaxe : taxe.keySet()) {
|
Line 890... |
Line 894... |
890 |
|
894 |
|
891 |
MutableCell cell = sheet.getCellAt(location);
|
895 |
MutableCell cell = sheet.getCellAt(location);
|
892 |
|
896 |
|
893 |
// on divise en 2 cellules si il y a des retours à la ligne
|
897 |
// on divise en 2 cellules si il y a des retours à la ligne
|
894 |
if (controleMultiline && value != null && value.toString().indexOf('\n') >= 0) {
|
898 |
if (controleMultiline && value != null && value.toString().indexOf('\n') >= 0) {
|
- |
|
899 |
String[] values;
|
- |
|
900 |
if (cell.getRowsSpanned() < 2) {
|
- |
|
901 |
// TODO : mettre une option pour splitter ou pas
|
895 |
String[] values = value.toString().split("\n");
|
902 |
values = value.toString().split("\n");
|
- |
|
903 |
} else {
|
- |
|
904 |
values = new String[] { value.toString() };
|
- |
|
905 |
}
|
896 |
|
906 |
|
897 |
Point p = sheet.resolveHint(location);
|
907 |
Point p = sheet.resolveHint(location);
|
898 |
int y = 0;
|
908 |
int y = 0;
|
899 |
for (String string : values) {
|
909 |
for (String string : values) {
|
900 |
if (string != null && (keepEmptyLines || string.trim().length() != 0)) {
|
910 |
if (string != null && (keepEmptyLines || string.trim().length() != 0)) {
|
Line 1028... |
Line 1038... |
1028 |
}
|
1038 |
}
|
1029 |
|
1039 |
|
1030 |
/**
|
1040 |
/**
|
1031 |
* parcourt l'ensemble de la feuille pour trouver les style définit
|
1041 |
* parcourt l'ensemble de la feuille pour trouver les style définit
|
1032 |
*/
|
1042 |
*/
|
1033 |
private Map<String, Map<Integer, String>> searchStyle(Sheet sheet, int colEnd, int rowEnd) {
|
1043 |
private Map<String, Map<Integer, String>> searchStyle(Sheet sheet, int rowDeb, int colEnd, int rowEnd) {
|
1034 |
|
1044 |
|
1035 |
if (cacheStyle.get(sheet) != null) {
|
1045 |
if (cacheStyle.get(sheet) != null) {
|
1036 |
return cacheStyle.get(sheet);
|
1046 |
return cacheStyle.get(sheet);
|
1037 |
}
|
1047 |
}
|
1038 |
|
1048 |
|
Line 1041... |
Line 1051... |
1041 |
// on parcourt chaque ligne de la feuille pour recuperer les styles
|
1051 |
// on parcourt chaque ligne de la feuille pour recuperer les styles
|
1042 |
int columnCount = (colEnd == -1) ? sheet.getColumnCount() : (colEnd + 1);
|
1052 |
int columnCount = (colEnd == -1) ? sheet.getColumnCount() : (colEnd + 1);
|
1043 |
System.err.println("End column search : " + columnCount);
|
1053 |
System.err.println("End column search : " + columnCount);
|
1044 |
|
1054 |
|
1045 |
int rowCount = (rowEnd > 0) ? rowEnd : sheet.getRowCount();
|
1055 |
int rowCount = (rowEnd > 0) ? rowEnd : sheet.getRowCount();
|
- |
|
1056 |
int start = (rowDeb - 1 > 0) ? rowDeb - 1 : 0;
|
- |
|
1057 |
|
1046 |
System.err.println("End row search : " + rowCount);
|
1058 |
System.err.println("End row search : " + rowCount);
|
1047 |
for (int i = 0; i < rowCount; i++) {
|
1059 |
for (int i = start; i < rowCount; i++) {
|
1048 |
int x = 0;
|
1060 |
int x = 0;
|
1049 |
Map<Integer, String> mapCellStyle = new HashMap<>();
|
1061 |
Map<Integer, String> mapCellStyle = new HashMap<>();
|
1050 |
String style = "";
|
1062 |
String style = "";
|
1051 |
|
1063 |
|
1052 |
for (int j = 0; j < columnCount; j++) {
|
1064 |
for (int j = 0; j < columnCount; j++) {
|
Line 1117... |
Line 1129... |
1117 |
}
|
1129 |
}
|
1118 |
final Sheet sheet = spreadSheet.getSheet(0);
|
1130 |
final Sheet sheet = spreadSheet.getSheet(0);
|
1119 |
|
1131 |
|
1120 |
Object oLastColTmp = tableau.getAttributeValue("lastColumn");
|
1132 |
Object oLastColTmp = tableau.getAttributeValue("lastColumn");
|
1121 |
int lastColumn = -1;
|
1133 |
int lastColumn = -1;
|
1122 |
int endPageLine = Integer.parseInt(tableau.getAttributeValue("endPageLine"));
|
- |
|
1123 |
if (oLastColTmp != null) {
|
1134 |
if (oLastColTmp != null) {
|
1124 |
lastColumn = sheet.resolveHint(oLastColTmp.toString() + 1).x + 1;
|
1135 |
lastColumn = sheet.resolveHint(oLastColTmp.toString() + 1).x + 1;
|
1125 |
}
|
1136 |
}
|
- |
|
1137 |
int firstLine = Integer.parseInt(tableau.getAttributeValue("firstLine"));
|
- |
|
1138 |
int endLine = Integer.parseInt(tableau.getAttributeValue("endLine"));
|
1126 |
|
1139 |
|
1127 |
Map<String, Map<Integer, String>> mapStyle = searchStyle(sheet, lastColumn, endPageLine);
|
1140 |
Map<String, Map<Integer, String>> mapStyle = searchStyle(sheet, firstLine, lastColumn, endLine);
|
1128 |
|
1141 |
|
1129 |
int nbPage = fillTable(tableau, row, sheet, mapStyle, true, rowLanguage);
|
1142 |
int nbPage = fillTable(tableau, row, sheet, mapStyle, true, rowLanguage);
|
1130 |
|
1143 |
|
1131 |
return nbPage > 1;
|
1144 |
return nbPage > 1;
|
1132 |
} catch (Throwable e) {
|
1145 |
} catch (Throwable e) {
|