From: Jeremias Maerki Date: Mon, 7 Feb 2005 16:26:13 +0000 (+0000) Subject: Support for border-spacing shorthand. X-Git-Tag: Root_Temp_KnuthStylePageBreaking~118 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=83371d2d601858d8938c8468a361b9b67a66038c;p=xmlgraphics-fop.git Support for border-spacing shorthand. Accessor for border-separation on table. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@198389 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/fop/fo/FOPropertyMapping.java b/src/java/org/apache/fop/fo/FOPropertyMapping.java index f7ae53372..b7ebace99 100644 --- a/src/java/org/apache/fop/fo/FOPropertyMapping.java +++ b/src/java/org/apache/fop/fo/FOPropertyMapping.java @@ -23,6 +23,7 @@ import java.util.Map; 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; @@ -2296,7 +2297,8 @@ public class FOPropertyMapping implements Constants { 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); @@ -2309,6 +2311,7 @@ public class FOPropertyMapping implements Constants { // 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"); @@ -2589,9 +2592,10 @@ public class FOPropertyMapping implements Constants { 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 diff --git a/src/java/org/apache/fop/fo/flow/Table.java b/src/java/org/apache/fop/fo/flow/Table.java index 3b9d6b81e..1cb67c134 100644 --- a/src/java/org/apache/fop/fo/flow/Table.java +++ b/src/java/org/apache/fop/fo/flow/Table.java @@ -199,6 +199,11 @@ public class Table extends FObj { public int getBreakBefore() { return breakBefore; } + + /** @return the "border-separation" property. */ + public LengthPairProperty getBorderSeparation() { + return borderSeparation; + } /** * @return the "id" property. diff --git a/src/java/org/apache/fop/fo/properties/BorderSpacingShorthandParser.java b/src/java/org/apache/fop/fo/properties/BorderSpacingShorthandParser.java new file mode 100644 index 000000000..360fb1aae --- /dev/null +++ b/src/java/org/apache/fop/fo/properties/BorderSpacingShorthandParser.java @@ -0,0 +1,47 @@ +/* + * 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"); + } +} diff --git a/src/java/org/apache/fop/fo/properties/LengthPairProperty.java b/src/java/org/apache/fop/fo/properties/LengthPairProperty.java index b782d9b06..a982c2adc 100644 --- a/src/java/org/apache/fop/fo/properties/LengthPairProperty.java +++ b/src/java/org/apache/fop/fo/properties/LengthPairProperty.java @@ -1,5 +1,5 @@ /* - * 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. @@ -36,7 +36,7 @@ public class LengthPairProperty extends Property implements CompoundDatatype { 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); @@ -54,8 +54,7 @@ public class LengthPairProperty extends Property implements CompoundDatatype { * @see CompoundPropertyMaker#convertProperty */ public Property convertProperty(Property p, PropertyList propertyList, FObj fo) - throws PropertyException - { + throws PropertyException { if (p instanceof LengthPairProperty) { return p; } @@ -63,6 +62,33 @@ public class LengthPairProperty extends Property implements CompoundDatatype { } } + /** + * 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) */ @@ -102,10 +128,11 @@ public class LengthPairProperty extends Property implements CompoundDatatype { 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() + "]"; } /**