Fix handling of colors in hex format

This commit is contained in:
Nathan Gray 2011-08-09 19:39:24 +00:00
parent e15b7304bc
commit 1c2486e058
2 changed files with 22 additions and 9 deletions

View File

@ -150,12 +150,11 @@ Breakers
<xsl:choose> <xsl:choose>
<xsl:when test="contains(., 'rgb(')"> <xsl:when test="contains(., 'rgb(')">
<xsl:call-template name="rbga-to-hex"> <xsl:call-template name="rbga-to-hex">
<xsl:with-param name="rgba-val" select="."/> <xsl:with-param name="rgba-val" select="substring-after(.,':')"/>
</xsl:call-template> </xsl:call-template>
</xsl:when> </xsl:when>
<xsl:otherwise> <xsl:otherwise>
<!-- This is not quite right --> <xsl:value-of select="substring-after(.,'#')" />
<xsl:variable name="hex" select="." />
</xsl:otherwise> </xsl:otherwise>
</xsl:choose> </xsl:choose>
</xsl:variable> </xsl:variable>
@ -163,9 +162,16 @@ Breakers
</xsl:if> </xsl:if>
<xsl:if test="starts-with(.,'background-color:')"> <xsl:if test="starts-with(.,'background-color:')">
<xsl:variable name="hex"> <xsl:variable name="hex">
<xsl:call-template name="rbga-to-hex"> <xsl:choose>
<xsl:with-param name="rgba-val" select="."/> <xsl:when test="contains(., 'rgb(')">
</xsl:call-template> <xsl:call-template name="rbga-to-hex">
<xsl:with-param name="rgba-val" select="substring-after(.,':')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="substring-after(.,'#')" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable> </xsl:variable>
<w:shd w:fill="{$hex}"/> <w:shd w:fill="{$hex}"/>
</xsl:if> </xsl:if>

View File

@ -167,9 +167,16 @@
<xsl:choose> <xsl:choose>
<xsl:when test="starts-with(.,'color:')"> <xsl:when test="starts-with(.,'color:')">
<xsl:variable name="hex"> <xsl:variable name="hex">
<xsl:call-template name="rbga-to-hex"> <xsl:choose>
<xsl:with-param name="rgba-val" select="substring-after(.,':')"/> <xsl:when test="contains(., 'rgb(')">
</xsl:call-template> <xsl:call-template name="rbga-to-hex">
<xsl:with-param name="rgba-val" select="substring-after(.,':')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="substring-after(.,'#')"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable> </xsl:variable>
<style:text-properties fo:color="#{$hex}"/> <style:text-properties fo:color="#{$hex}"/>
</xsl:when> </xsl:when>