]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Fix for the two problems raised by Simon: Temp_SpaceResolution Temp_SpaceResolution
authorJeremias Maerki <jeremias@apache.org>
Thu, 20 Oct 2005 13:30:19 +0000 (13:30 +0000)
committerJeremias Maerki <jeremias@apache.org>
Thu, 20 Oct 2005 13:30:19 +0000 (13:30 +0000)
In some cases the element lists were processed in the wrong direction. Fixed by not reversing the list itself anymore but teaching the conditional handling to process the lists backwards.
The problem is now covered by block_space-before_space-after_9 and 9a.

While fixing this another problem surfaced with hard breaks where two element lists are generated.
The problem is now covered by block_space-before_space-after_9a.

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

15 files changed:
src/java/org/apache/fop/layoutmgr/AbstractBreaker.java
src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java
src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java
src/java/org/apache/fop/layoutmgr/KnuthSequence.java
src/java/org/apache/fop/layoutmgr/SpaceResolver.java
src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java
src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java
test/layoutengine/testcases/block-container_space-before_space-after_1.xml
test/layoutengine/testcases/block_space-before_space-after_2.xml
test/layoutengine/testcases/block_space-before_space-after_9.xml [new file with mode: 0644]
test/layoutengine/testcases/block_space-before_space-after_9a.xml [new file with mode: 0644]
test/layoutengine/testcases/list-block_space-before_space-after_1.xml
test/layoutengine/testcases/region_side_space-resolution.xml
test/layoutengine/testcases/table_space-before_space-after_1.xml

index 9c82728e505e57c87a2c29a65d0c4d36f93fe4b9..743d305741cc30180f019fb4e6576219abb6f3d4 100644 (file)
@@ -76,8 +76,8 @@ public abstract class AbstractBreaker {
             return this.startOn;
         }
 
