/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/xhtml/body.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: body.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" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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" xmlns="http://www.w3.org/1999/xhtml">
 
36
 
 
37
 
 
38
 
 
39
        <!--+++++ INCLUDED XSL MODULES +++++-->
 
40
 
 
41
        <!-- helper collection, to convert measures (e.g. inch to pixel using DPI (dots per inch) parameter)-->
 
42
        <xsl:import href="../../common/measure_conversion.xsl"/>
 
43
 
 
44
        <!-- common office body element handling -->
 
45
        <xsl:import href="../common/body.xsl"/>
 
46
 
 
47
        <!-- common table handling -->
 
48
        <xsl:import href="../common/table/table.xsl"/>
 
49
 
 
50
        <!-- xhtml table handling -->
 
51
        <xsl:include href="table.xsl"/>
 
52
 
 
53
        <!-- Useful in case of 'style:map', conditional formatting, where a style references to another -->
 
54
        <xsl:key name="styles" match="/*/office:styles/style:style | /*/office:automatic-styles/style:style" use="@style:name"/>
 
55
 
 
56
 
 
57
        <!-- ************ -->
 
58
        <!-- *** body *** -->
 
59
        <!-- ************ -->
 
60
 
 
61
        <xsl:template name="create-body">
 
62
                <xsl:param name="globalData"/>
 
63
 
 
64
                <!-- approximation as attribute belongs to a page style, which won't work in XHTML -->
 
65
                <xsl:variable name="pageProperties" select="$globalData/styles-file/*/office:automatic-styles/style:page-layout[1]/style:page-layout-properties"/>
 
66
 
 
67
                <xsl:element name="body">
 
68
                        <!-- direction of text flow -->
 
69
                        <xsl:variable name="writingMode" select="$pageProperties/@style:writing-mode"/>
 
70
                        <xsl:if test="$writingMode">
 
71
                                <xsl:choose>
 
72
                                        <xsl:when test="contains($writingMode, 'lr')">
 
73
                                                <xsl:attribute name="dir">ltr</xsl:attribute>
 
74
                                        </xsl:when>
 
75
                                        <xsl:when test="contains($writingMode, 'rl')">
 
76
                                                <xsl:attribute name="dir">rtl</xsl:attribute>
 
77
                                        </xsl:when>
 
78
                                </xsl:choose>
 
79
                        </xsl:if>
 
80
 
 
81
                        <!-- adapt page size -->
 
82
                        <xsl:variable name="pageWidth" select="$pageProperties/@fo:page-width"/>
 
83
 
 
84
                        <!-- multiple backgroundimages for different page styles (never used in html) -->
 
85
                        <xsl:variable name="backgroundImage" select="$pageProperties/style:background-image"/>
 
86
 
 
87
                        <!-- page margins & background image  -->
 
88
                        <xsl:if test="$pageWidth or $pageProperties/@fo:* or $backgroundImage/@xlink:href">
 
89
                                <xsl:attribute name="style">
 
90
                                        <xsl:if test="$pageWidth">
 
91
                                                 <xsl:text>max-width:</xsl:text><xsl:value-of select="$pageWidth"/><xsl:text>;</xsl:text>
 
92
                                        </xsl:if>
 
93
                                        <xsl:if test="$pageProperties/@fo:* or $backgroundImage/@xlink:href">
 
94
                                                <xsl:apply-templates select="$pageProperties/@fo:*"/>
 
95
                                                <xsl:if test="$backgroundImage/@xlink:href">
 
96
                                                        <xsl:text>background-image:url(</xsl:text>
 
97
                                                        <xsl:call-template name="create-href">
 
98
                                                                <xsl:with-param name="href" select="$backgroundImage/@xlink:href"/>
 
99
                                                        </xsl:call-template>
 
100
                                                        <xsl:text>);</xsl:text>
 
101
 
 
102
                                                        <xsl:if test="$backgroundImage/@style:repeat">
 
103
                                                                <xsl:choose>
 
104
                                                                        <xsl:when test="$backgroundImage/@style:repeat = 'no-repeat'">
 
105
                                                                                <xsl:text>background-repeat:no-repeat;</xsl:text>
 
106
                                                                        </xsl:when>
 
107
                                                                        <xsl:otherwise>
 
108
                                                                                <xsl:text>background-repeat:repeat;</xsl:text>
 
109
                                                                        </xsl:otherwise>
 
110
                                                                </xsl:choose>
 
111
                                                        </xsl:if>
 
112
                                                        <xsl:if test="$backgroundImage/@style:position">
 
113
                                                                <xsl:text>background-position:</xsl:text>
 
114
                                                                <xsl:value-of select="$backgroundImage/@style:position"/>
 
115
                                                                <xsl:text>;</xsl:text>
 
116
                                                        </xsl:if>
 
117
                                                </xsl:if>
 
118
                                        </xsl:if>
 
119
                                </xsl:attribute>
 
120
                        </xsl:if>
 
121
                        <!-- processing the content of the xml file -->
 
122
                        <xsl:apply-templates select="/*/office:body/*">
 
123
                                <xsl:with-param name="globalData" select="$globalData"/>
 
124
                        </xsl:apply-templates>
 
125
                </xsl:element>
 
126
        </xsl:template>
 
127
 
 
128
 
 
129
        <xsl:template match="office:body/*">
 
130
                <xsl:param name="globalData"/>
 
131
 
 
132
                <!-- not using of 'apply-styles-and-content' as the content table information migth have been added to 'globalData' variable -->
 
133
                <xsl:apply-templates select="@text:style-name | @draw:style-name | @draw:text-style-name | @table:style-name"><!-- | @presentation:style-name -->
 
134
                        <xsl:with-param name="globalData" select="$globalData"/>
 
135
                </xsl:apply-templates>
 
136
 
 
137
                <xsl:apply-templates>
 
138
                        <xsl:with-param name="globalData" select="$globalData"/>
 
139
                </xsl:apply-templates>
 
140
 
 
141
                <!-- writing the footer- and endnotes beyond the body -->
 
142
                <xsl:call-template name="write-text-nodes">
 
143
                        <xsl:with-param name="globalData" select="$globalData"/>
 
144
                </xsl:call-template>
 
145
 
 
146
        </xsl:template>
 
147
 
 
148
        <!-- ******************************* -->
 
149
        <!-- *** User Field Declarations *** -->
 
150
        <!-- ******************************* -->
 
151
 
 
152
        <xsl:template match="text:user-field-get | text:user-field-input">
 
153
                <xsl:param name="globalData"/>
 
154
 
 
155
                <xsl:value-of select="."/>
 
156
        </xsl:template>
 
157
 
 
158
        <xsl:template match="text:conditional-text">
 
159
                <xsl:param name="globalData"/>
 
160
 
 
161
                <xsl:value-of select="."/>
 
162
        </xsl:template>
 
163
 
 
164
        <!-- ODF text fields -->
 
165
        <xsl:template match="text:author-initials |
 
166
                                                text:author-name |
 
167
                                                text:chapter |
 
168
                                                text:character-count |
 
169
                                                text:creation-date |
 
170
                                                text:creation-time |
 
171
                                                text:creator |
 
172
                                                text:date |
 
173
                                                text:description |
 
174
                                                text:editing-cycles |
 
175
                                                text:editing-duration |
 
176
                                                text:file-name |
 
177
                                                text:image-count |
 
178
                                                text:initial-creator |
 
179
                                                text:keywords |
 
180
                                                text:modification-date |
 
181
                                                text:modification-time |
 
182
                                                text:object-count |
 
183
                                                text:page-continuation |
 
184
                                                text:page-count |
 
185
                                                text:page-number |
 
186
                                                text:paragraph-count |
 
187
                                                text:print-date |
 
188
                                                text:print-time |
 
189
                                                text:printed-by |
 
190
                                                text:sender-city |
 
191
                                                text:sender-company |
 
192
                                                text:sender-country |
 
193
                                                text:sender-email |
 
194
                                                text:sender-fax |
 
195
                                                text:sender-firstname |
 
196
                                                text:sender-initials |
 
197
                                                text:sender-lastname |
 
198
                                                text:sender-phone-private |
 
199
                                                text:sender-phone-work |
 
200
                                                text:sender-position |
 
201
                                                text:sender-postal-code |
 
202
                                                text:sender-state-or-province |
 
203
                                                text:sender-street |
 
204
                                                text:sender-title |
 
205
                                                text:sheet-name |
 
206
                                                text:subject |
 
207
                                                text:table-count |
 
208
                                                text:time |
 
209
                                                text:title |
 
210
                                                text:user-defined |
 
211
                                                text:word-count">
 
212
                <xsl:param name="globalData"/>
 
213
 
 
214
                <xsl:element name="span">
 
215
                        <xsl:attribute name="title"><xsl:value-of select="local-name()"/></xsl:attribute>
 
216
                        <xsl:apply-templates>
 
217
                                <xsl:with-param name="globalData" select="$globalData"/>
 
218
                        </xsl:apply-templates>
 
219
                </xsl:element>
 
220
        </xsl:template>
 
221
 
 
222
 
 
223
 
 
224
        <!-- *************** -->
 
225
        <!-- *** Textbox *** -->
 
226
        <!-- *************** -->
 
227
 
 
228
        <xsl:template match="draw:text-box">
 
229
                <xsl:param name="globalData"/>
 
230
 
 
231
                <xsl:element name="div">
 
232
                        <xsl:if test="@svg:height | @svg:width">
 
233
                                <xsl:attribute name="style">
 
234
                                        <xsl:choose>
 
235
                                                <xsl:when test="not(@svg:width)">
 
236
                                                        <xsl:call-template name="svg:height"/>
 
237
                                                </xsl:when>
 
238
                                                <xsl:when test="not(@svg:height)">
 
239
                                                        <xsl:call-template name="svg:width"/>
 
240
                                                </xsl:when>
 
241
                                                <xsl:otherwise>
 
242
                                                        <xsl:call-template name="svg:height"/>
 
243
                                                        <xsl:call-template name="svg:width"/>
 
244
                                                </xsl:otherwise>
 
245
                                        </xsl:choose>
 
246
                                </xsl:attribute>
 
247
                        </xsl:if>
 
248
                        <xsl:apply-templates select="@draw:name">
 
249
                                <xsl:with-param name="globalData" select="$globalData"/>
 
250
                        </xsl:apply-templates>
 
251
 
 
252
                        <xsl:call-template name="apply-styles-and-content">
 
253
                                <xsl:with-param name="globalData" select="$globalData"/>
 
254
                        </xsl:call-template>
 
255
                </xsl:element>
 
256
        </xsl:template>
 
257
 
 
258
        <!-- inline style helper for the 'div' boxes -->
 
259
        <xsl:template name="svg:height">
 
260
                <xsl:text>height: </xsl:text>
 
261
                <xsl:choose>
 
262
                        <!-- changing the distance measure: inch to in -->
 
263
                        <xsl:when test="contains(@svg:height, 'inch')">
 
264
                                <xsl:value-of select="substring-before(@svg:height, 'ch')"/>
 
265
                        </xsl:when>
 
266
                        <xsl:otherwise>
 
267
                                <xsl:value-of select="@svg:height"/>
 
268
                        </xsl:otherwise>
 
269
                </xsl:choose>
 
270
                <xsl:text>;</xsl:text>
 
271
        </xsl:template>
 
272
 
 
273
        <!-- inline style helper for the 'div' boxes -->
 
274
        <xsl:template name="svg:width">
 
275
                <xsl:text>width: </xsl:text>
 
276
                <xsl:choose>
 
277
                        <!-- changing the distance measure: inch to in -->
 
278
                        <xsl:when test="contains(@svg:width, 'inch')">
 
279
                                <xsl:value-of select="substring-before(@svg:width, 'ch')"/>
 
280
                        </xsl:when>
 
281
                        <xsl:otherwise>
 
282
                                <xsl:value-of select="@svg:width"/>
 
283
                        </xsl:otherwise>
 
284
                </xsl:choose>
 
285
                <xsl:text>;</xsl:text>
 
286
        </xsl:template>
 
287
 
 
288
 
 
289
 
 
290
        <!-- ****************** -->
 
291
        <!-- *** Paragraphs *** -->
 
292
        <!-- ****************** -->
 
293
 
 
294
        <xsl:template match="text:p | draw:page">
 
295
                <xsl:param name="globalData"/>
 
296
                <!-- the footnote symbol is the prefix for a footnote in the footer -->
 
297
                <xsl:param name="footnotePrefix"/>
 
298
 
 
299
                <!-- 1) A draw:text-box my include paragraphs (text:p) itself and in HTML a 'p' can only have inline documents (no other 'p' as children'),
 
300
                                a 'div' will be given out instead.
 
301
                         2) A images are embedded in a paragraph, but are in CSS not able to express a horizontal alignment for themself (text:align is only valid for block elements).
 
302
                                A surrounding 'div' element taking over the image style solves that problem, but is invalid as child of a paragraph
 
303
                -->
 
304
                <xsl:choose>
 
305
                        <xsl:when test="draw:frame">
 
306
                                <xsl:element name="div">
 
307
                                        <xsl:call-template name="apply-styles-and-content">
 
308
                                                <xsl:with-param name="globalData" select="$globalData" />
 
309
                                                <xsl:with-param name="footnotePrefix" select="$footnotePrefix" />
 
310
                                        </xsl:call-template>
 
311
                                </xsl:element>
 
312
                        </xsl:when>
 
313
                        <xsl:otherwise>
 
314
                                <xsl:element name="p">
 
315
                                        <xsl:choose>
 
316
                                                <!-- in ODF borders of paragraphs will be merged by default. Merging means the adjactend paragraphs are building a unit,
 
317
                                                        where only the first and the last will have have a border to the surrounding (top / bottom border)
 
318
                                                                                                                <xsl:variable name="precedingParagraphStyle" select="preceding-sibling::*[1][name() = 'text:p']/@text:style-name"/>
 
319
                                                        <xsl:variable name="followingParagraphStyle" select="following-sibling::*[1][name() = 'text:p']/@text:style-name"/>
 
320
                                                        -->
 
321
                                                <xsl:when test="$globalData/all-styles/style[@style:name = current()/@text:style-name]/@mergedBorders">
 
322
                                                        <xsl:variable name="precedingParagraphStyle" select="preceding-sibling::*[1][name() = 'text:p']/@text:style-name"/>
 
323
                                                        <xsl:variable name="followingParagraphStyle" select="following-sibling::*[1][name() = 'text:p']/@text:style-name"/>
 
