Skip to content

Commit

Permalink
Fix area line margin-top of first line after page break (#1443) (#1449)
Browse files Browse the repository at this point in the history
* Fix area line margin-top of first line after page break (#1443)

* Remove debug comment
  • Loading branch information
speckyspooky authored Oct 14, 2023
1 parent 8f196c5 commit 5c22cbe
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,6 @@ protected AbstractArea createNewArea(ContainerArea parent, LayoutContext context
} else {
area = new BlockContainerArea(parent, context, content);
}
if (context.isFixedLayout()) {
area.setPageBreakInside(IStyle.AVOID_VALUE);
}
return area;

case IContent.IMAGE_CONTENT:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,45 +290,45 @@ protected SplitResult _split(int height, boolean force) throws BirtException {
result.add(current);
continue;
}
contentHeight -= ah;
int childSplitHeight = cheight - contentHeight;
SplitResult splitResult = current.split(childSplitHeight, force && !isValidResult(result));
if (splitResult.status == SplitResult.SPLIT_SUCCEED_WITH_PART) {
ContainerArea splitChildArea = splitResult.getResult();
result.add(splitChildArea);
status = SplitResult.SPLIT_SUCCEED_WITH_PART;
contentHeight += splitChildArea.getAllocatedHeight();
break;
} else if (splitResult.status == SplitResult.SPLIT_BEFORE_AVOID_WITH_NULL) {
if (force) {
if (result.size() > 0) {
status = SplitResult.SPLIT_SUCCEED_WITH_PART;
}
contentHeight -= ah;
int childSplitHeight = cheight - contentHeight;
SplitResult splitResult = current.split(childSplitHeight, force && !isValidResult(result));
if (splitResult.status == SplitResult.SPLIT_SUCCEED_WITH_PART) {
ContainerArea splitChildArea = splitResult.getResult();
result.add(splitChildArea);
status = SplitResult.SPLIT_SUCCEED_WITH_PART;
contentHeight += splitChildArea.getAllocatedHeight();
break;
} else if (splitResult.status == SplitResult.SPLIT_BEFORE_AVOID_WITH_NULL) {
if (force) {
if (result.size() > 0) {
status = SplitResult.SPLIT_SUCCEED_WITH_PART;
}
break;
} else if (splitResult.status == SplitResult.SPLIT_SUCCEED_WITH_NULL) {
if (isValidResult(result)) {
if (force) {
status = SplitResult.SPLIT_SUCCEED_WITH_PART;
break;
}
if (previous.isPageBreakAfterAvoid()) {
status = SplitResult.SPLIT_BEFORE_AVOID_WITH_NULL;
break;
}
}
break;
} else if (splitResult.status == SplitResult.SPLIT_SUCCEED_WITH_NULL) {
if (isValidResult(result)) {
if (force) {
status = SplitResult.SPLIT_SUCCEED_WITH_PART;
break;
} else if (force) {
// error status
status = SplitResult.SPLIT_SUCCEED_WITH_PART;
}
if (previous.isPageBreakAfterAvoid()) {
status = SplitResult.SPLIT_BEFORE_AVOID_WITH_NULL;
break;
} else {
if (isPageBreakBeforeAvoid()) {
return SplitResult.BEFORE_AVOID_WITH_NULL;
}
return SplitResult.SUCCEED_WITH_NULL;
}
status = SplitResult.SPLIT_SUCCEED_WITH_PART;
break;
} else if (force) {
// error status
status = SplitResult.SPLIT_SUCCEED_WITH_PART;
break;
} else {
if (isPageBreakBeforeAvoid()) {
return SplitResult.BEFORE_AVOID_WITH_NULL;
}
return SplitResult.SUCCEED_WITH_NULL;
}
}
}
// split height is larger than content height.(cell)
if (result.size() == children.size()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,9 @@ public void setAllocatedHeight(int aHeight) {
}

/**
* Get content height
* Get content height, that is the height available for the content.
*
* This is computed as allocatedHeight minus bottom/top margin/border/padding. *
*
* @param allocatedHeight
* @return Return the content height
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,13 @@ public SplitResult split(int height, boolean force) throws BirtException {
result.addChild(splitChildArea);
splitChildArea.setParent(result);
} else {
// reset the line height due to negative height caused by page break.
// Otherwise the first line could be rendered too far down.
// See (old) BIRT bug 562873 and
// https://github.com/eclipse-birt/birt/issues/1443.
if (height < 0) {
height = 0;
}
child.setY(Math.max(0, child.getY() - height));
}
}
Expand Down

0 comments on commit 5c22cbe

Please sign in to comment.