From 4a3d1a1e38ce79712163988ee61d8910c5ef196d Mon Sep 17 00:00:00 2001 From: Finn Bock Date: Mon, 13 Sep 2004 08:05:34 +0000 Subject: [PATCH] Changed initial-page-number from string to number property. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197947 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/fop/fo/Constants.java | 4 ++- .../org/apache/fop/fo/FOPropertyMapping.java | 5 ++- .../fop/fo/pagination/PageSequence.java | 36 +++++-------------- 3 files changed, 15 insertions(+), 30 deletions(-) diff --git a/src/java/org/apache/fop/fo/Constants.java b/src/java/org/apache/fop/fo/Constants.java index a987fb61d..2a23edece 100644 --- a/src/java/org/apache/fop/fo/Constants.java +++ b/src/java/org/apache/fop/fo/Constants.java @@ -498,7 +498,9 @@ public interface Constants { int LINE_HEIGHT = 108; int MAX_HEIGHT = 109; int NO_LIMIT = 110; - int ENUM_COUNT = 110; + int AUTO_ODD = 111; + int AUTO_EVEN = 112; + int ENUM_COUNT = 112; // Enumeration Interfaces diff --git a/src/java/org/apache/fop/fo/FOPropertyMapping.java b/src/java/org/apache/fop/fo/FOPropertyMapping.java index c9d5b2ea9..21feda5a1 100644 --- a/src/java/org/apache/fop/fo/FOPropertyMapping.java +++ b/src/java/org/apache/fop/fo/FOPropertyMapping.java @@ -2062,8 +2062,11 @@ public class FOPropertyMapping implements Constants { addPropertyMaker("force-page-count", m); // initial-page-number - m = new StringProperty.Maker(PR_INITIAL_PAGE_NUMBER); + m = new NumberProperty.Maker(PR_INITIAL_PAGE_NUMBER); m.setInherited(false); + m.addEnum("auto", makeEnumProperty(AUTO, "AUTO")); + m.addEnum("auto-odd", makeEnumProperty(AUTO_ODD, "AUTO_ODD")); + m.addEnum("auto-even", makeEnumProperty(AUTO_EVEN, "AUTO_EVEN")); m.setDefault("auto"); addPropertyMaker("initial-page-number", m); diff --git a/src/java/org/apache/fop/fo/pagination/PageSequence.java b/src/java/org/apache/fop/fo/pagination/PageSequence.java index c2dd48ebc..2c82affc8 100644 --- a/src/java/org/apache/fop/fo/pagination/PageSequence.java +++ b/src/java/org/apache/fop/fo/pagination/PageSequence.java @@ -29,6 +29,7 @@ import org.xml.sax.SAXParseException; // FOP import org.apache.fop.fo.FONode; import org.apache.fop.fo.FObj; +import org.apache.fop.fo.properties.Property; /** * This provides pagination of flows onto pages. Much of the @@ -40,9 +41,6 @@ public class PageSequence extends FObj { // initial-page-number types // public static final int EXPLICIT = 0; - public static final int AUTO = 1; - public static final int AUTO_EVEN = 2; - public static final int AUTO_ODD = 3; /** * The parent root object @@ -74,7 +72,6 @@ public class PageSequence extends FObj { // // page number and related formatting variables - private String ipnValue; public int currentPageNumber = 0; private int explicitFirstNumber = 0; // explicitly specified public int firstPageNumber = 0; // actual @@ -134,23 +131,15 @@ public class PageSequence extends FObj { // we are now on the first page of the page sequence thisIsFirstPage = true; - ipnValue = getPropString(PR_INITIAL_PAGE_NUMBER); - - if (ipnValue.equals("auto")) { - pageNumberType = AUTO; - } else if (ipnValue.equals("auto-even")) { - pageNumberType = AUTO_EVEN; - } else if (ipnValue.equals("auto-odd")) { - pageNumberType = AUTO_ODD; + Property ipnValue = getProperty(PR_INITIAL_PAGE_NUMBER); + + if (ipnValue.getEnum() != 0) { + // auto | auto-odd | auto-even. + pageNumberType = ipnValue.getEnum(); } else { pageNumberType = EXPLICIT; - try { - int pageStart = new Integer(ipnValue).intValue(); - this.explicitFirstNumber = (pageStart > 0) ? pageStart : 1; - } catch (NumberFormatException nfe) { - throw new SAXParseException("\"" + ipnValue - + "\" is not a valid value for initial-page-number", locator); - } + int pageStart = ipnValue.getNumber().intValue(); + this.explicitFirstNumber = (pageStart > 0) ? pageStart : 1; } String masterName = getPropString(PR_MASTER_REFERENCE); @@ -534,15 +523,6 @@ public class PageSequence extends FObj { // this.isFlowSet = isFlowSet; // } - /** - * Get the "initial-page-number" value. - * - * @return the initial-page-number property value - */ - public String getIpnValue() { - return ipnValue; - } - /** * Get the current page number for this page sequence. * -- 2.39.5