324
                                                        <xsl:choose>
 
325
                                                                <xsl:when test="$precedingParagraphStyle or $followingParagraphStyle">
 
326
                                                                        <xsl:variable name="isPrecedingBorderParagraph" select="$globalData/all-styles/style[@style:name = $precedingParagraphStyle]/@mergedBorders"/>
 
327
                                                                        <xsl:variable name="isFollowingBorderParagraph" select="$globalData/all-styles/style[@style:name = $followingParagraphStyle]/@mergedBorders"/>
 
328
                                                                        <xsl:choose>
 
329
                                                                                <xsl:when test="not($isPrecedingBorderParagraph) and $isFollowingBorderParagraph">
 
330
                                                                                        <xsl:attribute name="class">
 
331
                                                                                                <xsl:value-of select="concat(translate(@text:style-name, '.,;: %()[]/\+', '_____________'), '_borderStart')"/>
 
332
                                                                                        </xsl:attribute>
 
333
                                                                                        <xsl:apply-templates>
 
334
                                                                                                <xsl:with-param name="globalData" select="$globalData"/>
 
335
                                                                                        </xsl:apply-templates>
 
336
                                                                                </xsl:when>
 
337
                                                                                <xsl:when test="$isPrecedingBorderParagraph and not($isFollowingBorderParagraph)">
 
338
                                                                                        <xsl:attribute name="class">
 
339
                                                                                                <xsl:value-of select="concat(translate(@text:style-name, '.,;: %()[]/\+', '_____________'), '_borderEnd')"/>
 
340
                                                                                        </xsl:attribute>
 
341
                                                                                        <xsl:apply-templates>
 
342
                                                                                                <xsl:with-param name="globalData" select="$globalData"/>
 
343
                                                                                        </xsl:apply-templates>
 
344
                                                                                </xsl:when>
 
345
                                                                                <xsl:otherwise>
 
346
                                                                                        <xsl:attribute name="class">
 
347
                                                                                                <xsl:value-of select="translate(@text:style-name, '.,;: %()[]/\+', '_____________')"/>
 
348
                                                                                        </xsl:attribute>
 
349
                                                                                        <xsl:apply-templates>
 
350
                                                                                                <xsl:with-param name="globalData" select="$globalData"/>
 
351
                                                                                        </xsl:apply-templates>
 
352
                                                                                </xsl:otherwise>
 
353
                                                                        </xsl:choose>
 
354
                                                                </xsl:when>
 
355
                                                                <xsl:otherwise>
 
356
                                                                        <xsl:call-template name="write-paragraph">
 
357
                                                                                <xsl:with-param name="globalData" select="$globalData"/>
 
358
                                                                        </xsl:call-template>
 
359
                                                                </xsl:otherwise>
 
360
                                                        </xsl:choose>
 
361
                                                </xsl:when>
 
362
                                                <xsl:otherwise>
 
363
                                                        <xsl:call-template name="write-paragraph">
 
364
                                                                <xsl:with-param name="globalData" select="$globalData" />
 
365
                                                                <xsl:with-param name="footnotePrefix" select="$footnotePrefix" />
 
366
                                                        </xsl:call-template>
 
367
                                                </xsl:otherwise>
 
368
                                        </xsl:choose>
 
369
                                </xsl:element>
 
370
                        </xsl:otherwise>
 
371
                </xsl:choose>
 
372
        </xsl:template>
 
373
 
 
374
        <xsl:template name="write-paragraph">
 
375
                <xsl:param name="globalData"/>
 
376
                <!-- the footnote symbol is the prefix for a footnote in the footer -->
 
377
                <xsl:param name="footnotePrefix" />
 
378
 
 
379
                        <!-- empty paragraph tags does not provoke an carridge return,
 
380
                                therefore an non breakable space (&nbsp) have been inserted.-->
 
381
                <xsl:choose>
 
382
                        <xsl:when test="node()">
 
383
                                <xsl:call-template name="apply-styles-and-content">
 
384
                                        <xsl:with-param name="globalData" select="$globalData" />
 
385
                                        <xsl:with-param name="footnotePrefix" select="$footnotePrefix" />
 
386
                                </xsl:call-template>
 
387
                        </xsl:when>
 
388
                        <xsl:otherwise>
 
389
                                <xsl:call-template name="apply-styles-and-content">
 
390
                                        <xsl:with-param name="globalData" select="$globalData" />
 
391
                                        <xsl:with-param name="footnotePrefix" select="$footnotePrefix" />
 
392
                                </xsl:call-template>
 
393
                                <xsl:text>&#160;</xsl:text>
 
394
                        </xsl:otherwise>
 
395
                </xsl:choose>
 
396
        </xsl:template>
 
397
 
 
398
        <xsl:template match="draw:frame">
 
399
                <xsl:param name="globalData"/>
 
400
 
 
401
                <xsl:element name="div">
 
402
                        <xsl:if test="@svg:height | @svg:width">
 
403
                                <xsl:attribute name="style">
 
404
                                        <xsl:choose>
 
405
                                                <xsl:when test="not(@svg:width)">
 
406
                                                        <xsl:call-template name="svg:height"/>
 
407
                                                </xsl:when>
 
408
                                                <xsl:when test="not(@svg:height)">
 
409
                                                        <xsl:call-template name="svg:width"/>
 
410
                                                </xsl:when>
 
411
                                                <xsl:otherwise>
 
412
                                                        <xsl:call-template name="svg:height"/>
 
413
                                                        <xsl:call-template name="svg:width"/>
 
414
                                                </xsl:otherwise>
 
415
                                        </xsl:choose>
 
416
                                </xsl:attribute>
 
417
                        </xsl:if>
 
418
                        <xsl:apply-templates select="@draw:name">
 
419
                                <xsl:with-param name="globalData" select="$globalData"/>
 
420
                        </xsl:apply-templates>
 
421
 
 
422
                        <xsl:call-template name="apply-styles-and-content">
 
423
                                <xsl:with-param name="globalData" select="$globalData"/>
 
424
                        </xsl:call-template>
 
425
                </xsl:element>
 
426
        </xsl:template>
 
427
 
 
428
        <!-- ***************** -->
 
429
        <!-- *** Text Span *** -->
 
430
        <!-- ***************** -->
 
431
 
 
432
        <xsl:template match="text:span">
 
433
                <xsl:param name="globalData"/>
 
434
 
 
435
                <xsl:element name="span">
 
436
                        <xsl:call-template name="apply-styles-and-content">
 
437
                                <xsl:with-param name="globalData" select="$globalData"/>
 
438
                        </xsl:call-template>
 
439
                </xsl:element>
 
440
        </xsl:template>
 
441
 
 
442
 
 
443
 
 
444
        <!-- **************** -->
 
445
        <!-- *** Headings *** -->
 
446
        <!-- **************** -->
 
447
 
 
448
        <xsl:template match="text:h">
 
449
                <xsl:param name="globalData"/>
 
450
 
 
451
                <!-- no creation of empty headings (without text content)   -->
 
452
                <xsl:if test="text()">
 
