You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by kl...@apache.org on 2001/01/02 22:32:25 UTC
cvs commit: xml-fop/src/org/apache/fop/datatypes Keep.java CompoundDatatype.java Space.java CondLength.java LengthRange.java
klease 01/01/02 13:32:24
Modified: src/org/apache/fop/datatypes Space.java CondLength.java
LengthRange.java
Added: src/org/apache/fop/datatypes Keep.java CompoundDatatype.java
Log:
Modify handling of compound datatypes
Revision Changes Path
1.3 +32 -18 xml-fop/src/org/apache/fop/datatypes/Space.java
Index: Space.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/datatypes/Space.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Space.java 2000/12/16 21:50:24 1.2
+++ Space.java 2001/01/02 21:32:18 1.3
@@ -1,4 +1,4 @@
-/*-- $Id: Space.java,v 1.2 2000/12/16 21:50:24 klease Exp $ --
+/*-- $Id: Space.java,v 1.3 2001/01/02 21:32:18 klease Exp $ --
============================================================================
The Apache Software License, Version 1.1
@@ -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 ;
}
}
1.3 +26 -35 xml-fop/src/org/apache/fop/datatypes/CondLength.java
Index: CondLength.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/datatypes/CondLength.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- CondLength.java 2000/12/16 21:50:24 1.2
+++ CondLength.java 2001/01/02 21:32:19 1.3
@@ -1,4 +1,4 @@
-/*-- $Id: CondLength.java,v 1.2 2000/12/16 21:50:24 klease Exp $ --
+/*-- $Id: CondLength.java,v 1.3 2001/01/02 21:32:19 klease Exp $ --
============================================================================
The Apache Software License, Version 1.1
@@ -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 int conditionality=DISCARD ;
-
- public CondLength () {
- super(0);
- }
-
- public CondLength (Length l) {
- super(l.mvalue());
- }
-
- public void setLength(Length l, boolean bIsDefault) {
- setValue(l.mvalue());
- }
-
- 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
- }
+ private Property length;
+ private Property conditionality;
- public String getConditionality() {
- return ((this.conditionality == DISCARD)? "discard" : "retain");
- }
+ // 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 Property getComponent(String sCmpnName) {
+ if (sCmpnName.equals("length"))
+ return length;
+ else if (sCmpnName.equals("conditionality"))
+ return conditionality ;
+ else return null;
+ }
- public Length getLength() {
- return this;
- }
+ public Property getConditionality() {
+ return this.conditionality ;
+ }
- public boolean isDiscard() {
- return (conditionality==DISCARD);
+ public Property getLength() {
+ return this.length;
}
}
1.3 +38 -12 xml-fop/src/org/apache/fop/datatypes/LengthRange.java
Index: LengthRange.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/datatypes/LengthRange.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- LengthRange.java 2000/12/16 21:50:24 1.2
+++ LengthRange.java 2001/01/02 21:32:20 1.3
@@ -1,4 +1,4 @@
-/*-- $Id: LengthRange.java,v 1.2 2000/12/16 21:50:24 klease Exp $ --
+/*-- $Id: LengthRange.java,v 1.3 2001/01/02 21:32:20 klease Exp $ --
============================================================================
The Apache Software License, Version 1.1
@@ -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 @@
* @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 @@
* @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 @@
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 @@
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;
}
1.1 xml-fop/src/org/apache/fop/datatypes/Keep.java
Index: Keep.java
===================================================================
/*-- $Id: Keep.java,v 1.1 2001/01/02 21:32:18 klease Exp $ --
============================================================================
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 <jt...@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";
}
}
1.1 xml-fop/src/org/apache/fop/datatypes/CompoundDatatype.java
Index: CompoundDatatype.java
===================================================================
/*-- $Id: CompoundDatatype.java,v 1.1 2001/01/02 21:32:18 klease Exp $ --
============================================================================
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 <jt...@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);
}