jeremias    2005/02/08 03:21:57

  Modified:    src/java/org/apache/fop/layoutmgr/table Row.java Cell.java
  Log:
  Initial support for column spanning. Still WIP.
  
  Revision  Changes    Path
  1.19      +56 -24    xml-fop/src/java/org/apache/fop/layoutmgr/table/Row.java
  
  Index: Row.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/table/Row.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- Row.java  8 Feb 2005 10:10:00 -0000       1.18
  +++ Row.java  8 Feb 2005 11:21:57 -0000       1.19
  @@ -134,17 +134,20 @@
           LayoutManager curLM; // currently active LM
   
           BreakPoss lastPos = null;
  -        List breakList = new ArrayList();
  +        List breakList = new java.util.ArrayList();
  +        List spannedColumns = new java.util.ArrayList();
   
           int min = 0;
           int opt = 0;
           int max = 0;
   
  -        int cellcount = 0;
  +        int startColumn = 1;
  +        int cellLMIndex = 0;
           boolean over = false;
   
  -        while ((curLM = getCellLM(cellcount++)) != null) {
  -
  +        while ((curLM = getCellLM(cellLMIndex++)) != null) {
  +            Cell cellLM = (Cell)curLM;
  +            
               List childBreaks = new ArrayList();
               MinOptMax stackSize = new MinOptMax();
   
  @@ -158,14 +161,19 @@
                     MinOptMax.subtract(context.getStackLimit(),
                                        stackSize));
   
  -            int size = columns.size();
  -            Column col;
  -            if (cellcount > size - 1) {
  -                col = (Column)columns.get(size - 1);
  -            } else {
  -                col = (Column)columns.get(cellcount - 1);
  +            getColumnsForCell(cellLM, startColumn, spannedColumns);
  +            int childRefIPD = 0;
  +            Iterator i = spannedColumns.iterator();
  +            while (i.hasNext()) {
  +                Column col = (Column)i.next();
  +                childRefIPD += col.getWidth().getValue();
  +            }
  +            //Handle border-separation when border-collapse="separate"
  +            if (getTable().getBorderCollapse() == EN_SEPARATE) {
  +                childRefIPD += (spannedColumns.size() - 1) 
  +                    * 
getTable().getBorderSeparation().getIPD().getLength().getValue();
               }
  -            childLC.setRefIPD(col.getWidth().getValue());
  +            childLC.setRefIPD(childRefIPD);
   
               while (!curLM.isFinished()) {
                   if ((bp = curLM.getNextBreakPoss(childLC)) != null) {
  @@ -210,6 +218,8 @@
               }
   
               breakList.add(childBreaks);
  +            
  +            startColumn += cellLM.getFObj().getNumberColumnsSpanned();
           }
           MinOptMax rowSize = new MinOptMax(min, opt, max);
           LengthRangeProperty specifiedBPD = 
fobj.getBlockProgressionDimension();
  @@ -224,8 +234,9 @@
           rowHeight = rowSize.opt;
   
           boolean fin = true;
  -        cellcount = 0;
  -        while ((curLM = getCellLM(cellcount++)) != null) {
  +        cellLMIndex = 0;
  +        //Check if any of the cell LMs haven't finished, yet
  +        while ((curLM = getCellLM(cellLMIndex++)) != null) {
               if (!curLM.isFinished()) {
                   fin = false;
                   break;
  @@ -243,6 +254,34 @@
       }
   
       /**
  +     * Gets the Column at a given index.
  +     * @param index index of the column (index must be >= 1)
  +     * @return the requested Column
  +     */
  +    private Column getColumn(int index) {
  +        int size = columns.size();
  +        if (index > size - 1) {
  +            return (Column)columns.get(size - 1);
  +        } else {
  +            return (Column)columns.get(index - 1);
  +        }
  +    }
  +    
  +    /**
  +     * Determines the columns that are spanned by the given cell.
  +     * @param cellLM table-cell LM
  +     * @param startCell starting cell index (must be >= 1)
  +     * @param spannedColumns List to receive the applicable columns
  +     */
  +    private void getColumnsForCell(Cell cellLM, int startCell, List 
spannedColumns) {
  +        int count = cellLM.getFObj().getNumberColumnsSpanned();
  +        spannedColumns.clear();
  +        for (int i = 0; i < count; i++) {
  +            spannedColumns.add(getColumn(startCell + i));
  +        }
  +    }
  +
  +    /**
        * Reset the layoutmanager "iterator" so that it will start
        * with the passed Position's generating LM
        * on the next call to getChildLM.
  @@ -330,26 +369,19 @@
               //int x = (TableLayoutManager)getParent()).;
               for (Iterator iter = lfp.cellBreaks.iterator(); iter.hasNext();) 
{
                   List cellsbr = (List)iter.next();
  -                PositionIterator breakPosIter;
  +                BreakPossPosIter breakPosIter;
                   breakPosIter = new BreakPossPosIter(cellsbr, 0, 
cellsbr.size());
                   iStartPos = lfp.getLeafPos() + 1;
   
  -                int size = columns.size();
  -                Column col;
  -                if (cellcount > size - 1) {
  -                   col = (Column)columns.get(size - 1);
  -                } else {
  -                    col = (Column)columns.get(cellcount);
  -                    cellcount++;
  -                }
  -
  +                int cellWidth = 0;
                   while ((childLM = (Cell)breakPosIter.getNextChildLM()) != 
null) {
  +                    cellWidth = childLM.getReferenceIPD();
                       childLM.setXOffset(x);
                       childLM.setYOffset(yoffset);
                       childLM.setRowHeight(rowHeight);
                       childLM.addAreas(breakPosIter, lc);
                   }
  -                x += col.getWidth().getValue();
  +                x += cellWidth;
                   
                   //Handle border-separation
                   Table table = getTable();
  
  
  
  1.16      +14 -1     xml-fop/src/java/org/apache/fop/layoutmgr/table/Cell.java
  
  Index: Cell.java
  ===================================================================
  RCS file: 
/home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/table/Cell.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- Cell.java 8 Feb 2005 10:10:00 -0000       1.15
  +++ Cell.java 8 Feb 2005 11:21:57 -0000       1.16
  @@ -52,6 +52,7 @@
   
       private int xoffset;
       private int yoffset;
  +    private int referenceIPD;
       private int cellIPD;
       private int rowHeight;
       private int usedBPD;
  @@ -59,12 +60,23 @@
   
       /**
        * Create a new Cell layout manager.
  +     * @node table-cell FO for which to create the LM
        */
       public Cell(TableCell node) {
           super(node);
           fobj = node;
       }
   
  +    /** @return the table-cell FO */
  +    public TableCell getFObj() {
  +        return this.fobj;
  +    }
  +    
  +    /** @return this cell's reference IPD */
  +    public int getReferenceIPD() {
  +        return this.referenceIPD;
  +    }
  +    
       private int getIPIndents() {
           int iIndents = 0;
           iIndents += 
fobj.getCommonBorderPaddingBackground().getIPPaddingAndBorder(false);
  @@ -90,7 +102,8 @@
           // stackSize.add(spaceBefore);
           BreakPoss lastPos = null;
   
  -        cellIPD = context.getRefIPD();
  +        referenceIPD = context.getRefIPD(); 
  +        cellIPD = referenceIPD;
           cellIPD -= getIPIndents();
   
           while ((curLM = getChildLM()) != null) {
  
  
  

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

Reply via email to