You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by vh...@apache.org on 2008/01/10 16:53:21 UTC

svn commit: r610821 - in /xmlgraphics/fop/trunk/src/java/org/apache/fop: fo/flow/table/EffRow.java fo/flow/table/PrimaryGridUnit.java layoutmgr/table/RowGroupLayoutManager.java

Author: vhennebert
Date: Thu Jan 10 07:53:20 2008
New Revision: 610821

URL: http://svn.apache.org/viewvc?rev=610821&view=rev
Log:
- renamed variables for clarity
- moved the computation of a cell's content length in PrimaryGridUnit
- better javadoc for getHeight method in EffRow

Modified:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/table/EffRow.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/table/PrimaryGridUnit.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/table/EffRow.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/table/EffRow.java?rev=610821&r1=610820&r2=610821&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/table/EffRow.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/table/EffRow.java Thu Jan 10 07:53:20 2008
@@ -80,13 +80,20 @@
         return getGridUnit(0).getRow();
     }
     
-    /** @return the calculated height for this EffRow. */
+    /**
+     * Returns the calculated height for this EffRow, including the cells'
+     * bpds/paddings/borders, and the table's border-separation.
+     * 
+     * @return the row's height
+     */
     public MinOptMax getHeight() {
         return this.height;
     }
     
     /**
-     * Sets the calculated height for this EffRow.
+     * Sets the calculated height for this EffRow, including everything (cells' bpds,
+     * paddings, borders, and border-separation).
+     * 
      * @param mom the calculated height
      */
     public void setHeight(MinOptMax mom) {

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/table/PrimaryGridUnit.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/table/PrimaryGridUnit.java?rev=610821&r1=610820&r2=610821&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/table/PrimaryGridUnit.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/table/PrimaryGridUnit.java Thu Jan 10 07:53:20 2008
@@ -24,6 +24,7 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.fop.layoutmgr.ElementListUtils;
 import org.apache.fop.layoutmgr.table.TableCellLayoutManager;
 
 /**
@@ -142,13 +143,11 @@
         return getHalfMaxBeforeBorderWidth() + getHalfMaxAfterBorderWidth();
     }
 
-    /** @param value The length of the cell content to remember. */
-    public void setContentLength(int value) {
-        this.contentLength = value;
-    }
-
     /** @return the length of the cell content. */
     public int getContentLength() {
+        if (contentLength < 0) {
+            contentLength = ElementListUtils.calcContentLength(elements);
+        }
         return contentLength;
     }
 

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java?rev=610821&r1=610820&r2=610821&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java Thu Jan 10 07:53:20 2008
@@ -148,9 +148,9 @@
             TableRow tableRow = null;
             // The row's minimum content height; 0 if the row's height is auto, otherwise
             // the .minimum component of the explicitly specified value
-            int minContentHeight = 0;
-            int maxCellHeight = 0;
-            int effRowContentHeight = 0;
+            int minRowBPD = 0;
+            // The BPD of the biggest cell in the row
+            int maxCellBPD = 0;
             for (int j = 0; j < row.getGridUnits().size(); j++) {
                 assert maxColumnCount == 0 || maxColumnCount == row.getGridUnits().size();
                 maxColumnCount = Math.max(maxColumnCount, row.getGridUnits().size());
@@ -168,14 +168,12 @@
                             tableRow = primary.getRow();
                             
                             //Check for bpd on row, see CSS21, 17.5.3 Table height algorithms
-                            LengthRangeProperty bpd = tableRow.getBlockProgressionDimension();
-                            if (!bpd.getMinimum(tableLM).isAuto()) {
-                                minContentHeight = Math.max(
-                                        minContentHeight, 
-                                        bpd.getMinimum(
-                                                tableLM).getLength().getValue(tableLM));
+                            LengthRangeProperty rowBPD = tableRow.getBlockProgressionDimension();
+                            if (!rowBPD.getMinimum(tableLM).isAuto()) {
+                                minRowBPD = Math.max(minRowBPD,
+                                        rowBPD.getMinimum(tableLM).getLength().getValue(tableLM));
                             }
-                            MinOptMaxUtil.restrict(explicitRowHeights[rgi], bpd, tableLM);
+                            MinOptMaxUtil.restrict(explicitRowHeights[rgi], rowBPD, tableLM);
                             
                         }
 
@@ -218,31 +216,27 @@
                         }
                     }
 
