xmlgraphics-fop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vhenneb...@apache.org
Subject svn commit: r554690 - in /xmlgraphics/fop/trunk: src/java/org/apache/fop/layoutmgr/table/TableStepper.java test/layoutengine/standard-testcases/table_border-collapse_separate_border-spacing_2.xml
Date Mon, 09 Jul 2007 16:00:52 GMT
Author: vhennebert
Date: Mon Jul  9 09:00:51 2007
New Revision: 554690

URL: http://svn.apache.org/viewvc?view=rev&rev=554690
Log:
Use a list of active cells for computing steps, continued:
- remove the need for backupWidth
- handle the iteration over the cell's Knuth element inside the active cell itself
- improve the computation of the remaining height (a testcase needed to be updated; no visual
change, only the values for the boxes/penalties which lead to the same result)

Modified:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/TableStepper.java
    xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/table_border-collapse_separate_border-spacing_2.xml

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/TableStepper.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/TableStepper.java?view=diff&rev=554690&r1=554689&r2=554690
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/TableStepper.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/TableStepper.java Mon Jul
 9 09:00:51 2007
@@ -55,8 +55,9 @@
          * current one.
          */
         private int width;
-        private int backupWidth;
         private int baseWidth;
+        private int totalLength;
+        private int includedLength;
         private int borderBefore;
         private int borderAfter;
         private int paddingBefore;
@@ -93,9 +94,12 @@
 //                    log.trace("column " + (column+1) + ": recording " + elementLists.size()
+ " element(s)");
 //                }
             }
+            totalLength = ElementListUtils.calcContentLength(elementList);
             if (pgu.getTable().isSeparateBorderModel()) {
-                borderBefore = pgu.getBorders().getBorderBeforeWidth(false) + tableLM.getHalfBorderSeparationBPD();
-                borderAfter = pgu.getBorders().getBorderAfterWidth(false) + tableLM.getHalfBorderSeparationBPD();
+                borderBefore = pgu.getBorders().getBorderBeforeWidth(false)
+                        + tableLM.getHalfBorderSeparationBPD();
+                borderAfter = pgu.getBorders().getBorderAfterWidth(false)
+                        + tableLM.getHalfBorderSeparationBPD();
             } else {
                 borderBefore = pgu.getHalfMaxBeforeBorderWidth();
                 borderAfter = pgu.getHalfMaxAfterBorderWidth();
@@ -104,17 +108,19 @@
             paddingAfter = pgu.getBorders().getPaddingAfter(false, pgu.getCellLM());
             start = 0;
             end = -1;
-            width = 0;
             startRow = rowIndex;
             keepWithNextSignal = false;
             computeBaseWidth(rowGroup);
+            goToNextLegalBreak();
         }
 
         private void computeBaseWidth(EffRow[] rowGroup) {
-            baseWidth = 0;
+            width = 0;
+            includedLength = 0;
             for (int prevRow = 0; prevRow < startRow; prevRow++) {
-                baseWidth += rowGroup[prevRow].getHeight().opt;
+                width += rowGroup[prevRow].getHeight().opt;
             }
+            baseWidth = width;
         }
 
         private boolean endsOnRow(int rowIndex) {
@@ -122,29 +128,17 @@
         }
 
         int getRemainingHeight(int activeRowIndex, EffRow[] rowGroup) {
-            if (end == elementList.size() - 1) {
-                return 0;
-            }
             if (!endsOnRow(activeRowIndex)) {
                 return 0;
+            } else if (includedLength == totalLength) {
+                return 0;
+            } else {
+                return totalLength - includedLength
+                        + borderBefore + borderAfter + paddingBefore + paddingAfter;
             }
-            int len = width;
-            if (len > 0) {
-                len += borderBefore + borderAfter;
-                len += paddingBefore + paddingAfter;
-            }
-            int nominalHeight = 0;
-            for (int r = startRow; r < startRow + pgu.getCell().getNumberRowsSpanned();
r++) {
-                nominalHeight += rowGroup[r].getHeight().opt;
-            }
-            return nominalHeight - len;
         }
 
