/xmlbench/trunk

To get this branch, use:
bzr branch http://darksoft.org/webbzr/xmlbench/trunk

« back to all changes in this revision

Viewing changes to xml.files/odt/export/common/table/table.xsl

  • Committer: Suren A. Chilingaryan
  • Date: 2009-02-16 09:27:17 UTC
  • Revision ID: csa@dside.dyndns.org-20090216092717-wipyvaaw2srxhgns
Initial import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="UTF-8"?>
 
2
<!--
 
3
 
 
4
  DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 
5
  
 
6
  Copyright 2008 by Sun Microsystems, Inc.
 
7
 
 
8
  OpenOffice.org - a multi-platform office productivity suite
 
9
 
 
10
  $RCSfile: table.xsl,v $
 
11
 
 
12
  $Revision: 1.2.62.1 $
 
13
 
 
14
  This file is part of OpenOffice.org.
 
15
 
 
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.
 
19
 
 
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).
 
25
 
 
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.
 
30
 
 
31
-->
 
32
<!--
 
33
        For further documentation and updates visit http://xml.openoffice.org/odf2xhtml
 
34
-->
 
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
 
 
63
 
 
64
        <!-- table row handling -->
 
65
        <xsl:include href="table_rows.xsl" />
 
66
        <!-- table column handling -->
 
67
        <xsl:include href="table_columns.xsl" />
 
68
        <!-- table cell handling -->
 
69
        <xsl:include href="table_cells.xsl" />
 
70
 
 
71
        <xsl:param name="tableElement" select="'table'" />
 
72
 
 
73
        <!-- ******************* -->
 
74
        <!-- *** main table  *** -->
 
75
        <!-- ******************* -->
 
76
 
 
77
 
 
78
        <xsl:template match="table:table" name="table:table">
 
79
                <xsl:param name="globalData" />
 
80
 
 
81
                <!-- The table will only be created if the table:scenario is active -->
 
82
                <xsl:if test="not(table:scenario) or table:scenario/@table:is-active">
 
83
                        <xsl:call-template name="create-table">
 
84
                                <xsl:with-param name="globalData" select="$globalData" />
 
85
                        </xsl:call-template>
 
86
                </xsl:if>
 
87
        </xsl:template>
 
88
 
 
89
 
 
90
 
 
91
        <xsl:template name="create-table">
 
92
                <xsl:param name="globalData" />
 
93
 
 
94
                <!-- by default '1', for each new sub/inner/nested table the number counts one up -->
 
95
                <xsl:variable name="tableLevel" select="count(ancestor-or-self::table:table)" />
 
96
                <!-- collecting all visible "table:table-row" elements of the table -->
 
97
                <xsl:variable name="allVisibleTableRows" select="table:table-row[not(@table:visibility = 'collapse' or @table:visibility = 'filter')][count(ancestor-or-self::table:table) = $tableLevel] |
 
98
                                                                                                                 table:table-header-rows/descendant::table:table-row[not(@table:visibility = 'collapse' or @table:visibility = 'filter')][count(ancestor-or-self::table:table) = $tableLevel] |
 
99
                                                                                                                 table:table-row-group/descendant::table:table-row[not(@table:visibility = 'collapse' or @table:visibility = 'filter')][count(ancestor-or-self::table:table) = $tableLevel]" />
 
100
                <!-- As the alignment of a table is by 'align' attribut is deprecated and as the CSS 'float' attribute not well displayed,
 
101
                         we do a trick by encapsulating the table with a aligned 'div' element-->
 
102
                <xsl:variable name="table-alignment" select="key('styles', @style:name = current()/@table:style-name)/*/@table:align" />
 
103
                <xsl:choose>
 
104
                        <xsl:when test="string-length($table-alignment) != 0">
 
105
                                <xsl:element namespace="{$namespace}" name="div">
 
106
                                        <xsl:attribute name="style">
 
107
                                                <xsl:choose>
 
108
                                                        <xsl:when test='$table-alignment="left" or $table-alignment="margins"'>
 
109
                                                                <xsl:text>text-align:left</xsl:text>
 
110
                                                        </xsl:when>
 
111
                                                        <xsl:when test='$table-alignment="right"'>
 
112
                                                                <xsl:text>text-align:right</xsl:text>
 
113
                                                        </xsl:when>
 
114
                                                        <xsl:when test='$table-alignment="center"'>
 
115
                                                                <xsl:text>text-align:center</xsl:text>
 
116
                                                        </xsl:when>
 
117
                                                </xsl:choose>
 
118
                                        </xsl:attribute>
 
119
                                        <xsl:call-template name="create-table-element">
 
120
                                                <xsl:with-param name="globalData" select="$globalData" />
 
121
                                                <xsl:with-param name="allVisibleTableRows" select="$allVisibleTableRows" />
 
122
                                        </xsl:call-template>
 
123
                                </xsl:element>
 
124
                        </xsl:when>
 
125
                        <xsl:otherwise>
 
126
                                <xsl:call-template name="create-table-element">
 
127
                                        <xsl:with-param name="globalData" select="$globalData" />
 
128
                                        <xsl:with-param name="allVisibleTableRows" select="$allVisibleTableRows" />
 
129
                                </xsl:call-template>
 
130
                        </xsl:otherwise>
 
131
                </xsl:choose>
 
132
        </xsl:template>
 
133
 
 
134
 
 
135
        <xsl:template name="create-table-element">
 
136
                <xsl:param name="globalData" />
 
137
                <xsl:param name="allVisibleTableRows" />
 
138
 
 
139
                <xsl:element namespace="{$namespace}" name="{$tableElement}">
 
140
                        <xsl:attribute name="border">0</xsl:attribute>
 
141
                        <xsl:attribute name="cellspacing">0</xsl:attribute>
 
142
                        <xsl:attribute name="cellpadding">0</xsl:attribute>
 
143
                        <xsl:choose>
 
144
                                <xsl:when test='name()="table:table"'>
 
145
                                        <xsl:variable name="value" select="$globalData/all-doc-styles/style[@style:name = current()/@table:style-name]/*/@style:rel-width" />
 
146
                                        <xsl:if test="$value">
 
147
                                                <xsl:attribute name="width">
 
148
                                                        <xsl:value-of select="$value" />
 
149
                                                </xsl:attribute>
 
150
                                        </xsl:if>
 
151
                                </xsl:when>
 
152
                                <xsl:otherwise>
 
153
                                        <xsl:attribute name="width">100%</xsl:attribute>
 
154
                                </xsl:otherwise>
 
155
                        </xsl:choose>
 
156
 
 
157
                        <xsl:apply-templates select="@table:style-name">
 
158
                                <xsl:with-param name="globalData" select="$globalData" />
 
159
                        </xsl:apply-templates>
 
160
 
 
161
                        <xsl:call-template name="create-column-style-variable">
 
162
                                <xsl:with-param name="globalData" select="$globalData" />
 
163
                                <xsl:with-param name="allVisibleTableRows" select="$allVisibleTableRows" />
 
164
                        </xsl:call-template>
 
165
                </xsl:element>
 
166
        </xsl:template>
 
167
 
 
168
</xsl:stylesheet>