jeremias    2005/02/23 14:04:01

  Modified:    src/java/org/apache/fop/fo FObj.java FONode.java
               src/java/org/apache/fop/fo/flow TableBody.java
  Log:
  An empty table-body is illegal but we'll allow it to make things easier for 
stylesheet writers.
  Empty table-body elements are removed from their parent so they can't cause 
any nasty effects in the LMs.
  
  Revision  Changes    Path
  1.92      +7 -0      xml-fop/src/java/org/apache/fop/fo/FObj.java
  
  Index: FObj.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/FObj.java,v
  retrieving revision 1.91
  retrieving revision 1.92
  diff -u -r1.91 -r1.92
  --- FObj.java 3 Feb 2005 08:18:27 -0000       1.91
  +++ FObj.java 23 Feb 2005 22:04:01 -0000      1.92
  @@ -170,6 +170,13 @@
           }
       }
   
  +    /** @see org.apache.fop.fo.FONode#removeChild(org.apache.fop.fo.FONode) 
*/
  +    public void removeChild(FONode child) {
  +        if (childNodes != null) {
  +            childNodes.remove(child);
  +        }
  +    }
  +    
       /**
        * Find the nearest parent, grandparent, etc. FONode that is also an FObj
        * @return FObj the nearest ancestor FONode that is an FObj
  
  
  
  1.54      +10 -0     xml-fop/src/java/org/apache/fop/fo/FONode.java
  
  Index: FONode.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/FONode.java,v
  retrieving revision 1.53
  retrieving revision 1.54
  diff -u -r1.53 -r1.54
  --- FONode.java       1 Feb 2005 21:21:28 -0000       1.53
  +++ FONode.java       23 Feb 2005 22:04:01 -0000      1.54
  @@ -198,6 +198,15 @@
       }
   
       /**
  +     * Removes a child node. Used by the child nodes to remove themselves, 
for
  +     * example table-body if it has no children.
  +     * @param child child node to be removed
  +     */
  +    public void removeChild(FONode child) {
  +        //nop
  +    }
  +
  +    /**
        * @return the parent node of this node
        */
       public FONode getParent() {
  @@ -410,5 +419,6 @@
       public int getNameId() {
           return Constants.FO_UNKNOWN_NODE;
       }
  +
   }
   
  
  
  
  1.38      +8 -1      xml-fop/src/java/org/apache/fop/fo/flow/TableBody.java
  
  Index: TableBody.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/TableBody.java,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- TableBody.java    21 Feb 2005 21:52:14 -0000      1.37
  +++ TableBody.java    23 Feb 2005 22:04:01 -0000      1.38
  @@ -88,6 +88,11 @@
        */
       protected void endOfNode() throws FOPException {
           getFOEventHandler().endBody(this);
  +        if (childNodes == null || childNodes.size() == 0) {
  +            getLogger().error("fo:table-body must not be empty. "
  +                    + "Expected: (table-row+|table-cell+)");
  +            getParent().removeChild(this);
  +        }
           convertCellsToRows();
       }
   
  @@ -98,7 +103,9 @@
        */
       private void convertCellsToRows() throws FOPException {
           try {
  -            if (childNodes.size() == 0 || childNodes.get(0) instanceof 
TableRow) {
  +            if (childNodes == null 
  +                    || childNodes.size() == 0 
  +                    || childNodes.get(0) instanceof TableRow) {
                   return;
               }
               //getLogger().debug("Converting cells to rows...");
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to