diff options
author | Karen Lease <klease@apache.org> | 2001-03-04 21:23:35 +0000 |
---|---|---|
committer | Karen Lease <klease@apache.org> | 2001-03-04 21:23:35 +0000 |
commit | d169e9ec5d2643ac6ba5d304269353750f987eef (patch) | |
tree | f7acb4d40f76a023b10f56ae6948f8da7bbf26eb /src | |
parent | f163e8fc28d6db4ef3194496c0d2014de86322a9 (diff) | |
download | xmlgraphics-fop-d169e9ec5d2643ac6ba5d304269353750f987eef.tar.gz xmlgraphics-fop-d169e9ec5d2643ac6ba5d304269353750f987eef.zip |
Add support for border and padding shorthand properties, color keywords in foproperties file, new Constants iface
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194121 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r-- | src/codegen/colorkw.xml | 149 | ||||
-rw-r--r-- | src/codegen/enumgen.xsl | 4 | ||||
-rw-r--r-- | src/codegen/foproperties.xml | 107 | ||||
-rw-r--r-- | src/codegen/properties.xsl | 74 | ||||
-rw-r--r-- | src/codegen/propinc.xsl | 1 |
5 files changed, 289 insertions, 46 deletions
diff --git a/src/codegen/colorkw.xml b/src/codegen/colorkw.xml new file mode 100644 index 000000000..2fc7be623 --- /dev/null +++ b/src/codegen/colorkw.xml @@ -0,0 +1,149 @@ +<toto> +<keyword-equiv match="aliceblue">#f0f8ff</keyword-equiv> +<keyword-equiv match="antiquewhite">#faebd7</keyword-equiv> +<keyword-equiv match="aqua">#00ffff</keyword-equiv> +<keyword-equiv match="aquamarine">#7fffd4</keyword-equiv> +<keyword-equiv match="azure">#f0ffff</keyword-equiv> +<keyword-equiv match="beige">#f5f5dc</keyword-equiv> +<keyword-equiv match="bisque">#ffe4c4</keyword-equiv> +<keyword-equiv match="black">#000000</keyword-equiv> +<keyword-equiv match="blanchedalmond">#ffebcd</keyword-equiv> +<keyword-equiv match="blue">#0000ff</keyword-equiv> +<keyword-equiv match="blueviolet">#8a2be2</keyword-equiv> +<keyword-equiv match="brown">#a52a2a</keyword-equiv> +<keyword-equiv match="burlywood">#deb887</keyword-equiv> +<keyword-equiv match="cadetblue">#5f9ea0</keyword-equiv> +<keyword-equiv match="chartreuse">#7fff00</keyword-equiv> +<keyword-equiv match="chocolate">#d2691e</keyword-equiv> +<keyword-equiv match="coral">#ff7f50</keyword-equiv> +<keyword-equiv match="cornflowerblue">#6495ed</keyword-equiv> +<keyword-equiv match="cornsilk">#fff8dc</keyword-equiv> +<keyword-equiv match="crimson">#dc143c</keyword-equiv> +<keyword-equiv match="cyan">#00ffff</keyword-equiv> +<keyword-equiv match="darkblue">#00008b</keyword-equiv> +<keyword-equiv match="darkcyan">#008b8b</keyword-equiv> +<keyword-equiv match="darkgoldenrod">#b8860b</keyword-equiv> +<keyword-equiv match="darkgray">#a9a9a9</keyword-equiv> +<keyword-equiv match="darkgreen">#006400</keyword-equiv> +<keyword-equiv match="darkgrey">#a9a9a9</keyword-equiv> +<keyword-equiv match="darkkhaki">#bdb76b</keyword-equiv> +<keyword-equiv match="darkmagenta">#8b008b</keyword-equiv> +<keyword-equiv match="darkolivegreen">#556b2f</keyword-equiv> +<keyword-equiv match="darkorange">#ff8c00</keyword-equiv> +<keyword-equiv match="darkorchid">#9932cc</keyword-equiv> +<keyword-equiv match="darkred">#8b0000</keyword-equiv> +<keyword-equiv match="darksalmon">#e9967a</keyword-equiv> +<keyword-equiv match="darkseagreen">#8fbc8f</keyword-equiv> +<keyword-equiv match="darkslateblue">#483d8b</keyword-equiv> +<keyword-equiv match="darkslategray">#2f4f4f</keyword-equiv> +<keyword-equiv match="darkslategrey">#2f4f4f</keyword-equiv> +<keyword-equiv match="darkturquoise">#00ced1</keyword-equiv> +<keyword-equiv match="darkviolet">#9400d3</keyword-equiv> +<keyword-equiv match="deeppink">#ff1493</keyword-equiv> +<keyword-equiv match="deepskyblue">#00bfff</keyword-equiv> +<keyword-equiv match="dimgray">#696969</keyword-equiv> +<keyword-equiv match="dimgrey">#696969</keyword-equiv> +<keyword-equiv match="dodgerblue">#1e90ff</keyword-equiv> +<keyword-equiv match="firebrick">#b22222</keyword-equiv> +<keyword-equiv match="floralwhite">#fffaf0</keyword-equiv> +<keyword-equiv match="forestgreen">#228b22</keyword-equiv> +<keyword-equiv match="fuchsia">#ff00ff</keyword-equiv> +<keyword-equiv match="gainsboro">#dcdcdc</keyword-equiv> +<keyword-equiv match="lightpink">#ffb6c1</keyword-equiv> +<keyword-equiv match="lightsalmon">#ffa07a</keyword-equiv> +<keyword-equiv match="lightseagreen">#20b2aa</keyword-equiv> +<keyword-equiv match="lightskyblue">#87cefa</keyword-equiv> +<keyword-equiv match="lightslategray">#778899</keyword-equiv> +<keyword-equiv match="lightslategrey">#778899</keyword-equiv> +<keyword-equiv match="lightsteelblue">#b0c4de</keyword-equiv> +<keyword-equiv match="lightyellow">#ffffe0</keyword-equiv> +<keyword-equiv match="lime">#00ff00</keyword-equiv> +<keyword-equiv match="limegreen">#32cd32</keyword-equiv> +<keyword-equiv match="linen">#faf0e6</keyword-equiv> +<keyword-equiv match="magenta">#ff00ff</keyword-equiv> +<keyword-equiv match="maroon">#800000</keyword-equiv> +<keyword-equiv match="mediumaquamarine">#66cdaa</keyword-equiv> +<keyword-equiv match="mediumblue">#0000cd</keyword-equiv> +<keyword-equiv match="mediumorchid">#ba55d3</keyword-equiv> +<keyword-equiv match="mediumpurple">#9370db</keyword-equiv> +<keyword-equiv match="mediumseagreen">#3cb371</keyword-equiv> +<keyword-equiv match="mediumslateblue">#7b68ee</keyword-equiv> +<keyword-equiv match="mediumspringgreen">#00fa9a</keyword-equiv> +<keyword-equiv match="mediumturquoise">#48d1cc</keyword-equiv> +<keyword-equiv match="mediumvioletred">#c71585</keyword-equiv> +<keyword-equiv match="midnightblue">#191970</keyword-equiv> +<keyword-equiv match="mintcream">#f5fffa</keyword-equiv> +<keyword-equiv match="mistyrose">#ffe4e1</keyword-equiv> +<keyword-equiv match="moccasin">#ffe4b5</keyword-equiv> +<keyword-equiv match="navajowhite">#ffdead</keyword-equiv> +<keyword-equiv match="navy">#000080</keyword-equiv> +<keyword-equiv match="oldlace">#fdf5e6</keyword-equiv> +<keyword-equiv match="olive">#808000</keyword-equiv> +<keyword-equiv match="olivedrab">#6b8e23</keyword-equiv> +<keyword-equiv match="orange">#ffa500</keyword-equiv> +<keyword-equiv match="orangered">#ff4500</keyword-equiv> +<keyword-equiv match="orchid">#da70d6</keyword-equiv> +<keyword-equiv match="palegoldenrod">#eee8aa</keyword-equiv> +<keyword-equiv match="palegreen">#98fb98</keyword-equiv> +<keyword-equiv match="paleturquoise">#afeeee</keyword-equiv> +<keyword-equiv match="palevioletred">#db7093</keyword-equiv> +<keyword-equiv match="papayawhip">#ffefd5</keyword-equiv> +<keyword-equiv match="peachpuff">#ffdab9</keyword-equiv> +<keyword-equiv match="peru">#cd853f</keyword-equiv> +<keyword-equiv match="pink">#ffc0cb</keyword-equiv> +<keyword-equiv match="plum">#dda0dd</keyword-equiv> +<keyword-equiv match="powderblue">#b0e0e6</keyword-equiv> +<keyword-equiv match="purple">#800080</keyword-equiv> +<keyword-equiv match="red">#ff0000</keyword-equiv> +<keyword-equiv match="rosybrown">#bc8f8f</keyword-equiv> +<keyword-equiv match="royalblue">#4169e1</keyword-equiv> +<keyword-equiv match="saddlebrown">#8b4513</keyword-equiv> +<keyword-equiv match="salmon">#fa8072</keyword-equiv> +<keyword-equiv match="ghostwhite">#f8f8ff</keyword-equiv> +<keyword-equiv match="gold">#ffd700</keyword-equiv> +<keyword-equiv match="goldenrod">#daa520</keyword-equiv> +<keyword-equiv match="gray">#808080</keyword-equiv> +<keyword-equiv match="grey">#808080</keyword-equiv> +<keyword-equiv match="green">#008000</keyword-equiv> +<keyword-equiv match="greenyellow">#adff2f</keyword-equiv> +<keyword-equiv match="honeydew">#f0fff0</keyword-equiv> +<keyword-equiv match="hotpink">#ff69b4</keyword-equiv> +<keyword-equiv match="indianred">#cd5c5c</keyword-equiv> +<keyword-equiv match="indigo">#4b0082</keyword-equiv> +<keyword-equiv match="ivory">#fffff0</keyword-equiv> +<keyword-equiv match="khaki">#f0e68c</keyword-equiv> +<keyword-equiv match="lavender">#e6e6fa</keyword-equiv> +<keyword-equiv match="lavenderblush">#fff0f5</keyword-equiv> +<keyword-equiv match="lawngreen">#7cfc00</keyword-equiv> +<keyword-equiv match="lemonchiffon">#fffacd</keyword-equiv> +<keyword-equiv match="lightblue">#add8e6</keyword-equiv> +<keyword-equiv match="lightcoral">#f08080</keyword-equiv> +<keyword-equiv match="lightcyan">#e0ffff</keyword-equiv> +<keyword-equiv match="lightgoldenrodyellow">#fafad2</keyword-equiv> +<keyword-equiv match="lightgray">#d3d3d3</keyword-equiv> +<keyword-equiv match="lightgreen">#90ee90</keyword-equiv> +<keyword-equiv match="lightgrey">#d3d3d3</keyword-equiv> +<keyword-equiv match="sandybrown">#f4a460</keyword-equiv> +<keyword-equiv match="seagreen">#2e8b57</keyword-equiv> +<keyword-equiv match="seashell">#fff5ee</keyword-equiv> +<keyword-equiv match="sienna">#a0522d</keyword-equiv> +<keyword-equiv match="silver">#c0c0c0</keyword-equiv> +<keyword-equiv match="skyblue">#87ceeb</keyword-equiv> +<keyword-equiv match="slateblue">#6a5acd</keyword-equiv> +<keyword-equiv match="slategray">#708090</keyword-equiv> +<keyword-equiv match="slategrey">#708090</keyword-equiv> +<keyword-equiv match="snow">#fffafa</keyword-equiv> +<keyword-equiv match="springgreen">#00ff7f</keyword-equiv> +<keyword-equiv match="steelblue">#4682b4</keyword-equiv> +<keyword-equiv match="tan">#d2b48c</keyword-equiv> +<keyword-equiv match="teal">#008080</keyword-equiv> +<keyword-equiv match="thistle">#d8bfd8</keyword-equiv> +<keyword-equiv match="tomato">#ff6347</keyword-equiv> +<keyword-equiv match="turquoise">#40e0d0</keyword-equiv> +<keyword-equiv match="violet">#ee82ee</keyword-equiv> +<keyword-equiv match="wheat">#f5deb3</keyword-equiv> +<keyword-equiv match="white">#ffffff</keyword-equiv> +<keyword-equiv match="whitesmoke">#f5f5f5</keyword-equiv> +<keyword-equiv match="yellow">#ffff00</keyword-equiv> +<keyword-equiv match="yellowgreen">#9acd32</keyword-equiv> +</toto> diff --git a/src/codegen/enumgen.xsl b/src/codegen/enumgen.xsl index e86a5fc27..80c8db4fd 100644 --- a/src/codegen/enumgen.xsl +++ b/src/codegen/enumgen.xsl @@ -41,7 +41,7 @@ package org.apache.fop.fo.properties; extends <xsl:value-of select="use-generic"/>.Enums </xsl:if>{ <xsl:for-each select="enumeration/value"> - public final static int <xsl:value-of select="@const"/> = <xsl:number/>; + public final static int <xsl:value-of select="@const"/> = Constants.<xsl:value-of select="@const"/>; </xsl:for-each> <xsl:if test="contains($bSubpropEnum, 'true')"> <xsl:call-template name="genSubpropEnum"/> @@ -58,7 +58,7 @@ package org.apache.fop.fo.properties; <xsl:for-each select="compound/subproperty[enumeration]"> public interface <xsl:value-of select="name"/> { <xsl:for-each select="enumeration/value"> - public final static int <xsl:value-of select="@const"/> = <xsl:number/>; + public final static int <xsl:value-of select="@const"/> = Constants.<xsl:value-of select="@const"/>; </xsl:for-each> } </xsl:for-each> diff --git a/src/codegen/foproperties.xml b/src/codegen/foproperties.xml index ad03a9477..ae190d94c 100644 --- a/src/codegen/foproperties.xml +++ b/src/codegen/foproperties.xml @@ -1,12 +1,15 @@ -<?xml version="1.0" ?> +<?xml version="1.0" standalone="yes" ?> <property-list family="FO"> <generic-property-list> <property type="generic"> <name>generic-color</name> <class-name>GenericColor</class-name> <datatype>ColorType</datatype> + <extfile href="colorkw.xml"/> +<!-- <datatype-conversion from-type="String" varname="strval"> new ColorType(strval)</datatype-conversion> +--> </property> <property type="generic"> <name>generic-boolean</name> @@ -83,6 +86,7 @@ <datatype>Length</datatype> <inherited>false</inherited> <default>0pt</default> + <shorthand>padding</shorthand> </property> <!-- Before, After, Start, End border width props --> @@ -93,18 +97,18 @@ <property type="generic"> <name>border-cond-width-template</name> <class-name>GenericCondBorderWidth</class-name> - <keyword-equiv match="thin" eval="true">0.5pt</keyword-equiv> - <keyword-equiv match="medium" eval="true">1pt</keyword-equiv> - <keyword-equiv match="thick" eval="true">2pt</keyword-equiv> + <keyword-equiv match="thin">0.5pt</keyword-equiv> + <keyword-equiv match="medium">1pt</keyword-equiv> + <keyword-equiv match="thick">2pt</keyword-equiv> <inherited>false</inherited> <datatype>CondLength</datatype> <compound> <subproperty set-by-shorthand="true"> <name>length</name> <datatype>Length</datatype> - <keyword-equiv match="thin" eval="true">0.5pt</keyword-equiv> - <keyword-equiv match="medium" eval="true">1pt</keyword-equiv> - <keyword-equiv match="thick" eval="true">2pt</keyword-equiv> + <keyword-equiv match="thin">0.5pt</keyword-equiv> + <keyword-equiv match="medium">1pt</keyword-equiv> + <keyword-equiv match="thick">2pt</keyword-equiv> <default>medium</default> </subproperty> <subproperty> @@ -122,11 +126,12 @@ <name>border-width-template</name> <class-name>GenericBorderWidth</class-name> <datatype>Length</datatype> - <keyword-equiv match="thin" eval="true">0.5pt</keyword-equiv> - <keyword-equiv match="medium" eval="true">1pt</keyword-equiv> - <keyword-equiv match="thick" eval="true">2pt</keyword-equiv> + <keyword-equiv match="thin">0.5pt</keyword-equiv> + <keyword-equiv match="medium">1pt</keyword-equiv> + <keyword-equiv match="thick">2pt</keyword-equiv> <inherited>false</inherited> <default>0pt</default> + <shorthand>border-width</shorthand> </property> <property type="generic"> <name>border-style-template</name> @@ -146,6 +151,7 @@ <value const="OUTSET">outset</value> </enumeration> <default>none</default> + <shorthand>border-style</shorthand> </property> <property type="generic"> <name>break-template</name> @@ -450,7 +456,7 @@ <inherited type="specified">true</inherited> <datatype>Length</datatype> <default contextdep="true">normal</default> - <keyword-equiv match="normal" eval="true">1.2em</keyword-equiv> + <keyword-equiv match="normal">1.2em</keyword-equiv> <datatype-conversion from-type="Number" varname="numval"> new PercentLength(numval.doubleValue(), getPercentBase(fo,propertyList))</datatype-conversion> @@ -498,13 +504,16 @@ <inherited>false</inherited> <use-generic>GenericColor</use-generic> <default>transparent</default> + <!-- Handle transparent --> + <datatype-conversion from-type="NCname" vartype="String" varname="nameval"> + new ColorType(nameval)</datatype-conversion> </property> <!-- shorthand class for all padding.... --> <property> <name>padding</name> <inherited>false</inherited> - <datatype>Length</datatype> - <default>0pt</default> + <datatype>List</datatype> + <datatype-parser>BoxPropShorthandParser</datatype-parser> </property> <property> <name>padding-before</name> @@ -682,6 +691,9 @@ <corresponding> <propval>border-<wmabs2rel dir="TOP"/>-color</propval> </corresponding> + <shorthand>border-top</shorthand> + <shorthand>border-color</shorthand> + <shorthand>border</shorthand> </property> <property> <name>border-top-style</name> @@ -689,6 +701,9 @@ <corresponding> <propval>border-<wmabs2rel dir="TOP"/>-style</propval> </corresponding> + <shorthand>border-top</shorthand> + <shorthand>border-style</shorthand> + <shorthand>border</shorthand> </property> <property> <name>border-top-width</name> @@ -696,6 +711,9 @@ <corresponding> <propval>border-<wmabs2rel dir="TOP"/>-width</propval> </corresponding> + <shorthand>border-top</shorthand> + <shorthand>border-width</shorthand> + <shorthand>border</shorthand> </property> <property> <name>border-bottom-color</name> @@ -705,6 +723,9 @@ <propval>border-<wmabs2rel dir="BOTTOM"/>-color</propval> </corresponding> <default>black</default> + <shorthand>border-bottom</shorthand> + <shorthand>border-color</shorthand> + <shorthand>border</shorthand> </property> <property> <name>border-bottom-style</name> @@ -712,6 +733,9 @@ <corresponding> <propval>border-<wmabs2rel dir="BOTTOM"/>-style</propval> </corresponding> + <shorthand>border-bottom</shorthand> + <shorthand>border-style</shorthand> + <shorthand>border</shorthand> </property> <property> <name>border-bottom-width</name> @@ -719,6 +743,9 @@ <corresponding> <propval>border-<wmabs2rel dir="BOTTOM"/>-width</propval> </corresponding> + <shorthand>border-bottom</shorthand> + <shorthand>border-width</shorthand> + <shorthand>border</shorthand> </property> <property> <name>border-left-color</name> @@ -728,6 +755,9 @@ <corresponding> <propval>border-<wmabs2rel dir="LEFT"/>-color</propval> </corresponding> + <shorthand>border-left</shorthand> + <shorthand>border-color</shorthand> + <shorthand>border</shorthand> </property> <property> <name>border-left-style</name> @@ -735,6 +765,9 @@ <corresponding> <propval>border-<wmabs2rel dir="LEFT"/>-style</propval> </corresponding> + <shorthand>border-left</shorthand> + <shorthand>border-style</shorthand> + <shorthand>border</shorthand> </property> <property> <name>border-left-width</name> @@ -742,6 +775,9 @@ <corresponding> <propval>border-<wmabs2rel dir="LEFT"/>-width</propval> </corresponding> + <shorthand>border-left</shorthand> + <shorthand>border-width</shorthand> + <shorthand>border</shorthand> </property> <property> <name>border-right-color</name> @@ -751,6 +787,9 @@ <corresponding> <propval>border-<wmabs2rel dir="RIGHT"/>-color</propval> </corresponding> + <shorthand>border-right</shorthand> + <shorthand>border-color</shorthand> + <shorthand>border</shorthand> </property> <property> <name>border-right-style</name> @@ -758,6 +797,9 @@ <corresponding> <propval>border-<wmabs2rel dir="RIGHT"/>-style</propval> </corresponding> + <shorthand>border-right</shorthand> + <shorthand>border-style</shorthand> + <shorthand>border</shorthand> </property> <property> <name>border-right-width</name> @@ -765,46 +807,57 @@ <corresponding> <propval>border-<wmabs2rel dir="RIGHT"/>-width</propval> </corresponding> + <shorthand>border-right</shorthand> + <shorthand>border-width</shorthand> + <shorthand>border</shorthand> </property> <property> <name>border-color</name> <inherited>false</inherited> - <use-generic>GenericColor</use-generic> - <default>black</default> + <datatype>List</datatype> + <datatype-parser>BoxPropShorthandParser</datatype-parser> </property> <property> <name>border-style</name> - <use-generic>GenericBorderStyle</use-generic> + <inherited>false</inherited> + <datatype>List</datatype> + <datatype-parser>BoxPropShorthandParser</datatype-parser> </property> <property> <name>border-width</name> <inherited>false</inherited> - <datatype>Length</datatype> - <default>0pt</default> + <datatype>List</datatype> + <datatype-parser>BoxPropShorthandParser</datatype-parser> </property> <property> <name>border-top</name> <inherited>false</inherited> - <datatype>String</datatype> - <default>normal</default> + <datatype>List</datatype> + <datatype-parser>GenericShorthandParser</datatype-parser> </property> <property> <name>border-bottom</name> <inherited>false</inherited> - <datatype>String</datatype> - <default>normal</default> + <datatype>List</datatype> + <datatype-parser>GenericShorthandParser</datatype-parser> </property> <property> <name>border-left</name> <inherited>false</inherited> - <datatype>String</datatype> - <default>normal</default> + <datatype>List</datatype> + <datatype-parser>GenericShorthandParser</datatype-parser> </property> <property> <name>border-right</name> <inherited>false</inherited> - <datatype>String</datatype> - <default>normal</default> + <datatype>List</datatype> + <datatype-parser>GenericShorthandParser</datatype-parser> + </property> + <property> + <name>border</name> + <inherited>false</inherited> + <datatype>List</datatype> + <datatype-parser>GenericShorthandParser</datatype-parser> </property> <property> <name>position</name> @@ -980,7 +1033,7 @@ <inherited>true</inherited> <datatype>Length</datatype> <default contextdep="true">use-font-metrics</default> - <keyword-equiv match="use-font-metrics" eval="true">0pt</keyword-equiv> + <keyword-equiv match="use-font-metrics">0pt</keyword-equiv> <percent-ok base="CONTAINING_BOX"/> </property> diff --git a/src/codegen/properties.xsl b/src/codegen/properties.xsl index aae85444d..95893abd6 100644 --- a/src/codegen/properties.xsl +++ b/src/codegen/properties.xsl @@ -8,6 +8,10 @@ <xsl:output method="text" /> +<xsl:template match="extfile"> +<xsl:message>Do <xsl:value-of select="@href"/></xsl:message> + <xsl:apply-templates select="document(@href)/*"/> +</xsl:template> <!-- Content of element is code to calculate the base length --> <xsl:template match="percent-ok"> @@ -49,13 +53,26 @@ <!-- Look for keyword equivalents. Value is the new expression --> <xsl:template match="keyword-equiv[1]"> - protected String checkValueKeywords(String value) { + // Initialize hashtable of keywords + static Hashtable s_htKeywords; + static { + s_htKeywords = new Hashtable(<xsl:value-of select="count(../keyword-equiv)"/>); <xsl:for-each select="../keyword-equiv"> + s_htKeywords.put("<xsl:value-of select="@match"/>", "<xsl:value-of select="."/>"); + </xsl:for-each> + } + protected String checkValueKeywords(String keyword) { +<!-- <xsl:for-each select="../keyword-equiv"> if (value.equals("<xsl:value-of select="@match"/>")) { return new String("<xsl:value-of select="."/>"); } </xsl:for-each> - return super.checkValueKeywords(value); +--> + String value = (String)s_htKeywords.get(keyword); + if (value == null) { + return super.checkValueKeywords(keyword); + } + else return value; } </xsl:template> @@ -91,7 +108,7 @@ </xsl:otherwise> </xsl:choose> </xsl:variable> - <xsl:value-of select="$dtc"/><xsl:text> </xsl:text> <xsl:value-of select="@varname"/> = + <xsl:value-of select="$dtc"/><xsl:text> </xsl:text> <xsl:value-of select="@varname"/> = p.get<xsl:value-of select="@from-type"/>(); if (<xsl:value-of select="@varname"/> != null) { return new <xsl:value-of select="$propclass"/>( @@ -194,6 +211,7 @@ <redirect:write select="concat('@org/apache/fop@/fo/properties/', $classname, '.java')"> package org.apache.fop.fo.properties; +import java.util.Hashtable; import org.apache.fop.datatypes.*; import org.apache.fop.fo.*; import org.apache.fop.apps.FOPException; @@ -206,7 +224,7 @@ public class <xsl:value-of select="$classname"/> extends <xsl:value-of select=" <xsl:if test=".//enumeration and @type='generic'"> public interface Enums { <xsl:for-each select="enumeration/value"> - int <xsl:value-of select="@const"/> = <xsl:number/>; + int <xsl:value-of select="@const"/> = Constants.<xsl:value-of select="@const"/>; </xsl:for-each> <xsl:for-each select="compound/subproperty[enumeration]"> <xsl:variable name="spname"> @@ -216,7 +234,7 @@ public class <xsl:value-of select="$classname"/> extends <xsl:value-of select=" </xsl:variable> public interface <xsl:value-of select="$spname"/> { <xsl:for-each select="enumeration/value"> - int <xsl:value-of select="@const"/> = <xsl:number/>; + int <xsl:value-of select="@const"/> = Constants.<xsl:value-of select="@const"/>; </xsl:for-each> } </xsl:for-each> @@ -231,7 +249,7 @@ public class <xsl:value-of select="$classname"/> extends <xsl:value-of select=" <!-- Look for compound properties --> -<xsl:if test="compound"> +<xsl:if test="compound"> <xsl:variable name="enumclass"> <xsl:choose> <xsl:when test="@type='generic'">Enums</xsl:when> @@ -257,7 +275,7 @@ public class <xsl:value-of select="$classname"/> extends <xsl:value-of select=" <xsl:choose> <xsl:when test='*[local-name(.)!="name" and local-name(.)!="datatype" and local-name(.)!="use-generic" and local-name(.)!="default"]'> - static private class SP_<xsl:value-of select="$spname"/>Maker + static private class SP_<xsl:value-of select="$spname"/>Maker extends <xsl:value-of select="$sp_superclass"/> <xsl:if test="enumeration"> implements <xsl:value-of select="$enumclass"/>.<xsl:value-of select="$spname"/></xsl:if> { SP_<xsl:value-of select="$spname"/>Maker(String sPropName) { @@ -330,8 +348,8 @@ public class <xsl:value-of select="$classname"/> extends <xsl:value-of select=" <xsl:value-of select="datatype"/> val = baseProp.get<xsl:value-of select="datatype"/>(); return val.getComponent(subpropName); } -<xsl:choose> -<!-- some subproperty default is context dependent; don't cache default! --> +<xsl:choose> +<!-- some subproperty default is context dependent; don't cache default! --> <xsl:when test='.//default[@contextdep="true"]'> public Property make(PropertyList propertyList) throws FOPException { return makeCompound(propertyList, propertyList.getParentFObj()); @@ -462,11 +480,11 @@ public class <xsl:value-of select="$classname"/> extends <xsl:value-of select=" sbExpr.setLength(0); <xsl:apply-templates select="."/> if (propertyList.getExplicit(sbExpr.toString()) != null) return true; - </xsl:for-each> + </xsl:for-each> return false; } </xsl:if> - + public Property compute(PropertyList propertyList) throws FOPException { FObj parentFO = propertyList.getParentFObj(); StringBuffer sbExpr=new StringBuffer(); @@ -474,20 +492,20 @@ public class <xsl:value-of select="$classname"/> extends <xsl:value-of select=" <xsl:choose><xsl:when test="corresponding/propexpr"> <xsl:apply-templates select="corresponding/propval"/> // Make sure the property is set before calculating it! - if (propertyList.getExplicit(sbExpr.toString()) == null) return p; + if (propertyList.getExplicitOrShorthand(sbExpr.toString()) == null) return p; sbExpr.setLength(0); <xsl:apply-templates select="corresponding/propexpr"/> p= make(propertyList, sbExpr.toString(), propertyList.getParentFObj()); </xsl:when><xsl:otherwise> <xsl:apply-templates select="corresponding/propval"/> - p= propertyList.getExplicit(sbExpr.toString()); + p= propertyList.getExplicitOrShorthand(sbExpr.toString()); </xsl:otherwise></xsl:choose> if (p != null) { p = convertProperty(p, propertyList, parentFO ); } <xsl:if test="compound"> else p= makeCompound(propertyList, parentFO); - + Property subprop; <xsl:for-each select="compound/subproperty/corresponding"> sbExpr.setLength(0); @@ -497,7 +515,7 @@ public class <xsl:value-of select="$classname"/> extends <xsl:value-of select=" make(propertyList, sbExpr.toString(), parentFO); </xsl:when><xsl:otherwise> <xsl:apply-templates select="propval"/> - subprop= propertyList.getExplicit(sbExpr.toString()); + subprop= propertyList.getExplicitOrShorthand(sbExpr.toString()); </xsl:otherwise></xsl:choose> setSubprop(p, "<xsl:value-of select='../name'/>", subprop); </xsl:for-each> @@ -506,7 +524,29 @@ public class <xsl:value-of select="$classname"/> extends <xsl:value-of select=" } </xsl:if> -<xsl:apply-templates select="percent-ok|auto-ok|default|keyword-equiv|datatype-conversion|enumeration"/> +<!-- If can be specified by any shorthand property --> +<xsl:if test="shorthand"> + public Property getShorthand(PropertyList propertyList) { + Property p = null; + ListProperty listprop; + <xsl:for-each select="shorthand"> + <xsl:variable name="shprop" select="."/> + if (p == null) { + listprop = (ListProperty)propertyList.getExplicit("<xsl:value-of select='$shprop'/>"); + if (listprop != null) { + // Get a parser for the shorthand to set the individual properties +<!-- ShorthandParser shparser = new <xsl:value-of select="//property[name=$shprop]/datatype-parser"/>(listprop); +--> + ShorthandParser shparser = new <xsl:value-of select="key('shorthandref', $shprop)/datatype-parser"/>(listprop); + p = shparser.getValueForProperty(getPropName(), this, propertyList); + } + } + </xsl:for-each> + return p; + } +</xsl:if> + +<xsl:apply-templates select="percent-ok|auto-ok|default|keyword-equiv|datatype-conversion|enumeration|extfile"/> } </redirect:write> </xsl:if> <!-- need to create a class --> @@ -536,7 +576,7 @@ public class <xsl:value-of select="$classname"/> extends <xsl:value-of select=" <xsl:template match="localname"/> <!-- Check that each member of the nodeset dtlist has the same value. - Print a message if any member of dtlist is different + Print a message if any member of dtlist is different from the first member. Return the first member. --> <xsl:template name="check-subprop-datatype"> diff --git a/src/codegen/propinc.xsl b/src/codegen/propinc.xsl index 87f62e60a..f83945b3d 100644 --- a/src/codegen/propinc.xsl +++ b/src/codegen/propinc.xsl @@ -2,6 +2,7 @@ xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > <xsl:key name="genericref" match="property[@type='generic']" use="class-name"/> +<xsl:key name="shorthandref" match="property" use="name"/> <xsl:template name="capfirst"> <xsl:param name="str"/> |