<td class="no">
no
</td>
- <td class="no">
- no
+ <td class="partial">
+ partial
</td>
<td align="center">
-
+ [0.91 beta] Enum values other than "inherit" not yet supported.
</td>
</tr>
<tr>
/*
- * Copyright 1999-2005 The Apache Software Foundation.
+ * Copyright 1999-2006 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.
import org.apache.fop.fo.properties.DimensionPropertyMaker;
import org.apache.fop.fo.properties.EnumProperty;
import org.apache.fop.fo.properties.FontFamilyProperty;
+import org.apache.fop.fo.properties.FontShorthandParser;
+import org.apache.fop.fo.properties.FontShorthandProperty;
import org.apache.fop.fo.properties.FontSizePropertyMaker;
import org.apache.fop.fo.properties.FontStretchPropertyMaker;
import org.apache.fop.fo.properties.GenericShorthandParser;
m = new FontFamilyProperty.Maker(PR_FONT_FAMILY);
m.setInherited(true);
m.setDefault("sans-serif");
+ m.addShorthand(s_generics[PR_FONT]);
addPropertyMaker("font-family", m);
// font-selection-strategy
m = new EnumProperty.Maker(PR_FONT_SELECTION_STRATEGY);
m.setInherited(true);
m.addEnum("auto", getEnumProperty(EN_AUTO, "AUTO"));
- m.addEnum("character-by-character", getEnumProperty(EN_CHARACTER_BY_CHARACTER, "CHARACTER_BY_CHARACTER"));
+ m.addEnum("character-by-character", getEnumProperty(
+ EN_CHARACTER_BY_CHARACTER, "CHARACTER_BY_CHARACTER"));
m.setDefault("auto");
addPropertyMaker("font-selection-strategy", m);
m.addEnum("larger", getEnumProperty(EN_LARGER, "LARGER"));
m.addEnum("smaller", getEnumProperty(EN_SMALLER, "SMALLER"));
m.setPercentBase(LengthBase.INH_FONTSIZE);
+ m.addShorthand(s_generics[PR_FONT]);
addPropertyMaker("font-size", m);
// font-stretch
m.addEnum("italic", getEnumProperty(EN_ITALIC, "ITALIC"));
m.addEnum("oblique", getEnumProperty(EN_OBLIQUE, "OBLIQUE"));
m.addEnum("backslant", getEnumProperty(EN_BACKSLANT, "BACKSLANT"));
-
m.setDefault("normal");
+ m.addShorthand(s_generics[PR_FONT]);
addPropertyMaker("font-style", m);
// font-variant
m.addEnum("normal", getEnumProperty(EN_NORMAL, "NORMAL"));
m.addEnum("small-caps", getEnumProperty(EN_SMALL_CAPS, "SMALL_CAPS"));
m.setDefault("normal");
+ m.addShorthand(s_generics[PR_FONT]);
addPropertyMaker("font-variant", m);
// font-weight
m.setInherited(true);
m.addKeyword("normal", "400");
m.addKeyword("bold", "700");
- m.addEnum("bolder",getEnumProperty(EN_BOLDER, "BOLDER"));
- m.addEnum("lighter",getEnumProperty(EN_LIGHTER, "LIGHTER"));
- m.addEnum("100",getEnumProperty(EN_100, "100"));
- m.addEnum("200",getEnumProperty(EN_200, "200"));
- m.addEnum("300",getEnumProperty(EN_300, "300"));
- m.addEnum("400",getEnumProperty(EN_400, "400"));
- m.addEnum("500",getEnumProperty(EN_500, "500"));
- m.addEnum("600",getEnumProperty(EN_600, "600"));
- m.addEnum("700",getEnumProperty(EN_700, "700"));
- m.addEnum("800",getEnumProperty(EN_800, "800"));
- m.addEnum("900",getEnumProperty(EN_900, "900"));
+ m.addEnum("bolder", getEnumProperty(EN_BOLDER, "BOLDER"));
+ m.addEnum("lighter", getEnumProperty(EN_LIGHTER, "LIGHTER"));
+ m.addEnum("100", getEnumProperty(EN_100, "100"));
+ m.addEnum("200", getEnumProperty(EN_200, "200"));
+ m.addEnum("300", getEnumProperty(EN_300, "300"));
+ m.addEnum("400", getEnumProperty(EN_400, "400"));
+ m.addEnum("500", getEnumProperty(EN_500, "500"));
+ m.addEnum("600", getEnumProperty(EN_600, "600"));
+ m.addEnum("700", getEnumProperty(EN_700, "700"));
+ m.addEnum("800", getEnumProperty(EN_800, "800"));
+ m.addEnum("900", getEnumProperty(EN_900, "900"));
m.setDefault("400");
+ m.addShorthand(s_generics[PR_FONT]);
addPropertyMaker("font-weight", m);
}
m = new LineHeightPropertyMaker(PR_LINE_HEIGHT);
m.useGeneric(genericSpace);
m.setInherited(true);
- m.setDefault("normal", true);
m.addKeyword("normal", "1.2");
m.setPercentBase(LengthBase.FONTSIZE);
+ m.setDefault("normal", true);
+ m.addShorthand(s_generics[PR_FONT]);
addPropertyMaker("line-height", m);
// line-height-shift-adjustment
addPropertyMaker("cue", m);
// font
- m = new ToBeImplementedProperty.Maker(PR_FONT);
- m.setInherited(true);
+ m = new FontShorthandProperty.Maker(PR_FONT);
+ m.setInherited(true);
+ m.addEnum("caption", getEnumProperty(EN_CAPTION, "CAPTION"));
+ m.addEnum("icon", getEnumProperty(EN_ICON, "ICON"));
+ m.addEnum("message-box", getEnumProperty(EN_MESSAGE_BOX, "MESSAGE_BOX"));
+ m.addEnum("menu", getEnumProperty(EN_MENU, "MENU"));
+ m.addEnum("small-caption", getEnumProperty(EN_SMALL_CAPTION, "SMALL_CAPTION"));
+ m.addEnum("status-bar", getEnumProperty(EN_STATUS_BAR, "STATUS_BAR"));
m.setDefault("");
+ m.setDatatypeParser(new FontShorthandParser());
addPropertyMaker("font", m);
// margin
/*
- * Copyright 1999-2005 The Apache Software Foundation.
+ * Copyright 1999-2006 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.
/**
* Class containing the collection of properties for a given FObj.
*/
-abstract public class PropertyList {
+public abstract class PropertyList {
// writing-mode index
private int writingMode;
private static boolean[] inheritableProperty;
+ /** reference to the parent FO's propertyList **/
protected PropertyList parentPropertyList = null;
private FObj fobj = null;
/**
* Basic constructor.
+ * @param fObjToAttach the FO this PropertyList should be attached to
* @param parentPropertyList the PropertyList belonging to the new objects
* parent
*/
}
/**
- * @return the FObj object attached to the parentPropetyList
+ * @return the FObj object attached to the parentPropertyList
*/
public FObj getParentFObj() {
if (parentPropertyList != null) {
* @param propId The id of the property whose value is desired.
* @return The value if the property is explicitly set or set by
* a shorthand property, otherwise null.
+ * @throws PropertyException ...
*/
public Property getExplicitOrShorthand(int propId) throws PropertyException {
/* Handle request for one part of a compound property */
* @param propId The ID of the property whose value is desired.
* @return The value if the property is explicitly set, otherwise null.
*/
- abstract public Property getExplicit(int propId);
+ public abstract Property getExplicit(int propId);
/**
* Set an value defined explicitly on this FO.
* @param propId The ID of the property to set.
* @param value The value of the property.
*/
- abstract public void putExplicit(int propId, Property value);
+ public abstract void putExplicit(int propId, Property value);
/**
* Return the value of this property inherited by this FO.
* The property must be inheritable!
* @param propId The ID of the property whose value is desired.
* @return The inherited value, otherwise null.
+ * @throws PropertyException ...
*/
public Property getInherited(int propId) throws PropertyException {
* the default value.
* @param propId The Constants ID of the property whose value is desired.
* @return the Property corresponding to that name
+ * @throws PropertyException ...
*/
public Property get(int propId) throws PropertyException {
return get(propId, true, true);
* this will try to compute it based on other properties, or if it is
* inheritable, to return the inherited value. If all else fails, it returns
* the default value.
+ * @param propId the property's id
+ * @param bTryInherit true for inherited properties, or when the inherited
+ * value is needed
+ * @param bTryDefault true when the default value may be used as a last resort
+ * @return the property
+ * @throws PropertyException ...
*/
public Property get(int propId, boolean bTryInherit,
boolean bTryDefault) throws PropertyException {
* @param propId The ID of the property whose value is desired.
* @return The computed value if the property is explicitly set on some
* ancestor of the current FO, else the initial value.
+ * @throws PropertyException ...
*/
public Property getNearestSpecified(int propId) throws PropertyException {
Property p = null;
* @param propId The Constants ID of the property whose value is desired.
* @return The computed value on the parent or the initial value if this
* FO is the root or is in a different namespace from its parent.
+ * @throws PropertyException ...
*/
public Property getFromParent(int propId) throws PropertyException {
if (parentPropertyList != null) {
* Set writing mode for this FO.
* Use that from the nearest ancestor, including self, which generates
* reference areas, or from root FO if no ancestor found.
+ * @throws PropertyException ...
*/
public void setWritingMode() throws PropertyException {
FObj p = fobj.findNearestAncestorFObj();
case Constants.EN_LR_TB: return lrtb;
case Constants.EN_RL_TB: return rltb;
case Constants.EN_TB_RL: return tbrl;
+ default:
+ //nop
}
return -1;
}
/**
- *
+ * Adds the attributes, passed in by the parser to the PropertyList
+ *
* @param attributes Collection of attributes passed to us from the parser.
- * @throws FOPException If an error occurs while building the PropertyList
*/
public void addAttributesToList(Attributes attributes) {
/*
* If font-size is set on this FO, must set it first, since
* other attributes specified in terms of "ems" depend on it.
*/
- /** @todo When we do "shorthand" properties, must handle the
- * "font" property as well to see if font-size is set.
- */
- attributeName = "font-size";
+ attributeName = "font";
attributeValue = attributes.getValue(attributeName);
convertAttributeToProperty(attributes, attributeName,
- attributeValue);
+ attributeValue);
+ if (attributeValue == null) {
+ /*
+ * font shorthand wasn't specified, so still need to process
+ * explicit font-size
+ */
+ attributeName = "font-size";
+ attributeValue = attributes.getValue(attributeName);
+ convertAttributeToProperty(attributes, attributeName,
+ attributeValue);
+ }
for (int i = 0; i < attributes.getLength(); i++) {
attributeName = attributes.getQName(i);
/*
- * Copyright 2005 The Apache Software Foundation.
+ * Copyright 2005-2006 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.
package org.apache.fop.fo.properties;
-import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.Constants;
import org.apache.fop.fo.FObj;
import org.apache.fop.fo.PropertyList;
import org.apache.fop.fo.expr.PropertyException;
-import org.apache.fop.fo.flow.TableFObj;
import org.apache.fop.fo.flow.TableBody;
+import org.apache.fop.fo.flow.TableFObj;
/**
* Maker class for the column-number property on table-cells and
//if column-number was explicitly specified, force the parent's current
//column index to the specified value, so that the updated index will
- //be the correct initial value for the next cell (see Rec 7.26.8)
+ //be the correct initial value for the next cell/column (see Rec 7.26.8)
if (propertyList.getExplicit(Constants.PR_COLUMN_NUMBER) != null) {
parent.setCurrentColumnIndex(p.getNumeric().getValue());
}
* @param parentFO The parent FO for the FO whose property is being made.
* @return a Property subclass object holding a "compound" property object
* initialized to the default values for each component.
- * @throws PropertyException
+ * @throws PropertyException ...
*/
protected Property makeCompound(PropertyList propertyList, FObj parentFO)
- throws PropertyException
- {
+ throws PropertyException {
Property p = makeNewProperty();
CompoundDatatype data = (CompoundDatatype) p.getObject();
for (int i = 0; i < Constants.COMPOUND_COUNT; i++) {
--- /dev/null
+/*
+ * Copyright 2006 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 org.apache.fop.fo.Constants;
+import org.apache.fop.fo.FObj;
+import org.apache.fop.fo.FOPropertyMapping;
+import org.apache.fop.fo.PropertyList;
+import org.apache.fop.fo.expr.PropertyException;
+
+/**
+ * A shorthand parser for the font shorthand property
+ */
+public class FontShorthandParser extends GenericShorthandParser {
+
+ /**
+ * @see org.apache.fop.fo.properties.ShorthandParser#getValueForProperty()
+ */
+ public Property getValueForProperty(int propId,
+ Property property,
+ PropertyMaker maker,
+ PropertyList propertyList)
+ throws PropertyException {
+
+ int index = -1;
+ Property newProp;
+ switch (propId) {
+ case Constants.PR_FONT_SIZE:
+ index = 0;
+ break;
+ case Constants.PR_FONT_FAMILY:
+ index = 1;
+ break;
+ case Constants.PR_LINE_HEIGHT:
+ index = 2;
+ break;
+ case Constants.PR_FONT_STYLE:
+ index = 3;
+ break;
+ case Constants.PR_FONT_VARIANT:
+ index = 4;
+ break;
+ case Constants.PR_FONT_WEIGHT:
+ index = 5;
+ break;
+ default:
+ //nop
+ }
+ newProp = (Property) property.getList().get(index);
+ return newProp;
+ }
+}
--- /dev/null
+/*
+ * Copyright 2006 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 org.apache.fop.fo.Constants;
+import org.apache.fop.fo.FObj;
+import org.apache.fop.fo.PropertyList;
+import org.apache.fop.fo.expr.PropertyException;
+
+/**
+ * Property subclass for the font shorthand
+ */
+public class FontShorthandProperty extends ListProperty {
+
+ /**
+ * Inner class for creating instances of FontShorthandProperty
+ */
+ public static class Maker extends PropertyMaker {
+
+ private static final int[] PROP_IDS = {
+ Constants.PR_FONT_SIZE, Constants.PR_FONT_FAMILY,
+ Constants.PR_LINE_HEIGHT, Constants.PR_FONT_STYLE,
+ Constants.PR_FONT_VARIANT, Constants.PR_FONT_WEIGHT
+ };
+
+ /**
+ * @param propId ID of the property for which Maker should be created
+ */
+ public Maker(int propId) {
+ super(propId);
+ }
+
+ /**
+ * @see PropertyMaker#make(PropertyList, String, FObj)
+ */
+ public Property make(PropertyList propertyList,
+ String value, FObj fo) throws PropertyException {
+
+ FontShorthandProperty newProp = new FontShorthandProperty();
+ newProp.setSpecifiedValue(value);
+
+ String specVal = value;
+ Property prop = null;
+ if ("inherit".equals(specVal)) {
+ for (int i = PROP_IDS.length; --i >= 0;) {
+ prop = propertyList.getFromParent(PROP_IDS[i]);
+ newProp.addProperty(prop, i);
+ }
+ } else {
+ /* initialize list with nulls */
+ for (int pos = 6; --pos >= 0;) {
+ newProp.addProperty(null, pos);
+ }
+ prop = checkEnumValues(specVal);
+ if (prop == null) {
+ /* not an enum:
+ * value should consist at least of font-size and font-family
+ * separated by a space
+ * mind the possible spaces from quoted font-family names
+ */
+ int spaceIndex = value.indexOf(' ');
+ int quoteIndex = (value.indexOf('\'') == -1)
+ ? value.indexOf('\"') : value.indexOf('\'');
+ if (spaceIndex == -1
+ || (quoteIndex != -1 && spaceIndex > quoteIndex)) {
+ /* no spaces or first space appears after the first
+ * single/double quote, so malformed value string
+ */
+ throw new PropertyException("Invalid property value: "
+ + "font=\"" + value + "\"");
+ }
+ PropertyMaker m = null;
+ int fromIndex = spaceIndex + 1;
+ int toIndex = specVal.length();
+ /* at least one space that appears before the first
+ * single/double quote, so extract the individual properties
+ */
+ boolean fontFamilyParsed = false;
+ int commaIndex = value.indexOf(',');
+ while (!fontFamilyParsed) {
+ /* value contains a (list of) possibly quoted
+ * font-family name(s)
+ */
+ if (commaIndex == -1) {
+ /* no list, just a single name
+ * (or first name in the list)
+ */
+ m = FObj.getPropertyMakerFor(PROP_IDS[1]);
+ prop = m.make(propertyList, specVal.substring(fromIndex), fo);
+ newProp.addProperty(prop, 1);
+ fontFamilyParsed = true;
+ } else {
+ if (quoteIndex != -1 && quoteIndex < commaIndex) {
+ /* a quoted font-family name as first name
+ * in the comma-separated list
+ * fromIndex = index of the first quote
+ */
+ fromIndex = quoteIndex;
+ } else {
+ fromIndex = value.lastIndexOf(' ', commaIndex) + 1;
+ }
+ commaIndex = -1;
+ }
+ }
+ toIndex = fromIndex - 1;
+ fromIndex = value.lastIndexOf(' ', toIndex - 1) + 1;
+ value = specVal.substring(fromIndex, toIndex);
+ int slashIndex = value.indexOf('/');
+ String fontSize = value.substring(0,
+ (slashIndex == -1) ? value.length() : slashIndex);
+ m = FObj.getPropertyMakerFor(PROP_IDS[0]);
+ prop = m.make(propertyList, fontSize, fo);
+ /* need to make sure subsequent call to LineHeightPropertyMaker.make()
+ * doesn't generate the default font-size property...
+ */
+ propertyList.putExplicit(PROP_IDS[0], prop);
+ newProp.addProperty(prop, 0);
+ if (slashIndex != -1) {
+ /* line-height */
+ String lineHeight = value.substring(slashIndex + 1);
+ m = FObj.getPropertyMakerFor(PROP_IDS[2]);
+ prop = m.make(propertyList, lineHeight, fo);
+ newProp.addProperty(prop, 2);
+ }
+ if (fromIndex != 0) {
+ toIndex = fromIndex - 1;
+ value = specVal.substring(0, toIndex);
+ fromIndex = 0;
+ spaceIndex = value.indexOf(' ');
+ do {
+ toIndex = (spaceIndex == -1) ? value.length() : spaceIndex;
+ String val = value.substring(fromIndex, toIndex);
+ for (int i = 6; --i >= 3;) {
+ if (newProp.list.get(i) == null) {
+ /* not set */
+ m = FObj.getPropertyMakerFor(PROP_IDS[i]);
+ val = m.checkValueKeywords(val);
+ prop = m.checkEnumValues(val);
+ if (prop != null) {
+ newProp.addProperty(prop, i);
+ }
+ }
+ }
+ fromIndex = toIndex + 1;
+ spaceIndex = value.indexOf(' ', fromIndex);
+ } while (toIndex != value.length());
+ }
+ } else {
+ //TODO: implement enum values
+ log.warn("Enum values other than \"inherit\""
+ + " not yet supported for the font shorthand.");
+ return null;
+ }
+ }
+ if (newProp.list.get(0) == null || newProp.list.get(1) == null) {
+ throw new PropertyException("Invalid property value: "
+ + "font-size and font-family are required for the font shorthand"
+ + "\nfont=" + value);
+ }
+ return newProp;
+ }
+
+ }
+
+ private void addProperty(Property prop, int pos) {
+ while (list.size() < (pos + 1)) {
+ list.add(null);
+ }
+ list.set(pos, prop);
+ }
+}
* limitations under the License.
*/
-/* $Id: $ */
+/* $Id$ */
package org.apache.fop.fo.properties;
import org.apache.fop.fo.Constants;
import org.apache.fop.fo.PropertyList;
import org.apache.fop.fo.expr.PropertyException;
+/**
+ * Generic shorthand parser for ListProperties
+ */
public class GenericShorthandParser implements ShorthandParser {
/**
}
/**
+ * @param list the ListProperty
* @param index the index into the List of properties
* @return the property from the List of properties at the index parameter
*/
return null;
}
}
-
- // Stores 1 to 3 values for border width, style, color
- // Used for: border, border-top, border-right etc
+
+ /**
+ * @see org.apache.fop.fo.properties.ShorthandParser#getValueForProperty()
+ */
public Property getValueForProperty(int propId,
Property property,
PropertyMaker maker,
* Converts a property name into a Property
* @param propId the property ID in the Constants interface
* @param maker the Property.Maker to be used in the conversion
+ * @param property ...
* @param propertyList the PropertyList from which the Property should be
* extracted
* @return the Property matching the parameters, or null if not found
+ * @throws PropertyException (when?)
*/
protected Property convertValueForProperty(int propId,
Property property,
/**
* Superclass for properties wrapping a Length value.
*/
-abstract public class LengthProperty extends Property
- implements Length, Numeric
-{
+public abstract class LengthProperty extends Property
+ implements Length, Numeric {
+
/**
* Inner class for making instances of LengthProperty
*/
public Property convertProperty(Property p,
PropertyList propertyList,
FObj fo) throws PropertyException {
- Property prop = super.convertProperty(p, propertyList, fo);
- if (prop != null) {
- return prop;
- }
if (p instanceof EnumProperty) {
return new EnumLength(p);
}
if (val != null) {
return (Property) val;
}
+ /* always null ?? */
return convertPropertyDatatype(p, propertyList, fo);
}
/* $Id$ */
package org.apache.fop.fo.properties;
+
import org.apache.fop.datatypes.Numeric;
+import org.apache.fop.fo.Constants;
import org.apache.fop.fo.FObj;
import org.apache.fop.fo.PropertyList;
import org.apache.fop.fo.expr.PropertyException;
super(propId);
}
+ /**
+ * @see PropertyMaker#make(PropertyList, String, FObj)
+ * @throws PropertyException
+ */
+ public Property make(PropertyList propertyList, String value, FObj fo)
+ throws PropertyException {
+ /* if value was specified as a number/length/percentage then
+ * conditionality and precedence components are overridden
+ */
+ Property p = super.make(propertyList, value, fo);
+ p.getSpace().setConditionality(
+ new EnumProperty(Constants.EN_RETAIN, "RETAIN"), true);
+ p.getSpace().setPrecedence(
+ new EnumProperty(Constants.EN_FORCE, "FORCE"), true);
+ return p;
+ }
+
/**
* Recalculate the line-height value based on the nearest specified
* value.
public Property convertProperty(Property p,
PropertyList propertyList,
FObj fo) throws PropertyException {
- Numeric numval = p.getNumeric();
+ Numeric numval = p.getNumeric();
if (numval != null && numval.getDimension() == 0) {
- p = new PercentLength(numval.getNumericValue(), getPercentBase(fo,propertyList));
+ p = new PercentLength(numval.getNumericValue(), getPercentBase(fo, propertyList));
Property spaceProp = super.convertProperty(p, propertyList, fo);
spaceProp.setSpecifiedValue(String.valueOf(numval.getNumericValue()));
return spaceProp;
import org.apache.fop.fo.Constants;
import org.apache.fop.fo.PropertyList;
import org.apache.fop.fo.expr.PropertyException;
-import org.apache.fop.fo.properties.KeepProperty;
/**
* Shorthand parser for page-break-before, page-break-after and page-break-inside.
* values for absolute-position and relative-position.
*/
public class PositionShorthandParser implements ShorthandParser {
+
+ /**
+ * @see org.apache.fop.fo.properties.ShorthandParser#getValueForProperty()
+ */
public Property getValueForProperty(int propId,
Property property,
PropertyMaker maker,
PropertyList propertyList) {
+
int propVal = property.getEnum();
if (propId == Constants.PR_ABSOLUTE_POSITION) {
switch (propVal) {
return new EnumProperty(Constants.EN_ABSOLUTE, "ABSOLUTE");
case Constants.EN_FIXED:
return new EnumProperty(Constants.EN_FIXED, "FIXED");
+ default:
+ //nop
}
}
if (propId == Constants.PR_RELATIVE_POSITION) {
return new EnumProperty(Constants.EN_STATIC, "STATIC");
case Constants.EN_FIXED:
return new EnumProperty(Constants.EN_STATIC, "STATIC");
+ default:
+ //nop
}
}
return null;
private PropertyMaker[] shorthands = null;
private ShorthandParser datatypeParser;
+ /** default property **/
protected Property defaultProperty;
+ /** Maker for 'corresponding' properties **/
protected CorrespondingPropertyMaker corresponding;
/**
p = corresponding.compute(propertyList);
} else {
p = propertyList.getExplicit(propId);
- if (p == null) {
- p = this.compute(propertyList);
- }
if (p == null) { // check for shorthand specification
p = getShorthand(propertyList);
}
+ if (p == null) {
+ p = this.compute(propertyList);
+ }
}
if (p == null && tryInherit) {
// else inherit (if has parent and is inheritable)
newProp = convertProperty(newProp, propertyList, fo);
}
if (newProp == null) {
- throw new org.apache.fop.fo.expr.PropertyException(
- "No conversion defined " + pvalue);
+ throw new PropertyException("No conversion defined " + pvalue);
}
return newProp;
} catch (PropertyException propEx) {
return baseProperty;
}
+ /**
+ * Converts a shorthand property
+ *
+ * @param propertyList the propertyList for which to convert
+ * @param prop the shorthand property
+ * @param fo ...
+ * @return the converted property
+ * @throws PropertyException ...
+ */
public Property convertShorthandProperty(PropertyList propertyList,
Property prop, FObj fo)
throws PropertyException {
// If value is a name token, may be keyword or Enum
String sval = prop.getNCname();
if (sval != null) {
- //log.debug("Convert shorthand ncname " + sval);
+ log.debug("Convert shorthand ncname " + sval);
pret = checkEnumValues(sval);
if (pret == null) {
/* Check for keyword shorthand values to be substituted. */
String pvalue = checkValueKeywords(sval);
if (!pvalue.equals(sval)) {
- // log.debug("Convert shorthand keyword" + pvalue);
+ log.debug("Convert shorthand keyword" + pvalue);
// Substituted a value: must parse it
Property p = PropertyParser.parse(pvalue,
new PropertyInfo(this,
}
/**
- * @see org.apache.fop.fo.properties.CorrespondingPropertyMaker#compute(org.apache.fop.fo.PropertyList)
+ * @see org.apache.fop.fo.properties.CorrespondingPropertyMaker#compute(PropertyList)
*/
public Property compute(PropertyList propertyList) throws PropertyException {
Property prop = super.compute(propertyList);
<changes>
<release version="FOP Trunk">
+ <action context="Code" dev="AD" type="add">
+ Added support for the font shorthand property.
+ </action>
<action context="Code" dev="JM" type="add" fixes-bug="38618" due-to="Max Berger">
Added support for system-color() function.
</action>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!--\r
+ Copyright 2005 The Apache Software Foundation\r
+\r
+ Licensed under the Apache License, Version 2.0 (the "License");\r
+ you may not use this file except in compliance with the License.\r
+ You may obtain a copy of the License at\r
+\r
+ http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+ Unless required by applicable law or agreed to in writing, software\r
+ distributed under the License is distributed on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ See the License for the specific language governing permissions and\r
+ limitations under the License.\r
+-->\r
+<!-- $Id$ -->\r
+<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:test="http://xmlgraphics.apache.org/fop/test">\r
+ <fo:layout-master-set>\r
+ <fo:simple-page-master master-name="simpleA4" page-height="29.7cm" page-width="21cm" margin-top="2cm" margin-bottom="2cm" margin-left="2cm" margin-right="2cm">\r
+ <fo:region-body/>\r
+ </fo:simple-page-master>\r
+ </fo:layout-master-set>\r
+ <fo:page-sequence master-reference="simpleA4">\r
+ <fo:flow flow-name="xsl-region-body">\r
+ <fo:block font="10pt sans-serif">\r
+ <test:assert property="font-family" expected="[sans-serif]"/>\r
+ <test:assert property="font-size" expected="10000mpt"/>\r
+ <test:assert property="font-weight" expected="400" />\r
+ <test:assert property="font-style" expected="NORMAL" />\r
+ <test:assert property="line-height.optimum" expected="120.0%" />\r
+ <test:assert property="font-variant" expected="NORMAL" />\r
+ </fo:block>\r
+ <fo:block font="italic small-caps 14pt 'Times New Roman', serif">\r
+ <test:assert property="font-family" expected="[Times New Roman, serif]"/>\r
+ <test:assert property="font-size" expected="14000mpt"/>\r
+ <test:assert property="font-weight" expected="400" />\r
+ <test:assert property="font-style" expected="ITALIC" />\r
+ <test:assert property="line-height.optimum" expected="120.0%" />\r
+ <test:assert property="font-variant" expected="SMALL_CAPS" />\r
+ Test font shorthand\r
+ </fo:block>\r
+ <fo:block font="bold italic 14pt/80% Helvetica, sans-serif">\r
+ <test:assert property="font-family" expected="[Helvetica, sans-serif]"/>\r
+ <test:assert property="font-size" expected="14000mpt"/>\r
+ <test:assert property="font-weight" expected="700" />\r
+ <test:assert property="font-style" expected="ITALIC" />\r
+ <test:assert property="line-height.optimum" expected="80.0%" />\r
+ <test:assert property="font-variant" expected="NORMAL" />\r
+ Test font shorthand\r
+ </fo:block>\r
+ <fo:block font="xx-large/1.4 Helvetica, sans-serif">\r
+ <test:assert property="font-family" expected="[Helvetica, sans-serif]"/>\r
+ <test:assert property="font-size" expected="20736mpt"/>\r
+ <test:assert property="font-weight" expected="400" />\r
+ <test:assert property="font-style" expected="NORMAL" />\r
+ <test:assert property="line-height.optimum" expected="140.0%" />\r
+ <test:assert property="font-variant" expected="NORMAL" />\r
+ Test font shorthand\r
+ </fo:block>\r
+ <fo:block font="bold italic 14pt/80% Helvetica, sans-serif">\r
+ <fo:block font="inherit">\r
+ <test:assert property="font-family" expected="[Helvetica, sans-serif]"/>\r
+ <test:assert property="font-size" expected="14000mpt"/>\r
+ <test:assert property="font-weight" expected="700" />\r
+ <test:assert property="font-style" expected="ITALIC" />\r
+ <test:assert property="line-height.optimum" expected="80.0%" />\r
+ <test:assert property="font-variant" expected="NORMAL" />\r
+ Test font shorthand inheritance\r
+ </fo:block>\r
+ </fo:block>\r
+ </fo:flow>\r
+ </fo:page-sequence>\r
+</fo:root>\r