[#11366] - DOCX: Text Field Border Paddings are lost when using Table or List Elements

Category:
Bug report
Priority:
Normal
Status:
Confirmed
Project: Severity:
Minor
Resolution:
Open
Component: Reproducibility:
Always
Assigned to:
0

Hello,

When Text Field Border Paddings values are set with non-zero values and both conditions below are true:
1) Table, List or other report element that produces text in frames (JRPrintFrame), is used;
2) report property "export.docx.frames.as.nested.tables" is set to “false”;
then padding values are lost when generating DOCX report format - all DOCX table cell paddings are set to value "0".

After some investigation we found, that 'JRGridLayout.setFrameCellsStyle' method calls the 'JRBoxUtil.copyBordersNoPadding' method where border paddings are cleared and not restored. The code for values restoration is commented under the 'FIXMEBORDER' comment – it looks like this piece of code is broken.

We solved this issue by overriding JRGridLayout class for restoration of lost cell paddings:

public class OurJRGridLayout extends JRGridLayout {

public OurJRGridLayout(ExporterNature nature, List<JRPrintElement> elements, int width, int height, int offsetX,
int offsetY, CutsInfo xCuts) {
super(nature, elements, width, height, offsetX, offsetY, xCuts);
}

/**
* Restore lost cell paddings.
*/
@Override
protected JRExporterGridCell changeStyle(JRExporterGridCell cell, GridCellStyle newStyle) {
JRLineBox oldBox = (cell != null ? cell.getBox() : null);
JRLineBox newBox = (newStyle != null ? newStyle.getBox() : null);
if (oldBox != null && newBox != null) {
if (oldBox.getPadding() != null) {
newBox.setPadding(oldBox.getPadding());
}
if (oldBox.getTopPadding() != null) {
newBox.setTopPadding(oldBox.getTopPadding());
}
if (oldBox.getBottomPadding() != null) {
newBox.setBottomPadding(oldBox.getBottomPadding());
}
if (oldBox.getLeftPadding() != null) {
newBox.setLeftPadding(oldBox.getLeftPadding());
}
if (oldBox.getRightPadding() != null) {
newBox.setRightPadding(oldBox.getRightPadding());
}
}
return super.changeStyle(cell, newStyle);
}

}

v6.4.3
laimutisign's picture
Joined: Nov 16 2018 - 3:47am
Last seen: 1 month 3 weeks ago

2 Comments:

#1
  • Status:New» Confirmed
Feedback
randomness