1*cdf0e10cSrcweir<?xml version="1.0" encoding="UTF-8"?>
2*cdf0e10cSrcweir<!--
3*cdf0e10cSrcweir
4*cdf0e10cSrcweir  DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5*cdf0e10cSrcweir
6*cdf0e10cSrcweir  Copyright 2000, 2010 Oracle and/or its affiliates.
7*cdf0e10cSrcweir
8*cdf0e10cSrcweir  OpenOffice.org - a multi-platform office productivity suite
9*cdf0e10cSrcweir
10*cdf0e10cSrcweir  This file is part of OpenOffice.org.
11*cdf0e10cSrcweir
12*cdf0e10cSrcweir  OpenOffice.org is free software: you can redistribute it and/or modify
13*cdf0e10cSrcweir  it under the terms of the GNU Lesser General Public License version 3
14*cdf0e10cSrcweir  only, as published by the Free Software Foundation.
15*cdf0e10cSrcweir
16*cdf0e10cSrcweir  OpenOffice.org is distributed in the hope that it will be useful,
17*cdf0e10cSrcweir  but WITHOUT ANY WARRANTY; without even the implied warranty of
18*cdf0e10cSrcweir  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19*cdf0e10cSrcweir  GNU Lesser General Public License version 3 for more details
20*cdf0e10cSrcweir  (a copy is included in the LICENSE file that accompanied this code).
21*cdf0e10cSrcweir
22*cdf0e10cSrcweir  You should have received a copy of the GNU Lesser General Public License
23*cdf0e10cSrcweir  version 3 along with OpenOffice.org.  If not, see
24*cdf0e10cSrcweir  <http://www.openoffice.org/license.html>
25*cdf0e10cSrcweir  for a copy of the LGPLv3 License.
26*cdf0e10cSrcweir
27*cdf0e10cSrcweir-->
28*cdf0e10cSrcweir<xsl:stylesheet version="1.0"
29*cdf0e10cSrcweir	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
30*cdf0e10cSrcweir	xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
31*cdf0e10cSrcweir	xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0"
32*cdf0e10cSrcweir	xmlns:dc="http://purl.org/dc/elements/1.1/"
33*cdf0e10cSrcweir	xmlns:dom="http://www.w3.org/2001/xml-events"
34*cdf0e10cSrcweir	xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"
35*cdf0e10cSrcweir	xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
36*cdf0e10cSrcweir	xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
37*cdf0e10cSrcweir	xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"
38*cdf0e10cSrcweir	xmlns:math="http://www.w3.org/1998/Math/MathML"
39*cdf0e10cSrcweir	xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0"
40*cdf0e10cSrcweir	xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
41*cdf0e10cSrcweir	xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
42*cdf0e10cSrcweir	xmlns:ooo="http://openoffice.org/2004/office"
43*cdf0e10cSrcweir	xmlns:oooc="http://openoffice.org/2004/calc"
44*cdf0e10cSrcweir	xmlns:ooow="http://openoffice.org/2004/writer"
45*cdf0e10cSrcweir	xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"
46*cdf0e10cSrcweir	xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
47*cdf0e10cSrcweir	xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
48*cdf0e10cSrcweir	xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
49*cdf0e10cSrcweir	xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
50*cdf0e10cSrcweir	xmlns:xlink="http://www.w3.org/1999/xlink"
51*cdf0e10cSrcweir	xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:c="urn:schemas-microsoft-com:office:component:spreadsheet" xmlns:html="http://www.w3.org/TR/REC-html40" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:x2="http://schemas.microsoft.com/office/excel/2003/xml" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
52*cdf0e10cSrcweir	exclude-result-prefixes="chart config dc dom dr3d draw fo form math meta number office ooo oooc ooow script style svg table text xlink">
53*cdf0e10cSrcweir
54*cdf0e10cSrcweir
55*cdf0e10cSrcweir	<!--+++++ INCLUDED XSL MODULES +++++-->
56*cdf0e10cSrcweir
57*cdf0e10cSrcweir	<!-- helper collection, to convert measures (e.g. inch to pixel using DPI (dots per inch) parameter)-->
58*cdf0e10cSrcweir	<xsl:import  href="../../common/measure_conversion.xsl" />
59*cdf0e10cSrcweir
60*cdf0e10cSrcweir	<!-- excel table handling -->
61*cdf0e10cSrcweir	<xsl:include  href="table.xsl" />
62*cdf0e10cSrcweir
63*cdf0e10cSrcweir	<!-- mapping rules of office style properties to Excel style properties -->
64*cdf0e10cSrcweir	<xsl:include href="style_mapping.xsl" />
65*cdf0e10cSrcweir
66*cdf0e10cSrcweir	<!-- creating the Excel styles element  -->
67*cdf0e10cSrcweir	<xsl:include href="styles.xsl" />
68*cdf0e10cSrcweir
69*cdf0e10cSrcweir	<!-- mapping formalar Expressions  -->
70*cdf0e10cSrcweir	<xsl:include href="formular.xsl" />
71*cdf0e10cSrcweir
72*cdf0e10cSrcweir	<xsl:output method               = "xml"
73*cdf0e10cSrcweir				indent               = "no"
74*cdf0e10cSrcweir				encoding             = "UTF-8"
75*cdf0e10cSrcweir				omit-xml-declaration = "no" />
76*cdf0e10cSrcweir
77*cdf0e10cSrcweir	<xsl:strip-space elements="ss:Data html:Data" />
78*cdf0e10cSrcweir
79*cdf0e10cSrcweir
80*cdf0e10cSrcweir	<!-- common table handling -->
81*cdf0e10cSrcweir	<xsl:variable name="namespace" select="'urn:schemas-microsoft-com:office:spreadsheet'" />
82*cdf0e10cSrcweir
83*cdf0e10cSrcweir	<!--+++++ PARAMETER SECTION +++++-->
84*cdf0e10cSrcweir
85*cdf0e10cSrcweir	<!-- OPTIONAL: (MANDATORY: for all input document with relative external links): parameter is a (relative) URL to the target directory.
86*cdf0e10cSrcweir		 Relative links from the office document (e.g. to external graphics) will get this parameter as a prefix -->
87*cdf0e10cSrcweir	<xsl:param name="targetBaseURL" select="'./'" />
88*cdf0e10cSrcweir
89*cdf0e10cSrcweir	<!-- OPTIONAL: (MANDATORY: for input document with relative internal links)
90*cdf0e10cSrcweir		 To access contents of a office file (content like the meta.xml, styles.xml file or  graphics) a URL could be choosen.
91*cdf0e10cSrcweir	 This could be even a JAR URL. The sourceBase of the content URL "jar:file:/C:/temp/Test.sxw!/content.xml" would be
92*cdf0e10cSrcweir	 "jar:file:/C:/temp/Test.sxw!/" for example.
93*cdf0e10cSrcweir		 When working with OpenOffice API a Package-URL encoded over HTTP can be used to access the jared contents of the the jared document. -->
94*cdf0e10cSrcweir	<xsl:param name="sourceBaseURL" select="'./'" />
95*cdf0e10cSrcweir
96*cdf0e10cSrcweir	<!-- OPTIONAL: (MANDATORY: for session management by URL rewriting)
97*cdf0e10cSrcweir		 Useful for WebApplications: if a HTTP session is not cookie based, URL rewriting is beeing used (the session is appended to the URL).
98*cdf0e10cSrcweir		 This URL session is used for example when links to graphics are created by XSLT. Otherwise the user havt to log again in for every graphic he liks to see. -->
99*cdf0e10cSrcweir	<xsl:param name="optionalURLSuffix" />
100*cdf0e10cSrcweir
101*cdf0e10cSrcweir	<!-- OPTIONAL: URL to office meta file (flat xml use the URL to the input file) -->
102*cdf0e10cSrcweir	<xsl:param name="metaFileURL" />
103*cdf0e10cSrcweir
104*cdf0e10cSrcweir	<!-- OPTIONAL: URL to office meta file (flat xml use the URL to the input file) -->
105*cdf0e10cSrcweir	<xsl:param name="stylesFileURL" />
106*cdf0e10cSrcweir
107*cdf0e10cSrcweir	<!-- OPTIONAL: in case of using a different processor than a JAVA XSLT, you can unable the Java functionality
108*cdf0e10cSrcweir		 (e.g. encoding chapter names for the content-table as href and anchors ) -->
109*cdf0e10cSrcweir	<xsl:param name="java"        select="true()" />
110*cdf0e10cSrcweir	<xsl:param name="javaEnabled" select="boolean($java)" />
111*cdf0e10cSrcweir
112*cdf0e10cSrcweir	<!-- OPTIONAL: for activating the debug mode set the variable here to 'true()' or give any value from outside -->
113*cdf0e10cSrcweir	<xsl:param name="debug"                    select="false()" />
114*cdf0e10cSrcweir	<xsl:param name="debugEnabled"             select="boolean($debug)" />
115*cdf0e10cSrcweir
116*cdf0e10cSrcweir	<!-- matching configuration entries -->
117*cdf0e10cSrcweir	<xsl:key name="config" use="@config:name"
118*cdf0e10cSrcweir			 match="/*/office:settings/config:config-item-set/config:config-item-map-indexed/config:config-item-map-entry/config:config-item |
119*cdf0e10cSrcweir					/*/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:config-item" />
120*cdf0e10cSrcweir
121*cdf0e10cSrcweir	<xsl:key name="colors" match="/*/office:styles//@*[name() = 'fo:background-color' or name() = 'fo:color'] |
122*cdf0e10cSrcweir								  /*/office:automatic-styles//@*[name() = 'fo:background-color' or name() = 'fo:color']" use="/" />
123*cdf0e10cSrcweir	<xsl:key name="colorRGB" match="@fo:background-color | @fo:color" use="." />
124*cdf0e10cSrcweir	<!-- *************************** -->
125*cdf0e10cSrcweir	<!-- *** Built up Excel file *** -->
126*cdf0e10cSrcweir	<!-- *************************** -->
127*cdf0e10cSrcweir	<xsl:template match="/">
128*cdf0e10cSrcweir		<xsl:processing-instruction  name="mso-application">progid="Excel.Sheet"</xsl:processing-instruction>
129*cdf0e10cSrcweir		<!-- Note: for debugging purpose include schema location
130*cdf0e10cSrcweir		<Workbook xsi:schemaLocation="urn:schemas-microsoft-com:office:spreadsheet <YOUR_SCHEMA_URL>/excelss.xsd"> -->
131*cdf0e10cSrcweir		<Workbook>
132*cdf0e10cSrcweir			<!-- adding some default settings -->
133*cdf0e10cSrcweir			<OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office">
134*cdf0e10cSrcweir				<Colors>
135*cdf0e10cSrcweir					<xsl:for-each select="key('colors', /)
136*cdf0e10cSrcweir						[generate-id(.) =
137*cdf0e10cSrcweir						 generate-id(key('colorRGB', .)[1]) and starts-with(., '#')] ">
138*cdf0e10cSrcweir					<xsl:sort select="." />
139*cdf0e10cSrcweir					<Color>
140*cdf0e10cSrcweir						<Index><xsl:value-of select="position() + 2" /></Index>
141*cdf0e10cSrcweir						<RGB><xsl:value-of select="." /></RGB>
142*cdf0e10cSrcweir					</Color>
143*cdf0e10cSrcweir					</xsl:for-each>
144*cdf0e10cSrcweir                    <xsl:for-each select="key('config', 'TabColor')[not(.=preceding::config:config-item)]">
145*cdf0e10cSrcweir                    <xsl:sort select="." />
146*cdf0e10cSrcweir                    <Color>
147*cdf0e10cSrcweir                        <Index><xsl:value-of select="56 - position()" /></Index>
148*cdf0e10cSrcweir                        <RGB>
149*cdf0e10cSrcweir                            <xsl:call-template name="colordecimal2rgb">
150*cdf0e10cSrcweir                                <xsl:with-param name="colordecimal" select="."/>
151*cdf0e10cSrcweir                            </xsl:call-template>
152*cdf0e10cSrcweir                        </RGB>
153*cdf0e10cSrcweir                    </Color>
154*cdf0e10cSrcweir                    </xsl:for-each>
155*cdf0e10cSrcweir				</Colors>
156*cdf0e10cSrcweir			</OfficeDocumentSettings>
157*cdf0e10cSrcweir			<ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
158*cdf0e10cSrcweir				<xsl:if test="key('config', 'HasSheetTabs') = 'false'">
159*cdf0e10cSrcweir						<xsl:element name="HideWorkbookTabs" />
160*cdf0e10cSrcweir				</xsl:if>
161*cdf0e10cSrcweir				<WindowHeight>9000</WindowHeight>
162*cdf0e10cSrcweir				<WindowWidth>13860</WindowWidth>
163*cdf0e10cSrcweir				<WindowTopX>240</WindowTopX>
164*cdf0e10cSrcweir				<WindowTopY>75</WindowTopY>
165*cdf0e10cSrcweir				<ProtectStructure>False</ProtectStructure>
166*cdf0e10cSrcweir				<ProtectWindows>False</ProtectWindows>
167*cdf0e10cSrcweir			</ExcelWorkbook>
168*cdf0e10cSrcweir			<!-- Note: the following handling will exchange the default, later
169*cdf0e10cSrcweir				<x:ExcelWorkbook>
170*cdf0e10cSrcweir					<xsl:apply-templates select="table:calculation-settings" />
171*cdf0e10cSrcweir				</x:ExcelWorkbook>
172*cdf0e10cSrcweir			-->
173*cdf0e10cSrcweir			<xsl:element name="Styles">
174*cdf0e10cSrcweir				<!-- our application default will not be used for export to Excel
175*cdf0e10cSrcweir				<xsl:apply-templates select="/*/office:styles/style:default-style" mode="styles" />-->
176*cdf0e10cSrcweir				<xsl:apply-templates select="/*/office:styles/style:style" mode="styles" />
177*cdf0e10cSrcweir				<xsl:apply-templates select="/*/office:automatic-styles/style:style" mode="styles" >
178*cdf0e10cSrcweir					<xsl:with-param name="isAutomatic" select="true()" />
179*cdf0e10cSrcweir				</xsl:apply-templates>
180*cdf0e10cSrcweir			</xsl:element>
181*cdf0e10cSrcweir			<xsl:apply-templates select="/*/office:body" />
182*cdf0e10cSrcweir		</Workbook>
183*cdf0e10cSrcweir	</xsl:template>
184*cdf0e10cSrcweir
185*cdf0e10cSrcweir    <xsl:template name="colordecimal2rgb">
186*cdf0e10cSrcweir        <xsl:param name="colordecimal"/>
187*cdf0e10cSrcweir        <xsl:choose>
188*cdf0e10cSrcweir            <xsl:when test="$colordecimal &lt;= 16777215 and $colordecimal &gt;= 65536">
189*cdf0e10cSrcweir                <xsl:variable name="redValue" select="floor(($colordecimal) div 65536)"/>
190*cdf0e10cSrcweir                <xsl:variable name="greenValue" select="floor(($colordecimal - ($redValue*65536)) div 256)"/>
191*cdf0e10cSrcweir                <xsl:variable name="blueValue" select="$colordecimal - ($redValue*65536) - ($greenValue*256)"/>
192*cdf0e10cSrcweir                <xsl:call-template name="dec_rgb2Hex">
193*cdf0e10cSrcweir                    <xsl:with-param name="decRedValue" select="$redValue"/>
194*cdf0e10cSrcweir                    <xsl:with-param name="decGreenValue" select="$greenValue"/>
195*cdf0e10cSrcweir                    <xsl:with-param name="decBlueValue" select="$blueValue"/>
196*cdf0e10cSrcweir                </xsl:call-template>
197*cdf0e10cSrcweir            </xsl:when>
198*cdf0e10cSrcweir            <xsl:when test="$colordecimal &lt;= 65535 and $colordecimal &gt;= 256">
199*cdf0e10cSrcweir                <xsl:variable name="redValue" select="0"/>
200*cdf0e10cSrcweir                <xsl:variable name="greenValue" select="$colordecimal div 256"/>
201*cdf0e10cSrcweir                <xsl:variable name="blueValue" select="$colordecimal - ($greenValue*256)"/>
202*cdf0e10cSrcweir                <xsl:call-template name="dec_rgb2Hex">
203*cdf0e10cSrcweir                    <xsl:with-param name="decRedValue" select="$redValue"/>
204*cdf0e10cSrcweir                    <xsl:with-param name="decGreenValue" select="$greenValue"/>
205*cdf0e10cSrcweir                    <xsl:with-param name="decBlueValue" select="$blueValue"/>
206*cdf0e10cSrcweir                </xsl:call-template>
207*cdf0e10cSrcweir            </xsl:when>
208*cdf0e10cSrcweir            <xsl:when test="$colordecimal &lt;= 255 and $colordecimal &gt;= 0">
209*cdf0e10cSrcweir                <xsl:variable name="redValue" select="0"/>
210*cdf0e10cSrcweir                <xsl:variable name="greenValue" select="0"/>
211*cdf0e10cSrcweir                <xsl:variable name="blueValue" select="$colordecimal"/>
212*cdf0e10cSrcweir                <xsl:call-template name="dec_rgb2Hex">
213*cdf0e10cSrcweir                    <xsl:with-param name="decRedValue" select="$redValue"/>
214*cdf0e10cSrcweir                    <xsl:with-param name="decGreenValue" select="$greenValue"/>
215*cdf0e10cSrcweir                    <xsl:with-param name="decBlueValue" select="$blueValue"/>
216*cdf0e10cSrcweir                </xsl:call-template>
217*cdf0e10cSrcweir            </xsl:when>
218*cdf0e10cSrcweir            <xsl:otherwise/>
219*cdf0e10cSrcweir        </xsl:choose>
220*cdf0e10cSrcweir    </xsl:template>
221*cdf0e10cSrcweir    <xsl:template name="dec_rgb2Hex">
222*cdf0e10cSrcweir        <xsl:param name="decRedValue"/>
223*cdf0e10cSrcweir        <xsl:param name="decGreenValue"/>
224*cdf0e10cSrcweir        <xsl:param name="decBlueValue"/>
225*cdf0e10cSrcweir        <xsl:variable name="hexRedValue">
226*cdf0e10cSrcweir            <xsl:variable name="tmpHexRedValue">
227*cdf0e10cSrcweir                <xsl:call-template name="decimal2hex">
228*cdf0e10cSrcweir                    <xsl:with-param name="dec-number" select="$decRedValue"/>
229*cdf0e10cSrcweir                    <xsl:with-param name="last-value" select="'H'"/>
230*cdf0e10cSrcweir                </xsl:call-template>
231*cdf0e10cSrcweir            </xsl:variable>
232*cdf0e10cSrcweir            <xsl:choose>
233*cdf0e10cSrcweir                <xsl:when test="string-length($tmpHexRedValue) = 1">
234*cdf0e10cSrcweir                    <xsl:value-of select="concat('0',$tmpHexRedValue)"/>
235*cdf0e10cSrcweir                </xsl:when>
236*cdf0e10cSrcweir                <xsl:otherwise>
237*cdf0e10cSrcweir                    <xsl:value-of select="$tmpHexRedValue"/>
238*cdf0e10cSrcweir                </xsl:otherwise>
239*cdf0e10cSrcweir            </xsl:choose>
240*cdf0e10cSrcweir        </xsl:variable>
241*cdf0e10cSrcweir        <xsl:variable name="hexGreenValue">
242*cdf0e10cSrcweir            <xsl:variable name="tmpHexGreenValue">
243*cdf0e10cSrcweir                <xsl:call-template name="decimal2hex">
244*cdf0e10cSrcweir                    <xsl:with-param name="dec-number" select="$decGreenValue"/>
245*cdf0e10cSrcweir                    <xsl:with-param name="last-value" select="'H'"/>
246*cdf0e10cSrcweir                </xsl:call-template>
247*cdf0e10cSrcweir            </xsl:variable>
248*cdf0e10cSrcweir            <xsl:choose>
249*cdf0e10cSrcweir                <xsl:when test="string-length($tmpHexGreenValue) = 1">
250*cdf0e10cSrcweir                    <xsl:value-of select="concat('0',$tmpHexGreenValue)"/>
251*cdf0e10cSrcweir                </xsl:when>
252*cdf0e10cSrcweir                <xsl:otherwise>
253*cdf0e10cSrcweir                    <xsl:value-of select="$tmpHexGreenValue"/>
254*cdf0e10cSrcweir                </xsl:otherwise>
255*cdf0e10cSrcweir            </xsl:choose>
256*cdf0e10cSrcweir        </xsl:variable>
257*cdf0e10cSrcweir        <xsl:variable name="hexBlueValue">
258*cdf0e10cSrcweir            <xsl:variable name="tmpHexBlueValue">
259*cdf0e10cSrcweir                <xsl:call-template name="decimal2hex">
260*cdf0e10cSrcweir                    <xsl:with-param name="dec-number" select="$decBlueValue"/>
261*cdf0e10cSrcweir                    <xsl:with-param name="last-value" select="'H'"/>
262*cdf0e10cSrcweir                </xsl:call-template>
263*cdf0e10cSrcweir            </xsl:variable>
264*cdf0e10cSrcweir            <xsl:choose>
265*cdf0e10cSrcweir                <xsl:when test="string-length($tmpHexBlueValue) = 1">
266*cdf0e10cSrcweir                    <xsl:value-of select="concat('0',$tmpHexBlueValue)"/>
267*cdf0e10cSrcweir                </xsl:when>
268*cdf0e10cSrcweir                <xsl:otherwise>
269*cdf0e10cSrcweir                    <xsl:value-of select="$tmpHexBlueValue"/>
270*cdf0e10cSrcweir                </xsl:otherwise>
271*cdf0e10cSrcweir            </xsl:choose>
272*cdf0e10cSrcweir        </xsl:variable>
273*cdf0e10cSrcweir        <xsl:value-of select="concat('#',$hexRedValue,$hexGreenValue,$hexBlueValue)"/>
274*cdf0e10cSrcweir    </xsl:template>
275*cdf0e10cSrcweir    <xsl:template name="decimal2hex">
276*cdf0e10cSrcweir        <!-- transforms a decimal number to a hex number,only for two-bit hex(less than 256 in decimal) currently -->
277*cdf0e10cSrcweir        <xsl:param name="dec-number"/>
278*cdf0e10cSrcweir        <xsl:param name="last-value"/>
279*cdf0e10cSrcweir        <xsl:variable name="current-value">
280*cdf0e10cSrcweir            <xsl:call-template name="decNumber2hex">
281*cdf0e10cSrcweir                <xsl:with-param name="dec-value">
282*cdf0e10cSrcweir                    <xsl:if test="$dec-number &gt; 15">
283*cdf0e10cSrcweir                        <xsl:value-of select="floor($dec-number div 16)"/>
284*cdf0e10cSrcweir                    </xsl:if>
285*cdf0e10cSrcweir                    <xsl:if test="$dec-number &lt; 16">
286*cdf0e10cSrcweir                        <xsl:value-of select="$dec-number"/>
287*cdf0e10cSrcweir                    </xsl:if>
288*cdf0e10cSrcweir                </xsl:with-param>
289*cdf0e10cSrcweir            </xsl:call-template>
290*cdf0e10cSrcweir        </xsl:variable>
291*cdf0e10cSrcweir        <xsl:if test="$dec-number &gt; 15">
292*cdf0e10cSrcweir            <xsl:call-template name="decimal2hex">
293*cdf0e10cSrcweir                <xsl:with-param name="dec-number" select="$dec-number mod 16"/>
294*cdf0e10cSrcweir                <xsl:with-param name="last-value" select="concat($last-value,$current-value)"/>
295*cdf0e10cSrcweir            </xsl:call-template>
296*cdf0e10cSrcweir        </xsl:if>
297*cdf0e10cSrcweir        <xsl:if test="$dec-number &lt; 16">
298*cdf0e10cSrcweir            <xsl:value-of select="substring-after(concat($last-value,$current-value),'H')"/>
299*cdf0e10cSrcweir        </xsl:if>
300*cdf0e10cSrcweir    </xsl:template>
301*cdf0e10cSrcweir
302*cdf0e10cSrcweir    <xsl:template name="decNumber2hex">
303*cdf0e10cSrcweir        <!-- return a hex number for a decimal character -->
304*cdf0e10cSrcweir        <xsl:param name="dec-value"/>
305*cdf0e10cSrcweir        <xsl:choose>
306*cdf0e10cSrcweir            <xsl:when test="$dec-value = 10">
307*cdf0e10cSrcweir                <xsl:value-of select="'A'"/>
308*cdf0e10cSrcweir            </xsl:when>
309*cdf0e10cSrcweir            <xsl:when test="$dec-value = 11">
310*cdf0e10cSrcweir                <xsl:value-of select="'B'"/>
311*cdf0e10cSrcweir            </xsl:when>
312*cdf0e10cSrcweir            <xsl:when test="$dec-value = 12">
313*cdf0e10cSrcweir                <xsl:value-of select="'C'"/>
314*cdf0e10cSrcweir            </xsl:when>
315*cdf0e10cSrcweir            <xsl:when test="$dec-value = 13">
316*cdf0e10cSrcweir                <xsl:value-of select="'D'"/>
317*cdf0e10cSrcweir            </xsl:when>
318*cdf0e10cSrcweir            <xsl:when test="$dec-value = 14">
319*cdf0e10cSrcweir                <xsl:value-of select="'E'"/>
320*cdf0e10cSrcweir            </xsl:when>
321*cdf0e10cSrcweir            <xsl:when test="$dec-value = 15">
322*cdf0e10cSrcweir                <xsl:value-of select="'F'"/>
323*cdf0e10cSrcweir            </xsl:when>
324*cdf0e10cSrcweir            <xsl:otherwise>
325*cdf0e10cSrcweir                <xsl:value-of select="$dec-value"/>
326*cdf0e10cSrcweir            </xsl:otherwise>
327*cdf0e10cSrcweir        </xsl:choose>
328*cdf0e10cSrcweir    </xsl:template>
329*cdf0e10cSrcweir    <xsl:template name="GetTabColorIndex">
330*cdf0e10cSrcweir        <xsl:param name="SheetColor"/>
331*cdf0e10cSrcweir        <xsl:for-each select="key('config', 'TabColor')[not(.=preceding::config:config-item)]">
332*cdf0e10cSrcweir        <xsl:sort select="." />
333*cdf0e10cSrcweir            <xsl:variable name="tmpColor" select="."/>
334*cdf0e10cSrcweir            <xsl:if test=". = $SheetColor" >
335*cdf0e10cSrcweir                <xsl:value-of select="56 - position()"/>
336*cdf0e10cSrcweir            </xsl:if>
337*cdf0e10cSrcweir        </xsl:for-each>
338*cdf0e10cSrcweir    </xsl:template>
339*cdf0e10cSrcweir	<xsl:template match="office:body">
340*cdf0e10cSrcweir		<!-- office:body table:table children are spreadsheets -->
341*cdf0e10cSrcweir		<xsl:apply-templates />
342*cdf0e10cSrcweir	</xsl:template>
343*cdf0e10cSrcweir
344*cdf0e10cSrcweir	<xsl:template match="office:spreadsheet">
345*cdf0e10cSrcweir		<xsl:apply-templates />
346*cdf0e10cSrcweir	</xsl:template>
347*cdf0e10cSrcweir
348*cdf0e10cSrcweir	<!-- office:body table:table children are spreadsheets -->
349*cdf0e10cSrcweir	<xsl:template match="office:spreadsheet/table:table">
350*cdf0e10cSrcweir		<xsl:element name="ss:Worksheet">
351*cdf0e10cSrcweir			<xsl:variable name="TableName">
352*cdf0e10cSrcweir				<xsl:value-of select="@table:name" />
353*cdf0e10cSrcweir			</xsl:variable>
354*cdf0e10cSrcweir			<xsl:attribute name="ss:Name">
355*cdf0e10cSrcweir				<xsl:value-of select="$TableName" />
356*cdf0e10cSrcweir			</xsl:attribute>
357*cdf0e10cSrcweir			<xsl:call-template name="table:table" />
358*cdf0e10cSrcweir			<xsl:element name="x:WorksheetOptions">
359*cdf0e10cSrcweir				<xsl:if test="key('config', 'ShowGrid') = 'false'">
360*cdf0e10cSrcweir						<xsl:element name="x:DoNotDisplayGridlines" />
361*cdf0e10cSrcweir				</xsl:if>
362*cdf0e10cSrcweir				<xsl:if test="key('config', 'HasColumnRowHeaders') = 'false'">
363*cdf0e10cSrcweir						<xsl:element name="x:DoNotDisplayHeadings" />
364*cdf0e10cSrcweir				</xsl:if>
365*cdf0e10cSrcweir				<xsl:if test="key('config', 'IsOutlineSymbolsSet') = 'false'">
366*cdf0e10cSrcweir						<xsl:element name="x:DoNotDisplayOutline" />
367*cdf0e10cSrcweir				</xsl:if>
368*cdf0e10cSrcweir				<xsl:if test="key('config', 'ShowZeroValues') = 'false'">
369*cdf0e10cSrcweir						<xsl:element name="x:DoNotDisplayZeros" />
370*cdf0e10cSrcweir				</xsl:if>
371*cdf0e10cSrcweir                <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']">
372*cdf0e10cSrcweir                    <xsl:element name="x:TabColorIndex">
373*cdf0e10cSrcweir                        <xsl:variable name="TabColorIndex">
374*cdf0e10cSrcweir                            <xsl:call-template name="GetTabColorIndex">
375*cdf0e10cSrcweir                                <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']"/>
376*cdf0e10cSrcweir                            </xsl:call-template>
377*cdf0e10cSrcweir                        </xsl:variable>
378*cdf0e10cSrcweir                        <xsl:value-of select="$TabColorIndex"/>
379*cdf0e10cSrcweir                    </xsl:element>
380*cdf0e10cSrcweir                </xsl:if>
381*cdf0e10cSrcweir			</xsl:element>
382*cdf0e10cSrcweir		</xsl:element>
383*cdf0e10cSrcweir	</xsl:template>
384*cdf0e10cSrcweir
385*cdf0e10cSrcweir	<xsl:template match="table:decls" mode="ExcelWorkbook">
386*cdf0e10cSrcweir		<xsl:apply-templates mode="ExcelWorkbook" />
387*cdf0e10cSrcweir	</xsl:template>
388*cdf0e10cSrcweir
389*cdf0e10cSrcweir	<xsl:template match="table:calculation-settings"  mode="ExcelWorkbook">
390*cdf0e10cSrcweir		<xsl:if test="table:precision-as-shown">
391*cdf0e10cSrcweir			<x:PrecisionAsDisplayed/>
392*cdf0e10cSrcweir		</xsl:if>
393*cdf0e10cSrcweir		<xsl:if test="table:null-date/@office:date-value='1904-01-01'">
394*cdf0e10cSrcweir			<x:Date1904/>
395*cdf0e10cSrcweir		</xsl:if>
396*cdf0e10cSrcweir		<xsl:apply-templates select="table:iteration" />
397*cdf0e10cSrcweir	</xsl:template>
398*cdf0e10cSrcweir
399*cdf0e10cSrcweir	<xsl:template match="table:iteration" mode="ExcelWorkbook">
400*cdf0e10cSrcweir		<xsl:element name="x:ExcelWorkbook">
401*cdf0e10cSrcweir			<xsl:if test="@table:status = 'enable'">
402*cdf0e10cSrcweir				<x:Iteration/>
403*cdf0e10cSrcweir			</xsl:if>
404*cdf0e10cSrcweir			<xsl:if test="@table:steps">
405*cdf0e10cSrcweir				<xsl:element name="x:MaxIterations">
406*cdf0e10cSrcweir					<xsl:value-of select="@table:steps" />
407*cdf0e10cSrcweir				</xsl:element>
408*cdf0e10cSrcweir			</xsl:if>
409*cdf0e10cSrcweir			<xsl:if test="@table:maximum-difference">
410*cdf0e10cSrcweir				<xsl:element name="x:MaxChange">
411*cdf0e10cSrcweir					<xsl:value-of select="@table:maximum-difference" />
412*cdf0e10cSrcweir				</xsl:element>
413*cdf0e10cSrcweir			</xsl:if>
414*cdf0e10cSrcweir		</xsl:element>
415*cdf0e10cSrcweir	</xsl:template>
416*cdf0e10cSrcweir
417*cdf0e10cSrcweir</xsl:stylesheet>
418