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_rows.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">
64
<xsl:param name="rowElement" select="'tr'" />
66
<!-- ********************************** -->
67
<!-- *** write repeating table rows *** -->
68
<!-- ********************************** -->
70
<!-- current node is a table:table -->
71
<xsl:template name="create-table-rows">
72
<xsl:param name="globalData" />
73
<xsl:param name="allVisibleTableRows" />
74
<xsl:param name="allTableColumns" />
76
<!-- Some Office Calc documents simulate a background by repeating one of the later cells until end of used space
77
(The value of "table:number-columns-repeated" is enourmous). Writing out all these cells would be fatal in time
78
and output size. Therefore, this global variable shows us the longest row with content. -->
79
<xsl:variable name="maxRowLength" select="count($allTableColumns/table:table-column)" />
80
<xsl:if test="$debugEnabled">
81
<xsl:message>maxRowLength: <xsl:value-of select="$maxRowLength" /></xsl:message>
82
<xsl:call-template name="table-debug-allTableColumns">
83
<xsl:with-param name="allTableColumns" select="$allTableColumns" />
87
<!-- a table is a table header, when it has a "table:table-header-rows" ancestor -->
88
<xsl:variable name="tableDataType">
90
<xsl:when test="ancestor::table:table-header-rows">
91
<xsl:text>th</xsl:text>
94
<xsl:text>td</xsl:text>
99
<!-- removes repetition of rows, most probably done for background emulating -->
100
<xsl:for-each select="$allVisibleTableRows">
102
<xsl:when test="(last() or (last() - 1)) and @table:number-rows-repeated > 99">
103
<xsl:call-template name="repeat-write-row">
104
<xsl:with-param name="globalData" select="$globalData" />
105
<xsl:with-param name="allTableColumns" select="$allTableColumns" />
106
<xsl:with-param name="numberRowsRepeated" select="1" />
107
<xsl:with-param name="maxRowLength" select="$maxRowLength" />
108
<xsl:with-param name="tableDataType" select="$tableDataType" />
112
<xsl:call-template name="repeat-write-row">
113
<xsl:with-param name="globalData" select="$globalData" />
114
<xsl:with-param name="allTableColumns" select="$allTableColumns" />
115
<xsl:with-param name="numberRowsRepeated" select="@table:number-rows-repeated" />
116
<xsl:with-param name="maxRowLength" select="$maxRowLength" />
117
<xsl:with-param name="tableDataType" select="$tableDataType" />
125
<xsl:template name="repeat-write-row">
126
<xsl:param name="globalData" />
127
<xsl:param name="allTableColumns" />
128
<xsl:param name="numberRowsRepeated" select="1" />
129
<xsl:param name="maxRowLength" />
130
<xsl:param name="tableDataType" />
133
<!-- write an entry of a row and repeat calling this method until all elements are written out -->
134
<xsl:when test="$numberRowsRepeated > 1 and table:table-cell">
135
<xsl:call-template name="write-row">
136
<xsl:with-param name="globalData" select="$globalData" />
137
<xsl:with-param name="allTableColumns" select="$allTableColumns" />
138
<xsl:with-param name="maxRowLength" select="$maxRowLength" />
139
<xsl:with-param name="tableDataType" select="$tableDataType" />
142
<!-- NOTE: take variable from the output of repeated write-row and iterate giving out the variable -->
143
<xsl:call-template name="repeat-write-row">
144
<xsl:with-param name="globalData" select="$globalData" />
145
<xsl:with-param name="allTableColumns" select="$allTableColumns" />
146
<xsl:with-param name="maxRowLength" select="$maxRowLength" />
147
<xsl:with-param name="numberRowsRepeated" select="$numberRowsRepeated - 1" />
148
<xsl:with-param name="tableDataType" select="$tableDataType" />
151
<!-- write a single entry of a row -->
153
<xsl:call-template name="write-row">
154
<xsl:with-param name="globalData" select="$globalData" />
155
<xsl:with-param name="allTableColumns" select="$allTableColumns" />
156
<xsl:with-param name="maxRowLength" select="$maxRowLength" />
157
<xsl:with-param name="tableDataType" select="$tableDataType" />
164
<xsl:template name="add-table-row-attributes">
165
<xsl:param name="globalData" />
167
<!-- writing the style of the row -->
168
<xsl:if test="@table:style-name">
169
<xsl:call-template name='add-style-properties'>
170
<xsl:with-param name="globalData" select="$globalData" />
175
<xsl:template name="write-row">
176
<xsl:param name="globalData" />
177
<xsl:param name="allTableColumns" />
178
<xsl:param name="maxRowLength" />
179
<xsl:param name="tableDataType" />
182
<xsl:element namespace="{$namespace}" name="{$rowElement}">
183
<xsl:call-template name='add-table-row-attributes'>
184
<xsl:with-param name="globalData" select="$globalData" />
187
<xsl:if test="$debugEnabled">
188
<xsl:message>'tr' element has been added!</xsl:message>
191
<xsl:apply-templates select="table:table-cell">
192
<xsl:with-param name="globalData" select="$globalData" />
193
<xsl:with-param name="allTableColumns" select="$allTableColumns" />
194
<xsl:with-param name="maxRowLength" select="$maxRowLength" />
195
<xsl:with-param name="tableDataType" select="$tableDataType" />
196
</xsl:apply-templates>
202
<!-- **************************** -->
203
<!-- *** HELPER: table styles *** -->
204
<!-- **************************** -->
206
<xsl:template name="add-style-properties">
207
<xsl:param name="globalData" />
208
<xsl:param name="allTableColumns" />
209
<xsl:param name="node-position" />
211
<xsl:attribute name="class">
212
<xsl:value-of select="translate(@table:style-name, '. %()/\+', '')" />