453
                        <!-- The URL linking of an table-of-content is due to a bug (cp. bug id# 102311) not mapped as URL in the XML.
 
454
                                 Linking of the table-of-content can therefore only be archieved by a work-around in HTML -->
 
455
                        <xsl:call-template name="create-heading">
 
456
                                <xsl:with-param name="globalData" select="$globalData"/>
 
457
                        </xsl:call-template>
 
458
                </xsl:if>
 
459
        </xsl:template>
 
460
 
 
461
        <!-- default matching for header elements -->
 
462
        <xsl:template name="create-heading">
 
463
                <xsl:param name="globalData"/>
 
464
 
 
465
                <xsl:variable name="headingNumber1">
 
466
                        <xsl:choose>
 
467
                        <xsl:when test="@text:outline-level &lt; 6">
 
468
                                <xsl:value-of select="@text:outline-level"/>
 
469
                        </xsl:when>
 
470
                        <xsl:otherwise>6</xsl:otherwise>
 
471
                        </xsl:choose>
 
472
                </xsl:variable>
 
473
                <xsl:variable name="headertyp" select="concat('h', $headingNumber1)"/>
 
474
                <xsl:element name="{$headertyp}">
 
475
                        <!-- outline style 'text:min-label-width' is interpreted as a CSS 'margin-right' attribute
 
476
                        NOTE: Should be handled as CSS style in style header -->
 
477
                        <xsl:variable name="min-label" select="$globalData/office:styles/text:outline-style/text:outline-level-style[@text:level = current()/@text:outline-level]/*/@text:min-label-width"/>
 
478
                        <xsl:attribute name="class">
 
479
                                <xsl:value-of select="translate(@text:style-name, '.,;: %()[]/\+', '_____________')"/>
 
480
                        </xsl:attribute>
 
481
 
 
482
 
 
483
                        <!-- writing out a heading number if desired.-->
 
484
                        <!-- if a corresponding 'text:outline-style' exist or is not empty -->
 
485
                        <xsl:choose>
 
486
                                <xsl:when test="$globalData/office:styles/text:outline-style/text:outline-level-style[@text:level = current()/@text:outline-level]/@style:num-format != ''">
 
487
 
 
488
                                        <!-- Every heading element will get an unique anchor for its file, from its hiearchy level and name:
 
489
                                                 For example:  The heading title 'My favorite heading' might get <a name="1_2_2_My_favorite_heading" /> -->
 
490
                                        <!-- creating an anchor for referencing the heading (e.g. from content table) -->
 
491
                                        <xsl:variable name="headingNumber">
 
492
                                                <!-- write number prefix -->
 
493
                                                <xsl:value-of select="$globalData/office:styles/text:outline-style/text:outline-level-style[@text:level = current()/@text:outline-level]/@style:num-prefix"/>
 
494
                                                <xsl:call-template name="write-heading-number">
 
495
                                                        <xsl:with-param name="globalData" select="$globalData"/>
 
496
                                                </xsl:call-template>
 
497
                                                <!-- write number suffix -->
 
498
                                                <xsl:value-of select="$globalData/office:styles/text:outline-style/text:outline-level-style[@text:level = current()/@text:outline-level]/@style:num-suffix"/>
 
499
                                        </xsl:variable>
 
500
                                        <xsl:call-template name="create-heading-anchor">
 
501
                                                <xsl:with-param name="globalData" select="$globalData"/>
 
502
                                                <xsl:with-param name="headingNumber" select="$headingNumber"/>
 
503
                                        </xsl:call-template>
 
504
                                </xsl:when>
 
505
                                <xsl:otherwise>
 
506
                                        <xsl:call-template name="create-heading-anchor">
 
507
                                                <xsl:with-param name="globalData" select="$globalData"/>
 
508
                                        </xsl:call-template>
 
509
                                </xsl:otherwise>
 
510
                        </xsl:choose>
 
511
 
 
512
                        <xsl:apply-templates>
 
513
                                <xsl:with-param name="globalData" select="$globalData"/>
 
514
                        </xsl:apply-templates>
 
515
                </xsl:element>
 
516
 
 
517
        </xsl:template>
 
518
 
 
519
 
 
520
        <!-- creating an anchor for referencing the heading -->
 
521
        <xsl:template name="create-heading-anchor">
 
522
                <xsl:param name="globalData"/>
 
523
                <xsl:param name="headingNumber" />
 
524
 
 
525
                <xsl:variable name="title">
 
526
                        <xsl:apply-templates mode="concatenate"/>
 
527
                </xsl:variable>
 
528
                <xsl:element namespace="{$namespace}" name="a">
 
529
                        <xsl:attribute name="name">
 
530
                                <xsl:value-of select="translate(concat($headingNumber, '_', $title), '.,;: %()[]/\+', '_____________')"/>
 
531
                        </xsl:attribute>
 
532
 
 
533
                        <xsl:element name="span">
 
534
                                <!-- outline style 'text:min-label-width' is interpreted as a CSS 'margin-right' attribute
 
535
                                NOTE: Should be handled as CSS style in style header -->
 
536
                                <xsl:variable name="minLabelDistance" select="$globalData/office:styles/text:outline-style/text:outline-level-style[@text:level = current()/@text:outline-level]/*/@text:min-label-distance"/>
 
537
                                <xsl:variable name="minLabelWidth" select="$globalData/office:styles/text:outline-style/text:outline-level-style[@text:level = current()/@text:outline-level]/*/@text:min-label-width"/>
 
538
 
 
539
                                <xsl:if test="$minLabelDistance | $minLabelWidth">
 
540
                                        <xsl:attribute name="style">
 
541
                                                <xsl:if test="$minLabelDistance">
 
542
                                                                <xsl:text>margin-right:</xsl:text>
 
543
                                                                <xsl:call-template name="convert2cm">
 
544
                                                                        <xsl:with-param name="value" select="$minLabelDistance"/>
 
545
                                                                </xsl:call-template>
 
546
                                                                <xsl:text>cm;</xsl:text>
 
547
                                                </xsl:if>
 
548
                                                <xsl:if test="$minLabelWidth">
 
549
                                                                <xsl:text>min-width:</xsl:text>
 
550
                                                                <xsl:call-template name="convert2cm">
 
551
                                                                        <xsl:with-param name="value" select="$minLabelWidth"/>
 
552
                                                                </xsl:call-template>
 
553
                                                                <xsl:text>cm;</xsl:text>
 
554
                                                </xsl:if>
 
555
                                                </xsl:attribute>
 
556
                                </xsl:if>
 
557
                                <xsl:copy-of select="$headingNumber"/>
 
558
                        </xsl:element>
 
559
                </xsl:element>
 
560
        </xsl:template>
 
561
 
 
562
        <xsl:template name="write-heading-number">
 
563
                <xsl:param name="globalData"/>
 
564
 
 
565
                <!-- By default heading start with '1', the parameter 'textStartValue' will only be set, if the attribute @text:start-value exist -->
 
566
                <xsl:choose>
 
567
                        <xsl:when test="$globalData/office:styles/text:outline-style/text:outline-level-style[@text:level = current()/@text:outline-level]/@text:start-value">
 
568
                                <xsl:call-template name="calc-heading-number">
 
569
                                        <xsl:with-param name="globalData" select="$globalData"/>
 
570
                                        <xsl:with-param name="outlineLevel" select="@text:outline-level"/>
 
571
                                        <xsl:with-param name="textStartValue" select="$globalData/office:styles/text:outline-style/text:outline-level-style[@text:level = current()/@text:outline-level]/@text:start-value"/>
 
572
                                </xsl:call-template>
 
573
                        </xsl:when>
 
574
                        <xsl:otherwise>
 
575
                                <xsl:call-template name="calc-heading-number">
 
576
                                        <xsl:with-param name="globalData" select="$globalData"/>
 
577
                                        <xsl:with-param name="outlineLevel" select="@text:outline-level"/>
 
578
                                </xsl:call-template>
 
579
                        </xsl:otherwise>
 
580
                </xsl:choose>
 
581
        </xsl:template>
 
582
 
 
583
        <!--
 
584
        Find the correct heading no., which is the sum of 'text:start-value'
 
585
        and preceding siblings of 'text:h' with the same 'text:outline-level' (until a text:outline-level with lower value is found).
 
586
        If the 'text:start-value is not set the default value of '1' has to be taken.
 
587
        If a heading number is found (e.g. text:outline-level='3') all heading numbers
 
588
        for the higher levels have to be written out -->
 
589
        <xsl:template name="calc-heading-number">
 
590
                <xsl:param name="globalData"/>
 
591
                <xsl:param name="outlineLevel"/><!-- text level of the heading -->
 
592
                <xsl:param name="iOutlineLevel" select="1"/><!-- iterator, counts from 1 to the text level of the heading -->
 
593
                <xsl:param name="textStartValue" select="1"/><!-- text level to start with, default is '1' -->
 
594
 
 
595
                <xsl:choose>
 
596
                        <!-- iText levels counts up from '1' to outlineLevel
 
597
                                Which means writing a heading number from left to right -->
 
598
                        <xsl:when test="$iOutlineLevel &lt; $outlineLevel">
 
599
 
 
600
                        <!-- Write preceding heading numbers -->
 
601
                                <xsl:call-template name="writeNumber">
 
602
                                        <xsl:with-param name="numberDigit">
 
603
                                                <xsl:call-template name="calc-heading-digit">
 
604
                                                        <xsl:with-param name="value" select="0"/>
 
605
                                                        <xsl:with-param name="currentoutlineLevel" select="$iOutlineLevel"/>
 
606
                                                </xsl:call-template>
 
607
                                        </xsl:with-param>
 
608
                                        <xsl:with-param name="numberFormat" select="$globalData/office:styles/text:outline-style/text:outline-level-style[@text:level = ($outlineLevel)]/@style:num-format"/>
 
609
                                </xsl:call-template>
 
610
                                <xsl:choose>
 
611
                                        <xsl:when test="$globalData/office:styles/text:outline-style/text:outline-level-style[@text:level = ($iOutlineLevel + 1)]/@text:start-value">
 
612
                                                <xsl:call-template name="calc-heading-number">
 
613
                                                        <xsl:with-param name="globalData" select="$globalData"/>
 
614
                                                        <xsl:with-param name="outlineLevel" select="$outlineLevel"/>
 
615
                                                        <xsl:with-param name="iOutlineLevel" select="$iOutlineLevel + 1"/>
 
616
                                                        <xsl:with-param name="textStartValue" select="$globalData/office:styles/text:outline-style/text:outline-level-style[@text:level = ($iOutlineLevel + 1)]/@text:start-value"/>
 
617
                                                </xsl:call-template>
 
618
                                        </xsl:when>
 
619
                                        <xsl:otherwise>
 
620
                                                <xsl:call-template name="calc-heading-number">
 
621
                                                        <xsl:with-param name="globalData" select="$globalData"/>
 
622
                                                        <xsl:with-param name="outlineLevel" select="$outlineLevel"/>
 
623
                                                        <xsl:with-param name="iOutlineLevel" select="$iOutlineLevel + 1"/>
 
624
                                                </xsl:call-template>
 
625
                                        </xsl:otherwise>
 
626
                                </xsl:choose>
 
627
                        </xsl:when>
 
628
                        <xsl:otherwise>
 
629
                                <!-- Write preceding heading numbers -->
 
630
                                <xsl:call-template name="writeNumber">
 
631
                                        <xsl:with-param name="numberDigit">
 
632
                                                <xsl:call-template name="calc-heading-digit">
 
633
                                                        <xsl:with-param name="value" select="$textStartValue"/>
 
634
                                                        <xsl:with-param name="currentoutlineLevel" select="$iOutlineLevel"/>
 
635
                                                </xsl:call-template>
 
636
                                        </xsl:with-param><xsl:with-param name="numberFormat" select="$globalData/office:styles/text:outline-style/text:outline-level-style[@text:level = $outlineLevel]/@style:num-format"/>
 
637
                                        <xsl:with-param name="last" select="true()"/>
 
638
                                </xsl:call-template>
 
639
                        </xsl:otherwise>
 
640
                </xsl:choose>
 
641
        </xsl:template>
 
642
 
 
643
        <xsl:template name="writeNumber">
 
644
                <xsl:param name="numberDigit"/>
 
645
                <xsl:param name="numberFormat"/>
 
646
                <xsl:param name="last"/>
 
647
 
 
648
                <xsl:choose>
 
649
                        <xsl:when test="not($numberFormat)">
 
650
                                <xsl:number value="$numberDigit" format="1."/>
 
651
                        </xsl:when>
 
652
                        <xsl:otherwise>
 
653
                                <xsl:choose>
 
654
                                        <xsl:when test="$last">
 
655
                                                <xsl:number value="$numberDigit" format="{$numberFormat}"/>
 
656
                                        </xsl:when>
 
657
                                        <xsl:otherwise>
 
658
                                                <xsl:number value="$numberDigit" format="{$numberFormat}."/>
 
659
                                        </xsl:otherwise>
 
660
                                </xsl:choose>
 
661
                        </xsl:otherwise>
 
662
                </xsl:choose>
 
663
        </xsl:template>
 
664
 
 
665
        <xsl:template name="calc-heading-digit">
 
666
                <xsl:param name="value"/>
 
667
                <xsl:param name="currentoutlineLevel"/>
 
668
                <xsl:param name="i" select="1"/>
 
669
 
 
670
                <xsl:variable name="precedingoutlineLevel" select="preceding-sibling::text:h[$i]/@text:outline-level"/>
 
671
                <xsl:choose>
 
672
                        <xsl:when test="$currentoutlineLevel = $precedingoutlineLevel">
 
673
                                <xsl:call-template name="calc-heading-digit">
 
674
                                        <xsl:with-param name="value" select="$value + 1"/>
 
675
                                        <xsl:with-param name="currentoutlineLevel" select="$currentoutlineLevel"/>
 
676
                                        <xsl:with-param name="i" select="$i + 1"/>
 
677
                                </xsl:call-template>
 
678
                        </xsl:when>
 
679
                        <xsl:when test="$currentoutlineLevel &lt; $precedingoutlineLevel">
 
680
                                <xsl:call-template name="calc-heading-digit">
 
681
                                        <xsl:with-param name="value" select="$value"/>
 
682
                                        <xsl:with-param name="currentoutlineLevel" select="$currentoutlineLevel"/>
 
683
                                        <xsl:with-param name="i" select="$i + 1"/>
 
684
                                </xsl:call-template>
 
685
                        </xsl:when>
 
686
                        <xsl:otherwise>
 
687
                                <xsl:value-of select="$value"/>
 
688
                        </xsl:otherwise>
 
689
                </xsl:choose>
 
690
        </xsl:template>
 
691
 
 
692
        <!-- Neglect Annotations -->
 
693
        <xsl:template match="office:annotation" mode="concatenate"/>
 
694
 
 
695
        <!-- Match text:placeholder child nodes (e.g. text) -->
 
696
        <xsl:template match="text:placeholder">
 
697
                <xsl:param name="globalData"/>
 
698
 
 
699
                <xsl:call-template name="apply-styles-and-content">
 
700
                        <xsl:with-param name="globalData" select="$globalData"/>
 
701
                </xsl:call-template>
 
702
        </xsl:template>
 
703
 
 
704
        <!-- ************* -->
 
705
        <!-- *** Link  *** -->
 
706
        <!-- ************* -->
 
707
 
 
708
        <xsl:template match="text:a | draw:a">
 
709
                <xsl:param name="globalData"/>
 
710
 
 
711
                <xsl:call-template name="create-common-anchor-link">
 
712
                        <xsl:with-param name="globalData" select="$globalData"/>
 
713
                </xsl:call-template>
 
714
        </xsl:template>
 
715
 
 
716
 
 
717
        <xsl:template name="create-common-anchor-link">
 
718
                <xsl:param name="globalData"/>
 
719
 
 
720
                <xsl:element name="a">
 
721
                        <xsl:attribute name="href">
 
722
                                <xsl:call-template name="create-href">
 
723
                                        <xsl:with-param name="href" select="@xlink:href"/>
 
724
                                </xsl:call-template>
 
725
                        </xsl:attribute>
 
726
                        <xsl:call-template name="apply-styles-and-content">
 
727
                                <xsl:with-param name="globalData" select="$globalData"/>
 
728
                        </xsl:call-template>
 
729
                </xsl:element>
 
730
        </xsl:template>
 
731
 
 
732
 
 
733
 
 
734
        <!-- ******************* -->
 
735
        <!-- *** Image Link  *** -->
 
736
        <!-- ******************* -->
 
737
 
 
738
        <!-- currently suggesting that all draw:object-ole elements are images -->
 
739
        <xsl:template match="draw:image | draw:object-ole">
 
740
                <xsl:param name="globalData"/>
 
741
 
 
742
                <xsl:choose>
 
743
                        <xsl:when test="parent::text:p or parent::text:span or parent::text:h or parent::draw:a or parent::text:a or text:ruby-base">
 
744
                                <!-- XHTML does not allow the mapped elements to contain paragraphs -->
 
745
                                <xsl:call-template name="create-image-element">
 
746
                                        <xsl:with-param name="globalData" select="$globalData"/>
 
747
                                </xsl:call-template>
 
748
                        </xsl:when>
 
749
                        <xsl:otherwise>
 
750
                                <!-- images are embedded in a paragraph, but are in CSS not able to express a horizontal alignment for themself.
 
751
                                        A 'div' element taking over the image style would solve that problem, but is invalid as child of a paragraph -->
 
752
                                <xsl:element name="p">
 
753
                                        <xsl:apply-templates select="@draw:style-name">
 
754
                                                <xsl:with-param name="globalData" select="$globalData"/>
 
755
                                        </xsl:apply-templates>
 
756
 
 
757
                                        <xsl:call-template name="create-image-element">
 
758
                                                <xsl:with-param name="globalData" select="$globalData"/>
 
759
                                        </xsl:call-template>
 
760
                                </xsl:element>
 
761
                        </xsl:otherwise>
 
762
                </xsl:choose>
 
763
        </xsl:template>
 
764
 
 
765
        <xsl:template name="create-image-element">
 
766
                <xsl:param name="globalData"/>
 
767
 
 
768
                <xsl:element name="img">
 
769
                        <xsl:if test="../@svg:width">
 
770
                                <xsl:attribute name="width">
 
771
                                        <xsl:call-template name="convert2px">
 
772
                                                <xsl:with-param name="value" select="../@svg:width"/>
 
773
                                        </xsl:call-template>
 
774
                                </xsl:attribute>
 
775
                        </xsl:if>
 
776
                        <xsl:if test="../@svg:height">
 
777
                                <xsl:attribute name="height">
 
778
                                        <xsl:call-template name="convert2px">
 
779
                                                <xsl:with-param name="value" select="../@svg:height"/>
 
780
                                        </xsl:call-template>
 
781
                                </xsl:attribute>
 
782
                        </xsl:if>
 
783
                        <xsl:attribute name="alt">
 
784
                                <xsl:choose>
 
785
                                        <xsl:when test="../svg:desc">
 
786
                                                <xsl:value-of select="../svg:desc"/>
 
787
                                        </xsl:when>
 
788
                                        <xsl:otherwise>
 
789
                                                <xsl:message>
 
790
        Accessibility Warning:
 
791
                 No alternate text ('svg:desc' element) set for
 
792
                 image '<xsl:value-of select="@xlink:href"/>'!</xsl:message>
 
793
                                        </xsl:otherwise>
 
794
                                </xsl:choose>
 
795
                        </xsl:attribute>
 
796
 
 
797
                        <xsl:attribute name="src">
 
798
                                <xsl:call-template name="create-href">
 
799
                                        <xsl:with-param name="href" select="@xlink:href"/>
 
800
                                </xsl:call-template>
 
801
                        </xsl:attribute>
 
802
 
 
803
                        <!-- style interpretation only, as no subelements are allowed for img in XHTML -->
 
804
                        <xsl:apply-templates select="@draw:style-name">
 
805
                                <xsl:with-param name="globalData" select="$globalData"/>
 
806
                        </xsl:apply-templates>
 
807
                </xsl:element>
 
808
        </xsl:template>
 
809
 
 
810
        <!-- ************ -->
 
811
        <!-- *** list *** -->
 
812
        <!-- ************ -->
 
813
        <!--
 
814
                Due to the requirements below the ODF list functionality is not handled by CSS, but the list labels calculated and written by XSLT.
 
815
 
 
816
                REQUIREMENTS:
 
817
                =============
 
818
 
 
819
                A)
 
820
                One significant difference between XHTML and Office List elements is that a list without text nodes but only further list children
 
821
                would not show a list symbol in the Office, but in the browser from XHTML.
 
822
 
 
823
                B)
 
824
                Since OASIS Open Document XML (implemented in OOo2.0) only one parent type exists for list items
 
825
                the 'text:list' element. The XHTML element 'ol', 'ul' will be choosen upon the list style type.
 
826
 
 
827
                C)
 
828
                An Office list may be spread over the whole document. Linked by their style and text:continue-numbering='true'.
 
829
 
 
830
                D)
 
831
                An Office list can use characters or images as list label.
 
832
 
 
833
                E)
 
834
                An Office list can have a prefix and suffix around the list label.
 
835
 
 
836
                F)
 
837
                An Office list style may have the attribute consecutive numbering, which resolves in a list counting for all levels
 
838
 
 
839
                G)
 
840
                An Office list may (re)start on any arbitrary value by using @text:start-value on the text:list-item
 
841
 
 
842
                INDENDATION:
 
843
                ============
 
844
 
 
845
                The indent of a list label is not only calculated by using the text:space-before of the list level (listLevelStyle), but
 
846
                as well taking the left margin of the first paragraph (or heading) of the list into account as long it is not negative.
 
847
 
 
848
                |           MARGIN LEFT                 |        LABEL           |
 
849
 
 
850
                |   text:space-before (listlevelstyle)  | text:min-label-width   |
 
851
                | + fo:left-margin (firstParagraph)     |                        |
 
