Skip to content

Commit

Permalink
Fix data item leading whitespace preserve #1536 (#1539)
Browse files Browse the repository at this point in the history
  • Loading branch information
hvbtup authored Jan 11, 2024
1 parent bb4fc62 commit 76af50f
Showing 1 changed file with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.eclipse.birt.report.engine.content.IStyle;
import org.eclipse.birt.report.engine.content.ITextContent;
import org.eclipse.birt.report.engine.css.engine.StyleConstants;
import org.eclipse.birt.report.engine.css.engine.value.DataFormatValue;
import org.eclipse.birt.report.engine.css.engine.value.css.CSSValueConstants;
import org.eclipse.birt.report.engine.layout.pdf.util.PropertyUtil;
import org.eclipse.birt.report.engine.nLayout.LayoutContext;
Expand Down Expand Up @@ -138,19 +139,27 @@ public void align(boolean endParagraph, LayoutContext context) {
Iterator<IArea> iter = getChildren();
while (iter.hasNext()) {
AbstractArea area = (AbstractArea) iter.next();
area.setPosition(spacing / 2 + area.getX() - adjustLeftWhiteSpace + adjustRightWhiteSpace,
area.getY());
area.setPosition(spacing / 2 + area.getX() - adjustLeftWhiteSpace + adjustRightWhiteSpace, area.getY());
}
} else if (isJustified) {
justify(spacing, adjustLeftWhiteSpace, adjustRightWhiteSpace);
} else {
// is left aligned
if (parent.content != null && !parent.content.isDirectionRTL()) {
if (adjustLeftWhiteSpace != 0) {
Iterator<IArea> iter = getChildren();
while (iter.hasNext()) {
AbstractArea area = (AbstractArea) iter.next();
area.setPosition(area.getX() - adjustLeftWhiteSpace, area.getY());
String sp = null;
DataFormatValue dfv = parent.content.getComputedStyle().getDataFormat();
if (dfv != null) {
sp = dfv.getStringPattern();
}
if (sp == null || !sp.startsWith("^")) {
Iterator<IArea> iter = getChildren();
while (iter.hasNext()) {
AbstractArea area = (AbstractArea) iter.next();
area.setPosition(area.getX() - adjustLeftWhiteSpace, area.getY());
}
} else {
// Do not adjust (see https://github.com/eclipse-birt/birt/discussions/1536)
}
}
}
Expand Down Expand Up @@ -335,7 +344,6 @@ private IntTupleCounter countCharactersAndWhiteSpace(ContainerArea area) {
return count;
}


protected void justify(int spacing, int adjustLeftWhiteSpace, int adjustRightWhiteSpace) {
// 1. Gets the white space number. The last white space of a line should not be
// counted.
Expand Down

0 comments on commit 76af50f

Please sign in to comment.