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 pi...@apache.org on 2002/07/20 14:50:01 UTC

cvs commit: xml-fop/src/org/apache/fop/fo/flow AbstractTableBody.java TableBody.java TableCell.java TableColumn.java TableRow.java

pietsch     2002/07/20 05:50:01

  Modified:    src/org/apache/fop/fo/flow Tag: fop-0_20_2-maintain
                        TableBody.java TableCell.java TableColumn.java
                        TableRow.java
  Added:       src/org/apache/fop/fo/flow Tag: fop-0_20_2-maintain
                        AbstractTableBody.java
  Log:
  Better validity checking for table FOs.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.38.2.3  +2 -229    xml-fop/src/org/apache/fop/fo/flow/TableBody.java
  
  Index: TableBody.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/flow/TableBody.java,v
  retrieving revision 1.38.2.2
  retrieving revision 1.38.2.3
  diff -u -r1.38.2.2 -r1.38.2.3
  --- TableBody.java	23 Apr 2002 22:24:44 -0000	1.38.2.2
  +++ TableBody.java	20 Jul 2002 12:50:00 -0000	1.38.2.3
  @@ -18,7 +18,7 @@
   import java.util.Vector;
   import java.util.Enumeration;
   
  -public class TableBody extends FObj {
  +public class TableBody extends AbstractTableBody {
   
       public static class Maker extends FObj.Maker {
           public FObj make(FObj parent,
  @@ -32,236 +32,9 @@
           return new TableBody.Maker();
       }
   
  -    int spaceBefore;
  -    int spaceAfter;
  -    String id;
  -
  -    Vector columns;
  -    RowSpanMgr rowSpanMgr;    // manage information about spanning rows
  -
  -    AreaContainer areaContainer;
  -
       public TableBody(FObj parent, PropertyList propertyList) {
           super(parent, propertyList);
           this.name = "fo:table-body";
  -    }
  -
  -    public void setColumns(Vector columns) {
  -        this.columns = columns;
  -    }
  -
  -    public void setYPosition(int value) {
  -        areaContainer.setYPosition(value);
  -    }
  -
  -    public int getYPosition() {
  -        return areaContainer.getCurrentYPosition();
  -    }
  -
  -    public int getHeight() {
  -        return areaContainer.getHeight() + spaceBefore + spaceAfter;
  -    }
  -
  -    public Status layout(Area area) throws FOPException {
  -        if (this.marker == BREAK_AFTER) {
  -            return new Status(Status.OK);
  -        }
  -
  -        if (this.marker == START) {
  -
  -            // Common Accessibility Properties
  -            AccessibilityProps mAccProps = propMgr.getAccessibilityProps();
  -
  -            // Common Aural Properties
  -            AuralProps mAurProps = propMgr.getAuralProps();
  -
  -            // Common Border, Padding, and Background Properties
  -            BorderAndPadding bap = propMgr.getBorderAndPadding();
  -            BackgroundProps bProps = propMgr.getBackgroundProps();
  -
  -            // Common Relative Position Properties        
  -            RelativePositionProps mRelProps = propMgr.getRelativePositionProps();
  -        
  -            // this.properties.get("id");
  -
  -            this.spaceBefore =
  -                this.properties.get("space-before.optimum").getLength().mvalue();
  -            this.spaceAfter =
  -                this.properties.get("space-after.optimum").getLength().mvalue();
  -            this.id = this.properties.get("id").getString();
  -
  -            area.getIDReferences().createID(id);
  -
  -            if (area instanceof BlockArea) {
  -                area.end();
  -            }
  -
  -            if (rowSpanMgr == null) {
  -                rowSpanMgr = new RowSpanMgr(columns.size());
  -            }
  -
  -            // if (this.isInListBody) {
  -            // startIndent += bodyIndent + distanceBetweenStarts;
  -            // }
  -
  -            this.marker = 0;
  -
  -        }
  -
  -        if ((spaceBefore != 0) && (this.marker == 0)) {
  -            area.increaseHeight(spaceBefore);
  -        }
  -
  -        if (marker == 0) {
  -            // configure id
  -            area.getIDReferences().configureID(id, area);
  -        }
  -
  -        int spaceLeft = area.spaceLeft();
  -
  -        /*
  -         * Note: the parent FO must be a Table. The parent Area is the Block
  -         * type area created by the Table, which is also a reference area.
  -         * The content "width" (IPD) of the TableBody is the same as that
  -         * of the containing table area, and its relative position is 0,0.
  -         * Strictly speaking (CR), this FO should generate no areas!
  -         */
  -        this.areaContainer =
  -            new AreaContainer(propMgr.getFontState(area.getFontInfo()), 0,
  -                              area.getContentHeight(),
  -                              area.getContentWidth(),    // IPD
  -        area.spaceLeft(), Position.RELATIVE);
  -        areaContainer.foCreator = this;                  // G Seshadri
  -        areaContainer.setPage(area.getPage());
  -        areaContainer.setBackground(propMgr.getBackgroundProps());
  -        areaContainer.setBorderAndPadding(propMgr.getBorderAndPadding());
  -        areaContainer.start();
  -
  -        areaContainer.setAbsoluteHeight(area.getAbsoluteHeight());
  -        areaContainer.setIDReferences(area.getIDReferences());
  -
  -        Vector keepWith = new Vector();
  -        int numChildren = this.children.size();
  -        TableRow lastRow = null;
  -        boolean endKeepGroup = true;
  -        for (int i = this.marker; i < numChildren; i++) {
  -            Object child = children.elementAt(i);
  -            if (!(child instanceof TableRow)) {
  -                throw new FOPException("Currently only Table Rows are supported in table body, header and footer");
  -            }
  -            TableRow row = (TableRow)child;
  -
  -            row.setRowSpanMgr(rowSpanMgr);
  -            row.setColumns(columns);
  -            row.doSetup(areaContainer);
  -            if (row.getKeepWithPrevious().getType()
  -                    != KeepValue.KEEP_WITH_AUTO && lastRow != null
  -                                                && keepWith.indexOf(lastRow)
  -                                                   == -1) {
  -                keepWith.addElement(lastRow);
  -            } else {
  -                if (endKeepGroup && keepWith.size() > 0) {
  -                    keepWith = new Vector();
  -                }
  -            }
  -
  -            Status status;
  -            if ((status = row.layout(areaContainer)).isIncomplete()) {
  -                // BUG!!! don't distinguish between break-before and after!
  -                if (status.isPageBreak()) {
  -                    this.marker = i;
  -                    area.addChild(areaContainer);
  -                    // areaContainer.end();
  -
  -                    area.increaseHeight(areaContainer.getHeight());
  -                    area.setAbsoluteHeight(areaContainer.getAbsoluteHeight());
  -                    if (i == numChildren - 1) {
  -                        this.marker = BREAK_AFTER;
  -                        if (spaceAfter != 0) {
  -                            area.increaseHeight(spaceAfter);
  -                        }
  -                    }
  -                    return status;
  -                }
  -                if ((keepWith.size() > 0)
  -                    && (!rowSpanMgr.ignoreKeeps())) {
  -                    // && status.getCode() == Status.AREA_FULL_NONE
  -                    // FIXME!!! Handle rows spans!!!
  -                    row.removeLayout(areaContainer);
  -                    for (Enumeration e = keepWith.elements();
  -                            e.hasMoreElements(); ) {
  -                        TableRow tr = (TableRow)e.nextElement();
  -                        tr.removeLayout(areaContainer);
  -                        i--;
  -                    }
  -                    if (i == 0) {
  -                        resetMarker();
  -
  -                        // Fix for infinite loop bug if keeps are too big for page
  -                        rowSpanMgr.setIgnoreKeeps(true);
  -
  -                        return new Status(Status.AREA_FULL_NONE);
  -                    }
  -                }
  -                this.marker = i;
  -                if ((i != 0) && (status.getCode() == Status.AREA_FULL_NONE)) {
  -                    status = new Status(Status.AREA_FULL_SOME);
  -                }
  -                if (!((i == 0) && (areaContainer.getContentHeight() <= 0))) {
  -                    area.addChild(areaContainer);
  -                    // areaContainer.end();
  -
  -                    area.increaseHeight(areaContainer.getHeight());
  -                    area.setAbsoluteHeight(areaContainer.getAbsoluteHeight());
  -                }
  -
  -                // Fix for infinite loop bug if spanned rows are too big for page
  -                rowSpanMgr.setIgnoreKeeps(true);
  -
  -                return status;
  -            } else if (status.getCode() == Status.KEEP_WITH_NEXT
  -                       || rowSpanMgr.hasUnfinishedSpans()) {
  -                keepWith.addElement(row);
  -                endKeepGroup = false;
  -            } else {
  -                endKeepGroup = true;
  -            }
  -            lastRow = row;
  -            area.setMaxHeight(area.getMaxHeight() - spaceLeft
  -                              + this.areaContainer.getMaxHeight());
  -            spaceLeft = area.spaceLeft();
  -        }
  -        area.addChild(areaContainer);
  -        areaContainer.end();
  -
  -        area.increaseHeight(areaContainer.getHeight());
  -
  -        area.setAbsoluteHeight(areaContainer.getAbsoluteHeight());
  -
  -        if (spaceAfter != 0) {
  -            area.increaseHeight(spaceAfter);
  -            area.setMaxHeight(area.getMaxHeight() - spaceAfter);
  -        }
  -
  -        if (area instanceof BlockArea) {
  -            area.start();
  -        }
  -
  -        return new Status(Status.OK);
  -    }
  -
  -    public void removeLayout(Area area) {
  -        if (areaContainer != null) {
  -            area.removeChild(areaContainer);
  -        }
  -        if (spaceBefore != 0) {
  -            area.increaseHeight(-spaceBefore);
  -        }
  -        if (spaceAfter != 0) {
  -            area.increaseHeight(-spaceAfter);
  -        }
  -        this.resetMarker();
  -        this.removeID(area.getIDReferences());
       }
   
   }
  
  
  
  1.39.2.2  +7 -2      xml-fop/src/org/apache/fop/fo/flow/TableCell.java
  
  Index: TableCell.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/flow/TableCell.java,v
  retrieving revision 1.39.2.1
  retrieving revision 1.39.2.2
  diff -u -r1.39.2.1 -r1.39.2.2
  --- TableCell.java	23 Apr 2002 22:24:44 -0000	1.39.2.1
  +++ TableCell.java	20 Jul 2002 12:50:00 -0000	1.39.2.2
  @@ -95,9 +95,14 @@
   
       AreaContainer cellArea;
   
  -    public TableCell(FObj parent, PropertyList propertyList) {
  +    public TableCell(FObj parent, PropertyList propertyList)
  +        throws FOPException {
           super(parent, propertyList);
           this.name = "fo:table-cell";
  +        if (!(parent instanceof TableRow)) {
  +            throw new FOPException("A table cell must be child of fo:table-row,"
  +                                   + " not " + parent.getName());
  +        }
           doSetup();    // init some basic property values
       }
   
  
  
  
  1.20.2.2  +7 -2      xml-fop/src/org/apache/fop/fo/flow/TableColumn.java
  
  Index: TableColumn.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/flow/TableColumn.java,v
  retrieving revision 1.20.2.1
  retrieving revision 1.20.2.2
  diff -u -r1.20.2.1 -r1.20.2.2
  --- TableColumn.java	23 Apr 2002 22:24:44 -0000	1.20.2.1
  +++ TableColumn.java	20 Jul 2002 12:50:00 -0000	1.20.2.2
  @@ -38,9 +38,14 @@
           return new TableColumn.Maker();
       }
   
  -    public TableColumn(FObj parent, PropertyList propertyList) {
  +    public TableColumn(FObj parent, PropertyList propertyList)
  +        throws FOPException {
           super(parent, propertyList);
           this.name = "fo:table-column";
  +        if (!(parent instanceof Table)) {
  +            throw new FOPException("A table column must be child of fo:table, not "
  +                                   + parent.getName());
  +        }
       }
   
       public Length getColumnWidthAsLength() {
  
  
  
  1.51.2.2  +8 -2      xml-fop/src/org/apache/fop/fo/flow/TableRow.java
  
  Index: TableRow.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/flow/TableRow.java,v
  retrieving revision 1.51.2.1
  retrieving revision 1.51.2.2
  diff -u -r1.51.2.1 -r1.51.2.2
  --- TableRow.java	23 Apr 2002 22:24:44 -0000	1.51.2.1
  +++ TableRow.java	20 Jul 2002 12:50:00 -0000	1.51.2.2
  @@ -171,9 +171,15 @@
       }
   
   
  -    public TableRow(FObj parent, PropertyList propertyList) {
  +    public TableRow(FObj parent, PropertyList propertyList)
  +        throws FOPException {
           super(parent, propertyList);
           this.name = "fo:table-row";
  +        if (!(parent instanceof AbstractTableBody)) {
  +            throw new FOPException("A table row must be child of fo:table-body,"
  +                                   + " fo:table-header or fo:table-footer, not "
  +                                   + parent.getName());
  +        }
       }
   
       public void setColumns(Vector columns) {
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.1   +259 -0    xml-fop/src/org/apache/fop/fo/flow/Attic/AbstractTableBody.java
  
  
  
  

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