From cd24266733a19cd61bc61e0f463b69154001bd8a Mon Sep 17 00:00:00 2001 From: Jeremias Maerki Date: Mon, 18 Jul 2005 15:46:44 +0000 Subject: Renamed Item to Cell to TableCellLayoutManager. Renamed Caption to TableCaptionLayoutManager. Adjusted SVN properties. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@219519 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/fop/layoutmgr/table/Caption.java | 207 -------- src/java/org/apache/fop/layoutmgr/table/Cell.java | 535 --------------------- .../fop/layoutmgr/table/PrimaryGridUnit.java | 6 +- .../layoutmgr/table/TableCaptionLayoutManager.java | 207 ++++++++ .../layoutmgr/table/TableCellLayoutManager.java | 535 +++++++++++++++++++++ .../layoutmgr/table/TableContentLayoutManager.java | 2 +- .../fop/layoutmgr/table/TableLayoutManager.java | 2 +- 7 files changed, 747 insertions(+), 747 deletions(-) delete mode 100644 src/java/org/apache/fop/layoutmgr/table/Caption.java delete mode 100644 src/java/org/apache/fop/layoutmgr/table/Cell.java create mode 100644 src/java/org/apache/fop/layoutmgr/table/TableCaptionLayoutManager.java create mode 100644 src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java (limited to 'src') diff --git a/src/java/org/apache/fop/layoutmgr/table/Caption.java b/src/java/org/apache/fop/layoutmgr/table/Caption.java deleted file mode 100644 index 2101d793f..000000000 --- a/src/java/org/apache/fop/layoutmgr/table/Caption.java +++ /dev/null @@ -1,207 +0,0 @@ -/* - * Copyright 1999-2005 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.layoutmgr.table; - -import org.apache.fop.fo.flow.TableCaption; -import org.apache.fop.layoutmgr.BlockStackingLayoutManager; -import org.apache.fop.layoutmgr.LayoutContext; -import org.apache.fop.layoutmgr.PositionIterator; -import org.apache.fop.layoutmgr.Position; -import org.apache.fop.area.Area; -import org.apache.fop.area.Block; - -/** - * LayoutManager for a table-caption FO. - * The table caption contains blocks that are placed beside the - * table. - * @todo Implement getNextKnuthElements() - */ -public class Caption extends BlockStackingLayoutManager { - private TableCaption fobj; - - private Block curBlockArea; - - //private List childBreaks = new ArrayList(); - - /** - * Create a new Caption layout manager. - * @param node table-caption FO - */ - public Caption(TableCaption node) { - super(node); - fobj = node; - } - - /** - * Get the next break position for the caption. - * - * @param context the layout context for finding breaks - * @return the next break possibility - */ - /* - public BreakPoss getNextBreakPoss(LayoutContext context) { - LayoutManager curLM; // currently active LM - - MinOptMax stackSize = new MinOptMax(); - // if starting add space before - // stackSize.add(spaceBefore); - BreakPoss lastPos = null; - - // if there is a caption then get the side and work out when - // to handle it - - while ((curLM = getChildLM()) != null) { - // Make break positions and return blocks! - // Set up a LayoutContext - int ipd = context.getRefIPD(); - BreakPoss bp; - - LayoutContext childLC = new LayoutContext(0); - // if line layout manager then set stack limit to ipd - // line LM actually generates a LineArea which is a block - childLC.setStackLimit( - MinOptMax.subtract(context.getStackLimit(), - stackSize)); - childLC.setRefIPD(ipd); - - 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; - childBreaks.add(bp); - - if (bp.nextBreakOverflows()) { - over = true; - break; - } - - childLC.setStackLimit(MinOptMax.subtract( - context.getStackLimit(), stackSize)); - } - } - BreakPoss breakPoss = new BreakPoss( - new LeafPosition(this, childBreaks.size() - 1)); - if (over) { - breakPoss.setFlag(BreakPoss.NEXT_OVERFLOWS, true); - } - breakPoss.setStackingSize(stackSize); - return breakPoss; - } - setFinished(true); - return null; - }*/ - - /** - * Add the areas to the parent. - * - * @param parentIter the position iterator of the breaks - * @param layoutContext the layout context for adding areas - */ - public void addAreas(PositionIterator parentIter, - LayoutContext layoutContext) { - getParentArea(null); - getPSLM().addIDToPage(fobj.getId()); - - /* TODO: Reimplement using Knuth approach - LayoutManager childLM; - int iStartPos = 0; - LayoutContext lc = new LayoutContext(0); - while (parentIter.hasNext()) { - LeafPosition lfp = (LeafPosition) parentIter.next(); - // Add the block areas to Area - PositionIterator breakPosIter = new BreakPossPosIter( - childBreaks, iStartPos, lfp.getLeafPos() + 1); - iStartPos = lfp.getLeafPos() + 1; - while ((childLM = breakPosIter.getNextChildLM()) != null) { - childLM.addAreas(breakPosIter, lc); - } - }*/ - - flush(); - - //childBreaks.clear(); - curBlockArea = null; - } - - /** - * Return an Area which can contain the passed childArea. The childArea - * may not yet have any content, but it has essential traits set. - * In general, if the LayoutManager already has an Area it simply returns - * it. Otherwise, it makes a new Area of the appropriate class. - * It gets a parent area for its area by calling its parent LM. - * Finally, based on the dimensions of the parent area, it initializes - * its own area. This includes setting the content IPD and the maximum - * BPD. - * - * @param childArea the child area - * @return the parent area from this caption - */ - public Area getParentArea(Area childArea) { - if (curBlockArea == null) { - curBlockArea = new Block(); - // Set up dimensions - // Must get dimensions from parent area - Area parentArea = parentLM.getParentArea(curBlockArea); - int referenceIPD = parentArea.getIPD(); - curBlockArea.setIPD(referenceIPD); - // Get reference IPD from parentArea - setCurrentArea(curBlockArea); // ??? for generic operations - } - return curBlockArea; - } - - /** - * Add the child to the caption area. - * - * @param childArea the child area to add - */ - public void addChildArea(Area childArea) { - if (curBlockArea != null) { - curBlockArea.addBlock((Block) childArea); - } - } - - /** - * Reset the layout position. - * - * @param resetPos the position to reset to - */ - public void resetPosition(Position resetPos) { - if (resetPos == null) { - reset(null); - } - } -} - diff --git a/src/java/org/apache/fop/layoutmgr/table/Cell.java b/src/java/org/apache/fop/layoutmgr/table/Cell.java deleted file mode 100644 index 053132ed5..000000000 --- a/src/java/org/apache/fop/layoutmgr/table/Cell.java +++ /dev/null @@ -1,535 +0,0 @@ -/* - * Copyright 1999-2005 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.layoutmgr.table; - -import java.util.LinkedList; - -import org.apache.fop.fo.FONode; -import org.apache.fop.fo.flow.Table; -import org.apache.fop.fo.flow.TableCell; -import org.apache.fop.fo.properties.CommonBorderPaddingBackground; -import org.apache.fop.layoutmgr.AreaAdditionUtil; -import org.apache.fop.layoutmgr.BlockLevelLayoutManager; -import org.apache.fop.layoutmgr.BlockStackingLayoutManager; -import org.apache.fop.layoutmgr.KnuthElement; -import org.apache.fop.layoutmgr.KnuthGlue; -import org.apache.fop.layoutmgr.KnuthPenalty; -import org.apache.fop.layoutmgr.LayoutContext; -import org.apache.fop.layoutmgr.PositionIterator; -import org.apache.fop.layoutmgr.Position; -import org.apache.fop.layoutmgr.TraitSetter; -import org.apache.fop.area.Area; -import org.apache.fop.area.Block; -import org.apache.fop.area.Trait; -import org.apache.fop.traits.MinOptMax; - -/** - * LayoutManager for a table-cell FO. - * A cell contains blocks. These blocks fill the cell. - */ -public class Cell extends BlockStackingLayoutManager implements BlockLevelLayoutManager { - - private TableCell fobj; - private PrimaryGridUnit gridUnit; - - private Block curBlockArea; - - private int inRowIPDOffset; - - private int xoffset; - private int yoffset; - private int cellIPD; - private int rowHeight; - private int usedBPD; - private int startBorderWidth; - private int endBorderWidth; - private int borderAndPaddingBPD; - private boolean emptyCell = true; - - /** - * Create a new Cell layout manager. - * @param node table-cell FO for which to create the LM - * @param pgu primary grid unit for the cell - */ - public Cell(TableCell node, PrimaryGridUnit pgu) { - super(node); - fobj = node; - this.gridUnit = pgu; - initialize(); - } - - /** @return the table-cell FO */ - public TableCell getFObj() { - return this.fobj; - } - - private boolean isSeparateBorderModel() { - return fobj.isSeparateBorderModel(); - } - - private void initialize() { - borderAndPaddingBPD = 0; - borderAndPaddingBPD += fobj.getCommonBorderPaddingBackground().getBorderBeforeWidth(false); - borderAndPaddingBPD += fobj.getCommonBorderPaddingBackground().getBorderAfterWidth(false); - if (!isSeparateBorderModel()) { - borderAndPaddingBPD /= 2; - } - borderAndPaddingBPD += fobj.getCommonBorderPaddingBackground().getPaddingBefore(false); - borderAndPaddingBPD += fobj.getCommonBorderPaddingBackground().getPaddingAfter(false); - } - - /** - * @return the table owning this cell - */ - public Table getTable() { - FONode node = fobj.getParent(); - while (!(node instanceof Table)) { - node = node.getParent(); - } - return (Table)node; - } - - - private int getIPIndents() { - int iIndents = 0; - int[] startEndBorderWidths = gridUnit.getStartEndBorderWidths(); - startBorderWidth += startEndBorderWidths[0]; - endBorderWidth += startEndBorderWidths[1]; - iIndents += startBorderWidth; - iIndents += endBorderWidth; - if (!isSeparateBorderModel()) { - iIndents /= 2; - } - iIndents += fobj.getCommonBorderPaddingBackground().getPaddingStart(false); - iIndents += fobj.getCommonBorderPaddingBackground().getPaddingEnd(false); - return iIndents; - } - - /** - * @see org.apache.fop.layoutmgr.LayoutManager - */ - public LinkedList getNextKnuthElements(LayoutContext context, int alignment) { - MinOptMax stackLimit = new MinOptMax(context.getStackLimit()); - - referenceIPD = context.getRefIPD(); - cellIPD = referenceIPD; - cellIPD -= getIPIndents(); - if (isSeparateBorderModel()) { - int borderSep = fobj.getBorderSeparation().getLengthPair() - .getIPD().getLength().getValue(); - cellIPD -= borderSep; - } - - LinkedList returnedList = null; - LinkedList contentList = new LinkedList(); - LinkedList returnList = new LinkedList(); - - BlockLevelLayoutManager curLM; // currently active LM - BlockLevelLayoutManager prevLM = null; // previously active LM - while ((curLM = (BlockLevelLayoutManager) getChildLM()) != null) { - LayoutContext childLC = new LayoutContext(0); - // curLM is a ? - childLC.setStackLimit(MinOptMax.subtract(context - .getStackLimit(), stackLimit)); - childLC.setRefIPD(cellIPD); - - // get elements from curLM - returnedList = curLM.getNextKnuthElements(childLC, alignment); - if (childLC.isKeepWithNextPending()) { - log.debug("child LM signals pending keep with next"); - } - if (contentList.size() == 0 && childLC.isKeepWithPreviousPending()) { - context.setFlags(LayoutContext.KEEP_WITH_PREVIOUS_PENDING); - childLC.setFlags(LayoutContext.KEEP_WITH_PREVIOUS_PENDING, false); - } - - 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 - } - 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() - || context.isKeepWithNextPending() - || childLC.isKeepWithPreviousPending()) { - //Clear keep pending flag - context.setFlags(LayoutContext.KEEP_WITH_NEXT_PENDING, false); - childLC.setFlags(LayoutContext.KEEP_WITH_PREVIOUS_PENDING, false); - // 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; - } - } - if (childLC.isKeepWithNextPending()) { - //Clear and propagate - childLC.setFlags(LayoutContext.KEEP_WITH_NEXT_PENDING, false); - context.setFlags(LayoutContext.KEEP_WITH_NEXT_PENDING); - } - prevLM = curLM; - } - - returnedList = new LinkedList(); - wrapPositionElements(contentList, returnList); - - setFinished(true); - return returnList; - } - - /** - * Set the y offset of this cell. - * This offset is used to set the absolute position of the cell. - * - * @param off the y direction offset - */ - public void setYOffset(int off) { - yoffset = off; - } - - /** - * Set the x offset of this cell (usually the same as its parent row). - * This offset is used to determine the absolute position of the cell. - * - * @param off the x offset - */ - public void setXOffset(int off) { - xoffset = off; - } - - /** - * Set the IPD offset of this cell inside the table-row. - * This offset is used to determine the absolute position of the cell. - * @param off the IPD offset - */ - public void setInRowIPDOffset(int off) { - this.inRowIPDOffset = off; - } - - /** - * Set the content height for this cell. This method is used during - * addAreas() stage. - * - * @param h the height of the contents of this cell - */ - public void setContentHeight(int h) { - usedBPD = h; - } - - /** - * Set the row height that contains this cell. This method is used during - * addAreas() stage. - * - * @param h the height of the row - */ - public void setRowHeight(int h) { - rowHeight = h; - } - - private int getContentHeight(int rowHeight, GridUnit gu) { - int bpd = rowHeight; - if (isSeparateBorderModel()) { - bpd -= gu.getPrimary().getBorders().getBorderBeforeWidth(false); - bpd -= gu.getPrimary().getBorders().getBorderAfterWidth(false); - } else { - bpd -= gu.getPrimary().getHalfMaxBorderWidth(); - } - CommonBorderPaddingBackground cbpb - = gu.getCell().getCommonBorderPaddingBackground(); - bpd -= cbpb.getPaddingBefore(false); - bpd -= cbpb.getPaddingAfter(false); - return bpd; - } - - /** - * Add the areas for the break points. - * The cell contains block stacking layout managers - * that add block areas. - * - * @param parentIter the iterator of the break positions - * @param layoutContext the layout context for adding the areas - */ - public void addAreas(PositionIterator parentIter, - LayoutContext layoutContext) { - getParentArea(null); - - getPSLM().addIDToPage(fobj.getId()); - - if (isSeparateBorderModel()) { - if (!emptyCell || fobj.showEmptyCells()) { - TraitSetter.addBorders(curBlockArea, fobj.getCommonBorderPaddingBackground()); - TraitSetter.addBackground(curBlockArea, fobj.getCommonBorderPaddingBackground()); - } - } else { - TraitSetter.addBackground(curBlockArea, fobj.getCommonBorderPaddingBackground()); - boolean[] outer = new boolean[] { - gridUnit.getFlag(GridUnit.FIRST_IN_TABLE), - gridUnit.getFlag(GridUnit.LAST_IN_TABLE), - gridUnit.getFlag(GridUnit.IN_FIRST_COLUMN), - gridUnit.getFlag(GridUnit.IN_LAST_COLUMN)}; - if (!gridUnit.hasSpanning()) { - //Can set the borders directly if there's no span - TraitSetter.addCollapsingBorders(curBlockArea, - gridUnit.getBorders(), outer); - } else { - int dy = yoffset; - for (int y = 0; y < gridUnit.getRows().size(); y++) { - GridUnit[] gridUnits = (GridUnit[])gridUnit.getRows().get(y); - int dx = xoffset; - int lastRowHeight = 0; - for (int x = 0; x < gridUnits.length; x++) { - GridUnit gu = gridUnits[x]; - if (!gu.hasBorders()) { - continue; - } - - //Blocks for painting grid unit borders - Block block = new Block(); - block.addTrait(Trait.IS_REFERENCE_AREA, Boolean.TRUE); - block.setPositioning(Block.ABSOLUTE); - - int bpd = getContentHeight(rowHeight, gu); - if (isSeparateBorderModel()) { - bpd += (gu.getBorders().getBorderBeforeWidth(false)); - bpd += (gu.getBorders().getBorderAfterWidth(false)); - } else { - bpd += gridUnit.getHalfMaxBeforeBorderWidth() - - (gu.getBorders().getBorderBeforeWidth(false) / 2); - bpd += gridUnit.getHalfMaxAfterBorderWidth() - - (gu.getBorders().getBorderAfterWidth(false) / 2); - } - block.setBPD(bpd); - lastRowHeight = rowHeight; - int ipd = gu.getColumn().getColumnWidth().getValue(); - int borderStartWidth = gu.getBorders().getBorderStartWidth(false) / 2; - ipd -= borderStartWidth; - ipd -= gu.getBorders().getBorderEndWidth(false) / 2; - block.setIPD(ipd); - block.setXOffset(dx + borderStartWidth); - int halfCollapsingBorderHeight = 0; - if (!isSeparateBorderModel()) { - halfCollapsingBorderHeight - += gu.getBorders().getBorderBeforeWidth(false) / 2; - } - block.setYOffset(dy - halfCollapsingBorderHeight); - TraitSetter.addCollapsingBorders(block, gu.getBorders(), outer); - parentLM.addChildArea(block); - dx += gu.getColumn().getColumnWidth().getValue(); - } - dy += lastRowHeight; - } - log.warn("TODO Add collapsed border painting for spanned cells"); - } - } - - //Handle display-align - if (usedBPD < rowHeight) { - if (fobj.getDisplayAlign() == EN_CENTER) { - Block space = new Block(); - space.setBPD((rowHeight - usedBPD) / 2); - curBlockArea.addBlock(space); - } else if (fobj.getDisplayAlign() == EN_AFTER) { - Block space = new Block(); - space.setBPD((rowHeight - usedBPD)); - curBlockArea.addBlock(space); - } - } - - AreaAdditionUtil.addAreas(this, parentIter, layoutContext); - - int contentBPD = getContentHeight(rowHeight, gridUnit); - curBlockArea.setBPD(contentBPD); - - flush(); - - curBlockArea = null; - } - - /** - * Return an Area which can contain the passed childArea. The childArea - * may not yet have any content, but it has essential traits set. - * In general, if the LayoutManager already has an Area it simply returns - * it. Otherwise, it makes a new Area of the appropriate class. - * It gets a parent area for its area by calling its parent LM. - * Finally, based on the dimensions of the parent area, it initializes - * its own area. This includes setting the content IPD and the maximum - * BPD. - * - * @param childArea the child area to get the parent for - * @return the parent area - */ - public Area getParentArea(Area childArea) { - if (curBlockArea == null) { - curBlockArea = new Block(); - curBlockArea.addTrait(Trait.IS_REFERENCE_AREA, Boolean.TRUE); - curBlockArea.setPositioning(Block.ABSOLUTE); - int indent = 0; - indent += startBorderWidth; - if (!isSeparateBorderModel()) { - indent /= 2; - } - indent += fobj.getCommonBorderPaddingBackground().getPaddingStart(false); - // set position - int halfBorderSep = 0; - if (isSeparateBorderModel()) { - halfBorderSep = fobj.getBorderSeparation().getLengthPair() - .getIPD().getLength().getValue() / 2; - } - int borderAdjust = 0; - if (!isSeparateBorderModel()) { - if (gridUnit.hasSpanning()) { - borderAdjust -= gridUnit.getHalfMaxBeforeBorderWidth(); - } else { - borderAdjust += gridUnit.getHalfMaxBeforeBorderWidth(); - } - } else { - //borderAdjust += gridUnit.getBorders().getBorderBeforeWidth(false); - } - curBlockArea.setXOffset(xoffset + inRowIPDOffset + halfBorderSep + indent); - curBlockArea.setYOffset(yoffset - borderAdjust); - curBlockArea.setIPD(cellIPD); - //curBlockArea.setHeight(); - - // Set up dimensions - /*Area parentArea =*/ parentLM.getParentArea(curBlockArea); - // Get reference IPD from parentArea - setCurrentArea(curBlockArea); // ??? for generic operations - } - return curBlockArea; - } - - /** - * Add the child to the cell block area. - * - * @param childArea the child to add to the cell - */ - public void addChildArea(Area childArea) { - if (curBlockArea != null) { - curBlockArea.addBlock((Block) childArea); - } - } - - /** - * Reset the position of the layout. - * - * @param resetPos the position to reset to - */ - public void resetPosition(Position resetPos) { - if (resetPos == null) { - reset(null); - } - } - - /** - * @see org.apache.fop.layoutmgr.BlockLevelLayoutManager - */ - public int negotiateBPDAdjustment(int adj, KnuthElement lastElement) { - // TODO Auto-generated method stub - return 0; - } - - /** - * @see org.apache.fop.layoutmgr.BlockLevelLayoutManager - */ - public void discardSpace(KnuthGlue spaceGlue) { - // TODO Auto-generated method stub - } - - /** - * @see org.apache.fop.layoutmgr.BlockLevelLayoutManager#mustKeepTogether() - */ - public boolean mustKeepTogether() { - //TODO Keeps will have to be more sophisticated sooner or later - boolean keep = ((BlockLevelLayoutManager)getParent()).mustKeepTogether(); - if (gridUnit.getRow() != null) { - keep |= gridUnit.getRow().mustKeepTogether(); - } - return keep; - } - - /** - * @see org.apache.fop.layoutmgr.BlockLevelLayoutManager#mustKeepWithPrevious() - */ - public boolean mustKeepWithPrevious() { - return false; //TODO FIX ME - /* - return !fobj.getKeepWithPrevious().getWithinPage().isAuto() - || !fobj.getKeepWithPrevious().getWithinColumn().isAuto(); - */ - } - - /** - * @see org.apache.fop.layoutmgr.BlockLevelLayoutManager#mustKeepWithNext() - */ - public boolean mustKeepWithNext() { - return false; //TODO FIX ME - /* - return !fobj.getKeepWithNext().getWithinPage().isAuto() - || !fobj.getKeepWithNext().getWithinColumn().isAuto(); - */ - } - -} - diff --git a/src/java/org/apache/fop/layoutmgr/table/PrimaryGridUnit.java b/src/java/org/apache/fop/layoutmgr/table/PrimaryGridUnit.java index 2695890a7..0657128cf 100644 --- a/src/java/org/apache/fop/layoutmgr/table/PrimaryGridUnit.java +++ b/src/java/org/apache/fop/layoutmgr/table/PrimaryGridUnit.java @@ -31,7 +31,7 @@ import org.apache.fop.fo.properties.LengthRangeProperty; public class PrimaryGridUnit extends GridUnit { /** Cell layout manager. */ - private Cell cellLM; + private TableCellLayoutManager cellLM; /** List of Knuth elements representing the contents of the cell. */ private LinkedList elements; /** Index of row where this cell starts */ @@ -45,11 +45,11 @@ public class PrimaryGridUnit extends GridUnit { super(cell, column, startCol, 0); this.startRow = startRow; if (cell != null) { - cellLM = new Cell(cell, this); + cellLM = new TableCellLayoutManager(cell, this); } } - public Cell getCellLM() { + public TableCellLayoutManager getCellLM() { return cellLM; } diff --git a/src/java/org/apache/fop/layoutmgr/table/TableCaptionLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableCaptionLayoutManager.java new file mode 100644 index 000000000..b0efad7cd --- /dev/null +++ b/src/java/org/apache/fop/layoutmgr/table/TableCaptionLayoutManager.java @@ -0,0 +1,207 @@ +/* + * Copyright 1999-2005 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Id$ */ + +package org.apache.fop.layoutmgr.table; + +import org.apache.fop.fo.flow.TableCaption; +import org.apache.fop.layoutmgr.BlockStackingLayoutManager; +import org.apache.fop.layoutmgr.LayoutContext; +import org.apache.fop.layoutmgr.PositionIterator; +import org.apache.fop.layoutmgr.Position; +import org.apache.fop.area.Area; +import org.apache.fop.area.Block; + +/** + * LayoutManager for a table-caption FO. + * The table caption contains blocks that are placed beside the + * table. + * @todo Implement getNextKnuthElements() + */ +public class TableCaptionLayoutManager extends BlockStackingLayoutManager { + private TableCaption fobj; + + private Block curBlockArea; + + //private List childBreaks = new ArrayList(); + + /** + * Create a new Caption layout manager. + * @param node table-caption FO + */ + public TableCaptionLayoutManager(TableCaption node) { + super(node); + fobj = node; + } + + /** + * Get the next break position for the caption. + * + * @param context the layout context for finding breaks + * @return the next break possibility + */ + /* + public BreakPoss getNextBreakPoss(LayoutContext context) { + LayoutManager curLM; // currently active LM + + MinOptMax stackSize = new MinOptMax(); + // if starting add space before + // stackSize.add(spaceBefore); + BreakPoss lastPos = null; + + // if there is a caption then get the side and work out when + // to handle it + + while ((curLM = getChildLM()) != null) { + // Make break positions and return blocks! + // Set up a LayoutContext + int ipd = context.getRefIPD(); + BreakPoss bp; + + LayoutContext childLC = new LayoutContext(0); + // if line layout manager then set stack limit to ipd + // line LM actually generates a LineArea which is a block + childLC.setStackLimit( + MinOptMax.subtract(context.getStackLimit(), + stackSize)); + childLC.setRefIPD(ipd); + + 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; + childBreaks.add(bp); + + if (bp.nextBreakOverflows()) { + over = true; + break; + } + + childLC.setStackLimit(MinOptMax.subtract( + context.getStackLimit(), stackSize)); + } + } + BreakPoss breakPoss = new BreakPoss( + new LeafPosition(this, childBreaks.size() - 1)); + if (over) { + breakPoss.setFlag(BreakPoss.NEXT_OVERFLOWS, true); + } + breakPoss.setStackingSize(stackSize); + return breakPoss; + } + setFinished(true); + return null; + }*/ + + /** + * Add the areas to the parent. + * + * @param parentIter the position iterator of the breaks + * @param layoutContext the layout context for adding areas + */ + public void addAreas(PositionIterator parentIter, + LayoutContext layoutContext) { + getParentArea(null); + getPSLM().addIDToPage(fobj.getId()); + + /* TODO: Reimplement using Knuth approach + LayoutManager childLM; + int iStartPos = 0; + LayoutContext lc = new LayoutContext(0); + while (parentIter.hasNext()) { + LeafPosition lfp = (LeafPosition) parentIter.next(); + // Add the block areas to Area + PositionIterator breakPosIter = new BreakPossPosIter( + childBreaks, iStartPos, lfp.getLeafPos() + 1); + iStartPos = lfp.getLeafPos() + 1; + while ((childLM = breakPosIter.getNextChildLM()) != null) { + childLM.addAreas(breakPosIter, lc); + } + }*/ + + flush(); + + //childBreaks.clear(); + curBlockArea = null; + } + + /** + * Return an Area which can contain the passed childArea. The childArea + * may not yet have any content, but it has essential traits set. + * In general, if the LayoutManager already has an Area it simply returns + * it. Otherwise, it makes a new Area of the appropriate class. + * It gets a parent area for its area by calling its parent LM. + * Finally, based on the dimensions of the parent area, it initializes + * its own area. This includes setting the content IPD and the maximum + * BPD. + * + * @param childArea the child area + * @return the parent area from this caption + */ + public Area getParentArea(Area childArea) { + if (curBlockArea == null) { + curBlockArea = new Block(); + // Set up dimensions + // Must get dimensions from parent area + Area parentArea = parentLM.getParentArea(curBlockArea); + int referenceIPD = parentArea.getIPD(); + curBlockArea.setIPD(referenceIPD); + // Get reference IPD from parentArea + setCurrentArea(curBlockArea); // ??? for generic operations + } + return curBlockArea; + } + + /** + * Add the child to the caption area. + * + * @param childArea the child area to add + */ + public void addChildArea(Area childArea) { + if (curBlockArea != null) { + curBlockArea.addBlock((Block) childArea); + } + } + + /** + * Reset the layout position. + * + * @param resetPos the position to reset to + */ + public void resetPosition(Position resetPos) { + if (resetPos == null) { + reset(null); + } + } +} + diff --git a/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java new file mode 100644 index 000000000..210b55227 --- /dev/null +++ b/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java @@ -0,0 +1,535 @@ +/* + * Copyright 1999-2005 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Id$ */ + +package org.apache.fop.layoutmgr.table; + +import java.util.LinkedList; + +import org.apache.fop.fo.FONode; +import org.apache.fop.fo.flow.Table; +import org.apache.fop.fo.flow.TableCell; +import org.apache.fop.fo.properties.CommonBorderPaddingBackground; +import org.apache.fop.layoutmgr.AreaAdditionUtil; +import org.apache.fop.layoutmgr.BlockLevelLayoutManager; +import org.apache.fop.layoutmgr.BlockStackingLayoutManager; +import org.apache.fop.layoutmgr.KnuthElement; +import org.apache.fop.layoutmgr.KnuthGlue; +import org.apache.fop.layoutmgr.KnuthPenalty; +import org.apache.fop.layoutmgr.LayoutContext; +import org.apache.fop.layoutmgr.PositionIterator; +import org.apache.fop.layoutmgr.Position; +import org.apache.fop.layoutmgr.TraitSetter; +import org.apache.fop.area.Area; +import org.apache.fop.area.Block; +import org.apache.fop.area.Trait; +import org.apache.fop.traits.MinOptMax; + +/** + * LayoutManager for a table-cell FO. + * A cell contains blocks. These blocks fill the cell. + */ +public class TableCellLayoutManager extends BlockStackingLayoutManager implements BlockLevelLayoutManager { + + private TableCell fobj; + private PrimaryGridUnit gridUnit; + + private Block curBlockArea; + + private int inRowIPDOffset; + + private int xoffset; + private int yoffset; + private int cellIPD; + private int rowHeight; + private int usedBPD; + private int startBorderWidth; + private int endBorderWidth; + private int borderAndPaddingBPD; + private boolean emptyCell = true; + + /** + * Create a new Cell layout manager. + * @param node table-cell FO for which to create the LM + * @param pgu primary grid unit for the cell + */ + public TableCellLayoutManager(TableCell node, PrimaryGridUnit pgu) { + super(node); + fobj = node; + this.gridUnit = pgu; + initialize(); + } + + /** @return the table-cell FO */ + public TableCell getFObj() { + return this.fobj; + } + + private boolean isSeparateBorderModel() { + return fobj.isSeparateBorderModel(); + } + + private void initialize() { + borderAndPaddingBPD = 0; + borderAndPaddingBPD += fobj.getCommonBorderPaddingBackground().getBorderBeforeWidth(false); + borderAndPaddingBPD += fobj.getCommonBorderPaddingBackground().getBorderAfterWidth(false); + if (!isSeparateBorderModel()) { + borderAndPaddingBPD /= 2; + } + borderAndPaddingBPD += fobj.getCommonBorderPaddingBackground().getPaddingBefore(false); + borderAndPaddingBPD += fobj.getCommonBorderPaddingBackground().getPaddingAfter(false); + } + + /** + * @return the table owning this cell + */ + public Table getTable() { + FONode node = fobj.getParent(); + while (!(node instanceof Table)) { + node = node.getParent(); + } + return (Table)node; + } + + + private int getIPIndents() { + int iIndents = 0; + int[] startEndBorderWidths = gridUnit.getStartEndBorderWidths(); + startBorderWidth += startEndBorderWidths[0]; + endBorderWidth += startEndBorderWidths[1]; + iIndents += startBorderWidth; + iIndents += endBorderWidth; + if (!isSeparateBorderModel()) { + iIndents /= 2; + } + iIndents += fobj.getCommonBorderPaddingBackground().getPaddingStart(false); + iIndents += fobj.getCommonBorderPaddingBackground().getPaddingEnd(false); + return iIndents; + } + + /** + * @see org.apache.fop.layoutmgr.LayoutManager + */ + public LinkedList getNextKnuthElements(LayoutContext context, int alignment) { + MinOptMax stackLimit = new MinOptMax(context.getStackLimit()); + + referenceIPD = context.getRefIPD(); + cellIPD = referenceIPD; + cellIPD -= getIPIndents(); + if (isSeparateBorderModel()) { + int borderSep = fobj.getBorderSeparation().getLengthPair() + .getIPD().getLength().getValue(); + cellIPD -= borderSep; + } + + LinkedList returnedList = null; + LinkedList contentList = new LinkedList(); + LinkedList returnList = new LinkedList(); + + BlockLevelLayoutManager curLM; // currently active LM + BlockLevelLayoutManager prevLM = null; // previously active LM + while ((curLM = (BlockLevelLayoutManager) getChildLM()) != null) { + LayoutContext childLC = new LayoutContext(0); + // curLM is a ? + childLC.setStackLimit(MinOptMax.subtract(context + .getStackLimit(), stackLimit)); + childLC.setRefIPD(cellIPD); + + // get elements from curLM + returnedList = curLM.getNextKnuthElements(childLC, alignment); + if (childLC.isKeepWithNextPending()) { + log.debug("child LM signals pending keep with next"); + } + if (contentList.size() == 0 && childLC.isKeepWithPreviousPending()) { + context.setFlags(LayoutContext.KEEP_WITH_PREVIOUS_PENDING); + childLC.setFlags(LayoutContext.KEEP_WITH_PREVIOUS_PENDING, false); + } + + 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 + } + 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() + || context.isKeepWithNextPending() + || childLC.isKeepWithPreviousPending()) { + //Clear keep pending flag + context.setFlags(LayoutContext.KEEP_WITH_NEXT_PENDING, false); + childLC.setFlags(LayoutContext.KEEP_WITH_PREVIOUS_PENDING, false); + // 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; + } + } + if (childLC.isKeepWithNextPending()) { + //Clear and propagate + childLC.setFlags(LayoutContext.KEEP_WITH_NEXT_PENDING, false); + context.setFlags(LayoutContext.KEEP_WITH_NEXT_PENDING); + } + prevLM = curLM; + } + + returnedList = new LinkedList(); + wrapPositionElements(contentList, returnList); + + setFinished(true); + return returnList; + } + + /** + * Set the y offset of this cell. + * This offset is used to set the absolute position of the cell. + * + * @param off the y direction offset + */ + public void setYOffset(int off) { + yoffset = off; + } + + /** + * Set the x offset of this cell (usually the same as its parent row). + * This offset is used to determine the absolute position of the cell. + * + * @param off the x offset + */ + public void setXOffset(int off) { + xoffset = off; + } + + /** + * Set the IPD offset of this cell inside the table-row. + * This offset is used to determine the absolute position of the cell. + * @param off the IPD offset + */ + public void setInRowIPDOffset(int off) { + this.inRowIPDOffset = off; + } + + /** + * Set the content height for this cell. This method is used during + * addAreas() stage. + * + * @param h the height of the contents of this cell + */ + public void setContentHeight(int h) { + usedBPD = h; + } + + /** + * Set the row height that contains this cell. This method is used during + * addAreas() stage. + * + * @param h the height of the row + */ + public void setRowHeight(int h) { + rowHeight = h; + } + + private int getContentHeight(int rowHeight, GridUnit gu) { + int bpd = rowHeight; + if (isSeparateBorderModel()) { + bpd -= gu.getPrimary().getBorders().getBorderBeforeWidth(false); + bpd -= gu.getPrimary().getBorders().getBorderAfterWidth(false); + } else { + bpd -= gu.getPrimary().getHalfMaxBorderWidth(); + } + CommonBorderPaddingBackground cbpb + = gu.getCell().getCommonBorderPaddingBackground(); + bpd -= cbpb.getPaddingBefore(false); + bpd -= cbpb.getPaddingAfter(false); + return bpd; + } + + /** + * Add the areas for the break points. + * The cell contains block stacking layout managers + * that add block areas. + * + * @param parentIter the iterator of the break positions + * @param layoutContext the layout context for adding the areas + */ + public void addAreas(PositionIterator parentIter, + LayoutContext layoutContext) { + getParentArea(null); + + getPSLM().addIDToPage(fobj.getId()); + + if (isSeparateBorderModel()) { + if (!emptyCell || fobj.showEmptyCells()) { + TraitSetter.addBorders(curBlockArea, fobj.getCommonBorderPaddingBackground()); + TraitSetter.addBackground(curBlockArea, fobj.getCommonBorderPaddingBackground()); + } + } else { + TraitSetter.addBackground(curBlockArea, fobj.getCommonBorderPaddingBackground()); + boolean[] outer = new boolean[] { + gridUnit.getFlag(GridUnit.FIRST_IN_TABLE), + gridUnit.getFlag(GridUnit.LAST_IN_TABLE), + gridUnit.getFlag(GridUnit.IN_FIRST_COLUMN), + gridUnit.getFlag(GridUnit.IN_LAST_COLUMN)}; + if (!gridUnit.hasSpanning()) { + //Can set the borders directly if there's no span + TraitSetter.addCollapsingBorders(curBlockArea, + gridUnit.getBorders(), outer); + } else { + int dy = yoffset; + for (int y = 0; y < gridUnit.getRows().size(); y++) { + GridUnit[] gridUnits = (GridUnit[])gridUnit.getRows().get(y); + int dx = xoffset; + int lastRowHeight = 0; + for (int x = 0; x < gridUnits.length; x++) { + GridUnit gu = gridUnits[x]; + if (!gu.hasBorders()) { + continue; + } + + //Blocks for painting grid unit borders + Block block = new Block(); + block.addTrait(Trait.IS_REFERENCE_AREA, Boolean.TRUE); + block.setPositioning(Block.ABSOLUTE); + + int bpd = getContentHeight(rowHeight, gu); + if (isSeparateBorderModel()) { + bpd += (gu.getBorders().getBorderBeforeWidth(false)); + bpd += (gu.getBorders().getBorderAfterWidth(false)); + } else { + bpd += gridUnit.getHalfMaxBeforeBorderWidth() + - (gu.getBorders().getBorderBeforeWidth(false) / 2); + bpd += gridUnit.getHalfMaxAfterBorderWidth() + - (gu.getBorders().getBorderAfterWidth(false) / 2); + } + block.setBPD(bpd); + lastRowHeight = rowHeight; + int ipd = gu.getColumn().getColumnWidth().getValue(); + int borderStartWidth = gu.getBorders().getBorderStartWidth(false) / 2; + ipd -= borderStartWidth; + ipd -= gu.getBorders().getBorderEndWidth(false) / 2; + block.setIPD(ipd); + block.setXOffset(dx + borderStartWidth); + int halfCollapsingBorderHeight = 0; + if (!isSeparateBorderModel()) { + halfCollapsingBorderHeight + += gu.getBorders().getBorderBeforeWidth(false) / 2; + } + block.setYOffset(dy - halfCollapsingBorderHeight); + TraitSetter.addCollapsingBorders(block, gu.getBorders(), outer); + parentLM.addChildArea(block); + dx += gu.getColumn().getColumnWidth().getValue(); + } + dy += lastRowHeight; + } + log.warn("TODO Add collapsed border painting for spanned cells"); + } + } + + //Handle display-align + if (usedBPD < rowHeight) { + if (fobj.getDisplayAlign() == EN_CENTER) { + Block space = new Block(); + space.setBPD((rowHeight - usedBPD) / 2); + curBlockArea.addBlock(space); + } else if (fobj.getDisplayAlign() == EN_AFTER) { + Block space = new Block(); + space.setBPD((rowHeight - usedBPD)); + curBlockArea.addBlock(space); + } + } + + AreaAdditionUtil.addAreas(this, parentIter, layoutContext); + + int contentBPD = getContentHeight(rowHeight, gridUnit); + curBlockArea.setBPD(contentBPD); + + flush(); + + curBlockArea = null; + } + + /** + * Return an Area which can contain the passed childArea. The childArea + * may not yet have any content, but it has essential traits set. + * In general, if the LayoutManager already has an Area it simply returns + * it. Otherwise, it makes a new Area of the appropriate class. + * It gets a parent area for its area by calling its parent LM. + * Finally, based on the dimensions of the parent area, it initializes + * its own area. This includes setting the content IPD and the maximum + * BPD. + * + * @param childArea the child area to get the parent for + * @return the parent area + */ + public Area getParentArea(Area childArea) { + if (curBlockArea == null) { + curBlockArea = new Block(); + curBlockArea.addTrait(Trait.IS_REFERENCE_AREA, Boolean.TRUE); + curBlockArea.setPositioning(Block.ABSOLUTE); + int indent = 0; + indent += startBorderWidth; + if (!isSeparateBorderModel()) { + indent /= 2; + } + indent += fobj.getCommonBorderPaddingBackground().getPaddingStart(false); + // set position + int halfBorderSep = 0; + if (isSeparateBorderModel()) { + halfBorderSep = fobj.getBorderSeparation().getLengthPair() + .getIPD().getLength().getValue() / 2; + } + int borderAdjust = 0; + if (!isSeparateBorderModel()) { + if (gridUnit.hasSpanning()) { + borderAdjust -= gridUnit.getHalfMaxBeforeBorderWidth(); + } else { + borderAdjust += gridUnit.getHalfMaxBeforeBorderWidth(); + } + } else { + //borderAdjust += gridUnit.getBorders().getBorderBeforeWidth(false); + } + curBlockArea.setXOffset(xoffset + inRowIPDOffset + halfBorderSep + indent); + curBlockArea.setYOffset(yoffset - borderAdjust); + curBlockArea.setIPD(cellIPD); + //curBlockArea.setHeight(); + + // Set up dimensions + /*Area parentArea =*/ parentLM.getParentArea(curBlockArea); + // Get reference IPD from parentArea + setCurrentArea(curBlockArea); // ??? for generic operations + } + return curBlockArea; + } + + /** + * Add the child to the cell block area. + * + * @param childArea the child to add to the cell + */ + public void addChildArea(Area childArea) { + if (curBlockArea != null) { + curBlockArea.addBlock((Block) childArea); + } + } + + /** + * Reset the position of the layout. + * + * @param resetPos the position to reset to + */ + public void resetPosition(Position resetPos) { + if (resetPos == null) { + reset(null); + } + } + + /** + * @see org.apache.fop.layoutmgr.BlockLevelLayoutManager + */ + public int negotiateBPDAdjustment(int adj, KnuthElement lastElement) { + // TODO Auto-generated method stub + return 0; + } + + /** + * @see org.apache.fop.layoutmgr.BlockLevelLayoutManager + */ + public void discardSpace(KnuthGlue spaceGlue) { + // TODO Auto-generated method stub + } + + /** + * @see org.apache.fop.layoutmgr.BlockLevelLayoutManager#mustKeepTogether() + */ + public boolean mustKeepTogether() { + //TODO Keeps will have to be more sophisticated sooner or later + boolean keep = ((BlockLevelLayoutManager)getParent()).mustKeepTogether(); + if (gridUnit.getRow() != null) { + keep |= gridUnit.getRow().mustKeepTogether(); + } + return keep; + } + + /** + * @see org.apache.fop.layoutmgr.BlockLevelLayoutManager#mustKeepWithPrevious() + */ + public boolean mustKeepWithPrevious() { + return false; //TODO FIX ME + /* + return !fobj.getKeepWithPrevious().getWithinPage().isAuto() + || !fobj.getKeepWithPrevious().getWithinColumn().isAuto(); + */ + } + + /** + * @see org.apache.fop.layoutmgr.BlockLevelLayoutManager#mustKeepWithNext() + */ + public boolean mustKeepWithNext() { + return false; //TODO FIX ME + /* + return !fobj.getKeepWithNext().getWithinPage().isAuto() + || !fobj.getKeepWithNext().getWithinColumn().isAuto(); + */ + } + +} + diff --git a/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java index 72c44f2ad..932e7be28 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java @@ -851,7 +851,7 @@ public class TableContentLayoutManager { log.debug("start row: " + pgu.getStartRow() + " " + yoffset + " " + effYOffset); log.debug("contentHeight: " + contentHeight + " rowHeight=" + rowHeight + " effCellHeight=" + effCellHeight); - Cell cellLM = pgu.getCellLM(); + TableCellLayoutManager cellLM = pgu.getCellLM(); cellLM.setXOffset(getXOffsetOfGridUnit(pgu)); cellLM.setYOffset(effYOffset); cellLM.setContentHeight(contentHeight); diff --git a/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java index bb9a40a71..cdb1ea781 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java @@ -14,7 +14,7 @@ * limitations under the License. */ -/* $Id: TableLayoutManager.java,v 1.8 2004/03/21 12:03:08 gmazza Exp $ */ +/* $Id$ */ package org.apache.fop.layoutmgr.table; -- cgit v1.2.3