diff options
author | Simon Pepping <spepping@apache.org> | 2004-12-22 18:22:35 +0000 |
---|---|---|
committer | Simon Pepping <spepping@apache.org> | 2004-12-22 18:22:35 +0000 |
commit | 344f3faf836d2045b9481b4ffe2b955233d32280 (patch) | |
tree | 5a075987fb554b08f18f97b82adff6ec194a3d86 /src | |
parent | 2ca1efa3177579a4da21ee1097193ab57cc09419 (diff) | |
download | xmlgraphics-fop-344f3faf836d2045b9481b4ffe2b955233d32280.tar.gz xmlgraphics-fop-344f3faf836d2045b9481b4ffe2b955233d32280.zip |
Fixed the NPE for fo:title in FOText.createBlockPointers by returning
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
Diffstat (limited to 'src')
-rw-r--r-- | src/java/org/apache/fop/fo/FOText.java | 8 | ||||
-rw-r--r-- | src/java/org/apache/fop/layoutmgr/ContentLayoutManager.java | 51 |
2 files changed, 29 insertions, 30 deletions
diff --git a/src/java/org/apache/fop/fo/FOText.java b/src/java/org/apache/fop/fo/FOText.java index 9a2faaa10..7c477dfb6 100644 --- a/src/java/org/apache/fop/fo/FOText.java +++ b/src/java/org/apache/fop/fo/FOText.java @@ -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; } } diff --git a/src/java/org/apache/fop/layoutmgr/ContentLayoutManager.java b/src/java/org/apache/fop/layoutmgr/ContentLayoutManager.java index d8eb3fbb0..adc25fd74 100644 --- a/src/java/org/apache/fop/layoutmgr/ContentLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/ContentLayoutManager.java @@ -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) { |