You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by sp...@apache.org on 2004/12/22 19:22:35 UTC

cvs commit: xml-fop/src/java/org/apache/fop/layoutmgr ContentLayoutManager.java

spepping    2004/12/22 10:22:35

  Modified:    src/java/org/apache/fop/fo FOText.java
               src/java/org/apache/fop/layoutmgr ContentLayoutManager.java
  Log:
  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.
  
  Revision  Changes    Path
  1.35      +5 -3      xml-fop/src/java/org/apache/fop/fo/FOText.java
  
  Index: FOText.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/FOText.java,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- FOText.java	24 Nov 2004 21:07:29 -0000	1.34
  +++ FOText.java	22 Dec 2004 18:22:35 -0000	1.35
  @@ -197,10 +197,12 @@
           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;
               }
           }
  
  
  
  1.17      +23 -26    xml-fop/src/java/org/apache/fop/layoutmgr/ContentLayoutManager.java
  
  Index: ContentLayoutManager.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/ContentLayoutManager.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- ContentLayoutManager.java	13 Nov 2004 20:37:17 -0000	1.16
  +++ ContentLayoutManager.java	22 Dec 2004 18:22:35 -0000	1.17
  @@ -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 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 @@
           // 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);
  +        stackSize = 0;
   
  -                if (bp.getLead() > lineLead) {
  -                    lineLead = bp.getLead();
  +        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 @@
           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) {
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-cvs-help@xml.apache.org