852
 
 
853
                Further details beyond text:list-list..
 
854
        -->
 
855
        <xsl:key name="listStyles" match="/*/office:styles/text:list-style | /*/office:automatic-styles/text:list-style  |
 
856
                                                                          /*/office:styles/style:graphic-properties/text:list-style | /*/office:automatic-styles/style:graphic-properties/text:list-style" use="@style:name"/>
 
857
 
 
858
        <!--
 
859
                A text list may only have text:list-item and text:list-header as children.
 
860
        -->
 
861
        <xsl:template match="text:list">
 
862
                <xsl:param name="globalData"/>
 
863
                <xsl:param name="isListNumberingReset"/>
 
864
                <xsl:param name="isNextLevelNumberingReset"/>
 
865
                <xsl:param name="listLevel" select="1"/>
 
866
                <xsl:param name="listRestart" select="false()"/>
 
867
                <xsl:param name="itemLabel" select="''"/>
 
868
<!--DS
 
869
                <xsl:param name="listStyle"/>
 
870
-->
 
871
                <xsl:param name="listStyleName" select="@text:style-name"/>
 
872
 
 
873
                <!-- To choose list type - get the list style, with the same 'text:style-name' and same 'text:level' -->
 
874
                <xsl:variable name="listStyle" select="key('listStyles', $listStyleName)"/>
 
875
                <xsl:variable name="listLevelStyle" select="$listStyle/*[@text:level = number($listLevel)]"/>
 
876
                <xsl:variable name="listIndent">
 
877
                        <xsl:call-template name="getListIndent">
 
878
                                <xsl:with-param name="globalData" select="$globalData"/>
 
879
                                <xsl:with-param name="listLevelStyle" select="$listLevelStyle"/>
 
880
                                <xsl:with-param name="firstPara" select="*[1]/*[name() = 'text:p' or name() = 'text:h'][1]"/>
 
881
                        </xsl:call-template>
 
882
                </xsl:variable>
 
883
                <xsl:variable name="isEmptyList" select="not(*[1]/*[name() = 'text:h' or name() = 'text:p'])"/>
 
884
                <xsl:variable name="listType">
 
885
                        <xsl:choose>
 
886
                                <!-- ordered list -->
 
887
                                <xsl:when test="name($listLevelStyle) = 'text:list-level-style-number'">
 
888
                                        <xsl:text>ol</xsl:text>
 
889
                                </xsl:when>
 
890
                                <!-- unordered list (bullet or image) -->
 
891
                                <xsl:otherwise>
 
892
                                        <xsl:text>ul</xsl:text>
 
893
                                </xsl:otherwise>
 
894
                        </xsl:choose>
 
895
                </xsl:variable>
 
896
                <xsl:element name="{$listType}">
 
897
                        <xsl:apply-templates select="*[1]" mode="listItemSibling">
 
898
                                <xsl:with-param name="globalData" select="$globalData"/>
 
899
                                <xsl:with-param name="isEmptyList" select="$isEmptyList"/>
 
900
                                <xsl:with-param name="isListNumberingReset" select="$isNextLevelNumberingReset"/>
 
901
                                <xsl:with-param name="isNextLevelNumberingReset">
 
902
                                        <xsl:choose>
 
903
                                                <xsl:when test="$isListNumberingReset">
 
904
                                                        <xsl:value-of select="true()"/>
 
905
                                                </xsl:when>
 
906
                                                <xsl:otherwise>
 
907
                                                        <!-- A list is empty if a text:list does not have a text:list-header or text:list-item (wildcard as only those can exist beyond a text:list), which contains a text:h or text:p -->
 
908
                                                        <xsl:value-of select="not($isEmptyList)"/>
 
909
                                                </xsl:otherwise>
 
910
                                        </xsl:choose>
 
911
                                </xsl:with-param>
 
912
                                <xsl:with-param name="itemLabel" select="$itemLabel"/>
 
913
                                <xsl:with-param name="listIndent" select="$listIndent"/>
 
914
                                <xsl:with-param name="listLevel" select="$listLevel"/>
 
915
                                <xsl:with-param name="listLevelStyle" select="$listLevelStyle"/>
 
916
                                <xsl:with-param name="listRestart">
 
917
                                          <xsl:choose>
 
918
                                                <xsl:when test="$listRestart">
 
919
                                                        <xsl:value-of select="$listRestart"/>
 
920
                                                </xsl:when>
 
921
                                                <xsl:otherwise>
 
922
                                                        <!-- descdendants restart their list numbering, when an ancestor is not empty -->
 
923
                                                        <xsl:value-of select="not($isEmptyList)"/>
 
924
                                                </xsl:otherwise>
 
925
                                        </xsl:choose>
 
926
                                </xsl:with-param>
 
927
                                <xsl:with-param name="listStyle" select="$listStyle"/>
 
928
                                <xsl:with-param name="listStyleName" select="$listStyleName"/>
 
929
                                <xsl:with-param name="minLabelDist">
 
930
                                        <xsl:choose>
 
931
                                                <xsl:when test="$listLevelStyle/*/@text:min-label-distance">
 
932
                                                        <xsl:call-template name="convert2cm">
 
933
                                                                <xsl:with-param name="value" select="$listLevelStyle/*/@text:min-label-distance"/>
 
934
                                                        </xsl:call-template>
 
935
                                                </xsl:when>
 
936
                                                <xsl:otherwise>0</xsl:otherwise>
 
937
                                        </xsl:choose>
 
938
                                </xsl:with-param>
 
939
                                <xsl:with-param name="minLabelWidth">
 
940
                                        <xsl:choose>
 
941
                                                <xsl:when test="$listLevelStyle/*/@text:min-label-width">
 
942
                                                        <xsl:call-template name="convert2cm">
 
943
                                                                <xsl:with-param name="value" select="$listLevelStyle/*/@text:min-label-width"/>
 
944
                                                        </xsl:call-template>
 
945
                                                </xsl:when>
 
946
                                                <xsl:otherwise>0</xsl:otherwise>
 
947
                                        </xsl:choose>
 
948
                                </xsl:with-param>
 
949
                        </xsl:apply-templates>
 
950
                </xsl:element>
 
951
        </xsl:template>
 
952
 
 
953
        <!-- See comment before text:list template -->
 
954
        <xsl:template name="getListIndent">
 
955
                <xsl:param name="globalData"/>
 
956
                <xsl:param name="listLevelStyle"/>
 
957
                <!-- The first paragraph of the list item (heading is special paragraph in ODF) -->
 
958
                <xsl:param name="firstPara" />
 
959
 
 
960
                <!-- Styles of first paragraph in list item, including ancestor styles (inheritance) -->
 
961
                <xsl:variable name="firstParaStyles" select="$globalData/all-styles/style[@style:name = $firstPara/@text:style-name]/final-properties"/>
 
962
 
 
963
                <!-- Only the left margin of the first paragraph of a list item will be added to the margin of the complete list (all levels)-->
 
964
                <xsl:variable name="firstParaLeftMargin">
 
965
                        <xsl:choose>
 
966
                                <xsl:when test="contains($firstParaStyles, 'margin-left:')">
 
967
                                        <xsl:call-template name="convert2cm">
 
968
                                                <xsl:with-param name="value" select="normalize-space(substring-before(substring-after($firstParaStyles, 'margin-left:'), ';'))"/>
 
969
                                        </xsl:call-template>
 
970
                                </xsl:when>
 
971
                                <xsl:otherwise>0</xsl:otherwise>
 
972
                        </xsl:choose>
 
973
                </xsl:variable>
 
974
                <xsl:variable name="spaceBefore">
 
975
                        <xsl:choose>
 
976
                                <xsl:when test="$listLevelStyle/*/@text:space-before">
 
977
                                        <xsl:call-template name="convert2cm">
 
978
                                                <xsl:with-param name="value" select="$listLevelStyle/*/@text:space-before"/>
 
979
                                        </xsl:call-template>
 
980
                                </xsl:when>
 
981
                                <xsl:otherwise>0</xsl:otherwise>
 
982
                        </xsl:choose>
 
983
                </xsl:variable>
 
984
                <!-- Only if the left-margin of the first paragraph is positive the sum
 
985
                text:space-before and fo:left-margin is taken as list indent -->
 
986
                <xsl:choose>
 
987
                        <xsl:when test="$firstParaLeftMargin &gt; 0">
 
988
                                <xsl:value-of select="$firstParaLeftMargin + $spaceBefore"/>
 
989
                        </xsl:when>
 
990
                        <xsl:otherwise>
 
991
                                <xsl:value-of select="$spaceBefore"/>
 
992
                        </xsl:otherwise>
 
993
                </xsl:choose>
 
994
        </xsl:template>
 
995
 
 
996
        <!-- ****************** -->
 
997
        <!-- *** list item  *** -->
 
998
        <!-- ****************** -->
 
999
<!--
 
1000
        Left margin of the complete list:
 
1001
        The space between left page and the list symbol (left-margin) is in the Office implemented by
 
1002
        the sum of three values:
 
1003
                1) 'text:space-before', which is part of the 'text:list-style' element.
 
1004
                2) 'margin:left' from the style of the first child (e.g. paragraph).
 
1005
                3) 'fo:text-indent' the indent of the first line of some child (e.g. paragraph) (applied by CSS class style)
 
1006
 
 
1007
        Possible list children:
 
1008
        <!ELEMENT text:list-item (text:p|text:h|text:list|text:list)+>
 
1009
 
 
1010
        In the Office the list label before the text depends on two attributes:
 
1011
                - 'text:min-label-width': the distance between list label and all text of the list item.
 
1012
                - 'text:min-label-distance': the distance between list label and text of the first line,
 
1013
                        only used, when text does not fit in text:min-label-width (ignored)
 
1014
 
 
1015
-->
 
1016
        <xsl:template match="text:list-item | text:list-header" mode="listItemSibling">
 
1017
                <xsl:param name="globalData"/>
 
1018
                <xsl:param name="firstitemLabelWidth"/>
 
1019
                <xsl:param name="isEmptyList" select="not(*[name() = 'text:h' or name() = 'text:p'])"/>
 
1020
                <xsl:param name="isListNumberingReset"/>
 
1021
                <xsl:param name="isNextLevelNumberingReset"/>
 
1022
                <xsl:param name="itemNumber"/>
 
1023
                <xsl:param name="itemLabel"/>
 
1024
                <xsl:param name="listLevel"/>
 
1025
                <xsl:param name="listLevelStyle"/>
 
1026
                <xsl:param name="listRestart"/>
 
1027
                <xsl:param name="listStyle"/>
 
1028
                <xsl:param name="listStyleName"/>
 
1029
                <xsl:param name="minLabelDist"/>
 
1030
                <xsl:param name="minLabelWidth"/>
 
1031
                <xsl:param name="listIndent" />
 
1032
 
 
1033
 
 
1034
                <xsl:variable name="listIndentNew">
 
1035
                        <xsl:choose>
 
1036
                                <xsl:when test="$listIndent">
 
1037
                                        <xsl:value-of select="$listIndent"/>
 
1038
                                </xsl:when>
 
1039
                                <xsl:otherwise>
 
1040
                                        <xsl:call-template name="getListIndent">
 
1041
                                                <xsl:with-param name="globalData" select="$globalData"/>
 
1042
                                                <xsl:with-param name="listLevelStyle" select="$listLevelStyle"/>
 
1043
                                                <xsl:with-param name="firstPara" select="*[name() = 'text:p' or name() = 'text:h'][1]" />
 
1044
                                        </xsl:call-template>
 
1045
                                </xsl:otherwise>
 
1046
                        </xsl:choose>
 
1047
                </xsl:variable>
 
1048
                <xsl:variable name="itemNumberNew">
 
1049
                        <xsl:if test="$listStyle/text:list-level-style-number">
 
1050
                                <xsl:choose>
 
1051
                                        <xsl:when test="$isEmptyList">
 
1052
                                                <!--  An empty list item (no text:h/text:p as child), will not count as item and does not increment the count.  -->
 
1053
                                                <xsl:variable name="tempItemNumber">
 
1054
                                                        <xsl:choose>
 
1055
                                                                <!-- siblings will be incremented by one -->
 
1056
                                                                <xsl:when test="$itemNumber">
 
1057
                                                                        <xsl:value-of select="$itemNumber + 1"/>
 
1058
                                                                </xsl:when>
 
1059
                                                                <!-- if a higher list level had content the numbering starts with 1 -->
 
1060
                                                                <xsl:when test="$isListNumberingReset and $listLevel &gt; 1">
 
1061
                                                                        <xsl:value-of select="1"/>
 
1062
                                                                </xsl:when>
 
1063
                                                                <xsl:otherwise>
 
1064
                                                                        <xsl:call-template name="getItemNumber">
 
1065
                                                                                <xsl:with-param name="isEmptyList" select="$isEmptyList"/>
 
1066
                                                                                <xsl:with-param name="isListNumberingReset" select="$isListNumberingReset"/>
 
1067
                                                                                <xsl:with-param name="itemNumber" select="$itemNumber"/>
 
1068
                                                                                <xsl:with-param name="listStyleName" select="$listStyleName"/>
 
1069
                                                                                <xsl:with-param name="listLevel" select="$listLevel"/>
 
1070
                                                                                <xsl:with-param name="listLevelStyle" select="$listLevelStyle"/>
 
1071
                                                                                <xsl:with-param name="listStyle" select="$listStyle"/>
 
1072
                                                                        </xsl:call-template>
 
1073
                                                                </xsl:otherwise>
 
1074
                                                        </xsl:choose>
 
1075
                                                </xsl:variable>
 
1076
                                                <xsl:choose>
 
1077
                                                        <!-- in case the empty list-item is the first list-item in document -->
 
1078
                                                        <xsl:when test="$tempItemNumber = 1">
 
1079
                                                                <xsl:value-of select="1"/>
 
1080
                                                        </xsl:when>
 
1081
                                                        <xsl:otherwise>
 
1082
                                                                <xsl:value-of select="$tempItemNumber - 1"/>
 
1083
                                                        </xsl:otherwise>
 
1084
                                                </xsl:choose>
 
1085
                                        </xsl:when>
 
1086
                                        <xsl:otherwise>
 
1087
                                                <xsl:choose>
 
1088
                                                        <xsl:when test="@text:start-value">
 
1089
                                                                <xsl:value-of select="@text:start-value"/>
 
1090
                                                        </xsl:when>
 
1091
                                                        <xsl:when test="$listLevelStyle/@text:start-value">
 
