keiron      2002/10/28 05:07:22

  Modified:    src/org/apache/fop/layoutmgr LineLayoutManager.java
  Log:
  fixed a looping problem, added more comments
  
  Revision  Changes    Path
  1.16      +74 -10    xml-fop/src/org/apache/fop/layoutmgr/LineLayoutManager.java
  
  Index: LineLayoutManager.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/layoutmgr/LineLayoutManager.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- LineLayoutManager.java    25 Oct 2002 09:29:45 -0000      1.15
  +++ LineLayoutManager.java    28 Oct 2002 13:07:22 -0000      1.16
  @@ -36,6 +36,13 @@
   /**
    * LayoutManager for lines. It builds one or more lines containing
    * inline areas generated by its sub layout managers.
  + * A break is found for each line which may contain one of more
  + * breaks from the child layout managers.
  + * Once a break is found then it is return for the parent layout
  + * manager to handle.
  + * When the areas are being added to the page this manager
  + * creates a line area to contain the inline areas added by the
  + * child layout managers.
    */
   public class LineLayoutManager extends InlineStackingLayoutManager {
   
  @@ -44,7 +51,6 @@
        * Each value holds the start and end indexes into a List of
        * inline break positions.
        */
  -    // private static class LineBreakPosition implements Position {
       private static class LineBreakPosition extends LeafPosition {
           // int m_iPos;
           double m_dAdjust; // Percentage to adjust (stretch or shrink)
  @@ -82,8 +88,18 @@
       // inline start pos when adding areas
       int iStartPos = 0;    
   
  +    /**
  +     * Create a new Line Layout Manager.
  +     * This is used by the block layout manager to create
  +     * line managers for handling inline areas flowing into line areas.
  +     *
  +     * @param fobj the block the is creating the lines
  +     * @param lms the list of layout managers that will add inline areas
  +     * @param lh the default line height
  +     * @param l the default lead, from top to baseline
  +     * @param f the default follow, from baseline to bottom
  +     */
       public LineLayoutManager(FObj fobj, List lms, int lh, int l, int f) {
  -        //super(fobj, lms.listIterator(), lh, l, f);
           super(fobj, lms.listIterator());
           lineHeight = lh;
           lead = l;
  @@ -91,6 +107,10 @@
           init(); // Normally done when started by parent!
       }
   
  +    /**
  +     * Initialize the properties for this layout manager.
  +     * The properties are from the block area.
  +     */
       protected void initProperties(PropertyManager propMgr) {
           MarginProps marginProps = propMgr.getMarginProps();
           m_iIndents = marginProps.startIndent + marginProps.endIndent;
  @@ -103,7 +123,9 @@
       /**
        * Call child layout managers to generate content.
        * This gets the next break which is a full line.
  -     * 
  +     *
  +     * @param context the layout context for finding breaks
  +     * @return the next break position
        */
       public BreakPoss getNextBreakPoss(LayoutContext context) {
           // Get a break from currently active child LM
  @@ -126,6 +148,8 @@
           clearPrevIPD();
           int iPrevLineEnd = m_vecInlineBreaks.size();
   
  +        m_prevBP = null;
  +
           while ((curLM = getChildLM()) != null) {
               // INITIALIZE LAYOUT CONTEXT FOR CALL TO CHILD LM
               // First break for the child LM in each of its areas
  @@ -302,8 +326,6 @@
           }
       }
   
  -
  -
       private BreakPoss getBestBP(ArrayList vecPossEnd) {
           if (vecPossEnd.size() == 1) {
               return ((BreakCost) vecPossEnd.get(0)).getBP();
  @@ -389,7 +411,16 @@
           }
       }
   
  -
  +    /**
  +     * Make a line break for returning as the next break.
  +     * This makes the line break and calculates the height and
  +     * ipd adjustment factors.
  +     *
  +     * @param prevLineEnd previous line break index
  +     * @param target the target ipd value
  +     * @param textalign the text align in operation for this line
  +     * @return the line break position
  +     */
       private BreakPoss makeLineBreak(int prevLineEnd, MinOptMax target,
                                       int textalign) {
           // make a new BP
  @@ -509,6 +540,11 @@
           return curLineBP;
       }
   
  +    /**
  +     * Reset the positions to the given position.
  +     *
  +     * @param resetPos the position to reset to
  +     */
       public void resetPosition(Position resetPos) {
           if (resetPos == null) {
               iStartPos = 0;
  @@ -525,6 +561,12 @@
           }
       }
   
  +    /**
  +     * Add the areas with the break points.
  +     *
  +     * @param parentIter the iterator of break positions
  +     * @param context the context for adding areas
  +     */
       public void addAreas(PositionIterator parentIter,
                            LayoutContext context) {
           addAreas(parentIter, 0.0);
  @@ -536,8 +578,14 @@
       // Generate and add areas to parent area
       // Set size etc
       // dSpaceAdjust should reference extra space in the BPD
  +    /**
  +     * Add the areas with the associated space adjustment.
  +     *
  +     * @param parentIter the iterator of breaks positions
  +     * @param dSpaceAdjust the space adjustment
  +     */
       public void addAreas(PositionIterator parentIter, double dSpaceAdjust) {
  -        LayoutManager childLM ;
  +        LayoutManager childLM;
           //int iStartPos = 0;
           LayoutContext lc = new LayoutContext(0);
           while (parentIter.hasNext()) {
  @@ -563,13 +611,29 @@
                   lc.setLeadingSpace(lc.getTrailingSpace());
                   lc.setTrailingSpace(new SpaceSpecifier(false));
               }
  -            addSpace(lineArea, lc.getTrailingSpace().resolve(true),
  -                     lc.getSpaceAdjust());
  +            // when can this be null?
  +            if(lc.getTrailingSpace() != null) {
  +                addSpace(lineArea, lc.getTrailingSpace().resolve(true),
  +                         lc.getSpaceAdjust());
  +            }
               parentLM.addChild(lineArea);
           }
           setCurrentArea(null); // ?? necessary
       }
   
  +    /**
  +     * Add an unresolved area.
  +     * If a child layout manager needs to add an unresolved area
  +     * for page reference or linking then this intercepts it for
  +     * line area handling.
  +     * A line area may need to have the inline areas adjusted
  +     * to properly fill the line area. This adds a resolver that
  +     * resolves the inline area and can do the necessary
  +     * adjustments to the line and inline areas.
  +     *
  +     * @param id the id reference of the resolveable
  +     * @param res the resolveable object
  +     */
       public void addUnresolvedArea(String id, Resolveable res) {
           // create a resolveable class that handles ipd
           // adjustment for the current line
  
  
  

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

Reply via email to