diff options
author | Kohei Yoshida <kyoshida@novell.com> | 2009-09-17 15:48:04 -0400 |
---|---|---|
committer | Kohei Yoshida <kyoshida@novell.com> | 2009-09-17 15:48:04 -0400 |
commit | 8fa785c164bea369990fa389fecd6d32af1933f2 (patch) | |
tree | 80095d7e9f64bebc14fd46f3e9dba2eafa92548e /filter/source/xslt | |
parent | a5cafc72a0ece6ab259c5586dce476fe33ba4aad (diff) |
#i5560# Applied & adjusted for the latest codebase the patches from go-oo.
The original patches were contributed by Daniel Watson.
Diffstat (limited to 'filter/source/xslt')
3 files changed, 397 insertions, 4 deletions
diff --git a/filter/source/xslt/export/spreadsheetml/formular.xsl b/filter/source/xslt/export/spreadsheetml/formular.xsl index 859ef29c2e99..a6fe96a32753 100644 --- a/filter/source/xslt/export/spreadsheetml/formular.xsl +++ b/filter/source/xslt/export/spreadsheetml/formular.xsl @@ -381,7 +381,7 @@ </xsl:when> <xsl:otherwise> <xsl:value-of select="$earlierCandidate" /> - <xsl:variable name="parameterCandidate"> + <xsl:variable name="parameterCandidate2"> <xsl:variable name="formularAfterCandidate" select="substring-after($expressionSuffix, $earlierCandidate)" /> <xsl:variable name="parameterTillBracket" select="concat(substring-before($formularAfterCandidate,')'),')')" /> <xsl:variable name="parameterTillComma" select="substring-before(substring-after($expressionSuffix, $parameterTillBracket),',')" /> @@ -405,8 +405,8 @@ <xsl:call-template name="getParameter"> <xsl:with-param name="closingBracketCount" select="$closingBracketCount" /> <xsl:with-param name="openingBracketCount" select="$openingBracketCount" /> - <xsl:with-param name="parameterCandidate" select="$parameterCandidate" /> - <xsl:with-param name="earlierCandidate" select="$parameterCandidate" /> + <xsl:with-param name="parameterCandidate" select="$parameterCandidate2" /> + <xsl:with-param name="earlierCandidate" select="$parameterCandidate2" /> <xsl:with-param name="expressionSuffix" select="$expressionSuffix" /> </xsl:call-template> </xsl:otherwise> diff --git a/filter/source/xslt/export/spreadsheetml/ooo2spreadsheetml.xsl b/filter/source/xslt/export/spreadsheetml/ooo2spreadsheetml.xsl index e91fff273245..c63600c2bb8b 100644 --- a/filter/source/xslt/export/spreadsheetml/ooo2spreadsheetml.xsl +++ b/filter/source/xslt/export/spreadsheetml/ooo2spreadsheetml.xsl @@ -145,6 +145,17 @@ <RGB><xsl:value-of select="." /></RGB> </Color> </xsl:for-each> + <xsl:for-each select="key('config', 'TabColor')[not(.=preceding::config:config-item)]"> + <xsl:sort select="." /> + <Color> + <Index><xsl:value-of select="56 - position()" /></Index> + <RGB> + <xsl:call-template name="colordecimal2rgb"> + <xsl:with-param name="colordecimal" select="."/> + </xsl:call-template> + </RGB> + </Color> + </xsl:for-each> </Colors> </OfficeDocumentSettings> <ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel"> @@ -175,6 +186,160 @@ </Workbook> </xsl:template> + <xsl:template name="colordecimal2rgb"> + <xsl:param name="colordecimal"/> + <xsl:choose> + <xsl:when test="$colordecimal <= 16777215 and $colordecimal >= 65536"> + <xsl:variable name="redValue" select="floor(($colordecimal) div 65536)"/> + <xsl:variable name="greenValue" select="floor(($colordecimal - ($redValue*65536)) div 256)"/> + <xsl:variable name="blueValue" select="$colordecimal - ($redValue*65536) - ($greenValue*256)"/> + <xsl:call-template name="dec_rgb2Hex"> + <xsl:with-param name="decRedValue" select="$redValue"/> + <xsl:with-param name="decGreenValue" select="$greenValue"/> + <xsl:with-param name="decBlueValue" select="$blueValue"/> + </xsl:call-template> + </xsl:when> + <xsl:when test="$colordecimal <= 65535 and $colordecimal >= 256"> + <xsl:variable name="redValue" select="0"/> + <xsl:variable name="greenValue" select="$colordecimal div 256"/> + <xsl:variable name="blueValue" select="$colordecimal - ($greenValue*256)"/> + <xsl:call-template name="dec_rgb2Hex"> + <xsl:with-param name="decRedValue" select="$redValue"/> + <xsl:with-param name="decGreenValue" select="$greenValue"/> + <xsl:with-param name="decBlueValue" select="$blueValue"/> + </xsl:call-template> + </xsl:when> + <xsl:when test="$colordecimal <= 255 and $colordecimal >= 0"> + <xsl:variable name="redValue" select="0"/> + <xsl:variable name="greenValue" select="0"/> + <xsl:variable name="blueValue" select="$colordecimal"/> + <xsl:call-template name="dec_rgb2Hex"> + <xsl:with-param name="decRedValue" select="$redValue"/> + <xsl:with-param name="decGreenValue" select="$greenValue"/> + <xsl:with-param name="decBlueValue" select="$blueValue"/> + </xsl:call-template> + </xsl:when> + <xsl:otherwise/> + </xsl:choose> + </xsl:template> + <xsl:template name="dec_rgb2Hex"> + <xsl:param name="decRedValue"/> + <xsl:param name="decGreenValue"/> + <xsl:param name="decBlueValue"/> + <xsl:variable name="hexRedValue"> + <xsl:variable name="tmpHexRedValue"> + <xsl:call-template name="decimal2hex"> + <xsl:with-param name="dec-number" select="$decRedValue"/> + <xsl:with-param name="last-value" select="'H'"/> + </xsl:call-template> + </xsl:variable> + <xsl:choose> + <xsl:when test="string-length($tmpHexRedValue) = 1"> + <xsl:value-of select="concat('0',$tmpHexRedValue)"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$tmpHexRedValue"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + <xsl:variable name="hexGreenValue"> + <xsl:variable name="tmpHexGreenValue"> + <xsl:call-template name="decimal2hex"> + <xsl:with-param name="dec-number" select="$decGreenValue"/> + <xsl:with-param name="last-value" select="'H'"/> + </xsl:call-template> + </xsl:variable> + <xsl:choose> + <xsl:when test="string-length($tmpHexGreenValue) = 1"> + <xsl:value-of select="concat('0',$tmpHexGreenValue)"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$tmpHexGreenValue"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + <xsl:variable name="hexBlueValue"> + <xsl:variable name="tmpHexBlueValue"> + <xsl:call-template name="decimal2hex"> + <xsl:with-param name="dec-number" select="$decBlueValue"/> + <xsl:with-param name="last-value" select="'H'"/> + </xsl:call-template> + </xsl:variable> + <xsl:choose> + <xsl:when test="string-length($tmpHexBlueValue) = 1"> + <xsl:value-of select="concat('0',$tmpHexBlueValue)"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$tmpHexBlueValue"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + <xsl:value-of select="concat('#',$hexRedValue,$hexGreenValue,$hexBlueValue)"/> + </xsl:template> + <xsl:template name="decimal2hex"> + <!-- transforms a decimal number to a hex number,only for two-bit hex(less than 256 in decimal) currently --> + <xsl:param name="dec-number"/> + <xsl:param name="last-value"/> + <xsl:variable name="current-value"> + <xsl:call-template name="decNumber2hex"> + <xsl:with-param name="dec-value"> + <xsl:if test="$dec-number > 15"> + <xsl:value-of select="floor($dec-number div 16)"/> + </xsl:if> + <xsl:if test="$dec-number < 16"> + <xsl:value-of select="$dec-number"/> + </xsl:if> + </xsl:with-param> + </xsl:call-template> + </xsl:variable> + <xsl:if test="$dec-number > 15"> + <xsl:call-template name="decimal2hex"> + <xsl:with-param name="dec-number" select="$dec-number mod 16"/> + <xsl:with-param name="last-value" select="concat($last-value,$current-value)"/> + </xsl:call-template> + </xsl:if> + <xsl:if test="$dec-number < 16"> + <xsl:value-of select="substring-after(concat($last-value,$current-value),'H')"/> + </xsl:if> + </xsl:template> + + <xsl:template name="decNumber2hex"> + <!-- return a hex number for a decimal character --> + <xsl:param name="dec-value"/> + <xsl:choose> + <xsl:when test="$dec-value = 10"> + <xsl:value-of select="'A'"/> + </xsl:when> + <xsl:when test="$dec-value = 11"> + <xsl:value-of select="'B'"/> + </xsl:when> + <xsl:when test="$dec-value = 12"> + <xsl:value-of select="'C'"/> + </xsl:when> + <xsl:when test="$dec-value = 13"> + <xsl:value-of select="'D'"/> + </xsl:when> + <xsl:when test="$dec-value = 14"> + <xsl:value-of select="'E'"/> + </xsl:when> + <xsl:when test="$dec-value = 15"> + <xsl:value-of select="'F'"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$dec-value"/> + </xsl:otherwise> + </xsl:choose> + </xsl:template> + <xsl:template name="GetTabColorIndex"> + <xsl:param name="SheetColor"/> + <xsl:for-each select="key('config', 'TabColor')[not(.=preceding::config:config-item)]"> + <xsl:sort select="." /> + <xsl:variable name="tmpColor" select="."/> + <xsl:if test=". = $SheetColor" > + <xsl:value-of select="56 - position()"/> + </xsl:if> + </xsl:for-each> + </xsl:template> <xsl:template match="office:body"> <!-- office:body table:table children are spreadsheets --> <xsl:apply-templates /> @@ -187,8 +352,11 @@ <!-- office:body table:table children are spreadsheets --> <xsl:template match="office:spreadsheet/table:table"> <xsl:element name="ss:Worksheet"> - <xsl:attribute name="ss:Name"> + <xsl:variable name="TableName"> <xsl:value-of select="@table:name" /> + </xsl:variable> + <xsl:attribute name="ss:Name"> + <xsl:value-of select="$TableName" /> </xsl:attribute> <xsl:call-template name="table:table" /> <xsl:element name="x:WorksheetOptions"> @@ -204,6 +372,16 @@ <xsl:if test="key('config', 'ShowZeroValues') = 'false'"> <xsl:element name="x:DoNotDisplayZeros" /> </xsl:if> + <xsl:if test="/*/office:settings/config:config-item-set/config:config-item-map-indexed/config:config-item-map-entry/config:config-item-map-named/config:config-item-map-entry[@config:name=$TableName]/config:config-item[@config:name='TabColor']"> + <xsl:element name="x:TabColorIndex"> + <xsl:variable name="TabColorIndex"> + <xsl:call-template name="GetTabColorIndex"> + <xsl:with-param name="SheetColor" select="/*/office:settings/config:config-item-set/config:config-item-map-indexed/config:config-item-map-entry/config:config-item-map-named/config:config-item-map-entry[@config:name=$TableName]/config:config-item[@config:name='TabColor']"/> + </xsl:call-template> + </xsl:variable> + <xsl:value-of select="$TabColorIndex"/> + </xsl:element> + </xsl:if> </xsl:element> </xsl:element> </xsl:template> diff --git a/filter/source/xslt/import/spreadsheetml/spreadsheetml2ooo.xsl b/filter/source/xslt/import/spreadsheetml/spreadsheetml2ooo.xsl index a1576db37f10..6fcae4abebc9 100644 --- a/filter/source/xslt/import/spreadsheetml/spreadsheetml2ooo.xsl +++ b/filter/source/xslt/import/spreadsheetml/spreadsheetml2ooo.xsl @@ -385,6 +385,16 @@ </xsl:otherwise> </xsl:choose> <xsl:copy-of select="$sharedConfiguration"/> + <xsl:if test="x:WorksheetOptions/x:TabColorIndex"> + <config:config-item config:name="TabColor" config:type="int"> + <xsl:variable name="temp-value"> + <xsl:call-template name="colorindex2decimal"> + <xsl:with-param name="colorindex" select="x:WorksheetOptions/x:TabColorIndex"/> + </xsl:call-template> + </xsl:variable> + <xsl:value-of select="$temp-value"/> + </config:config-item> + </xsl:if> </config:config-item-map-entry> </xsl:for-each> </config:config-item-map-named> @@ -4641,6 +4651,211 @@ </xsl:variable> <xsl:value-of select="concat('#',$R-value,$G-value,$B-value)"/> </xsl:template> + <xsl:template name="colorindex2decimal"> + <xsl:param name="colorindex"/> + <xsl:variable name="colorIndexLookup"> + <xsl:value-of select="$colorindex - 8"/> + </xsl:variable> + <xsl:variable name="tempColorValue"> + <xsl:choose> + <!-- Grab the color from the custom color index if it exists... --> + <xsl:when test="/ss:Workbook/o:OfficeDocumentSettings/o:Colors/o:Color/o:Index=$colorIndexLookup"> + <xsl:value-of select="substring-after(normalize-space(/ss:Workbook/o:OfficeDocumentSettings/o:Colors/o:Color/o:RGB[/ss:Workbook/o:OfficeDocumentSettings/o:Colors/o:Color/o:Index=$colorIndexLookup]), '#')"/> + </xsl:when > + <xsl:otherwise> + <xsl:choose> + <xsl:when test="$colorindex=8"> + <xsl:value-of select="'000000'"/> + </xsl:when> + <xsl:when test="$colorindex=9"> + <xsl:value-of select="'FFFFFF'"/> + </xsl:when> + <xsl:when test="$colorindex=10"> + <xsl:value-of select="'FF0000'"/> + </xsl:when> + <xsl:when test="$colorindex=11"> + <xsl:value-of select="'00FF00'"/> + </xsl:when> + <xsl:when test="$colorindex=12"> + <xsl:value-of select="'0000FF'"/> + </xsl:when> + <xsl:when test="$colorindex=13"> + <xsl:value-of select="'FFFF00'"/> + </xsl:when> + <xsl:when test="$colorindex=14"> + <xsl:value-of select="'FF00FF'"/> + </xsl:when> + <xsl:when test="$colorindex=15"> + <xsl:value-of select="'00FFFF'"/> + </xsl:when> + <xsl:when test="$colorindex=16"> + <xsl:value-of select="'800000'"/> + </xsl:when> + <xsl:when test="$colorindex=17"> + <xsl:value-of select="'008000'"/> + </xsl:when> + <xsl:when test="$colorindex=18"> + <xsl:value-of select="'000080'"/> + </xsl:when> + <xsl:when test="$colorindex=19"> + <xsl:value-of select="'808000'"/> + </xsl:when> + <xsl:when test="$colorindex=20"> + <xsl:value-of select="'800080'"/> + </xsl:when> + <xsl:when test="$colorindex=21"> + <xsl:value-of select="'008080'"/> + </xsl:when> + <xsl:when test="$colorindex=22"> + <xsl:value-of select="'C0C0C0'"/> + </xsl:when> + <xsl:when test="$colorindex=23"> + <xsl:value-of select="'808080'"/> + </xsl:when> + <xsl:when test="$colorindex=24"> + <xsl:value-of select="'9999FF'"/> + </xsl:when> + <xsl:when test="$colorindex=25"> + <xsl:value-of select="'993366'"/> + </xsl:when> + <xsl:when test="$colorindex=26"> + <xsl:value-of select="'FFFFCC'"/> + </xsl:when> + <xsl:when test="$colorindex=27"> + <xsl:value-of select="'CCFFFF'"/> + </xsl:when> + <xsl:when test="$colorindex=28"> + <xsl:value-of select="'660066'"/> + </xsl:when> + <xsl:when test="$colorindex=29"> + <xsl:value-of select="'FF8080'"/> + </xsl:when> + <xsl:when test="$colorindex=30"> + <xsl:value-of select="'0066CC'"/> + </xsl:when> + <xsl:when test="$colorindex=31"> + <xsl:value-of select="'CCCCFF'"/> + </xsl:when> + <xsl:when test="$colorindex=32"> + <xsl:value-of select="'000080'"/> + </xsl:when> + <xsl:when test="$colorindex=33"> + <xsl:value-of select="'FF00FF'"/> + </xsl:when> + <xsl:when test="$colorindex=34"> + <xsl:value-of select="'FFFF00'"/> + </xsl:when> + <xsl:when test="$colorindex=35"> + <xsl:value-of select="'00FFFF'"/> + </xsl:when> + <xsl:when test="$colorindex=36"> + <xsl:value-of select="'800080'"/> + </xsl:when> + <xsl:when test="$colorindex=37"> + <xsl:value-of select="'800000'"/> + </xsl:when> + <xsl:when test="$colorindex=38"> + <xsl:value-of select="'008080'"/> + </xsl:when> + <xsl:when test="$colorindex=39"> + <xsl:value-of select="'0000FF'"/> + </xsl:when> + <xsl:when test="$colorindex=40"> + <xsl:value-of select="'00CCFF'"/> + </xsl:when> + <xsl:when test="$colorindex=41"> + <xsl:value-of select="'CCFFFF'"/> + </xsl:when> + <xsl:when test="$colorindex=42"> + <xsl:value-of select="'CCFFCC'"/> + </xsl:when> + <xsl:when test="$colorindex=43"> + <xsl:value-of select="'FFFF99'"/> + </xsl:when> + <xsl:when test="$colorindex=44"> + <xsl:value-of select="'99CCFF'"/> + </xsl:when> + <xsl:when test="$colorindex=45"> + <xsl:value-of select="'FF99CC'"/> + </xsl:when> + <xsl:when test="$colorindex=46"> + <xsl:value-of select="'CC99FF'"/> + </xsl:when> + <xsl:when test="$colorindex=47"> + <xsl:value-of select="'FFCC99'"/> + </xsl:when> + <xsl:when test="$colorindex=48"> + <xsl:value-of select="'3366FF'"/> + </xsl:when> + <xsl:when test="$colorindex=49"> + <xsl:value-of select="'33CCCC'"/> + </xsl:when> + <xsl:when test="$colorindex=50"> + <xsl:value-of select="'99CC00'"/> + </xsl:when> + <xsl:when test="$colorindex=51"> + <xsl:value-of select="'FFCC00'"/> + </xsl:when> + <xsl:when test="$colorindex=52"> + <xsl:value-of select="'FF9900'"/> + </xsl:when> + <xsl:when test="$colorindex=53"> + <xsl:value-of select="'FF6600'"/> + </xsl:when> + <xsl:when test="$colorindex=54"> + <xsl:value-of select="'666699'"/> + </xsl:when> + <xsl:when test="$colorindex=55"> + <xsl:value-of select="'969696'"/> + </xsl:when> + <xsl:when test="$colorindex=56"> + <xsl:value-of select="'003366'"/> + </xsl:when> + <xsl:when test="$colorindex=57"> + <xsl:value-of select="'339966'"/> + </xsl:when> + <xsl:when test="$colorindex=58"> + <xsl:value-of select="'003300'"/> + </xsl:when> + <xsl:when test="$colorindex=59"> + <xsl:value-of select="'333300'"/> + </xsl:when> + <xsl:when test="$colorindex=60"> + <xsl:value-of select="'993300'"/> + </xsl:when> + <xsl:when test="$colorindex=61"> + <xsl:value-of select="'993366'"/> + </xsl:when> + <xsl:when test="$colorindex=62"> + <xsl:value-of select="'333399'"/> + </xsl:when> + <xsl:when test="$colorindex=63"> + <xsl:value-of select="'333333'"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="'NOTFOUND'"/> + </xsl:otherwise> + </xsl:choose> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + <xsl:variable name="tempColorDecimal"> + <xsl:choose> + <xsl:when test="not($tempColorValue = 'NOTFOUND')"> + <xsl:call-template name="hex2decimal"> + <xsl:with-param name="hex-number" select="$tempColorValue"/> + <xsl:with-param name="index" select="1"/> + <xsl:with-param name="str-length" select="6"/> + <xsl:with-param name="last-value" select="0"/> + </xsl:call-template> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="4294967295"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + <xsl:value-of select="$tempColorDecimal"/> + </xsl:template> <xsl:template name="hex2decimal"> <!-- transforms a hex number to a decimal number.parses the string from left to right --> <xsl:param name="hex-number"/> |