diff --git a/plugins/org.obeonetwork.m2doc.html/src/org/obeonetwork/m2doc/html/services/M2DocHTMLParser.java b/plugins/org.obeonetwork.m2doc.html/src/org/obeonetwork/m2doc/html/services/M2DocHTMLParser.java
index 9299a028c..825eb7a98 100644
--- a/plugins/org.obeonetwork.m2doc.html/src/org/obeonetwork/m2doc/html/services/M2DocHTMLParser.java
+++ b/plugins/org.obeonetwork.m2doc.html/src/org/obeonetwork/m2doc/html/services/M2DocHTMLParser.java
@@ -970,7 +970,6 @@ private void insertTable(MParagraph parent, Context context, Node header, Node b
if ("tr".equals(child.nodeName())) {
final MRow row = new MRowImpl();
table.getRows().add(row);
- int currentColumn = 0;
for (Node rowChild : child.childNodes()) {
if ("th".equals(rowChild.nodeName()) || "td".equals(rowChild.nodeName())) {
final MList contents = new MListImpl();
@@ -985,7 +984,7 @@ private void insertTable(MParagraph parent, Context context, Node header, Node b
CSS_PARSER.setStyle(localContext.cssProperties, cell);
walkChildren(rowChild, localContext, newParagraph);
createNeededParagraphes(newParagraph);
- currentColumn = insertMergedCells(row, rowChild, cell, rowSpans, vMergeCopies, currentColumn);
+ insertMergedCells(row, rowChild, cell, rowSpans, vMergeCopies);
}
}
insertRowspans(row, rowSpans, vMergeCopies);
@@ -1064,14 +1063,12 @@ private void insertRowspans(final MRow row, final Map rowSpans
* the {@link Map} from the starting column to the number of remaining cells to merge
* @param vMergeCopies
* the {@link Map} from the starting column to the {@link List} of {@link MCell} to copy
- * @param currentColumn
- * the current column
- * @return the new current column
*/
- private int insertMergedCells(final MRow row, Node rowChild, final MCell cell, Map rowSpans,
- Map> vMergeCopies, int currentColumn) {
- int res = currentColumn;
-
+ private void insertMergedCells(final MRow row, Node rowChild, final MCell cell, Map rowSpans,
+ Map> vMergeCopies) {
+ insertRowspans(row, rowSpans, vMergeCopies);
+ final int currentColumn = row.getCells().size();
+ int lastColumn = currentColumn;
final int rowSpan = getRowSpan(rowChild);
final boolean restartVMerge;
if (rowSpan > -1) {
@@ -1084,11 +1081,10 @@ private int insertMergedCells(final MRow row, Node rowChild, final MCell cell, M
}
} else {
restartVMerge = false;
- insertRowspans(row, rowSpans, vMergeCopies);
}
row.getCells().add(cell);
- res++;
+ lastColumn++;
final int colSpan = getColSpan(rowChild);
final boolean restartHMerge;
@@ -1101,7 +1097,7 @@ private int insertMergedCells(final MRow row, Node rowChild, final MCell cell, M
hMergedCell.setHMerge(MCell.Merge.CONTINUE);
hMergedCell.setVMerge(cell.getVMerge());
row.getCells().add(hMergedCell);
- res++;
+ lastColumn++;
}
} else {
restartHMerge = false;
@@ -1117,7 +1113,7 @@ private int insertMergedCells(final MRow row, Node rowChild, final MCell cell, M
}
vMergeCopy.add(vMergedCell);
- for (int i = 0; i < res - currentColumn - 1; i++) {
+ for (int i = 0; i < lastColumn - currentColumn - 1; i++) {
final MList hMergedContents = new MListImpl();
final MCell hMergedCell = new MCellImpl(hMergedContents, null);
hMergedCell.setVMerge(MCell.Merge.CONTINUE);
@@ -1126,8 +1122,6 @@ private int insertMergedCells(final MRow row, Node rowChild, final MCell cell, M
}
vMergeCopies.put(currentColumn, vMergeCopy);
}
-
- return res;
}
/**
diff --git a/tests/org.obeonetwork.m2doc.html.tests/resources/html/table_bug523/doc.html b/tests/org.obeonetwork.m2doc.html.tests/resources/html/table_bug523/doc.html
new file mode 100644
index 000000000..63e21792a
--- /dev/null
+++ b/tests/org.obeonetwork.m2doc.html.tests/resources/html/table_bug523/doc.html
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+ | Jeff |
+ Elon | Bill |
+ Warren |
+
+
+ 1 |
+ 1-5 |
+ 1-3 |
+ 1 |
+ 1 |
+
+
+ 2 |
+ 2-4 |
+ 2 |
+
+
+ 3 |
+ 3-5 |
+
+
+ 4 | 4 |
+
+
+ 5 | 5 | 5 |
+
+
+
+
+
+
diff --git a/tests/org.obeonetwork.m2doc.html.tests/resources/html/table_bug523/table_bug523-expected-ast.txt b/tests/org.obeonetwork.m2doc.html.tests/resources/html/table_bug523/table_bug523-expected-ast.txt
new file mode 100644
index 000000000..3f0e1f694
--- /dev/null
+++ b/tests/org.obeonetwork.m2doc.html.tests/resources/html/table_bug523/table_bug523-expected-ast.txt
@@ -0,0 +1,11 @@
+
+=== HEADER ===
+
+=== BODY ===
+
+ A simple demonstration of a query :
+ [query: .fromHTMLURI('doc.html')]
+ End of demonstration.
+=== FOOTER ===
+
+=== TEMPLATES ===
\ No newline at end of file
diff --git a/tests/org.obeonetwork.m2doc.html.tests/resources/html/table_bug523/table_bug523-expected-generation-messages.txt b/tests/org.obeonetwork.m2doc.html.tests/resources/html/table_bug523/table_bug523-expected-generation-messages.txt
new file mode 100644
index 000000000..e69de29bb
diff --git a/tests/org.obeonetwork.m2doc.html.tests/resources/html/table_bug523/table_bug523-expected-generation.docx b/tests/org.obeonetwork.m2doc.html.tests/resources/html/table_bug523/table_bug523-expected-generation.docx
new file mode 100644
index 000000000..1d9a36746
Binary files /dev/null and b/tests/org.obeonetwork.m2doc.html.tests/resources/html/table_bug523/table_bug523-expected-generation.docx differ
diff --git a/tests/org.obeonetwork.m2doc.html.tests/resources/html/table_bug523/table_bug523-expected-validation.docx b/tests/org.obeonetwork.m2doc.html.tests/resources/html/table_bug523/table_bug523-expected-validation.docx
new file mode 100644
index 000000000..e69de29bb
diff --git a/tests/org.obeonetwork.m2doc.html.tests/resources/html/table_bug523/table_bug523-template.docx b/tests/org.obeonetwork.m2doc.html.tests/resources/html/table_bug523/table_bug523-template.docx
new file mode 100644
index 000000000..119c94fca
Binary files /dev/null and b/tests/org.obeonetwork.m2doc.html.tests/resources/html/table_bug523/table_bug523-template.docx differ
diff --git a/tests/org.obeonetwork.m2doc.html.tests/resources/html/table_bug523/table_bug523.genconf b/tests/org.obeonetwork.m2doc.html.tests/resources/html/table_bug523/table_bug523.genconf
new file mode 100644
index 000000000..33da17551
--- /dev/null
+++ b/tests/org.obeonetwork.m2doc.html.tests/resources/html/table_bug523/table_bug523.genconf
@@ -0,0 +1,2 @@
+
+