]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Bugfix for layout of block-containers with fixed BPD. They weren't properly broken...
authorJeremias Maerki <jeremias@apache.org>
Wed, 26 Jan 2005 15:00:04 +0000 (15:00 +0000)
committerJeremias Maerki <jeremias@apache.org>
Wed, 26 Jan 2005 15:00:04 +0000 (15:00 +0000)
If autoHeight is false, the whole block-container is considered a non-breakable block. Seems to match the behaviour of other implementations but I still haven't found the right place in the spec.

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@198322 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java

index 68517a1a480856e807270e19e3ca3f19b78f2c97..a92558ee2a15209ec5fb143df5c575dae4aca158 100644 (file)
@@ -234,6 +234,19 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
         fobj.setLayoutDimension(PercentBase.REFERENCE_AREA_BPD, relDims.bpd);
 
         while ((curLM = getChildLM()) != null) {
+            //Treat bc with fixed BPD as non-breakable
+            if (!autoHeight && (stackLimit.max > context.stackLimit.max)) {
+                if (log.isDebugEnabled()) {
+                    log.debug("block-container does not fit in the available area "
+                            + "(available: " + context.stackLimit.max
+                            + ", needed: " + stackLimit.max + ")");
+                }
+                BreakPoss breakPoss = new BreakPoss(new LeafPosition(this, -1));
+                breakPoss.setFlag(BreakPoss.NEXT_OVERFLOWS, true);
+                breakPoss.setStackingSize(new MinOptMax());
+                return breakPoss;
+            }
+
             // Make break positions and return blocks!
             // Set up a LayoutContext
             BreakPoss bp;
@@ -247,8 +260,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
             boolean over = false;
             while (!curLM.isFinished()) {
                 if ((bp = curLM.getNextBreakPoss(childLC)) != null) {
-                    stackSize.add(bp.getStackingSize());
-                    if (stackSize.opt > stackLimit.max) {
+                    if (stackSize.opt + bp.getStackingSize().opt > stackLimit.max) {
                         // reset to last break
                         if (lastPos != null) {
                             reset(lastPos.getPosition());
@@ -258,19 +270,20 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
                         over = true;
                         break;
                     }
-                    lastPos = bp;
-                    childBreaks.add(bp);
-
                     if (bp.nextBreakOverflows()) {
                         over = true;
                         break;
                     }                    
                     
+                    stackSize.add(bp.getStackingSize());
+                    lastPos = bp;
+                    childBreaks.add(bp);
+
                     childLC.setStackLimit(MinOptMax.subtract(
                                            stackLimit, stackSize));
                 }
             }
-            if (!rotated) {
+            if (!rotated && autoHeight) {
                 BreakPoss breakPoss;
                 breakPoss = new BreakPoss(new LeafPosition(this,
                                                    childBreaks.size() - 1));
@@ -289,6 +302,14 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
             breakPoss.setStackingSize(new MinOptMax(relDims.ipd));
             return breakPoss;
         }
+        if (!rotated && !autoHeight) {
+            //Treated as if all content is kept together
+            BreakPoss breakPoss;
+            breakPoss = new BreakPoss(new LeafPosition(this,
+                                               childBreaks.size() - 1));
+            breakPoss.setStackingSize(new MinOptMax(relDims.bpd));
+            return breakPoss;
+        }
         return null;
     }