You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by je...@apache.org on 2005/05/12 15:55:19 UTC

cvs commit: xml-fop/src/java/org/apache/fop/layoutmgr/table TableLayoutManager.java Column.java Body.java OldGridUnit.java Row.java

jeremias    2005/05/12 06:55:19

  Modified:    src/java/org/apache/fop/layoutmgr/table Tag:
                        Temp_KnuthStylePageBreaking TableLayoutManager.java
  Removed:     src/java/org/apache/fop/layoutmgr/table Tag:
                        Temp_KnuthStylePageBreaking Column.java Body.java
                        OldGridUnit.java Row.java
  Log:
  Pretty radical clean-up.
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.21.2.6  +10 -413   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.21.2.5
  retrieving revision 1.21.2.6
  diff -u -r1.21.2.5 -r1.21.2.6
  --- TableLayoutManager.java	11 May 2005 00:17:58 -0000	1.21.2.5
  +++ TableLayoutManager.java	12 May 2005 13:55:19 -0000	1.21.2.6
  @@ -30,11 +30,8 @@
   import org.apache.fop.layoutmgr.KnuthPenalty;
   import org.apache.fop.layoutmgr.LayoutManager;
   import org.apache.fop.layoutmgr.LeafPosition;
  -import org.apache.fop.layoutmgr.BreakPoss;
   import org.apache.fop.layoutmgr.LayoutContext;
  -import org.apache.fop.layoutmgr.NonLeafPosition;
   import org.apache.fop.layoutmgr.PositionIterator;
  -import org.apache.fop.layoutmgr.BreakPossPosIter;
   import org.apache.fop.layoutmgr.Position;
   import org.apache.fop.layoutmgr.TraitSetter;
   import org.apache.fop.area.Area;
  @@ -59,16 +56,10 @@
       private Table fobj;
       
       private TableContentLayoutManager contentLM; 
  -    private List oldColumns = null;
       private ColumnSetup columns = null;
   
       private Block curBlockArea;
   
  -    private List bodyBreaks = new java.util.ArrayList();
  -    private BreakPoss headerBreak;
  -    private BreakPoss footerBreak;
  -    private boolean firstRowHandled = false;
  -    
       private int referenceIPD;
       private boolean autoLayout = true;
   
  @@ -101,14 +92,8 @@
       }
       
       /**
  -     * Set the oldColumns for this table.
  -     *
  -     * @param cols the list of column layout managers
  +     * @return the column setup for this table.
        */
  -    public void setColumns(List cols) {
  -        oldColumns = cols;
  -    }
  -
       public ColumnSetup getColumns() {
           return this.columns;
       }
  @@ -137,7 +122,7 @@
        */
       public LinkedList getNextKnuthElements(LayoutContext context, int alignment) {
           
  -        Body curLM; // currently active LM
  +        //Body curLM; // currently active LM
   
           referenceIPD = context.getRefIPD();
           if (fobj.getInlineProgressionDimension().getOptimum().getEnum() != EN_AUTO) {
  @@ -157,18 +142,11 @@
               stackSize.add(spaceBefore);
           }
   
  -        BreakPoss lastPos = null;
  -
           fobj.setLayoutDimension(PercentBase.BLOCK_IPD, referenceIPD);
           fobj.setLayoutDimension(PercentBase.BLOCK_BPD, context.getStackLimit().opt);
           fobj.setLayoutDimension(PercentBase.REFERENCE_AREA_IPD, referenceIPD);
           fobj.setLayoutDimension(PercentBase.REFERENCE_AREA_BPD, context.getStackLimit().opt);
   
  -        /*
  -        if (oldColumns == 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;
  @@ -189,27 +167,12 @@
                                         (contentIPD - sumCols) / factors);
               }
           }
  -        
  -        LinkedList headerElements = null;
  -        LinkedList footerElements = null;
  -        if (getTable().getTableHeader() != null) {
  -            Body tableHeader = new Body(getTable().getTableHeader());
  -            tableHeader.setParent(this);
  -            headerElements = getKnuthElementsForHeaderFooter(
  -                    tableHeader, context, alignment);
  -        }
  -        if (getTable().getTableFooter() != null) {
  -            Body tableFooter = new Body(getTable().getTableFooter());
  -            tableFooter.setParent(this);
  -            footerElements = getKnuthElementsForHeaderFooter(
  -                    tableFooter, context, alignment);
  -        }
   
           LinkedList returnedList = null;
           LinkedList contentList = new LinkedList();
           LinkedList returnList = new LinkedList();
  -        Position returnPosition = new NonLeafPosition(this, null);
  -        Body prevLM = null;
  +        //Position returnPosition = new NonLeafPosition(this, null);
  +        //Body prevLM = null;
   
           LayoutContext childLC = new LayoutContext(0);
           childLC.setStackLimit(
  @@ -243,12 +206,13 @@
   
                   return returnList;
               } else {
  +                /*
                   if (prevLM != null) {
                       // there is a block handled by prevLM
                       // before the one handled by curLM
                       if (mustKeepTogether() 
  -                            /*|| prevLM.mustKeepWithNext()
  -                            || curLM.mustKeepWithPrevious()*/) {
  +                            || prevLM.mustKeepWithNext()
  +                            || curLM.mustKeepWithPrevious()) {
                           // add an infinite penalty to forbid a break between
                           // blocks
                           contentList.add(new KnuthPenalty(0,
  @@ -263,7 +227,7 @@
                           // it is a feasible breakpoint, there is no need to add
                           // a penalty
                       }
  -                }
  +                }*/
                   contentList.addAll(returnedList);
                   /*
                   if (returnedList.size() == 0) {
  @@ -292,349 +256,6 @@
       }
       
       /**
  -     * Get the next break possibility.
  -     * The break possibility depends on the height of the header and footer
  -     * and possible breaks inside the table body.
  -     *
  -     * @param context the layout context for finding breaks
  -     * @return the next break possibility
  -     *//*
  -    public BreakPoss getNextBreakPossOLDOLDOLD(LayoutContext context) {
  -        Body curLM; // currently active LM
  -
  -        referenceIPD = context.getRefIPD();
  -        if (fobj.getInlineProgressionDimension().getOptimum().getEnum() != EN_AUTO) {
  -            referenceIPD = fobj.getInlineProgressionDimension().getOptimum().getLength().getValue();
  -        }
  -        if (referenceIPD > context.getRefIPD()) {
  -            log.warn("Allocated IPD exceeds available reference IPD");
  -        }
  -        int contentIPD = referenceIPD - getIPIndents();
  -
  -        MinOptMax stackSize = new MinOptMax();
  -        //Add spacing
  -        if (spaceAfter != null) {
  -            stackSize.add(spaceAfter);
  -        }
  -        if (spaceBefore != null) {
  -            stackSize.add(spaceBefore);
  -        }
  -
  -        BreakPoss lastPos = null;
  -
  -        fobj.setLayoutDimension(PercentBase.BLOCK_IPD, referenceIPD);
  -        fobj.setLayoutDimension(PercentBase.BLOCK_BPD, context.getStackLimit().opt);
  -        fobj.setLayoutDimension(PercentBase.REFERENCE_AREA_IPD, referenceIPD);
  -        fobj.setLayoutDimension(PercentBase.REFERENCE_AREA_BPD, context.getStackLimit().opt);
  -
  -        if (columns.getColumnCount() == 0) {
  -            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;
  -        float factors = 0;
  -        if (oldColumns != null) {
  -            for (Iterator i = oldColumns.iterator(); i.hasNext(); ) {
  -                Column column = (Column) i.next();
  -                Length width = column.getWidth();
  -                sumCols += width.getValue();
  -                if (width instanceof TableColLength) {
  -                    factors += ((TableColLength) width).getTableUnits();
  -                }
  -            }
  -        }
  -        // sets TABLE_UNITS in case where one or more oldColumns is defined using 
  -        // proportional-column-width
  -        if (sumCols < contentIPD) {
  -            if (fobj.getLayoutDimension(PercentBase.TABLE_UNITS).floatValue() == 0.0) {
  -                fobj.setLayoutDimension(PercentBase.TABLE_UNITS,
  -                                      (contentIPD - sumCols) / factors);
  -            }
  -        }
  -        
  -        boolean headerFooterBuilt = false;
  -
  -        while ((curLM = (Body)getChildLM()) != null) {
  -            if (!headerFooterBuilt) {
  -                //Calculate the headers and footers only when needed
  -                MinOptMax headerSize = null;
  -                if (getTable().getTableHeader() != null) {
  -                    if (!getTable().omitHeaderAtBreak() || !firstRowHandled) {
  -                        Body tableHeader = new Body(getTable().getTableHeader());
  -                        tableHeader.setParent(this);
  -                        headerBreak = getHeightOLDOLDOLD(tableHeader, context);
  -                        headerSize = headerBreak.getStackingSize();
  -                        stackSize.add(headerSize);
  -                    }
  -                }
  -
  -                //TODO Implement table-omit-footer-at-break once the page breaking
  -                //is improved, so we don't have to do this twice
  -                MinOptMax footerSize = null;
  -                if (getTable().getTableFooter() != null) {
  -                    Body tableFooter = new Body(getTable().getTableFooter());
  -                    tableFooter.setParent(this);
  -                    footerBreak = getHeightOLDOLDOLD(tableFooter, context);
  -                    footerSize = footerBreak.getStackingSize();
  -                    stackSize.add(footerSize);
  -                }
  -
  -                if (stackSize.opt > context.getStackLimit().max) {
  -                    BreakPoss breakPoss = new BreakPoss(
  -                                            new LeafPosition(this, 0));
  -                    breakPoss.setFlag(BreakPoss.NEXT_OVERFLOWS, true);
  -                    breakPoss.setStackingSize(stackSize);
  -                    return breakPoss;
  -                }
  -                headerFooterBuilt = true;
  -            }
  -            
  -            // Make break positions
  -            // Set up a LayoutContext
  -            int ipd = context.getRefIPD();
  -            BreakPoss bp;
  -
  -            LayoutContext childLC = new LayoutContext(0);
  -            childLC.setStackLimit(
  -                  MinOptMax.subtract(context.getStackLimit(),
  -                                     stackSize));
  -            childLC.setRefIPD(ipd);
  -
  -            curLM.setColumns(oldColumns);
  -
  -            boolean over = false;
  -            while (!curLM.isFinished()) {
  -                if ((bp = curLM.getNextBreakPoss(childLC)) != null) {
  -                    if (stackSize.opt + bp.getStackingSize().opt > context.getStackLimit().max) {
  -                        // reset to last break
  -                        if (lastPos != null) {
  -                            LayoutManager lm = lastPos.getLayoutManager();
  -                            lm.resetPosition(lastPos.getPosition());
  -                            if (lm != curLM) {
  -                                curLM.resetPosition(null);
  -                            }
  -                        } else {
  -                            curLM.resetPosition(null);
  -                        }
  -                        over = true;
  -                        break;
  -                    }
  -                    stackSize.add(bp.getStackingSize());
  -                    lastPos = bp;
  -                    bodyBreaks.add(bp);
  -                    firstRowHandled = true;
  -
  -                    if (bp.nextBreakOverflows()) {
  -                        over = true;
  -                        break;
  -                    }
  -
  -                    childLC.setStackLimit(MinOptMax.subtract(
  -                                             context.getStackLimit(), stackSize));
  -                }
  -            }
  -            BreakPoss breakPoss = new BreakPoss(
  -                                    new LeafPosition(this, bodyBreaks.size() - 1));
  -            if (over) {
  -                breakPoss.setFlag(BreakPoss.NEXT_OVERFLOWS, true);
  -            }
  -            breakPoss.setStackingSize(stackSize);
  -            return breakPoss;
  -        }
  -        setFinished(true);
  -        return null;
  -    }*/
  -
  -    /*
  -    private void createColumnsFromFirstRow() {
  -        this.oldColumns = new java.util.ArrayList();
  -        //TODO Create oldColumns from first row here 
  -        //--> rule 2 in "fixed table layout", see CSS2, 17.5.2
  -        //Alternative: extend oldColumns on-the-fly, but in this case we need the
  -        //new property evaluation context so proportional-column-width() works
  -        //correctly.
  -        if (oldColumns.size() == 0) {
  -            Column col = new Column(getTable().getDefaultColumn());
  -            col.setParent(this);
  -            this.oldColumns.add(col);
  -        }
  -    }*/
  -    
  -    /**
  -     * @param column the column to check
  -     * @return true if the column is the first column
  -     */
  -    public boolean isFirst(Column column) {
  -        return (this.oldColumns.size() == 0 || this.oldColumns.get(0) == column);
  -    }
  -    
  -    /**
  -     * @param column the column to check
  -     * @return true if the column is the last column
  -     */
  -    public boolean isLast(Column column) {
  -        return (this.oldColumns.size() == 0 || this.oldColumns.get(oldColumns.size() - 1) == column);
  -    }
  -    
  -    /**
  -     * Get the break possibility and height of the table header or footer.
  -     *
  -     * @param lm the header or footer layout manager
  -     * @param context the parent layout context
  -     * @return the break possibility containing the stacking size
  -     */
  -    protected LinkedList getKnuthElementsForHeaderFooter(Body lm, LayoutContext context, 
  -                int alignment) {
  -        int referenceIPD = context.getRefIPD();
  -        int contentIPD = referenceIPD - getIPIndents();
  -        BreakPoss bp;
  -
  -        MinOptMax stackSize = new MinOptMax();
  -
  -        LayoutContext childLC = new LayoutContext(0);
  -        childLC.setStackLimit(context.getStackLimit());
  -        childLC.setRefIPD(contentIPD);
  -
  -        lm.setColumns(oldColumns);
  -
  -        LinkedList returnedList = null;
  -        LinkedList contentList = new LinkedList();
  -        LinkedList returnList = new LinkedList();
  -        Position returnPosition = new NonLeafPosition(this, null);
  -        
  -        Row curLM; // currently active LM
  -        Row prevLM = null; // previously active LM
  -        while ((curLM = (Row)getChildLM()) != null) {
  -
  -            // get elements from curLM
  -            returnedList = curLM.getNextKnuthElements(childLC, alignment);
  -            /*
  -            if (returnedList.size() == 1
  -                    && ((KnuthElement) returnedList.getFirst()).isPenalty()
  -                    && ((KnuthPenalty) returnedList.getFirst()).getP() == -KnuthElement.INFINITE) {
  -                // a descendant of this block has break-before
  -                if (returnList.size() == 0) {
  -                    // the first child (or its first child ...) has
  -                    // break-before;
  -                    // all this block, including space before, will be put in
  -                    // the
  -                    // following page
  -                    bSpaceBeforeServed = false;
  -                }
  -                contentList.addAll(returnedList);
  -
  -                // "wrap" the Position inside each element
  -                // moving the elements from contentList to returnList
  -                returnedList = new LinkedList();
  -                wrapPositionElements(contentList, returnList);
  -
  -                return returnList;
  -            } else*/ {
  -                if (prevLM != null) {
  -                    // there is a block handled by prevLM
  -                    // before the one handled by curLM
  -                    if (mustKeepTogether() 
  -                            || prevLM.mustKeepWithNext()
  -                            || curLM.mustKeepWithPrevious()) {
  -                        // add an infinite penalty to forbid a break between
  -                        // blocks
  -                        contentList.add(new KnuthPenalty(0,
  -                                KnuthElement.INFINITE, false,
  -                                new Position(this), false));
  -                    } else if (!((KnuthElement) contentList.getLast()).isGlue()) {
  -                        // add a null penalty to allow a break between blocks
  -                        contentList.add(new KnuthPenalty(0, 0, false,
  -                                new Position(this), false));
  -                    } else {
  -                        // the last element in contentList is a glue;
  -                        // it is a feasible breakpoint, there is no need to add
  -                        // a penalty
  -                    }
  -                }
  -                contentList.addAll(returnedList);
  -                if (returnedList.size() == 0) {
  -                    //Avoid NoSuchElementException below (happens with empty blocks)
  -                    continue;
  -                }
  -                if (((KnuthElement) returnedList.getLast()).isPenalty()
  -                        && ((KnuthPenalty) returnedList.getLast()).getP() == -KnuthElement.INFINITE) {
  -                    // a descendant of this block has break-after
  -                    if (curLM.isFinished()) {
  -                        // there is no other content in this block;
  -                        // it's useless to add space after before a page break
  -                        setFinished(true);
  -                    }
  -
  -                    returnedList = new LinkedList();
  -                    wrapPositionElements(contentList, returnList);
  -
  -                    return returnList;
  -                }
  -            }
  -            prevLM = curLM;
  -        }
  -
  -        /*
  -        List breaks = new java.util.ArrayList();
  -        while (!lm.isFinished()) {
  -            if ((bp = lm.getNextBreakPoss(childLC)) != null) {
  -                stackSize.add(bp.getStackingSize());
  -                breaks.add(bp);
  -                childLC.setStackLimit(MinOptMax.subtract(
  -                                         context.getStackLimit(), stackSize));
  -            }
  -        }
  -        BreakPoss breakPoss = new BreakPoss(
  -                               new SectionPosition(this, breaks.size() - 1, breaks));
  -        breakPoss.setStackingSize(stackSize);
  -        return breakPoss;*/
  -
  -        if (returnList.size() > 0) {
  -            return returnList;
  -        } else {
  -            return null;
  -        }
  -        
  -    }
  -
  -    /**
  -     * Get the break possibility and height of the table header or footer.
  -     *
  -     * @param lm the header or footer layout manager
  -     * @param context the parent layout context
  -     * @return the break possibility containing the stacking size
  -     */
  -    protected BreakPoss getHeightOLDOLDOLD(Body lm, LayoutContext context) {
  -        int referenceIPD = context.getRefIPD();
  -        int contentIPD = referenceIPD - getIPIndents();
  -        BreakPoss bp;
  -
  -        MinOptMax stackSize = new MinOptMax();
  -
  -        LayoutContext childLC = new LayoutContext(0);
  -        childLC.setStackLimit(context.getStackLimit());
  -        childLC.setRefIPD(contentIPD);
  -
  -        lm.setColumns(oldColumns);
  -
  -        List breaks = new java.util.ArrayList();
  -        while (!lm.isFinished()) {
  -            if ((bp = lm.getNextBreakPoss(childLC)) != null) {
  -                stackSize.add(bp.getStackingSize());
  -                breaks.add(bp);
  -                childLC.setStackLimit(MinOptMax.subtract(
  -                                         context.getStackLimit(), stackSize));
  -            }
  -        }
  -        BreakPoss breakPoss = new BreakPoss(
  -                               new SectionPosition(this, breaks.size() - 1, breaks));
  -        breakPoss.setStackingSize(stackSize);
  -        return breakPoss;
  -    }
  -
  -    /**
        * The table area is a reference area that contains areas for
        * oldColumns, bodies, rows and the contents are in cells.
        *
  @@ -656,39 +277,15 @@
           // add column, body then row areas
   
           int tableHeight = 0;
  -        Body childLM;
  +        //Body childLM;
           LayoutContext lc = new LayoutContext(0);
   
  -        // add table header areas
  -        if (headerBreak != null) {
  -            SectionPosition pos = (SectionPosition)headerBreak.getPosition();
  -            List list = pos.list;
  -            PositionIterator breakPosIter = new BreakPossPosIter(list, 0, list.size() + 1);
  -            while ((childLM = (Body)breakPosIter.getNextChildLM()) != null) {
  -                childLM.setXOffset(startXOffset);
  -                childLM.addAreas(breakPosIter, lc);
  -                tableHeight += childLM.getBodyHeight();
  -            }
  -        }
   
           lc.setRefIPD(referenceIPD - getIPIndents());
           contentLM.setStartXOffset(startXOffset);
           contentLM.addAreas(parentIter, lc);
           tableHeight += contentLM.getUsedBPD();
   
  -        // add footer areas
  -        if (footerBreak != null) {
  -            SectionPosition pos = (SectionPosition)footerBreak.getPosition();
  -            List list = pos.list;
  -            PositionIterator breakPosIter = new BreakPossPosIter(list, 0, list.size() + 1);
  -            while ((childLM = (Body)breakPosIter.getNextChildLM()) != null) {
  -                childLM.setXOffset(startXOffset);
  -                childLM.setYOffset(tableHeight);
  -                childLM.addAreas(breakPosIter, lc);
  -                tableHeight += childLM.getBodyHeight();
  -            }
  -        }
  -
           curBlockArea.setBPD(tableHeight);
   
           if (fobj.isSeparateBorderModel()) {
  @@ -706,7 +303,7 @@
           // if adjusted space after
           addBlockSpacing(adjust, spaceAfter);
   
  -        bodyBreaks.clear();
  +        //bodyBreaks.clear();
           curBlockArea = null;
       }
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org