From d514821a2a1c3f432a5720fa90a901b573996f98 Mon Sep 17 00:00:00 2001 From: Keiron Liddle Date: Wed, 6 Nov 2002 15:46:55 +0000 Subject: [PATCH] some minor improvements to make layout work a bit better git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@195437 13f79535-47bb-0310-9956-ffa450edef68 --- .../BlockContainerLayoutManager.java | 28 +++++++++--------- src/org/apache/fop/layoutmgr/list/Item.java | 29 ++++++------------- .../list/ListBlockLayoutManager.java | 10 +++---- .../layoutmgr/list/ListItemLayoutManager.java | 20 ++----------- src/org/apache/fop/layoutmgr/table/Body.java | 5 ++++ .../apache/fop/layoutmgr/table/Caption.java | 2 +- src/org/apache/fop/layoutmgr/table/Cell.java | 2 +- src/org/apache/fop/layoutmgr/table/Row.java | 2 +- .../table/TableAndCaptionLayoutManager.java | 2 +- 9 files changed, 39 insertions(+), 61 deletions(-) diff --git a/src/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java b/src/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java index dbca5cdd0..3550798df 100644 --- a/src/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java +++ b/src/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java @@ -58,7 +58,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager { propManager = pm; abProps = pm.getAbsolutePositionProps(); - if(abProps.absolutePosition == AbsolutePosition.ABSOLUTE) { + if (abProps.absolutePosition == AbsolutePosition.ABSOLUTE) { Rectangle2D rect = new Rectangle2D.Double(abProps.left, abProps.top, abProps.right - abProps.left, abProps.bottom - abProps.top); @@ -77,7 +77,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager { public BreakPoss getNextBreakPoss(LayoutContext context) { - if(abProps.absolutePosition == AbsolutePosition.ABSOLUTE) { + if (abProps.absolutePosition == AbsolutePosition.ABSOLUTE) { return getAbsoluteBreakPoss(context); } @@ -90,13 +90,13 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager { MinOptMax stackLimit; int ipd = context.getRefIPD(); boolean rotated = vals[0] == 0.0; - if(rotated) { + if (rotated) { // rotated 90 degrees stackLimit = new MinOptMax(1000000); ipd = getRotatedIPD(); absoluteCTM = new CTM(vals[0], vals[1], vals[2], vals[3], 0, 0); } else { - if(vals[0] == -1.0) { + if (vals[0] == -1.0) { absoluteCTM = new CTM(vals[0], vals[1], vals[2], vals[3], 0, 0); } stackLimit = context.getStackLimit(); @@ -123,7 +123,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager { while (!curLM.isFinished()) { if ((bp = curLM.getNextBreakPoss(childLC)) != null) { stackSize.add(bp.getStackingSize()); - if (stackSize.min > stackLimit.max) { + if (stackSize.opt > stackLimit.max) { // reset to last break if (lastPos != null) { reset(lastPos.getPosition()); @@ -139,7 +139,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager { stackLimit, stackSize)); } } - if(!rotated) { + if (!rotated) { BreakPoss breakPoss; breakPoss = new BreakPoss(new LeafPosition(this, childBreaks.size() - 1)); @@ -148,7 +148,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager { } } setFinished(true); - if(rotated) { + if (rotated) { BreakPoss breakPoss; breakPoss = new BreakPoss(new LeafPosition(this, childBreaks.size() - 1)); @@ -189,10 +189,10 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager { // to the normal stacking breakPoss.setStackingSize(new MinOptMax(0)); - if(stackSize.min > relDims.bpd) { - if(overflow == Overflow.HIDDEN) { + if (stackSize.opt > relDims.bpd) { + if (overflow == Overflow.HIDDEN) { clip = true; - } else if(overflow == Overflow.ERROR_IF_OVERFLOW) { + } else if (overflow == Overflow.ERROR_IF_OVERFLOW) { //log.error("contents overflows block-container viewport: clipping"); clip = true; } @@ -230,7 +230,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager { public Area getParentArea(Area childArea) { if (curBlockArea == null) { viewportBlockArea = new BlockViewport(); - if(abProps.absolutePosition == AbsolutePosition.ABSOLUTE) { + if (abProps.absolutePosition == AbsolutePosition.ABSOLUTE) { viewportBlockArea.setXOffset(abProps.left); viewportBlockArea.setYOffset(abProps.top); viewportBlockArea.setWidth(abProps.right - abProps.left); @@ -241,12 +241,12 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager { } else { double[] vals = absoluteCTM.toArray(); boolean rotated = vals[0] == 0.0; - if(rotated) { + if (rotated) { viewportBlockArea.setWidth(relDims.bpd); viewportBlockArea.setHeight(getRotatedIPD()); viewportBlockArea.setCTM(absoluteCTM); viewportBlockArea.setClip(clip); - } else if(vals[0] == -1.0) { + } else if (vals[0] == -1.0) { // need to set bpd to actual size for rotation // and stacking viewportBlockArea.setWidth(relDims.ipd); @@ -259,7 +259,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager { curBlockArea = new Block(); viewportBlockArea.addBlock(curBlockArea); - if(abProps.absolutePosition == AbsolutePosition.ABSOLUTE) { + if (abProps.absolutePosition == AbsolutePosition.ABSOLUTE) { viewportBlockArea.setPositioning(Block.ABSOLUTE); } diff --git a/src/org/apache/fop/layoutmgr/list/Item.java b/src/org/apache/fop/layoutmgr/list/Item.java index 4372757f4..0157a0227 100644 --- a/src/org/apache/fop/layoutmgr/list/Item.java +++ b/src/org/apache/fop/layoutmgr/list/Item.java @@ -39,7 +39,6 @@ public class Item extends BlockStackingLayoutManager { private ArrayList childBreaks = new ArrayList(); private int xoffset; - private int yoffset; private int itemIPD; /** @@ -74,7 +73,7 @@ public class Item extends BlockStackingLayoutManager { itemIPD = context.getRefIPD(); while ((curLM = getChildLM()) != null) { - if(curLM.generatesInlineAreas()) { + if (curLM.generatesInlineAreas()) { // error curLM.setFinished(true); continue; @@ -91,7 +90,7 @@ public class Item extends BlockStackingLayoutManager { while (!curLM.isFinished()) { if ((bp = curLM.getNextBreakPoss(childLC)) != null) { stackSize.add(bp.getStackingSize()); - if (stackSize.min > context.getStackLimit().max) { + if (stackSize.opt > context.getStackLimit().max) { // reset to last break if (lastPos != null) { reset(lastPos.getPosition()); @@ -117,18 +116,9 @@ public class Item extends BlockStackingLayoutManager { } /** - * 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. - * This offset is used to set the absolute position of the cell. + * Set the x offset of this list item. + * This offset is used to set the absolute position + * of the list item within the parent block area. * * @param off the x offset */ @@ -138,7 +128,7 @@ public class Item extends BlockStackingLayoutManager { /** * Add the areas for the break points. - * The cell contains block stacking layout managers + * The list item contains block stacking layout managers * that add block areas. * * @param parentIter the iterator of the break positions @@ -164,10 +154,10 @@ public class Item extends BlockStackingLayoutManager { } } - if(borderProps != null) { + if (borderProps != null) { addBorders(curBlockArea, borderProps); } - if(backgroundProps != null) { + if (backgroundProps != null) { addBackground(curBlockArea, backgroundProps); } @@ -196,7 +186,6 @@ public class Item extends BlockStackingLayoutManager { curBlockArea.setPositioning(Block.ABSOLUTE); // set position curBlockArea.setXOffset(xoffset); - curBlockArea.setYOffset(yoffset); curBlockArea.setWidth(itemIPD); //curBlockArea.setHeight(); @@ -211,7 +200,7 @@ public class Item extends BlockStackingLayoutManager { } /** - * Add the child to the cell block area. + * Add the child to the list item area. * * @param childArea the child to add to the cell * @return unused diff --git a/src/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java b/src/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java index fd15515f8..6965e08b2 100644 --- a/src/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java +++ b/src/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java @@ -134,11 +134,9 @@ public class ListBlockLayoutManager extends BlockStackingLayoutManager { getParentArea(null); addID(); - // add column, body then row areas + // the list block contains areas stacked from each list item - // add table header areas - - int tableHeight = 0; + int listHeight = 0; ListItemLayoutManager childLM; int iStartPos = 0; @@ -152,13 +150,13 @@ public class ListBlockLayoutManager extends BlockStackingLayoutManager { iStartPos = lfp.getLeafPos() + 1; while ((childLM = (ListItemLayoutManager)breakPosIter.getNextChildLM()) != null) { childLM.addAreas(breakPosIter, lc); - tableHeight += childLM.getListItemHeight(); + listHeight += childLM.getListItemHeight(); } } // add footer areas - curBlockArea.setHeight(tableHeight); + curBlockArea.setHeight(listHeight); if(borderProps != null) { addBorders(curBlockArea, borderProps); diff --git a/src/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java b/src/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java index 71e7f34f7..a4422d7cd 100644 --- a/src/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java +++ b/src/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java @@ -40,7 +40,6 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager { private List cellList = null; private List columns = null; private int listItemHeight; - private int yoffset; private BorderAndPadding borderProps = null; private BackgroundProps backgroundProps; @@ -122,7 +121,7 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager { while (!curLM.isFinished()) { if ((bp = curLM.getNextBreakPoss(childLC)) != null) { stackSize.add(bp.getStackingSize()); - if (stackSize.min > context.getStackLimit().max) { + if (stackSize.opt > context.getStackLimit().max) { // reset to last break if (lastPos != null) { curLM.resetPosition(lastPos.getPosition()); @@ -130,8 +129,9 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager { curLM.resetPosition(null); } break; + } else { + lastPos = bp; } - lastPos = bp; childBreaks.add(bp); childLC.setStackLimit(MinOptMax.subtract( @@ -164,16 +164,6 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager { return breakPoss; } - /** - * Set the y position offset of this list item. - * This is used to set the position of the areas returned by this list item. - * - * @param off the y offset - */ - public void setYOffset(int off) { - yoffset = off; - } - /** * Add the areas for the break points. * This sets the offset of each cell as it is added. @@ -187,18 +177,15 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager { addID(); Item childLM; - int iStartPos = 0; LayoutContext lc = new LayoutContext(0); while (parentIter.hasNext()) { ItemPosition lfp = (ItemPosition) parentIter.next(); // Add the block areas to Area - int xoffset = 0; for (Iterator iter = lfp.cellBreaks.iterator(); iter.hasNext();) { List cellsbr = (List)iter.next(); PositionIterator breakPosIter; breakPosIter = new BreakPossPosIter(cellsbr, 0, cellsbr.size()); - iStartPos = lfp.getLeafPos() + 1; while ((childLM = (Item)breakPosIter.getNextChildLM()) != null) { if(childLM == body) { @@ -206,7 +193,6 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager { } childLM.addAreas(breakPosIter, lc); } - xoffset += 100000; } } diff --git a/src/org/apache/fop/layoutmgr/table/Body.java b/src/org/apache/fop/layoutmgr/table/Body.java index 770f6004d..e80ad30a6 100644 --- a/src/org/apache/fop/layoutmgr/table/Body.java +++ b/src/org/apache/fop/layoutmgr/table/Body.java @@ -53,6 +53,11 @@ public class Body extends BlockStackingLayoutManager { super(fobj); } + /** + * Initialize properties for this layout manager. + * + * @param propMgr the property manager from the fo object + */ protected void initProperties(PropertyManager propMgr) { borderProps = propMgr.getBorderAndPadding(); backgroundProps = propMgr.getBackgroundProps(); diff --git a/src/org/apache/fop/layoutmgr/table/Caption.java b/src/org/apache/fop/layoutmgr/table/Caption.java index 4e310034c..d5a0223f7 100644 --- a/src/org/apache/fop/layoutmgr/table/Caption.java +++ b/src/org/apache/fop/layoutmgr/table/Caption.java @@ -76,7 +76,7 @@ public class Caption extends BlockStackingLayoutManager { while (!curLM.isFinished()) { if ((bp = curLM.getNextBreakPoss(childLC)) != null) { stackSize.add(bp.getStackingSize()); - if (stackSize.min > context.getStackLimit().max) { + if (stackSize.opt > context.getStackLimit().max) { // reset to last break if (lastPos != null) { reset(lastPos.getPosition()); diff --git a/src/org/apache/fop/layoutmgr/table/Cell.java b/src/org/apache/fop/layoutmgr/table/Cell.java index c471a81a4..fe52955e6 100644 --- a/src/org/apache/fop/layoutmgr/table/Cell.java +++ b/src/org/apache/fop/layoutmgr/table/Cell.java @@ -92,7 +92,7 @@ public class Cell extends BlockStackingLayoutManager { while (!curLM.isFinished()) { if ((bp = curLM.getNextBreakPoss(childLC)) != null) { stackSize.add(bp.getStackingSize()); - if (stackSize.min > context.getStackLimit().max) { + if (stackSize.opt > context.getStackLimit().max) { // reset to last break if (lastPos != null) { reset(lastPos.getPosition()); diff --git a/src/org/apache/fop/layoutmgr/table/Row.java b/src/org/apache/fop/layoutmgr/table/Row.java index dfedc6315..f325e4e2e 100644 --- a/src/org/apache/fop/layoutmgr/table/Row.java +++ b/src/org/apache/fop/layoutmgr/table/Row.java @@ -152,7 +152,7 @@ public class Row extends BlockStackingLayoutManager { while (!curLM.isFinished()) { if ((bp = curLM.getNextBreakPoss(childLC)) != null) { stackSize.add(bp.getStackingSize()); - if (stackSize.min > context.getStackLimit().max) { + if (stackSize.opt > context.getStackLimit().max) { // reset to last break if (lastPos != null) { reset(lastPos.getPosition()); diff --git a/src/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java b/src/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java index dc7ffe21c..56af58346 100644 --- a/src/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java +++ b/src/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java @@ -78,7 +78,7 @@ public class TableAndCaptionLayoutManager extends BlockStackingLayoutManager { while (!curLM.isFinished()) { if ((bp = curLM.getNextBreakPoss(childLC)) != null) { stackSize.add(bp.getStackingSize()); - if (stackSize.min > context.getStackLimit().max) { + if (stackSize.opt > context.getStackLimit().max) { // reset to last break if (lastPos != null) { reset(lastPos.getPosition()); -- 2.39.5