]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Fixed the NPE for fo:title in FOText.createBlockPointers by returning
authorSimon Pepping <spepping@apache.org>
Wed, 22 Dec 2004 18:22:35 +0000 (18:22 +0000)
committerSimon Pepping <spepping@apache.org>
Wed, 22 Dec 2004 18:22:35 +0000 (18:22 +0000)
early.

Fixed the absence of output for fo:title: In ContentLM.fillArea, replace
curLM.getNextBreakPoss with getNextKnuthElements, BreakPossIter with
KnuthPossIter. Copied the line parameter calculations from
LineLM.makeLineBreakPosition. This is only a rough patch: leaders,
external graphics, page numbers cause null pointer exceptions.

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

src/java/org/apache/fop/fo/FOText.java
src/java/org/apache/fop/layoutmgr/ContentLayoutManager.java

index 9a2faaa104ed3bad32cce0b9154d1e945e9de8b0..7c477dfb6a164563ca9bf94b20d9b8a1848c33cc 100644 (file)
@@ -197,10 +197,12 @@ public class FOText extends FONode {
         while (this.ancestorBlock == null) {
             ancestorFONode = ancestorFONode.parent;
             Class myclass = ancestorFONode.getClass();
-            if (ancestorFONode instanceof Root) {
+            if (ancestorFONode instanceof org.apache.fop.fo.pagination.Title) {
+                return;
+            } else if (ancestorFONode instanceof Root) {
                 getLogger().warn("Unexpected: fo:text with no fo:block ancestor");
-            }
-            if (ancestorFONode instanceof Block) {
+                return;
+            } else if (ancestorFONode instanceof Block) {
                 this.ancestorBlock = (Block)ancestorFONode;
             }
         }
index d8eb3fbb08164f6b8faf65c381c3f191471a84cf..adc25fd7463b0d9a3c1ee8749204958dfc7fe493 100644 (file)
@@ -18,8 +18,9 @@
 
 package org.apache.fop.layoutmgr;
 
-import org.apache.fop.fo.FObj;
 import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.fo.FObj;
+import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.flow.Marker;
 import org.apache.fop.area.Area;
 import org.apache.fop.area.inline.InlineArea;
@@ -72,10 +73,7 @@ public class ContentLayoutManager implements InlineLevelLayoutManager {
 
     public void fillArea(LayoutManager curLM) {
 
-        List childBreaks = new ArrayList();
-        MinOptMax stack = new MinOptMax();
         int ipd = 1000000;
-        BreakPoss bp;
 
         LayoutContext childLC = new LayoutContext(LayoutContext.NEW_AREA);
         childLC.setLeadingSpace(new SpaceSpecifier(false));
@@ -96,35 +94,35 @@ public class ContentLayoutManager implements InlineLevelLayoutManager {
         // max size of middle alignment below baseline
         int middlefollow = maxtb;
 
-        while (!curLM.isFinished()) {
-            MinOptMax lastSize = null;
-            if ((bp = curLM.getNextBreakPoss(childLC)) != null) {
-                lastSize = bp.getStackingSize();
-                childBreaks.add(bp);
-
-                if (bp.getLead() > lineLead) {
-                    lineLead = bp.getLead();
+        stackSize = 0;
+
+        LinkedList contentList =
+            getNextKnuthElements(childLC, Constants.EN_START);
+        ListIterator contentIter = contentList.listIterator();
+        while (contentIter.hasNext()) {
+            KnuthElement element = (KnuthElement) contentIter.next();
+            if (element.isBox()) {
+                KnuthBox box = (KnuthBox) element;
+                if (box.getLead() > lineLead) {
+                    lineLead = box.getLead();
                 }
-                if (bp.getTotal() > maxtb) {
-                    maxtb = bp.getTotal();
+                if (box.getTotal() > maxtb) {
+                    maxtb = box.getTotal();
                 }
-                if (bp.getMiddle() > middlefollow) {
-                    middlefollow = bp.getMiddle();
+                // Is this needed? cf. LineLM.makeLineBreakPosition
+                // if (box.getMiddle() > lineLead) {
+                //     lineLead = box.getMiddle();
+                // }
+                if (box.getMiddle() > middlefollow) {
+                    middlefollow = box.getMiddle();
                 }
             }
-            if (lastSize != null) {
-                stack.add(lastSize);
-            }
         }
 
         if (maxtb - lineLead > middlefollow) {
             middlefollow = maxtb - lineLead;
         }
 
-        //if(holder instanceof InlineParent) {
-        //    ((InlineParent)holder).setHeight(lineHeight);
-        //}
-
         LayoutContext lc = new LayoutContext(0);
         lc.setBaseline(lineLead);
         lc.setLineHeight(lineHeight);
@@ -132,10 +130,9 @@ public class ContentLayoutManager implements InlineLevelLayoutManager {
         lc.setFlags(LayoutContext.RESOLVE_LEADING_SPACE, true);
         lc.setLeadingSpace(new SpaceSpecifier(false));
         lc.setTrailingSpace(new SpaceSpecifier(false));
-        PositionIterator breakPosIter =
-                new BreakPossPosIter(childBreaks, 0, childBreaks.size());
-        curLM.addAreas(breakPosIter, lc);
-        stackSize = stack.opt;
+        KnuthPossPosIter contentPosIter =
+            new KnuthPossPosIter(contentList, 0, contentList.size());
+        curLM.addAreas(contentPosIter, lc);
     }
 
     public void addAreas(PositionIterator posIter, LayoutContext context) {