return super.getSubpropMaker(subprop);
}
- protected Property setSubprop(Property baseProp, String subpropName,
+ protected Property setSubprop(Property baseProp, int subpropId,
Property subProp) {
</xsl:text>
+ String subpropName = FOPropertyMapping.getPropertyName(subpropId);
<xsl:value-of select="datatype"/>
<xsl:text> val = baseProp.get</xsl:text>
<xsl:value-of select="datatype"/>
<xsl:if test=".//corresponding/@use-if-specified='true'">
<xsl:text>
public boolean isCorrespondingForced(PropertyList propertyList) {
- FObj parentFO = propertyList.getParentFObj();
- StringBuffer sbExpr=new StringBuffer();</xsl:text>
+ FObj parentFO = propertyList.getParentFObj();</xsl:text>
<xsl:for-each select=".//corresponding/propval">
<xsl:text>
- sbExpr.setLength(0);</xsl:text>
+ if (propertyList.getExplicit(</xsl:text>
<xsl:apply-templates select="."/>
- <xsl:text>
- if (propertyList.getExplicit(sbExpr.toString()) != null)
+ <xsl:text>) != null)
return true;</xsl:text>
</xsl:for-each>
<xsl:text>
public Property compute(PropertyList propertyList) throws FOPException {
FObj parentFO = propertyList.getParentFObj();
- StringBuffer sbExpr=new StringBuffer();
Property p=null;</xsl:text>
<xsl:choose>
<xsl:when test="corresponding/propexpr">
- <xsl:apply-templates select="corresponding/propval"/>
<xsl:text>
// Make sure the property is set before calculating it!
- if (propertyList.getExplicitOrShorthand(sbExpr.toString()) == null)
+ if (propertyList.getExplicitOrShorthand(</xsl:text>
+ <xsl:apply-templates select="corresponding/propval"/>
+ <xsl:text>) == null)
return p;
+ StringBuffer sbExpr=new StringBuffer();
sbExpr.setLength(0);</xsl:text>
<xsl:apply-templates select="corresponding/propexpr"/>
<xsl:text>
p = make(propertyList, sbExpr.toString(), propertyList.getParentFObj());</xsl:text>
</xsl:when>
<xsl:otherwise>
- <xsl:apply-templates select="corresponding/propval"/>
<xsl:text>
- p= propertyList.getExplicitOrShorthand(sbExpr.toString());</xsl:text>
+ p= propertyList.getExplicitOrShorthand(</xsl:text>
+ <xsl:apply-templates select="corresponding/propval"/>
+ <xsl:text>);</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:text>
Property subprop;</xsl:text>
<xsl:for-each select="compound/subproperty/corresponding">
- <xsl:text>
- sbExpr.setLength(0);</xsl:text>
<xsl:choose>
<xsl:when test="propexpr">
<xsl:apply-templates select="propexpr"/>
make(propertyList, sbExpr.toString(), parentFO);</xsl:text>
</xsl:when>
<xsl:otherwise>
- <xsl:apply-templates select="propval"/>
<xsl:text>
- subprop = propertyList.getExplicitOrShorthand(sbExpr.toString());</xsl:text>
+ subprop = propertyList.getExplicitOrShorthand(</xsl:text>
+ <xsl:apply-templates select="propval"/>
+ <xsl:text>);</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:text>
if (subprop != null) {
- setSubprop(p, "</xsl:text>
- <xsl:value-of select='../name'/>
- <xsl:text>", subprop);
+ setSubprop(p, Constants.CP_</xsl:text>
+ <xsl:call-template name="makeEnumConstant">
+ <xsl:with-param name="propstr" select="../name"/>
+ </xsl:call-template>
+ <xsl:text>, subprop);
}</xsl:text>
</xsl:for-each>
</xsl:if>
<xsl:text>
if (p == null) {
listprop =
- (ListProperty)propertyList.getExplicit("</xsl:text>
- <xsl:value-of select='$shprop'/>
- <xsl:text>");
+ (ListProperty)propertyList.getExplicit(Constants.PR_</xsl:text>
+ <xsl:call-template name="makeEnumConstant">
+ <xsl:with-param name="propstr" select="$shprop"/>
+ </xsl:call-template>
+ <xsl:text>);
if (listprop != null) {
// Get a parser for the shorthand to set the individual properties
ShorthandParser shparser =
</xsl:template>
+<xsl:template match="propval">
+ <xsl:choose>
+ <xsl:when test="wmabs2rel[@dir='LEFT']">
+ <xsl:call-template name="makeMap">
+ <xsl:with-param name="lrtb" select='"START"'/>
+ <xsl:with-param name="rltb" select='"END"'/>
+ <xsl:with-param name="tbrl" select='"AFTER"'/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test="wmabs2rel[@dir='RIGHT']">
+ <xsl:call-template name="makeMap">
+ <xsl:with-param name="lrtb" select='"END"'/>
+ <xsl:with-param name="rltb" select='"START"'/>
+ <xsl:with-param name="tbrl" select='"BEFORE"'/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test="wmabs2rel[@dir='TOP']">
+ <xsl:call-template name="makeMap">
+ <xsl:with-param name="lrtb" select='"BEFORE"'/>
+ <xsl:with-param name="rltb" select='"BEFORE"'/>
+ <xsl:with-param name="tbrl" select='"START"'/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test="wmabs2rel[@dir='BOTTOM']">
+ <xsl:call-template name="makeMap">
+ <xsl:with-param name="lrtb" select='"AFTER"'/>
+ <xsl:with-param name="rltb" select='"AFTER"'/>
+ <xsl:with-param name="tbrl" select='"END"'/>
+ </xsl:call-template>
+ </xsl:when>
+
+ <xsl:when test="wmrel2abs[@dir='START']">
+ <xsl:call-template name="makeMap">
+ <xsl:with-param name="lrtb" select='"LEFT"'/>
+ <xsl:with-param name="rltb" select='"RIGHT"'/>
+ <xsl:with-param name="tbrl" select='"TOP"'/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test="wmrel2abs[@dir='END']">
+ <xsl:call-template name="makeMap">
+ <xsl:with-param name="lrtb" select='"RIGHT"'/>
+ <xsl:with-param name="rltb" select='"LEFT"'/>
+ <xsl:with-param name="tbrl" select='"BOTTOM"'/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test="wmrel2abs[@dir='BEFORE'] or parwmrel2abs[@dir='BEFORE']">
+ <xsl:call-template name="makeMap">
+ <xsl:with-param name="lrtb" select='"TOP"'/>
+ <xsl:with-param name="rltb" select='"TOP"'/>
+ <xsl:with-param name="tbrl" select='"RIGHT"'/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test="wmrel2abs[@dir='AFTER'] or parwmrel2abs[@dir='AFTER']">
+ <xsl:call-template name="makeMap">
+ <xsl:with-param name="lrtb" select='"BOTTOM"'/>
+ <xsl:with-param name="rltb" select='"BOTTOM"'/>
+ <xsl:with-param name="tbrl" select='"LEFT"'/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test="wmrel2abs[@dir='BLOCKPROGDIM']">
+ <xsl:call-template name="makeMap">
+ <xsl:with-param name="lrtb" select='"HEIGHT"'/>
+ <xsl:with-param name="rltb" select='"HEIGHT"'/>
+ <xsl:with-param name="tbrl" select='"WIDTH"'/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test="wmrel2abs[@dir='INLINEPROGDIM']">
+ <xsl:call-template name="makeMap">
+ <xsl:with-param name="lrtb" select='"WIDTH"'/>
+ <xsl:with-param name="rltb" select='"WIDTH"'/>
+ <xsl:with-param name="tbrl" select='"HEIGHT"'/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>UNKNOWN <xsl:value-of select="."/></xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
<xsl:template match="corresponding//text()">
<xsl:variable name="tval" select='normalize-space(.)'/>
<xsl:if test="$tval != ''">
</xsl:if>
</xsl:template>
+<xsl:template name="makeMap">
+ <xsl:param name="lrtb"/>
+ <xsl:param name="rltb"/>
+ <xsl:param name="tbrl"/>
+ <xsl:text>propertyList.wmMap(Constants.PR_</xsl:text>
+ <xsl:apply-templates mode="x">
+ <xsl:with-param name="dir" select='$lrtb'/>
+ </xsl:apply-templates>
+ <xsl:text>, Constants.PR_</xsl:text>
+ <xsl:apply-templates mode="x">
+ <xsl:with-param name="dir" select='$rltb'/>
+ </xsl:apply-templates>
+ <xsl:text>, Constants.PR_</xsl:text>
+ <xsl:apply-templates mode="x">
+ <xsl:with-param name="dir" select='$tbrl'/>
+ </xsl:apply-templates>
+ <xsl:text>)</xsl:text>
+</xsl:template>
+
+<xsl:template match="corresponding//text()" mode="x">
+ <xsl:variable name="tval" select='normalize-space(.)'/>
+ <xsl:if test="$tval != ''">
+ <xsl:call-template name="makeEnumConstant">
+ <xsl:with-param name="propstr" select="$tval"/>
+ </xsl:call-template>
+ </xsl:if>
+</xsl:template>
+
<xsl:template match="propval/wmrel2abs">
<xsl:text>
sbExpr.append(propertyList.wmRelToAbs(PropertyList.</xsl:text>
<xsl:text>));</xsl:text>
</xsl:template>
+<xsl:template match="propval/wmrel2abs" mode="x">
+ <xsl:param name="dir"/>
+ <xsl:value-of select="$dir"/>
+</xsl:template>
+
+<xsl:template match="propval/parwmrel2abs" mode="x">
+ <xsl:param name="dir"/>
+ <xsl:value-of select="$dir"/>
+</xsl:template>
+
+<xsl:template match="propval/wmabs2rel" mode="x">
+ <xsl:param name="dir"/>
+ <xsl:value-of select="$dir"/>
+</xsl:template>
+
<!-- avoid unwanted output to placeholder file -->
<xsl:template match="localname"/>
// writing-mode values
private byte[] wmtable = null;
+ private int writingMode;
// absolute directions and dimensions
/** constant for direction "left" */
* @return The value if the property is explicitly set or set by
* a shorthand property, otherwise null.
*/
- public Property getExplicitOrShorthand(String propertyName) {
+ public Property getExplicitOrShorthand(int propId) {
/* Handle request for one part of a compound property */
- int propId = FOPropertyMapping.getPropertyId(propertyName);
+ String propertyName = FOPropertyMapping.getPropertyName(propId);
int sepchar = propertyName.indexOf('.');
String baseName;
}
Property p = getExplicitBaseProp(baseName);
if (p == null) {
- p = getShorthand(namespace, elementName, baseName);
+ p = getShorthand(propId & Constants.PROPERTY_MASK);
}
if (p != null && sepchar > -1) {
return getSubpropValue(p, propId);
* It may be a compound name, such as space-before.optimum.
* @return The value if the property is explicitly set, otherwise null.
*/
- public Property getExplicit(String propertyName) {
- int propId = FOPropertyMapping.getPropertyId(propertyName);
+ public Property getExplicit(int propId) {
+ String propertyName = FOPropertyMapping.getPropertyName(propId);
/* Handle request for one part of a compound property */
int sepchar = propertyName.indexOf('.');
p = this.computeProperty(propId);
}
if (p == null) { // check for shorthand specification
- p = getShorthand(namespace, elementName, propertyName);
+ p = getShorthand(propId);
}
if (p == null && bTryInherit) {
// else inherit (if has parent and is inheritable)
* @return The computed value if the property is explicitly set on some
* ancestor of the current FO, else the initial value.
*/
- public Property getNearestSpecified(String propertyName) {
- int propId = FOPropertyMapping.getPropertyId(propertyName);
+ public Property getNearestSpecified(int propId) {
+ String propertyName = FOPropertyMapping.getPropertyName(propId);
Property p = null;
for (PropertyList plist = this; p == null && plist != null;
plist = plist.parentPropertyList) {
- p = plist.getExplicit(propertyName);
+ p = plist.getExplicit(propId);
}
if (p == null) {
// If no explicit setting found, return initial (default) value.
* FO is the root or is in a different namespace from its parent.
*/
public Property getFromParent(int propId) {
- String propertyName = FOPropertyMapping.getPropertyName(propId);
-
+
if (parentPropertyList != null) {
return parentPropertyList.get(propId);
} else {
return null; // Exception in makeProperty!
}
+ /**
+ * Uses the stored writingMode.
+ * @param absdir an absolute direction (top, bottom, left, right)
+ * @return the corresponding writing model relative direction name
+ * for the flow object.
+ */
+ public int wmMap(int lrtb, int rltb, int tbrl) {
+ switch (writingMode) {
+ case WritingMode.LR_TB: return lrtb;
+ case WritingMode.RL_TB: return lrtb;
+ case WritingMode.TB_RL: return lrtb;
+ }
+ return -1;
+ }
+
/**
* Uses the stored writingMode.
* @param absdir an absolute direction (top, bottom, left, right)
* @param writingMode the writing-mode property to be set for this object
*/
public void setWritingMode(int writingMode) {
+ this.writingMode = writingMode;
this.wmtable = (byte[])WRITING_MODE_TABLES.get(new Integer(writingMode));
}
* @param attributeName String to be atomized
* @return the base portion of the attribute
*/
- public static String findBasePropertyName(String attributeName) {
+ private static String findBasePropertyName(String attributeName) {
int sepCharIndex = attributeName.indexOf('.');
String basePropName = attributeName;
if (sepCharIndex > -1) {
* @param attributeName String to be atomized
* @return the sub portion of the attribute
*/
- public static String findSubPropertyName(String attributeName) {
+ private static String findSubPropertyName(String attributeName) {
int sepCharIndex = attributeName.indexOf('.');
String subPropName = null;
if (sepCharIndex > -1) {
}
/**
- * @param propertyName name of property
+ * @param propId ID of property
* @return new Property object
*/
- private Property getShorthand(String space, String element,
- String propertyName) {
- int propId = FOPropertyMapping.getPropertyId(propertyName);
-
+ private Property getShorthand(int propId) {
Property.Maker propertyMaker = findMaker(propId);
if (propertyMaker != null) {
boolean isBorderPresent = false;
// Cell background color
- if ((p = props.getNearestSpecified("background-color")) != null) {
+ if ((p = props.getNearestSpecified(Constants.PR_BACKGROUND_COLOR)) != null) {
ColorType color = p.getColorType();
if (color != null) {
if (color.getAlpha() != 0
}
// Cell borders :
- if ((p = props.getExplicit("border-color")) != null) {
- ListProperty listprop = (ListProperty)p;
+ if ((p = props.getExplicit(Constants.PR_BORDER_COLOR)) != null) {
+ ListProperty listprop = (ListProperty) p;
ColorType color = null;
if (listprop.getList().get(0) instanceof NCnameProperty) {
color = new ColorType(((NCnameProperty)listprop.getList().get(0)).getNCname());
colorTable.getColorNumber((int)color.getRed(), (int)color.getGreen(),
(int)color.getBlue()).intValue());
}
- if ((p = props.getExplicit("border-top-color")) != null) {
+ if ((p = props.getExplicit(Constants.PR_BORDER_TOP_COLOR)) != null) {
ColorType color = p.getColorType();
attrib.set(
BorderAttributesConverter.BORDER_COLOR,
colorTable.getColorNumber((int)color.getRed(), (int)color.getGreen(),
(int)color.getBlue()).intValue());
}
- if ((p = props.getExplicit("border-bottom-color")) != null) {
+ if ((p = props.getExplicit(Constants.PR_BORDER_BOTTOM_COLOR)) != null) {
ColorType color = p.getColorType();
attrib.set(
BorderAttributesConverter.BORDER_COLOR,
colorTable.getColorNumber((int)color.getRed(), (int)color.getGreen(),
(int)color.getBlue()).intValue());
}
- if ((p = props.getExplicit("border-left-color")) != null) {
+ if ((p = props.getExplicit(Constants.PR_BORDER_LEFT_COLOR)) != null) {
ColorType color = p.getColorType();
attrib.set(
BorderAttributesConverter.BORDER_COLOR,
colorTable.getColorNumber((int)color.getRed(), (int)color.getGreen(),
(int)color.getBlue()).intValue());
}
- if ((p = props.getExplicit("border-right-color")) != null) {
+ if ((p = props.getExplicit(Constants.PR_BORDER_RIGHT_COLOR)) != null) {
ColorType color = p.getColorType();
attrib.set(
BorderAttributesConverter.BORDER_COLOR,