]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Initial keep-together support on table.
authorJeremias Maerki <jeremias@apache.org>
Mon, 23 May 2005 13:52:26 +0000 (13:52 +0000)
committerJeremias Maerki <jeremias@apache.org>
Mon, 23 May 2005 13:52:26 +0000 (13:52 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@198672 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/fo/flow/Table.java
src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java
src/java/org/apache/fop/layoutmgr/table/TableStepper.java

index a6534e3d119fe1b3d3696565639c77d4f07d0908..f1fee2a3c76531f8abbeff04814a8e74813b0b92 100644 (file)
@@ -200,7 +200,8 @@ public class Table extends FObj {
      */
     protected void endOfNode() throws FOPException {
         if (!tableBodyFound) {
-           missingChildElementError("(marker*,table-column*,table-header?,table-footer?,table-body+)");
+           missingChildElementError(
+                   "(marker*,table-column*,table-header?,table-footer?,table-body+)");
         }
 
         getFOEventHandler().endTable(this);
@@ -235,6 +236,7 @@ public class Table extends FObj {
         return this.defaultColumn;
     }
     
+    /** @return the list of table-column elements. */
     public List getColumns() {
         return columns;
     }
@@ -247,10 +249,12 @@ public class Table extends FObj {
         return (TableBody)childNodes.get(index);
     }
 
+    /** @return the body for the table-header. */
     public TableBody getTableHeader() {
         return tableHeader;
     }
 
+    /** @return the body for the table-footer. */
     public TableBody getTableFooter() {
         return tableFooter;
     }
@@ -318,6 +322,15 @@ public class Table extends FObj {
         return keepTogether;
     }
 
+    /**
+     * Convenience method to check if a keep-together constraint is specified.
+     * @return true if keep-together is active.
+     */
+    public boolean mustKeepTogether() {
+        return !getKeepTogether().getWithinPage().isAuto()
+                || !getKeepTogether().getWithinColumn().isAuto();
+    }
+    
     /** @return the "border-collapse" property. */
     public int getBorderCollapse() {
         return borderCollapse;
index 8bced6f328c07d5f863d07bd07e9051134736f8f..20d3e70e265dfea85dfbdb3cf77589dbdfc5db62 100644 (file)
@@ -198,7 +198,7 @@ public class TableContentLayoutManager {
         if (returnList.size() > 0) {
             //Remove last penalty
             KnuthElement last = (KnuthElement)returnList.getLast();
-            if (last.isPenalty() && last.getP() == 0) {
+            if (last.isPenalty()) {
                 returnList.removeLast();
             }
         }
index 76f2dc96f2ddfd58d39f61879416402daa2304f0..21b0d44ba7927b5d7890fa80f59d9cee079f1382 100644 (file)
@@ -141,6 +141,7 @@ public class TableStepper {
             }
             if (pgu.isLastGridUnitRowSpan() && pgu.getRow() != null) {
                 makeBoxForWholeRow |= pgu.getRow().mustKeepTogether();
+                makeBoxForWholeRow |= pgu.getTable().mustKeepTogether();
             }
             if (makeBoxForWholeRow) {
                 List list = new java.util.ArrayList(1);
@@ -243,7 +244,11 @@ public class TableStepper {
                     penaltyPos.footerElements = tclm.getFooterElements();
                 }
             }
-            returnList.add(new KnuthPenalty(effPenaltyLen, 0, false, penaltyPos, false));
+            int p = 0;
+            if (getTableLM().mustKeepTogether()) {
+                p = KnuthPenalty.INFINITE;
+            }
+            returnList.add(new KnuthPenalty(effPenaltyLen, p, false, penaltyPos, false));
 
             log.debug("step=" + step + " (+" + increase + ")"
                     + " box=" + boxLen