]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Set border traits for fo:table only if border-collapse="separate".
authorJeremias Maerki <jeremias@apache.org>
Tue, 15 Feb 2005 19:30:51 +0000 (19:30 +0000)
committerJeremias Maerki <jeremias@apache.org>
Tue, 15 Feb 2005 19:30:51 +0000 (19:30 +0000)
Some clean-up.

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@198430 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/fo/flow/Table.java
src/java/org/apache/fop/fo/flow/TableCell.java
src/java/org/apache/fop/fo/flow/TableRow.java
src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java
src/java/org/apache/fop/layoutmgr/table/Cell.java
src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java

index 15b402fa6466f8991e1866cf580b0a33797e105f..78272973e2a7902e854906fadde95adb74709d33 100644 (file)
@@ -122,6 +122,11 @@ public class Table extends FObj {
         PropertyList colPList = new StaticPropertyList(defaultColumn, pList);
         colPList.setWritingMode();
         defaultColumn.bind(colPList);
+        
+        if (borderCollapse != EN_SEPARATE && commonBorderPaddingBackground.hasPadding()) {
+            //See "17.6.2 The collapsing border model" in CSS2
+            getLogger().error("Table may not have padding when using the collapsing border model.");
+        }
     }
 
     /**
@@ -237,6 +242,11 @@ public class Table extends FObj {
         return borderCollapse;
     }
 
+    /** @return true if the separate border model is active */
+    public boolean isSeparateBorderModel() {
+        return (getBorderCollapse() == EN_SEPARATE);
+    }
+    
     /** @return the "border-separation" property. */
     public LengthPairProperty getBorderSeparation() {
         return borderSeparation;
index 9853a54ff52a499423eacd7dfb2654349a32fc0f..6466da45393f5f0f8bf35e2283e88f174ed385ae 100644 (file)
@@ -49,8 +49,8 @@ public class TableCell extends FObj {
     // private ToBeImplementedProperty borderEndPrecedence;
     // private ToBeImplementedProperty borderStartPrecedence;
     private LengthRangeProperty blockProgressionDimension;
-    private int borderCollapse;
-    private LengthPairProperty borderSeparation;
+    private int borderCollapse; //inherited from fo:table
+    private LengthPairProperty borderSeparation; //inherited from fo:table
     private Numeric columnNumber;
     private int displayAlign;
     private int relativeAlign;
@@ -303,6 +303,21 @@ public class TableCell extends FObj {
         return (this.emptyCells == EN_SHOW);
     }
     
+    /** @return the "border-collapse" property (inherited from fo:table). */
+    public int getBorderCollapse() {
+        return borderCollapse;
+    }
+
+    /** @return true if the separate border model is active */
+    public boolean isSeparateBorderModel() {
+        return (getBorderCollapse() == EN_SEPARATE);
+    }
+    
+    /** @return the "border-separation" property (inherited from fo:table). */
+    public LengthPairProperty getBorderSeparation() {
+        return borderSeparation;
+    }
+
     /**
      * @return the "id" property.
      */
index 573bc55946fd4fedcd7fb97037b85f8b26ad62ec..0e484ebf39c0e7009a33ab92d2ad9be1602638ee 100644 (file)
@@ -25,7 +25,6 @@ import org.apache.fop.datatypes.Length;
 import org.apache.fop.fo.FONode;
 import org.apache.fop.fo.FObj;
 import org.apache.fop.fo.PropertyList;
-import org.apache.fop.fo.StaticPropertyList;
 import org.apache.fop.fo.ValidationException;
 import org.apache.fop.fo.properties.CommonAccessibility;
 import org.apache.fop.fo.properties.CommonAural;
index 03cf70c2d34a29bc9efc5ad568996c997374f766..dbb090fe8dc5a686eb7ec549412035d877ec46a0 100755 (executable)
@@ -279,4 +279,10 @@ public class CommonBorderPaddingBackground implements Cloneable {
     public boolean hasBackground() {
         return ((backgroundColor != null || getFopImage() != null));
     }
+
+    /** @return true if padding is non-zero. */
+    public boolean hasPadding() {
+        return ((getPaddingBefore(false) + getPaddingAfter(false) 
+                + getPaddingStart(false) + getPaddingEnd(false)) > 0);
+    }
 }
index 3d2ed37471590a93f952391d737c935588b5568f..c5b0b0892fab4d88e8d1b8e4aca2136f41cce458 100644 (file)
@@ -115,8 +115,8 @@ public class Cell extends BlockStackingLayoutManager {
         referenceIPD = context.getRefIPD(); 
         cellIPD = referenceIPD;
         cellIPD -= getIPIndents();
-        if (getTable().getBorderCollapse() == EN_SEPARATE) {
-            int borderSep = getTable().getBorderSeparation().getLengthPair()
+        if (fobj.isSeparateBorderModel()) {
+            int borderSep = fobj.getBorderSeparation().getLengthPair()
                     .getIPD().getLength().getValue();
             cellIPD -= borderSep;
         }
@@ -252,8 +252,8 @@ public class Cell extends BlockStackingLayoutManager {
             addID(fobj.getId());
         }
 
-        if (!emptyCell || (getTable().getBorderCollapse() == EN_SEPARATE 
-                && fobj.showEmptyCells())) {
+        if (!emptyCell 
+                || (fobj.isSeparateBorderModel() && fobj.showEmptyCells())) {
             TraitSetter.addBorders(curBlockArea, fobj.getCommonBorderPaddingBackground());
             TraitSetter.addBackground(curBlockArea, fobj.getCommonBorderPaddingBackground());
         }
@@ -320,8 +320,8 @@ public class Cell extends BlockStackingLayoutManager {
             indent += fobj.getCommonBorderPaddingBackground().getPaddingStart(false);
             // set position
             int halfBorderSep = 0;
-            if (getTable().getBorderCollapse() == EN_SEPARATE) {
-                halfBorderSep = getTable().getBorderSeparation().getLengthPair()
+            if (fobj.isSeparateBorderModel()) {
+                halfBorderSep = fobj.getBorderSeparation().getLengthPair()
                         .getIPD().getLength().getValue() / 2;
             }
             curBlockArea.setXOffset(xoffset + inRowIPDOffset + halfBorderSep + indent);
index c2778fce78a57b081d94b9e6f262d77bb6f0d2b2..5a1ee47d217f1b8f78a3cc3ba7bb2bbd307058a2 100644 (file)
@@ -387,7 +387,9 @@ public class TableLayoutManager extends BlockStackingLayoutManager {
 
         curBlockArea.setBPD(tableHeight);
 
-        TraitSetter.addBorders(curBlockArea, fobj.getCommonBorderPaddingBackground());
+        if (fobj.isSeparateBorderModel()) {
+            TraitSetter.addBorders(curBlockArea, fobj.getCommonBorderPaddingBackground());
+        }
         TraitSetter.addBackground(curBlockArea, fobj.getCommonBorderPaddingBackground());
         TraitSetter.addMargins(curBlockArea,
                 fobj.getCommonBorderPaddingBackground(),