From 9318fb5d17ba087e5c32564f99e4506555e4634d Mon Sep 17 00:00:00 2001 From: Vincent Hennebert Date: Mon, 9 Jul 2007 16:59:42 +0000 Subject: [PATCH] Use a prevIsBox boolean instead of duplicating the list of Knuth elements for active cells into an ArrayList git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@554709 13f79535-47bb-0310-9956-ffa450edef68 --- .../fop/layoutmgr/table/TableStepper.java | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/java/org/apache/fop/layoutmgr/table/TableStepper.java b/src/java/org/apache/fop/layoutmgr/table/TableStepper.java index 59228ce00..49b98f101 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableStepper.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableStepper.java @@ -44,6 +44,7 @@ public class TableStepper { private PrimaryGridUnit pgu; /** Knuth elements for this active cell. */ private List elementList; + private boolean prevIsBox = false; /** Number of the row where the row-span begins, zero-based. */ private int startRow; /** Index, in the list of Knuth elements, of the element starting the current step. */ @@ -89,7 +90,7 @@ public class TableStepper { } else { //Copy elements (LinkedList) to array lists to improve //element access performance - elementList = new java.util.ArrayList(pgu.getElements()); + elementList = pgu.getElements(); // if (log.isTraceEnabled()) { // log.trace("column " + (column+1) + ": recording " + elementLists.size() + " element(s)"); // } @@ -140,25 +141,27 @@ public class TableStepper { private void goToNextLegalBreak() { lastPenaltyLength = 0; - while (end + 1 < elementList.size()) { + boolean breakFound = false; + while (!breakFound && end + 1 < elementList.size()) { end++; KnuthElement el = (KnuthElement)elementList.get(end); if (el.isPenalty()) { + prevIsBox = false; if (el.getP() < KnuthElement.INFINITE) { //First legal break point lastPenaltyLength = el.getW(); - break; + breakFound = true; } } else if (el.isGlue()) { - if (end > 0) { - KnuthElement prev = (KnuthElement)elementList.get(end - 1); - if (prev.isBox()) { - //Second legal break point - break; - } + if (prevIsBox) { + //Second legal break point + breakFound = true; + } else { + width += el.getW(); } - width += el.getW(); + prevIsBox = false; } else { + prevIsBox = true; width += el.getW(); } } -- 2.39.5