1092
                                                                <xsl:value-of select="$listLevelStyle/@text:start-value"/>
 
1093
                                                        </xsl:when>
 
1094
                                                        <!-- siblings will be incremented by one -->
 
1095
                                                        <xsl:when test="$itemNumber">
 
1096
                                                                <xsl:value-of select="$itemNumber + 1"/>
 
1097
                                                        </xsl:when>
 
1098
                                                        <!-- if a higher list level had content the numbering starts with 1 -->
 
1099
                                                        <xsl:when test="$isListNumberingReset and $listLevel &gt; 1">
 
1100
                                                                <xsl:value-of select="1"/>
 
1101
                                                        </xsl:when>
 
1102
                                                        <xsl:otherwise>
 
1103
                                                                <xsl:call-template name="getItemNumber">
 
1104
                                                                        <xsl:with-param name="isEmptyList" select="$isEmptyList"/>
 
1105
                                                                        <xsl:with-param name="isListNumberingReset" select="$isListNumberingReset"/>
 
1106
                                                                        <xsl:with-param name="itemNumber" select="$itemNumber"/>
 
1107
                                                                        <xsl:with-param name="listStyleName" select="$listStyleName"/>
 
1108
                                                                        <xsl:with-param name="listLevel" select="$listLevel"/>
 
1109
                                                                        <xsl:with-param name="listLevelStyle" select="$listLevelStyle"/>
 
1110
                                                                        <xsl:with-param name="listStyle" select="$listStyle"/>
 
1111
                                                                </xsl:call-template>
 
1112
                                                        </xsl:otherwise>
 
1113
                                                </xsl:choose>
 
1114
                                        </xsl:otherwise>
 
1115
                                </xsl:choose>
 
1116
                        </xsl:if>
 
1117
                </xsl:variable>
 
1118
                <xsl:variable name="itemLabelNew">
 
1119
                   <xsl:if test="$listStyle/text:list-level-style-number">
 
1120
                                <!--
 
1121
                                        A numbered label (e.g. 2.C.III) is created for every text:list-item/header.
 
1122
                                        Above list levels are listed in the label, if the list-style requires this. Levels are separated by a '.'
 
1123
                                        Formatation is dependent for every list level depth.
 
1124
                                        The label is passed from anchestor text:list-item/header and if requrired truncated.
 
1125
                                        The prefix/suffix (as well list level dependent) comes before and after the complete label (after truncation)
 
1126
                                -->
 
1127
                                <!-- Numbered label will be generated  -->
 
1128
                                <xsl:call-template name="createItemLabel">
 
1129
                                        <xsl:with-param name="itemNumber" select="$itemNumberNew"/>
 
1130
                                        <xsl:with-param name="itemLabel" select="$itemLabel"/>
 
1131
                                        <xsl:with-param name="listLevelsToDisplay">
 
1132
                                                <xsl:variable name="display" select="$listLevelStyle/@text:display-levels"/>
 
1133
                                                <xsl:choose>
 
1134
                                                        <xsl:when test="$display">
 
1135
                                                                <xsl:value-of select="$display"/>
 
1136
                                                        </xsl:when>
 
1137
                                                        <xsl:otherwise>1</xsl:otherwise>
 
1138
                                                </xsl:choose>
 
1139
                                        </xsl:with-param>
 
1140
                                        <xsl:with-param name="listLevel" select="$listLevel"/>
 
1141
                                        <xsl:with-param name="listStyleName" select="$listStyleName"/>
 
1142
                                        <xsl:with-param name="listLevelStyle" select="$listLevelStyle"/>
 
1143
                                        <xsl:with-param name="listStyle" select="$listStyle"/>
 
1144
                                </xsl:call-template>
 
1145
                        </xsl:if>
 
1146
                </xsl:variable>
 
1147
                <xsl:element name="li">
 
1148
                        <xsl:choose>
 
1149
                                <xsl:when test="$isEmptyList">
 
1150
                                        <xsl:apply-templates>
 
1151
                                                <xsl:with-param name="globalData" select="$globalData"/>
 
1152
                                                <xsl:with-param name="itemLabel" select="$itemLabelNew"/>
 
1153
                                                <xsl:with-param name="listLevel" select="$listLevel + 1"/>
 
1154
                                                <xsl:with-param name="listStyleName" select="$listStyleName"/>
 
1155
                                        </xsl:apply-templates>
 
1156
                                </xsl:when>
 
1157
                                <xsl:otherwise>
 
1158
                                        <xsl:variable name="listLabelElement">
 
1159
                                <!-- Numbering is being done by this transformation creating a HTML span representing the number label
 
1160
                                         The html:span represents the list item/header label (e.g. 1.A.III)
 
1161
                                         As the html:span is usually a inline element is formated by CSS as block element to use width upon it,
 
1162
                                         to disable the caridge return float:left is used and later neglected -->
 
1163
                                        <span class="{$listLevelStyle/@text:style-name}"  style="display:block;float:left;min-width:{$minLabelWidth}cm;">
 
1164
                                                <xsl:choose>
 
1165
                                                        <xsl:when test="$listStyle/text:list-level-style-bullet">
 
1166
                                                                <xsl:value-of select="$listLevelStyle/@style:num-prefix"/>
 
1167
                                                                <xsl:value-of select="$listStyle/text:list-level-style-bullet/@text:bullet-char"/>
 
1168
                                                                <xsl:value-of select="$listLevelStyle/@style:num-suffix"/>
 
1169
                                                        </xsl:when>
 
1170
                                                        <xsl:when test="$listStyle/text:list-level-style-number">
 
1171
                                                                <xsl:value-of select="$listLevelStyle/@style:num-prefix"/>
 
1172
                                                                <xsl:value-of select="$itemLabelNew"/>
 
1173
                                                                <xsl:value-of select="$listLevelStyle/@style:num-suffix"/>
 
1174
                                                        </xsl:when>
 
1175
                                                        <xsl:otherwise>
 
1176
                                                                <!-- Listing with image as bullets, taken from the list style's href -->
 
1177
                                                                <xsl:value-of select="$listStyle/text:list-level-style-image/@xlink:href"/>
 
1178
                                                        </xsl:otherwise>
 
1179
                                                </xsl:choose>
 
1180
                                        </span>
 
1181
                                        </xsl:variable>
 
1182
                                        <!-- Maybe the following children: text:h, text:p, list:text, text:soft-page-break -->
 
1183
                                        <xsl:apply-templates mode="first-list-child-margin-adaption" select="*[1]">
 
1184
                                                <xsl:with-param name="globalData" select="$globalData"/>
 
1185
                                                <xsl:with-param name="isEmptyList" select="$isEmptyList"/>
 
1186
                                                <xsl:with-param name="isNextLevelNumberingReset" select="$isNextLevelNumberingReset"/>
 
1187
                                                <!-- The new created label is given to the children -->
 
1188
                                                <xsl:with-param name="itemLabel" select="$itemLabelNew"/>
 
1189
                                                <xsl:with-param name="listLabelElement" select="$listLabelElement"/>
 
1190
                                                <xsl:with-param name="listLevel" select="$listLevel + 1"/>
 
1191
                                                <xsl:with-param name="listLevelStyle" select="$listLevelStyle"/>
 
1192
                                                <xsl:with-param name="listRestart" select="$listRestart"/>
 
1193
                                                <xsl:with-param name="listStyle" select="$listStyle"/>
 
1194
                                                <xsl:with-param name="listStyleName" select="$listStyleName"/>
 
1195
                                                <xsl:with-param name="listIndent" select="$listIndentNew"/>
 
1196
                                                <xsl:with-param name="minLabelWidth" select="$minLabelWidth"/>
 
1197
                                        </xsl:apply-templates>
 
1198
                                </xsl:otherwise>
 
1199
                        </xsl:choose>
 
1200
                </xsl:element>
 
1201
                <xsl:apply-templates select="following-sibling::*[1]" mode="listItemSibling">
 
1202
                        <xsl:with-param name="globalData" select="$globalData"/>
 
1203
                        <xsl:with-param name="isListNumberingReset" select="$isListNumberingReset"/>
 
1204
                        <xsl:with-param name="isNextLevelNumberingReset" select="$isNextLevelNumberingReset"/>
 
1205
                        <xsl:with-param name="itemNumber" select="$itemNumberNew"/>
 
1206
                        <xsl:with-param name="listIndent">
 
1207
                                <xsl:choose>
 
1208
                                        <xsl:when test="not($isEmptyList)"><xsl:value-of select="$listIndentNew"/></xsl:when>
 
1209
                                </xsl:choose>
 
1210
                        </xsl:with-param>
 
1211
                        <!-- Receives the same parent label -->
 
1212
                        <xsl:with-param name="itemLabel" select="$itemLabel"/>
 
1213
                        <xsl:with-param name="listLevel" select="$listLevel"/>
 
1214
                        <xsl:with-param name="listLevelStyle" select="$listLevelStyle"/>
 
1215
                        <xsl:with-param name="listStyle" select="$listStyle"/>
 
1216
                        <xsl:with-param name="listStyleName" select="$listStyleName"/>
 
1217
                        <xsl:with-param name="minLabelDist" select="$minLabelDist"/>
 
1218
                        <xsl:with-param name="minLabelWidth" select="$minLabelWidth"/>
 
1219
                </xsl:apply-templates>
 
1220
        </xsl:template>
 
1221
 
 
1222
 
 
1223
        <!-- Each key element holds the set of all text:list-item/text:list-header of a certain level and a certain style -->
 
1224
        <xsl:key name="getListItemsByLevelAndStyle" use="concat(count(ancestor::text:list), ancestor::text:list/@text:style-name)" match="text:list-item | text:list-header"/>
 
1225
        <!-- Each key element holds the set of all text:list-item/text:list-header of a certain style -->
 
1226
        <xsl:key name="getListItemsByStyle" use="ancestor::text:list/@text:style-name" match="text:list-item | text:list-header"/>
 
1227
 
 
1228
 
 
1229
        <!-- The Numbering start value (or offset from regular counteing) is used at the first item of offset,
 
1230
        but have to be reused on following item/headers with no text:start-value -->
 
1231
        <xsl:template name="getItemNumber">
 
1232
                <xsl:param name="listLevel"/>
 
1233
                <xsl:param name="listLevelStyle"/>
 
1234
                <xsl:param name="listStyleName"/>
 
1235
                <xsl:param name="listStyle"/>
 
1236
 
 
1237
                <xsl:call-template name="countListItemTillStartValue">
 
1238
                        <xsl:with-param name="listLevel" select="$listLevel"/>
 
1239
                        <xsl:with-param name="listLevelStyle" select="$listLevelStyle"/>
 
1240
                        <xsl:with-param name="listStyleName" select="$listStyleName"/>
 
1241
                        <xsl:with-param name="listStyle" select="$listStyle"/>
 
1242
                        <xsl:with-param name="precedingListItemsOfSameLevelAndStyle" select="preceding::text:list-item[generate-id(key('getListItemsByLevelAndStyle', concat($listLevel, $listStyleName))) =
 
1243
                                                                                                                                                                                           generate-id(key('getListItemsByLevelAndStyle', concat(count(ancestor::text:list), ancestor::text:list/@text:style-name)))]"/>
 
1244
                        <xsl:with-param name="precedingListItemsOfSameStyle" select="preceding::text:list-item[generate-id(key('getListItemsByStyle', $listStyleName)) =
 
1245
                                                                                                                                                                                           generate-id(key('getListItemsByStyle', ancestor::text:list/@text:style-name))]"/>
 
1246
                </xsl:call-template>
 
1247
        </xsl:template>
 
1248
 
 
1249
        <!-- When there is a text:start-value the last have to be found and added to the number -->
 
1250
        <xsl:template name="countListItemTillStartValue">
 
1251
                <xsl:param name="IteratorSameLevelAndStyle" select="1"/>
 
1252
                <xsl:param name="IteratorSameStyle" select="1"/>
 
1253
                <xsl:param name="itemNumber" select="1"/>
 
1254
                <xsl:param name="listLevel"/>
 
1255
                <xsl:param name="listLevelStyle"/>
 
1256
                <xsl:param name="listStyle"/>
 
1257
                <xsl:param name="listStyleName"/>
 
1258
                <xsl:param name="precedingListItemsOfSameLevelAndStyle" />
 
1259
                <xsl:param name="precedingListItemsOfSameLevelAndStyleCount" select="count($precedingListItemsOfSameLevelAndStyle)"/>
 
1260
                <xsl:param name="precedingListItemsOfSameStyle" />
 
1261
                <xsl:param name="precedingListItemsOfSameStyleCount" select="count($precedingListItemsOfSameStyle)"/>
 
1262
                <!-- E.g.: If a list level 2 number is searched, a level 3 with content found with only a level 1 parent with content,
 
1263
                        the level 3 gets a 'pseudoLevel' -->
 
1264
                <xsl:param name="pseudoLevel" select="0" />
 
1265
 
 
1266
                <!-- set the next of preceding list items. Starting from the current to the next previous text:list-item -->
 
1267
                <xsl:variable name="precedingListItemOfSameLevelAndStyle" select="$precedingListItemsOfSameLevelAndStyle[$precedingListItemsOfSameLevelAndStyleCount - $IteratorSameLevelAndStyle + 1]"/>
 
1268
                <xsl:variable name="precedingListItemOfSameStyle" select="$precedingListItemsOfSameStyle[$precedingListItemsOfSameStyleCount - $IteratorSameStyle + 1]"/>
 
1269
                <xsl:choose>
 
1270
                        <xsl:when test="($precedingListItemOfSameStyle and $precedingListItemOfSameLevelAndStyle) or ($precedingListItemOfSameStyle and $listStyle/@text:consecutive-numbering)">
 
1271
                                <xsl:for-each select="$precedingListItemOfSameStyle">
 
1272
                                        <xsl:choose>
 
1273
                                                <!-- if it is a higher list level element  -->
 
1274
                                                <xsl:when test="$listStyle/@text:consecutive-numbering">
 
1275
 
 
1276
                                                        <xsl:call-template name="countListItem">
 
1277
                                                                <xsl:with-param name="IteratorSameLevelAndStyle" select="$IteratorSameLevelAndStyle" />
 
1278
                                                                <xsl:with-param name="IteratorSameStyle" select="$IteratorSameStyle"/>
 
1279
                                                                <xsl:with-param name="itemNumber" select="$itemNumber"/>
 
1280
                                                                <xsl:with-param name="listLevel" select="$listLevel"/>
 
