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