From f61419abeaa60fbd3d35a1637a5d4c8d75571003 Mon Sep 17 00:00:00 2001 From: Peter Bernard West Date: Wed, 2 Oct 2002 07:10:37 +0000 Subject: [PATCH] Split ShorthandPropSets from PropertySets. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/FOP_0-20-0_Alt-Design@195266 13f79535-47bb-0310-9956-ffa450edef68 --- src/org/apache/fop/fo/Properties.java | 72 +- src/org/apache/fop/fo/PropertySets.java | 909 +---------------- src/org/apache/fop/fo/ShorthandPropSets.java | 943 ++++++++++++++++++ .../fop/fo/expr/SystemFontFunction.java | 8 +- 4 files changed, 986 insertions(+), 946 deletions(-) create mode 100644 src/org/apache/fop/fo/ShorthandPropSets.java diff --git a/src/org/apache/fop/fo/Properties.java b/src/org/apache/fop/fo/Properties.java index 7f5bc1b4f..bd049d4fa 100644 --- a/src/org/apache/fop/fo/Properties.java +++ b/src/org/apache/fop/fo/Properties.java @@ -23,6 +23,7 @@ import java.util.Collections; import org.apache.fop.messaging.MessageHandler; import org.apache.fop.fo.PropertyConsts; +import org.apache.fop.fo.ShorthandPropSets; import org.apache.fop.fo.FOTree; import org.apache.fop.fo.FObjects; import org.apache.fop.datatypes.PropertyValue; @@ -425,7 +426,7 @@ public abstract class Properties { default: if ( ! nested) { if ((datatype & COMPOUND) != 0) - return PropertySets.expandCompoundProperty + return ShorthandPropSets.expandCompoundProperty (foNode.foTree, value); if (proptype == PropertyValue.INHERIT) { if ((datatype & INHERIT) != 0) @@ -597,7 +598,7 @@ public abstract class Properties { * a border-EDGE-width MappedNumeric or inheritance value * * N.B. this is the order of elements defined in - * PropertySets.borderRightExpansion + * ShorthandPropSets.borderRightExpansion */ protected static PropertyValue borderEdge(FONode foNode, PropertyValue value, int styleProp, int colorProp, int widthProp) @@ -635,7 +636,7 @@ public abstract class Properties { { // Copy the value to each member of the shorthand expansion return refineExpansionList - (foNode, PropertySets.expandAndCopySHand(value)); + (foNode, ShorthandPropSets.expandAndCopySHand(value)); } } // Make a list and pass to processList @@ -1138,7 +1139,7 @@ public abstract class Properties { { // Copy the value to each member of the shorthand expansion return refineExpansionList - (foNode, PropertySets.expandAndCopySHand(value)); + (foNode, ShorthandPropSets.expandAndCopySHand(value)); } else { // Make a list and pass to processList PropertyValueList tmpList @@ -1503,7 +1504,7 @@ public abstract class Properties { type == PropertyValue.FROM_NEAREST_SPECIFIED) { // Copy the value to each member of the shorthand newlist = refineExpansionList - (foNode, PropertySets.expandAndCopySHand(value)); + (foNode, ShorthandPropSets.expandAndCopySHand(value)); } } @@ -1951,7 +1952,7 @@ public abstract class Properties { type == PropertyValue.FROM_NEAREST_SPECIFIED) // Copy the value to each member of the shorthand expansion return refineExpansionList - (foNode, PropertySets.expandAndCopySHand(value)); + (foNode, ShorthandPropSets.expandAndCopySHand(value)); PropertyValueList ssList = null; // Must be a space-separated list or a single value from the @@ -2245,7 +2246,7 @@ public abstract class Properties { * a border-EDGE-width MappedNumeric or inheritance value * * N.B. this is the order of elements defined in - * PropertySets.borderRightExpansion + * ShorthandPropSets.borderRightExpansion * * @param foNode - the FONode being built * @param value PropertyValue returned by the parser @@ -2397,12 +2398,12 @@ public abstract class Properties { if (type == PropertyValue.INHERIT || type == PropertyValue.FROM_PARENT || type == PropertyValue.FROM_NEAREST_SPECIFIED) - return refineExpansionList - (foNode, PropertySets.expandAndCopySHand(value)); + return refineExpansionList(foNode, + ShorthandPropSets.expandAndCopySHand(value)); } if (type == PropertyValue.COLOR_TYPE) return refineExpansionList - (foNode, PropertySets.expandAndCopySHand(value)); + (foNode, ShorthandPropSets.expandAndCopySHand(value)); if (type == PropertyValue.NCNAME) { // Must be a standard color ColorType color; @@ -2415,7 +2416,7 @@ public abstract class Properties { " not a standard color for border-color"); } return refineExpansionList - (foNode, PropertySets.expandAndCopySHand(color)); + (foNode, ShorthandPropSets.expandAndCopySHand(color)); } else throw new PropertyException ("Invalid " + value.getClass().getName() + @@ -2614,7 +2615,7 @@ public abstract class Properties { * a border-EDGE-width MappedNumeric or inheritance value * * N.B. this is the order of elements defined in - * PropertySets.borderRightExpansion + * ShorthandPropSets.borderRightExpansion * * @param foNode - the FONode being built * @param value PropertyValue returned by the parser @@ -2700,7 +2701,7 @@ public abstract class Properties { * a border-EDGE-width MappedNumeric or inheritance value * * N.B. this is the order of elements defined in - * PropertySets.borderRightExpansion + * ShorthandPropSets.borderRightExpansion * * @param foNode - the FONode being built * @param value PropertyValue returned by the parser @@ -2838,12 +2839,12 @@ public abstract class Properties { type == PropertyValue.FROM_PARENT || type == PropertyValue.FROM_NEAREST_SPECIFIED) return refineExpansionList - (foNode, PropertySets.expandAndCopySHand(value)); + (foNode, ShorthandPropSets.expandAndCopySHand(value)); if (type == PropertyValue.NUMERIC && ((Numeric)value).isLength()) return refineExpansionList - (foNode, PropertySets.expandAndCopySHand(value)); + (foNode, ShorthandPropSets.expandAndCopySHand(value)); throw new PropertyException ("Invalid " + value.getClass().getName() + @@ -3036,8 +3037,8 @@ public abstract class Properties { if (type == PropertyValue.INHERIT || type == PropertyValue.FROM_PARENT || type == PropertyValue.FROM_NEAREST_SPECIFIED) - return refineExpansionList - (foNode, PropertySets.expandAndCopySHand(value)); + return refineExpansionList(foNode, + ShorthandPropSets.expandAndCopySHand(value)); } if (type == PropertyValue.NCNAME) { // Must be a border-style @@ -3051,7 +3052,7 @@ public abstract class Properties { " not a border-style"); } return refineExpansionList - (foNode, PropertySets.expandAndCopySHand(enum)); + (foNode, ShorthandPropSets.expandAndCopySHand(enum)); } else throw new PropertyException ("Invalid " + value.getClass().getName() + @@ -3125,7 +3126,7 @@ public abstract class Properties { * a border-EDGE-width MappedNumeric or inheritance value * * N.B. this is the order of elements defined in - * PropertySets.borderRightExpansion + * ShorthandPropSets.borderRightExpansion * * @param foNode - the FONode being built * @param value PropertyValue returned by the parser @@ -3255,8 +3256,8 @@ public abstract class Properties { if (type == PropertyValue.INHERIT || type == PropertyValue.FROM_PARENT || type == PropertyValue.FROM_NEAREST_SPECIFIED) - return refineExpansionList - (foNode, PropertySets.expandAndCopySHand(value)); + return refineExpansionList(foNode, + ShorthandPropSets.expandAndCopySHand(value)); } if (type == PropertyValue.NCNAME) { // Must be a border-width @@ -3277,7 +3278,7 @@ public abstract class Properties { // Correct the property in the mapped Numeric mapped.setProperty(PropNames.BORDER_WIDTH); return refineExpansionList - (foNode, PropertySets.expandAndCopySHand(mapped)); + (foNode, ShorthandPropSets.expandAndCopySHand(mapped)); } else throw new PropertyException ("Invalid " + value.getClass().getName() + @@ -3698,7 +3699,7 @@ public abstract class Properties { type == PropertyValue.FROM_NEAREST_SPECIFIED || type == PropertyValue.URI_TYPE) return refineExpansionList - (foNode, PropertySets.expandAndCopySHand(value)); + (foNode, ShorthandPropSets.expandAndCopySHand(value)); throw new PropertyException ("Invalid " + value.getClass().getName() + " object for cue"); @@ -4168,7 +4169,7 @@ public abstract class Properties { type == PropertyValue.FROM_NEAREST_SPECIFIED) { return refineExpansionList - (foNode, PropertySets.expandAndCopySHand(value)); + (foNode, ShorthandPropSets.expandAndCopySHand(value)); } // else not Inherit/From../From.. FontFamilySet family = null; @@ -4385,9 +4386,9 @@ public abstract class Properties { newlist = new PropertyValueList(PropNames.FONT); // Add each discovered property to the list. // N.B. These properties should be added in the order given - // in the PropertySets.fontExpansion ROIntArray. - for (int i = 0; i < PropertySets.fontExpansion.length; i++) { - switch (PropertySets.fontExpansion.get(i)) { + // in the ShorthandPropSets.fontExpansion ROIntArray. + for (int i = 0; i < ShorthandPropSets.fontExpansion.length; i++) { + switch (ShorthandPropSets.fontExpansion.get(i)) { case PropNames.FONT_STYLE: if (style != null) newlist.add(style); break; @@ -4405,7 +4406,8 @@ public abstract class Properties { break; case PropNames.LINE_HEIGHT: if (height != null) - newlist.addAll(PropertySets.expandCompoundProperty + newlist.addAll + (ShorthandPropSets.expandCompoundProperty (foNode.foTree, height)); break; } @@ -5653,11 +5655,11 @@ public abstract class Properties { || value instanceof FromNearestSpecified ) return refineExpansionList - (foNode, PropertySets.expandAndCopySHand(value)); + (foNode, ShorthandPropSets.expandAndCopySHand(value)); // N.B. Does this require further refinement? // Where is Auto expanded? return refineExpansionList - (foNode, PropertySets.expandAndCopySHand + (foNode, ShorthandPropSets.expandAndCopySHand (autoOrDistance(value))); } else { PropertyValueList list = @@ -6046,7 +6048,7 @@ public abstract class Properties { && ((Numeric)value).isDistance()) ) return refineExpansionList - (foNode, PropertySets.expandAndCopySHand(value)); + (foNode, ShorthandPropSets.expandAndCopySHand(value)); throw new PropertyException ("Invalid property value for 'padding': " + value.getClass().getName()); @@ -6362,7 +6364,7 @@ public abstract class Properties { value instanceof Auto) { return refineExpansionList - (foNode, PropertySets.expandAndCopySHand(value)); + (foNode, ShorthandPropSets.expandAndCopySHand(value)); } if (value instanceof NCName) { EnumType enum = null; @@ -6425,7 +6427,7 @@ public abstract class Properties { value instanceof Auto) { return refineExpansionList - (foNode, PropertySets.expandAndCopySHand(value)); + (foNode, ShorthandPropSets.expandAndCopySHand(value)); } if (value instanceof NCName) { EnumType enum = null; @@ -6496,7 +6498,7 @@ public abstract class Properties { value instanceof Auto) { return refineExpansionList - (foNode, PropertySets.expandAndCopySHand(value)); + (foNode, ShorthandPropSets.expandAndCopySHand(value)); } if (value instanceof NCName) { EnumType enum = null; @@ -6654,7 +6656,7 @@ public abstract class Properties { value instanceof FromNearestSpecified) { return refineExpansionList - (foNode, PropertySets.expandAndCopySHand(value)); + (foNode, ShorthandPropSets.expandAndCopySHand(value)); } if (value instanceof NCName) { EnumType enum = null; diff --git a/src/org/apache/fop/fo/PropertySets.java b/src/org/apache/fop/fo/PropertySets.java index d9b5a34e2..510ca7bfb 100644 --- a/src/org/apache/fop/fo/PropertySets.java +++ b/src/org/apache/fop/fo/PropertySets.java @@ -14,24 +14,16 @@ import java.lang.CloneNotSupportedException; import java.util.Set; import java.util.HashSet; -import java.util.HashMap; -import java.util.List; -import java.util.ListIterator; -import java.util.Iterator; -import java.util.Arrays; import java.util.Collections; import org.apache.fop.fo.expr.PropertyException; -import org.apache.fop.datatypes.PropertyValue; -import org.apache.fop.datatypes.PropertyValueList; import org.apache.fop.fo.PropNames; -import org.apache.fop.datastructs.ROIntArray; import org.apache.fop.datatypes.Ints; /** - * This class contains HashMaps which encode the various sets of + * This class contains HashSets which encode the various sets of * properties which are defined to apply to each of the Flow Objects. These - * HashMaps provide a convenient means of specifying the + * HashSets provide a convenient means of specifying the * relationship between FOs and properties. */ public class PropertySets { @@ -387,903 +379,6 @@ public class PropertySets { tableSet = Collections.unmodifiableSet((Set)tableProps); } - // My preference here for shorthands which expand to compound properties - // would be to expand only to the compound, and allow compounds to be - // "normally" expanded in a second step. Unfortunately, the shorthand - // border-spacing expands (potentially) into both of the elements of - // the border-separation compound. However, other compound expansions - // are defined with only a single value for the compound, so I will - // treat border-separation as a special case in the event that two - // values are provided. - // I''m not sure whether a shorthand specification which sets a compound - // property with a single top-level value should be regarded as a - // specification for the purposes of inheritance, but I will assume so - // until further notice. - // pbw - - private static final int[] backgroundPosition = { - PropNames.BACKGROUND_POSITION_HORIZONTAL - ,PropNames.BACKGROUND_POSITION_VERTICAL - }; - - private static final int[] borderColor = { - PropNames.BORDER_TOP_COLOR - ,PropNames.BORDER_RIGHT_COLOR - ,PropNames.BORDER_BOTTOM_COLOR - ,PropNames.BORDER_LEFT_COLOR - }; - - private static final int[] borderStyle = { - PropNames.BORDER_TOP_STYLE - ,PropNames.BORDER_RIGHT_STYLE - ,PropNames.BORDER_BOTTOM_STYLE - ,PropNames.BORDER_LEFT_STYLE - }; - - private static final int[] borderWidth = { - PropNames.BORDER_TOP_WIDTH - ,PropNames.BORDER_RIGHT_WIDTH - ,PropNames.BORDER_BOTTOM_WIDTH - ,PropNames.BORDER_LEFT_WIDTH - }; - - public static final ROIntArray backgroundExpansion = - new ROIntArray(new int[][] { - new int[] { - PropNames.BACKGROUND_COLOR - ,PropNames.BACKGROUND_IMAGE - ,PropNames.BACKGROUND_REPEAT - ,PropNames.BACKGROUND_ATTACHMENT - ,PropNames.BACKGROUND_POSITION_HORIZONTAL - ,PropNames.BACKGROUND_POSITION_VERTICAL - }, backgroundPosition}); - - public static final ROIntArray backgroundPositionExpansion = - new ROIntArray(backgroundPosition); - - public static final ROIntArray borderExpansion = - new ROIntArray(new int[][] { borderStyle, borderColor, borderWidth }); - - public static final ROIntArray borderStyleExpansion = - new ROIntArray(borderStyle); - - public static final ROIntArray borderColorExpansion = - new ROIntArray(borderColor); - - public static final ROIntArray borderWidthExpansion = - new ROIntArray(borderWidth); - - public static final ROIntArray borderTopExpansion = - new ROIntArray(new int[] { - PropNames.BORDER_TOP_STYLE - ,PropNames.BORDER_TOP_COLOR - ,PropNames.BORDER_TOP_WIDTH - }); - - public static final ROIntArray borderRightExpansion = - new ROIntArray(new int[] { - PropNames.BORDER_RIGHT_STYLE - ,PropNames.BORDER_RIGHT_COLOR - ,PropNames.BORDER_RIGHT_WIDTH - }); - - public static final ROIntArray borderBottomExpansion = - new ROIntArray(new int[] { - PropNames.BORDER_BOTTOM_STYLE - ,PropNames.BORDER_BOTTOM_COLOR - ,PropNames.BORDER_BOTTOM_WIDTH - }); - - public static final ROIntArray borderLeftExpansion = - new ROIntArray(new int[] { - PropNames.BORDER_LEFT_STYLE - ,PropNames.BORDER_LEFT_COLOR - ,PropNames.BORDER_LEFT_WIDTH - }); - - /** - * Watch this one. border-spacing is a shorthand which expands - * into the components of the <border-separation> compound - * property. - */ - public static final ROIntArray borderSpacingExpansion = - new ROIntArray(new int[] { - PropNames.BORDER_SEPARATION - }); - - public static final ROIntArray cueExpansion = - new ROIntArray(new int[] { - PropNames.CUE_BEFORE - ,PropNames.CUE_AFTER - }); - - /** - * Another nasty one. font expands, in part, into - * line-height, which is itself a compound property with a - * <space> value. - */ - public static final ROIntArray fontExpansion = - new ROIntArray(new int[] { - PropNames.FONT_FAMILY - ,PropNames.FONT_STYLE - ,PropNames.FONT_VARIANT - ,PropNames.FONT_WEIGHT - ,PropNames.FONT_SIZE - ,PropNames.LINE_HEIGHT - ,PropNames.FONT_SIZE_ADJUST - ,PropNames.FONT_STRETCH - ,PropNames.FONT_SELECTION_STRATEGY - }); - - public static final ROIntArray marginExpansion = - new ROIntArray(new int[] { - PropNames.MARGIN_TOP - ,PropNames.MARGIN_RIGHT - ,PropNames.MARGIN_BOTTOM - ,PropNames.MARGIN_LEFT - }); - - public static final ROIntArray paddingExpansion = - new ROIntArray(new int[] { - PropNames.PADDING_TOP - ,PropNames.PADDING_RIGHT - ,PropNames.PADDING_BOTTOM - ,PropNames.PADDING_LEFT - }); - - public static final ROIntArray pageBreakAfterExpansion = - new ROIntArray(new int[] { - PropNames.BREAK_AFTER - ,PropNames.KEEP_WITH_NEXT - }); - - public static final ROIntArray pageBreakBeforeExpansion = - new ROIntArray(new int[] { - PropNames.BREAK_BEFORE - ,PropNames.KEEP_WITH_PREVIOUS - }); - - public static final ROIntArray pageBreakInsideExpansion = - new ROIntArray(new int[] { - PropNames.KEEP_TOGETHER - }); - - public static final ROIntArray pauseExpansion = - new ROIntArray(new int[] { - PropNames.PAUSE_BEFORE - ,PropNames.PAUSE_AFTER - }); - - public static final ROIntArray positionExpansion = - new ROIntArray(new int[] { - PropNames.RELATIVE_POSITION - ,PropNames.ABSOLUTE_POSITION - }); - - public static final ROIntArray sizeExpansion = - new ROIntArray(new int[] { - PropNames.PAGE_HEIGHT - ,PropNames.PAGE_WIDTH - }); - - public static final ROIntArray verticalAlignExpansion = - new ROIntArray(new int[] { - PropNames.ALIGNMENT_BASELINE - ,PropNames.ALIGNMENT_ADJUST - ,PropNames.BASELINE_SHIFT - ,PropNames.DOMINANT_BASELINE - }); - - public static final ROIntArray whiteSpaceExpansion = - new ROIntArray(new int[] { - PropNames.LINEFEED_TREATMENT - ,PropNames.WHITE_SPACE_COLLAPSE - ,PropNames.WHITE_SPACE_TREATMENT - ,PropNames.WRAP_OPTION - }); - - public static final ROIntArray xmlLangExpansion = - new ROIntArray(new int[] { - PropNames.COUNTRY - ,PropNames.LANGUAGE - }); - - /** - * Shorthand properties. Where properties interact, they are listed - * in increasing precision. - */ - private static final int[] shorthands = { - PropNames.BACKGROUND - ,PropNames.BACKGROUND_POSITION - ,PropNames.BORDER - ,PropNames.BORDER_STYLE - ,PropNames.BORDER_COLOR - ,PropNames.BORDER_WIDTH - ,PropNames.BORDER_TOP - ,PropNames.BORDER_RIGHT - ,PropNames.BORDER_BOTTOM - ,PropNames.BORDER_LEFT - ,PropNames.BORDER_SPACING - ,PropNames.CUE - ,PropNames.FONT - ,PropNames.MARGIN - ,PropNames.PADDING - ,PropNames.PAGE_BREAK_AFTER - ,PropNames.PAGE_BREAK_BEFORE - ,PropNames.PAGE_BREAK_INSIDE - ,PropNames.PAUSE - ,PropNames.POSITION - ,PropNames.SIZE - ,PropNames.VERTICAL_ALIGN - ,PropNames.WHITE_SPACE - ,PropNames.XML_LANG - }; - - /** - * Map property index to shorthand array index - */ - private static final HashMap shorthandMap; - static { - shorthandMap = new HashMap(shorthands.length); - for (int i = 0; i < shorthands.length; i++) { - shorthandMap.put - ((Object)(Ints.consts.get(shorthands[i])), - (Object)(Ints.consts.get(i))); - } - } - - /** - * RO Shorthand properties. - */ - public static final ROIntArray roShorthands = - new ROIntArray(shorthands); - - /** - * Array of ROIntArray in same order as shorthands - * ROIntArray. - * If a public view of this is required, use - * Collections.unmodifiableList(Arrays.asList(shorthandExpansions)) - */ - private static final ROIntArray[] shorthandExpansions = { - backgroundExpansion - ,backgroundPositionExpansion - ,borderExpansion - ,borderStyleExpansion - ,borderColorExpansion - ,borderWidthExpansion - ,borderTopExpansion - ,borderRightExpansion - ,borderBottomExpansion - ,borderLeftExpansion - ,borderSpacingExpansion - ,cueExpansion - ,fontExpansion - ,marginExpansion - ,paddingExpansion - ,pageBreakAfterExpansion - ,pageBreakBeforeExpansion - ,pageBreakInsideExpansion - ,pauseExpansion - ,positionExpansion - ,sizeExpansion - ,verticalAlignExpansion - ,whiteSpaceExpansion - ,xmlLangExpansion - }; - - /** - * @param property int property index - * @return ROIntArray containing the expansion list for - * this shorthand. - * @exception PropertyException if this is not a valid - * shorthand property - */ - public static ROIntArray getSHandExpansionSet(int property) - throws PropertyException - { - // Is the property of the argument a shorthand? - Integer sHIndex = - (Integer)(shorthandMap.get(Ints.consts.get(property))); - if (sHIndex == null) { - String propname = PropNames.getPropertyName(property); - throw new PropertyException - (propname + " not a shorthand property"); - } - // Get the array of indices of the properties in the - // expansion of this shorthand - return shorthandExpansions[property]; - } - - /** - * Expand the shorthand property associated with the - * PropertyValue argument by copying the given value for each - * property in the expansion. The property field of each - * PropertyValue will be set to one of the proeprties in the - * shorthand expansion. - * @param value a propertyValue whose property field - * is assumed to be set to a shorthand property. - * @return PropertyValueList containing a list of - * PropertyValues, one for each property in the expansion of - * the shorthand property. - * @exception PropertyException - */ - public static PropertyValueList expandAndCopySHand(PropertyValue value) - throws PropertyException - { - // The property associated with this PropertyValue - int property = value.getProperty(); - ROIntArray expansion = getSHandExpansionSet(property); - PropertyValueList list = new PropertyValueList(property); - return copyValueToSet(value, expansion, list); - } - - /** - * Generate a list of the intial values of each property in a - * shorthand expansion. Note that this will be a list of - * references to the initial values. - * @param foTree the FOTree for which properties are being - * processed - * @param property int property index - * @return PropertyValueList containing the intial value - * expansions for the (shorthand) property - * @exception PropertyException - */ - /* - Don't do this. Shorthands should not expand initial values, because - a distinction is needed between those properties which are given - a specified value and those which are set by normal inheritance or from - their initial values. This so that fromSpecifiedValue() will work. - - public static PropertyValueList initialValueSHandExpansion - (FOTree foTree, int property) - throws PropertyException - { - ROIntArray expansion = getSHandExpansionSet(property); - PropertyValueList list = new PropertyValueList(property); - for (int i = 0; i < expansion.length; i++) { - int expandedProp = expansion.get(i); - PropertyValue specified - = foTree.getInitialSpecifiedValue(expandedProp); - list.add(specified); - } - return list; - } - */ - - /** - * Given a shorthand expansion list and a PropertyValue, - * override the list element corresponding to the PropertyValue. - * Correspondence is based on the property field of the - * PropertyValue. - * @param expansionList the expansion PropertyValueList - * @param element the overriding PropertyValue - * @return PropertyValueList the expansion list with the - * appropriate element reset - * @exception PropertyException - */ - public static PropertyValueList overrideSHandElement - (PropertyValueList expansionList, PropertyValue element) - throws PropertyException - { - int elementProp = element.getProperty(); - ListIterator elements = expansionList.listIterator(); - while (elements.hasNext()) { - PropertyValue next = (PropertyValue)(elements.next()); - if (next.getProperty() == elementProp) { - elements.set(element); - return expansionList; - } - } - throw new PropertyException - ("Unmatched property " + elementProp + - " in expansion list for " + expansionList.getProperty()); - } - - /** - * Given a shorthand expansion list and a PropertyValueList, - * override the expansion list elements corresponding to the elements - * of the PropertyValueList. - * Correspondence is based on the property field of the - * PropertyValue. - * @param expansionList the expansion PropertyValueList - * @param list the overriding PropertyValueList - * @return PropertyValueList the new expansion list with - * appropriate elements reset - * @exception PropertyException - */ - public static PropertyValueList overrideSHandElements - (PropertyValueList expansionList, PropertyValueList list) - throws PropertyException - { - // From the overriding list, form an array of PropertyValue references - // an array of property indices and an array of booleans, - int listsize = list.size(); - Object[] listrefs = new Object[listsize]; - int[] listprops = new int[listsize]; - boolean[] propseen = new boolean[listsize]; - Iterator listels = list.iterator(); - int i = 0; - while (listels.hasNext()) { - listrefs[i] = listels.next(); - listprops[i] = ((PropertyValue)listrefs[i]).getProperty(); - i++; - } - - ListIterator elements = expansionList.listIterator(); - while (elements.hasNext()) { - PropertyValue next = (PropertyValue)(elements.next()); - int expprop = next.getProperty(); - for (i = 0; i < listsize; i++) { - if (expprop != listprops[i]) continue; - elements.set(listrefs[i]); - propseen[i] = true; - } - } - // Check for unmatched override elements - String unmatched = ""; - boolean someunmatched = false; - for (i = 0; i < listsize; i++) { - if ( ! propseen[i]) { - someunmatched = true; - unmatched = unmatched + " " + - PropNames.getPropertyName(listprops[i]); - } - } - if (someunmatched) - throw new PropertyException - ("Unmatched properties:" + unmatched + - " : in expansion list for " + expansionList.getProperty()); - return expansionList; - } - - public static final ROIntArray blockProgressionDimensionCopyExpansion = - new ROIntArray(new int[] { - PropNames.BLOCK_PROGRESSION_DIMENSION_MINIMUM - ,PropNames.BLOCK_PROGRESSION_DIMENSION_OPTIMUM - ,PropNames.BLOCK_PROGRESSION_DIMENSION_MAXIMUM - }); - - public static final ROIntArray blockProgressionDimensionNonCopyExpansion = - new ROIntArray(new int[] {}); - - public static final ROIntArray borderAfterWidthCopyExpansion = - new ROIntArray(new int[] { - PropNames.BORDER_AFTER_WIDTH_LENGTH - }); - - public static final ROIntArray borderAfterWidthNonCopyExpansion = - new ROIntArray(new int[] { - PropNames.BORDER_AFTER_WIDTH_CONDITIONALITY - }); - - public static final ROIntArray borderBeforeWidthCopyExpansion = - new ROIntArray(new int[] { - PropNames.BORDER_BEFORE_WIDTH_LENGTH - }); - - public static final ROIntArray borderBeforeWidthNonCopyExpansion = - new ROIntArray(new int[] { - PropNames.BORDER_BEFORE_WIDTH_CONDITIONALITY - }); - - public static final ROIntArray borderEndWidthCopyExpansion = - new ROIntArray(new int[] { - PropNames.BORDER_END_WIDTH_LENGTH - }); - - public static final ROIntArray borderEndWidthNonCopyExpansion = - new ROIntArray(new int[] { - PropNames.BORDER_END_WIDTH_CONDITIONALITY - }); - - public static final ROIntArray borderStartWidthCopyExpansion = - new ROIntArray(new int[] { - PropNames.BORDER_START_WIDTH_LENGTH - }); - - public static final ROIntArray borderStartWidthNonCopyExpansion = - new ROIntArray(new int[] { - PropNames.BORDER_START_WIDTH_CONDITIONALITY - }); - - public static final ROIntArray borderSeparationCopyExpansion = - new ROIntArray(new int[] { - PropNames.BORDER_SEPARATION_BLOCK_PROGRESSION_DIRECTION - ,PropNames.BORDER_SEPARATION_INLINE_PROGRESSION_DIRECTION - }); - - public static final ROIntArray borderSeparationNonCopyExpansion = - new ROIntArray(new int[] {}); - - public static final ROIntArray inlineProgressionDimensionCopyExpansion = - new ROIntArray(new int[] { - PropNames.INLINE_PROGRESSION_DIMENSION_MINIMUM - ,PropNames.INLINE_PROGRESSION_DIMENSION_OPTIMUM - ,PropNames.INLINE_PROGRESSION_DIMENSION_MAXIMUM - }); - - public static final ROIntArray inlineProgressionDimensionNonCopyExpansion = - new ROIntArray(new int[] {}); - - public static final ROIntArray keepTogetherCopyExpansion = - new ROIntArray(new int[] { - PropNames.KEEP_TOGETHER_WITHIN_LINE - ,PropNames.KEEP_TOGETHER_WITHIN_COLUMN - ,PropNames.KEEP_TOGETHER_WITHIN_PAGE - }); - - public static final ROIntArray keepTogetherNonCopyExpansion = - new ROIntArray(new int[] {}); - - public static final ROIntArray keepWithNextCopyExpansion = - new ROIntArray(new int[] { - PropNames.KEEP_WITH_NEXT_WITHIN_LINE - ,PropNames.KEEP_WITH_NEXT_WITHIN_COLUMN - ,PropNames.KEEP_WITH_NEXT_WITHIN_PAGE - }); - - public static final ROIntArray keepWithNextNonCopyExpansion = - new ROIntArray(new int[] {}); - - public static final ROIntArray keepWithPreviousCopyExpansion = - new ROIntArray(new int[] { - PropNames.KEEP_WITH_PREVIOUS_WITHIN_LINE - ,PropNames.KEEP_WITH_PREVIOUS_WITHIN_COLUMN - ,PropNames.KEEP_WITH_PREVIOUS_WITHIN_PAGE - }); - - public static final ROIntArray keepWithPreviousNonCopyExpansion = - new ROIntArray(new int[] {}); - - public static final ROIntArray leaderLengthCopyExpansion = - new ROIntArray(new int[] { - PropNames.LEADER_LENGTH_MINIMUM - ,PropNames.LEADER_LENGTH_OPTIMUM - ,PropNames.LEADER_LENGTH_MAXIMUM - }); - - public static final ROIntArray leaderLengthNonCopyExpansion = - new ROIntArray(new int[] {}); - - public static final ROIntArray letterSpacingCopyExpansion = - new ROIntArray(new int[] { - PropNames.LETTER_SPACING_MINIMUM - ,PropNames.LETTER_SPACING_OPTIMUM - ,PropNames.LETTER_SPACING_MAXIMUM - }); - - public static final ROIntArray letterSpacingNonCopyExpansion = - new ROIntArray(new int[] { - PropNames.LETTER_SPACING_CONDITIONALITY - ,PropNames.LETTER_SPACING_PRECEDENCE - }); - - public static final ROIntArray lineHeightCopyExpansion = - new ROIntArray(new int[] { - PropNames.LINE_HEIGHT_MINIMUM - ,PropNames.LINE_HEIGHT_OPTIMUM - ,PropNames.LINE_HEIGHT_MAXIMUM - }); - - public static final ROIntArray lineHeightNonCopyExpansion = - new ROIntArray(new int[] { - PropNames.LINE_HEIGHT_CONDITIONALITY - ,PropNames.LINE_HEIGHT_PRECEDENCE - }); - - public static final ROIntArray paddingAfterCopyExpansion = - new ROIntArray(new int[] { - PropNames.PADDING_AFTER_LENGTH - }); - - public static final ROIntArray paddingAfterNonCopyExpansion = - new ROIntArray(new int[] { - PropNames.PADDING_AFTER_CONDITIONALITY - }); - - public static final ROIntArray paddingBeforeCopyExpansion = - new ROIntArray(new int[] { - PropNames.PADDING_BEFORE_LENGTH - }); - - public static final ROIntArray paddingBeforeNonCopyExpansion = - new ROIntArray(new int[] { - PropNames.PADDING_BEFORE_CONDITIONALITY - }); - - public static final ROIntArray paddingEndCopyExpansion = - new ROIntArray(new int[] { - PropNames.PADDING_END_LENGTH - }); - - public static final ROIntArray paddingEndNonCopyExpansion = - new ROIntArray(new int[] { - PropNames.PADDING_END_CONDITIONALITY - }); - - public static final ROIntArray paddingStartCopyExpansion = - new ROIntArray(new int[] { - PropNames.PADDING_START_LENGTH - }); - - public static final ROIntArray paddingStartNonCopyExpansion = - new ROIntArray(new int[] { - PropNames.PADDING_START_CONDITIONALITY - }); - - public static final ROIntArray spaceAfterCopyExpansion = - new ROIntArray(new int[] { - PropNames.SPACE_AFTER_MINIMUM - ,PropNames.SPACE_AFTER_OPTIMUM - ,PropNames.SPACE_AFTER_MAXIMUM - }); - - public static final ROIntArray spaceAfterNonCopyExpansion = - new ROIntArray(new int[] { - PropNames.SPACE_AFTER_CONDITIONALITY - ,PropNames.SPACE_AFTER_PRECEDENCE - }); - - public static final ROIntArray spaceBeforeCopyExpansion = - new ROIntArray(new int[] { - PropNames.SPACE_BEFORE_MINIMUM - ,PropNames.SPACE_BEFORE_OPTIMUM - ,PropNames.SPACE_BEFORE_MAXIMUM - }); - - public static final ROIntArray spaceBeforeNonCopyExpansion = - new ROIntArray(new int[] { - PropNames.SPACE_BEFORE_CONDITIONALITY - ,PropNames.SPACE_BEFORE_PRECEDENCE - }); - - public static final ROIntArray spaceEndCopyExpansion = - new ROIntArray(new int[] { - PropNames.SPACE_END_MINIMUM - ,PropNames.SPACE_END_OPTIMUM - ,PropNames.SPACE_END_MAXIMUM - }); - - public static final ROIntArray spaceEndNonCopyExpansion = - new ROIntArray(new int[] { - PropNames.SPACE_END_CONDITIONALITY - ,PropNames.SPACE_END_PRECEDENCE - }); - - public static final ROIntArray spaceStartCopyExpansion = - new ROIntArray(new int[] { - PropNames.SPACE_START_MINIMUM - ,PropNames.SPACE_START_OPTIMUM - ,PropNames.SPACE_START_MAXIMUM - }); - - public static final ROIntArray spaceStartNonCopyExpansion = - new ROIntArray(new int[] { - PropNames.SPACE_START_CONDITIONALITY - ,PropNames.SPACE_START_PRECEDENCE - }); - - public static final ROIntArray wordSpacingCopyExpansion = - new ROIntArray(new int[] { - PropNames.WORD_SPACING_MINIMUM - ,PropNames.WORD_SPACING_OPTIMUM - ,PropNames.WORD_SPACING_MAXIMUM - }); - - public static final ROIntArray wordSpacingNonCopyExpansion = - new ROIntArray(new int[] { - PropNames.WORD_SPACING_CONDITIONALITY - ,PropNames.WORD_SPACING_PRECEDENCE - }); - - private static final int[] compounds = { - PropNames.BLOCK_PROGRESSION_DIMENSION - ,PropNames.BORDER_AFTER_WIDTH - ,PropNames.BORDER_BEFORE_WIDTH - ,PropNames.BORDER_END_WIDTH - ,PropNames.BORDER_START_WIDTH - ,PropNames.BORDER_SEPARATION - ,PropNames.INLINE_PROGRESSION_DIMENSION - ,PropNames.KEEP_TOGETHER - ,PropNames.KEEP_WITH_NEXT - ,PropNames.KEEP_WITH_PREVIOUS - ,PropNames.LEADER_LENGTH - ,PropNames.LETTER_SPACING - ,PropNames.LINE_HEIGHT - ,PropNames.PADDING_AFTER - ,PropNames.PADDING_BEFORE - ,PropNames.PADDING_END - ,PropNames.PADDING_START - ,PropNames.SPACE_AFTER - ,PropNames.SPACE_BEFORE - ,PropNames.SPACE_END - ,PropNames.SPACE_START - ,PropNames.WORD_SPACING - }; - - /** - * Map property index to compound array index - */ - private static final HashMap compoundMap; - static { - compoundMap = new HashMap(compounds.length); - for (int i = 0; i < compounds.length; i++) { - compoundMap.put - ((Object)(Ints.consts.get(compounds[i])), - (Object)(Ints.consts.get(i))); - } - } - - /** - * RO compound properties. - */ - public static final ROIntArray roCompounds; - static { - roCompounds = new ROIntArray(compounds); - } - - /** - * Array of ROIntArray of the copy expansion properties of - * compounds in same order as compounds - * ROIntArray. - * If a public view of this is required, use - * Collections.unmodifiableList(Arrays.asList(compoundCopyExpansions)) - */ - private static final ROIntArray[] compoundCopyExpansions = { - blockProgressionDimensionCopyExpansion - ,borderAfterWidthCopyExpansion - ,borderBeforeWidthCopyExpansion - ,borderEndWidthCopyExpansion - ,borderStartWidthCopyExpansion - ,borderSeparationCopyExpansion - ,inlineProgressionDimensionCopyExpansion - ,keepTogetherCopyExpansion - ,keepWithNextCopyExpansion - ,keepWithPreviousCopyExpansion - ,leaderLengthCopyExpansion - ,letterSpacingCopyExpansion - ,lineHeightCopyExpansion - ,paddingAfterCopyExpansion - ,paddingBeforeCopyExpansion - ,paddingEndCopyExpansion - ,paddingStartCopyExpansion - ,spaceAfterCopyExpansion - ,spaceBeforeCopyExpansion - ,spaceEndCopyExpansion - ,spaceStartCopyExpansion - ,wordSpacingCopyExpansion - }; - - /** - * Array of ROIntArray of the non-copy expansion properties of - * compounds in same order as compounds - * ROIntArray. - * If a public view of this is required, use - * Collections.unmodifiableList(Arrays.asList(compoundNonCopyExpansions)) - */ - private static final ROIntArray[] compoundNonCopyExpansions = { - blockProgressionDimensionNonCopyExpansion - ,borderAfterWidthNonCopyExpansion - ,borderBeforeWidthNonCopyExpansion - ,borderEndWidthNonCopyExpansion - ,borderStartWidthNonCopyExpansion - ,borderSeparationNonCopyExpansion - ,inlineProgressionDimensionNonCopyExpansion - ,keepTogetherNonCopyExpansion - ,keepWithNextNonCopyExpansion - ,keepWithPreviousNonCopyExpansion - ,leaderLengthNonCopyExpansion - ,letterSpacingNonCopyExpansion - ,lineHeightNonCopyExpansion - ,paddingAfterNonCopyExpansion - ,paddingBeforeNonCopyExpansion - ,paddingEndNonCopyExpansion - ,paddingStartNonCopyExpansion - ,spaceAfterNonCopyExpansion - ,spaceBeforeNonCopyExpansion - ,spaceEndNonCopyExpansion - ,spaceStartNonCopyExpansion - ,wordSpacingNonCopyExpansion - }; - - /** - * Expand the PropertyValue assigned to a compound property - * into propertyValues for the individual property components. - * N.B. This method assumes that the set of expansion properties is - * comprised of a copy and a non-copy set. For example, <space> - * compounds have a copy set of .minimum, .optimum and .maximum, and a - * non-copy set of .precedence and .conditionality. For each element of - * the copy set, the given value is cloned. For each member of the - * non-copy set, a reference to the initial value is taken. - * @param foTree - the FOTree for which properties are being - * developed. - * @param value - the PropertyValue to be cloned for the copy - * set members. - * @return a PropertyValueList containing the copy set - * expansions followed by the non-copy set expansions, in the order - * they are defined in appropriate ROIntArrays in this class. - */ - public static PropertyValueList expandCompoundProperty - (FOTree foTree, PropertyValue value) - throws PropertyException - { - int property = value.getProperty(); - Integer compoundX = - (Integer)(compoundMap.get(Ints.consts.get(property))); - if (compoundX == null) - throw new PropertyException - (PropNames.getPropertyName(property) + " (" + property + ") " - + " is not a compound property."); - int compoundIdx = compoundX.intValue(); - PropertyValueList list = new PropertyValueList(property); - ROIntArray expansion; - // Expand the copy components - list = copyValueToSet - (value, compoundCopyExpansions[compoundIdx], list); - // Expand the non-copy components - return initialValueCompoundExpansion - (foTree, compoundNonCopyExpansions[compoundIdx], list); - } - - /** - * Clone the given property value for each property in the given - * expansion set. Append the new property values to the given list. - * @param value - the property value to clone. - * @param expansionSet - the set of indices of the expansion properties. - * @param list - the list to which to append the expansion elements. - * @return the original PropertyValueList containing the - * appended expansions. - * @exception PropertyException - */ - private static PropertyValueList copyValueToSet(PropertyValue value, - ROIntArray expansionSet, PropertyValueList list) - throws PropertyException - { - for (int i = 0; i < expansionSet.length; i++) { - int expandedProp = expansionSet.get(i); - PropertyValue expandedPropValue; - // The PropertyValue must be cloneable - // The property associated with each PV in the expansion will - // necessarily be different. - try { - expandedPropValue = (PropertyValue)(value.clone()); - } catch (CloneNotSupportedException e) { - throw new PropertyException(e.getMessage()); - } - - expandedPropValue.setProperty(expandedProp); - list.add(expandedPropValue); - } - return list; - } - - /** - * Append the initial values of each non-copy property in a - * compound expansion to a list. Note that these elements will be - * references to the initial values. Note also that, in the - * expansion of a compound value, the initial value comonents are - * regarded as having been specified. - * @param foTree - the FOTree of the node whose properties are - * being processed. - * @param expansion - the set of indices of the expansion properties. - * @param list - the list to which to append the expansion elements. - * @return the original PropertyValueList containing the - * appended initial value expansions for the (compound) property. - * @exception PropertyException - */ - public static PropertyValueList initialValueCompoundExpansion - (FOTree foTree, ROIntArray expansion, PropertyValueList list) - throws PropertyException - { - for (int i = 0; i < expansion.length; i++) { - int expandedProp = expansion.get(i); - PropertyValue specified - = foTree.getInitialValue(expandedProp); - list.add(specified); - } - return list; - } - private PropertySets (){} } diff --git a/src/org/apache/fop/fo/ShorthandPropSets.java b/src/org/apache/fop/fo/ShorthandPropSets.java new file mode 100644 index 000000000..9f41203ad --- /dev/null +++ b/src/org/apache/fop/fo/ShorthandPropSets.java @@ -0,0 +1,943 @@ +/** + * $Id$ + *
Copyright (C) 2001 The Apache Software Foundation. All rights reserved. + *
For details on use and redistribution please refer to the + *
LICENSE file included with these sources. + * + * @author Peter B. West + * @version $Revision$ $Name$ + */ + +package org.apache.fop.fo; + +import java.lang.CloneNotSupportedException; + +import java.util.Set; +import java.util.HashSet; +import java.util.HashMap; +import java.util.List; +import java.util.ListIterator; +import java.util.Iterator; +import java.util.Arrays; +import java.util.Collections; + +import org.apache.fop.fo.expr.PropertyException; +import org.apache.fop.datatypes.PropertyValue; +import org.apache.fop.datatypes.PropertyValueList; +import org.apache.fop.fo.PropNames; +import org.apache.fop.datastructs.ROIntArray; +import org.apache.fop.datatypes.Ints; + +/** + * This class contains ROIntArrays which encode the various sets of + * properties into which the shorthand and compound properties expand, and + * utility methods for manipulating these expansions. + */ +public class ShorthandPropSets { + + private static final String tag = "$Name$"; + private static final String revision = "$Revision$"; + + private static final String packageName = "org.apache.fop.fo"; + + + // My preference here for shorthands which expand to compound properties + // would be to expand only to the compound, and allow compounds to be + // "normally" expanded in a second step. Unfortunately, the shorthand + // border-spacing expands (potentially) into both of the elements of + // the border-separation compound. However, other compound expansions + // are defined with only a single value for the compound, so I will + // treat border-separation as a special case in the event that two + // values are provided. + // I''m not sure whether a shorthand specification which sets a compound + // property with a single top-level value should be regarded as a + // specification for the purposes of inheritance, but I will assume so + // until further notice. + // pbw + + private static final int[] backgroundPosition = { + PropNames.BACKGROUND_POSITION_HORIZONTAL + ,PropNames.BACKGROUND_POSITION_VERTICAL + }; + + private static final int[] borderColor = { + PropNames.BORDER_TOP_COLOR + ,PropNames.BORDER_RIGHT_COLOR + ,PropNames.BORDER_BOTTOM_COLOR + ,PropNames.BORDER_LEFT_COLOR + }; + + private static final int[] borderStyle = { + PropNames.BORDER_TOP_STYLE + ,PropNames.BORDER_RIGHT_STYLE + ,PropNames.BORDER_BOTTOM_STYLE + ,PropNames.BORDER_LEFT_STYLE + }; + + private static final int[] borderWidth = { + PropNames.BORDER_TOP_WIDTH + ,PropNames.BORDER_RIGHT_WIDTH + ,PropNames.BORDER_BOTTOM_WIDTH + ,PropNames.BORDER_LEFT_WIDTH + }; + + public static final ROIntArray backgroundExpansion = + new ROIntArray(new int[][] { + new int[] { + PropNames.BACKGROUND_COLOR + ,PropNames.BACKGROUND_IMAGE + ,PropNames.BACKGROUND_REPEAT + ,PropNames.BACKGROUND_ATTACHMENT + ,PropNames.BACKGROUND_POSITION_HORIZONTAL + ,PropNames.BACKGROUND_POSITION_VERTICAL + }, backgroundPosition}); + + public static final ROIntArray backgroundPositionExpansion = + new ROIntArray(backgroundPosition); + + public static final ROIntArray borderExpansion = + new ROIntArray(new int[][] { borderStyle, borderColor, borderWidth }); + + public static final ROIntArray borderStyleExpansion = + new ROIntArray(borderStyle); + + public static final ROIntArray borderColorExpansion = + new ROIntArray(borderColor); + + public static final ROIntArray borderWidthExpansion = + new ROIntArray(borderWidth); + + public static final ROIntArray borderTopExpansion = + new ROIntArray(new int[] { + PropNames.BORDER_TOP_STYLE + ,PropNames.BORDER_TOP_COLOR + ,PropNames.BORDER_TOP_WIDTH + }); + + public static final ROIntArray borderRightExpansion = + new ROIntArray(new int[] { + PropNames.BORDER_RIGHT_STYLE + ,PropNames.BORDER_RIGHT_COLOR + ,PropNames.BORDER_RIGHT_WIDTH + }); + + public static final ROIntArray borderBottomExpansion = + new ROIntArray(new int[] { + PropNames.BORDER_BOTTOM_STYLE + ,PropNames.BORDER_BOTTOM_COLOR + ,PropNames.BORDER_BOTTOM_WIDTH + }); + + public static final ROIntArray borderLeftExpansion = + new ROIntArray(new int[] { + PropNames.BORDER_LEFT_STYLE + ,PropNames.BORDER_LEFT_COLOR + ,PropNames.BORDER_LEFT_WIDTH + }); + + /** + * Watch this one. border-spacing is a shorthand which expands + * into the components of the <border-separation> compound + * property. + */ + public static final ROIntArray borderSpacingExpansion = + new ROIntArray(new int[] { + PropNames.BORDER_SEPARATION + }); + + public static final ROIntArray cueExpansion = + new ROIntArray(new int[] { + PropNames.CUE_BEFORE + ,PropNames.CUE_AFTER + }); + + /** + * Another nasty one. font expands, in part, into + * line-height, which is itself a compound property with a + * <space> value. + */ + public static final ROIntArray fontExpansion = + new ROIntArray(new int[] { + PropNames.FONT_FAMILY + ,PropNames.FONT_STYLE + ,PropNames.FONT_VARIANT + ,PropNames.FONT_WEIGHT + ,PropNames.FONT_SIZE + ,PropNames.LINE_HEIGHT + ,PropNames.FONT_SIZE_ADJUST + ,PropNames.FONT_STRETCH + ,PropNames.FONT_SELECTION_STRATEGY + }); + + public static final ROIntArray marginExpansion = + new ROIntArray(new int[] { + PropNames.MARGIN_TOP + ,PropNames.MARGIN_RIGHT + ,PropNames.MARGIN_BOTTOM + ,PropNames.MARGIN_LEFT + }); + + public static final ROIntArray paddingExpansion = + new ROIntArray(new int[] { + PropNames.PADDING_TOP + ,PropNames.PADDING_RIGHT + ,PropNames.PADDING_BOTTOM + ,PropNames.PADDING_LEFT + }); + + public static final ROIntArray pageBreakAfterExpansion = + new ROIntArray(new int[] { + PropNames.BREAK_AFTER + ,PropNames.KEEP_WITH_NEXT + }); + + public static final ROIntArray pageBreakBeforeExpansion = + new ROIntArray(new int[] { + PropNames.BREAK_BEFORE + ,PropNames.KEEP_WITH_PREVIOUS + }); + + public static final ROIntArray pageBreakInsideExpansion = + new ROIntArray(new int[] { + PropNames.KEEP_TOGETHER + }); + + public static final ROIntArray pauseExpansion = + new ROIntArray(new int[] { + PropNames.PAUSE_BEFORE + ,PropNames.PAUSE_AFTER + }); + + public static final ROIntArray positionExpansion = + new ROIntArray(new int[] { + PropNames.RELATIVE_POSITION + ,PropNames.ABSOLUTE_POSITION + }); + + public static final ROIntArray sizeExpansion = + new ROIntArray(new int[] { + PropNames.PAGE_HEIGHT + ,PropNames.PAGE_WIDTH + }); + + public static final ROIntArray verticalAlignExpansion = + new ROIntArray(new int[] { + PropNames.ALIGNMENT_BASELINE + ,PropNames.ALIGNMENT_ADJUST + ,PropNames.BASELINE_SHIFT + ,PropNames.DOMINANT_BASELINE + }); + + public static final ROIntArray whiteSpaceExpansion = + new ROIntArray(new int[] { + PropNames.LINEFEED_TREATMENT + ,PropNames.WHITE_SPACE_COLLAPSE + ,PropNames.WHITE_SPACE_TREATMENT + ,PropNames.WRAP_OPTION + }); + + public static final ROIntArray xmlLangExpansion = + new ROIntArray(new int[] { + PropNames.COUNTRY + ,PropNames.LANGUAGE + }); + + /** + * Shorthand properties. Where properties interact, they are listed + * in increasing precision. + */ + private static final int[] shorthands = { + PropNames.BACKGROUND + ,PropNames.BACKGROUND_POSITION + ,PropNames.BORDER + ,PropNames.BORDER_STYLE + ,PropNames.BORDER_COLOR + ,PropNames.BORDER_WIDTH + ,PropNames.BORDER_TOP + ,PropNames.BORDER_RIGHT + ,PropNames.BORDER_BOTTOM + ,PropNames.BORDER_LEFT + ,PropNames.BORDER_SPACING + ,PropNames.CUE + ,PropNames.FONT + ,PropNames.MARGIN + ,PropNames.PADDING + ,PropNames.PAGE_BREAK_AFTER + ,PropNames.PAGE_BREAK_BEFORE + ,PropNames.PAGE_BREAK_INSIDE + ,PropNames.PAUSE + ,PropNames.POSITION + ,PropNames.SIZE + ,PropNames.VERTICAL_ALIGN + ,PropNames.WHITE_SPACE + ,PropNames.XML_LANG + }; + + /** + * Map property index to shorthand array index + */ + private static final HashMap shorthandMap; + static { + shorthandMap = new HashMap(shorthands.length); + for (int i = 0; i < shorthands.length; i++) { + shorthandMap.put + ((Object)(Ints.consts.get(shorthands[i])), + (Object)(Ints.consts.get(i))); + } + } + + /** + * RO Shorthand properties. + */ + public static final ROIntArray roShorthands = + new ROIntArray(shorthands); + + /** + * Array of ROIntArray in same order as shorthands + * ROIntArray. + * If a public view of this is required, use + * Collections.unmodifiableList(Arrays.asList(shorthandExpansions)) + */ + private static final ROIntArray[] shorthandExpansions = { + backgroundExpansion + ,backgroundPositionExpansion + ,borderExpansion + ,borderStyleExpansion + ,borderColorExpansion + ,borderWidthExpansion + ,borderTopExpansion + ,borderRightExpansion + ,borderBottomExpansion + ,borderLeftExpansion + ,borderSpacingExpansion + ,cueExpansion + ,fontExpansion + ,marginExpansion + ,paddingExpansion + ,pageBreakAfterExpansion + ,pageBreakBeforeExpansion + ,pageBreakInsideExpansion + ,pauseExpansion + ,positionExpansion + ,sizeExpansion + ,verticalAlignExpansion + ,whiteSpaceExpansion + ,xmlLangExpansion + }; + + /** + * @param property int property index + * @return ROIntArray containing the expansion list for + * this shorthand. + * @exception PropertyException if this is not a valid + * shorthand property + */ + public static ROIntArray getSHandExpansionSet(int property) + throws PropertyException + { + // Is the property of the argument a shorthand? + Integer sHIndex = + (Integer)(shorthandMap.get(Ints.consts.get(property))); + if (sHIndex == null) { + String propname = PropNames.getPropertyName(property); + throw new PropertyException + (propname + " not a shorthand property"); + } + // Get the array of indices of the properties in the + // expansion of this shorthand + return shorthandExpansions[property]; + } + + /** + * Expand the shorthand property associated with the + * PropertyValue argument by copying the given value for each + * property in the expansion. The property field of each + * PropertyValue will be set to one of the proeprties in the + * shorthand expansion. + * @param value a propertyValue whose property field + * is assumed to be set to a shorthand property. + * @return PropertyValueList containing a list of + * PropertyValues, one for each property in the expansion of + * the shorthand property. + * @exception PropertyException + */ + public static PropertyValueList expandAndCopySHand(PropertyValue value) + throws PropertyException + { + // The property associated with this PropertyValue + int property = value.getProperty(); + ROIntArray expansion = getSHandExpansionSet(property); + PropertyValueList list = new PropertyValueList(property); + return copyValueToSet(value, expansion, list); + } + + /** + * Generate a list of the intial values of each property in a + * shorthand expansion. Note that this will be a list of + * references to the initial values. + * @param foTree the FOTree for which properties are being + * processed + * @param property int property index + * @return PropertyValueList containing the intial value + * expansions for the (shorthand) property + * @exception PropertyException + */ + /* + Don't do this. Shorthands should not expand initial values, because + a distinction is needed between those properties which are given + a specified value and those which are set by normal inheritance or from + their initial values. This so that fromSpecifiedValue() will work. + + public static PropertyValueList initialValueSHandExpansion + (FOTree foTree, int property) + throws PropertyException + { + ROIntArray expansion = getSHandExpansionSet(property); + PropertyValueList list = new PropertyValueList(property); + for (int i = 0; i < expansion.length; i++) { + int expandedProp = expansion.get(i); + PropertyValue specified + = foTree.getInitialSpecifiedValue(expandedProp); + list.add(specified); + } + return list; + } + */ + + /** + * Given a shorthand expansion list and a PropertyValue, + * override the list element corresponding to the PropertyValue. + * Correspondence is based on the property field of the + * PropertyValue. + * @param expansionList the expansion PropertyValueList + * @param element the overriding PropertyValue + * @return PropertyValueList the expansion list with the + * appropriate element reset + * @exception PropertyException + */ + public static PropertyValueList overrideSHandElement + (PropertyValueList expansionList, PropertyValue element) + throws PropertyException + { + int elementProp = element.getProperty(); + ListIterator elements = expansionList.listIterator(); + while (elements.hasNext()) { + PropertyValue next = (PropertyValue)(elements.next()); + if (next.getProperty() == elementProp) { + elements.set(element); + return expansionList; + } + } + throw new PropertyException + ("Unmatched property " + elementProp + + " in expansion list for " + expansionList.getProperty()); + } + + /** + * Given a shorthand expansion list and a PropertyValueList, + * override the expansion list elements corresponding to the elements + * of the PropertyValueList. + * Correspondence is based on the property field of the + * PropertyValue. + * @param expansionList the expansion PropertyValueList + * @param list the overriding PropertyValueList + * @return PropertyValueList the new expansion list with + * appropriate elements reset + * @exception PropertyException + */ + public static PropertyValueList overrideSHandElements + (PropertyValueList expansionList, PropertyValueList list) + throws PropertyException + { + // From the overriding list, form an array of PropertyValue references + // an array of property indices and an array of booleans, + int listsize = list.size(); + Object[] listrefs = new Object[listsize]; + int[] listprops = new int[listsize]; + boolean[] propseen = new boolean[listsize]; + Iterator listels = list.iterator(); + int i = 0; + while (listels.hasNext()) { + listrefs[i] = listels.next(); + listprops[i] = ((PropertyValue)listrefs[i]).getProperty(); + i++; + } + + ListIterator elements = expansionList.listIterator(); + while (elements.hasNext()) { + PropertyValue next = (PropertyValue)(elements.next()); + int expprop = next.getProperty(); + for (i = 0; i < listsize; i++) { + if (expprop != listprops[i]) continue; + elements.set(listrefs[i]); + propseen[i] = true; + } + } + // Check for unmatched override elements + String unmatched = ""; + boolean someunmatched = false; + for (i = 0; i < listsize; i++) { + if ( ! propseen[i]) { + someunmatched = true; + unmatched = unmatched + " " + + PropNames.getPropertyName(listprops[i]); + } + } + if (someunmatched) + throw new PropertyException + ("Unmatched properties:" + unmatched + + " : in expansion list for " + expansionList.getProperty()); + return expansionList; + } + + public static final ROIntArray blockProgressionDimensionCopyExpansion = + new ROIntArray(new int[] { + PropNames.BLOCK_PROGRESSION_DIMENSION_MINIMUM + ,PropNames.BLOCK_PROGRESSION_DIMENSION_OPTIMUM + ,PropNames.BLOCK_PROGRESSION_DIMENSION_MAXIMUM + }); + + public static final ROIntArray blockProgressionDimensionNonCopyExpansion = + new ROIntArray(new int[] {}); + + public static final ROIntArray borderAfterWidthCopyExpansion = + new ROIntArray(new int[] { + PropNames.BORDER_AFTER_WIDTH_LENGTH + }); + + public static final ROIntArray borderAfterWidthNonCopyExpansion = + new ROIntArray(new int[] { + PropNames.BORDER_AFTER_WIDTH_CONDITIONALITY + }); + + public static final ROIntArray borderBeforeWidthCopyExpansion = + new ROIntArray(new int[] { + PropNames.BORDER_BEFORE_WIDTH_LENGTH + }); + + public static final ROIntArray borderBeforeWidthNonCopyExpansion = + new ROIntArray(new int[] { + PropNames.BORDER_BEFORE_WIDTH_CONDITIONALITY + }); + + public static final ROIntArray borderEndWidthCopyExpansion = + new ROIntArray(new int[] { + PropNames.BORDER_END_WIDTH_LENGTH + }); + + public static final ROIntArray borderEndWidthNonCopyExpansion = + new ROIntArray(new int[] { + PropNames.BORDER_END_WIDTH_CONDITIONALITY + }); + + public static final ROIntArray borderStartWidthCopyExpansion = + new ROIntArray(new int[] { + PropNames.BORDER_START_WIDTH_LENGTH + }); + + public static final ROIntArray borderStartWidthNonCopyExpansion = + new ROIntArray(new int[] { + PropNames.BORDER_START_WIDTH_CONDITIONALITY + }); + + public static final ROIntArray borderSeparationCopyExpansion = + new ROIntArray(new int[] { + PropNames.BORDER_SEPARATION_BLOCK_PROGRESSION_DIRECTION + ,PropNames.BORDER_SEPARATION_INLINE_PROGRESSION_DIRECTION + }); + + public static final ROIntArray borderSeparationNonCopyExpansion = + new ROIntArray(new int[] {}); + + public static final ROIntArray inlineProgressionDimensionCopyExpansion = + new ROIntArray(new int[] { + PropNames.INLINE_PROGRESSION_DIMENSION_MINIMUM + ,PropNames.INLINE_PROGRESSION_DIMENSION_OPTIMUM + ,PropNames.INLINE_PROGRESSION_DIMENSION_MAXIMUM + }); + + public static final ROIntArray inlineProgressionDimensionNonCopyExpansion = + new ROIntArray(new int[] {}); + + public static final ROIntArray keepTogetherCopyExpansion = + new ROIntArray(new int[] { + PropNames.KEEP_TOGETHER_WITHIN_LINE + ,PropNames.KEEP_TOGETHER_WITHIN_COLUMN + ,PropNames.KEEP_TOGETHER_WITHIN_PAGE + }); + + public static final ROIntArray keepTogetherNonCopyExpansion = + new ROIntArray(new int[] {}); + + public static final ROIntArray keepWithNextCopyExpansion = + new ROIntArray(new int[] { + PropNames.KEEP_WITH_NEXT_WITHIN_LINE + ,PropNames.KEEP_WITH_NEXT_WITHIN_COLUMN + ,PropNames.KEEP_WITH_NEXT_WITHIN_PAGE + }); + + public static final ROIntArray keepWithNextNonCopyExpansion = + new ROIntArray(new int[] {}); + + public static final ROIntArray keepWithPreviousCopyExpansion = + new ROIntArray(new int[] { + PropNames.KEEP_WITH_PREVIOUS_WITHIN_LINE + ,PropNames.KEEP_WITH_PREVIOUS_WITHIN_COLUMN + ,PropNames.KEEP_WITH_PREVIOUS_WITHIN_PAGE + }); + + public static final ROIntArray keepWithPreviousNonCopyExpansion = + new ROIntArray(new int[] {}); + + public static final ROIntArray leaderLengthCopyExpansion = + new ROIntArray(new int[] { + PropNames.LEADER_LENGTH_MINIMUM + ,PropNames.LEADER_LENGTH_OPTIMUM + ,PropNames.LEADER_LENGTH_MAXIMUM + }); + + public static final ROIntArray leaderLengthNonCopyExpansion = + new ROIntArray(new int[] {}); + + public static final ROIntArray letterSpacingCopyExpansion = + new ROIntArray(new int[] { + PropNames.LETTER_SPACING_MINIMUM + ,PropNames.LETTER_SPACING_OPTIMUM + ,PropNames.LETTER_SPACING_MAXIMUM + }); + + public static final ROIntArray letterSpacingNonCopyExpansion = + new ROIntArray(new int[] { + PropNames.LETTER_SPACING_CONDITIONALITY + ,PropNames.LETTER_SPACING_PRECEDENCE + }); + + public static final ROIntArray lineHeightCopyExpansion = + new ROIntArray(new int[] { + PropNames.LINE_HEIGHT_MINIMUM + ,PropNames.LINE_HEIGHT_OPTIMUM + ,PropNames.LINE_HEIGHT_MAXIMUM + }); + + public static final ROIntArray lineHeightNonCopyExpansion = + new ROIntArray(new int[] { + PropNames.LINE_HEIGHT_CONDITIONALITY + ,PropNames.LINE_HEIGHT_PRECEDENCE + }); + + public static final ROIntArray paddingAfterCopyExpansion = + new ROIntArray(new int[] { + PropNames.PADDING_AFTER_LENGTH + }); + + public static final ROIntArray paddingAfterNonCopyExpansion = + new ROIntArray(new int[] { + PropNames.PADDING_AFTER_CONDITIONALITY + }); + + public static final ROIntArray paddingBeforeCopyExpansion = + new ROIntArray(new int[] { + PropNames.PADDING_BEFORE_LENGTH + }); + + public static final ROIntArray paddingBeforeNonCopyExpansion = + new ROIntArray(new int[] { + PropNames.PADDING_BEFORE_CONDITIONALITY + }); + + public static final ROIntArray paddingEndCopyExpansion = + new ROIntArray(new int[] { + PropNames.PADDING_END_LENGTH + }); + + public static final ROIntArray paddingEndNonCopyExpansion = + new ROIntArray(new int[] { + PropNames.PADDING_END_CONDITIONALITY + }); + + public static final ROIntArray paddingStartCopyExpansion = + new ROIntArray(new int[] { + PropNames.PADDING_START_LENGTH + }); + + public static final ROIntArray paddingStartNonCopyExpansion = + new ROIntArray(new int[] { + PropNames.PADDING_START_CONDITIONALITY + }); + + public static final ROIntArray spaceAfterCopyExpansion = + new ROIntArray(new int[] { + PropNames.SPACE_AFTER_MINIMUM + ,PropNames.SPACE_AFTER_OPTIMUM + ,PropNames.SPACE_AFTER_MAXIMUM + }); + + public static final ROIntArray spaceAfterNonCopyExpansion = + new ROIntArray(new int[] { + PropNames.SPACE_AFTER_CONDITIONALITY + ,PropNames.SPACE_AFTER_PRECEDENCE + }); + + public static final ROIntArray spaceBeforeCopyExpansion = + new ROIntArray(new int[] { + PropNames.SPACE_BEFORE_MINIMUM + ,PropNames.SPACE_BEFORE_OPTIMUM + ,PropNames.SPACE_BEFORE_MAXIMUM + }); + + public static final ROIntArray spaceBeforeNonCopyExpansion = + new ROIntArray(new int[] { + PropNames.SPACE_BEFORE_CONDITIONALITY + ,PropNames.SPACE_BEFORE_PRECEDENCE + }); + + public static final ROIntArray spaceEndCopyExpansion = + new ROIntArray(new int[] { + PropNames.SPACE_END_MINIMUM + ,PropNames.SPACE_END_OPTIMUM + ,PropNames.SPACE_END_MAXIMUM + }); + + public static final ROIntArray spaceEndNonCopyExpansion = + new ROIntArray(new int[] { + PropNames.SPACE_END_CONDITIONALITY + ,PropNames.SPACE_END_PRECEDENCE + }); + + public static final ROIntArray spaceStartCopyExpansion = + new ROIntArray(new int[] { + PropNames.SPACE_START_MINIMUM + ,PropNames.SPACE_START_OPTIMUM + ,PropNames.SPACE_START_MAXIMUM + }); + + public static final ROIntArray spaceStartNonCopyExpansion = + new ROIntArray(new int[] { + PropNames.SPACE_START_CONDITIONALITY + ,PropNames.SPACE_START_PRECEDENCE + }); + + public static final ROIntArray wordSpacingCopyExpansion = + new ROIntArray(new int[] { + PropNames.WORD_SPACING_MINIMUM + ,PropNames.WORD_SPACING_OPTIMUM + ,PropNames.WORD_SPACING_MAXIMUM + }); + + public static final ROIntArray wordSpacingNonCopyExpansion = + new ROIntArray(new int[] { + PropNames.WORD_SPACING_CONDITIONALITY + ,PropNames.WORD_SPACING_PRECEDENCE + }); + + private static final int[] compounds = { + PropNames.BLOCK_PROGRESSION_DIMENSION + ,PropNames.BORDER_AFTER_WIDTH + ,PropNames.BORDER_BEFORE_WIDTH + ,PropNames.BORDER_END_WIDTH + ,PropNames.BORDER_START_WIDTH + ,PropNames.BORDER_SEPARATION + ,PropNames.INLINE_PROGRESSION_DIMENSION + ,PropNames.KEEP_TOGETHER + ,PropNames.KEEP_WITH_NEXT + ,PropNames.KEEP_WITH_PREVIOUS + ,PropNames.LEADER_LENGTH + ,PropNames.LETTER_SPACING + ,PropNames.LINE_HEIGHT + ,PropNames.PADDING_AFTER + ,PropNames.PADDING_BEFORE + ,PropNames.PADDING_END + ,PropNames.PADDING_START + ,PropNames.SPACE_AFTER + ,PropNames.SPACE_BEFORE + ,PropNames.SPACE_END + ,PropNames.SPACE_START + ,PropNames.WORD_SPACING + }; + + /** + * Map property index to compound array index + */ + private static final HashMap compoundMap; + static { + compoundMap = new HashMap(compounds.length); + for (int i = 0; i < compounds.length; i++) { + compoundMap.put + ((Object)(Ints.consts.get(compounds[i])), + (Object)(Ints.consts.get(i))); + } + } + + /** + * RO compound properties. + */ + public static final ROIntArray roCompounds; + static { + roCompounds = new ROIntArray(compounds); + } + + /** + * Array of ROIntArray of the copy expansion properties of + * compounds in same order as compounds + * ROIntArray. + * If a public view of this is required, use + * Collections.unmodifiableList(Arrays.asList(compoundCopyExpansions)) + */ + private static final ROIntArray[] compoundCopyExpansions = { + blockProgressionDimensionCopyExpansion + ,borderAfterWidthCopyExpansion + ,borderBeforeWidthCopyExpansion + ,borderEndWidthCopyExpansion + ,borderStartWidthCopyExpansion + ,borderSeparationCopyExpansion + ,inlineProgressionDimensionCopyExpansion + ,keepTogetherCopyExpansion + ,keepWithNextCopyExpansion + ,keepWithPreviousCopyExpansion + ,leaderLengthCopyExpansion + ,letterSpacingCopyExpansion + ,lineHeightCopyExpansion + ,paddingAfterCopyExpansion + ,paddingBeforeCopyExpansion + ,paddingEndCopyExpansion + ,paddingStartCopyExpansion + ,spaceAfterCopyExpansion + ,spaceBeforeCopyExpansion + ,spaceEndCopyExpansion + ,spaceStartCopyExpansion + ,wordSpacingCopyExpansion + }; + + /** + * Array of ROIntArray of the non-copy expansion properties of + * compounds in same order as compounds + * ROIntArray. + * If a public view of this is required, use + * Collections.unmodifiableList(Arrays.asList(compoundNonCopyExpansions)) + */ + private static final ROIntArray[] compoundNonCopyExpansions = { + blockProgressionDimensionNonCopyExpansion + ,borderAfterWidthNonCopyExpansion + ,borderBeforeWidthNonCopyExpansion + ,borderEndWidthNonCopyExpansion + ,borderStartWidthNonCopyExpansion + ,borderSeparationNonCopyExpansion + ,inlineProgressionDimensionNonCopyExpansion + ,keepTogetherNonCopyExpansion + ,keepWithNextNonCopyExpansion + ,keepWithPreviousNonCopyExpansion + ,leaderLengthNonCopyExpansion + ,letterSpacingNonCopyExpansion + ,lineHeightNonCopyExpansion + ,paddingAfterNonCopyExpansion + ,paddingBeforeNonCopyExpansion + ,paddingEndNonCopyExpansion + ,paddingStartNonCopyExpansion + ,spaceAfterNonCopyExpansion + ,spaceBeforeNonCopyExpansion + ,spaceEndNonCopyExpansion + ,spaceStartNonCopyExpansion + ,wordSpacingNonCopyExpansion + }; + + /** + * Expand the PropertyValue assigned to a compound property + * into propertyValues for the individual property components. + * N.B. This method assumes that the set of expansion properties is + * comprised of a copy and a non-copy set. For example, <space> + * compounds have a copy set of .minimum, .optimum and .maximum, and a + * non-copy set of .precedence and .conditionality. For each element of + * the copy set, the given value is cloned. For each member of the + * non-copy set, a reference to the initial value is taken. + * @param foTree - the FOTree for which properties are being + * developed. + * @param value - the PropertyValue to be cloned for the copy + * set members. + * @return a PropertyValueList containing the copy set + * expansions followed by the non-copy set expansions, in the order + * they are defined in appropriate ROIntArrays in this class. + */ + public static PropertyValueList expandCompoundProperty + (FOTree foTree, PropertyValue value) + throws PropertyException + { + int property = value.getProperty(); + Integer compoundX = + (Integer)(compoundMap.get(Ints.consts.get(property))); + if (compoundX == null) + throw new PropertyException + (PropNames.getPropertyName(property) + " (" + property + ") " + + " is not a compound property."); + int compoundIdx = compoundX.intValue(); + PropertyValueList list = new PropertyValueList(property); + ROIntArray expansion; + // Expand the copy components + list = copyValueToSet + (value, compoundCopyExpansions[compoundIdx], list); + // Expand the non-copy components + return initialValueCompoundExpansion + (foTree, compoundNonCopyExpansions[compoundIdx], list); + } + + /** + * Clone the given property value for each property in the given + * expansion set. Append the new property values to the given list. + * @param value - the property value to clone. + * @param expansionSet - the set of indices of the expansion properties. + * @param list - the list to which to append the expansion elements. + * @return the original PropertyValueList containing the + * appended expansions. + * @exception PropertyException + */ + private static PropertyValueList copyValueToSet(PropertyValue value, + ROIntArray expansionSet, PropertyValueList list) + throws PropertyException + { + for (int i = 0; i < expansionSet.length; i++) { + int expandedProp = expansionSet.get(i); + PropertyValue expandedPropValue; + // The PropertyValue must be cloneable + // The property associated with each PV in the expansion will + // necessarily be different. + try { + expandedPropValue = (PropertyValue)(value.clone()); + } catch (CloneNotSupportedException e) { + throw new PropertyException(e.getMessage()); + } + + expandedPropValue.setProperty(expandedProp); + list.add(expandedPropValue); + } + return list; + } + + /** + * Append the initial values of each non-copy property in a + * compound expansion to a list. Note that these elements will be + * references to the initial values. Note also that, in the + * expansion of a compound value, the initial value comonents are + * regarded as having been specified. + * @param foTree - the FOTree of the node whose properties are + * being processed. + * @param expansion - the set of indices of the expansion properties. + * @param list - the list to which to append the expansion elements. + * @return the original PropertyValueList containing the + * appended initial value expansions for the (compound) property. + * @exception PropertyException + */ + public static PropertyValueList initialValueCompoundExpansion + (FOTree foTree, ROIntArray expansion, PropertyValueList list) + throws PropertyException + { + for (int i = 0; i < expansion.length; i++) { + int expandedProp = expansion.get(i); + PropertyValue specified + = foTree.getInitialValue(expandedProp); + list.add(specified); + } + return list; + } + + private ShorthandPropSets (){} + +} diff --git a/src/org/apache/fop/fo/expr/SystemFontFunction.java b/src/org/apache/fop/fo/expr/SystemFontFunction.java index 5e14d6305..3946c9159 100644 --- a/src/org/apache/fop/fo/expr/SystemFontFunction.java +++ b/src/org/apache/fop/fo/expr/SystemFontFunction.java @@ -9,7 +9,7 @@ package org.apache.fop.fo.expr; import org.apache.fop.fo.Properties.Font; import org.apache.fop.fo.PropNames; -import org.apache.fop.fo.PropertySets; +import org.apache.fop.fo.ShorthandPropSets; import org.apache.fop.fo.expr.PropertyException; import org.apache.fop.fo.expr.FunctionNotImplementedException; import org.apache.fop.datastructs.ROIntArray; @@ -29,7 +29,7 @@ public class SystemFontFunction { * Return the PropertyValue appropriate to the property * of the argument. property must be one of the font * characteristic properties in the expansion set of the font - * shorthand property; PropertySets.fontExpansion. + * shorthand property; ShorthandPropSets.fontExpansion. * @param property int index of the font characteristic property * to be returned. * @param font String name of the system font @@ -50,7 +50,7 @@ public class SystemFontFunction { * font characteristic, named by propName, defined on the * system font named by font. propName must be one of * characteristic properties in the expansion set of the font - * shorthand property; PropertySets.fontExpansion. + * shorthand property; ShorthandPropSets.fontExpansion. * @param property int index of the property for the * PropertyValue to be returned. * @param font String name of the system font @@ -88,7 +88,7 @@ public class SystemFontFunction { { // Get the array of indices of the properties in the // expansion of this shorthand - ROIntArray expansion = PropertySets.fontExpansion; + ROIntArray expansion = ShorthandPropSets.fontExpansion; PropertyValueList list = new PropertyValueList(property); for (int i = 0; i < expansion.length; i++) { list.add(systemFontCharacteristic(expansion.get(i), font)); -- 2.39.5