]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Fixes for a few minor problems in certain special cases.
authorJeremias Maerki <jeremias@apache.org>
Mon, 23 May 2005 07:43:05 +0000 (07:43 +0000)
committerJeremias Maerki <jeremias@apache.org>
Mon, 23 May 2005 07:43:05 +0000 (07:43 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@198666 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java
src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java
src/java/org/apache/fop/layoutmgr/table/TableStepper.java

index eae8a537f035d79a3abe864482d50f4199d845fd..79810d12dde18df0e689d42b8794ea497a703584 100644 (file)
@@ -196,10 +196,12 @@ public class TableContentLayoutManager {
                         returnList, rowGroup);
         }
         
-        //Remove last penalty
-        KnuthElement last = (KnuthElement)returnList.getLast();
-        if (last.isPenalty() && last.getP() == 0) {
-            returnList.removeLast();
+        if (returnList.size() > 0) {
+            //Remove last penalty
+            KnuthElement last = (KnuthElement)returnList.getLast();
+            if (last.isPenalty() && last.getP() == 0) {
+                returnList.removeLast();
+            }
         }
         return returnList;
     }
index 317a68447bf1e5ab08ef70b515e0325ff33efacc..533a5f8099e5c2895cf94c5d107bffce3113798b 100644 (file)
@@ -184,56 +184,52 @@ public class TableLayoutManager extends BlockStackingLayoutManager
         returnedList = contentLM.getNextKnuthElements(childLC, alignment);
         log.debug(returnedList);
         
-            if (returnedList.size() == 1
-                    && ((KnuthElement) returnedList.getFirst()).isPenalty()
-                    && ((KnuthPenalty) returnedList.getFirst()).getP() == -KnuthElement.INFINITE) {
-                // a descendant of this block has break-before
-                if (returnList.size() == 0) {
-                    // the first child (or its first child ...) has
-                    // break-before;
-                    // all this block, including space before, will be put in
-                    // the
-                    // following page
-                    //FIX ME
-                    //bSpaceBeforeServed = false;
+        if (returnedList.size() == 1
+                && ((KnuthElement) returnedList.getFirst()).isPenalty()
+                && ((KnuthPenalty) returnedList.getFirst()).getP() == -KnuthElement.INFINITE) {
+            // a descendant of this block has break-before
+            if (returnList.size() == 0) {
+                // the first child (or its first child ...) has
+                // break-before;
+                // all this block, including space before, will be put in
+                // the
+                // following page
+                //FIX ME
+                //bSpaceBeforeServed = false;
+            }
+            contentList.addAll(returnedList);
+
+            // "wrap" the Position inside each element
+            // moving the elements from contentList to returnList
+            returnedList = new LinkedList();
+            wrapPositionElements(contentList, returnList);
+
+            return returnList;
+        } else {
+            /*
+            if (prevLM != null) {
+                // there is a block handled by prevLM
+                // before the one handled by curLM
+                if (mustKeepTogether() 
+                        || prevLM.mustKeepWithNext()
+                        || curLM.mustKeepWithPrevious()) {
+                    // add an infinite penalty to forbid a break between
+                    // blocks
+                    contentList.add(new KnuthPenalty(0,
+                            KnuthElement.INFINITE, false,
+                            new Position(this), false));
+                } else if (!((KnuthElement) contentList.getLast()).isGlue()) {
+                    // add a null penalty to allow a break between blocks
+                    contentList.add(new KnuthPenalty(0, 0, false,
+                            new Position(this), false));
+                } else {
+                    // the last element in contentList is a glue;
+                    // it is a feasible breakpoint, there is no need to add
+                    // a penalty
                 }
-                contentList.addAll(returnedList);
-
-                // "wrap" the Position inside each element
-                // moving the elements from contentList to returnList
-                returnedList = new LinkedList();
-                wrapPositionElements(contentList, returnList);
-
-                return returnList;
-            } else {
-                /*
-                if (prevLM != null) {
-                    // there is a block handled by prevLM
-                    // before the one handled by curLM
-                    if (mustKeepTogether() 
-                            || prevLM.mustKeepWithNext()
-                            || curLM.mustKeepWithPrevious()) {
-                        // add an infinite penalty to forbid a break between
-                        // blocks
-                        contentList.add(new KnuthPenalty(0,
-                                KnuthElement.INFINITE, false,
-                                new Position(this), false));
-                    } else if (!((KnuthElement) contentList.getLast()).isGlue()) {
-                        // add a null penalty to allow a break between blocks
-                        contentList.add(new KnuthPenalty(0, 0, false,
-                                new Position(this), false));
-                    } else {
-                        // the last element in contentList is a glue;
-                        // it is a feasible breakpoint, there is no need to add
-                        // a penalty
-                    }
-                }*/
-                contentList.addAll(returnedList);
-                /*
-                if (returnedList.size() == 0) {
-                    //Avoid NoSuchElementException below (happens with empty blocks)
-                    continue;
-                }*/
+            }*/
+            contentList.addAll(returnedList);
+            if (returnedList.size() > 0) {
                 if (((KnuthElement) returnedList.getLast()).isPenalty()
                         && ((KnuthPenalty) returnedList.getLast()).getP() == -KnuthElement.INFINITE) {
                     // a descendant of this block has break-after
@@ -248,7 +244,7 @@ public class TableLayoutManager extends BlockStackingLayoutManager
 
                     return returnList;
                 }
-            
+            }
         }
         wrapPositionElements(contentList, returnList);
         setFinished(true);
index 9600053abb82f97a347c85078b8a146f7ebe6cb5..67427d169a49b7cf10b5fcf035f5852b6a85685f 100644 (file)
@@ -185,7 +185,7 @@ public class TableStepper {
         int step;
         int addedBoxLen = 0;
         LinkedList returnList = new LinkedList();
-        while ((step = getNextStep(laststep)) > 0) {
+        while ((step = getNextStep(laststep)) >= 0) {
             if (rowBacktrackForLastStep) {
                 //Even though we've already switched to the next row, we have to 
                 //calculate as if we were still on the previous row
@@ -340,7 +340,7 @@ public class TableStepper {
             log.debug("borders before=" + borderBefore[i] + " after=" + borderAfter[i]);
         }
         if (seqCount == 0) {
-            return 0;
+            return -1;
         }
 
         //Determine smallest possible step