git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@377222 13f79535-47bb-0310-9956-ffa450edef68tags/fop-0_92-beta
@@ -6631,11 +6631,11 @@ | |||
<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> |
@@ -1,5 +1,5 @@ | |||
/* | |||
* 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. | |||
@@ -34,6 +34,8 @@ import org.apache.fop.fo.properties.CorrespondingPropertyMaker; | |||
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; | |||
@@ -1081,13 +1083,15 @@ public class FOPropertyMapping implements Constants { | |||
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); | |||
@@ -1105,6 +1109,7 @@ public class FOPropertyMapping implements Constants { | |||
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 | |||
@@ -1137,8 +1142,8 @@ public class FOPropertyMapping implements Constants { | |||
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 | |||
@@ -1147,6 +1152,7 @@ public class FOPropertyMapping implements Constants { | |||
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 | |||
@@ -1154,18 +1160,19 @@ public class FOPropertyMapping implements Constants { | |||
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); | |||
} | |||
@@ -1614,9 +1621,10 @@ public class FOPropertyMapping implements Constants { | |||
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 | |||
@@ -2677,9 +2685,16 @@ public class FOPropertyMapping implements Constants { | |||
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 |
@@ -1,5 +1,5 @@ | |||
/* | |||
* 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. | |||
@@ -42,13 +42,14 @@ import org.apache.fop.fo.properties.PropertyMaker; | |||
/** | |||
* 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; | |||
@@ -56,6 +57,7 @@ abstract public class PropertyList { | |||
/** | |||
* Basic constructor. | |||
* @param fObjToAttach the FO this PropertyList should be attached to | |||
* @param parentPropertyList the PropertyList belonging to the new objects | |||
* parent | |||
*/ | |||
@@ -72,7 +74,7 @@ abstract public class PropertyList { | |||
} | |||
/** | |||
* @return the FObj object attached to the parentPropetyList | |||
* @return the FObj object attached to the parentPropertyList | |||
*/ | |||
public FObj getParentFObj() { | |||
if (parentPropertyList != null) { | |||
@@ -94,6 +96,7 @@ abstract public class PropertyList { | |||
* @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 */ | |||
@@ -109,14 +112,14 @@ abstract public class PropertyList { | |||
* @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. | |||
@@ -124,6 +127,7 @@ abstract public class PropertyList { | |||
* 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 { | |||
@@ -142,6 +146,7 @@ abstract public class PropertyList { | |||
* 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); | |||
@@ -152,6 +157,12 @@ abstract public class PropertyList { | |||
* 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 { | |||
@@ -167,6 +178,7 @@ abstract public class PropertyList { | |||
* @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; | |||
@@ -189,6 +201,7 @@ abstract public class PropertyList { | |||
* @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) { | |||
@@ -202,6 +215,7 @@ abstract public class PropertyList { | |||
* 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(); | |||
@@ -235,14 +249,16 @@ abstract public class PropertyList { | |||
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) { | |||
/* | |||
@@ -263,13 +279,20 @@ abstract public class PropertyList { | |||
* 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); |
@@ -1,5 +1,5 @@ | |||
/* | |||
* 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. | |||
@@ -18,13 +18,12 @@ | |||
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 | |||
@@ -126,7 +125,7 @@ public class ColumnNumberPropertyMaker extends NumberProperty.Maker { | |||
//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()); | |||
} |
@@ -256,11 +256,10 @@ public class CompoundPropertyMaker extends PropertyMaker { | |||
* @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++) { |
@@ -0,0 +1,68 @@ | |||
/* | |||
* 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; | |||
} | |||
} |
@@ -0,0 +1,187 @@ | |||
/* | |||
* 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); | |||
} | |||
} |
@@ -14,7 +14,7 @@ | |||
* limitations under the License. | |||
*/ | |||
/* $Id: $ */ | |||
/* $Id$ */ | |||
package org.apache.fop.fo.properties; | |||
import org.apache.fop.fo.Constants; |
@@ -23,6 +23,9 @@ import java.util.Iterator; | |||
import org.apache.fop.fo.PropertyList; | |||
import org.apache.fop.fo.expr.PropertyException; | |||
/** | |||
* Generic shorthand parser for ListProperties | |||
*/ | |||
public class GenericShorthandParser implements ShorthandParser { | |||
/** | |||
@@ -32,6 +35,7 @@ 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 | |||
*/ | |||
@@ -42,9 +46,10 @@ public class GenericShorthandParser implements ShorthandParser { | |||
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, | |||
@@ -65,9 +70,11 @@ public class GenericShorthandParser implements ShorthandParser { | |||
* 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, |
@@ -27,9 +27,9 @@ import org.apache.fop.fo.expr.PropertyException; | |||
/** | |||
* 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 | |||
*/ | |||
@@ -49,10 +49,6 @@ abstract public class LengthProperty extends Property | |||
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); | |||
} | |||
@@ -63,6 +59,7 @@ abstract public class LengthProperty extends Property | |||
if (val != null) { | |||
return (Property) val; | |||
} | |||
/* always null ?? */ | |||
return convertPropertyDatatype(p, propertyList, fo); | |||
} | |||
@@ -17,7 +17,9 @@ | |||
/* $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; | |||
@@ -40,6 +42,23 @@ public class LineHeightPropertyMaker extends SpaceProperty.Maker { | |||
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. | |||
@@ -65,9 +84,9 @@ public class LineHeightPropertyMaker extends SpaceProperty.Maker { | |||
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; |
@@ -21,7 +21,6 @@ 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; | |||
import org.apache.fop.fo.properties.KeepProperty; | |||
/** | |||
* Shorthand parser for page-break-before, page-break-after and page-break-inside. |
@@ -26,10 +26,15 @@ import org.apache.fop.fo.PropertyList; | |||
* 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) { | |||
@@ -40,6 +45,8 @@ public class PositionShorthandParser implements ShorthandParser { | |||
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) { | |||
@@ -52,6 +59,8 @@ public class PositionShorthandParser implements ShorthandParser { | |||
return new EnumProperty(Constants.EN_STATIC, "STATIC"); | |||
case Constants.EN_FIXED: | |||
return new EnumProperty(Constants.EN_STATIC, "STATIC"); | |||
default: | |||
//nop | |||
} | |||
} | |||
return null; |
@@ -59,7 +59,9 @@ public class PropertyMaker implements Cloneable { | |||
private PropertyMaker[] shorthands = null; | |||
private ShorthandParser datatypeParser; | |||
/** default property **/ | |||
protected Property defaultProperty; | |||
/** Maker for 'corresponding' properties **/ | |||
protected CorrespondingPropertyMaker corresponding; | |||
/** | |||
@@ -257,12 +259,12 @@ public class PropertyMaker implements Cloneable { | |||
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) | |||
@@ -426,8 +428,7 @@ public class PropertyMaker implements Cloneable { | |||
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) { | |||
@@ -459,6 +460,15 @@ public class PropertyMaker implements Cloneable { | |||
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 { | |||
@@ -467,13 +477,13 @@ public class PropertyMaker implements Cloneable { | |||
// 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, |
@@ -36,7 +36,7 @@ public class SpacePropertyMaker extends CorrespondingPropertyMaker { | |||
} | |||
/** | |||
* @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); |
@@ -27,6 +27,9 @@ | |||
<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> |
@@ -0,0 +1,74 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<!-- | |||
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$ --> | |||
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:test="http://xmlgraphics.apache.org/fop/test"> | |||
<fo:layout-master-set> | |||
<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"> | |||
<fo:region-body/> | |||
</fo:simple-page-master> | |||
</fo:layout-master-set> | |||
<fo:page-sequence master-reference="simpleA4"> | |||
<fo:flow flow-name="xsl-region-body"> | |||
<fo:block font="10pt sans-serif"> | |||
<test:assert property="font-family" expected="[sans-serif]"/> | |||
<test:assert property="font-size" expected="10000mpt"/> | |||
<test:assert property="font-weight" expected="400" /> | |||
<test:assert property="font-style" expected="NORMAL" /> | |||
<test:assert property="line-height.optimum" expected="120.0%" /> | |||
<test:assert property="font-variant" expected="NORMAL" /> | |||
</fo:block> | |||
<fo:block font="italic small-caps 14pt 'Times New Roman', serif"> | |||
<test:assert property="font-family" expected="[Times New Roman, serif]"/> | |||
<test:assert property="font-size" expected="14000mpt"/> | |||
<test:assert property="font-weight" expected="400" /> | |||
<test:assert property="font-style" expected="ITALIC" /> | |||
<test:assert property="line-height.optimum" expected="120.0%" /> | |||
<test:assert property="font-variant" expected="SMALL_CAPS" /> | |||
Test font shorthand | |||
</fo:block> | |||
<fo:block font="bold italic 14pt/80% Helvetica, sans-serif"> | |||
<test:assert property="font-family" expected="[Helvetica, sans-serif]"/> | |||
<test:assert property="font-size" expected="14000mpt"/> | |||
<test:assert property="font-weight" expected="700" /> | |||
<test:assert property="font-style" expected="ITALIC" /> | |||
<test:assert property="line-height.optimum" expected="80.0%" /> | |||
<test:assert property="font-variant" expected="NORMAL" /> | |||
Test font shorthand | |||
</fo:block> | |||
<fo:block font="xx-large/1.4 Helvetica, sans-serif"> | |||
<test:assert property="font-family" expected="[Helvetica, sans-serif]"/> | |||
<test:assert property="font-size" expected="20736mpt"/> | |||
<test:assert property="font-weight" expected="400" /> | |||
<test:assert property="font-style" expected="NORMAL" /> | |||
<test:assert property="line-height.optimum" expected="140.0%" /> | |||
<test:assert property="font-variant" expected="NORMAL" /> | |||
Test font shorthand | |||
</fo:block> | |||
<fo:block font="bold italic 14pt/80% Helvetica, sans-serif"> | |||
<fo:block font="inherit"> | |||
<test:assert property="font-family" expected="[Helvetica, sans-serif]"/> | |||
<test:assert property="font-size" expected="14000mpt"/> | |||
<test:assert property="font-weight" expected="700" /> | |||
<test:assert property="font-style" expected="ITALIC" /> | |||
<test:assert property="line-height.optimum" expected="80.0%" /> | |||
<test:assert property="font-variant" expected="NORMAL" /> | |||
Test font shorthand inheritance | |||
</fo:block> | |||
</fo:block> | |||
</fo:flow> | |||
</fo:page-sequence> | |||
</fo:root> |