-        void backupWidth() {
-            backupWidth = width;
-        }
-
-        int getNextStep() {
+        private void goToNextLegalBreak() {
             lastPenaltyLength = 0;
             while (end + 1 < elementList.size()) {
                 end++;
@@ -168,34 +162,51 @@
                     width += el.getW();
                 }
             }
-            if (end < start) {
-//              if (log.isTraceEnabled()) {
-//              log.trace("column " + (i + 1) + ": (end=" + end + ") < (start=" + start
-//              + ") => resetting width to backupWidth");
-//              }
-                width = backupWidth;
-                return 0;
+        }
+
+        int getNextStep() {
+            if (!includedInLastStep()) {
+                return width + borderBefore + borderAfter + paddingBefore + paddingAfter;
             } else {
-                return baseWidth + width + borderBefore + borderAfter + paddingBefore
-                        + paddingAfter;
+                start = end + 1;
+                if (end < elementList.size() - 1) {
+
+                    goToNextLegalBreak();
+                    return width + borderBefore + borderAfter + paddingBefore + paddingAfter;

+                } else {
+                    return 0;
+                }
             }
         }
 
+        private boolean includedInLastStep() {
+            return includedLength == width;
+        }
+
         boolean signalMinStep(int minStep) {
-            int len = baseWidth + width + borderBefore + borderAfter + paddingBefore + paddingAfter;
-            if (len > minStep) {
-                width = backupWidth;
-                end = start - 1;
-                return baseWidth + borderBefore + borderAfter + paddingBefore
-                        + paddingAfter + width > minStep;
-            } else {
+            if (width + borderBefore + borderAfter + paddingBefore + paddingAfter <= minStep)
{
+                includedLength = width;
                 return false;
+            } else {
+                return baseWidth + borderBefore + borderAfter + paddingBefore + paddingAfter
> minStep;
             }
         }
 
+        boolean contributesContent() {
+            return includedInLastStep() && end >= start;
+        }
+
+        boolean hasStarted() {
+            return includedLength > 0;
+        }
+
         int getLastPenaltyLength() {
             return lastPenaltyLength;
         }
+
+        boolean isFinished() {
+            return includedInLastStep() && (end == elementList.size() - 1);
+        }
     }
     /** Logger **/
     private static Log log = LogFactory.getLog(TableStepper.class);
@@ -330,7 +341,7 @@
             List gridUnitParts = new java.util.ArrayList(maxColumnCount);
             for (Iterator iter = activeCells.iterator(); iter.hasNext();) {
                 ActiveCell activeCell = (ActiveCell) iter.next();
-                if (activeCell.end >= activeCell.start) {
+                if (activeCell.contributesContent()) {
                     PrimaryGridUnit pgu = activeCell.pgu;
                     if (activeCell.start == 0 && activeCell.end == 0
                             && activeCell.elementList.size() == 1
@@ -414,9 +425,7 @@
             signalKeepWithNext = false;
             for (Iterator iter = activeCells.iterator(); iter.hasNext();) {
                 ActiveCell activeCell = (ActiveCell) iter.next();
-                if (activeCell.start == 0 && activeCell.end < 0 && activeCell.elementList
!= null) {
-                    allCellsHaveContributed = false;
-                }
+                allCellsHaveContributed &= activeCell.hasStarted();
                 signalKeepWithNext |= activeCell.keepWithNextSignal;
             }
             if (!allCellsHaveContributed) {
@@ -476,10 +485,6 @@
             return -1;
         }*/
 
-        for (Iterator iter = activeCells.iterator(); iter.hasNext();) {
-            ((ActiveCell) iter.next()).backupWidth();
-        }
-
         //set starting points
         goToNextRowIfCurrentFinished();
 
@@ -536,20 +541,12 @@
 
     private void goToNextRowIfCurrentFinished() {
         // We assume that the current grid row is finished. If this is not the case this
-        // boolean will be reset (see below)
+        // boolean will be reset
         boolean currentGridRowFinished = true;
         for (Iterator iter = activeCells.iterator(); iter.hasNext();) {
             ActiveCell activeCell = (ActiveCell) iter.next();
-            if (activeCell.end < activeCell.elementList.size()) {
-                activeCell.start = activeCell.end + 1;
-                if (activeCell.end + 1 < activeCell.elementList.size()
-                        && activeCell.endsOnRow(activeRowIndex)) {
-                    // Ok, so this grid unit is the last in the row-spanning direction and
-                    // there are still unhandled Knuth elements. They /will/ have to be
-                    // put on the current grid row, which means that this row isn't
-                    // finished yet
-                    currentGridRowFinished = false;
-                }
+            if (activeCell.endsOnRow(activeRowIndex)) {
+                currentGridRowFinished &= activeCell.isFinished();
             }
         }
 

Modified: xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/table_border-collapse_separate_border-spacing_2.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/table_border-collapse_separate_border-spacing_2.xml?view=diff&rev=554690&r1=554689&r2=554690
==============================================================================
--- xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/table_border-collapse_separate_border-spacing_2.xml
(original)
+++ xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/table_border-collapse_separate_border-spacing_2.xml
Mon Jul  9 09:00:51 2007
@@ -136,11 +136,11 @@
       <glue w="7500"/>
       <box w="15000"/>
       <penalty w="0"/>
-      <box w="10000"/>
-      <penalty w="0"/>
-      <box w="0"/>
+      <box w="5000"/>
       <penalty w="5000"/>
-      <box w="10000"/>
+      <box w="0"/>
+      <penalty w="10000"/>
+      <box w="15000"/>
       <penalty w="0"/>
       <box w="0"/>
       <penalty w="5000"/>
@@ -156,11 +156,11 @@
       <glue w="7500"/>
       <box w="15000"/>
       <penalty w="0"/>
-      <box w="10000"/>
-      <penalty w="0"/>
-      <box w="0"/>
+      <box w="5000"/>
       <penalty w="5000"/>
-      <box w="10000"/>
+      <box w="0"/>
+      <penalty w="10000"/>
+      <box w="15000"/>
       <penalty w="0"/>
       <box w="0"/>
       <penalty w="5000"/>



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org


Mime
View raw message