From: Jeremias Maerki Date: Thu, 9 Feb 2006 08:54:06 +0000 (+0000) Subject: Bugfix: padding-top and padding-bottom on list-items could lead to wrong page break... X-Git-Tag: fop-0_92-beta~139 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=88879d05069e6d5fff9da743bd08f77d3a883f22;p=xmlgraphics-fop.git Bugfix: padding-top and padding-bottom on list-items could lead to wrong page break decisions and thus to overlapping text. Bugfix: break-before and break-after were ignored on list-items. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@376226 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java index eb7a2599c..5c57796ce 100644 --- a/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java @@ -1,5 +1,5 @@ /* - * Copyright 1999-2005 The Apache Software Foundation. + * Copyright 1999-2006 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -338,11 +338,6 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager contentList.addAll(returnedList); if (((ListElement) returnedList.getLast()).isForcedBreak()) { // a descendant of this block has break-after - if (curLM.isFinished()) { - // there is no other content in this block; - // it's useless to add space after before a page break - setFinished(true); - } /* extension: conversione di tutta la sequenza fin'ora ottenuta */ if (bpUnit > 0) { @@ -356,11 +351,6 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager return returnList; } - /* - if (allocatedSpace.min > context.getStackLimit().max) { - log.debug("Allocated space exceeds stack limit, returning early."); - return returnList; - }*/ } // propagate and clear context.setFlags(LayoutContext.KEEP_WITH_NEXT_PENDING, childLC.isKeepWithNextPending()); @@ -863,6 +853,8 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager /** * Creates Knuth elements for before border padding and adds them to the return list. * @param returnList return list to add the additional elements to + * @param isFirst true if this is the first time a layout manager instance needs to generate + * border and padding */ protected void addKnuthElementsForBorderPaddingBefore(LinkedList returnList, boolean isFirst) { //Border and Padding (before) @@ -888,6 +880,8 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager /** * Creates Knuth elements for after border padding and adds them to the return list. * @param returnList return list to add the additional elements to + * @param isLast true if this is the last time a layout manager instance needs to generate + * border and padding */ protected void addKnuthElementsForBorderPaddingAfter(LinkedList returnList, boolean isLast) { //Border and Padding (after) @@ -913,6 +907,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager /** * Creates Knuth elements for break-before and adds them to the return list. * @param returnList return list to add the additional elements to + * @param context the layout context * @return true if an element has been added due to a break-before. */ protected boolean addKnuthElementsForBreakBefore(LinkedList returnList, @@ -922,6 +917,10 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager breakBefore = ((org.apache.fop.fo.flow.Block) fobj).getBreakBefore(); } else if (fobj instanceof org.apache.fop.fo.flow.BlockContainer) { breakBefore = ((org.apache.fop.fo.flow.BlockContainer) fobj).getBreakBefore(); + } else if (fobj instanceof org.apache.fop.fo.flow.ListBlock) { + breakBefore = ((org.apache.fop.fo.flow.ListBlock) fobj).getBreakBefore(); + } else if (fobj instanceof org.apache.fop.fo.flow.ListItem) { + breakBefore = ((org.apache.fop.fo.flow.ListItem) fobj).getBreakBefore(); } else if (fobj instanceof org.apache.fop.fo.flow.Table) { breakBefore = ((org.apache.fop.fo.flow.Table) fobj).getBreakBefore(); } @@ -932,8 +931,6 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager // return a penalty element, representing a forced page break returnList.add(new BreakElement(getAuxiliaryPosition(), 0, -KnuthElement.INFINITE, breakBefore, context)); - //returnList.add(new KnuthPenalty(0, -KnuthElement.INFINITE, false, - // breakBefore, getAuxiliaryPosition(), false)); return true; } else { return false; @@ -943,6 +940,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager /** * Creates Knuth elements for break-after and adds them to the return list. * @param returnList return list to add the additional elements to + * @param context the layout context * @return true if an element has been added due to a break-after. */ protected boolean addKnuthElementsForBreakAfter(LinkedList returnList, @@ -952,6 +950,10 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager breakAfter = ((org.apache.fop.fo.flow.Block) fobj).getBreakAfter(); } else if (fobj instanceof org.apache.fop.fo.flow.BlockContainer) { breakAfter = ((org.apache.fop.fo.flow.BlockContainer) fobj).getBreakAfter(); + } else if (fobj instanceof org.apache.fop.fo.flow.ListBlock) { + breakAfter = ((org.apache.fop.fo.flow.ListBlock) fobj).getBreakAfter(); + } else if (fobj instanceof org.apache.fop.fo.flow.ListItem) { + breakAfter = ((org.apache.fop.fo.flow.ListItem) fobj).getBreakAfter(); } else if (fobj instanceof org.apache.fop.fo.flow.Table) { breakAfter = ((org.apache.fop.fo.flow.Table) fobj).getBreakAfter(); } @@ -962,8 +964,6 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager // add a penalty element, representing a forced page break returnList.add(new BreakElement(getAuxiliaryPosition(), 0, -KnuthElement.INFINITE, breakAfter, context)); - //returnList.add(new KnuthPenalty(0, -KnuthElement.INFINITE, false, - // breakAfter, getAuxiliaryPosition(), false)); return true; } else { return false; diff --git a/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java b/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java index c402f37ae..d9bbd18f6 100644 --- a/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java @@ -179,8 +179,21 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager LinkedList returnList = new LinkedList(); + if (!breakBeforeServed) { + try { + if (addKnuthElementsForBreakBefore(returnList, context)) { + return returnList; + } + } finally { + breakBeforeServed = true; + } + } + addKnuthElementsForSpaceBefore(returnList, alignment); + addKnuthElementsForBorderPaddingBefore(returnList, !firstVisibleMarkServed); + firstVisibleMarkServed = true; + //Spaces, border and padding to be repeated at each break addPendingMarks(context); @@ -222,7 +235,9 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager // "wrap" the Position inside each element wrapPositionElements(returnedList, returnList, true); + addKnuthElementsForBorderPaddingAfter(returnList, true); addKnuthElementsForSpaceAfter(returnList, alignment); + addKnuthElementsForBreakAfter(returnList, context); if (keepWithNextPendingOnLabel || keepWithNextPendingOnBody || mustKeepWithNext()) { context.setFlags(LayoutContext.KEEP_WITH_NEXT_PENDING); diff --git a/status.xml b/status.xml index 1c82a06bc..89aa4492c 100644 --- a/status.xml +++ b/status.xml @@ -27,6 +27,13 @@ + + Bugfix: padding-top and padding-bottom on list-items could lead to wrong page + break decisions and thus to overlapping text. + + + Bugfix: break-before and break-after were ignored on list-items. + Bugfix: The elements representing a non-breaking space weren't always correct. diff --git a/test/layoutengine/standard-testcases/list-item_break-before_break-after.xml b/test/layoutengine/standard-testcases/list-item_break-before_break-after.xml new file mode 100644 index 000000000..b74f27497 --- /dev/null +++ b/test/layoutengine/standard-testcases/list-item_break-before_break-after.xml @@ -0,0 +1,83 @@ + + + + + +

+ This test checks element list generation with breaks on list-items. +

+
+ + + + + + + + + + + + + label 1 + + + + body 1: We'll break after this yellow list item. + + + + + + label 2 + + + + body 2: This is just a boring list item. + + + + + + label 3 + + + + body 3: We had a break before this orange list item. + + + + + + + + + + + + 3 + + + + 3 + + + + 3 + + +
diff --git a/test/layoutengine/standard-testcases/list-item_padding.xml b/test/layoutengine/standard-testcases/list-item_padding.xml new file mode 100644 index 000000000..fa76cdef1 --- /dev/null +++ b/test/layoutengine/standard-testcases/list-item_padding.xml @@ -0,0 +1,82 @@ + + + + + +

+ This test checks element list generation with padding in lists (list-item). +

+
+ + + + + + + + + + + + + label 1 + + + + body 1: We should have 5pt padding-before and 8pt padding-after for this yellow list item. + + + + + + label 2 + + + + body 2: We should have 5pt padding-before and 8pt padding-after for this list item. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 3 + + +