jeremias    2005/02/09 07:38:15

  Modified:    src/java/org/apache/fop/layoutmgr/table
                        TableLayoutManager.java Body.java
               src/java/org/apache/fop/fo/flow Table.java
  Log:
  No longer fail when no table-columns are defined. The table creates a 
"default column" which is used to handle any defaults and inheritance.
  The columns list is populated with at least the default column.
  The first row is not yet inspected for determining column widths as described 
in fixed table layout. (see comment in code)
  
  Revision  Changes    Path
  1.16      +35 -4     
xml-fop/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java
  
  Index: TableLayoutManager.java
  ===================================================================
  RCS file: 
/home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- TableLayoutManager.java   31 Jan 2005 21:16:45 -0000      1.15
  +++ TableLayoutManager.java   9 Feb 2005 15:38:15 -0000       1.16
  @@ -21,6 +21,8 @@
   import org.apache.fop.datatypes.Length;
   import org.apache.fop.datatypes.PercentBase;
   import org.apache.fop.fo.flow.Table;
  +import org.apache.fop.fo.flow.TableBody;
  +import org.apache.fop.fo.flow.TableRow;
   import org.apache.fop.fo.properties.TableColLength;
   import org.apache.fop.layoutmgr.BlockStackingLayoutManager;
   import org.apache.fop.layoutmgr.LayoutManager;
  @@ -62,6 +64,7 @@
       private BreakPoss footerBreak;
       
       private int referenceIPD;
  +    private boolean autoLayout = true;
   
       //TODO space-before|after: handle space-resolution rules
       private MinOptMax spaceBefore;
  @@ -78,13 +81,18 @@
   
       /**
        * Create a new table layout manager.
  -     *
  +     * @param node the table FO
        */
       public TableLayoutManager(Table node) {
           super(node);
           fobj = node;
       }
   
  +    /** @return the table FO */
  +    public Table getTable() {
  +        return this.fobj;
  +    }
  +    
       /**
        * Set the columns for this table.
        *
  @@ -119,6 +127,11 @@
           super.initProperties();
           spaceBefore = new 
SpaceVal(fobj.getCommonMarginBlock().spaceBefore).getSpace();
           spaceAfter = new 
SpaceVal(fobj.getCommonMarginBlock().spaceAfter).getSpace();
  +        
  +        if (!fobj.isAutoLayout() 
  +                && 
fobj.getInlineProgressionDimension().getOptimum().getEnum() != EN_AUTO) {
  +            autoLayout = false;
  +        }
       }
   
       private int getIPIndents() {
  @@ -164,6 +177,10 @@
           fobj.setLayoutDimension(PercentBase.REFERENCE_AREA_IPD, 
referenceIPD);
           fobj.setLayoutDimension(PercentBase.REFERENCE_AREA_BPD, 
context.getStackLimit().opt);
   
  +        if (columns == null) {
  +            createColumnsFromFirstRow();
  +        }
  +        
           // either works out table of column widths or if 
proportional-column-width function
           // is used works out total factor, so that value of single unit can 
be computed.
           int sumCols = 0;
  @@ -265,6 +282,18 @@
           return null;
       }
   
  +    private void createColumnsFromFirstRow() {
  +        this.columns = new java.util.ArrayList();
  +        //TODO Create columns from first row here 
  +        //--> rule 2 in "fixed table layout", see CSS2, 17.5.2
  +        //Alternative: extend columns on-the-fly, but in this case we need 
the
  +        //new property evaluation context so proportional-column-width() 
works
  +        //correctly.
  +        if (columns.size() == 0) {
  +            this.columns.add(new Column(getTable().getDefaultColumn()));
  +        }
  +    }
  +    
       /**
        * Get the break possibility and height of the table header or footer.
        *
  @@ -316,6 +345,8 @@
           double adjust = layoutContext.getSpaceAdjust();
           addBlockSpacing(adjust, spaceBefore);
           spaceBefore = null;
  +
  +        int startXOffset = 
fobj.getCommonMarginBlock().startIndent.getValue();
           
           // add column, body then row areas
   
  @@ -329,7 +360,7 @@
               List list = pos.list;
               PositionIterator breakPosIter = new BreakPossPosIter(list, 0, 
list.size() + 1);
               while ((childLM = (Body)breakPosIter.getNextChildLM()) != null) {
  -                
childLM.setXOffset(fobj.getCommonMarginBlock().startIndent.getValue());
  +                childLM.setXOffset(startXOffset);
                   childLM.addAreas(breakPosIter, lc);
                   tableHeight += childLM.getBodyHeight();
               }
  @@ -344,7 +375,7 @@
                                      lfp.getLeafPos() + 1);
               iStartPos = lfp.getLeafPos() + 1;
               while ((childLM = (Body)breakPosIter.getNextChildLM()) != null) {
  -                
childLM.setXOffset(fobj.getCommonMarginBlock().startIndent.getValue());
  +                childLM.setXOffset(startXOffset);
                   childLM.setYOffset(tableHeight);
                   childLM.addAreas(breakPosIter, lc);
                   tableHeight += childLM.getBodyHeight();
  @@ -357,7 +388,7 @@
               List list = pos.list;
               PositionIterator breakPosIter = new BreakPossPosIter(list, 0, 
list.size() + 1);
               while ((childLM = (Body)breakPosIter.getNextChildLM()) != null) {
  -                
childLM.setXOffset(fobj.getCommonMarginBlock().startIndent.getValue());
  +                childLM.setXOffset(startXOffset);
                   childLM.setYOffset(tableHeight);
                   childLM.addAreas(breakPosIter, lc);
                   tableHeight += childLM.getBodyHeight();
  
  
  
  1.13      +9 -16     xml-fop/src/java/org/apache/fop/layoutmgr/table/Body.java
  
  Index: Body.java
  ===================================================================
  RCS file: 
/home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/table/Body.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- Body.java 31 Jan 2005 21:16:45 -0000      1.12
  +++ Body.java 9 Feb 2005 15:38:15 -0000       1.13
  @@ -18,6 +18,8 @@
    
   package org.apache.fop.layoutmgr.table;
   
  +import java.util.List;
  +
   import org.apache.fop.fo.flow.TableBody;
   import org.apache.fop.layoutmgr.LayoutManager;
   import org.apache.fop.layoutmgr.BlockStackingLayoutManager;
  @@ -32,9 +34,6 @@
   import org.apache.fop.area.Block;
   import org.apache.fop.traits.MinOptMax;
   
  -import java.util.ArrayList;
  -import java.util.List;
  -
   /**
    * LayoutManager for a table-header, table-footer and table body FO.
    * These fo objects have either rows or cells underneath.
  @@ -43,19 +42,19 @@
   public class Body extends BlockStackingLayoutManager {
       private TableBody fobj;
       
  -    private boolean rows = true;
       private List columns;
   
       private int xoffset;
       private int yoffset;
       private int bodyHeight;
   
  -    private Block curBlockArea;
  +    //private Block curBlockArea;
   
  -    private List childBreaks = new ArrayList();
  +    private List childBreaks = new java.util.ArrayList();
   
       /**
        * Create a new body layout manager.
  +     * @param node the table-body FO
        */
       public Body(TableBody node) {
           super(node);
  @@ -84,12 +83,6 @@
           MinOptMax stackSize = new MinOptMax();
           BreakPoss lastPos = null;
   
  -        if (columns == null) {
  -            setFinished(true);
  -            log.warn("ignoring fo:table-body with undefined 
fo:table-columns");
  -            return null;
  -        }
  -
           while ((curLM = (Row)getChildLM()) != null) {
               // Make break positions
               // Set up a LayoutContext
  @@ -151,7 +144,7 @@
       /**
        * Set the x offset of this body within the table.
        * This is used to set the row offsets.
  -     * @param value
  +     * @param off the x offset
        */
       public void setXOffset(int off) {
           xoffset = off;
  @@ -185,8 +178,8 @@
           while (parentIter.hasNext()) {
               LeafPosition lfp = (LeafPosition) parentIter.next();
               // Add the block areas to Area
  -            PositionIterator breakPosIter =
  -              new BreakPossPosIter(childBreaks, iStartPos,
  +            PositionIterator breakPosIter 
  +                = new BreakPossPosIter(childBreaks, iStartPos,
                                      lfp.getLeafPos() + 1);
               iStartPos = lfp.getLeafPos() + 1;
               int lastheight = 0;
  @@ -203,7 +196,7 @@
           flush();
   
           childBreaks.clear();
  -        curBlockArea = null;
  +        //curBlockArea = null;
       }
   
       /**
  
  
  
  1.47      +17 -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.46
  retrieving revision 1.47
  diff -u -r1.46 -r1.47
  --- Table.java        9 Feb 2005 11:47:42 -0000       1.46
  +++ Table.java        9 Feb 2005 15:38:15 -0000       1.47
  @@ -24,6 +24,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.properties.CommonAccessibility;
   import org.apache.fop.fo.properties.CommonAural;
   import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
  @@ -73,6 +74,11 @@
       private TableBody tableHeader = null;
       private TableBody tableFooter = null;
   
  +    /** 
  +     * Default table-column used when no columns are specified. It is used
  +     * to handle inheritance (especially visibility) and defaults properly. 
*/
  +    private TableColumn defaultColumn;
  +    
       /**
        * @param parent FONode that is the parent of this object
        */
  @@ -110,6 +116,12 @@
           tableOmitHeaderAtBreak = 
pList.get(PR_TABLE_OMIT_HEADER_AT_BREAK).getEnum();
           //width = pList.get(PR_WIDTH).getLength();
           writingMode = pList.get(PR_WRITING_MODE).getEnum();
  +        
  +        //Create default column in case no table-columns will be defined.
  +        defaultColumn = new TableColumn(this);
  +        PropertyList colPList = new StaticPropertyList(defaultColumn, pList);
  +        colPList.setWritingMode();
  +        defaultColumn.bind(colPList);
       }
   
       /**
  @@ -151,6 +163,11 @@
           return (tableLayout != EN_FIXED);
       }
       
  +    /** @return the default table column */
  +    public TableColumn getDefaultColumn() {
  +        return this.defaultColumn;
  +    }
  +    
       public List getColumns() {
           return columns;
       }
  
  
  

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

Reply via email to