1
<?xml version="1.0" encoding="UTF-8"?>
4
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6
Copyright 2008 by Sun Microsystems, Inc.
8
OpenOffice.org - a multi-platform office productivity suite
10
$RCSfile: table.xsl,v $
14
This file is part of OpenOffice.org.
16
OpenOffice.org is free software: you can redistribute it and/or modify
17
it under the terms of the GNU Lesser General Public License version 3
18
only, as published by the Free Software Foundation.
20
OpenOffice.org is distributed in the hope that it will be useful,
21
but WITHOUT ANY WARRANTY; without even the implied warranty of
22
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
GNU Lesser General Public License version 3 for more details
24
(a copy is included in the LICENSE file that accompanied this code).
26
You should have received a copy of the GNU Lesser General Public License
27
version 3 along with OpenOffice.org. If not, see
28
<http://www.openoffice.org/license.html>
29
for a copy of the LGPLv3 License.
33
For further documentation and updates visit http://xml.openoffice.org/odf2xhtml
35
<xsl:stylesheet version="1.0"
36
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
37
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
38
xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0"
39
xmlns:dc="http://purl.org/dc/elements/1.1/"
40
xmlns:dom="http://www.w3.org/2001/xml-events"
41
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"
42
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
43
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
44
xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"
45
xmlns:math="http://www.w3.org/1998/Math/MathML"
46
xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0"
47
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
48
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
49
xmlns:ooo="http://openoffice.org/2004/office"
50
xmlns:oooc="http://openoffice.org/2004/calc"
51
xmlns:ooow="http://openoffice.org/2004/writer"
52
xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"
53
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
54
xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
55
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
56
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
57
xmlns:xforms="http://www.w3.org/2002/xforms"
58
xmlns:xlink="http://www.w3.org/1999/xlink"
59
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
60
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
61
exclude-result-prefixes="chart config dc dom dr3d draw fo form math meta number office ooo oooc ooow script style svg table text xforms xlink xsd xsi"
62
xmlns="http://www.w3.org/1999/xhtml">
66
<!-- current node is a table:table -->
67
<xsl:template name="create-table-children">
68
<xsl:param name="globalData" />
69
<xsl:param name="allVisibleTableRows" />
70
<xsl:param name="allTableColumns" />
72
<xsl:element name="colgroup">
73
<xsl:for-each select="$allTableColumns/table:table-column">
74
<xsl:if test="not(@table:visibility = 'collapse' or @table:visibility = 'filter')">
75
<xsl:element name="col">
76
<xsl:variable name="value" select="$globalData/all-doc-styles/style[@style:name = current()/@table:style-name]/*/@style:column-width" />
77
<xsl:if test="$value">
78
<xsl:attribute name="width">
79
<!-- using the absolute width, problems with the relative in browser (in OOo style:rel-column-width) -->
80
<xsl:call-template name="convert2px">
81
<xsl:with-param name="value" select="$globalData/all-doc-styles/style[@style:name = current()/@table:style-name]/*/@style:column-width" />
86
<!-- *** the column-style ***
87
<xsl:attribute name="width">
88
<xsl:variable name="currentColumnStyleName" select="$allTableColumns/table:table-column[position() = $columnPosition]/@table:style-name" />
89
<xsl:value-of select="$globalData/all-doc-styles/style[@style:name = $currentColumnStyleName]/*/@style:column-width" />
95
<xsl:call-template name="create-table-rows">
96
<xsl:with-param name="globalData" select="$globalData" />
97
<xsl:with-param name="allVisibleTableRows" select="$allVisibleTableRows" />
98
<xsl:with-param name="allTableColumns" select="$allTableColumns" />
104
<!-- Creating the content of a table content using CSS styles -->
105
<xsl:template name="create-table-cell-content">
106
<xsl:param name="tableDataType" />
107
<xsl:param name="globalData" />
108
<xsl:param name="allTableColumns" />
109
<xsl:param name="columnPosition" />
110
<xsl:param name="currentTableColumn" />
112
<xsl:element name="{$tableDataType}">
114
<!-- if parser reads DTD the default is set to '1' -->
115
<xsl:if test="@table:number-columns-spanned and @table:number-columns-spanned > 1">
116
<xsl:attribute name="colspan">
117
<xsl:value-of select="@table:number-columns-spanned" />
120
<!-- if parser reads DTD the default is set to '1' -->
121
<xsl:if test="@table:number-rows-spanned and @table:number-rows-spanned > 1">
122
<xsl:attribute name="rowspan">
123
<xsl:value-of select="@table:number-rows-spanned" />
128
<!-- *** the cell-style *** -->
129
<!-- The cell style has no conclusion with the column style, so we switch the order/priorities due to browser issues
131
The cell-style depends on two attributes:
133
1) table:style-name - the style properties of cell. When they exist, a default alignement (cp. below) will be added for the
134
case of no alignment in the style exist.
136
2) office:value-type - the value type of the table-cell giving the default alignments.
137
By default a string value is left aligned, all other are aligned:right.
140
<xsl:when test="@table:style-name">
141
<xsl:call-template name="set-styles">
142
<xsl:with-param name="globalData" select="$globalData" />
143
<xsl:with-param name="styleName" select="@table:style-name" />
144
<xsl:with-param name="currentTableColumn" select="$currentTableColumn" />
148
<!-- Cells without a style use the 'table:default-cell-style-name'
149
when there is no default cell style specified for the current column. -->
150
<xsl:variable name="defaultCellStyleName" select="$currentTableColumn/@table:default-cell-style-name" />
152
<xsl:when test="$defaultCellStyleName">
153
<xsl:call-template name="set-styles">
154
<xsl:with-param name="globalData" select="$globalData" />
155
<xsl:with-param name="styleName" select="$defaultCellStyleName" />
156
<xsl:with-param name="currentTableColumn" select="$currentTableColumn" />
160
<!-- No cell style exists, nor a default table cell style for the column -->
161
<xsl:attribute name="style">
162
<!-- sets cell alignment dependent of cell value type -->
163
<xsl:call-template name="set-cell-alignment" />
170
<xsl:if test="$debugEnabled">
171
<xsl:message>A table cell '<xsl:value-of select="$tableDataType" />' element has been added!</xsl:message>
174
<!-- empty cell tags produce problems with width CSS style on itself other table cells as well
175
therefore an non breakable space ( / ) have been inserted.-->
177
<xsl:when test="node()">
178
<xsl:call-template name="apply-styles-and-content">
179
<xsl:with-param name="globalData" select="$globalData" />
183
<xsl:call-template name="apply-styles-and-content">
184
<xsl:with-param name="globalData" select="$globalData" />
186
<xsl:text> </xsl:text>
194
<!-- Sets the cell alignment by the 'office:value-type' of the 'table:table-cell'.
195
Strings have a left alignment, other values right -->
196
<xsl:template name="set-cell-alignment">
198
<xsl:when test="@office:value-type and not(@office:value-type = 'string')">text-align:right; </xsl:when>
199
<xsl:otherwise>text-align:left;</xsl:otherwise>
205
<!-- Sets styles of a cell -->
206
<xsl:template name="set-styles">
207
<xsl:param name="globalData" />
208
<xsl:param name="styleName" />
209
<xsl:param name="currentTableColumn" />
211
<xsl:attribute name="style">
212
<!-- sets cell alignment dependent of cell value type -->
213
<xsl:call-template name="set-cell-alignment" />
215
<!-- set column style (disjunct of cell style) -->
216
<xsl:value-of select="$globalData/all-styles/style[@style:name = $currentTableColumn/@table:style-name]/final-properties" />
220
<!-- cell style header -->
221
<xsl:attribute name="class">
222
<xsl:value-of select="translate($styleName, '.,;: %()[]/\+', '_____________')"/>