jeremias    2005/02/08 01:20:41

  Modified:    src/java/org/apache/fop/fo/flow TableBody.java TableRow.java
                        TableCell.java Table.java
               src/java/org/apache/fop/fo PropertyList.java
  Log:
  Support for table-cells as direct children of table-body|header|footer.
  The table-cells are grouped into table-rows using starts-row and ends-row 
properties during FO tree building so the layout managers don't have to handle 
both cases. This will hopefully keep the code simpler.
  Additional accessors on some FO objects.
  
  Revision  Changes    Path
  1.36      +51 -3     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.35
  retrieving revision 1.36
  diff -u -r1.35 -r1.36
  --- TableBody.java    24 Dec 2004 12:06:26 -0000      1.35
  +++ TableBody.java    8 Feb 2005 09:20:41 -0000       1.36
  @@ -1,5 +1,5 @@
   /*
  - * Copyright 1999-2004 The Apache Software Foundation.
  + * Copyright 1999-2005 The Apache Software Foundation.
    * 
    * Licensed under the Apache License, Version 2.0 (the "License");
    * you may not use this file except in compliance with the License.
  @@ -19,17 +19,18 @@
   package org.apache.fop.fo.flow;
   
   // Java
  +import java.util.Iterator;
   import java.util.List;
   
   import org.apache.fop.apps.FOPException;
   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.properties.CommonAccessibility;
   import org.apache.fop.fo.properties.CommonAural;
   import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
   import org.apache.fop.fo.properties.CommonRelativePosition;
  -import org.apache.fop.layoutmgr.table.Body;
   
   /**
    * Class modelling the fo:table-body object.
  @@ -48,6 +49,8 @@
       private int visibility;
       // End of property values
       
  +    private PropertyList savedPropertyList;
  +    
       /**
        * @param parent FONode that is the parent of the object
        */
  @@ -68,6 +71,9 @@
           // borderEndPrecedence = pList.get(PR_BORDER_END_PRECEDENCE);
           // borderStartPrecedence = pList.get(PR_BORDER_START_PRECEDENCE);
           visibility = pList.get(PR_VISIBILITY).getEnum();
  +        
  +        //Used by convertCellsToRows()
  +        savedPropertyList = pList;
       }
       
       /**
  @@ -82,10 +88,52 @@
        */
       protected void endOfNode() throws FOPException {
           getFOEventHandler().endBody(this);
  +        convertCellsToRows();
       }
   
       /**
  -     * Return the Common Border, Padding, and Background Properties.
  +     * If table-cells are used as direct children of a 
table-body|header|footer
  +     * they are replace in this method by proper table-rows.
  +     * @throws FOPException if there's a problem binding the TableRows 
properties.
  +     */
  +    private void convertCellsToRows() throws FOPException {
  +        try {
  +            if (childNodes.size() == 0 || childNodes.get(0) instanceof 
TableRow) {
  +                return;
  +            }
  +            //getLogger().debug("Converting cells to rows...");
  +            List cells = (List)childNodes.clone();
  +            childNodes.clear();
  +            Iterator i = cells.iterator();
  +            TableRow row = null;
  +            while (i.hasNext()) {
  +                TableCell cell = (TableCell)i.next();
  +                if (cell.startsRow() && (row != null)) {
  +                    childNodes.add(row);
  +                    row = null;
  +                }
  +                if (row == null) {
  +                    row = new TableRow(this);
  +                    PropertyList pList = new StaticPropertyList(row, 
savedPropertyList);
  +                    pList.setWritingMode();
  +                    row.bind(pList);
  +                }
  +                row.addReplacedCell(cell);
  +                if (cell.endsRow()) {
  +                    childNodes.add(row);
  +                    row = null;
  +                }
  +            }
  +            if (row != null) {
  +                childNodes.add(row);
  +            }
  +        } finally {
  +            savedPropertyList = null; //Release reference
  +        }
  +    }
  +    
  +    /**
  +     * @return the Common Border, Padding, and Background Properties.
        */
       public CommonBorderPaddingBackground getCommonBorderPaddingBackground() {
           return commonBorderPaddingBackground;
  
  
  
  1.45      +15 -1     xml-fop/src/java/org/apache/fop/fo/flow/TableRow.java
  
  Index: TableRow.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/TableRow.java,v
  retrieving revision 1.44
  retrieving revision 1.45
  diff -u -r1.44 -r1.45
  --- TableRow.java     7 Feb 2005 10:55:35 -0000       1.44
  +++ TableRow.java     8 Feb 2005 09:20:41 -0000       1.45
  @@ -25,6 +25,7 @@
   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;
  @@ -56,7 +57,7 @@
       private KeepProperty keepWithPrevious;
       private int visibility;
       // End of property values
  -    
  +
       private boolean setup = false;
   
       /**
  @@ -90,6 +91,19 @@
       }
   
       /**
  +     * Adds a cell to this row (skips marker handling done by 
FObj.addChildNode().
  +     * Used by TableBody during the row building process when only cells are
  +     * used as direct children of a table-body/header/footer.
  +     * @param cell cell to add.
  +     */
  +    protected void addReplacedCell(TableCell cell) {
  +        if (childNodes == null) {
  +            childNodes = new java.util.ArrayList();
  +        }
  +        childNodes.add(cell);
  +    }
  +    
  +    /**
        * @see org.apache.fop.fo.FONode#startOfNode
        */
       protected void startOfNode() throws FOPException {
  
  
  
  1.44      +10 -0     xml-fop/src/java/org/apache/fop/fo/flow/TableCell.java
  
  Index: TableCell.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/TableCell.java,v
  retrieving revision 1.43
  retrieving revision 1.44
  diff -u -r1.43 -r1.44
  --- TableCell.java    7 Feb 2005 10:55:35 -0000       1.43
  +++ TableCell.java    8 Feb 2005 09:20:41 -0000       1.44
  @@ -324,6 +324,16 @@
           return displayAlign;
       }
       
  +    /** @return true if the cell starts a row. */
  +    public boolean startsRow() {
  +        return (startsRow == EN_TRUE);
  +    }
  +    
  +    /** @return true if the cell ends a row. */
  +    public boolean endsRow() {
  +        return (endsRow == EN_TRUE);
  +    }
  +    
       /**
        * @see org.apache.fop.fo.FObj#getName()
        */
  
  
  
  1.45      +5 -0      xml-fop/src/java/org/apache/fop/fo/flow/Table.java
  
  Index: Table.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/Table.java,v
  retrieving revision 1.44
  retrieving revision 1.45
  diff -u -r1.44 -r1.45
  --- Table.java        7 Feb 2005 16:26:13 -0000       1.44
  +++ Table.java        8 Feb 2005 09:20:41 -0000       1.45
  @@ -200,6 +200,11 @@
           return breakBefore;
       }
       
  +    /** @return the "border-collapse" property. */
  +    public int getBorderCollapse() {
  +        return borderCollapse;
  +    }
  +
       /** @return the "border-separation" property. */
       public LengthPairProperty getBorderSeparation() {
           return borderSeparation;
  
  
  
  1.45      +1 -1      xml-fop/src/java/org/apache/fop/fo/PropertyList.java
  
  Index: PropertyList.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/PropertyList.java,v
  retrieving revision 1.44
  retrieving revision 1.45
  diff -u -r1.44 -r1.45
  --- PropertyList.java 25 Jan 2005 10:55:46 -0000      1.44
  +++ PropertyList.java 8 Feb 2005 09:20:41 -0000       1.45
  @@ -203,7 +203,7 @@
        * Use that from the nearest ancestor, including self, which generates
        * reference areas, or from root FO if no ancestor found.
        */
  -    protected void setWritingMode() throws PropertyException {
  +    public void setWritingMode() throws PropertyException {
           FObj p = fobj.findNearestAncestorFObj();
           // If this is a RA or the root, use the property value.
           if (fobj.generatesReferenceAreas() || p == null) {
  
  
  

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

Reply via email to