Skip to content

Commit

Permalink
Fixed #418 Empty AQL expressions generate empty lines.
Browse files Browse the repository at this point in the history
  • Loading branch information
ylussaud committed Sep 6, 2024
1 parent 6e0b707 commit c2b9f71
Show file tree
Hide file tree
Showing 47 changed files with 51 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -698,33 +698,57 @@ private XWPFParagraph insertObject(XWPFParagraph paragraph, Object object, XWPFR
insertMImage(imageParagraph, imageRun, (MImage) object);
res = imageParagraph;
} else {
// nothing to do here
res = paragraph;
}
} else if (object instanceof MText) {
res = (XWPFParagraph) insertMText(paragraph, run, (MText) object).getParent();
if (((MText) object).getText() != null && !((MText) object).getText().isEmpty()) {
res = (XWPFParagraph) insertMText(paragraph, run, (MText) object).getParent();
} else {
// nothing to do here
res = paragraph;
}
} else if (object instanceof MTable) {
if (!((MTable) object).getRows().isEmpty()) {
if (!((MTable) object).getRows().isEmpty() && ((MTable) object).getColumnsCount() != 0) {
XWPFRun tableRun = run;
tableRun.getCTR().getInstrTextList().clear();
insertMTable(tableRun, (MTable) object);
res = (XWPFParagraph) tableRun.getParent();
} else {
// nothing to do here
res = paragraph;
}
} else if (object instanceof MPagination) {
res = insertMPagination(paragraph, run, (MPagination) object);
} else if (object instanceof MParagraph) {
res = insertMParagraph(generatedDocument, (MParagraph) object, run);
} else if (object instanceof IBody) {
final XWPFRun bodyRun = insertFieldRunReplacement(paragraph, run, "");
res = insertBody((XWPFParagraph) bodyRun.getParent(), (IBody) object);
if (!((IBody) object).getBodyElements().isEmpty()) {
final XWPFRun bodyRun = insertFieldRunReplacement(paragraph, run, "");
res = insertBody((XWPFParagraph) bodyRun.getParent(), (IBody) object);
} else {
// nothing to do here
res = paragraph;
}
} else if (object instanceof GenerationResult) {
final XWPFRun generationRun = insertFieldRunReplacement(paragraph, run, "");
res = insertGenerationResult((XWPFParagraph) generationRun.getParent(), (GenerationResult) object);
if (!((GenerationResult) object).getBody().getBodyElements().isEmpty()) {
final XWPFRun generationRun = insertFieldRunReplacement(paragraph, run, "");
res = insertGenerationResult((XWPFParagraph) generationRun.getParent(), (GenerationResult) object);
} else {
// nothing to do here
res = paragraph;
}
} else if (object == null) {
res = (XWPFParagraph) insertFieldRunReplacement(paragraph, run, "").getParent();
// nothing to do here
res = paragraph;
} else {
res = (XWPFParagraph) insertFieldRunReplacement(paragraph, run, object.toString()).getParent();
final String stringValue = object.toString();
if (stringValue != null && !stringValue.isEmpty()) {
res = (XWPFParagraph) insertFieldRunReplacement(paragraph, run, stringValue).getParent();
} else {
// nothing to do here
res = paragraph;
}
}

return res;
Expand All @@ -744,9 +768,9 @@ private XWPFParagraph insertGenerationResult(XWPFParagraph paragraph, Generation
result.addMessage(message);
}

final XWPFParagraph insertBody = insertBody(paragraph, generationResult.getBody());
currentGeneratedParagraph = insertBody;
return insertBody;
final XWPFParagraph res = insertBody(paragraph, generationResult.getBody());
currentGeneratedParagraph = res;
return res;
}

/**
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

=== HEADER ===

=== BODY ===

A simple demonstration of a template :
[query: .myTemplate(2)]
End of demonstration.
=== FOOTER ===

=== TEMPLATES ===

template myTemplate (a : java.lang.Integer)
[query: null]
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="ASCII"?>
<genconf:Generation xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:genconf="http://www.obeonetwork.org/m2doc/genconf/1.0" name="nominal" templateFileName="nominal-template.docx" resultFileName="nominal-actual-generation.docx" validationFileName="nominal-actual-validation.docx"/>
Binary file not shown.
Binary file not shown.

0 comments on commit c2b9f71

Please sign in to comment.