-                    
-                    //Calculate height of cell contents
-                    primary.setContentLength(ElementListUtils.calcContentLength(
-                            primary.getElements()));
-                    maxCellHeight = Math.max(maxCellHeight, primary.getContentLength());
-
                     //Calculate height of row, see CSS21, 17.5.3 Table height algorithms
                     if (gu.isLastGridUnitRowSpan()) {
-                        int effCellContentHeight = minContentHeight;
-                        LengthRangeProperty bpd = primary.getCell().getBlockProgressionDimension();
-                        if (!bpd.getMinimum(tableLM).isAuto()) {
-                            effCellContentHeight = Math.max(
-                                effCellContentHeight,
-                                bpd.getMinimum(tableLM).getLength().getValue(tableLM));
-                        }
-                        if (!bpd.getOptimum(tableLM).isAuto()) {
-                            effCellContentHeight = Math.max(
-                                effCellContentHeight,
-                                bpd.getOptimum(tableLM).getLength().getValue(tableLM));
+                        // The effective cell's bpd, after taking into account bpd
+                        // (possibly explicitly) set on the row or on the cell, and the
+                        // cell's content length
+                        int effectiveCellBPD = minRowBPD;
+                        LengthRangeProperty cellBPD = primary.getCell()
+                                .getBlockProgressionDimension();
+                        if (!cellBPD.getMinimum(tableLM).isAuto()) {
+                            effectiveCellBPD = Math.max(effectiveCellBPD,
+                                    cellBPD.getMinimum(tableLM).getLength().getValue(tableLM));
+                        }
+                        if (!cellBPD.getOptimum(tableLM).isAuto()) {
+                            effectiveCellBPD = Math.max(effectiveCellBPD,
+                                    cellBPD.getOptimum(tableLM).getLength().getValue(tableLM));
                         }
                         if (gu.getRowSpanIndex() == 0) {
                             //TODO ATM only non-row-spanned cells are taken for this
-                            MinOptMaxUtil.restrict(explicitRowHeights[rgi], bpd, tableLM);
+                            MinOptMaxUtil.restrict(explicitRowHeights[rgi], cellBPD, tableLM);
                         }
-                        effCellContentHeight = Math.max(effCellContentHeight, 
+                        effectiveCellBPD = Math.max(effectiveCellBPD, 
                                 primary.getContentLength());
                         
                         int borderWidths;
@@ -253,13 +247,12 @@
                             borderWidths = primary.getHalfMaxBorderWidth();
                         }
                         int padding = 0;
-                        effRowContentHeight = Math.max(effRowContentHeight,
-                                effCellContentHeight);
+                        maxCellBPD = Math.max(maxCellBPD, effectiveCellBPD);
                         CommonBorderPaddingBackground cbpb 
                             = primary.getCell().getCommonBorderPaddingBackground(); 
                         padding += cbpb.getPaddingBefore(false, primary.getCellLM());
                         padding += cbpb.getPaddingAfter(false, primary.getCellLM());
-                        int effRowHeight = effCellContentHeight 
+                        int effRowHeight = effectiveCellBPD 
                                 + padding + borderWidths
                                 + 2 * tableLM.getHalfBorderSeparationBPD();
                         for (int previous = 0; previous < gu.getRowSpanIndex(); previous++) {
@@ -279,13 +272,13 @@
 
             row.setHeight(rowHeights[rgi]);
             row.setExplicitHeight(explicitRowHeights[rgi]);
-            if (effRowContentHeight > row.getExplicitHeight().max) {
+            if (maxCellBPD > row.getExplicitHeight().max) {
                 log.warn(FONode.decorateWithContextInfo(
                         "The contents of row " + (row.getIndex() + 1) 
                         + " are taller than they should be (there is a"
                         + " block-progression-dimension or height constraint on the indicated row)."
                         + " Due to its contents the row grows"
-                        + " to " + effRowContentHeight + " millipoints, but the row shouldn't get"
+                        + " to " + maxCellBPD + " millipoints, but the row shouldn't get"
                         + " any taller than " + row.getExplicitHeight() + " millipoints.", 
                         row.getTableRow()));
             }



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