// text-align TODO: make it a StringProperty with enums.
m = new EnumProperty.Maker(PR_TEXT_ALIGN) {
public Property get(int subpropId, PropertyList propertyList,
boolean bTryInherit, boolean bTryDefault) throws PropertyException {
Property p = super.get(subpropId, propertyList, bTryInherit, bTryDefault);
if ( p != null ) {
int pv = p.getEnum();
if ( ( pv == EN_LEFT ) || ( pv == EN_RIGHT ) ) {
p = calcWritingModeDependent
( pv, propertyList.get(Constants.PR_WRITING_MODE).getEnum() );
}
}
return p;
}
};
m.setInherited(true);
m.addEnum("center", getEnumProperty(EN_CENTER, "CENTER"));
m.addEnum("end", getEnumProperty(EN_END, "END"));
m.addEnum("start", getEnumProperty(EN_START, "START"));
m.addEnum("justify", getEnumProperty(EN_JUSTIFY, "JUSTIFY"));
// [GA] must defer writing-mode relative mapping of left/right
m.addEnum("left", getEnumProperty(EN_LEFT, "LEFT"));
m.addEnum("right", getEnumProperty(EN_RIGHT, "RIGHT"));
// [GA] inside and outside are not correctly implemented by the following mapping
m.addEnum("inside", getEnumProperty(EN_START, "START"));
m.addEnum("outside", getEnumProperty(EN_END, "END"));
m.setDefault("start");
addPropertyMaker("text-align", m);
// text-align-last
m = new EnumProperty.Maker(PR_TEXT_ALIGN_LAST) {
public Property get(int subpropId, PropertyList propertyList,
boolean bTryInherit, boolean bTryDefault) throws PropertyException {
Property p = super.get(subpropId, propertyList, bTryInherit, bTryDefault);
if (p != null && p.getEnum() == EN_RELATIVE) {
//The default may have been returned, so check inherited value
p = propertyList.getNearestSpecified(PR_TEXT_ALIGN_LAST);
if (p.getEnum() == EN_RELATIVE) {
return calcRelative(propertyList);
}
}
return p;
}
private Property calcRelative(PropertyList propertyList) throws PropertyException {
Property corresponding = propertyList.get(PR_TEXT_ALIGN);
if (corresponding == null) {
return null;
}
int correspondingValue = corresponding.getEnum();
if (correspondingValue == EN_JUSTIFY) {
return getEnumProperty(EN_START, "START");
} else if (correspondingValue == EN_END) {
return getEnumProperty(EN_END, "END");
} else if (correspondingValue == EN_START) {