jeremias 2005/02/07 03:01:37 Modified: src/java/org/apache/fop/layoutmgr PageSequenceLayoutManager.java AbstractLayoutManager.java LayoutManager.java PositionIterator.java ContentLayoutManager.java BreakPoss.java BlockLayoutManager.java src/java/org/apache/fop/layoutmgr/table Row.java Cell.java Added: src/java/org/apache/fop/layoutmgr MinOptMaxUtil.java Log: Temporary fix for markers (using isBogus() check) ipd/height and display-align support for table rows and cells. Revision Changes Path 1.29 +9 -3 xml-fop/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java Index: PageSequenceLayoutManager.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java,v retrieving revision 1.28 retrieving revision 1.29 diff -u -r1.28 -r1.29 --- PageSequenceLayoutManager.java 6 Feb 2005 20:48:48 -0000 1.28 +++ PageSequenceLayoutManager.java 7 Feb 2005 11:01:36 -0000 1.29 @@ -227,6 +227,11 @@ pageSeq.setCurrentPageNumber(getPageCount()); } + /** @see org.apache.fop.layoutmgr.LayoutManager#isBogus() */ + public boolean isBogus() { + return false; + } + /** * Get the next break possibility. * This finds the next break for a page which is always at the end @@ -484,8 +489,9 @@ RegionViewport rv = curPage.getPage().getRegionViewport( FO_REGION_BODY); curBody = (BodyRegion) rv.getRegion(); - flowBPD = (int) curBody.getBPD() - - rv.getBorderAndPaddingWidthBefore() - rv.getBorderAndPaddingWidthAfter(); + flowBPD = (int) curBody.getBPD() + - rv.getBorderAndPaddingWidthBefore() + - rv.getBorderAndPaddingWidthAfter(); return curPage; } 1.36 +25 -2 xml-fop/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java Index: AbstractLayoutManager.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java,v retrieving revision 1.35 retrieving revision 1.36 diff -u -r1.35 -r1.36 --- AbstractLayoutManager.java 24 Dec 2004 12:06:26 -0000 1.35 +++ AbstractLayoutManager.java 7 Feb 2005 11:01:36 -0000 1.36 @@ -1,5 +1,5 @@ /* - * Copyright 1999-2004 The Apache Software Foundation. + * 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. @@ -48,6 +48,13 @@ /** True if this LayoutManager has handled all of its content. */ private boolean bFinished = false; protected boolean bInited = false; + + /** + * Used during addAreas(): signals that a BreakPoss is not generating areas + * and therefore doesn't add IDs and markers to the current page. + * @see org.apache.fop.layoutmgr.AbstractLayoutManager#isBogus + */ + protected boolean bBogus = false; /** child LM and child LM iterator during getNextBreakPoss phase */ protected LayoutManager curChildLM = null; @@ -145,10 +152,20 @@ */ + /** @see org.apache.fop.layoutmgr.LayoutManager#generatesInlineAreas() */ public boolean generatesInlineAreas() { return false; } + /** @see org.apache.fop.layoutmgr.LayoutManager#isBogus() */ + public boolean isBogus() { + if (getParent().isBogus()) { + return true; + } else { + return bBogus; + } + } + /** * Add a child area to the current area. If this causes the maximum * dimension of the current area to be exceeded, the parent LM is called @@ -263,6 +280,9 @@ } + /** + * @see org.apache.fop.layoutmgr.LayoutManager#addAreas(org.apache.fop.layoutmgr.PositionIterator, org.apache.fop.layoutmgr.LayoutContext) + */ public void addAreas(PositionIterator posIter, LayoutContext context) { } @@ -276,6 +296,9 @@ * interface which are declared abstract in AbstractLayoutManager. * ---------------------------------------------------------*/ + /** + * @see org.apache.fop.layoutmgr.LayoutManager#getParentArea(org.apache.fop.area.Area) + */ public Area getParentArea(Area childArea) { return null; } @@ -309,7 +332,7 @@ * If the id string is not null then add the id to the current page. */ protected void addID(String foID) { - if (foID != null) { + if (foID != null && foID.length() > 0) { addIDToPage(foID); } } 1.18 +12 -1 xml-fop/src/java/org/apache/fop/layoutmgr/LayoutManager.java Index: LayoutManager.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/LayoutManager.java,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- LayoutManager.java 24 Dec 2004 12:06:26 -0000 1.17 +++ LayoutManager.java 7 Feb 2005 11:01:36 -0000 1.18 @@ -1,5 +1,5 @@ /* - * Copyright 1999-2004 The Apache Software Foundation. + * 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. @@ -72,6 +72,17 @@ boolean generatesInlineAreas(); /** + * This method is used during the stage where addAreas() converts BreakPoss + * instances to areas. It is used to skip adding IDs and markers to a page + * when the current BreakPoss/area was only generated to signal a break + * situation. This avoids adding IDs and markers to the wrong pages. + * @todo This is a hack. This should be handled differently in the long term. + * @return true if the current BreakPoss/area was only generated to signal + * break situations. + */ + boolean isBogus(); + + /** * Return true if the next area which would be generated by this * LayoutManager could start a new line (or flow for block-level FO). * 1.4 +2 -1 xml-fop/src/java/org/apache/fop/layoutmgr/PositionIterator.java Index: PositionIterator.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/PositionIterator.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- PositionIterator.java 21 Mar 2004 12:03:08 -0000 1.3 +++ PositionIterator.java 7 Feb 2005 11:01:36 -0000 1.4 @@ -84,13 +84,14 @@ if (bHasNext) { Object retObj = getPos(nextObj); lookAhead(); + //System.out.println(retObj); return retObj; } else { throw new NoSuchElementException("PosIter"); } } - protected Object peekNext() { + public Object peekNext() { return nextObj; } 1.19 +7 -1 xml-fop/src/java/org/apache/fop/layoutmgr/ContentLayoutManager.java Index: ContentLayoutManager.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/ContentLayoutManager.java,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- ContentLayoutManager.java 24 Dec 2004 12:06:26 -0000 1.18 +++ ContentLayoutManager.java 7 Feb 2005 11:01:36 -0000 1.19 @@ -1,5 +1,5 @@ /* - * Copyright 1999-2004 The Apache Software Foundation. + * 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. @@ -159,6 +159,11 @@ return true; } + /** @see org.apache.fop.layoutmgr.LayoutManager#isBogus() */ + public boolean isBogus() { + return false; + } + /** @see org.apache.fop.layoutmgr.LayoutManager */ public Area getParentArea(Area childArea) { return holder; @@ -370,5 +375,6 @@ int alignment) { return null; } + } 1.8 +7 -0 xml-fop/src/java/org/apache/fop/layoutmgr/BreakPoss.java Index: BreakPoss.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/BreakPoss.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- BreakPoss.java 26 Jan 2005 14:54:52 -0000 1.7 +++ BreakPoss.java 7 Feb 2005 11:01:36 -0000 1.8 @@ -187,6 +187,13 @@ return ((flags & ALL_ARE_SUPPRESS_AT_LB) != 0); } + /** + * @return true if the BreakPoss results in an area being created. + */ + public boolean generatesAreas() { + return !(nextBreakOverflows() && getStackingSize().opt <= 0); + } + public SpaceSpecifier getLeadingSpace() { return spaceSpecLeading; } 1.41 +10 -3 xml-fop/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java Index: BlockLayoutManager.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java,v retrieving revision 1.40 retrieving revision 1.41 diff -u -r1.40 -r1.41 --- BlockLayoutManager.java 1 Feb 2005 14:18:28 -0000 1.40 +++ BlockLayoutManager.java 7 Feb 2005 11:01:36 -0000 1.41 @@ -285,13 +285,18 @@ LayoutContext layoutContext) { getParentArea(null); + BreakPoss bp1 = (BreakPoss)parentIter.peekNext(); + bBogus = !bp1.generatesAreas(); + // if adjusted space before double adjust = layoutContext.getSpaceAdjust(); addBlockSpacing(adjust, foBlockSpaceBefore); foBlockSpaceBefore = null; - addID(fobj.getId()); - addMarkers(true, true); + if (!isBogus()) { + addID(fobj.getId()); + addMarkers(true, true); + } try { LayoutManager childLM; @@ -311,7 +316,9 @@ } } } finally { - addMarkers(false, true); + if (!isBogus()) { + addMarkers(false, true); + } flush(); // if adjusted space after 1.1 xml-fop/src/java/org/apache/fop/layoutmgr/MinOptMaxUtil.java Index: MinOptMaxUtil.java =================================================================== /* * Copyright 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: MinOptMaxUtil.java,v 1.1 2005/02/07 11:01:36 jeremias Exp $ */ package org.apache.fop.layoutmgr; import org.apache.fop.fo.Constants; import org.apache.fop.fo.properties.LengthRangeProperty; import org.apache.fop.traits.MinOptMax; /** * Utilities for MinOptMax and LengthRangeProperty. */ public class MinOptMaxUtil { /** * Restricts a MinOptMax using the values from a LengthRangeProperty. * @param mom MinOptMax to restrict * @param lr restricting source */ public static void restrict(MinOptMax mom, LengthRangeProperty lr) { if (lr.getEnum() != Constants.EN_AUTO) { if (lr.getMinimum().getEnum() != Constants.EN_AUTO) { int min = lr.getMinimum().getLength().getValue(); if (min > mom.min) { mom.min = min; fixAfterMinChanged(mom); } } if (lr.getMaximum().getEnum() != Constants.EN_AUTO) { int max = lr.getMaximum().getLength().getValue(); if (max < mom.max) { mom.max = max; if (mom.max < mom.opt) { mom.opt = mom.max; mom.min = mom.opt; } } } if (lr.getOptimum().getEnum() != Constants.EN_AUTO) { int opt = lr.getOptimum().getLength().getValue(); if (opt > mom.min) { mom.opt = opt; if (mom.opt > mom.max) { mom.max = mom.opt; } } } } } /** * After a calculation on a MinOptMax, this can be called to set opt to * a new effective value. * @param mom MinOptMax to adjust */ public static void fixAfterMinChanged(MinOptMax mom) { if (mom.min > mom.opt) { mom.opt = mom.min; if (mom.opt > mom.max) { mom.max = mom.opt; } } } } 1.17 +40 -10 xml-fop/src/java/org/apache/fop/layoutmgr/table/Row.java Index: Row.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/table/Row.java,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- Row.java 31 Jan 2005 21:16:45 -0000 1.16 +++ Row.java 7 Feb 2005 11:01:37 -0000 1.17 @@ -19,17 +19,20 @@ package org.apache.fop.layoutmgr.table; import org.apache.fop.fo.flow.TableRow; +import org.apache.fop.fo.properties.LengthRangeProperty; import org.apache.fop.layoutmgr.BlockStackingLayoutManager; 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.MinOptMaxUtil; 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; import org.apache.fop.area.Block; +import org.apache.fop.area.Trait; import org.apache.fop.traits.MinOptMax; import java.util.Iterator; @@ -48,6 +51,7 @@ private List cellList = null; private List columns = null; + private int referenceIPD; private int rowHeight; private int xoffset; private int yoffset; @@ -133,7 +137,7 @@ // Set up a LayoutContext // the ipd is from the current column - int ipd = context.getRefIPD(); + referenceIPD = context.getRefIPD(); BreakPoss bp; LayoutContext childLC = new LayoutContext(0); @@ -194,9 +198,17 @@ breakList.add(childBreaks); } - rowHeight = opt; - MinOptMax rowSize = new MinOptMax(min, opt, max); + LengthRangeProperty specifiedBPD = fobj.getBlockProgressionDimension(); + if (specifiedBPD.getEnum() != EN_AUTO) { + if ((specifiedBPD.getMaximum().getEnum() != EN_AUTO) + && (specifiedBPD.getMaximum().getLength().getValue() < rowSize.min)) { + log.warn("maximum height of row is smaller than the minimum " + + "height of its contents"); + } + MinOptMaxUtil.restrict(rowSize, specifiedBPD); + } + rowHeight = rowSize.opt; boolean fin = true; cellcount = 0; @@ -278,14 +290,27 @@ public void addAreas(PositionIterator parentIter, LayoutContext layoutContext) { getParentArea(null); - addID(fobj.getId()); + BreakPoss bp1 = (BreakPoss)parentIter.peekNext(); + bBogus = !bp1.generatesAreas(); + if (!isBogus()) { + addID(fobj.getId()); + } Cell childLM; int iStartPos = 0; LayoutContext lc = new LayoutContext(0); while (parentIter.hasNext()) { RowPosition lfp = (RowPosition) parentIter.next(); - // Add the block areas to Area + + //area exclusively for painting the row background + Block rowArea = getRowArea(); + if (rowArea != null) { + rowArea.setBPD(rowHeight); + rowArea.setIPD(referenceIPD); + rowArea.setXOffset(xoffset); + rowArea.setYOffset(yoffset); + parentLM.addChild(rowArea); + } int cellcount = 0; int x = this.xoffset; @@ -316,7 +341,6 @@ } flush(); - } /** @@ -374,10 +398,16 @@ * * @return the row area */ - public Area getRowArea() { - Area block = new Block(); - TraitSetter.addBackground(block, fobj.getCommonBorderPaddingBackground()); - return block; + public Block getRowArea() { + if (fobj.getCommonBorderPaddingBackground().hasBackground()) { + Block block = new Block(); + block.addTrait(Trait.IS_REFERENCE_AREA, Boolean.TRUE); + block.setPositioning(Block.ABSOLUTE); + TraitSetter.addBackground(block, fobj.getCommonBorderPaddingBackground()); + return block; + } else { + return null; + } } } 1.14 +39 -4 xml-fop/src/java/org/apache/fop/layoutmgr/table/Cell.java Index: Cell.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/table/Cell.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- Cell.java 31 Jan 2005 13:52:12 -0000 1.13 +++ Cell.java 7 Feb 2005 11:01:37 -0000 1.14 @@ -19,17 +19,20 @@ package org.apache.fop.layoutmgr.table; import org.apache.fop.fo.flow.TableCell; +import org.apache.fop.fo.properties.LengthRangeProperty; import org.apache.fop.layoutmgr.BlockStackingLayoutManager; 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.MinOptMaxUtil; 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; import org.apache.fop.area.Block; +import org.apache.fop.area.CTM; import org.apache.fop.area.Trait; import org.apache.fop.traits.MinOptMax; @@ -50,7 +53,8 @@ private int xoffset; private int yoffset; private int cellIPD; - private int height; + private int allocBPD; + private int usedBPD; /** * Create a new Cell layout manager. @@ -123,6 +127,19 @@ context.getStackLimit(), stackSize)); } } + + usedBPD = stackSize.opt; + + LengthRangeProperty specifiedBPD = fobj.getBlockProgressionDimension(); + if (specifiedBPD.getEnum() != EN_AUTO) { + if ((specifiedBPD.getMaximum().getEnum() != EN_AUTO) + && (specifiedBPD.getMaximum().getLength().getValue() < stackSize.min)) { + log.warn("maximum height of cell is smaller than the minimum " + + "height of its contents"); + } + MinOptMaxUtil.restrict(stackSize, specifiedBPD); + } + BreakPoss breakPoss = new BreakPoss( new LeafPosition(this, childBreaks.size() - 1)); if (over) { @@ -161,7 +178,7 @@ * @param h the height of the row */ public void setRowHeight(int h) { - height = h; + allocBPD = h; } /** @@ -175,7 +192,25 @@ public void addAreas(PositionIterator parentIter, LayoutContext layoutContext) { getParentArea(null); - addID(fobj.getId()); + BreakPoss bp1 = (BreakPoss)parentIter.peekNext(); + bBogus = !bp1.generatesAreas(); + + if (!isBogus()) { + addID(fobj.getId()); + } + + //Handle display-align + if (usedBPD < allocBPD) { + if (fobj.getDisplayAlign() == EN_CENTER) { + Block space = new Block(); + space.setBPD((allocBPD - usedBPD) / 2); + curBlockArea.addBlock(space); + } else if (fobj.getDisplayAlign() == EN_AFTER) { + Block space = new Block(); + space.setBPD((allocBPD - usedBPD)); + curBlockArea.addBlock(space); + } + } LayoutManager childLM; int iStartPos = 0; @@ -195,7 +230,7 @@ TraitSetter.addBorders(curBlockArea, fobj.getCommonBorderPaddingBackground()); TraitSetter.addBackground(curBlockArea, fobj.getCommonBorderPaddingBackground()); - curBlockArea.setBPD(height); + curBlockArea.setBPD(allocBPD); flush();
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]