1281
                                                                <xsl:with-param name="listLevelStyle" select="$listLevelStyle"/>
 
1282
                                                                <xsl:with-param name="listStyle" select="$listStyle"/>
 
1283
                                                                <xsl:with-param name="precedingListItemsOfSameLevelAndStyle" select="$precedingListItemsOfSameLevelAndStyle"/>
 
1284
                                                                <xsl:with-param name="precedingListItemsOfSameLevelAndStyleCount" select="$precedingListItemsOfSameLevelAndStyleCount"/>
 
1285
                                                                <xsl:with-param name="precedingListItemsOfSameStyle" select="$precedingListItemsOfSameStyle"/>
 
1286
                                                                <xsl:with-param name="precedingListItemsOfSameStyleCount" select="$precedingListItemsOfSameStyleCount"/>
 
1287
                                                                <xsl:with-param name="pseudoLevel" select="$pseudoLevel" />
 
1288
                                                        </xsl:call-template>
 
1289
                                                </xsl:when>
 
1290
                                                <xsl:otherwise>
 
1291
                                                        <!-- NOT CONSECUTIVE NUMBERING -->
 
1292
                                                        <xsl:variable name="currentListLevel" select="count(ancestor::text:list)"/>
 
1293
                                                        <xsl:choose>
 
1294
                                                                <!-- IF IT IS A HIGHER LIST LEVEL ELEMENT -->
 
1295
                                                                <xsl:when test="$currentListLevel &lt; $listLevel">
 
1296
                                                                        <xsl:choose>
 
1297
                                                                                <!-- if it has content the counting is ended -->
 
1298
                                                                                <xsl:when test="*[name() = 'text:h' or name() = 'text:p']">
 
1299
                                                                                        <!-- 2DO: Perhaps the children still have to be processed -->
 
1300
                                                                                        <xsl:value-of select="$itemNumber + $pseudoLevel"/>
 
1301
                                                                                </xsl:when>
 
1302
                                                                                <xsl:otherwise>
 
1303
                                                                                <!-- if it is empty the counting continues -->
 
1304
                                                                                        <xsl:call-template name="countListItemTillStartValue">
 
1305
                                                                                                <xsl:with-param name="IteratorSameLevelAndStyle" select="$IteratorSameLevelAndStyle" />
 
1306
                                                                                                <xsl:with-param name="IteratorSameStyle" select="$IteratorSameStyle + 1"/>
 
1307
                                                                                                <xsl:with-param name="itemNumber" select="$itemNumber"/>
 
1308
                                                                                                <xsl:with-param name="listLevel" select="$listLevel"/>
 
1309
                                                                                                <xsl:with-param name="listLevelStyle" select="$listLevelStyle"/>
 
1310
                                                                                                <xsl:with-param name="listStyle" select="$listStyle"/>
 
1311
                                                                                                <xsl:with-param name="precedingListItemsOfSameLevelAndStyle" select="$precedingListItemsOfSameLevelAndStyle"/>
 
1312
                                                                                                <xsl:with-param name="precedingListItemsOfSameLevelAndStyleCount" select="$precedingListItemsOfSameLevelAndStyleCount"/>
 
1313
                                                                                                <xsl:with-param name="precedingListItemsOfSameStyle" select="$precedingListItemsOfSameStyle"/>
 
1314
                                                                                                <xsl:with-param name="precedingListItemsOfSameStyleCount" select="$precedingListItemsOfSameStyleCount"/>
 
1315
                                                                                                <xsl:with-param name="pseudoLevel" select="$pseudoLevel" />
 
1316
                                                                                        </xsl:call-template>
 
1317
                                                                                </xsl:otherwise>
 
1318
                                                                        </xsl:choose>
 
1319
                                                                </xsl:when>
 
1320
                                                                <!-- IF IT IS A LIST LEVEL ELEMENT OF THE COUNTING LEVEL -->
 
1321
                                                                <xsl:when test="$currentListLevel = $listLevel">
 
1322
                                                                        <xsl:call-template name="countListItem">
 
1323
                                                                                <xsl:with-param name="IteratorSameLevelAndStyle" select="$IteratorSameLevelAndStyle" />
 
1324
                                                                                <xsl:with-param name="IteratorSameStyle" select="$IteratorSameStyle"/>
 
1325
                                                                                <xsl:with-param name="itemNumber" select="$itemNumber"/>
 
1326
                                                                                <xsl:with-param name="listLevel" select="$listLevel"/>
 
1327
                                                                                <xsl:with-param name="listLevelStyle" select="$listLevelStyle"/>
 
1328
                                                                                <xsl:with-param name="listStyle" select="$listStyle"/>
 
1329
                                                                                <xsl:with-param name="precedingListItemsOfSameLevelAndStyle" select="$precedingListItemsOfSameLevelAndStyle"/>
 
1330
                                                                                <xsl:with-param name="precedingListItemsOfSameLevelAndStyleCount" select="$precedingListItemsOfSameLevelAndStyleCount"/>
 
1331
                                                                                <xsl:with-param name="precedingListItemsOfSameStyle" select="$precedingListItemsOfSameStyle"/>
 
1332
                                                                                <xsl:with-param name="precedingListItemsOfSameStyleCount" select="$precedingListItemsOfSameStyleCount"/>
 
1333
                                                                                <xsl:with-param name="pseudoLevel" select="$pseudoLevel" />
 
1334
                                                                        </xsl:call-template>
 
1335
                                                                </xsl:when>
 
1336
                                                                <xsl:otherwise>
 
1337
                                                                        <!-- list item below the current level does not count -->
 
1338
                                                                        <xsl:call-template name="countListItemTillStartValue">
 
1339
                                                                                <xsl:with-param name="IteratorSameLevelAndStyle" select="$IteratorSameLevelAndStyle" />
 
1340
                                                                                <xsl:with-param name="IteratorSameStyle" select="$IteratorSameStyle + 1"/>
 
1341
                                                                                <xsl:with-param name="itemNumber" select="$itemNumber"/>
 
1342
                                                                                <xsl:with-param name="listLevel" select="$listLevel"/>
 
1343
                                                                                <xsl:with-param name="listLevelStyle" select="$listLevelStyle"/>
 
1344
                                                                                <xsl:with-param name="listStyle" select="$listStyle"/>
 
1345
                                                                                <xsl:with-param name="listStyleName" select="$listStyleName"/>
 
1346
                                                                                <xsl:with-param name="precedingListItemsOfSameLevelAndStyle" select="$precedingListItemsOfSameLevelAndStyle"/>
 
1347
                                                                                <xsl:with-param name="precedingListItemsOfSameLevelAndStyleCount" select="$precedingListItemsOfSameLevelAndStyleCount"/>
 
1348
                                                                                <xsl:with-param name="precedingListItemsOfSameStyle" select="$precedingListItemsOfSameStyle"/>
 
1349
                                                                                <xsl:with-param name="precedingListItemsOfSameStyleCount" select="$precedingListItemsOfSameStyleCount"/>
 
1350
                                                                                <xsl:with-param name="pseudoLevel">
 
1351
                                                                                        <xsl:choose>
 
1352
                                                                                                <!-- empty list item does not count -->
 
1353
                                                                                                <xsl:when test="not(*[name() = 'text:h' or name() = 'text:p'])">
 
1354
                                                                                                        <xsl:value-of select="$pseudoLevel"/>
 
1355
                                                                                                </xsl:when>
 
1356
                                                                                                <xsl:otherwise>1</xsl:otherwise>
 
1357
                                                                                        </xsl:choose>
 
1358
                                                                                </xsl:with-param>
 
1359
                                                                        </xsl:call-template>
 
1360
                                                                </xsl:otherwise>
 
1361
                                                        </xsl:choose>
 
1362
                                                </xsl:otherwise>
 
1363
                                        </xsl:choose>
 
1364
                                </xsl:for-each>
 
1365
                        </xsl:when>
 
1366
                        <xsl:otherwise>
 
1367
                                <xsl:value-of select="$itemNumber"/>
 
1368
                        </xsl:otherwise>
 
1369
                </xsl:choose>
 
1370
        </xsl:template>
 
1371
 
 
1372
        <xsl:template name="countListItem">
 
1373
                <xsl:param name="IteratorSameLevelAndStyle"/>
 
1374
                <xsl:param name="IteratorSameStyle"/>
 
1375
                <xsl:param name="itemNumber"/>
 
1376
                <xsl:param name="listLevel"/>
 
1377
                <xsl:param name="listLevelStyle"/>
 
1378
                <xsl:param name="listStyle"/>
 
1379
                <xsl:param name="listStyleName"/>
 
1380
                <xsl:param name="precedingListItemsOfSameLevelAndStyle"/>
 
1381
                <xsl:param name="precedingListItemsOfSameLevelAndStyleCount"/>
 
1382
                <xsl:param name="precedingListItemsOfSameStyle"/>
 
1383
                <xsl:param name="precedingListItemsOfSameStyleCount"/>
 
1384
                <xsl:param name="pseudoLevel" />
 
1385
 
 
1386
                <xsl:choose>
 
1387
                        <xsl:when test="@text:start-value">
 
1388
                                <xsl:choose>
 
1389
                                        <xsl:when test="not(*[name() = 'text:h' or name() = 'text:p'])">
 
1390
                                                <!-- empty list item does not count -->
 
1391
                                                <xsl:call-template name="countListItemTillStartValue">
 
1392
                                                        <xsl:with-param name="IteratorSameLevelAndStyle" select="$IteratorSameLevelAndStyle + 1" />
 
1393
                                                        <xsl:with-param name="IteratorSameStyle" select="$IteratorSameStyle + 1"/>
 
1394
                                                        <xsl:with-param name="itemNumber" select="$itemNumber"/>
 
1395
                                                        <xsl:with-param name="listLevel" select="$listLevel"/>
 
1396
                                                        <xsl:with-param name="listLevelStyle" select="$listLevelStyle"/>
 
1397
                                                        <xsl:with-param name="listStyle" select="$listStyle"/>
 
1398
                                                        <xsl:with-param name="precedingListItemsOfSameLevelAndStyle" select="$precedingListItemsOfSameLevelAndStyle"/>
 
1399
                                                        <xsl:with-param name="precedingListItemsOfSameLevelAndStyleCount" select="$precedingListItemsOfSameLevelAndStyleCount"/>
 
1400
                                                        <xsl:with-param name="precedingListItemsOfSameStyle" select="$precedingListItemsOfSameStyle"/>
 
1401
                                                        <xsl:with-param name="precedingListItemsOfSameStyleCount" select="$precedingListItemsOfSameStyleCount"/>
 
1402
                                                        <xsl:with-param name="pseudoLevel" select="$pseudoLevel" />
 
1403
                                                </xsl:call-template>
 
1404
                                        </xsl:when>
 
1405
                                        <xsl:otherwise>
 
1406
                                                <xsl:value-of select="$itemNumber + @text:start-value"/>
 
1407
                                        </xsl:otherwise>
 
1408
                                </xsl:choose>
 
1409
                        </xsl:when>
 
1410
                        <xsl:when test="$listLevelStyle/@text:start-value">
 
1411
                                <xsl:choose>
 
1412
                                        <xsl:when test="not(*[name() = 'text:h' or name() = 'text:p'])">
 
1413
                                                <!-- empty list item does not count -->
 
1414
                                                <xsl:call-template name="countListItemTillStartValue">
 
1415
                                                        <xsl:with-param name="IteratorSameLevelAndStyle" select="$IteratorSameLevelAndStyle + 1" />
 
1416
                                                        <xsl:with-param name="IteratorSameStyle" select="$IteratorSameStyle + 1"/>
 
1417
                                                        <xsl:with-param name="itemNumber" select="$itemNumber"/>
 
1418
                                                        <xsl:with-param name="listLevel" select="$listLevel"/>
 
1419
                                                        <xsl:with-param name="listLevelStyle" select="$listLevelStyle"/>
 
1420
                                                        <xsl:with-param name="listStyle" select="$listStyle"/>
 
1421
                                                        <xsl:with-param name="precedingListItemsOfSameLevelAndStyle" select="$precedingListItemsOfSameLevelAndStyle"/>
 
1422
                                                        <xsl:with-param name="precedingListItemsOfSameLevelAndStyleCount" select="$precedingListItemsOfSameLevelAndStyleCount"/>
 
1423
                                                        <xsl:with-param name="precedingListItemsOfSameStyle" select="$precedingListItemsOfSameStyle"/>
 
1424
                                                        <xsl:with-param name="precedingListItemsOfSameStyleCount" select="$precedingListItemsOfSameStyleCount"/>
 
1425
                                                        <xsl:with-param name="pseudoLevel" select="$pseudoLevel" />
 
1426
                                                </xsl:call-template>
 
1427
                                        </xsl:when>
 
1428
                                        <xsl:otherwise>
 
1429
                                                <xsl:value-of select="$itemNumber + $listLevelStyle/@text:start-value"/>
 
1430
                                        </xsl:otherwise>
 
1431
                                </xsl:choose>
 
1432
                        </xsl:when>
 
1433
                        <xsl:otherwise>
 
1434
                                <xsl:choose>
 
1435
                                        <xsl:when test="not(*[name() = 'text:h' or name() = 'text:p'])">
 
1436
                                                <!-- empty list item does not count -->
 
1437
                                                <xsl:call-template name="countListItemTillStartValue">
 
1438
                                                        <xsl:with-param name="IteratorSameLevelAndStyle" select="$IteratorSameLevelAndStyle + 1" />
 
1439
                                                        <xsl:with-param name="IteratorSameStyle" select="$IteratorSameStyle + 1"/>
 
1440
                                                        <xsl:with-param name="itemNumber" select="$itemNumber"/>
 
1441
                                                        <xsl:with-param name="listLevel" select="$listLevel"/>
 
1442
                                                        <xsl:with-param name="listLevelStyle" select="$listLevelStyle"/>
 
1443
                                                        <xsl:with-param name="listStyle" select="$listStyle"/>
 
1444
                                                        <xsl:with-param name="precedingListItemsOfSameLevelAndStyle" select="$precedingListItemsOfSameLevelAndStyle"/>
 
1445
                                                        <xsl:with-param name="precedingListItemsOfSameLevelAndStyleCount" select="$precedingListItemsOfSameLevelAndStyleCount"/>
 
1446
                                                        <xsl:with-param name="precedingListItemsOfSameStyle" select="$precedingListItemsOfSameStyle"/>
 
1447
                                                        <xsl:with-param name="precedingListItemsOfSameStyleCount" select="$precedingListItemsOfSameStyleCount"/>
 
