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 gm...@apache.org on 2005/05/07 06:28:29 UTC

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

gmazza      2005/05/06 21:28:29

  Modified:    src/java/org/apache/fop/layoutmgr Tag:
                        Temp_KnuthStylePageBreaking
                        PageSequenceLayoutManager.java AbstractBreaker.java
  Log:
  More simplifications to PSLM.  (Hmmm...I wonder if there's a way to have
  CVS just default this message...  ;-)
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.50.2.23 +26 -100   xml-fop/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java
  
  Index: PageSequenceLayoutManager.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java,v
  retrieving revision 1.50.2.22
  retrieving revision 1.50.2.23
  diff -u -r1.50.2.22 -r1.50.2.23
  --- PageSequenceLayoutManager.java	5 May 2005 04:54:08 -0000	1.50.2.22
  +++ PageSequenceLayoutManager.java	7 May 2005 04:28:28 -0000	1.50.2.23
  @@ -27,7 +27,6 @@
   import org.apache.fop.area.LineArea;
   import org.apache.fop.area.RegionViewport;
   import org.apache.fop.area.Resolvable;
  -import org.apache.fop.area.Trait;
   
   import org.apache.fop.datatypes.PercentBase;
   
  @@ -74,31 +73,21 @@
        */
       private int curFlowIdx = -1;
   
  -    /*
  -    private static class BlockBreakPosition extends LeafPosition {
  -        protected BreakPoss breakps;
  -
  -        protected BlockBreakPosition(LayoutManager lm, BreakPoss bp) {
  -            super(lm, 0);
  -            breakps = bp;
  -        }
  -    }*/
  -
  -    private int startPageNum = 0;
  -    private int currentPageNum = 0;
  -
       /**
  -     * The single FlowLayoutManager object, which processes
  +     * The FlowLayoutManager object, which processes
        * the single fo:flow of the fo:page-sequence
        */
       private FlowLayoutManager childFLM = null;
  -    
  +
       /**
        * The collection of StaticContentLayoutManager objects that
        * are associated with this Page Sequence, keyed by flow-name.
        */
       //private HashMap staticContentLMs = new HashMap(4);
   
  +    private int startPageNum = 0;
  +    private int currentPageNum = 0;
  +
       /**
        * Constructor
        *
  @@ -208,7 +197,7 @@
                           // the current BlockSequence, it could have a break
                           // condition that must be satisfied;
                           // otherwise, we may simply need a new page
  -                        handleBreakBefore(bIsFirstPage ? list.getStartOn() : Constants.EN_PAGE);
  +                        handleBreakTrait(bIsFirstPage ? list.getStartOn() : Constants.EN_PAGE);
                       }
                   }
               }
  @@ -433,29 +422,9 @@
           StaticContentLayoutManager lm;
           lm = (StaticContentLayoutManager)
               areaTreeHandler.getLayoutManagerMaker().makeLayoutManager(sc);
  -        lm.initialize();
           lm.setTargetRegion(rv.getRegionReference());
  -        lm.setParent(this);
  -        /*
  -        LayoutContext childLC = new LayoutContext(0);
  -        childLC.setStackLimit(new MinOptMax((int)curPV.getViewArea().getHeight()));
  -        childLC.setRefIPD(rv.getRegion().getIPD());
  -        */
  -        
  +        lm.setParent(this);       
           lm.doLayout(reg);
  -        
  -        /*
  -        while (!lm.isFinished()) {
  -            BreakPoss bp = lm.getNextBreakPoss(childLC);
  -            if (bp != null) {
  -                List vecBreakPoss = new java.util.ArrayList();
  -                vecBreakPoss.add(bp);
  -                lm.addAreas(new BreakPossPosIter(vecBreakPoss, 0,
  -                                                 vecBreakPoss.size()), null);
  -            } else {
  -                log.error("bp==null  cls=" + reg.getRegionName());
  -            }
  -        }*/
           lm.reset(null);
       }
   
  @@ -467,52 +436,11 @@
           layoutSideRegion(FO_REGION_END);
           // Queue for ID resolution and rendering
           areaTreeHandler.getAreaTreeModel().addPage(curPV);
  -        log.debug("page finished: " + curPV.getPageNumberString() + ", current num: " + currentPageNum);
  +        log.debug("page finished: " + curPV.getPageNumberString() 
  +                + ", current num: " + currentPageNum);
           curPV = null;
           curFlowIdx = -1;
       }
  -
  -    private void prepareNormalFlowArea(Area childArea) {
  -        // Need span, break
  -        int breakBeforeVal = Constants.EN_AUTO;
  -        Integer breakBefore = (Integer)childArea.getTrait(Trait.BREAK_BEFORE);
  -        if (breakBefore != null) {
  -            breakBeforeVal = breakBefore.intValue();
  -        }
  -        if (breakBeforeVal != Constants.EN_AUTO) {
  -            // We may be forced to make new page
  -            handleBreakBefore(breakBeforeVal);
  -        }
  -        /* Determine if a new span is needed.  From the XSL
  -         * fo:region-body definition, if an fo:block has a span="ALL"
  -         * (i.e., span all columns defined for the region-body), it
  -         * must be placed in a span-reference-area whose 
  -         * column-count = 1.  If its span-value is "NONE", 
  -         * place in a normal Span whose column-count is what
  -         * is defined for the region-body. 
  -         */  // temporarily hardcoded to EN_NONE.
  -        boolean bNeedNewSpan = false;
  -        int span = Constants.EN_NONE; // childArea.getSpan()
  -        int numColsNeeded;
  -        if (span == Constants.EN_ALL) {
  -            numColsNeeded = 1;
  -        } else { // EN_NONE
  -            numColsNeeded = curPV.getBodyRegion().getColumnCount();
  -        }
  -        if (numColsNeeded != curPV.getCurrentSpan().getColumnCount()) {
  -            // need a new Span, with numColsNeeded columns
  -            if (curPV.getCurrentSpan().getColumnCount() > 1) {
  -                // finished with current span, so balance 
  -                // its columns to make them the same "height"
  -                // balanceColumns();  // TODO: implement
  -            }
  -            bNeedNewSpan = true;
  -        }
  -        if (bNeedNewSpan) {
  -            curPV.createSpan(span == Constants.EN_ALL);
  -            curFlowIdx = 0;
  -        }
  -    }
       
       /**
        * This is called from FlowLayoutManager when it needs to start
  @@ -527,8 +455,6 @@
           int aclass = childArea.getAreaClass();
   
           if (aclass == Area.CLASS_NORMAL) {
  -            //We now do this in PageBreaker
  -            //prepareNormalFlowArea(childArea);
               return curPV.getCurrentSpan().getNormalFlow(curFlowIdx);
           } else if (aclass == Area.CLASS_BEFORE_FLOAT) {
               return curPV.getBodyRegion().getBeforeFloat();
  @@ -543,12 +469,10 @@
        * Depending on the kind of break condition, make new column
        * or page. May need to make an empty page if next page would
        * not have the desired "handedness".
  -     *
  -     * @param breakBefore - the break-before trait of the area
  -     * currently being processed.
  +     * @param breakVal - value of break-before or break-after trait.
        */
  -    private void handleBreakBefore(int breakBefore) {
  -        if (breakBefore == Constants.EN_COLUMN) {
  +    private void handleBreakTrait(int breakVal) {
  +        if (breakVal == Constants.EN_COLUMN) {
               if (curFlowIdx < curPV.getCurrentSpan().getColumnCount()) {
                   // Move to next column
                   curFlowIdx++;
  @@ -558,11 +482,11 @@
               return;
           }
           log.debug("handling break-before after page " + currentPageNum 
  -            + " breakVal=" + breakBefore);
  -        if (needEmptyPage(breakBefore)) {
  +            + " breakVal=" + breakVal);
  +        if (needBlankPageBeforeNew(breakVal)) {
               curPV = makeNewPage(true, false, false);
           }
  -        if (needNewPage(breakBefore)) {
  +        if (needNewPage(breakVal)) {
               curPV = makeNewPage(false, false, false);
           }
       }
  @@ -574,34 +498,36 @@
        * Note that if not all content is placed, we aren't sure whether
        * it will flow onto another page or not, so we'd probably better
        * block until the queue of layoutable stuff is empty!
  +     * @param breakVal - value of break-before or break-after trait.
        */
  -    private boolean needEmptyPage(int breakBefore) {
  -        if (breakBefore == Constants.EN_PAGE || (curPV.getPage().isEmpty())) {
  +    private boolean needBlankPageBeforeNew(int breakVal) {
  +        if (breakVal == Constants.EN_PAGE || (curPV.getPage().isEmpty())) {
               // any page is OK or we already have an empty page
               return false;
           } else {
               /* IF we are on the kind of page we need, we'll need a new page. */
               if (currentPageNum % 2 == 0) { // even page
  -                return (breakBefore == Constants.EN_EVEN_PAGE);
  +                return (breakVal == Constants.EN_EVEN_PAGE);
               } else { // odd page
  -                return (breakBefore == Constants.EN_ODD_PAGE);
  +                return (breakVal == Constants.EN_ODD_PAGE);
               }
           }
       }
   
       /**
        * See if need to generate a new page
  +     * @param breakVal - value of break-before or break-after trait.
        */
  -    private boolean needNewPage(int breakBefore) {
  +    private boolean needNewPage(int breakVal) {
           if (curPV.getPage().isEmpty()) {
  -            if (breakBefore == Constants.EN_PAGE) {
  +            if (breakVal == Constants.EN_PAGE) {
                   return false;
               }
               else if (currentPageNum % 2 == 0) { // even page
  -                return (breakBefore == Constants.EN_ODD_PAGE);
  +                return (breakVal == Constants.EN_ODD_PAGE);
               }
               else { // odd page
  -                return (breakBefore == Constants.EN_EVEN_PAGE);
  +                return (breakVal == Constants.EN_EVEN_PAGE);
               }
           } else {
               return true;
  
  
  
  1.1.2.7   +8 -1      xml-fop/src/java/org/apache/fop/layoutmgr/Attic/AbstractBreaker.java
  
  Index: AbstractBreaker.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/Attic/AbstractBreaker.java,v
  retrieving revision 1.1.2.6
  retrieving revision 1.1.2.7
  diff -u -r1.1.2.6 -r1.1.2.7
  --- AbstractBreaker.java	27 Apr 2005 15:59:59 -0000	1.1.2.6
  +++ AbstractBreaker.java	7 May 2005 04:28:28 -0000	1.1.2.7
  @@ -50,6 +50,13 @@
   
       public class BlockSequence extends KnuthSequence {
   
  +        /**
  +         * startOn represents where on the page/which page layout
  +         * should start for this BlockSequence.  Acceptable values:
  +         * Constants.EN_ANY (can continue from finished location 
  +         * of previous BlockSequence?), EN_COLUMN, EN_ODD_PAGE, 
  +         * EN_EVEN_PAGE. 
  +         */
           private int startOn;
   
           public BlockSequence(int iStartOn) {
  
  
  

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