diff options
author | Karen Lease <klease@apache.org> | 2001-01-02 21:32:20 +0000 |
---|---|---|
committer | Karen Lease <klease@apache.org> | 2001-01-02 21:32:20 +0000 |
commit | 3e1bbd3722e489d4c3c86288f414db6eb1270f76 (patch) | |
tree | 29b0d6c7c7939afe618fa39804143860040e2054 | |
parent | 93d72752b8649dc13202250534f30b80d9df031b (diff) | |
download | xmlgraphics-fop-3e1bbd3722e489d4c3c86288f414db6eb1270f76.tar.gz xmlgraphics-fop-3e1bbd3722e489d4c3c86288f414db6eb1270f76.zip |
Modify handling of compound datatypes
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@193939 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | src/org/apache/fop/datatypes/CompoundDatatype.java | 59 | ||||
-rw-r--r-- | src/org/apache/fop/datatypes/CondLength.java | 55 | ||||
-rw-r--r-- | src/org/apache/fop/datatypes/Keep.java | 116 | ||||
-rw-r--r-- | src/org/apache/fop/datatypes/LengthRange.java | 48 | ||||
-rw-r--r-- | src/org/apache/fop/datatypes/Space.java | 48 |
5 files changed, 266 insertions, 60 deletions
diff --git a/src/org/apache/fop/datatypes/CompoundDatatype.java b/src/org/apache/fop/datatypes/CompoundDatatype.java new file mode 100644 index 000000000..820eab327 --- /dev/null +++ b/src/org/apache/fop/datatypes/CompoundDatatype.java @@ -0,0 +1,59 @@ +/*-- $Id$ -- + + ============================================================================ + The Apache Software License, Version 1.1 + ============================================================================ + + Copyright (C) 1999 The Apache Software Foundation. All rights reserved. + + Redistribution and use in source and binary forms, with or without modifica- + tion, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + 3. The end-user documentation included with the redistribution, if any, must + include the following acknowledgment: "This product includes software + developed by the Apache Software Foundation (http://www.apache.org/)." + Alternately, this acknowledgment may appear in the software itself, if + and wherever such third-party acknowledgments normally appear. + + 4. The names "Fop" and "Apache Software Foundation" must not be used to + endorse or promote products derived from this software without prior + written permission. For written permission, please contact + apache@apache.org. + + 5. Products derived from this software may not be called "Apache", nor may + "Apache" appear in their name, without prior written permission of the + Apache Software Foundation. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + This software consists of voluntary contributions made by many individuals + on behalf of the Apache Software Foundation and was originally created by + James Tauber <jtauber@jtauber.com>. For more information on the Apache + Software Foundation, please see <http://www.apache.org/>. + + */ +package org.apache.fop.datatypes; +import org.apache.fop.fo.Property; + +public interface CompoundDatatype { + public void setComponent(String sCmpnName, Property cmpnValue, + boolean bIsDefault); + + public Property getComponent(String sCmpnName); +} diff --git a/src/org/apache/fop/datatypes/CondLength.java b/src/org/apache/fop/datatypes/CondLength.java index 019f43e51..6114d4da8 100644 --- a/src/org/apache/fop/datatypes/CondLength.java +++ b/src/org/apache/fop/datatypes/CondLength.java @@ -50,46 +50,37 @@ */ package org.apache.fop.datatypes; +import org.apache.fop.fo.Property; /** * a space quantity in XSL (space-before, space-after) */ -public class CondLength extends Length { +public class CondLength implements CompoundDatatype { - /** Values for conditionality. Specified as a string value. */ - public static final int DISCARD = 0; - public static final int RETAIN = 1; + private Property length; + private Property conditionality; - private int conditionality=DISCARD ; + // From CompoundDatatype + public void setComponent(String sCmpnName, Property cmpnValue, + boolean bIsDefault) { + if (sCmpnName.equals("length")) + length = cmpnValue; + else if (sCmpnName.equals("conditionality")) + conditionality = cmpnValue; + } - public CondLength () { - super(0); - } - - public CondLength (Length l) { - super(l.mvalue()); - } - - public void setLength(Length l, boolean bIsDefault) { - setValue(l.mvalue()); - } + public Property getComponent(String sCmpnName) { + if (sCmpnName.equals("length")) + return length; + else if (sCmpnName.equals("conditionality")) + return conditionality ; + else return null; + } - public void setConditionality(String conditionality, boolean bIsDefault) { - if (conditionality.equals("retain")) - this.conditionality = Space.RETAIN; - else if (conditionality.equals("discard")) - this.conditionality = Space.DISCARD; - // else unrecognized value + public Property getConditionality() { + return this.conditionality ; } - public String getConditionality() { - return ((this.conditionality == DISCARD)? "discard" : "retain"); - } - - public Length getLength() { - return this; - } - - public boolean isDiscard() { - return (conditionality==DISCARD); + public Property getLength() { + return this.length; } } diff --git a/src/org/apache/fop/datatypes/Keep.java b/src/org/apache/fop/datatypes/Keep.java new file mode 100644 index 000000000..99971f713 --- /dev/null +++ b/src/org/apache/fop/datatypes/Keep.java @@ -0,0 +1,116 @@ +/*-- $Id$ -- + + ============================================================================ + The Apache Software License, Version 1.1 + ============================================================================ + + Copyright (C) 1999 The Apache Software Foundation. All rights reserved. + + Redistribution and use in source and binary forms, with or without modifica- + tion, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + 3. The end-user documentation included with the redistribution, if any, must + include the following acknowledgment: "This product includes software + developed by the Apache Software Foundation (http://www.apache.org/)." + Alternately, this acknowledgment may appear in the software itself, if + and wherever such third-party acknowledgments normally appear. + + 4. The names "Fop" and "Apache Software Foundation" must not be used to + endorse or promote products derived from this software without prior + written permission. For written permission, please contact + apache@apache.org. + + 5. Products derived from this software may not be called "Apache", nor may + "Apache" appear in their name, without prior written permission of the + Apache Software Foundation. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + This software consists of voluntary contributions made by many individuals + on behalf of the Apache Software Foundation and was originally created by + James Tauber <jtauber@jtauber.com>. For more information on the Apache + Software Foundation, please see <http://www.apache.org/>. + + */ +package org.apache.fop.datatypes; + +import org.apache.fop.fo.Property; + +/** + * XSL FO Keep Property datatype (keep-together, etc) + */ +public class Keep implements CompoundDatatype { + private Property withinLine; + private Property withinColumn; + private Property withinPage; + + public Keep () { + } + + // From CompoundDatatype + public void setComponent(String sCmpnName, Property cmpnValue, + boolean bIsDefault) { + if (sCmpnName.equals("within-line")) + setWithinLine(cmpnValue, bIsDefault); + else if (sCmpnName.equals("within-column")) + setWithinColumn(cmpnValue, bIsDefault); + else if (sCmpnName.equals("within-page")) + setWithinPage(cmpnValue, bIsDefault); + } + + // From CompoundDatatype + public Property getComponent(String sCmpnName) { + if (sCmpnName.equals("within-line")) + return getWithinLine(); + else if (sCmpnName.equals("within-column")) + return getWithinColumn(); + else if (sCmpnName.equals("within-page")) + return getWithinPage(); + else return null; + } + + public void setWithinLine(Property withinLine, boolean bIsDefault) { + this.withinLine = withinLine; + } + + protected void setWithinColumn(Property withinColumn, boolean bIsDefault) { + this.withinColumn = withinColumn; + } + + public void setWithinPage(Property withinPage, boolean bIsDefault) { + this.withinPage = withinPage; + } + + public Property getWithinLine() { + return this.withinLine; + } + + public Property getWithinColumn() { + return this.withinColumn; + } + + public Property getWithinPage() { + return this.withinPage; + } + + /** What to do here?? There isn't really a meaningful single value. */ + public String toString() { + return "Keep"; + } +} diff --git a/src/org/apache/fop/datatypes/LengthRange.java b/src/org/apache/fop/datatypes/LengthRange.java index 093414264..d6e99a889 100644 --- a/src/org/apache/fop/datatypes/LengthRange.java +++ b/src/org/apache/fop/datatypes/LengthRange.java @@ -51,23 +51,45 @@ package org.apache.fop.datatypes; import org.apache.fop.messaging.MessageHandler; +import org.apache.fop.fo.Property; /** * a "progression-dimension" quantity * ex. block-progression-dimension, inline-progression-dimension * corresponds to the triplet min-height, height, max-height (or width) */ -public class LengthRange { +public class LengthRange implements CompoundDatatype { - private Length minimum; - private Length optimum; - private Length maximum; + private Property minimum; + private Property optimum; + private Property maximum; private static final int MINSET=1; private static final int OPTSET=2; private static final int MAXSET=4; private int bfSet = 0; // bit field private boolean bChecked = false; + // From CompoundDatatype + public void setComponent(String sCmpnName, Property cmpnValue, + boolean bIsDefault) { + if (sCmpnName.equals("minimum")) + setMinimum(cmpnValue, bIsDefault); + else if (sCmpnName.equals("optimum")) + setOptimum(cmpnValue, bIsDefault); + else if (sCmpnName.equals("maximum")) + setMaximum(cmpnValue, bIsDefault); + } + + // From CompoundDatatype + public Property getComponent(String sCmpnName) { + if (sCmpnName.equals("minimum")) + return getMinimum(); + else if (sCmpnName.equals("optimum")) + return getOptimum(); + else if (sCmpnName.equals("maximum")) + return getMaximum(); + else return null; // SHOULDN'T HAPPEN + } /** * Set minimum value to min. @@ -76,18 +98,19 @@ public class LengthRange { * @param bIsDefault If true, this is set as a "default" value * and not a user-specified explicit value. */ - public void setMinimum(Length min, boolean bIsDefault) { - minimum = min; + protected void setMinimum(Property minimum, boolean bIsDefault) { + this.minimum = minimum; if (!bIsDefault) bfSet |= MINSET; } + /** * Set maximum value to max if it is >= optimum or optimum isn't set. * @param max A Length value specifying the maximum value for this * @param bIsDefault If true, this is set as a "default" value * and not a user-specified explicit value. */ - public void setMaximum(Length max, boolean bIsDefault) { + protected void setMaximum(Property max, boolean bIsDefault) { maximum = max; if (!bIsDefault) bfSet |= MAXSET; } @@ -99,7 +122,7 @@ public class LengthRange { * @param bIsDefault If true, this is set as a "default" value * and not a user-specified explicit value. */ - public void setOptimum(Length opt, boolean bIsDefault) { + protected void setOptimum(Property opt, boolean bIsDefault) { optimum = opt; if (!bIsDefault) bfSet |= OPTSET; } @@ -108,6 +131,8 @@ public class LengthRange { private void checkConsistency() { if (bChecked) return; // Make sure max >= min + // Must also control if have any allowed enum values! + /********************* if (minimum.mvalue() > maximum.mvalue()) { if ((bfSet&MINSET)!=0) { // if minimum is explicit, force max to min @@ -150,20 +175,21 @@ public class LengthRange { minimum = optimum; // minimum was default value } } + ********$*********/ bChecked = true; } - public Length getMinimum() { + public Property getMinimum() { checkConsistency(); return this.minimum; } - public Length getMaximum() { + public Property getMaximum() { checkConsistency(); return this.maximum; } - public Length getOptimum() { + public Property getOptimum() { checkConsistency(); return this.optimum; } diff --git a/src/org/apache/fop/datatypes/Space.java b/src/org/apache/fop/datatypes/Space.java index 378172f9d..4b5fb9409 100644 --- a/src/org/apache/fop/datatypes/Space.java +++ b/src/org/apache/fop/datatypes/Space.java @@ -50,40 +50,54 @@ */ package org.apache.fop.datatypes; +import org.apache.fop.fo.Property; + /** * a space quantity in XSL (space-before, space-after) */ public class Space extends LengthRange { - /** Values for conditionality. Specified as a string value. */ - public static final int DISCARD = 0; - public static final int RETAIN = 1; - - //private Precedence precedence; - private Number precedence; - private int conditionality=DISCARD ; + private Property precedence; + private Property conditionality ; - public void setPrecedence(Number precedence, boolean bIsDefault) { + // From CompoundDatatype + public void setComponent(String sCmpnName, Property cmpnValue, + boolean bIsDefault) { + if (sCmpnName.equals("precedence")) + setPrecedence(cmpnValue, bIsDefault); + else if (sCmpnName.equals("conditionality")) + setConditionality(cmpnValue, bIsDefault); + else super.setComponent(sCmpnName, cmpnValue, bIsDefault); + } + + // From CompoundDatatype + public Property getComponent(String sCmpnName) { + if (sCmpnName.equals("precedence")) + return getPrecedence(); + else if (sCmpnName.equals("conditionality")) + return getConditionality(); + else return super.getComponent(sCmpnName); + } + + protected void setPrecedence(Property precedence, boolean bIsDefault) { this.precedence = precedence; } - public void setConditionality(String conditionality, boolean bIsDefault) { - if (conditionality.equals("retain")) - this.conditionality = Space.RETAIN; - else if (conditionality.equals("discard")) - this.conditionality = Space.DISCARD; - // else unrecognized value + protected void setConditionality(Property conditionality, boolean bIsDefault) { + this.conditionality = conditionality; } - public Number getPrecedence() { + public Property getPrecedence() { return this.precedence ; } + /* public boolean isDiscard() { return (this.conditionality == DISCARD); } + */ - public String getConditionality() { - return ((this.conditionality == DISCARD)? "discard" : "retain"); + public Property getConditionality() { + return this.conditionality ; } } |