Return-Path: Delivered-To: apmail-xmlgraphics-fop-commits-archive@www.apache.org Received: (qmail 83152 invoked from network); 17 May 2005 22:28:33 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 17 May 2005 22:28:33 -0000 Received: (qmail 77479 invoked by uid 500); 17 May 2005 09:11:22 -0000 Delivered-To: apmail-xmlgraphics-fop-commits-archive@xmlgraphics.apache.org Received: (qmail 77415 invoked by uid 500); 17 May 2005 09:11:19 -0000 Mailing-List: contact fop-commits-help@xmlgraphics.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: fop-dev@xmlgraphics.apache.org Delivered-To: mailing list fop-commits@xmlgraphics.apache.org Received: (qmail 77316 invoked by uid 500); 17 May 2005 09:11:16 -0000 Delivered-To: apmail-xml-fop-cvs@apache.org Received: (qmail 77268 invoked by uid 99); 17 May 2005 09:11:15 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Tue, 17 May 2005 02:11:14 -0700 Received: (qmail 29150 invoked by uid 1482); 17 May 2005 09:10:40 -0000 Date: 17 May 2005 09:10:40 -0000 Message-ID: <20050517091040.29149.qmail@minotaur.apache.org> From: jeremias@apache.org To: xml-fop-cvs@apache.org Subject: cvs commit: xml-fop/src/java/org/apache/fop/layoutmgr/table TableContentLayoutManager.java X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N jeremias 2005/05/17 02:10:40 Modified: src/java/org/apache/fop/layoutmgr/table TableContentLayoutManager.java Log: Bugfix: Removal of last penalty is fixed now. Cleanup, style improvements and javadocs. Revision Changes Path 1.3 +76 -24 xml-fop/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java Index: TableContentLayoutManager.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- TableContentLayoutManager.java 13 May 2005 19:16:53 -0000 1.2 +++ TableContentLayoutManager.java 17 May 2005 09:10:40 -0000 1.3 @@ -22,7 +22,6 @@ import java.util.Iterator; import java.util.LinkedList; import java.util.List; -import java.util.ListIterator; import java.util.Map; import org.apache.commons.logging.Log; @@ -36,7 +35,6 @@ import org.apache.fop.layoutmgr.ElementListUtils; import org.apache.fop.layoutmgr.KnuthBox; import org.apache.fop.layoutmgr.KnuthElement; -import org.apache.fop.layoutmgr.KnuthPenalty; import org.apache.fop.layoutmgr.KnuthPossPosIter; import org.apache.fop.layoutmgr.LayoutContext; import org.apache.fop.layoutmgr.LayoutManager; @@ -145,10 +143,8 @@ if (getTableLM().getTable().omitHeaderAtBreak()) { //We can simply add the table header at the beginning of the whole list headerAsFirst = box; - //returnList.add(0, box); } else { headerAsSecondToLast = box; - //returnList.add(box); } } if (footerIter != null) { @@ -165,7 +161,6 @@ getTableLM(), false, this.footerList); KnuthBox box = new KnuthBox(footerNetHeight, pos, false); footerAsLast = box; - //returnList.add(box); } } LinkedList returnList = getKnuthElementsForRowIterator( @@ -203,7 +198,7 @@ //Remove last penalty KnuthElement last = (KnuthElement)returnList.getLast(); - if (last.isPenalty() && last.getW() == 0 && last.getP() == 0) { + if (last.isPenalty() && last.getP() == 0) { returnList.removeLast(); } return returnList; @@ -252,7 +247,7 @@ //Create empty grid units to hold resolved borders of neighbouring cells //TODO maybe this needs to be done differently (and sooner) for (int i = 0; i < guCount - row.getGridUnits().size(); i++) { - //TODO This block in untested! + //TODO This block is untested! int pos = row.getGridUnits().size() + i; row.getGridUnits().add(new EmptyGridUnit(gu.getRow(), this.tableLM.getColumns().getColumn(pos + 1), gu.getBody(), @@ -370,7 +365,8 @@ //Calculate width of cell int spanWidth = 0; for (int i = primary.getStartCol(); - i < primary.getStartCol() + primary.getCell().getNumberColumnsSpanned(); + i < primary.getStartCol() + + primary.getCell().getNumberColumnsSpanned(); i++) { spanWidth += getTableLM().getColumns().getColumn(i + 1) .getColumnWidth().getValue(); @@ -380,7 +376,8 @@ childLC.setRefIPD(spanWidth); //Get the element list for the cell contents - LinkedList elems = primary.getCellLM().getNextKnuthElements(childLC, alignment); + LinkedList elems = primary.getCellLM().getNextKnuthElements( + childLC, alignment); primary.setElements(elems); log.debug("Elements: " + elems); } @@ -457,11 +454,21 @@ } + /** + * Retuns the X offset of the given grid unit. + * @param gu the grid unit + * @return the requested X offset + */ protected int getXOffsetOfGridUnit(GridUnit gu) { int col = gu.getStartCol(); return startXOffset + getTableLM().getColumns().getXOffset(col + 1); } + /** + * Adds the areas generated my this layout manager to the area tree. + * @param parentIter the position iterator + * @param layoutContext the layout context for adding areas + */ public void addAreas(PositionIterator parentIter, LayoutContext layoutContext) { this.usedBPD = 0; RowPainter painter = new RowPainter(layoutContext); @@ -680,7 +687,7 @@ + start[i] + "-" + end[i]); } addAreasForCell(gridUnits[i], start[i], end[i], - layoutContext, lastRow, yoffset, + lastRow, partLength[i], actualRowHeight); gridUnits[i] = null; start[i] = 0; @@ -692,8 +699,7 @@ } private void addAreasForCell(PrimaryGridUnit pgu, int start, int end, - LayoutContext layoutContext, EffRow row, - int yoffset, int contentHeight, int rowHeight) { + EffRow row, int contentHeight, int rowHeight) { int bt = row.getBodyType(); if (firstRow[bt] < 0) { firstRow[bt] = row.getIndex(); @@ -737,6 +743,13 @@ } } + /** + * Adds the area for the row background if any. + * @param row row for which to generate the background + * @param bpd block-progression-dimension of the row + * @param ipd inline-progression-dimension of the row + * @param yoffset Y offset at which to paint + */ public void addRowBackgroundArea(TableRow row, int bpd, int ipd, int yoffset) { //Add row background if any Block rowBackground = getRowArea(row); @@ -758,16 +771,31 @@ this.startXOffset = startXOffset; } + /** + * @return the amount of block-progression-dimension used by the content + */ public int getUsedBPD() { return this.usedBPD; } + /** + * Represents a non-dividable part of a grid unit. Used by the table stepper. + */ protected static class GridUnitPart { + /** Primary grid unit */ protected PrimaryGridUnit pgu; + /** Index of the starting element of this part */ protected int start; + /** Index of the ending element of this part */ protected int end; + /** + * Creates a new GridUnitPart. + * @param pgu Primary grid unit + * @param start starting element + * @param end ending element + */ protected GridUnitPart(PrimaryGridUnit pgu, int start, int end) { this.pgu = pgu; this.start = start; @@ -784,11 +812,23 @@ } + /** + * This class represents a Position specific to this layout manager. Used for normal content + * cases. + */ public static class TableContentPosition extends Position { + /** the list of GridUnitParts making up this position */ protected List gridUnitParts; + /** effective row this position belongs to */ protected EffRow row; + /** + * Creates a new TableContentPosition. + * @param lm applicable layout manager + * @param gridUnitParts the list of GridUnitPart instances + * @param row effective row this position belongs to + */ protected TableContentPosition(LayoutManager lm, List gridUnitParts, EffRow row) { super(lm); @@ -805,11 +845,23 @@ } } + /** + * This class represents a Position specific to this layout manager. Used for table + * headers and footers at the beginning and end of a table. + */ public static class TableHeaderFooterPosition extends Position { - + + /** True indicates a position for a header, false for a footer. */ protected boolean header; + /** Element list representing the header/footer */ protected List nestedElements; + /** + * Creates a new TableHeaderFooterPosition. + * @param lm applicable layout manager + * @param header True indicates a position for a header, false for a footer. + * @param nestedElements Element list representing the header/footer + */ protected TableHeaderFooterPosition(LayoutManager lm, boolean header, List nestedElements) { super(lm); @@ -828,11 +880,21 @@ } } + /** + * This class represents a Position specific to this layout manager. Used for table + * headers and footers at breaks. + */ public static class TableHFPenaltyPosition extends Position { + /** Element list for the header */ protected List headerElements; + /** Element list for the footer */ protected List footerElements; + /** + * Creates a new TableHFPenaltyPosition + * @param lm applicable layout manager + */ protected TableHFPenaltyPosition(LayoutManager lm) { super(lm); } @@ -850,14 +912,4 @@ } } - private class KnuthBoxCellWithBPD extends KnuthBox { - - private PrimaryGridUnit pgu; - - public KnuthBoxCellWithBPD(int w, PrimaryGridUnit pgu) { - super(w, null, true); - this.pgu = pgu; - } - } - } --------------------------------------------------------------------- To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org