You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by gm...@apache.org on 2004/01/05 01:44:59 UTC
cvs commit: xml-fop/src/java/org/apache/fop/render/rtf TableAttributesConverter.java
gmazza 2004/01/04 16:44:59
Modified: src/codegen properties.xsl
src/java/org/apache/fop/fo Property.java PropertyList.java
src/java/org/apache/fop/fo/expr LabelEndFunction.java
NearestSpecPropFunction.java
src/java/org/apache/fop/render/rtf
TableAttributesConverter.java
Log:
More String-->int conversions. Work primarily from Finn Bock's patch.
Revision Changes Path
1.26 +146 -22 xml-fop/src/codegen/properties.xsl
Index: properties.xsl
===================================================================
RCS file: /home/cvs/xml-fop/src/codegen/properties.xsl,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- properties.xsl 4 Jan 2004 05:42:03 -0000 1.25
+++ properties.xsl 5 Jan 2004 00:44:59 -0000 1.26
@@ -563,9 +563,10 @@
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"/>
@@ -769,14 +770,12 @@
<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>
@@ -788,24 +787,26 @@
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>
@@ -818,8 +819,6 @@
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"/>
@@ -830,16 +829,19 @@
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>
@@ -860,9 +862,11 @@
<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 =
@@ -899,6 +903,83 @@
</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 != ''">
@@ -909,6 +990,34 @@
</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>
@@ -928,6 +1037,21 @@
sbExpr.append(propertyList.wmAbsToRel(PropertyList.</xsl:text>
<xsl:value-of select="@dir"/>
<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 -->
1.9 +1 -2 xml-fop/src/java/org/apache/fop/fo/Property.java
Index: Property.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/Property.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- Property.java 31 Dec 2003 01:41:46 -0000 1.8
+++ Property.java 5 Jan 2004 00:44:59 -0000 1.9
@@ -417,9 +417,8 @@
if (inheritsSpecified()) {
// recalculate based on last specified value
// Climb up propertylist and find last spec'd value
- String propName = FOPropertyMapping.getPropertyName(this.propId);
Property specProp =
- propertyList.getNearestSpecified(propName);
+ propertyList.getNearestSpecified(propId);
if (specProp != null) {
// Only need to do this if the value is relative!!!
String specVal = specProp.getSpecifiedValue();
1.19 +31 -18 xml-fop/src/java/org/apache/fop/fo/PropertyList.java
Index: PropertyList.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/PropertyList.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- PropertyList.java 4 Jan 2004 22:47:36 -0000 1.18
+++ PropertyList.java 5 Jan 2004 00:44:59 -0000 1.19
@@ -68,6 +68,7 @@
// writing-mode values
private byte[] wmtable = null;
+ private int writingMode;
// absolute directions and dimensions
/** constant for direction "left" */
@@ -181,9 +182,9 @@
* @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;
@@ -194,7 +195,7 @@
}
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);
@@ -208,8 +209,8 @@
* 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('.');
@@ -326,7 +327,7 @@
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)
@@ -346,13 +347,13 @@
* @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.
@@ -374,8 +375,7 @@
* 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 {
@@ -395,6 +395,21 @@
* @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)
+ * @return the corresponding writing model relative direction name
+ * for the flow object.
+ */
public String wmAbsToRel(int absdir) {
if (wmtable != null) {
return REL_NAMES[wmtable[absdir]];
@@ -424,6 +439,7 @@
* @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));
}
@@ -554,7 +570,7 @@
* @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) {
@@ -570,7 +586,7 @@
* @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) {
@@ -615,13 +631,10 @@
}
/**
- * @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) {
1.5 +1 -1 xml-fop/src/java/org/apache/fop/fo/expr/LabelEndFunction.java
Index: LabelEndFunction.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/expr/LabelEndFunction.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- LabelEndFunction.java 29 Dec 2003 23:28:47 -0000 1.4
+++ LabelEndFunction.java 5 Jan 2004 00:44:59 -0000 1.5
@@ -87,7 +87,7 @@
Length distance =
pInfo.getPropertyList().get(Constants.PR_PROVISIONAL_DISTANCE_BETWEEN_STARTS).getLength();
Length separation =
- pInfo.getPropertyList().getNearestSpecified("provisional-label-separation").getLength();
+ pInfo.getPropertyList().getNearestSpecified(Constants.PR_PROVISIONAL_LABEL_SEPARATION).getLength();
FONode item = pInfo.getFO();
while (item != null && !(item instanceof ListItem)) {
1.3 +3 -1 xml-fop/src/java/org/apache/fop/fo/expr/NearestSpecPropFunction.java
Index: NearestSpecPropFunction.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/expr/NearestSpecPropFunction.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- NearestSpecPropFunction.java 13 Jul 2003 03:16:11 -0000 1.2
+++ NearestSpecPropFunction.java 5 Jan 2004 00:44:59 -0000 1.3
@@ -51,6 +51,7 @@
package org.apache.fop.fo.expr;
import org.apache.fop.fo.Property;
+import org.apache.fop.fo.properties.FOPropertyMapping;
/**
* Class modelling the from-nearest-specified-value function. See Sec. 5.10.4
@@ -82,7 +83,8 @@
}
// NOTE: special cases for shorthand property
// Should return COMPUTED VALUE
- return pInfo.getPropertyList().getNearestSpecified(propName);
+ int propId = FOPropertyMapping.getPropertyId(propName);
+ return pInfo.getPropertyList().getNearestSpecified(propId);
}
}
1.7 +8 -8 xml-fop/src/java/org/apache/fop/render/rtf/TableAttributesConverter.java
Index: TableAttributesConverter.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/render/rtf/TableAttributesConverter.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- TableAttributesConverter.java 29 Dec 2003 23:28:47 -0000 1.6
+++ TableAttributesConverter.java 5 Jan 2004 00:44:59 -0000 1.7
@@ -156,7 +156,7 @@
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
@@ -174,8 +174,8 @@
}
// 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());
@@ -188,28 +188,28 @@
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,
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-cvs-help@xml.apache.org