]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Bugzilla #52572: Prevent NPE on use of unsupported collapse-with-precedence; fall...
authorGlenn Adams <gadams@apache.org>
Sat, 14 Apr 2012 16:48:59 +0000 (16:48 +0000)
committerGlenn Adams <gadams@apache.org>
Sat, 14 Apr 2012 16:48:59 +0000 (16:48 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1326144 13f79535-47bb-0310-9956-ffa450edef68

src/documentation/content/xdocs/compliance.ihtml
src/java/org/apache/fop/fo/flow/table/ConditionalBorder.java
src/java/org/apache/fop/fo/flow/table/Table.java
src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModel.java
src/java/org/apache/fop/render/txt/TXTRenderer.java
status.xml

index fe3107142893bd20f52059835cd1ca32e7e5f5d2..a8e7a39ca324dc83f21f4cd81b98f3b4fdbf9153 100644 (file)
       <td><a name="fo-property-border-collapse" id=
       "fo-property-border-collapse">border-collapse</a></td>
       <td class="extended">Extended</td>
-      <td class="yes">yes</td>
-      <td class="yes">yes</td>
-      <td class="yes">yes</td>
-      <td>Some small limitations</td>
+      <td class="partial">partial</td>
+      <td class="partial">partial</td>
+      <td class="partial">partial</td>
+      <td>value "collapse-with-precedence" not yet supported</td>
     </tr>
     <tr>
       <td align="center"><a href=
index b5cd56d47158d6b695c8b54ba66b40fd7bb3ea68..e69439276e77109ab3481258dd4f1ec0ded33235 100644 (file)
@@ -60,6 +60,7 @@ public class ConditionalBorder {
     private ConditionalBorder(BorderSpecification normal,
             BorderSpecification leadingTrailing, BorderSpecification rest,
             CollapsingBorderModel collapsingBorderModel) {
+        assert collapsingBorderModel != null;
         this.normal = normal;
         this.leadingTrailing = leadingTrailing;
         this.rest = rest;
@@ -74,14 +75,10 @@ public class ConditionalBorder {
      */
     ConditionalBorder(BorderSpecification borderSpecification,
             CollapsingBorderModel collapsingBorderModel) {
-        normal = borderSpecification;
-        leadingTrailing = normal;
-        if (borderSpecification.getBorderInfo().getWidth().isDiscard()) {
-            rest = BorderSpecification.getDefaultBorder();
-        } else {
-            rest = leadingTrailing;
-        }
-        this.collapsingBorderModel = collapsingBorderModel;
+        this ( borderSpecification, borderSpecification,
+               borderSpecification.getBorderInfo().getWidth().isDiscard()
+                 ? BorderSpecification.getDefaultBorder() : borderSpecification,
+               collapsingBorderModel );
     }
 
     /**
index b14326af519da2ee32201f4c96305e1978403b38..e599fc8c5f00c86ec44b4f49ea56d3306a625c96 100644 (file)
@@ -147,13 +147,19 @@ public class Table extends TableFObj implements ColumnNumberManagerHolder, Break
             getFOValidationEventProducer().unimplementedFeature(this, getName(),
                     "table-layout=\"auto\"", getLocator());
         }
-        if (!isSeparateBorderModel()
-                && getCommonBorderPaddingBackground().hasPadding(
-                        ValidationPercentBaseContext.getPseudoContext())) {
-            //See "17.6.2 The collapsing border model" in CSS2
-            TableEventProducer eventProducer = TableEventProducer.Provider.get(
-                    getUserAgent().getEventBroadcaster());
-            eventProducer.noTablePaddingWithCollapsingBorderModel(this, getLocator());
+        if (!isSeparateBorderModel()) {
+            if (borderCollapse == EN_COLLAPSE_WITH_PRECEDENCE) {
+                getFOValidationEventProducer().unimplementedFeature(this, getName(),
+                    "border-collapse=\"collapse-with-precedence\"; defaulting to \"collapse\"", getLocator());
+                borderCollapse = EN_COLLAPSE;
+            }
+            if (getCommonBorderPaddingBackground().hasPadding(
+                            ValidationPercentBaseContext.getPseudoContext())) {
+                //See "17.6.2 The collapsing border model" in CSS2
+                TableEventProducer eventProducer = TableEventProducer.Provider.get(
+                        getUserAgent().getEventBroadcaster());
+                eventProducer.noTablePaddingWithCollapsingBorderModel(this, getLocator());
+            }
         }
 
         /* Store reference to the property list, so
index 7221d4feebe52606217cc9f2fc626954da277fd8..88b89e1db924b6cbf05bd7f04e6b6d9ee33dbee4 100644 (file)
@@ -49,7 +49,7 @@ public abstract class CollapsingBorderModel {
 
     //These statics are used singleton-style. No MT issues here.
     private static CollapsingBorderModel collapse = null;
-    private static CollapsingBorderModel collapseWithPrecedence = null;
+    // private static CollapsingBorderModel collapseWithPrecedence = null;
 
     /**
      * @param borderCollapse border collapse control
@@ -63,10 +63,7 @@ public abstract class CollapsingBorderModel {
                 }
                 return collapse;
             case Constants.EN_COLLAPSE_WITH_PRECEDENCE:
-                if (collapseWithPrecedence == null) {
-                    //collapseWithPrecedence = new CollapsingBorderModelWithPrecedence();
-                }
-                return collapseWithPrecedence;
+                throw new UnsupportedOperationException ( "collapse-with-precedence not yet supported" );
             default:
                 throw new IllegalArgumentException("Illegal border-collapse mode.");
         }
index dd3d883f661d7c6736ce490b13bd5f2ee8b35385..9492018fcc5afa8b605ee4df7a81bdd783dafc09 100644 (file)
@@ -195,7 +195,7 @@ public class TXTRenderer extends AbstractPathOrientedRenderer {
      */
     protected void renderText(TextArea area) {
         int col = Helper.ceilPosition(this.currentIPPosition, CHAR_WIDTH);
-        int row = Helper.ceilPosition(this.currentBPPosition - LINE_LEADING, CHAR_HEIGHT + 2*LINE_LEADING);
+        int row = Helper.ceilPosition(this.currentBPPosition - LINE_LEADING, CHAR_HEIGHT + 2 * LINE_LEADING);
 
         String s = area.getText();
 
@@ -219,7 +219,7 @@ public class TXTRenderer extends AbstractPathOrientedRenderer {
         double height = bounds.getHeight();
 
         pageWidth = Helper.ceilPosition((int) width, CHAR_WIDTH);
-        pageHeight = Helper.ceilPosition((int) height, CHAR_HEIGHT + 2*LINE_LEADING);
+        pageHeight = Helper.ceilPosition((int) height, CHAR_HEIGHT + 2 * LINE_LEADING);
 
         // init buffers
         charData = new StringBuffer[pageHeight];
@@ -463,9 +463,9 @@ public class TXTRenderer extends AbstractPathOrientedRenderer {
      */
     public void renderImage(Image image, Rectangle2D pos) {
         int x1 = Helper.ceilPosition(currentIPPosition, CHAR_WIDTH);
-        int y1 = Helper.ceilPosition(currentBPPosition - LINE_LEADING, CHAR_HEIGHT + 2*LINE_LEADING);
+        int y1 = Helper.ceilPosition(currentBPPosition - LINE_LEADING, CHAR_HEIGHT + 2 * LINE_LEADING);
         int width = Helper.ceilPosition((int) pos.getWidth(), CHAR_WIDTH);
-        int height = Helper.ceilPosition((int) pos.getHeight(), CHAR_HEIGHT + 2*LINE_LEADING);
+        int height = Helper.ceilPosition((int) pos.getHeight(), CHAR_HEIGHT + 2 * LINE_LEADING);
 
         fillRect(x1, y1, width, height, IMAGE_CHAR);
     }
@@ -562,9 +562,9 @@ public class TXTRenderer extends AbstractPathOrientedRenderer {
     protected void drawBackAndBorders(Area area, float startx, float starty,
             float width, float height) {
         bm.setWidth(Helper.ceilPosition(toMilli(width), CHAR_WIDTH));
-        bm.setHeight(Helper.ceilPosition(toMilli(height), CHAR_HEIGHT + 2*LINE_LEADING));
+        bm.setHeight(Helper.ceilPosition(toMilli(height), CHAR_HEIGHT + 2 * LINE_LEADING));
         bm.setStartX(Helper.ceilPosition(toMilli(startx), CHAR_WIDTH));
-        bm.setStartY(Helper.ceilPosition(toMilli(starty), CHAR_HEIGHT + 2*LINE_LEADING));
+        bm.setStartY(Helper.ceilPosition(toMilli(starty), CHAR_HEIGHT + 2 * LINE_LEADING));
 
         super.drawBackAndBorders(area, startx, starty, width, height);
     }
index 95f6406395f7fb355d4e3f72d4bc652f504655c1..92f35af8d366afd4a674a660b2cc8778e1bba895 100644 (file)
@@ -62,6 +62,9 @@
       documents. Example: the fix of marks layering will be such a case when it's done.
     -->
     <release version="FOP Trunk" date="TBD">
+      <action context="Code" dev="GA" type="fix" fixes-bug="52572" due-to="Pascal Sancho">
+        Prevent NPE on use of unsupported collapse-with-precedence; fall back to collapse. Fix checkstyle errors from prior commit.
+      </action>
       <action context="Code" dev="GA" type="fix" fixes-bug="52514" due-to="Luis Bernardo">
         Ensure square image is appropriately scaled.
       </action>