1448
                                                        <xsl:with-param name="pseudoLevel" select="$pseudoLevel" />
 
1449
                                                </xsl:call-template>
 
1450
                                        </xsl:when>
 
1451
                                        <xsl:otherwise>
 
1452
                                                <!-- count on till you find a start-value or the end is reached -->
 
1453
                                                <xsl:call-template name="countListItemTillStartValue">
 
1454
                                                        <xsl:with-param name="IteratorSameLevelAndStyle" select="$IteratorSameLevelAndStyle + 1" />
 
1455
                                                        <xsl:with-param name="IteratorSameStyle" select="$IteratorSameStyle + 1"/>
 
1456
                                                        <xsl:with-param name="itemNumber" select="$itemNumber + 1"/>
 
1457
                                                        <xsl:with-param name="listLevel" select="$listLevel"/>
 
1458
                                                        <xsl:with-param name="listLevelStyle" select="$listLevelStyle"/>
 
1459
                                                        <xsl:with-param name="listStyle" select="$listStyle"/>
 
1460
                                                        <xsl:with-param name="precedingListItemsOfSameLevelAndStyle" select="$precedingListItemsOfSameLevelAndStyle"/>
 
1461
                                                        <xsl:with-param name="precedingListItemsOfSameLevelAndStyleCount" select="$precedingListItemsOfSameLevelAndStyleCount"/>
 
1462
                                                        <xsl:with-param name="precedingListItemsOfSameStyle" select="$precedingListItemsOfSameStyle"/>
 
1463
                                                        <xsl:with-param name="precedingListItemsOfSameStyleCount" select="$precedingListItemsOfSameStyleCount"/>
 
1464
                                                        <xsl:with-param name="pseudoLevel" select="0" />
 
1465
                                                </xsl:call-template>
 
1466
                                        </xsl:otherwise>
 
1467
                                </xsl:choose>
 
1468
                        </xsl:otherwise>
 
1469
                </xsl:choose>
 
1470
        </xsl:template>
 
1471
 
 
1472
 
 
1473
        <!-- Creates the list label containing the number, which is separated by '.' between the levels.
 
1474
                Depending on the levels to display (listLevelsToDisplay) -->
 
1475
        <xsl:template name="createItemLabel">
 
1476
                <xsl:param name="itemLabel" select="''"/>
 
1477
                <xsl:param name="itemNumber" />
 
1478
                <xsl:param name="listLevel" />
 
1479
                <xsl:param name="listLevelStyle" />
 
1480
                <xsl:param name="listLevelsToDisplay" />
 
1481
 
 
1482
                <xsl:choose>
 
1483
                        <xsl:when test="$listLevelsToDisplay &lt; $listLevel">
 
1484
                                <xsl:call-template name="truncLabel">
 
1485
                                        <xsl:with-param name="itemLabel" select="$itemLabel"/>
 
1486
                                        <xsl:with-param name="itemNumber" select="$itemNumber" />
 
1487
                                        <xsl:with-param name="listLevel" select="$listLevel"/>
 
1488
                                        <xsl:with-param name="listLevelStyle" select="$listLevelStyle" />
 
1489
                                        <xsl:with-param name="listLevelsToDisplay" select="$listLevelsToDisplay"/>
 
1490
                                </xsl:call-template>
 
1491
                        </xsl:when>
 
1492
                        <xsl:otherwise>
 
1493
                                <xsl:variable name="numberedSymbol">
 
1494
                                        <xsl:number value="$itemNumber" format="{$listLevelStyle/@style:num-format}"/>
 
1495
                                </xsl:variable>
 
1496
                                <xsl:choose>
 
1497
                                        <xsl:when test="$listLevelsToDisplay != 1">
 
1498
                                                <xsl:value-of select="concat($itemLabel, '.' , $numberedSymbol)"/>
 
1499
                                        </xsl:when>
 
1500
                                        <xsl:otherwise>
 
1501
                                                <xsl:value-of select="$numberedSymbol"/>
 
1502
                                        </xsl:otherwise>
 
1503
                                </xsl:choose>
 
1504
                        </xsl:otherwise>
 
1505
                </xsl:choose>
 
1506
        </xsl:template>
 
1507
 
 
1508
        <xsl:template name="truncLabel">
 
1509
                <xsl:param name="itemLabel" />
 
1510
                <xsl:param name="itemNumber" />
 
1511
                <xsl:param name="listLevel" />
 
1512
                <xsl:param name="listLevelStyle" />
 
1513
                <xsl:param name="listLevelsToDisplay" />
 
1514
                <xsl:param name="listStyle" />
 
1515
                <xsl:param name="listStyleName" />
 
1516
 
 
1517
                <xsl:call-template name="createItemLabel">
 
1518
                        <xsl:with-param name="itemLabel">
 
1519
                                <xsl:if test="contains($itemLabel, '.')">
 
1520
                                        <xsl:value-of select="substring-after($itemLabel, '.')"/>
 
1521
                                </xsl:if>
 
1522
                        </xsl:with-param>
 
1523
                        <xsl:with-param name="itemNumber" select="$itemNumber"/>
 
1524
                        <xsl:with-param name="listLevel" select="$listLevel - 1"/>
 
1525
                        <xsl:with-param name="listLevelStyle" select="$listLevelStyle"/>
 
1526
                        <xsl:with-param name="listLevelsToDisplay" select="$listLevelsToDisplay"/>
 
1527
                        <xsl:with-param name="listStyle" select="$listStyle"/>
 
1528
                        <xsl:with-param name="listStyleName" select="$listStyleName"/>
 
1529
                </xsl:call-template>
 
1530
        </xsl:template>
 
1531
 
 
1532
 
 
1533
        <xsl:template match="text:p" mode="first-list-child-margin-adaption">
 
1534
                <xsl:param name="globalData"/>
 
1535
                <xsl:param name="listLabelElement"/>
 
1536
                <xsl:param name="isEmptyList"/>
 
1537
                <xsl:param name="isListNumberingReset"/>
 
1538
                <xsl:param name="isNextLevelNumberingReset"/>
 
1539
                <xsl:param name="itemLabel"/>
 
1540
                <xsl:param name="itemNumber"/>
 
1541
                <xsl:param name="listIndent"/>
 
1542
                <xsl:param name="listLevel"/>
 
1543
                <xsl:param name="listRestart"/>
 
1544
                <xsl:param name="listStyle"/>
 
1545
                <xsl:param name="listStyleName"/>
 
1546
                <xsl:param name="minLabelWidth"/>
 
1547
 
 
1548
                <xsl:element name="p">
 
1549
                        <xsl:call-template name="create-list-style">
 
1550
                                <xsl:with-param name="globalData" select="$globalData"/>
 
1551
                                <xsl:with-param name="listIndent" select="$listIndent"/>
 
1552
                                <xsl:with-param name="styleName" select="@text:style-name"/>
 
1553
                        </xsl:call-template>
 
1554
                        <xsl:if test="$listLabelElement">
 
1555
                                <xsl:copy-of select="$listLabelElement"/>
 
1556
                        </xsl:if>
 
1557
                        <xsl:apply-templates>
 
1558
                                <xsl:with-param name="globalData" select="$globalData"/>
 
1559
                                <xsl:with-param name="listIndent" select="$minLabelWidth"/>
 
1560
                        </xsl:apply-templates>
 
1561
                        <xsl:if test="$listLabelElement">
 
1562
                                <!-- this span disables the float necessary to bring two block elements on one line. It contains a space as IE6 bug workaround -->
 
1563
                                <span class="odfLiEnd"></span>
 
1564
                        </xsl:if>
 
1565
                        <xsl:text>&#160;</xsl:text>
 
1566
                </xsl:element>
 
1567
 
 
1568
                <xsl:apply-templates mode="first-list-child-margin-adaption" select="following-sibling::*[1]">
 
1569
                        <xsl:with-param name="globalData" select="$globalData"/>
 
1570
                        <xsl:with-param name="isEmptyList" select="$isEmptyList"/>
 
1571
                        <xsl:with-param name="isListNumberingReset" select="$isListNumberingReset"/>
 
1572
                        <xsl:with-param name="isNextLevelNumberingReset" select="$isNextLevelNumberingReset"/>
 
1573
                        <xsl:with-param name="itemLabel" select="$itemLabel"/>
 
1574
                        <xsl:with-param name="itemNumber" select="$itemNumber"/>
 
1575
                        <xsl:with-param name="listLevel" select="$listLevel"/>
 
1576
                        <xsl:with-param name="listRestart" select="$listRestart"/>
 
1577
                        <xsl:with-param name="listStyle" select="$listStyle"/>
 
1578
                        <xsl:with-param name="listStyleName" select="$listStyleName"/>
 
1579
                        <xsl:with-param name="listIndent" select="$listIndent"/>
 
1580
                        <xsl:with-param name="minLabelWidth" select="$minLabelWidth"/>
 
1581
                </xsl:apply-templates>
 
1582
        </xsl:template>
 
1583
 
 
1584
 
 
1585
        <!-- Neglecting the left margin behavior for headings for now -->
 
1586
        <xsl:template match="text:h" mode="first-list-child-margin-adaption">
 
1587
                <xsl:param name="globalData"/>
 
1588
                <xsl:param name="listLabelElement"/>
 
1589
                <xsl:param name="isEmptyList"/>
 
1590
                <xsl:param name="isListNumberingReset"/>
 
1591
                <xsl:param name="isNextLevelNumberingReset"/>
 
1592
                <xsl:param name="itemLabel"/>
 
1593
                <xsl:param name="itemNumber"/>
 
1594
                <xsl:param name="listIndent"/>
 
1595
                <xsl:param name="listLevel"/>
 
1596
                <xsl:param name="listRestart"/>
 
1597
                <xsl:param name="listStyle"/>
 
1598
                <xsl:param name="listStyleName"/>
 
1599
                <xsl:param name="minLabelWidth"/>
 
1600
 
 
1601
                <xsl:element name="h">
 
1602
                        <xsl:call-template name="create-list-style">
 
1603
                                <xsl:with-param name="globalData" select="$globalData"/>
 
1604
                                <xsl:with-param name="listIndent" select="$listIndent"/>
 
1605
                                <xsl:with-param name="styleName" select="@text:style-name"/>
 
1606
                        </xsl:call-template>
 
1607
                        <xsl:if test="$listLabelElement">
 
1608
                                <xsl:copy-of select="$listLabelElement"/>
 
1609
                        </xsl:if>
 
1610
                        <xsl:apply-templates>
 
1611
                                <xsl:with-param name="globalData" select="$globalData"/>
 
1612
                                <xsl:with-param name="listIndent" select="$minLabelWidth"/>
 
1613
                        </xsl:apply-templates>
 
1614
                        <xsl:if test="$listLabelElement">
 
1615
                                <!-- this span disables the float necessary to bring two block elements on one line. It contains a space as IE6 bug workaround -->
 
1616
                                <span class="odfLiEnd"></span>
 
1617
                        </xsl:if>
 
1618
                        <xsl:text>&#160;</xsl:text>
 
1619
                </xsl:element>
 
1620
 
 
1621
                <xsl:apply-templates mode="first-list-child-margin-adaption" select="following-sibling::*[1]">
 
1622
                        <xsl:with-param name="globalData" select="$globalData"/>
 
1623
                        <xsl:with-param name="isEmptyList" select="$isEmptyList"/>
 
1624
                        <xsl:with-param name="isListNumberingReset" select="$isListNumberingReset"/>
 
1625
                        <xsl:with-param name="isNextLevelNumberingReset" select="$isNextLevelNumberingReset"/>
 
1626
                        <xsl:with-param name="itemLabel" select="$itemLabel"/>
 
1627
                        <xsl:with-param name="itemNumber" select="$itemNumber"/>
 
1628
                        <xsl:with-param name="listLevel" select="$listLevel"/>
 
1629
                        <xsl:with-param name="listRestart" select="$listRestart"/>
 
1630
                        <xsl:with-param name="listStyle" select="$listStyle"/>
 
1631
                        <xsl:with-param name="listStyleName" select="$listStyleName"/>
 
1632
                        <xsl:with-param name="listIndent" select="$listIndent"/>
 
1633
                        <xsl:with-param name="minLabelWidth" select="$minLabelWidth"/>
 
1634
                </xsl:apply-templates>
 
1635
        </xsl:template>
 
1636
 
 
1637
 
 
1638
        <xsl:template match="*" mode="first-list-child-margin-adaption">
 
1639
                <xsl:param name="globalData"/>
 
1640
                <xsl:param name="isEmptyList"/>
 
1641
                <xsl:param name="isListNumberingReset"/>
 
1642
                <xsl:param name="isNextLevelNumberingReset"/>
 
1643
                <xsl:param name="itemLabel"/>
 
1644
                <xsl:param name="itemNumber"/>
 
1645
                <xsl:param name="listIndent"/>
 
1646
                <xsl:param name="listLevel"/>
 
1647
                <xsl:param name="listRestart"/>
 
1648
                <xsl:param name="listStyle"/>
 
1649
                <xsl:param name="listStyleName"/>
 
1650
                <xsl:param name="minLabelWidth"/>
 
1651
 
 
1652
                <xsl:apply-templates select="self::*" mode="listItemSibling">
 
1653
                        <xsl:with-param name="globalData" select="$globalData"/>
 
1654
                        <xsl:with-param name="isEmptyList" select="$isEmptyList"/>
 
1655
                        <xsl:with-param name="isListNumberingReset" select="$isListNumberingReset"/>
 
1656
                        <xsl:with-param name="isNextLevelNumberingReset" select="$isNextLevelNumberingReset"/>
 
1657
                        <xsl:with-param name="itemLabel" select="$itemLabel"/>
 
1658
                        <xsl:with-param name="itemNumber" select="$itemNumber"/>
 
1659
                        <xsl:with-param name="listIndent" select="$listIndent"/>
 
1660
                        <xsl:with-param name="listLevel" select="$listLevel"/>
 
1661
                        <xsl:with-param name="listRestart" select="$listRestart"/>
 
1662
                        <xsl:with-param name="listStyle" select="$listStyle"/>
 
1663
                        <xsl:with-param name="listStyleName" select="$listStyleName"/>
 
1664
                </xsl:apply-templates>
 
1665
 
 
1666
                <xsl:apply-templates mode="first-list-child-margin-adaption" select="following-sibling::*[1]">
 
1667
                        <xsl:with-param name="globalData" select="$globalData"/>
 
1668
                        <xsl:with-param name="isEmptyList" select="$isEmptyList"/>
 
