keiron      2002/08/18 06:47:13

  Modified:    src/org/apache/fop/fo/flow Block.java
               src/org/apache/fop/layoutmgr BlockLayoutManager.java
                        BreakPoss.java FlowLayoutManager.java LMiter.java
                        LayoutContext.java LineBPLayoutManager.java
                        PageLayoutManager.java TextBPLayoutManager.java
  Log:
  improved block layout, adds areas to correct parent
  properly resets
  
  Revision  Changes    Path
  1.61      +2 -2      xml-fop/src/org/apache/fop/fo/flow/Block.java
  
  Index: Block.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/flow/Block.java,v
  retrieving revision 1.60
  retrieving revision 1.61
  diff -u -r1.60 -r1.61
  --- Block.java        16 Aug 2002 12:30:41 -0000      1.60
  +++ Block.java        18 Aug 2002 13:47:12 -0000      1.61
  @@ -293,7 +293,7 @@
                           break;
   
                       case CharUtilities.EOT:
  -                        //   A "boundary" objects such as non-character inline
  +                        // A "boundary" objects such as non-character inline
                           // or nested block object was encountered.
                           // If any whitespace run in progress, finish it.
                           // FALL THROUGH
  
  
  
  1.13      +15 -22    xml-fop/src/org/apache/fop/layoutmgr/BlockLayoutManager.java
  
  Index: BlockLayoutManager.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/layoutmgr/BlockLayoutManager.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- BlockLayoutManager.java   11 Aug 2002 07:31:30 -0000      1.12
  +++ BlockLayoutManager.java   18 Aug 2002 13:47:13 -0000      1.13
  @@ -103,45 +103,37 @@
           MinOptMax stackSize = new MinOptMax();
           // if starting add space before
           // stackSize.add(spaceBefore);
  +        BreakPoss lastPos = null;
   
           while ((curLM = getChildLM()) != null) {
               // Make break positions and return blocks!
               // Set up a LayoutContext
  -            int ipd = 0;
  +            int ipd = context.getRefIPD();
               BreakPoss bp;
   
  -            // Force area creation on first call
  -            // NOTE: normally not necessary when fully integrated!
               LayoutContext childLC =
  -              new LayoutContext(LayoutContext.CHECK_REF_AREA);
  +              new LayoutContext(0);
               if(curLM.generatesInlineAreas()) {
  -                // Reset stackLimit for non-first lines
  -                childLC.setStackLimit(new MinOptMax(ipd/* - m_iIndents*/));
  +                // set stackLimit for lines
  +                childLC.setStackLimit(new MinOptMax(ipd/* - m_iIndents - 
m_iTextIndent*/));
               } else {
                   childLC.setStackLimit(MinOptMax.subtract(context.getStackLimit(), 
stackSize));
  +                childLC.setRefIPD(ipd);
               }
   
               while (!curLM.isFinished()) {
                   if ((bp = curLM.getNextBreakPoss(childLC, null)) != null) {
  -                    if (bp.checkIPD()) {
  -                        // Need IPD in order to layout lines!
  -                        // This is supposed to bubble up to PageLM to
  -                        // make the necessary flow reference area, depending
  -                        // on span and break-before flags set as the BreakPoss
  -                        // makes its way back up the call stack.
  -                        // Fake it for now!
  -                        getParentArea(null);
  -                        ipd = getContentIPD();
  -                        childLC.flags &= ~LayoutContext.CHECK_REF_AREA;
  -                        childLC.setStackLimit(new MinOptMax(ipd/* - m_iIndents -
  -                                                              m_iTextIndent*/));
  -                    } else {
                           stackSize.add(bp.getStackingSize());
                           if(stackSize.min > context.getStackLimit().max) {
                               // reset to last break
  -                            // curLM.reset();
  +                            if(lastPos != null) {
  +                                reset(lastPos.getPosition());
  +                            } else {
  +                                curLM.resetPosition(null);
  +                            }
                               break;
                           }
  +                        lastPos = bp;
                           childBreaks.add(bp);
   
                           if(curLM.generatesInlineAreas()) {
  @@ -150,7 +142,6 @@
                           } else {
                               
childLC.setStackLimit(MinOptMax.subtract(context.getStackLimit(), stackSize));
                           }
  -                    }
                   }
               }
               BreakPoss breakPoss = new BreakPoss(
  @@ -163,6 +154,7 @@
       }
   
       public void addAreas(PositionIterator parentIter, LayoutContext layoutContext) {
  +        getParentArea(null);
   
           BPLayoutManager childLM ;
           int iStartPos = 0;
  @@ -182,6 +174,7 @@
           flush();
   
           childBreaks.clear();
  +        curBlockArea = null;
       }
   
       /**
  
  
  
  1.7       +1 -6      xml-fop/src/org/apache/fop/layoutmgr/BreakPoss.java
  
  Index: BreakPoss.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/layoutmgr/BreakPoss.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- BreakPoss.java    16 Aug 2002 12:44:07 -0000      1.6
  +++ BreakPoss.java    18 Aug 2002 13:47:13 -0000      1.7
  @@ -28,7 +28,6 @@
       public static final int ISFIRST = 0x04; // First area generated by FO
       public static final int FORCE = 0x08; // Forced break (ie LF)
       public static final int CAN_BREAK_BEFORE = 0x10;
  -    public static final int NEED_IPD = 0x20;
       public static final int HAS_ANCHORS = 0x40;
       // Set this flag if all fo:character generated Areas would
       // suppressed at the end or beginning of a line
  @@ -196,10 +195,6 @@
   
       public LayoutProps getLayoutProps() {
           return m_layoutProps;
  -    }
  -
  -    public boolean checkIPD() {
  -        return ((m_flags & NEED_IPD) != 0);
       }
   
       public int getLead() {
  
  
  
  1.7       +2 -1      xml-fop/src/org/apache/fop/layoutmgr/FlowLayoutManager.java
  
  Index: FlowLayoutManager.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/layoutmgr/FlowLayoutManager.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- FlowLayoutManager.java    11 Aug 2002 07:31:30 -0000      1.6
  +++ FlowLayoutManager.java    18 Aug 2002 13:47:13 -0000      1.7
  @@ -51,6 +51,7 @@
               LayoutContext childLC = new LayoutContext(0);
               boolean breakPage = false;
               childLC.setStackLimit(MinOptMax.subtract(bpd, stackSize));
  +            childLC.setRefIPD(context.getRefIPD());
   
               if (!curLM.isFinished()) {
                   if ((bp = curLM.getNextBreakPoss(childLC, null)) != null) {
  
  
  
  1.3       +8 -5      xml-fop/src/org/apache/fop/layoutmgr/LMiter.java
  
  Index: LMiter.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/layoutmgr/LMiter.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- LMiter.java       8 Aug 2002 15:08:08 -0000       1.2
  +++ LMiter.java       18 Aug 2002 13:47:13 -0000      1.3
  @@ -31,13 +31,16 @@
       }
   
       private boolean preLoadNext() {
  -        if (m_baseIter.hasNext()) {
  +        // skip over child FObj's that don't add lms
  +        while (m_baseIter.hasNext()) {
               FObj fobj = (FObj) m_baseIter.next();
               //m_listLMs.add(fobj.getLayoutManager());
               fobj.addLayoutManager(m_listLMs);
  -            return m_curPos < m_listLMs.size();
  -        } else
  -            return false;
  +            if(m_curPos < m_listLMs.size()) {
  +                return true;
  +            }
  +        }
  +        return false;
       }
   
       public boolean hasPrevious() {
  
  
  
  1.8       +9 -1      xml-fop/src/org/apache/fop/layoutmgr/LayoutContext.java
  
  Index: LayoutContext.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/layoutmgr/LayoutContext.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- LayoutContext.java        16 Aug 2002 12:44:07 -0000      1.7
  +++ LayoutContext.java        18 Aug 2002 13:47:13 -0000      1.8
  @@ -157,6 +157,14 @@
           return m_stackLimit;
       }
   
  +    public void setRefIPD(int ipd) {
  +        refIPD = ipd;
  +    }
  +
  +    public int getRefIPD() {
  +        return refIPD;
  +    }
  +
       public void setHyphContext(HyphContext hyphContext) {
           m_hyphContext = hyphContext;
       }
  
  
  
  1.13      +20 -11    xml-fop/src/org/apache/fop/layoutmgr/LineBPLayoutManager.java
  
  Index: LineBPLayoutManager.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/layoutmgr/LineBPLayoutManager.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- LineBPLayoutManager.java  16 Aug 2002 13:06:38 -0000      1.12
  +++ LineBPLayoutManager.java  18 Aug 2002 13:47:13 -0000      1.13
  @@ -74,6 +74,9 @@
       private int lead;
       private int follow;
   
  +    // inline start pos when adding areas
  +    int iStartPos = 0;    
  +
       public LineBPLayoutManager(FObj fobj, List lms, int lh, int l, int f) {
           //super(fobj, lms.listIterator(), lh, l, f);
           super(fobj, lms.listIterator());
  @@ -103,15 +106,6 @@
           // Get a break from currently active child LM
           // Set up constraints for inline level managers
   
  -        if ((context.flags & LayoutContext.CHECK_REF_AREA) != 0) {
  -            /* Return a BreakPoss indicating that higher level LM
  -             * (page) should check reference area and possibly
  -             * create a new one.
  -             */
  -            return new BreakPoss(new LineBreakPosition(this, -1, 0.0, lineHeight, 
lead),
  -                                 BreakPoss.NEED_IPD);
  -        }
  -
           BPLayoutManager curLM ; // currently active LM
           BreakPoss prevBP = null;
           BreakPoss bp = null; // proposed BreakPoss
  @@ -461,6 +455,21 @@
           return curLineBP;
       }
   
  +    public void resetPosition(Position resetPos) {
  +        if (resetPos == null) {
  +            reset(null);
  +            m_vecInlineBreaks.clear();
  +            m_prevBP = null;
  +        } else {
  +            m_prevBP = 
(BreakPoss)m_vecInlineBreaks.get(((LineBreakPosition)resetPos).getLeafPos());
  +            while (m_vecInlineBreaks.get(m_vecInlineBreaks.size() - 1) != m_prevBP)
  +{
  +                m_vecInlineBreaks.remove(m_vecInlineBreaks.size() - 1);
  +            }
  +            reset(m_prevBP.getPosition());
  +        }
  +    }
  +
       public void addAreas(PositionIterator parentIter,
                            LayoutContext context) {
           addAreas(parentIter, 0.0);
  @@ -474,7 +483,7 @@
       // dSpaceAdjust should reference extra space in the BPD
       public void addAreas(PositionIterator parentIter, double dSpaceAdjust) {
           BPLayoutManager childLM ;
  -        int iStartPos = 0;
  +        //int iStartPos = 0;
           LayoutContext lc = new LayoutContext(0);
           while (parentIter.hasNext()) {
               LineBreakPosition lbp = (LineBreakPosition) parentIter.next();
  
  
  
  1.12      +21 -23    xml-fop/src/org/apache/fop/layoutmgr/PageLayoutManager.java
  
  Index: PageLayoutManager.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/layoutmgr/PageLayoutManager.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- PageLayoutManager.java    17 Aug 2002 23:51:08 -0000      1.11
  +++ PageLayoutManager.java    18 Aug 2002 13:47:13 -0000      1.12
  @@ -25,11 +25,11 @@
   public class PageLayoutManager extends AbstractBPLayoutManager implements Runnable {
   
       private static class BlockBreakPosition extends LeafPosition {
  -        List blockps;
  +        BreakPoss breakps;
   
  -        BlockBreakPosition(BPLayoutManager lm, int iBreakIndex, List bps) {
  -            super(lm, iBreakIndex);
  -            blockps = bps;
  +        BlockBreakPosition(BPLayoutManager lm, BreakPoss bp) {
  +            super(lm, 0);
  +            breakps = bp;
           }
       }
   
  @@ -51,6 +51,7 @@
       private Flow curFlow;
   
       private int flowBPD = 0;
  +    private int flowIPD = 0; 
   
       /** Manager which handles a queue of all pages which are completely
        * laid out and ready for rendering, except for resolution of ID
  @@ -86,16 +87,17 @@
   
       public void doLayout() {
   
  +        // this should be done another way
           makeNewPage(false, false);
  +        createBodyMainReferenceArea();
  +        createSpan(1);
  +        flowIPD = curFlow.getIPD();
   
           BreakPoss bp;
           LayoutContext childLC = new LayoutContext(0);
           while (!isFinished()) {
  -        ArrayList vecBreakPoss = new ArrayList();
               if ((bp = getNextBreakPoss(childLC, null)) != null) {
  -                vecBreakPoss.add(bp);
  -                addAreas( new BreakPossPosIter(vecBreakPoss, 0,
  -                                       vecBreakPoss.size()), null);
  +                addAreas((BlockBreakPosition)bp.getPosition());
                   // add static areas and resolve any new id areas
   
                   // finish page and add to area tree
  @@ -112,33 +114,29 @@
           BPLayoutManager curLM ; // currently active LM
   
           while ((curLM = getChildLM()) != null) {
  -            ArrayList vecBreakPoss = new ArrayList();
  +            BreakPoss bp = null;
   
               LayoutContext childLC = new LayoutContext(0);
               childLC.setStackLimit(new MinOptMax(flowBPD));
  +            childLC.setRefIPD(flowIPD);
   
               if (!curLM.isFinished()) {
  -                BreakPoss bp;
  -                if ((bp = curLM.getNextBreakPoss(childLC, null)) != null) {
  -                    vecBreakPoss.add(bp);
  -                }
  +                bp = curLM.getNextBreakPoss(childLC, null);
               }
  -            if(vecBreakPoss.size() > 0) {
  +            if(bp != null) {
                   return new BreakPoss(
  -                         new BlockBreakPosition(curLM, 0, vecBreakPoss));
  +                         new BlockBreakPosition(curLM, bp));
               }
           }
           setFinished(true);
           return null;
       }
   
  -    public void addAreas(PositionIterator parentIter, LayoutContext lc) {
  -
  -        while (parentIter.hasNext()) {
  -            BlockBreakPosition bbp = (BlockBreakPosition) parentIter.next();
  -            bbp.getLM().addAreas( new BreakPossPosIter(bbp.blockps, 0,
  -                                  bbp.blockps.size()), null);
  -        }
  +    public void addAreas(BlockBreakPosition bbp) {
  +        List list = new ArrayList();
  +        list.add(bbp.breakps);
  +        bbp.getLM().addAreas( new BreakPossPosIter(list, 0,
  +                              1), null);
       }
   
       /**
  
  
  
  1.11      +15 -9     xml-fop/src/org/apache/fop/layoutmgr/TextBPLayoutManager.java
  
  Index: TextBPLayoutManager.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/layoutmgr/TextBPLayoutManager.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- TextBPLayoutManager.java  16 Aug 2002 12:44:07 -0000      1.10
  +++ TextBPLayoutManager.java  18 Aug 2002 13:47:13 -0000      1.11
  @@ -466,14 +466,18 @@
           //                      " total=" + iAdjust);
   
           // Make an area containing all characters between start and end.
  -        Word word = createWord(
  -                      new String(chars, iStart, ai.m_iBreakIndex - iStart),
  +        Word word = null;
  +        String str = new String(chars, iStart, ai.m_iBreakIndex - iStart);
  +        //if(!"".equals(str.trim())) {
  +            word = createWord(
  +                      str,
                         ai.m_ipdArea.opt + iAdjust, context.getBaseline());
  -        if (iWScount > 0) {
  -            //log.error("Adjustment per word-space= " +
  -            //                   iAdjust / iWScount);
  -            word.setWSadjust(iAdjust / iWScount);
  -        }
  +            if (iWScount > 0) {
  +                //log.error("Adjustment per word-space= " +
  +                //                   iAdjust / iWScount);
  +                word.setWSadjust(iAdjust / iWScount);
  +            }
  +        //}
           if ((chars[iStart] == SPACE || chars[iStart] == NBSPACE) &&
                   context.getLeadingSpace().hasSpaces()) {
               context.getLeadingSpace().addSpace(m_halfWS);
  @@ -493,7 +497,9 @@
                   chars[ai.m_iBreakIndex - 1] == NBSPACE) {
               context.getTrailingSpace().addSpace(m_halfWS);
           }
  -        parentLM.addChild(word);
  +        if(word != null) {
  +            parentLM.addChild(word);
  +        }
       }
   
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to