cvs commit: xml-fop/src/org/apache/fop/fo/pagination PageSequence.java Root.java

2002-07-11 Thread pietsch

pietsch 2002/07/11 18:15:33

  Modified:src/org/apache/fop/fo/pagination Tag: fop-0_20_2-maintain
PageSequence.java Root.java
  Log:
  Rearranged and simplified calculations related to page
  numbering and forced pages.
  Fixed force-page-count=auto
  Removed some cruft.
  
  Revision  ChangesPath
  No   revision
  
  
  No   revision
  
  
  1.39.2.3  +97 -134   xml-fop/src/org/apache/fop/fo/pagination/PageSequence.java
  
  Index: PageSequence.java
  ===
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/pagination/PageSequence.java,v
  retrieving revision 1.39.2.2
  retrieving revision 1.39.2.3
  diff -u -r1.39.2.2 -r1.39.2.3
  --- PageSequence.java 3 Jan 2002 10:39:56 -   1.39.2.2
  +++ PageSequence.java 12 Jul 2002 01:15:33 -  1.39.2.3
  @@ -101,10 +101,12 @@
   private Page currentPage;
   
   // page number and related formatting variables
  -private String ipnValue;
  -private int currentPageNumber = 0;
  +//private String ipnValue;
  +private int firstPageNumber = 0;
   private PageNumberGenerator pageNumberGenerator;
   
  +private int currentPageNumber = 0;
  +
   private int forcePageCount = 0;
   private int pageCount = 0;
   private boolean isForcing = false;
  @@ -115,11 +117,6 @@
   private int pageNumberType;
   
   /**
  - * used to determine whether to calculate auto, auto-even, auto-odd
  - */
  -private boolean thisIsFirstPage;
  -
  -/**
* the current subsequence while formatting a given page sequence
*/
   private SubSequenceSpecifier currentSubsequence;
  @@ -143,7 +140,6 @@
   
   if (parent.getName().equals(fo:root)) {
   this.root = (Root)parent;
  -// this.root.addPageSequence(this);
   }
   else {
   throw new FOPException(page-sequence must be child of root, not 
  @@ -157,21 +153,22 @@
   
   _flowMap = new Hashtable();
   
  -thisIsFirstPage =
  -true;// we are now on the first page of the page sequence
  -ipnValue = this.properties.get(initial-page-number).getString();
  +String ipnValue = this.properties.get(initial-page-number).getString();
   
   if (ipnValue.equals(auto)) {
   pageNumberType = AUTO;
  +this.firstPageNumber = 1;
   } else if (ipnValue.equals(auto-even)) {
   pageNumberType = AUTO_EVEN;
  +this.firstPageNumber = 2;
   } else if (ipnValue.equals(auto-odd)) {
   pageNumberType = AUTO_ODD;
  +this.firstPageNumber = 1;
   } else {
   pageNumberType = EXPLICIT;
   try {
   int pageStart = new Integer(ipnValue).intValue();
  -this.currentPageNumber = (pageStart  0) ? pageStart - 1 : 0;
  +this.firstPageNumber = (pageStart  0) ? pageStart  : 1;
   } catch (NumberFormatException nfe) {
   throw new FOPException(\ + ipnValue
  + \ is not a valid value for 
initial-page-number);
  @@ -219,68 +216,71 @@
   
   this.layoutMasterSet.resetPageMasters();
   
  -int firstAvailPageNumber = 0;
  -do {
  -// makePage() moved to after the page-number computations,
  -// but store the page-number at this point for that method,
  -// since we want the 'current' current page-number...
  -firstAvailPageNumber = this.root.getRunningPageNumberCounter();
  -boolean tempIsFirstPage = false;
  -
  -if (thisIsFirstPage) {
  -tempIsFirstPage = thisIsFirstPage;
  -if (pageNumberType == AUTO) {
  -this.currentPageNumber =
  -this.root.getRunningPageNumberCounter();
  -} else if (pageNumberType == AUTO_ODD) {
  -this.currentPageNumber =
  -this.root.getRunningPageNumberCounter();
  -if (this.currentPageNumber % 2 == 1) {
  -this.currentPageNumber++;
  +PageSequence previousPageSequence=this.root.getPageSequence();
  +if( previousPageSequence!=null ) {
  +currentPageNumber = previousPageSequence.currentPageNumber;
  +if (previousPageSequence.forcePageCount == ForcePageCount.AUTO) {
  +if (pageNumberType == AUTO_ODD) {
  +if (currentPageNumber % 2 == 0) {
  +makeBlankPage(areaTree);
  +}
  +} else if (pageNumberType == AUTO_EVEN) {
  +if (currentPageNumber % 2 == 1) {
  +makeBlankPage(areaTree);
  +}
  +} else if (pageNumberType 

cvs commit: xml-fop/src/org/apache/fop/fo/pagination PageSequence.java Root.java

2001-06-22 Thread keiron

keiron  01/06/22 01:52:08

  Modified:src/org/apache/fop/fo/pagination PageSequence.java Root.java
  Log:
  should handle page number properly, with threads
  and multiple page sequences
  also cleaned up code
  Submitted by: Jeremias Maerki [EMAIL PROTECTED]
  
  Revision  ChangesPath
  1.29  +353 -386  xml-fop/src/org/apache/fop/fo/pagination/PageSequence.java
  
  Index: PageSequence.java
  ===
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/pagination/PageSequence.java,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- PageSequence.java 2001/05/01 01:00:32 1.28
  +++ PageSequence.java 2001/06/22 08:52:08 1.29
  @@ -1,8 +1,7 @@
  -/*-- $Id: PageSequence.java,v 1.28 2001/05/01 01:00:32 arved Exp $ -- 
  - *
  +/*-- $Id: PageSequence.java,v 1.29 2001/06/22 08:52:08 keiron Exp $ --
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
  - * For details on use and redistribution please refer to the 
  - * LICENSE file included with these sources.
  + * For details on use and redistribution please refer to the
  + * LICENSE file included with these sources.
*/
   
   package org.apache.fop.fo.pagination;
  @@ -19,7 +18,7 @@
   import org.apache.fop.layout.AreaTree;
   import org.apache.fop.layout.Page;
   import org.apache.fop.layout.PageMaster;
  -import org.apache.fop.apps.FOPException;   
  +import org.apache.fop.apps.FOPException;
   
   // Java
   import java.util.*;
  @@ -29,15 +28,13 @@
* This provides pagination of flows onto pages. Much of the logic for paginating
* flows is contained in this class. The main entry point is the format method.
*/
  -public class PageSequence extends FObj
  -{
  +public class PageSequence extends FObj {
   //
   // Factory methods
   //
  -public static class Maker extends FObj.Maker
  -{
  -public FObj make(FObj parent, PropertyList propertyList)
  -throws FOPException {
  +public static class Maker extends FObj.Maker {
  +public FObj make(FObj parent,
  + PropertyList propertyList) throws FOPException {
   return new PageSequence(parent, propertyList);
   }
   }
  @@ -74,11 +71,11 @@
   /** the master-name attribute */
   private String masterName;
   
  - // according to communication from Paul Grosso (XSL-List,
  - // 001228, Number 406), confusion in spec section 6.4.5 about
  - // multiplicity of fo:flow in XSL 1.0 is cleared up - one (1)
  - // fo:flow per fo:page-sequence only.
  - private boolean isFlowSet = false;
  +// according to communication from Paul Grosso (XSL-List,
  +// 001228, Number 406), confusion in spec section 6.4.5 about
  +// multiplicity of fo:flow in XSL 1.0 is cleared up - one (1)
  +// fo:flow per fo:page-sequence only.
  +private boolean isFlowSet = false;
   
   //
   // state attributes used during layout
  @@ -88,9 +85,6 @@
   
   private int currentPageNumber = 0;
   
  -/** keeps count of page number from previous PageSequence */
  -private int runningPageNumberCounter = 0;
  -
   /** specifies page numbering type (auto|auto-even|auto-odd|explicit) */
   private int pageNumberType;
   
  @@ -107,78 +101,65 @@
   private String currentPageMasterName;
   
   
  -protected PageSequence(FObj parent, PropertyList propertyList)
  -throws FOPException {
  +protected PageSequence(FObj parent,
  +   PropertyList propertyList) throws FOPException {
   super(parent, propertyList);
   this.name = fo:page-sequence;
   
  -if ( parent.getName().equals(fo:root) )
  -{
  -this.runningPageNumberCounter=0; //else not initialized correctly
  +if (parent.getName().equals(fo:root)) {
   this.root = (Root) parent;
   this.root.addPageSequence(this);
  -}
  -else
  -{
  -throw
  -new FOPException(page-sequence must be child of root, not 
  -+ parent.getName());
  +} else {
  +throw new FOPException(
  +  page-sequence must be child of root, not  +
  +  parent.getName());
   }
  - 
  +
   layoutMasterSet = root.getLayoutMasterSet();
   
  - // best time to run some checks on LayoutMasterSet
  +// best time to run some checks on LayoutMasterSet
   layoutMasterSet.checkRegionNames();
  -
  - _flowMap = new Hashtable();
   
  -thisIsFirstPage=true; // we are now on the first page of the page sequence
  -String ipnValue= this.properties.get(initial-page-number).getString();
  +_flowMap = new Hashtable();
   
  -if ( ipnValue.equals(auto) )
  -{
  -pageNumberType=AUTO;
  -}
  -