-        public BlockSequence endBlockSequence() {
-            KnuthSequence temp = super.endSequence();
+        public BlockSequence endBlockSequence(Position breakPosition) {
+            KnuthSequence temp = super.endSequence(breakPosition);
             if (temp != null) {
                 BlockSequence returnSequence = new BlockSequence(startOn);
                 returnSequence.addAll(temp);
@@ -308,6 +308,10 @@ public abstract class AbstractBreaker {
             
             int displayAlign = getCurrentDisplayAlign();
             
+            //The following is needed by SpaceResolver.performConditionalsNotification()
+            //further down as there may be important Position elements in the element list trailer
+            int notificationEndElementIndex = endElementIndex;
+
             // ignore the last elements added by the
             // PageSequenceLayoutManager
             endElementIndex -= (endElementIndex == (originalList.size() - 1)) 
@@ -329,12 +333,13 @@ public abstract class AbstractBreaker {
             while (effectiveListIterator.hasNext()
                     && !(firstElement = (KnuthElement) effectiveListIterator.next())
                             .isBox()) {
+                /*
                 if (firstElement.isGlue() && firstElement.getLayoutManager() != null) {
                     // discard the space representd by the glue element
                     ((BlockLevelLayoutManager) firstElement
                             .getLayoutManager())
                             .discardSpace((KnuthGlue) firstElement);
-                }
+                }*/
                 startElementIndex++;
             }
 
@@ -380,7 +385,7 @@ public abstract class AbstractBreaker {
 
                 // Handle SpaceHandling(Break)Positions, see SpaceResolver!
                 SpaceResolver.performConditionalsNotification(effectiveList, 
-                        startElementIndex, endElementIndex, lastBreak);
+                        startElementIndex, notificationEndElementIndex, lastBreak);
                 
                 // Add areas now!
                 addAreas(new KnuthPossPosIter(effectiveList,
@@ -439,10 +444,12 @@ public abstract class AbstractBreaker {
             //Only implemented by the PSLM
             nextSequenceStartsOn = handleSpanChange(childLC, nextSequenceStartsOn);
             
+            Position breakPosition = null;
             if (((KnuthElement) returnedList.getLast()).isPenalty()
                     && ((KnuthPenalty) returnedList.getLast()).getP() == -KnuthElement.INFINITE) {
                 KnuthPenalty breakPenalty = (KnuthPenalty) returnedList
                         .removeLast();
+                breakPosition = breakPenalty.getPosition();
                 switch (breakPenalty.getBreakClass()) {
                 case Constants.EN_PAGE:
                     log.debug("PLM> break - PAGE");
@@ -468,7 +475,7 @@ public abstract class AbstractBreaker {
             }
             blockList.addAll(returnedList);
             BlockSequence seq = null;
-            seq = blockList.endBlockSequence();
+            seq = blockList.endBlockSequence(breakPosition);
             if (seq != null) {
                 blockLists.add(seq);
             }
index d8183bcb81975c24b784876ef3ffe2d9c6822d73..50281ef448f71fe1556c86968f520eeed8ea26c0 100644 (file)
@@ -229,12 +229,10 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager
             }
         }
 
-        if (!bSpaceBeforeServed) {
-            addKnuthElementsForSpaceBefore(returnList, alignment);
-            bSpaceBeforeServed = true;
-        }
+        addKnuthElementsForSpaceBefore(returnList, alignment);
         
-        addKnuthElementsForBorderPaddingBefore(returnList);
+        addKnuthElementsForBorderPaddingBefore(returnList, !firstVisibleMarkServed);
+        firstVisibleMarkServed = true;
 
         if (autoHeight) {
             //Spaces, border and padding to be repeated at each break
@@ -256,6 +254,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager
                 if (returnedList.size() == 1
                         && ((KnuthElement)returnedList.getFirst()).isForcedBreak()) {
                     // a descendant of this block has break-before
+                    /*
                     if (returnList.size() == 0) {
                         // the first child (or its first child ...) has
                         // break-before;
@@ -263,7 +262,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager
                         // the
                         // following page
                         bSpaceBeforeServed = false;
-                    }
+                    }*/
                     contentList.addAll(returnedList);
 
                     // "wrap" the Position inside each element
@@ -352,7 +351,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager
                 }
             }
         }
-        addKnuthElementsForBorderPaddingAfter(returnList);
+        addKnuthElementsForBorderPaddingAfter(returnList, true);
         addKnuthElementsForSpaceAfter(returnList, alignment);
         addKnuthElementsForBreakAfter(returnList, context);
 
index ac0abc26e4b01db43addf04c1c23b568bbfffa63..b3ad7225b8a008f924b654b4485334ce1bbaf5b6 100644 (file)
@@ -55,8 +55,8 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
     protected LinkedList storedList = null;
     /** Indicates whether break before has been served or not */
     protected boolean bBreakBeforeServed = false;
-    /** Indicates whether space before has been served or not */
-    protected boolean bSpaceBeforeServed = false;
+    /** Indicates whether the first visible mark has been returned by this LM, yet */
+    protected boolean firstVisibleMarkServed = false;
     /** Reference IPD available */
     protected int referenceIPD = 0;
     /**
@@ -218,12 +218,10 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
             }
         }
 
-        if (!bSpaceBeforeServed) {
-            addKnuthElementsForSpaceBefore(returnList, alignment);
-            bSpaceBeforeServed = true;
-        }
+        addKnuthElementsForSpaceBefore(returnList, alignment);
         
-        addKnuthElementsForBorderPaddingBefore(returnList);
+        addKnuthElementsForBorderPaddingBefore(returnList, !firstVisibleMarkServed);
+        firstVisibleMarkServed = true;
 
         //Spaces, border and padding to be repeated at each break
         addPendingMarks(context);
@@ -257,6 +255,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
                     && returnedList.size() == 1
                     && ((ListElement) returnedList.getFirst()).isForcedBreak()) {
                 // a descendant of this block has break-before
+                /*
                 if (returnList.size() == 0) {
                     // the first child (or its first child ...) has
                     // break-before;
@@ -264,7 +263,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
                     // the
                     // following page
                     bSpaceBeforeServed = false;
-                }
+                }*/
                 contentList.addAll(returnedList);
 
                 /* extension: conversione di tutta la sequenza fin'ora ottenuta */
@@ -369,7 +368,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
             returnList.add(new KnuthBox(0, notifyPos(new Position(this)), true));
         }
 
-        addKnuthElementsForBorderPaddingAfter(returnList);
+        addKnuthElementsForBorderPaddingAfter(returnList, true);
         addKnuthElementsForSpaceAfter(returnList, alignment);
         addKnuthElementsForBreakAfter(returnList, context);
 
@@ -858,7 +857,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
      * Creates Knuth elements for before border padding and adds them to the return list.
      * @param returnList return list to add the additional elements to
      */
-    protected void addKnuthElementsForBorderPaddingBefore(LinkedList returnList) {
+    protected void addKnuthElementsForBorderPaddingBefore(LinkedList returnList, boolean isFirst) {
         //Border and Padding (before)
         CommonBorderPaddingBackground borderAndPadding = getBorderPaddingBackground();
         if (borderAndPadding != null) {
@@ -866,14 +865,15 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
                 returnList.add(new BorderElement(
                         getAuxiliaryPosition(), 
                         borderAndPadding.getBorderInfo(CommonBorderPaddingBackground.BEFORE)
-                            .getWidth(), RelSide.BEFORE, true, false, this));
+                                .getWidth(),
+                        RelSide.BEFORE, isFirst, false, this));
             }
             if (borderAndPadding.getPaddingBefore(false, this) > 0) {
                 returnList.add(new PaddingElement(
                         getAuxiliaryPosition(),
                         borderAndPadding.getPaddingLengthProperty(
                                 CommonBorderPaddingBackground.BEFORE), 
-                                RelSide.BEFORE, true, false, this));
+                        RelSide.BEFORE, isFirst, false, this));
             }
             //TODO Handle conditionality
             /*
@@ -889,7 +889,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
      * Creates Knuth elements for after border padding and adds them to the return list.
      * @param returnList return list to add the additional elements to
      */
-    protected void addKnuthElementsForBorderPaddingAfter(LinkedList returnList) {
+    protected void addKnuthElementsForBorderPaddingAfter(LinkedList returnList, boolean isLast) {
         //Border and Padding (after)
         CommonBorderPaddingBackground borderAndPadding = getBorderPaddingBackground();
         if (borderAndPadding != null) {
@@ -897,13 +897,15 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
                 returnList.add(new PaddingElement(
                         getAuxiliaryPosition(),
                         borderAndPadding.getPaddingLengthProperty(
-                                CommonBorderPaddingBackground.AFTER), RelSide.AFTER, false, true, this));
+                                CommonBorderPaddingBackground.AFTER),
+                        RelSide.AFTER, false, isLast, this));
             }
             if (borderAndPadding.getBorderAfterWidth(false) > 0) {
                 returnList.add(new BorderElement(
                         getAuxiliaryPosition(), 
                         borderAndPadding.getBorderInfo(CommonBorderPaddingBackground.AFTER)
-                            .getWidth(), RelSide.AFTER, false, true, this));
+                                .getWidth(),
+                        RelSide.AFTER, false, isLast, this));
             }
             //TODO Handle conditionality
             /*
index 62f5e2af6b2eeb4c574f64833b687ad05707a6f2..3ec814bd2faf961059bda98232faa222a7bf5b56 100644 (file)
@@ -132,7 +132,7 @@ public class FlowLayoutManager extends BlockStackingLayoutManager
                 }
                 if (returnedList.size() > 0) {
                     returnList.addAll(returnedList);
-                    if (ElementListUtils.endsWithForcedBreak(returnedList)) {
+                    if (ElementListUtils.endsWithForcedBreak(returnList)) {
                         // a descendant of this flow has break-after
                         SpaceResolver.resolveElementList(returnList);
                         return returnList;
index 77f30f1c5c42c248cd0f61fd0f1597ca5c0de662..15a61a182ec645d9c609d8e903746a9686c95583 100644 (file)
@@ -53,9 +53,19 @@ public class KnuthSequence extends ArrayList {
     }
 
     /**
+     * Finalizes a Knuth sequence.
      * @return a finalized sequence.
      */
     public KnuthSequence endSequence() {
+        return endSequence(null);
+    }
+    
+    /**
+     * Finalizes a Knuth sequence.
+     * @param breakPosition a Position instance for the last penalty (may be null)
+     * @return a finalized sequence.
+     */
+    public KnuthSequence endSequence(Position breakPosition) {
         // remove glue and penalty item at the end of the paragraph
         while (this.size() > ignoreAtStart
                && !((KnuthElement)this.get(this.size() - 1)).isBox()) {
@@ -66,7 +76,7 @@ public class KnuthSequence extends ArrayList {
             // and the forced break
             this.add(new KnuthPenalty(0, KnuthElement.INFINITE, false, null, false));
             this.add(new KnuthGlue(0, 10000000, 0, null, false));
-            this.add(new KnuthPenalty(0, -KnuthElement.INFINITE, false, null, false));
+            this.add(new KnuthPenalty(0, -KnuthElement.INFINITE, false, breakPosition, false));
             ignoreAtEnd = 3;
             return this;
         } else {
index 49e4161197cccffd853b55e8c5e559dec57e8f14..45e9990ea2979204781907e42a4a5c3e7e267c91 100644 (file)
@@ -18,6 +18,7 @@
 
 package org.apache.fop.layoutmgr;
 
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.LinkedList;
 import java.util.List;
@@ -74,9 +75,9 @@ public class SpaceResolver {
         int i = 0;
         ListIterator iter;
         if (first != null) {
-            iter = first.listIterator(first.size());
-            while (iter.hasPrevious()) {
-                noBreak[i] = (UnresolvedListElementWithLength)iter.previous();
+            iter = first.listIterator();
+            while (iter.hasNext()) {
+                noBreak[i] = (UnresolvedListElementWithLength)iter.next();
                 noBreakLengths[i] = noBreak[i].getLength();
                 i++;
             }
@@ -152,15 +153,21 @@ public class SpaceResolver {
     }
     
     private void removeConditionalBorderAndPadding(
-                UnresolvedListElement[] elems, MinOptMax[] lengths) {
+                UnresolvedListElement[] elems, MinOptMax[] lengths, boolean reverse) {
         for (int i = 0; i < elems.length; i++) {
-            if (elems[i] instanceof BorderOrPaddingElement) {
-                BorderOrPaddingElement bop = (BorderOrPaddingElement)elems[i];
+            int effIndex;
+            if (reverse) {
+                effIndex = elems.length - 1 - i;
+            } else {
+                effIndex = i;
+            }
+            if (elems[effIndex] instanceof BorderOrPaddingElement) {
+                BorderOrPaddingElement bop = (BorderOrPaddingElement)elems[effIndex];
                 if (bop.isConditional() && !(bop.isFirst() || bop.isLast())) {
                     if (log.isDebugEnabled()) {
                         log.debug("Nulling conditional element: " + bop);
                     }
-                    lengths[i] = null;
+                    lengths[effIndex] = null;
                 }
             }
         }
@@ -169,21 +176,28 @@ public class SpaceResolver {
         }
     }
     
-    private void performSpaceResolutionRule1(UnresolvedListElement[] elems, MinOptMax[] lengths) {
+    private void performSpaceResolutionRule1(UnresolvedListElement[] elems, MinOptMax[] lengths,
+                    boolean reverse) {
         for (int i = 0; i < elems.length; i++) {
-            if (lengths[i] == null) {
+            int effIndex;
+            if (reverse) {
+                effIndex = elems.length - 1 - i;
+            } else {
+                effIndex = i;
+            }
+            if (lengths[effIndex] == null) {
                 //Zeroed border or padding doesn't create a fence
                 continue;
-            } else if (elems[i] instanceof BorderOrPaddingElement) {
+            } else if (elems[effIndex] instanceof BorderOrPaddingElement) {
                 //Border or padding form fences!
                 break;
-            } else if (!elems[i].isConditional()) {
+            } else if (!elems[effIndex].isConditional()) {
                 break;
             }
             if (log.isDebugEnabled()) {
-                log.debug("Nulling conditional element using 4.3.1, rule 1: " + elems[i]);
+                log.debug("Nulling conditional element using 4.3.1, rule 1: " + elems[effIndex]);
             }
-            lengths[i] = null;
+            lengths[effIndex] = null;
         }
         if (log.isTraceEnabled() && elems.length > 0) {
             log.trace("-->Resulting list: " + toString(elems, lengths));
@@ -341,24 +355,55 @@ public class SpaceResolver {
         }
     }
     
+    private boolean hasFirstPart() {
+        return firstPart != null && firstPart.length > 0;
+    }
+    
+    private boolean hasSecondPart() {
+        return secondPart != null && secondPart.length > 0;
+    }
+    
     private void resolve() {
         if (breakPoss != null) {
-            if (firstPart != null) {
-                removeConditionalBorderAndPadding(firstPart, firstPartLengths);
-                performSpaceResolutionRule1(firstPart, firstPartLengths);
+            if (hasFirstPart()) {
+                removeConditionalBorderAndPadding(firstPart, firstPartLengths, true);
+                performSpaceResolutionRule1(firstPart, firstPartLengths, true);
                 performSpaceResolutionRules2to3(firstPart, firstPartLengths);
             }
-            if (secondPart != null) {
-                removeConditionalBorderAndPadding(secondPart, secondPartLengths);
-                performSpaceResolutionRule1(secondPart, secondPartLengths);
+            if (hasSecondPart()) {
+                removeConditionalBorderAndPadding(secondPart, secondPartLengths, false);
+                performSpaceResolutionRule1(secondPart, secondPartLengths, false);
                 performSpaceResolutionRules2to3(secondPart, secondPartLengths);
             }
             if (noBreak != null) {
                 performSpaceResolutionRules2to3(noBreak, noBreakLengths);
             }
         } else {
-            if (isFirst || isLast) {
-                performSpaceResolutionRule1(secondPart, secondPartLengths);
+            if (isFirst) {
+                removeConditionalBorderAndPadding(secondPart, secondPartLengths, false);
+                performSpaceResolutionRule1(secondPart, secondPartLengths, false);
+            }
+            if (isLast) {
+                removeConditionalBorderAndPadding(firstPart, firstPartLengths, true);
+                performSpaceResolutionRule1(firstPart, firstPartLengths, true);
+            }
+            
+            if (hasFirstPart()) {
+                //Now that we've handled isFirst/isLast conditions, we need to look at the
+                //active part in its normal order so swap it back.
+                log.trace("Swapping first and second parts.");
+                UnresolvedListElementWithLength[] tempList;
+                MinOptMax[] tempLengths;
+                tempList = secondPart;
+                tempLengths = secondPartLengths;
+                secondPart = firstPart;
+                secondPartLengths = firstPartLengths;
+                firstPart = tempList;
+                firstPartLengths = tempLengths;
+                if (hasFirstPart()) {
+                    throw new IllegalStateException("Didn't expect more than one parts in a"
+                            + "no-break condition.");
+                }
             }
             performSpaceResolutionRules2to3(secondPart, secondPartLengths);
         }
@@ -396,7 +441,7 @@ public class SpaceResolver {
         glue2shrink -= glue1.opt - glue1.min;
         glue2shrink -= glue3.opt - glue3.min;
         
-        
+        boolean hasPrecedingNonBlock = false;
         if (log.isDebugEnabled()) {
             log.debug("noBreakLength=" + noBreakLength 
                     + ", glue1=" + glue1 
@@ -439,8 +484,9 @@ public class SpaceResolver {
                     false, (Position)null, true));
             iter.add(new KnuthGlue(glue3.opt, glue3.max - glue3.opt, glue3.opt - glue3.min, 
                     (Position)null, true));
+            hasPrecedingNonBlock = true;
         }
-        if (isLast) {
+        if (isLast && hasPrecedingNonBlock) {
             //Otherwise, the preceding penalty and glue will be cut off
             iter.add(new KnuthBox(0, (Position)null, true));
         }
@@ -494,9 +540,7 @@ public class SpaceResolver {
                 }
             } else {
                 for (int i = 0; i < resolver.noBreak.length; i++) {
-                    if (resolver.noBreak[i] instanceof SpaceElement) {
-                        resolver.noBreak[i].notifyLayoutManager(resolver.noBreakLengths[i]);
-                    }
+                    resolver.noBreak[i].notifyLayoutManager(resolver.noBreakLengths[i]);
                 }
             }
         }
@@ -550,9 +594,7 @@ public class SpaceResolver {
                 throw new IllegalStateException("Only applicable to no-break situations");
             }
             for (int i = 0; i < resolver.secondPart.length; i++) {
-                if (resolver.secondPart[i] instanceof SpaceElement) {
-                    resolver.secondPart[i].notifyLayoutManager(resolver.secondPartLengths[i]);
-                }
+                resolver.secondPart[i].notifyLayoutManager(resolver.secondPartLengths[i]);
             }
         }
         
@@ -619,18 +661,14 @@ public class SpaceResolver {
                     }
                 }
                 //last = !iter.hasNext();
-                if (breakPoss == null & unresolvedSecond.size() == 0) {
+                if (breakPoss == null && unresolvedSecond.size() == 0 && !last) {
+                    log.trace("Swap first and second parts in no-break condition,"
+                            + " second part is empty.");
                     //The first list is reversed, so swap if this shouldn't happen
                     List swapList = unresolvedSecond;
                     unresolvedSecond = unresolvedFirst;
                     unresolvedFirst = swapList;
                 }
-                //Need to reverse the order of the first part
-                //From here on further down, the first part in the unresolved list is 
-                //always the one nearest to the break.
-                if (unresolvedFirst.size() > 0) {
-                    Collections.reverse(unresolvedFirst);
-                }
                 
                 log.debug("----start space resolution (first=" + first + ", last=" + last + ")...");
                 SpaceResolver resolver = new SpaceResolver(
index e7478fe7538bb431d0c8c698d6b8417f5c039068..c8cedb0bbe1c6f0e596a1f660ffb03e7b26d30bd 100644 (file)
@@ -184,10 +184,7 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager
         
         LinkedList returnList = new LinkedList();
         
-        if (!bSpaceBeforeServed) {
-            addKnuthElementsForSpaceBefore(returnList, alignment);
-            bSpaceBeforeServed = true;
-        }
+        addKnuthElementsForSpaceBefore(returnList, alignment);
         
         //Spaces, border and padding to be repeated at each break
         addPendingMarks(context);
index 4d551743c2b8371efb667ce220942eebcc38277f..f805fe9c75e3c80b8569f9ff1cae9e1328aa2944 100644 (file)
@@ -181,7 +181,8 @@ public class TableLayoutManager extends BlockStackingLayoutManager
         addKnuthElementsForSpaceBefore(returnList, alignment);
         
         if (getTable().isSeparateBorderModel()) {
-            addKnuthElementsForBorderPaddingBefore(returnList);
+            addKnuthElementsForBorderPaddingBefore(returnList, !firstVisibleMarkServed);
+            firstVisibleMarkServed = true;
         }
 
         //Spaces, border and padding to be repeated at each break
@@ -283,7 +284,7 @@ public class TableLayoutManager extends BlockStackingLayoutManager
         }
         wrapPositionElements(contentList, returnList);
         if (getTable().isSeparateBorderModel()) {
-            addKnuthElementsForBorderPaddingAfter(returnList);
+            addKnuthElementsForBorderPaddingAfter(returnList, true);
         }
         addKnuthElementsForSpaceAfter(returnList, alignment);
         addKnuthElementsForBreakAfter(returnList, context);
index ed4615b9a10f0ad5dea5d0ee7f77d1b4c5e7b3a4..37b7b87c2ba46174fee499d2ddb0814c2e35124a 100644 (file)
@@ -154,8 +154,6 @@ Two blocks, testing conditionality="discard".
       
       <box w="0"/> <!-- SpaceHandlingPosition-bearing helper box -->
       
-      <box w="0"/> <!-- This is used to make sure the preceding glue is not cut off -->
-      
       <skip>3</skip>
     </element-list>
   </checks>
index 14944f23239795254c5a3c1e7c32b89d362834b4..0676277f9a7150d2357dea23ad80e18ea93fd83b 100644 (file)
@@ -150,8 +150,6 @@ Two blocks, testing conditionality="discard".
       
       <box w="0"/> <!-- SpaceHandlingPosition-bearing helper box -->
       
-      <box w="0"/> <!-- This is used to make sure the preceding glue is not cut off -->
-      
       <skip>3</skip>
     </element-list>
   </checks>
diff --git a/test/layoutengine/testcases/block_space-before_space-after_9.xml b/test/layoutengine/testcases/block_space-before_space-after_9.xml
new file mode 100644 (file)
index 0000000..4df4591
--- /dev/null
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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$ -->
+<testcase>
+  <info>
+    <p>
+      This test checks if the isLast case is properly handled. In this case the part list has to be 
+      reversed to do the conditionals removal, but then has to be reversed again to its natural order 
+      so space resolution rules 2 and 3 are properly performed.
+    </p>
+  </info>
+  <fo>
+    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:svg="http://www.w3.org/2000/svg">
+      <fo:layout-master-set>
+        <fo:simple-page-master master-name="normal" page-width="5in" page-height="1in">
+          <fo:region-body/>
+        </fo:simple-page-master>
+      </fo:layout-master-set>
+      <fo:page-sequence master-reference="normal">
+        <fo:flow flow-name="xsl-region-body">
+          <fo:block space-before="11pt" space-after="11pt">
+            <fo:block space-before="12pt" space-after="12pt">
+              <fo:block space-before="13pt" space-after="13pt" border="solid 1pt">
+                Apache FOP!
+              </fo:block>
+            </fo:block>
+          </fo:block>
+        </fo:flow>
+      </fo:page-sequence>
+    </fo:root>
+  </fo>
+  <checks>
+    <element-list category="breaker">
+      <box w="0"/>
+      <penalty w="0" p="INF"/>
+      <glue w="1000"/>
+      
+      <box w="14400"/>
+      
+      <box w="0"/>
+      <penalty w="0" p="INF"/>
+      <glue w="1000"/>
+      
+      <box w="0"/>
+      <skip>3</skip>
+    </element-list>
+    <true xpath="not(boolean(//flow/block[1]/@space-before))"/>
+    <true xpath="not(boolean(//flow/block[1]/@space-after))"/>
+    <true xpath="not(boolean(//flow/block[1]/block[1]/@space-before))"/>
+    <true xpath="not(boolean(//flow/block[1]/block[1]/@space-after))"/>
+    <true xpath="not(boolean(//flow/block[1]/block[1]/block[1]/@space-before))"/>
+    <true xpath="not(boolean(//flow/block[1]/block[1]/block[1]/@space-after))"/>
+    <eval expected="1000 1000 1000 1000" xpath="//flow/block[1]/block[1]/block[1]/@bap"/>
+  </checks>
+</testcase>
diff --git a/test/layoutengine/testcases/block_space-before_space-after_9a.xml b/test/layoutengine/testcases/block_space-before_space-after_9a.xml
new file mode 100644 (file)
index 0000000..07f3783
--- /dev/null
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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$ -->
+<testcase>
+  <info>
+    <p>
+      This test checks if the isLast case is properly handled. In this case the part list has to be 
+      reversed to do the conditionals removal, but then has to be reversed again to its natural order 
+      so space resolution rules 2 and 3 are properly performed.
+    </p>
+  </info>
+  <fo>
+    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:svg="http://www.w3.org/2000/svg">
+      <fo:layout-master-set>
+        <fo:simple-page-master master-name="normal" page-width="5in" page-height="1in">
+          <fo:region-body/>
+        </fo:simple-page-master>
+      </fo:layout-master-set>
+      <fo:page-sequence master-reference="normal">
+        <fo:flow flow-name="xsl-region-body">
+          <fo:block space-before="11pt" space-after="11pt">
+            <fo:block space-before="12pt" space-after="12pt">
+              <fo:block space-before="13pt" space-after="13pt" border="solid 1pt">
+                Apache FOP!
+                <fo:block break-before="page"/>
+                Apache FOP!!!
+              </fo:block>
+            </fo:block>
+          </fo:block>
+        </fo:flow>
+      </fo:page-sequence>
+    </fo:root>
+  </fo>
+  <checks>
+    <element-list category="breaker" index="0">
+      <box w="0"/> <!-- SpaceHandlingPosition -->
+      <penalty w="0" p="INF"/>
+      <glue w="1000"/>
+      
+      <box w="14400"/>
+      
+      <skip>3</skip> <!-- the last of the three holds a SpaceHandlingBreakPosition -->
+    </element-list>
+    <element-list category="breaker" index="1">
+      <box w="0"/> <!-- SpaceHandlingPosition -->
+      
+      <box w="0"/> <!-- empty block used to cause the break-before -->
+      <penalty w="0" p="0"/>
+      
+      <box w="14400"/>
+      
+      <box w="0"/>
+      <penalty w="0" p="INF"/>
+      <glue w="1000"/>
+      <box w="0"/> <!-- SpaceHandlingPosition -->
+
+      <skip>3</skip>
+    </element-list>
+    
+    <true xpath="not(boolean(//pageViewport[@nr=1]/page/regionViewport/regionBody/mainReference/span/flow/block[1]/@space-before))"/>
+    <true xpath="not(boolean(//pageViewport[@nr=1]/page/regionViewport/regionBody/mainReference/span/flow/block[1]/@space-after))"/>
+    <true xpath="not(boolean(//pageViewport[@nr=1]/page/regionViewport/regionBody/mainReference/span/flow/block[1]/block[1]/@space-before))"/>
+    <true xpath="not(boolean(//pageViewport[@nr=1]/page/regionViewport/regionBody/mainReference/span/flow/block[1]/block[1]/@space-after))"/>
+    <true xpath="not(boolean(//pageViewport[@nr=1]/page/regionViewport/regionBody/mainReference/span/flow/block[1]/block[1]/block[1]/@space-before))"/>
+    <true xpath="not(boolean(//pageViewport[@nr=1]/page/regionViewport/regionBody/mainReference/span/flow/block[1]/block[1]/block[1]/@space-after))"/>
+    <eval expected="1000 1000 1000 0" xpath="//pageViewport[@nr=1]/page/regionViewport/regionBody/mainReference/span/flow/block[1]/block[1]/block[1]/@bap"/>
+
+    <true xpath="not(boolean(//pageViewport[@nr=2]/page/regionViewport/regionBody/mainReference/span/flow/block[1]/@space-before))"/>
+    <true xpath="not(boolean(//pageViewport[@nr=2]/page/regionViewport/regionBody/mainReference/span/flow/block[1]/@space-after))"/>
+    <true xpath="not(boolean(//pageViewport[@nr=2]/page/regionViewport/regionBody/mainReference/span/flow/block[1]/block[1]/@space-before))"/>
+    <true xpath="not(boolean(//pageViewport[@nr=2]/page/regionViewport/regionBody/mainReference/span/flow/block[1]/block[1]/@space-after))"/>
+    <true xpath="not(boolean(//pageViewport[@nr=2]/page/regionViewport/regionBody/mainReference/span/flow/block[1]/block[1]/block[1]/@space-before))"/>
+    <true xpath="not(boolean(//pageViewport[@nr=2]/page/regionViewport/regionBody/mainReference/span/flow/block[1]/block[1]/block[1]/@space-after))"/>
+    <eval expected="1000 1000 0 1000" xpath="//pageViewport[@nr=2]/page/regionViewport/regionBody/mainReference/span/flow/block[1]/block[1]/block[1]/@bap"/>
+  </checks>
+</testcase>
index 4c77cc01abd1346617cc27b57446cb8e5edcdf30..82af9d20d0e636d93dfd109d6b4cef846a3c4fb8 100644 (file)
@@ -196,8 +196,6 @@ Two blocks, testing conditionality="discard".
       
       <box w="0"/> <!-- SpaceHandlingPosition-bearing helper box -->
       
-      <box w="0"/> <!-- This is used to make sure the preceding glue is not cut off -->
-      
       <skip>3</skip>
     </element-list>
 
index a7e8af0ec13b1bc08ea788800d7e007221788366..912fa6e1690de2270867ee454699aee348854cf3 100644 (file)
@@ -52,7 +52,6 @@
       <box w="14400"/>
       
       <box w="0"/> <!-- SpaceHandlingPosition -->
-      <box w="0"/>
       <skip>3</skip>
     </element-list>
 
index 2d3041041a7651043bd70fd59280641fa41ba254..430d8689af822cc87eb0f8134b4983347cee9965 100644 (file)
@@ -178,8 +178,6 @@ Two blocks, testing conditionality="discard".
       
       <box w="0"/> <!-- SpaceHandlingPosition-bearing helper box -->
       
-      <box w="0"/> <!-- This is used to make sure the preceding glue is not cut off -->
-      
       <skip>3</skip>
     </element-list>