pietsch 2003/07/20 13:49:28 Modified: src/org/apache/fop/fo/flow Tag: fop-0_20_2-maintain AbstractTableBody.java Table.java TableCell.java TableFooter.java TableRow.java Log: Added fix (hackery) to release pointers to areas held by table elements, thereby allowing (hopefully) rendering of large tables. Revision Changes Path No revision No revision 1.1.2.10 +12 -9 xml-fop/src/org/apache/fop/fo/flow/Attic/AbstractTableBody.java Index: AbstractTableBody.java =================================================================== RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/flow/Attic/AbstractTableBody.java,v retrieving revision 1.1.2.9 retrieving revision 1.1.2.10 diff -u -r1.1.2.9 -r1.1.2.10 --- AbstractTableBody.java 11 Apr 2003 00:24:38 -0000 1.1.2.9 +++ AbstractTableBody.java 20 Jul 2003 20:49:28 -0000 1.1.2.10 @@ -69,7 +69,8 @@ ArrayList columns; RowSpanMgr rowSpanMgr; // manage information about spanning rows - AreaContainer areaContainer; + // public AreaContainer areaContainer; + public java.lang.ref.WeakReference areaContainerRef; public AbstractTableBody(FObj parent, PropertyList propertyList, String systemId, int line, int column) @@ -87,15 +88,15 @@ } public void setYPosition(int value) { - areaContainer.setYPosition(value); + ((AreaContainer)areaContainerRef.get()).setYPosition(value); } public int getYPosition() { - return areaContainer.getCurrentYPosition(); + return ((AreaContainer)areaContainerRef.get()).getCurrentYPosition(); } public int getHeight() { - return areaContainer.getHeight() + spaceBefore + spaceAfter; + return ((AreaContainer)areaContainerRef.get()).getHeight() + spaceBefore + spaceAfter; } public int layout(Area area) throws FOPException { @@ -170,7 +171,7 @@ * of the containing table area, and its relative position is 0,0. * Strictly speaking (CR), this FO should generate no areas! */ - this.areaContainer = + AreaContainer areaContainer = new AreaContainer(propMgr.getFontState(area.getFontInfo()), 0, area.getContentHeight(), area.getContentWidth(), // IPD @@ -185,6 +186,8 @@ areaContainer.setAbsoluteHeight(area.getAbsoluteHeight()); areaContainer.setIDReferences(area.getIDReferences()); + this.areaContainerRef = new java.lang.ref.WeakReference(areaContainer); + ArrayList keepWith = new ArrayList(); int numChildren = this.children.size(); TableRow lastRow = null; @@ -292,7 +295,7 @@ } lastRow = row; area.setMaxHeight(area.getMaxHeight() - spaceLeft - + this.areaContainer.getMaxHeight()); + + areaContainer.getMaxHeight()); spaceLeft = area.spaceLeft(); } area.addChild(areaContainer); @@ -313,8 +316,8 @@ } public void removeLayout(Area area) { - if (areaContainer != null) { - area.removeChild(areaContainer); + if (areaContainerRef != null) { + area.removeChild((AreaContainer)areaContainerRef.get()); } if (spaceBefore != 0) { area.increaseHeight(-spaceBefore); 1.39.2.12 +22 -13 xml-fop/src/org/apache/fop/fo/flow/Attic/Table.java Index: Table.java =================================================================== RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/flow/Attic/Table.java,v retrieving revision 1.39.2.11 retrieving revision 1.39.2.12 diff -u -r1.39.2.11 -r1.39.2.12 --- Table.java 11 Apr 2003 00:24:39 -0000 1.39.2.11 +++ Table.java 20 Jul 2003 20:49:28 -0000 1.39.2.12 @@ -99,7 +99,8 @@ /** Maximum inline-progression-dimension */ private int maxIPD; - AreaContainer areaContainer; + // public AreaContainer areaContainer; + public java.lang.ref.WeakReference areaContainerRef; public Table(FObj parent, PropertyList propertyList, String systemId, int line, int column) { @@ -179,7 +180,7 @@ area.end(); } // check if anything was previously laid out - if (this.areaContainer == null) { + if (this.areaContainerRef == null) { try { area.getIDReferences().createID(id); } @@ -212,13 +213,14 @@ area.addDisplaySpace(spaceBefore); } - if (marker == 0 && areaContainer == null) { + if (marker == 0 && this.areaContainerRef == null) { // configure id area.getIDReferences().configureID(id, area); } int spaceLeft = area.spaceLeft(); - this.areaContainer = + // Hack alert! + AreaContainer areaContainer = new AreaContainer(propMgr.getFontState(area.getFontInfo()), 0, 0, area.getAllocationWidth(), area.spaceLeft(), Position.STATIC); @@ -232,6 +234,7 @@ areaContainer.setAbsoluteHeight(area.getAbsoluteHeight()); areaContainer.setIDReferences(area.getIDReferences()); + this.areaContainerRef = new java.lang.ref.WeakReference(areaContainer); boolean addedHeader = false; boolean addedFooter = false; @@ -286,7 +289,7 @@ addedHeader = true; tableHeader.resetMarker(); area.setMaxHeight(area.getMaxHeight() - spaceLeft - + this.areaContainer.getMaxHeight()); + + areaContainer.getMaxHeight()); } if (tableFooter != null &&!this.omitFooterAtBreak &&!addedFooter) { @@ -324,7 +327,7 @@ tableFooter.setYPosition(tableFooter.getYPosition() + ((TableBody)fo).getHeight()); } - setupColumnHeights(); + setupColumnHeights(areaContainer); status = Status.AREA_FULL_SOME; this.areasGenerated++; } @@ -333,7 +336,7 @@ bodyCount++; } area.setMaxHeight(area.getMaxHeight() - spaceLeft - + this.areaContainer.getMaxHeight()); + + areaContainer.getMaxHeight()); if (tableFooter != null &&!this.omitFooterAtBreak) { // move footer to bottom of area and move up body // space before and after footer will make this wrong @@ -367,7 +370,7 @@ if (height != 0) areaContainer.setHeight(height); - setupColumnHeights(); + setupColumnHeights(areaContainer); areaContainer.end(); area.addChild(areaContainer); @@ -401,7 +404,12 @@ return Status.OK; } - protected void setupColumnHeights() { + public void resetMarker() { + this.areasGenerated=0; + super.resetMarker(); + } + + protected void setupColumnHeights(AreaContainer areaContainer) { for (int i = 0; i < columns.size(); i++) { TableColumn c = (TableColumn)columns.get(i); if ( c != null) { @@ -561,15 +569,16 @@ public int getAreaHeight() { - return areaContainer.getHeight(); + return ((AreaContainer)areaContainerRef.get()).getHeight(); } /** * Return the content width of the boxes generated by this table FO. */ public int getContentWidth() { - if (areaContainer != null) - return areaContainer.getContentWidth(); // getAllocationWidth()?? + if (areaContainerRef != null) + // getAllocationWidth()?? + return ((AreaContainer)areaContainerRef.get()).getContentWidth(); else return 0; // not laid out yet } 1.39.2.11 +13 -10 xml-fop/src/org/apache/fop/fo/flow/Attic/TableCell.java Index: TableCell.java =================================================================== RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/flow/Attic/TableCell.java,v retrieving revision 1.39.2.10 retrieving revision 1.39.2.11 diff -u -r1.39.2.10 -r1.39.2.11 --- TableCell.java 11 Apr 2003 00:24:39 -0000 1.39.2.10 +++ TableCell.java 20 Jul 2003 20:49:28 -0000 1.39.2.11 @@ -136,7 +136,8 @@ */ int m_borderSeparation = 0; - AreaContainer cellArea; + // public AreaContainer cellArea; + public java.lang.ref.WeakReference areaContainerRef; public TableCell(FObj parent, PropertyList propertyList, String systemId, int line, int column) @@ -288,7 +289,7 @@ int spaceLeft = area.spaceLeft() - m_borderSeparation; // The Area position defines the content rectangle! Borders // and padding are outside of this rectangle. - this.cellArea = + AreaContainer cellArea = new AreaContainer(propMgr.getFontState(area.getFontInfo()), startOffset + startAdjust, beforeOffset, width - widthAdjust, spaceLeft, @@ -311,6 +312,8 @@ cellArea.setIDReferences(area.getIDReferences()); // Add adjust for padding and border to fix link alignment! cellArea.setTableCellXOffset(startOffset + startAdjust); + + this.areaContainerRef = new java.lang.ref.WeakReference(cellArea); int numChildren = this.children.size(); for (int i = this.marker; bDone==false && i < numChildren; i++) { @@ -336,7 +339,7 @@ } area.setMaxHeight(area.getMaxHeight() - spaceLeft - + this.cellArea.getMaxHeight()); + + cellArea.getMaxHeight()); } this.bDone=true; cellArea.end(); @@ -371,7 +374,7 @@ * overestimate the allocation height). */ public int getHeight() { - return cellArea.getHeight() + m_borderSeparation - borderHeight; + return ((AreaContainer)areaContainerRef.get()).getHeight() + m_borderSeparation - borderHeight; } /** @@ -388,14 +391,14 @@ // Must get info for all cells starting in row! // verticalAlign can be BEFORE or BASELINE // For now just treat like "before" - cellArea.increaseHeight(delta); + ((AreaContainer)areaContainerRef.get()).increaseHeight(delta); } else if (delta > 0) { - BorderAndPadding cellBP = cellArea.getBorderAndPadding(); + BorderAndPadding cellBP = ((AreaContainer)areaContainerRef.get()).getBorderAndPadding(); switch (verticalAlign) { case DisplayAlign.CENTER: // Increase cell padding before and after and change // "Y" position of content rectangle - cellArea.shiftYPosition(delta / 2); + ((AreaContainer)areaContainerRef.get()).shiftYPosition(delta / 2); cellBP.setPaddingLength(BorderAndPadding.TOP, cellBP.getPaddingTop(false) + delta / 2); @@ -408,7 +411,7 @@ // "Y" position of content rectangle cellBP.setPaddingLength(BorderAndPadding.TOP, cellBP.getPaddingTop(false) + delta); - cellArea.shiftYPosition(delta); + ((AreaContainer)areaContainerRef.get()).shiftYPosition(delta); break; case DisplayAlign.BEFORE: // cellArea.increaseHeight(delta); @@ -463,7 +466,7 @@ this.beforeOffset = m_borderSeparation / 2 + bp.getBorderTopWidth(false) + bp.getPaddingTop(false); - // bp.getBorderBeforeWidth(false) + bp.getPaddingBefore(false); + // bp.getBorderBeforeWidth(false) + bp.getPaddingBefore(false); } else { // System.err.println("Collapse borders"); 1.3.2.7 +4 -3 xml-fop/src/org/apache/fop/fo/flow/Attic/TableFooter.java Index: TableFooter.java =================================================================== RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/flow/Attic/TableFooter.java,v retrieving revision 1.3.2.6 retrieving revision 1.3.2.7 diff -u -r1.3.2.6 -r1.3.2.7 --- TableFooter.java 11 Apr 2003 00:24:39 -0000 1.3.2.6 +++ TableFooter.java 20 Jul 2003 20:49:28 -0000 1.3.2.7 @@ -80,12 +80,13 @@ return "fo:table-footer"; } + // FIXME: this seems odd. public int getYPosition() { - return areaContainer.getCurrentYPosition() - spaceBefore; + return super.getYPosition() - spaceBefore; } public void setYPosition(int value) { - areaContainer.setYPosition(value + 2 * spaceBefore); + super.setYPosition(value + 2 * spaceBefore); } } 1.51.2.12 +9 -6 xml-fop/src/org/apache/fop/fo/flow/Attic/TableRow.java Index: TableRow.java =================================================================== RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/flow/Attic/TableRow.java,v retrieving revision 1.51.2.11 retrieving revision 1.51.2.12 diff -u -r1.51.2.11 -r1.51.2.12 --- TableRow.java 11 Apr 2003 00:24:39 -0000 1.51.2.11 +++ TableRow.java 20 Jul 2003 20:49:28 -0000 1.51.2.12 @@ -89,7 +89,8 @@ int minHeight = 0; // force row height ArrayList columns; - AreaContainer areaContainer; + // public AreaContainer areaContainer; + public java.lang.ref.WeakReference areaContainerRef; boolean areaAdded = false; @@ -296,7 +297,7 @@ int spaceLeft = area.spaceLeft(); - this.areaContainer = + AreaContainer areaContainer = new AreaContainer(propMgr.getFontState(area.getFontInfo()), 0, 0, area.getContentWidth(), spaceLeft, Position.RELATIVE); @@ -310,6 +311,8 @@ areaContainer.setAbsoluteHeight(area.getAbsoluteHeight()); areaContainer.setIDReferences(area.getIDReferences()); + this.areaContainerRef = new java.lang.ref.WeakReference(areaContainer); + largestCellHeight = minHeight; // Flag indicaing whether any cell didn't fit in available space @@ -391,7 +394,7 @@ // This is in case a float was composed in the cells area.setMaxHeight(area.getMaxHeight() - spaceLeft - + this.areaContainer.getMaxHeight()); + + areaContainer.getMaxHeight()); // Only do this for "STARTCELL", ending spans are handled separately // What about empty cells? Yes, we should set their height too! @@ -468,12 +471,12 @@ } public int getAreaHeight() { - return areaContainer.getHeight(); + return ((AreaContainer)areaContainerRef.get()).getHeight(); } public void removeLayout(Area area) { if (areaAdded) { - area.removeChild(areaContainer); + area.removeChild((AreaContainer)areaContainerRef.get()); areaAdded = false; } this.resetMarker();
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]