]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
some minor improvements to make layout work a bit better
authorKeiron Liddle <keiron@apache.org>
Wed, 6 Nov 2002 15:46:55 +0000 (15:46 +0000)
committerKeiron Liddle <keiron@apache.org>
Wed, 6 Nov 2002 15:46:55 +0000 (15:46 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@195437 13f79535-47bb-0310-9956-ffa450edef68

src/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java
src/org/apache/fop/layoutmgr/list/Item.java
src/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java
src/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java
src/org/apache/fop/layoutmgr/table/Body.java
src/org/apache/fop/layoutmgr/table/Caption.java
src/org/apache/fop/layoutmgr/table/Cell.java
src/org/apache/fop/layoutmgr/table/Row.java
src/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java

index dbca5cdd0c99a467503520a30cacb68d93c20958..3550798df13a03d52ffc6979fa4901f8ea3bf860 100644 (file)
@@ -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);
             }
 
index 4372757f47c5b66d4fa278129f1eb7ada7104a72..0157a022737cf43d4e9b81af76adfabee24d211e 100644 (file)
@@ -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
index fd15515f8d05feb6a5215dca1673bab2e0536050..6965e08b2fdc1c039c432f697583cfafa9e856a9 100644 (file)
@@ -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);
index 71e7f34f743633c4c21196434d72f0e4a6bb6bbe..a4422d7cd336cba34ccfd978bc79f1f6aeb406a3 100644 (file)
@@ -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;
             }
         }
 
index 770f6004dd4d2a29a1e57343c37c0551b42f554c..e80ad30a69055ea749163ce8999645b7e8046a26 100644 (file)
@@ -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();
index 4e310034c53af8e227c220a2fecf3628582e88ed..d5a0223f737d836d44549d1ca14f6103cf856267 100644 (file)
@@ -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());
index c471a81a4d3448c6ff7fdabfae5348d188fc8eb3..fe52955e635b04cf62660db0dd8451b8fc7f7f02 100644 (file)
@@ -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());
index dfedc631574ca05f8d1dc3a2c053835b6e1fed75..f325e4e2e20311b222874e5b151095ac98912ec0 100644 (file)
@@ -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());
index dc7ffe21c4f32853052e1ffbf2a7970f85095b85..56af5834653515d9f82e0f857fc057277763355b 100644 (file)
@@ -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());