diff --git a/plugins/org.obeonetwork.m2doc/src/org/obeonetwork/m2doc/generator/M2DocEvaluator.java b/plugins/org.obeonetwork.m2doc/src/org/obeonetwork/m2doc/generator/M2DocEvaluator.java
index f0988898a..2474ea6a6 100644
--- a/plugins/org.obeonetwork.m2doc/src/org/obeonetwork/m2doc/generator/M2DocEvaluator.java
+++ b/plugins/org.obeonetwork.m2doc/src/org/obeonetwork/m2doc/generator/M2DocEvaluator.java
@@ -1040,8 +1040,9 @@ private XWPFParagraph insertMPagination(XWPFParagraph paragraph, XWPFRun run, MP
final XWPFParagraph res;
switch (mPagination) {
case newColumn:
- insertFieldRunReplacement(paragraph, run, "").addBreak(BreakType.COLUMN);
- res = paragraph;
+ final XWPFRun newColumnRun = insertFieldRunReplacement(paragraph, run, "");
+ newColumnRun.addBreak(BreakType.COLUMN);
+ res = (XWPFParagraph) newColumnRun.getParent();
break;
case newParagraph:
@@ -1049,8 +1050,9 @@ private XWPFParagraph insertMPagination(XWPFParagraph paragraph, XWPFRun run, MP
break;
case newPage:
- insertFieldRunReplacement(paragraph, run, "").addBreak(BreakType.PAGE);
- res = paragraph;
+ final XWPFRun newPageRun = insertFieldRunReplacement(paragraph, run, "");
+ newPageRun.addBreak(BreakType.PAGE);
+ res = (XWPFParagraph) newPageRun.getParent();
break;
case newTableOfContent:
@@ -1064,13 +1066,15 @@ private XWPFParagraph insertMPagination(XWPFParagraph paragraph, XWPFRun run, MP
break;
case newTextWrapping:
- insertFieldRunReplacement(paragraph, run, "").addBreak(BreakType.TEXT_WRAPPING);
- res = paragraph;
+ final XWPFRun newTextWrappingRun = insertFieldRunReplacement(paragraph, run, "");
+ newTextWrappingRun.addBreak(BreakType.TEXT_WRAPPING);
+ res = (XWPFParagraph) newTextWrappingRun.getParent();
break;
case ligneBreak:
- insertFieldRunReplacement(paragraph, run, "").addBreak();
- res = paragraph;
+ final XWPFRun ligneBreakRun = insertFieldRunReplacement(paragraph, run, "");
+ ligneBreakRun.addBreak();
+ res = (XWPFParagraph) ligneBreakRun.getParent();
break;
default:
diff --git a/tests/org.obeonetwork.m2doc.html.tests/resources/m2DocHtmlServices/bug514/Mona_Lisa.jpg b/tests/org.obeonetwork.m2doc.html.tests/resources/m2DocHtmlServices/bug514/Mona_Lisa.jpg
new file mode 100644
index 000000000..967aed40d
Binary files /dev/null and b/tests/org.obeonetwork.m2doc.html.tests/resources/m2DocHtmlServices/bug514/Mona_Lisa.jpg differ
diff --git a/tests/org.obeonetwork.m2doc.html.tests/resources/m2DocHtmlServices/bug514/bug514-expected-ast.txt b/tests/org.obeonetwork.m2doc.html.tests/resources/m2DocHtmlServices/bug514/bug514-expected-ast.txt
new file mode 100644
index 000000000..3f0e1f694
--- /dev/null
+++ b/tests/org.obeonetwork.m2doc.html.tests/resources/m2DocHtmlServices/bug514/bug514-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/m2DocHtmlServices/bug514/bug514-expected-generation-messages.txt b/tests/org.obeonetwork.m2doc.html.tests/resources/m2DocHtmlServices/bug514/bug514-expected-generation-messages.txt
new file mode 100644
index 000000000..e69de29bb
diff --git a/tests/org.obeonetwork.m2doc.html.tests/resources/m2DocHtmlServices/bug514/bug514-expected-generation.docx b/tests/org.obeonetwork.m2doc.html.tests/resources/m2DocHtmlServices/bug514/bug514-expected-generation.docx
new file mode 100644
index 000000000..2219ef17e
Binary files /dev/null and b/tests/org.obeonetwork.m2doc.html.tests/resources/m2DocHtmlServices/bug514/bug514-expected-generation.docx differ
diff --git a/tests/org.obeonetwork.m2doc.html.tests/resources/m2DocHtmlServices/bug514/bug514-expected-validation.docx b/tests/org.obeonetwork.m2doc.html.tests/resources/m2DocHtmlServices/bug514/bug514-expected-validation.docx
new file mode 100644
index 000000000..e69de29bb
diff --git a/tests/org.obeonetwork.m2doc.html.tests/resources/m2DocHtmlServices/bug514/bug514-template.docx b/tests/org.obeonetwork.m2doc.html.tests/resources/m2DocHtmlServices/bug514/bug514-template.docx
new file mode 100644
index 000000000..901187dbf
Binary files /dev/null and b/tests/org.obeonetwork.m2doc.html.tests/resources/m2DocHtmlServices/bug514/bug514-template.docx differ
diff --git a/tests/org.obeonetwork.m2doc.html.tests/resources/m2DocHtmlServices/bug514/bug514.genconf b/tests/org.obeonetwork.m2doc.html.tests/resources/m2DocHtmlServices/bug514/bug514.genconf
new file mode 100644
index 000000000..2c85c7f32
--- /dev/null
+++ b/tests/org.obeonetwork.m2doc.html.tests/resources/m2DocHtmlServices/bug514/bug514.genconf
@@ -0,0 +1,2 @@
+
+
Titre colonne 1 | +Titre colonne 2 | +Titre colonne 3 | +Titre colonne 4 | +Titre colonne 5 | +
cell 1.1 | +cell 1.2 | +cell 1.3 | +cell 1.4 | +cell 1.5 | +
cell 2.1 | +cell 2.2 | +cell 2.3 | +cell 2.4 | +cell 2.5 | +
cell 3.1 | +cell 3.2 | +cell 3.3 | +cell 3.4 | +cell 3.5 | +
cell 4.1 | +cell 4.2 | +cell 4.3 | +cell 4.4 | +cell 4.5 | +