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 ke...@apache.org on 2002/09/18 16:15:05 UTC

cvs commit: xml-fop/src/org/apache/fop/layoutmgr/table Body.java Cell.java TableLayoutManager.java

keiron      2002/09/18 07:15:05

  Modified:    src/org/apache/fop/layoutmgr BlockLayoutManager.java
                        BlockStackingLayoutManager.java
                        FlowLayoutManager.java
                        InlineStackingLayoutManager.java
                        LeafNodeLayoutManager.java LineLayoutManager.java
                        PageLayoutManager.java
               src/org/apache/fop/layoutmgr/table Body.java Cell.java
                        TableLayoutManager.java
  Log:
  start of spacing and borders
  
  Revision  Changes    Path
  1.20      +66 -3     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.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- BlockLayoutManager.java	13 Sep 2002 08:21:54 -0000	1.19
  +++ BlockLayoutManager.java	18 Sep 2002 14:15:04 -0000	1.20
  @@ -9,11 +9,18 @@
   
   import org.apache.fop.fo.FObj;
   import org.apache.fop.fo.TextInfo;
  +import org.apache.fop.fo.PropertyManager;
   import org.apache.fop.area.Area;
   import org.apache.fop.area.BlockParent;
   import org.apache.fop.area.Block;
   import org.apache.fop.area.LineArea;
   import org.apache.fop.area.MinOptMax;
  +import org.apache.fop.area.Trait;
  +import org.apache.fop.traits.LayoutProps;
  +import org.apache.fop.layout.BorderAndPadding;
  +import org.apache.fop.layout.BackgroundProps;
  +import org.apache.fop.traits.SpaceVal;
  +import org.apache.fop.traits.BorderProps;
   
   import java.util.ListIterator;
   import java.util.ArrayList;
  @@ -26,6 +33,10 @@
   
       private Block curBlockArea;
   
  +    LayoutProps layoutProps;
  +    BorderAndPadding borderProps;
  +    BackgroundProps backgroundsPops;
  +
       int lead = 12000;
       int lineHeight = 14000;
       int follow = 2000;
  @@ -96,12 +107,23 @@
           lineHeight = ti.lineHeight;
       }
   
  +    /**
  +     * This method provides a hook for a LayoutManager to intialize traits
  +     * for the areas it will create, based on Properties set on its FO.
  +     */
  +    protected void initProperties(PropertyManager pm) {
  +        layoutProps = pm.getLayoutProps();
  +        borderProps = pm.getBorderAndPadding();
  +        backgroundsPops = pm.getBackgroundProps();
  +    }
  +    
       public BreakPoss getNextBreakPoss(LayoutContext context) {
           LayoutManager curLM ; // currently active LM
   
           MinOptMax stackSize = new MinOptMax();
           // if starting add space before
  -        // stackSize.add(spaceBefore);
  +        stackSize.add(layoutProps.spaceBefore.space);
  +
           BreakPoss lastPos = null;
   
           while ((curLM = getChildLM()) != null) {
  @@ -127,7 +149,7 @@
               while (!curLM.isFinished()) {
                   if ((bp = curLM.getNextBreakPoss(childLC)) != null) {
                       stackSize.add(bp.getStackingSize());
  -                    if (stackSize.min > context.getStackLimit().max) {
  +                    if (stackSize.opt > context.getStackLimit().max) {
                           // reset to last break
                           if (lastPos != null) {
                               reset(lastPos.getPosition());
  @@ -148,6 +170,9 @@
                       }
                   }
               }
  +            if(getChildLM() == null) {
  +                stackSize.add(layoutProps.spaceAfter.space);
  +            }
               BreakPoss breakPoss = new BreakPoss(
                                       new LeafPosition(this, childBreaks.size() - 1));
               breakPoss.setStackingSize(stackSize);
  @@ -160,6 +185,11 @@
       public void addAreas(PositionIterator parentIter,
                            LayoutContext layoutContext) {
           getParentArea(null);
  +
  +        // if adjusted space before
  +        double adjust = layoutContext.getSpaceAdjust();
  +        addBlockSpacing(adjust, layoutProps.spaceBefore.space);
  +
           addID();
   
           LayoutManager childLM ;
  @@ -179,6 +209,9 @@
   
           flush();
   
  +        // if adjusted space after
  +        addBlockSpacing(adjust, layoutProps.spaceAfter.space);
  +
           childBreaks.clear();
           curBlockArea = null;
       }
  @@ -196,6 +229,10 @@
       public Area getParentArea(Area childArea) {
           if (curBlockArea == null) {
               curBlockArea = new Block();
  +
  +            // set traits
  +            addBorders(curBlockArea);
  +
               // Set up dimensions
               // Must get dimensions from parent area
               Area parentArea = parentLM.getParentArea(curBlockArea);
  @@ -207,6 +244,32 @@
           return curBlockArea;
       }
   
  +    public void addBorders(Block curBlockArea) {
  +        BorderProps bps = getBorderProps(BorderAndPadding.TOP);
  +        if(bps.width != 0) {
  +            curBlockArea.addTrait(Trait.BORDER_START, bps);
  +        }
  +        bps = getBorderProps(BorderAndPadding.BOTTOM);
  +        if(bps.width != 0) {
  +            curBlockArea.addTrait(Trait.BORDER_END, bps);
  +        }
  +        bps = getBorderProps(BorderAndPadding.LEFT);
  +        if(bps.width != 0) {
  +            curBlockArea.addTrait(Trait.BORDER_BEFORE, bps);
  +        }
  +        bps = getBorderProps(BorderAndPadding.RIGHT);
  +        if(bps.width != 0) {
  +            curBlockArea.addTrait(Trait.BORDER_AFTER, bps);
  +        }
  +    }
  +
  +    private BorderProps getBorderProps(int side) {
  +        BorderProps bps;
  +        bps = new BorderProps(borderProps.getBorderStyle(side),
  +                              borderProps.getBorderWidth(side, false),
  +                              borderProps.getBorderColor(side));
  +        return bps;
  +    }
   
       public boolean addChild(Area childArea) {
           if (curBlockArea != null) {
  
  
  
  1.11      +29 -8     xml-fop/src/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
  
  Index: BlockStackingLayoutManager.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- BlockStackingLayoutManager.java	13 Sep 2002 08:21:54 -0000	1.10
  +++ BlockStackingLayoutManager.java	18 Sep 2002 14:15:04 -0000	1.11
  @@ -59,6 +59,27 @@
       }
   
       /**
  +     * Add a block spacer for space before and space after a block.
  +     * This adds an empty Block area that acts as a block space.
  +     *
  +     * @param adjust the adjustment value
  +     * @param minoptmax the min/opt/max value of the spacing
  +     */
  +    public void addBlockSpacing(double adjust, MinOptMax minoptmax) {
  +        int sp = minoptmax.opt;
  +        if(adjust > 0) {
  +            sp = sp + (int)(adjust * (minoptmax.max - minoptmax.opt));
  +        } else {
  +            sp = sp + (int)(adjust * (minoptmax.opt - minoptmax.min));
  +        }
  +        if(sp != 0) {
  +            Block spacer = new Block();
  +            spacer.setHeight(sp);
  +            parentLM.addChild(spacer);
  +        }
  +    }
  +
  +    /**
        * Add the childArea to the passed area.
        * Called by child LayoutManager when it has filled one of its areas.
        * The LM should already have an Area in which to put the child.
  @@ -77,14 +98,14 @@
   
           // See if the whole thing fits, including space before
           // Calculate space between last child in curFlow and childArea
  -        MinOptMax targetDim = parentArea.getAvailBPD();
  +        //MinOptMax targetDim = parentArea.getAvailBPD();
           MinOptMax spaceBefore = resolveSpaceSpecifier(childArea);
  -        targetDim.subtract(spaceBefore);
  -        if (targetDim.max >= childArea.getAllocationBPD().min) {
  +        //targetDim.subtract(spaceBefore);
  +        //if (targetDim.max >= childArea.getAllocationBPD().min) {
               //parentArea.addBlock(new InterBlockSpace(spaceBefore));
  -            parentArea.addBlock((Block) childArea);
  -            return false;
  -        } else {
  +        //    parentArea.addBlock((Block) childArea);
  +        //    return false;
  +        //} else {
               parentArea.addBlock((Block) childArea);
               flush(); // hand off current area to parent
               // Probably need something like max BPD so we don't get into
  @@ -104,7 +125,7 @@
               //addChild(splitContext.nextArea);
               //addChild(childArea);
               return true;
  -        }
  +        //}
       }
   
   
  
  
  
  1.13      +3 -3      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.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- FlowLayoutManager.java	13 Sep 2002 08:21:54 -0000	1.12
  +++ FlowLayoutManager.java	18 Sep 2002 14:15:04 -0000	1.13
  @@ -75,12 +75,12 @@
               // check the stack bpd and if greater than available
               // height then go to the last best break and return
               // break position
  -            if(stackSize.min > context.getStackLimit().opt) {
  +            if(stackSize.opt > context.getStackLimit().opt) {
                   breakPage = true;
               }
               if(breakPage) {
                   return new BreakPoss(
  -			     new LeafPosition(this, blockBreaks.size() - 1));
  +                      new LeafPosition(this, blockBreaks.size() - 1));
               }
           }
           setFinished(true);
  
  
  
  1.3       +5 -3      xml-fop/src/org/apache/fop/layoutmgr/InlineStackingLayoutManager.java
  
  Index: InlineStackingLayoutManager.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/layoutmgr/InlineStackingLayoutManager.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- InlineStackingLayoutManager.java	7 Sep 2002 08:58:06 -0000	1.2
  +++ InlineStackingLayoutManager.java	18 Sep 2002 14:15:04 -0000	1.3
  @@ -447,7 +447,9 @@
               context.setTrailingSpace(getContext().getTrailingSpace());
           }
           // Add own trailing space to parent context (or set on area?)
  -        context.getTrailingSpace().addSpace(m_inlineProps.spaceEnd);
  +        if(context.getTrailingSpace() != null) {
  +            context.getTrailingSpace().addSpace(m_inlineProps.spaceEnd);
  +        }
   
           // Add border and padding to current area and set flags (FIRST, LAST ...)
           TraitSetter.setBorderPaddingTraits(getCurrentArea(),
  @@ -511,5 +513,5 @@
           }
       }
   
  -
   }
  +
  
  
  
  1.18      +2 -2      xml-fop/src/org/apache/fop/layoutmgr/LeafNodeLayoutManager.java
  
  Index: LeafNodeLayoutManager.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/layoutmgr/LeafNodeLayoutManager.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- LeafNodeLayoutManager.java	9 Sep 2002 12:21:23 -0000	1.17
  +++ LeafNodeLayoutManager.java	18 Sep 2002 14:15:04 -0000	1.18
  @@ -128,7 +128,7 @@
                                        | BreakPoss.ISLAST);
           ipd = getAllocationIPD(context.getRefIPD());
           bp.setStackingSize(ipd);
  -        bp.setNonStackingSize(curArea.getAllocationBPD());
  +        bp.setNonStackingSize(new MinOptMax(curArea.getHeight()));
           bp.setTrailingSpace(new SpaceSpecifier(false));
   
           int bpd = curArea.getHeight();
  
  
  
  1.14      +3 -2      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.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- LineLayoutManager.java	4 Sep 2002 11:43:42 -0000	1.13
  +++ LineLayoutManager.java	18 Sep 2002 14:15:04 -0000	1.14
  @@ -166,7 +166,8 @@
                   if (bBreakOK) {
                       /* Add any non-conditional trailing space, assuming we
                        * end the line here. If we can't break here, we just
  -                     * check if the content fits. */
  +                     * check if the content fits.
  +                     */
                       bpDim.add(bp.resolveTrailingSpace(true));
                   }
                   // TODO: stop if linebreak is forced (NEWLINE)
  
  
  
  1.20      +5 -5      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.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- PageLayoutManager.java	13 Sep 2002 08:21:54 -0000	1.19
  +++ PageLayoutManager.java	18 Sep 2002 14:15:04 -0000	1.20
  @@ -60,7 +60,7 @@
       private AreaTree areaTree;
       private PageSequence pageSequence;
   
  -    private int pageCount = 0;
  +    private int pageCount = 1;
   
       /**
        * This is the top level layout manager.
  @@ -98,7 +98,6 @@
           BreakPoss bp;
           LayoutContext childLC = new LayoutContext(0);
           while (!isFinished()) {
  -            pageCount++;
               if ((bp = getNextBreakPoss(childLC)) != null) {
                   addAreas((BlockBreakPosition)bp.getPosition());
                   // add static areas and resolve any new id areas
  @@ -106,6 +105,7 @@
                   // finish page and add to area tree
                   finishPage();
               }
  +            pageCount++;
           }
   
       }
  @@ -214,14 +214,14 @@
           // Alternatively the child LM indicates to parent that it's full?
           //System.out.println("size: " + area.getAllocationBPD().max +
           //                   ":" + curSpan.getMaxBPD().min);
  -        if (area.getAllocationBPD().max >= curSpan.getMaxBPD().min) {
  +        /*if (area.getAllocationBPD().max >= curSpan.getMaxBPD().min) {
               // Consider it filled
               if (curSpan.getColumnCount() == curSpanColumns) {
                   finishPage();
                   return true;
               } else
                   curFlow = null; // Create new flow on next getParentArea()
  -        }
  +        }*/
           return false;
       }
   
  
  
  
  1.2       +4 -2      xml-fop/src/org/apache/fop/layoutmgr/table/Body.java
  
  Index: Body.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/layoutmgr/table/Body.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Body.java	13 Sep 2002 08:21:55 -0000	1.1
  +++ Body.java	18 Sep 2002 14:15:05 -0000	1.2
  @@ -146,11 +146,13 @@
                 new BreakPossPosIter(childBreaks, iStartPos,
                                      lfp.getLeafPos() + 1);
               iStartPos = lfp.getLeafPos() + 1;
  +            int lastheight = 0;
               while ((childLM = (Row)breakPosIter.getNextChildLM()) != null) {
                   childLM.setYOffset(yoffset + rowoffset);
                   childLM.addAreas(breakPosIter, lc);
  -                rowoffset += childLM.getRowHeight();
  +                lastheight = childLM.getRowHeight();
               }
  +            rowoffset += lastheight;
           }
           bodyHeight = rowoffset;
   
  
  
  
  1.2       +6 -1      xml-fop/src/org/apache/fop/layoutmgr/table/Cell.java
  
  Index: Cell.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/layoutmgr/table/Cell.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Cell.java	13 Sep 2002 08:21:55 -0000	1.1
  +++ Cell.java	18 Sep 2002 14:15:05 -0000	1.2
  @@ -63,6 +63,11 @@
           cellIPD = context.getRefIPD();
   
           while ((curLM = getChildLM()) != null) {
  +            if(curLM.generatesInlineAreas()) {
  +                // error
  +                curLM.setFinished(true);
  +                continue;
  +            }
               // Set up a LayoutContext
               int ipd = context.getRefIPD();
               BreakPoss bp;
  
  
  
  1.2       +2 -2      xml-fop/src/org/apache/fop/layoutmgr/table/TableLayoutManager.java
  
  Index: TableLayoutManager.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/layoutmgr/table/TableLayoutManager.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TableLayoutManager.java	13 Sep 2002 08:21:55 -0000	1.1
  +++ TableLayoutManager.java	18 Sep 2002 14:15:05 -0000	1.2
  @@ -131,7 +131,7 @@
               while (!curLM.isFinished()) {
                   if ((bp = curLM.getNextBreakPoss(childLC)) != null) {
                       stackSize.add(bp.getStackingSize());
  -                    if (stackSize.min > context.getStackLimit().max) {
  +                    if (stackSize.opt > context.getStackLimit().max) {
                           // reset to last break
                           if (lastPos != null) {
                               reset(lastPos.getPosition());
  
  
  

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