From 725e1eb9093f64f56ed9daf147e379c75fc9a00d Mon Sep 17 00:00:00 2001 From: Jeremias Maerki Date: Wed, 30 Nov 2005 08:52:26 +0000 Subject: Bugfix: Added missing conditionality notification for table-cell content. Extracted functionality to find a previous break into a helper method in ElementListUtils. Fixed misguided german->english translation on parameter names (last != previous). git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@349909 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/fop/layoutmgr/ElementListUtils.java | 19 ++++++++++++++ .../org/apache/fop/layoutmgr/SpaceResolver.java | 8 +++--- .../fop/layoutmgr/list/ListItemLayoutManager.java | 29 ++++++---------------- .../layoutmgr/table/TableContentLayoutManager.java | 4 +++ status.xml | 13 ++++++++++ 5 files changed, 47 insertions(+), 26 deletions(-) diff --git a/src/java/org/apache/fop/layoutmgr/ElementListUtils.java b/src/java/org/apache/fop/layoutmgr/ElementListUtils.java index c4fd42a35..e68698e57 100644 --- a/src/java/org/apache/fop/layoutmgr/ElementListUtils.java +++ b/src/java/org/apache/fop/layoutmgr/ElementListUtils.java @@ -146,4 +146,23 @@ public class ElementListUtils { return last.isForcedBreak(); } + /** + * Determines the position of the previous break before the start index on an + * element list. + * @param elems the element list + * @param startIndex the start index + * @return the position of the previous break, or -1 if there was no previous break + */ + public static int determinePreviousBreak(List elems, int startIndex) { + int prevBreak = startIndex - 1; + while (prevBreak >= 0) { + KnuthElement el = (KnuthElement)elems.get(prevBreak); + if (el.isPenalty() && el.getP() < KnuthElement.INFINITE) { + break; + } + prevBreak--; + } + return prevBreak; + } + } diff --git a/src/java/org/apache/fop/layoutmgr/SpaceResolver.java b/src/java/org/apache/fop/layoutmgr/SpaceResolver.java index 45e9990ea..583f8ffaa 100644 --- a/src/java/org/apache/fop/layoutmgr/SpaceResolver.java +++ b/src/java/org/apache/fop/layoutmgr/SpaceResolver.java @@ -692,14 +692,14 @@ public class SpaceResolver { * @param effectiveList the effective element list * @param startElementIndex index of the first element in the part to be processed * @param endElementIndex index of the last element in the part to be processed - * @param lastBreak index of the the break possibility just before this part (used to + * @param prevBreak index of the the break possibility just before this part (used to * identify a break condition, lastBreak <= 0 represents a no-break condition) */ public static void performConditionalsNotification(List effectiveList, - int startElementIndex, int endElementIndex, int lastBreak) { + int startElementIndex, int endElementIndex, int prevBreak) { KnuthElement el = null; - if (lastBreak > 0) { - el = (KnuthElement)effectiveList.get(lastBreak); + if (prevBreak > 0) { + el = (KnuthElement)effectiveList.get(prevBreak); } SpaceResolver.SpaceHandlingBreakPosition beforeBreak = null; SpaceResolver.SpaceHandlingBreakPosition afterBreak = null; diff --git a/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java b/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java index 5a98deac6..0ed202c6f 100644 --- a/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java @@ -461,30 +461,15 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager int bodyFirstIndex = ((ListItemPosition) positionList.getFirst()).getBodyFirstIndex(); int bodyLastIndex = ((ListItemPosition) positionList.getLast()).getBodyLastIndex(); - int lastBreak; - //Determine last break if any - lastBreak = labelFirstIndex - 1; - while (lastBreak >= 0) { - KnuthElement el = (KnuthElement)labelList.get(lastBreak); - if (el.isPenalty() && el.getP() < KnuthElement.INFINITE) { - break; - } - lastBreak--; - } + //Determine previous break if any + int previousBreak = ElementListUtils.determinePreviousBreak(labelList, labelFirstIndex); SpaceResolver.performConditionalsNotification(labelList, - labelFirstIndex, labelLastIndex, lastBreak); - - //Determine last break if any - lastBreak = bodyFirstIndex - 1; - while (lastBreak >= 0) { - KnuthElement el = (KnuthElement)bodyList.get(lastBreak); - if (el.isPenalty() && el.getP() < KnuthElement.INFINITE) { - break; - } - lastBreak--; - } + labelFirstIndex, labelLastIndex, previousBreak); + + //Determine previous break if any + previousBreak = ElementListUtils.determinePreviousBreak(labelList, labelFirstIndex); SpaceResolver.performConditionalsNotification(bodyList, - bodyFirstIndex, bodyLastIndex, lastBreak); + bodyFirstIndex, bodyLastIndex, previousBreak); // add label areas if (labelFirstIndex <= labelLastIndex) { diff --git a/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java index 99028d915..9fabeccc5 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java @@ -49,6 +49,7 @@ import org.apache.fop.layoutmgr.ListElement; import org.apache.fop.layoutmgr.MinOptMaxUtil; import org.apache.fop.layoutmgr.Position; import org.apache.fop.layoutmgr.PositionIterator; +import org.apache.fop.layoutmgr.SpaceResolver; import org.apache.fop.layoutmgr.TraitSetter; import org.apache.fop.layoutmgr.SpaceResolver.SpaceHandlingBreakPosition; import org.apache.fop.traits.MinOptMax; @@ -948,6 +949,9 @@ public class TableContentLayoutManager implements PercentBaseContext { cellLM.setContentHeight(contentHeight); cellLM.setRowHeight(effCellHeight); //cellLM.setRowHeight(row.getHeight().opt); + int prevBreak = ElementListUtils.determinePreviousBreak(pgu.getElements(), startPos); + SpaceResolver.performConditionalsNotification(pgu.getElements(), + startPos, endPos, prevBreak); cellLM.addAreas(new KnuthPossPosIter(pgu.getElements(), startPos, endPos + 1), layoutContext); } diff --git a/status.xml b/status.xml index 20e120e6a..a6a1e7334 100644 --- a/status.xml +++ b/status.xml @@ -27,6 +27,19 @@ + + Bugfix: Space resolution was incomplete for content in table-cells. Conditional elements + didn't get removed. + + + The validation check for non-zero borders and padding on a region-* is now turned off + when relaxed validation is active to improve compatibility with FO documents written + for other FO implementations. + + + Bugfix for "/ by zero" ArithmeticExceptions when an URL to a non-existing image is used + and content-width and/or content-height is used. + Bugfix for a multi-threading problem: propertyListTable initialization moved from the constructor to a static block in FONode. -- cgit v1.2.3