]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Extract conditionals notification into a public static method in SpaceResolver.
authorJeremias Maerki <jeremias@apache.org>
Fri, 14 Oct 2005 11:35:58 +0000 (11:35 +0000)
committerJeremias Maerki <jeremias@apache.org>
Fri, 14 Oct 2005 11:35:58 +0000 (11:35 +0000)
Add conditionals notification for content nestes in list-items.

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

src/java/org/apache/fop/layoutmgr/AbstractBreaker.java
src/java/org/apache/fop/layoutmgr/SpaceResolver.java
src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java
test/layoutengine/disabled-testcases.txt

index 991b363f857c1978d5f8a829c2ef9bc1f3952528..9c82728e505e57c87a2c29a65d0c4d36f93fe4b9 100644 (file)
@@ -379,7 +379,7 @@ public abstract class AbstractBreaker {
                 /* *** *** non-standard extension *** *** */
 
                 // Handle SpaceHandling(Break)Positions, see SpaceResolver!
-                performConditionalsNotification(effectiveList, 
+                SpaceResolver.performConditionalsNotification(effectiveList, 
                         startElementIndex, endElementIndex, lastBreak);
                 
                 // Add areas now!
@@ -404,43 +404,6 @@ public abstract class AbstractBreaker {
      * @param endElementIndex end index of the part
      * @param lastBreak index of the last break element
      */
-    private void performConditionalsNotification(BlockSequence effectiveList, 
-            int startElementIndex, int endElementIndex, int lastBreak) {
-        KnuthElement el = null;
-        if (lastBreak > 0) {
-            el = effectiveList.getElement(lastBreak);
-        }
-        SpaceResolver.SpaceHandlingBreakPosition beforeBreak = null;
-        SpaceResolver.SpaceHandlingBreakPosition afterBreak = null;
-        if (el != null && el.isPenalty()) {
-            Position pos = el.getPosition();
-            if (pos instanceof SpaceResolver.SpaceHandlingBreakPosition) {
-                beforeBreak = (SpaceResolver.SpaceHandlingBreakPosition)pos; 
-                beforeBreak.notifyBreakSituation(true, RelSide.BEFORE);
-            }
-        }
-        el = effectiveList.getElement(endElementIndex);
-        if (el != null && el.isPenalty()) {
-            Position pos = el.getPosition();
-            if (pos instanceof SpaceResolver.SpaceHandlingBreakPosition) {
-                afterBreak = (SpaceResolver.SpaceHandlingBreakPosition)pos; 
-                afterBreak.notifyBreakSituation(true, RelSide.AFTER);
-            }
-        }
-        for (int i = startElementIndex; i <= endElementIndex; i++) {
-            Position pos = effectiveList.getElement(i).getPosition();
-            if (pos instanceof SpaceResolver.SpaceHandlingPosition) {
-                ((SpaceResolver.SpaceHandlingPosition)pos).notifySpaceSituation();
-            } else if (pos instanceof SpaceResolver.SpaceHandlingBreakPosition) {
-                SpaceResolver.SpaceHandlingBreakPosition noBreak;
-                noBreak = (SpaceResolver.SpaceHandlingBreakPosition)pos;
-                if (noBreak != beforeBreak && noBreak != afterBreak) {
-                    noBreak.notifyBreakSituation(false, null);
-                }
-            }
-        }
-    }
-    
     /**
      * Handles span changes reported through the <code>LayoutContext</code>. 
      * Only used by the PSLM and called by <code>getNextBlockList()</code>.
index 4faa92bdec073a19a39b078b1de0b9b527459328..9611ec57c8f8f41c3f2a1ccf46467f150e15bd2f 100644 (file)
@@ -631,5 +631,53 @@ public class SpaceResolver {
             first = false;
         }
     }
+    
+    /**
+     * Inspects an effective element list and notifies all layout managers about the state of
+     * the spaces and conditional lengths.
+     * @param effectiveList the effective element list
+     * @param startElementIndex index of the first element in the part to be processed
+     * @param endElementIndex index of the last element in the part to be processed
+     * @param lastBreak index of the the break possibility just before this part (used to
+     *                  identify a break condition, lastBreak <= 0 represents a no-break condition)
+     */
+    public static void performConditionalsNotification(List effectiveList, 
+            int startElementIndex, int endElementIndex, int lastBreak) {
+        KnuthElement el = null;
+        if (lastBreak > 0) {
+            el = (KnuthElement)effectiveList.get(lastBreak);
+        }
+        SpaceResolver.SpaceHandlingBreakPosition beforeBreak = null;
+        SpaceResolver.SpaceHandlingBreakPosition afterBreak = null;
+        if (el != null && el.isPenalty()) {
+            Position pos = el.getPosition();
+            if (pos instanceof SpaceResolver.SpaceHandlingBreakPosition) {
+                beforeBreak = (SpaceResolver.SpaceHandlingBreakPosition)pos; 
+                beforeBreak.notifyBreakSituation(true, RelSide.BEFORE);
+            }
+        }
+        el = (KnuthElement)effectiveList.get(endElementIndex);
+        if (el != null && el.isPenalty()) {
+            Position pos = el.getPosition();
+            if (pos instanceof SpaceResolver.SpaceHandlingBreakPosition) {
+                afterBreak = (SpaceResolver.SpaceHandlingBreakPosition)pos; 
+                afterBreak.notifyBreakSituation(true, RelSide.AFTER);
+            }
+        }
+        for (int i = startElementIndex; i <= endElementIndex; i++) {
+            Position pos = ((KnuthElement)effectiveList.get(i)).getPosition();
+            if (pos instanceof SpaceResolver.SpaceHandlingPosition) {
+                ((SpaceResolver.SpaceHandlingPosition)pos).notifySpaceSituation();
+            } else if (pos instanceof SpaceResolver.SpaceHandlingBreakPosition) {
+                SpaceResolver.SpaceHandlingBreakPosition noBreak;
+                noBreak = (SpaceResolver.SpaceHandlingBreakPosition)pos;
+                if (noBreak != beforeBreak && noBreak != afterBreak) {
+                    noBreak.notifyBreakSituation(false, null);
+                }
+            }
+        }
+    }
+    
+    
 
 }
index 184b6f01de275ef05f75c95161418483d86960f0..e8c2057ca5bf9c741192dc8ea005cb740b4ef543 100644 (file)
@@ -470,6 +470,31 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager
         int bodyFirstIndex = ((ListItemPosition) positionList.getFirst()).getBodyFirstIndex();
         int bodyLastIndex = ((ListItemPosition) positionList.getLast()).getBodyLastIndex();
 
+        int lastBreak;
+        //Determine last break if any
+        lastBreak = labelFirstIndex - 1;
+        while (lastBreak >= 0) {
+            KnuthElement el = (KnuthElement)labelList.get(lastBreak);
+            if (el.isPenalty() && el.getP() < KnuthElement.INFINITE) {
+                break;
+            }
+            lastBreak--;
+        }
+        SpaceResolver.performConditionalsNotification(labelList, 
+                labelFirstIndex, labelLastIndex, lastBreak);
+
+        //Determine last break if any
+        lastBreak = bodyFirstIndex - 1;
+        while (lastBreak >= 0) {
+            KnuthElement el = (KnuthElement)bodyList.get(lastBreak);
+            if (el.isPenalty() && el.getP() < KnuthElement.INFINITE) {
+                break;
+            }
+            lastBreak--;
+        }
+        SpaceResolver.performConditionalsNotification(bodyList, 
+                bodyFirstIndex, bodyLastIndex, lastBreak);
+        
         // add label areas
         if (labelFirstIndex <= labelLastIndex) {
             KnuthPossPosIter labelIter = new KnuthPossPosIter(labelList, 
index b61e99f2c410f02e9ad46254cf22d0623b03277e..71c7cb857a7952dc6466e0fbfda17b610fbb8f5a 100644 (file)
@@ -17,7 +17,6 @@ inline_word-spacing_text-align_justify.xml
 leader-alignment.xml
 list-block_keep-with-previous.xml
 list-item_block_keep-with-previous.xml
-list-item_space-before_space-after_3.xml
 page-breaking_4.xml
 page-breaking_6.xml
 page-height_indefinite_simple.xml