From c18b42b9bcd8276b7e3e159045c87a5af1a96714 Mon Sep 17 00:00:00 2001 From: Smruti Prakash Sahoo Date: Fri, 11 Dec 2020 15:30:06 +0530 Subject: [PATCH] fix(clearingreport): Error while downloading clearing report Signed-off-by: Smruti Prakash Sahoo --- .../licenseinfo/outputGenerators/DocxUtils.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/backend/src/src-licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/outputGenerators/DocxUtils.java b/backend/src/src-licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/outputGenerators/DocxUtils.java index 1628e492cb..ac092c9a77 100644 --- a/backend/src/src-licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/outputGenerators/DocxUtils.java +++ b/backend/src/src-licenseinfo/src/main/java/org/eclipse/sw360/licenseinfo/outputGenerators/DocxUtils.java @@ -15,6 +15,7 @@ import org.apache.commons.lang.StringUtils; import org.apache.poi.xwpf.usermodel.*; import org.apache.xmlbeans.XmlException; +import org.eclipse.sw360.datahandler.common.CommonUtils; import org.openxmlformats.schemas.wordprocessingml.x2006.main.*; import java.math.BigInteger; @@ -66,11 +67,15 @@ public static void addPageBreak(XWPFDocument document) { } public static void setText(XWPFRun run, String text) { - String[] split = text.split("\n"); - run.setText(split[0]); - for (int i = 1; i < split.length; i++) { - run.addBreak(); - run.setText(split[i]); + if (CommonUtils.isNullEmptyOrWhitespace(text)) { + run.setText(""); + } else { + String[] split = text.split("\n"); + run.setText(split[0]); + for (int i = 1; i < split.length; i++) { + run.addBreak(); + run.setText(split[i]); + } } }