import org.apache.fop.datatypes.LengthBase;
import org.apache.fop.fo.expr.PropertyException;
+import org.apache.fop.fo.properties.BorderSpacingShorthandParser;
import org.apache.fop.fo.properties.BorderWidthPropertyMaker;
import org.apache.fop.fo.properties.BoxPropShorthandParser;
import org.apache.fop.fo.properties.CharacterProperty;
m.setInherited(true);
m.setDefault("collapse");
m.addEnum("separate", getEnumProperty(EN_SEPARATE, "SEPARATE"));
- m.addEnum("collapse-with-precedence", getEnumProperty(EN_COLLAPSE_WITH_PRECEDENCE, "COLLAPSE_WITH_PRECEDENCE"));
+ m.addEnum("collapse-with-precedence", getEnumProperty(
+ EN_COLLAPSE_WITH_PRECEDENCE, "COLLAPSE_WITH_PRECEDENCE"));
m.addEnum("collapse", getEnumProperty(EN_COLLAPSE, "COLLAPSE"));
addPropertyMaker("border-collapse", m);
// border-separation
m = new LengthPairProperty.Maker(PR_BORDER_SEPARATION);
m.setInherited(true);
+ m.addShorthand(s_generics[PR_BORDER_SPACING]);
sub = new LengthProperty.Maker(CP_BLOCK_PROGRESSION_DIRECTION);
sub.setDefault("0pt");
addPropertyMaker("border-style", m);
// border-spacing
- m = new ToBeImplementedProperty.Maker(PR_BORDER_SPACING);
+ m = new ListProperty.Maker(PR_BORDER_SPACING);
m.setInherited(true);
m.setDefault("0pt");
+ m.setDatatypeParser(new BorderSpacingShorthandParser());
addPropertyMaker("border-spacing", m);
// border-top
public int getBreakBefore() {
return breakBefore;
}
+
+ /** @return the "border-separation" property. */
+ public LengthPairProperty getBorderSeparation() {
+ return borderSeparation;
+ }
/**
* @return the "id" property.
--- /dev/null
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.fo.properties;
+
+import java.util.List;
+
+import org.apache.fop.fo.PropertyList;
+import org.apache.fop.fo.expr.PropertyException;
+
+/**
+ * Shorthand parser for the "border-spacing" shorthand property.
+ */
+public class BorderSpacingShorthandParser extends GenericShorthandParser {
+
+ protected Property convertValueForProperty(int propId, Property property,
+ PropertyMaker maker, PropertyList propertyList)
+ throws PropertyException {
+ List lst = property.getList();
+ if (lst != null) {
+ if (lst.size() == 1) {
+ Property len = (Property)lst.get(0);
+ return new LengthPairProperty(len);
+ } else if (lst.size() == 2) {
+ Property ipd = (Property)lst.get(0);
+ Property bpd = (Property)lst.get(1);
+ return new LengthPairProperty(ipd, bpd);
+ }
+ }
+ throw new PropertyException("list with 1 or 2 length values expected");
+ }
+}
/*
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Copyright 1999-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
public static class Maker extends CompoundPropertyMaker {
/**
- * @param name name of property for which this Maker should be created
+ * @param propId name of property for which this Maker should be created
*/
public Maker(int propId) {
super(propId);
* @see CompoundPropertyMaker#convertProperty
*/
public Property convertProperty(Property p, PropertyList propertyList, FObj fo)
- throws PropertyException
- {
+ throws PropertyException {
if (p instanceof LengthPairProperty) {
return p;
}
}
}
+ /**
+ * Creates a new LengthPairProperty with empty values.
+ */
+ public LengthPairProperty() {
+ super();
+ }
+
+ /**
+ * Creates a new LengthPairProperty.
+ * @param ipd inline-progression-dimension
+ * @param bpd block-progression-dimension
+ */
+ public LengthPairProperty(Property ipd, Property bpd) {
+ this();
+ this.ipd = ipd;
+ this.bpd = bpd;
+ }
+
+ /**
+ * Creates a new LengthPairProperty which sets both bpd and ipd to the
+ * same value.
+ * @param len length for both dimensions
+ */
+ public LengthPairProperty(Property len) {
+ this(len, len);
+ }
+
/**
* @see org.apache.fop.datatypes.CompoundDatatype#setComponent(int, Property, boolean)
*/
return this.bpd;
}
+ /** @see java.lang.Object#toString() */
public String toString() {
- return "LengthPair[" +
- "ipd:" + getIPD().getObject() +
- ", bpd:" + getBPD().getObject() + "]";
+ return "LengthPair["
+ + "ipd:" + getIPD().getObject()
+ + ", bpd:" + getBPD().getObject() + "]";
}
/**