--- /dev/null
+/*-- $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);
+}
*/
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;
}
}
--- /dev/null
+/*-- $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";
+ }
+}
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.
* @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;
}
* @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;
}
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
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;
}
*/
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 ;
}
}