From 3d9c0841e9c45fa0708c19a6526f26cdfb55f926 Mon Sep 17 00:00:00 2001 From: Finn Bock Date: Tue, 7 Sep 2004 20:14:51 +0000 Subject: [PATCH] Make maximum-repeats a number property instead of a string. This add support for expression. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197932 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/fop/fo/FOPropertyMapping.java | 3 ++- .../RepeatablePageMasterAlternatives.java | 21 ++++++++----------- .../RepeatablePageMasterReference.java | 20 +++++++----------- 3 files changed, 19 insertions(+), 25 deletions(-) diff --git a/src/java/org/apache/fop/fo/FOPropertyMapping.java b/src/java/org/apache/fop/fo/FOPropertyMapping.java index 67f26fb7c..810087799 100644 --- a/src/java/org/apache/fop/fo/FOPropertyMapping.java +++ b/src/java/org/apache/fop/fo/FOPropertyMapping.java @@ -2081,8 +2081,9 @@ public class FOPropertyMapping implements Constants { addPropertyMaker("master-reference", m); // maximum-repeats - m = new StringProperty.Maker(PR_MAXIMUM_REPEATS); + m = new NumberProperty.Maker(PR_MAXIMUM_REPEATS); m.setInherited(false); + m.addEnum("no-limit", makeEnumProperty(NO_LIMIT, "NO_LIMIT")); m.setDefault("no-limit"); addPropertyMaker("maximum-repeats", m); diff --git a/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java b/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java index 300d8d8d3..545d53b82 100644 --- a/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java +++ b/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.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; /** * A repeatable-page-master-alternatives formatting object. @@ -94,20 +95,16 @@ public class RepeatablePageMasterAlternatives extends FObj + parent.getName(), locator); } - String mr = getProperty(PR_MAXIMUM_REPEATS).getString(); - if (mr.equals("no-limit")) { + Property mr = getProperty(PR_MAXIMUM_REPEATS); + + if (mr.getEnum() == NO_LIMIT) { this.maximumRepeats = INFINITE; } else { - try { - this.maximumRepeats = Integer.parseInt(mr); - if (this.maximumRepeats < 0) { - getLogger().debug("negative maximum-repeats: " - + this.maximumRepeats); - this.maximumRepeats = 0; - } - } catch (NumberFormatException nfe) { - throw new SAXParseException("Invalid number for " - + "'maximum-repeats' property", locator); + this.maximumRepeats = mr.getNumber().intValue(); + if (this.maximumRepeats < 0) { + getLogger().debug("negative maximum-repeats: " + + this.maximumRepeats); + this.maximumRepeats = 0; } } } diff --git a/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java b/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java index 32c8a14b0..4ad7ab074 100644 --- a/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java +++ b/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java @@ -26,6 +26,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; /** * A repeatable-page-master-reference formatting object. @@ -62,21 +63,16 @@ public class RepeatablePageMasterReference extends FObj pageSequenceMaster.addSubsequenceSpecifier(this); } - String mr = getPropString(PR_MAXIMUM_REPEATS); + Property mr = getProperty(PR_MAXIMUM_REPEATS); - if (mr.equals("no-limit")) { + if (mr.getEnum() == NO_LIMIT) { this.maximumRepeats = INFINITE; } else { - try { - this.maximumRepeats = Integer.parseInt(mr); - if (this.maximumRepeats < 0) { - getLogger().debug("negative maximum-repeats: " - + this.maximumRepeats); - this.maximumRepeats = 0; - } - } catch (NumberFormatException nfe) { - throw new SAXParseException("Invalid number for " - + "'maximum-repeats' property", locator); + this.maximumRepeats = mr.getNumber().intValue(); + if (this.maximumRepeats < 0) { + getLogger().debug("negative maximum-repeats: " + + this.maximumRepeats); + this.maximumRepeats = 0; } } } -- 2.39.5