1669
                        <xsl:with-param name="isListNumberingReset" select="$isListNumberingReset"/>
 
1670
                        <xsl:with-param name="isNextLevelNumberingReset" select="$isNextLevelNumberingReset"/>
 
1671
                        <xsl:with-param name="itemLabel" select="$itemLabel"/>
 
1672
                        <xsl:with-param name="itemNumber" select="$itemNumber"/>
 
1673
                        <xsl:with-param name="listLevel" select="$listLevel"/>
 
1674
                        <xsl:with-param name="listRestart" select="$listRestart"/>
 
1675
                        <xsl:with-param name="listStyle" select="$listStyle"/>
 
1676
                        <xsl:with-param name="listStyleName" select="$listStyleName"/>
 
1677
                        <xsl:with-param name="listIndent" select="$listIndent"/>
 
1678
                        <xsl:with-param name="minLabelWidth" select="$minLabelWidth"/>
 
1679
                </xsl:apply-templates>
 
1680
        </xsl:template>
 
1681
 
 
1682
        <xsl:template match="*" mode="listItemSibling">
 
1683
                <xsl:param name="globalData"/>
 
1684
                <xsl:param name="isEmptyList"/>
 
1685
                <xsl:param name="isListNumberingReset"/>
 
1686
                <xsl:param name="isNextLevelNumberingReset"/>
 
1687
                <xsl:param name="itemLabel"/>
 
1688
                <xsl:param name="itemNumber"/>
 
1689
                <xsl:param name="listIndent"/>
 
1690
                <xsl:param name="listLevel"/>
 
1691
                <xsl:param name="listRestart"/>
 
1692
                <xsl:param name="listStyle"/>
 
1693
                <xsl:param name="listStyleName"/>
 
1694
 
 
1695
                <xsl:apply-templates select="self::*">
 
1696
                        <xsl:with-param name="globalData" select="$globalData"/>
 
1697
                        <xsl:with-param name="isEmptyList" select="$isEmptyList"/>
 
1698
                        <xsl:with-param name="isListNumberingReset" select="$isListNumberingReset"/>
 
1699
                        <xsl:with-param name="isNextLevelNumberingReset" select="$isNextLevelNumberingReset"/>
 
1700
                        <xsl:with-param name="itemNumber" select="$itemNumber"/>
 
1701
                        <xsl:with-param name="listIndent" select="$listIndent"/>
 
1702
                        <!-- receives the same parent label, only with a different itemNumber -->
 
1703
                        <xsl:with-param name="itemLabel" select="$itemLabel"/>
 
1704
                        <xsl:with-param name="listLevel" select="$listLevel"/>
 
1705
                        <xsl:with-param name="listStyle" select="$listStyle"/>
 
1706
                        <xsl:with-param name="listStyleName" select="$listStyleName"/>
 
1707
                </xsl:apply-templates>
 
1708
                <xsl:apply-templates select="following-sibling::*[1]" mode="listItemSibling">
 
1709
                        <xsl:with-param name="globalData" select="$globalData"/>
 
1710
                        <xsl:with-param name="isEmptyList" select="$isEmptyList"/>
 
1711
                        <xsl:with-param name="isListNumberingReset" select="$isListNumberingReset"/>
 
1712
                        <xsl:with-param name="isNextLevelNumberingReset" select="$isNextLevelNumberingReset"/>
 
1713
                        <xsl:with-param name="itemNumber" select="$itemNumber"/>
 
1714
                        <xsl:with-param name="listIndent" select="$listIndent"/>
 
1715
                        <!-- receives the same parent label, only with a different itemNumber -->
 
1716
                        <xsl:with-param name="itemLabel" select="$itemLabel"/>
 
1717
                        <xsl:with-param name="listLevel" select="$listLevel"/>
 
1718
                        <xsl:with-param name="listStyle" select="$listStyle"/>
 
1719
                        <xsl:with-param name="listStyleName" select="$listStyleName"/>
 
1720
                </xsl:apply-templates>
 
1721
        </xsl:template>
 
1722
 
 
1723
        <xsl:template match="text()" mode="first-list-child-margin-adaption">
 
1724
                <xsl:value-of select="."/>
 
1725
        </xsl:template>
 
1726
 
 
1727
 
 
1728
        <xsl:template name="create-list-style">
 
1729
                <xsl:param name="globalData"/>
 
1730
                <xsl:param name="listIndent" select="0"/>
 
1731
                <xsl:param name="styleName"/>
 
1732
 
 
1733
                <xsl:if test="$styleName">
 
1734
                        <xsl:attribute name="class">
 
1735
                                <xsl:value-of select="translate($styleName, '.,;: %()[]/\+', '_____________')"/>
 
1736
                        </xsl:attribute>
 
1737
                </xsl:if>
 
1738
                <xsl:attribute name="style">
 
1739
                        <xsl:text>margin-left:</xsl:text>
 
1740
                        <xsl:value-of select="$listIndent"/>
 
1741
                        <xsl:text>cm;</xsl:text>
 
1742
                </xsl:attribute>
 
1743
        </xsl:template>
 
1744
 
 
1745
 
 
1746
        <!-- ********************************************** -->
 
1747
        <!-- *** Text Section (contains: draw:text-box) *** -->
 
1748
        <!-- ********************************************** -->
 
1749
 
 
1750
        <xsl:template match="text:section">
 
1751
                <xsl:param name="globalData"/>
 
1752
 
 
1753
                <xsl:if test="not(contains(@text:display, 'none'))">
 
1754
                        <xsl:element name="div">
 
1755
                                <xsl:call-template name="apply-styles-and-content">
 
1756
                                        <xsl:with-param name="globalData" select="$globalData"/>
 
1757
                                </xsl:call-template>
 
1758
                        </xsl:element>
 
1759
                </xsl:if>
 
1760
        </xsl:template>
 
1761
 
 
1762
 
 
1763
        <!-- Hidden text dependend on Office variables:
 
1764
                 The text is not shown, if condition is 'true'.
 
1765
                 Implemented solely for conditons as '<VARIABLE>==0' or '<VARIABLE>==1'
 
1766
        -->
 
1767
        <xsl:key match="text:variable-set" name="varSet" use="@text:name"/>
 
1768
        <xsl:template match="text:hidden-text">
 
1769
                <xsl:param name="globalData"/>
 
1770
 
 
1771
                <xsl:variable name="varName" select="substring-before(@text:condition, '==')"/>
 
1772
                <xsl:variable name="varValue" select="substring-after(@text:condition, '==')"/>
 
1773
                <xsl:choose>
 
1774
                        <xsl:when test="key('varSet', $varName)/@text:value != $varValue">
 
1775
                                <xsl:value-of select="@text:string-value"/>
 
1776
                        </xsl:when>
 
1777
                        <xsl:otherwise>
 
1778
                                <xsl:comment>
 
1779
                                        <xsl:value-of select="$varName"/>
 
1780
                                        <xsl:value-of select="@text:string-value"/>
 
1781
                                        <xsl:value-of select="$varName"/>
 
1782
                                </xsl:comment>
 
1783
                        </xsl:otherwise>
 
1784
                </xsl:choose>
 
1785
        </xsl:template>
 
1786
 
 
1787
 
 
1788
        <xsl:template match="@text:style-name | @draw:style-name | @draw:text-style-name | @table:style-name"><!-- | @presentation:style-name-->
 
1789
                <xsl:param name="globalData"/>
 
1790
 
 
1791
                <xsl:attribute name="class">
 
1792
                        <xsl:value-of select="translate(., '.,;: %()[]/\+', '_____________')"/>
 
1793
                </xsl:attribute>
 
1794
        </xsl:template>
 
1795
 
 
1796
 
 
1797
        <!-- ***************** -->
 
1798
        <!-- *** Footnotes *** -->
 
1799
        <!-- ***************** -->
 
1800
 
 
1801
        <xsl:template match="text:note">
 
1802
                <xsl:param name="globalData"/>
 
1803
 
 
1804
                <!-- get style configuration -->
 
1805
                <xsl:variable name="footnoteConfig" select="$globalData/office:styles/text:notes-configuration[@text:note-class=current()/@text:note-class]" />
 
1806
 
 
1807
                <xsl:variable name="titlePrefix">
 
1808
                        <xsl:choose>
 
1809
                                <xsl:when test="@text:note-class = 'footnote'">
 
1810
                                        <xsl:text>Footnote: </xsl:text>
 
1811
                                </xsl:when>
 
1812
                                <xsl:otherwise>
 
1813
                                        <xsl:text>Endnote: </xsl:text>
 
1814
                                </xsl:otherwise>
 
1815
                        </xsl:choose>
 
1816
                </xsl:variable>
 
1817
 
 
1818
                <!-- write anchor -->
 
1819
                <xsl:element name="span">
 
1820
                        <xsl:attribute name="class"><xsl:value-of select="$footnoteConfig/@text:citation-body-style-name"/></xsl:attribute>
 
1821
                        <xsl:attribute name="title"><xsl:value-of select="$titlePrefix"/><xsl:apply-templates mode="textOnly" select="text:note-body"/></xsl:attribute>
 
1822
                        <xsl:element name="a">
 
1823
                                <xsl:attribute name="href"><xsl:value-of select="concat('#', @text:id)"/></xsl:attribute>
 
1824
                                <xsl:attribute name="id"><xsl:value-of select="concat('body_', @text:id)"/></xsl:attribute>
 
1825
                                <xsl:apply-templates  mode="textOnly" select="text:note-citation"/>
 
1826
                        </xsl:element>
 
1827
                </xsl:element>
 
1828
        </xsl:template>
 
1829
 
 
1830
        <xsl:template match="*" mode="textOnly">
 
1831
                <xsl:apply-templates select="* | text()" mode="textOnly" />
 
1832
        </xsl:template>
 
1833
 
 
1834
        <xsl:template match="text()" mode="textOnly">
 
1835
                <xsl:value-of select="."/>
 
1836
        </xsl:template>
 
1837
 
 
1838
        <!-- Useful in case of 'style:map', conditional formatting, where a style references to another -->
 
1839
        <xsl:key name="textNotes" match="text:note" use="@text:note-class"/>
 
1840
 
 
1841
        <!-- writing the footer- and endnotes beyond the body -->
 
1842
        <xsl:template name="write-text-nodes">
 
1843
                <xsl:param name="globalData"/>
 
1844
 
 
1845
                <!-- write footnote body -->
 
1846
                <xsl:for-each select="key('textNotes', 'footnote')">
 
1847
                        <xsl:call-template name="write-text-node">
 
1848
                                <xsl:with-param name="globalData" select="$globalData"/>
 
1849
                                <xsl:with-param name="footnoteConfig" select="$globalData/office:styles/text:notes-configuration[@text:note-class=current()/@text:note-class]" />
 
1850
                        </xsl:call-template>
 
1851
                </xsl:for-each>
 
1852
 
 
1853
                <!-- write endnote body -->
 
1854
                <xsl:for-each select="key('textNotes', 'endnote')">
 
1855
                        <xsl:call-template name="write-text-node">
 
1856
 
 
1857
                                <xsl:with-param name="globalData" select="$globalData"/>
 
1858
                                <xsl:with-param name="footnoteConfig" select="$globalData/office:styles/text:notes-configuration[@text:note-class=current()/@text:note-class]" />
 
1859
                        </xsl:call-template>
 
1860
                </xsl:for-each>
 
1861
        </xsl:template>
 
1862
 
 
1863
        <xsl:template name="write-text-node">
 
1864
                <xsl:param name="globalData"/>
 
1865
                <xsl:param name="footnoteConfig"/>
 
1866
 
 
1867
                <xsl:apply-templates select="text:note-body/node()">
 
1868
                                <xsl:with-param name="globalData" select="$globalData" />
 
1869
                                <xsl:with-param name="footnotePrefix">
 
1870
                                        <xsl:element name="span">
 
1871
                                                <xsl:attribute name="class">footnodeNumber</xsl:attribute>
 
1872
                                                <xsl:element name="a">
 
1873
                                                        <xsl:attribute name="class"><xsl:value-of select="$footnoteConfig/@text:citation-style-name"/></xsl:attribute>
 
1874
                                                        <xsl:attribute name="id"><xsl:value-of select="@text:id"/></xsl:attribute>
 
1875
                                                        <xsl:attribute name="href"><xsl:value-of select="concat('#body_', @text:id)"/></xsl:attribute>
 
1876
                                                        <xsl:apply-templates  mode="textOnly" select="text:note-citation"/>
 
1877
                                                </xsl:element>
 
1878
                                        </xsl:element>
 
1879
                                </xsl:with-param>
 
1880
                </xsl:apply-templates>
 
1881
        </xsl:template>
 
1882
 
 
1883
 
 
1884
        <!-- tabulator -->
 
1885
        <xsl:template match="text:tab">
 
1886
                <xsl:param name="globalData"/>
 
1887
 
 
1888
                <xsl:element name="span">
 
1889
                        <!-- using as heuristic the first tab width of the 0paragraph style as margin-left -->
 
1890
                        <xsl:attribute name="style">margin-left:<xsl:value-of select="$globalData/all-doc-styles/style[@style:name = current()/ancestor::*/@text:style-name]/*/style:tab-stops/style:tab-stop/@style:position"/>;</xsl:attribute>
 
1891
                </xsl:element>
 
1892
 
 
1893
        </xsl:template>
 
1894
 
 
1895
        <!-- MathML -->
 
1896
        <xsl:template match="draw:object[math:math]">
 
1897
                <math xmlns="http://www.w3.org/1998/Math/MathML">
 
1898
                        <xsl:apply-templates select="math:math/math:semantics/*" mode="math"/>
 
1899
                </math>
 
1900
        </xsl:template>
 
1901
 
 
1902
        <xsl:template match="*" mode="math">
 
1903
                <xsl:element name="{local-name()}" namespace="http://www.w3.org/1998/Math/MathML">
 
1904
                        <xsl:apply-templates select="@*|node()" mode="math"/>
 
1905
                </xsl:element>
 
1906
        </xsl:template>
 
1907
 
 
1908
        <xsl:template match="@*" mode="math">
 
1909
                <xsl:attribute name="{local-name()}">
 
1910
                        <xsl:value-of select="."/>
 
1911
                </xsl:attribute>
 
1912
        </xsl:template>
 
1913
 
 
1914
        <xsl:template match="math:annotation" mode="math"/>
 
1915
 
 
1916
</xsl:stylesheet>
 
 
b'\\ No newline at end of file'