1<?xml version="1.0" encoding="UTF-8"?>
2<!--***********************************************************
3 *
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements.  See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership.  The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License.  You may obtain a copy of the License at
11 *
12 *   http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied.  See the License for the
18 * specific language governing permissions and limitations
19 * under the License.
20 *
21 ***********************************************************-->
22
23
24<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml" xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:aml="http://schemas.microsoft.com/aml/2001/core" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" exclude-result-prefixes="office table style text draw svg   dc config xlink meta oooc dom ooo chart math dr3d form script ooow draw">
25    <xsl:template match="style:paragraph-properties" mode="paragraph">
26        <w:pPr>
27            <w:adjustRightInd w:val="off"/>
28            <xsl:if test="@fo:break-before = 'page'">
29                <w:pageBreakBefore w:val="on"/>
30            </xsl:if>
31            <xsl:if test="contains(@style:writing-mode, 'rl')">
32                <w:bidi/>
33            </xsl:if>
34            <xsl:choose>
35                <xsl:when test="@fo:text-align-last = 'start'">
36                    <xsl:choose>
37                        <xsl:when test="contains(@style:writing-mode, 'rl')">
38                            <w:jc w:val="right"/>
39                        </xsl:when>
40                        <xsl:otherwise>
41                            <w:jc w:val="left"/>
42                        </xsl:otherwise>
43                    </xsl:choose>
44                </xsl:when>
45                <xsl:when test="@fo:text-align-last = 'justify'">
46                    <w:jc w:val="distribute"/>
47                </xsl:when>
48                <xsl:when test="@fo:text-align-last = 'center'">
49                    <w:jc w:val="center"/>
50                </xsl:when>
51                <xsl:when test="@fo:text-align = 'start'">
52                    <xsl:choose>
53                        <xsl:when test="contains(@style:writing-mode, 'rl')">
54                            <w:jc w:val="right"/>
55                        </xsl:when>
56                        <xsl:otherwise>
57                            <w:jc w:val="left"/>
58                        </xsl:otherwise>
59                    </xsl:choose>
60                </xsl:when>
61                <xsl:when test="@fo:text-align = 'end'">
62                    <xsl:choose>
63                        <xsl:when test="contains(@style:writing-mode, 'rl')">
64                            <w:jc w:val="left"/>
65                        </xsl:when>
66                        <xsl:otherwise>
67                            <w:jc w:val="right"/>
68                        </xsl:otherwise>
69                    </xsl:choose>
70                </xsl:when>
71                <xsl:when test="@fo:text-align = 'justify'">
72                    <w:jc w:val="distribute"/>
73                </xsl:when>
74                <xsl:when test="@fo:text-align = 'center'">
75                    <w:jc w:val="center"/>
76                </xsl:when>
77            </xsl:choose>
78            <w:spacing>
79                <xsl:choose>
80                    <xsl:when test="@fo:line-height">
81                        <xsl:choose>
82                            <xsl:when test="contains(@fo:line-height, '%')">
83                                <xsl:attribute name="w:line-rule">auto</xsl:attribute>
84                                <xsl:attribute name="w:line">
85                                    <xsl:value-of select="round(substring-before(@fo:line-height, '%') div 100 * 240)"/>
86                                </xsl:attribute>
87                            </xsl:when>
88                            <xsl:otherwise>
89                                <xsl:attribute name="w:line-rule">exact</xsl:attribute>
90                                <xsl:attribute name="w:line">
91                                    <xsl:call-template name="convert2twip">
92                                        <xsl:with-param name="value" select="@fo:line-height"/>
93                                    </xsl:call-template>
94                                </xsl:attribute>
95                            </xsl:otherwise>
96                        </xsl:choose>
97                    </xsl:when>
98                    <xsl:when test="@style:line-height-at-least">
99                        <xsl:attribute name="w:line-rule">at-least</xsl:attribute>
100                        <xsl:attribute name="w:line">
101                            <xsl:call-template name="convert2twip">
102                                <xsl:with-param name="value" select="@style:line-height-at-least"/>
103                            </xsl:call-template>
104                        </xsl:attribute>
105                    </xsl:when>
106                    <xsl:when test="@style:line-spacing">
107                        <xsl:attribute name="w:line-rule">auto</xsl:attribute>
108                        <xsl:variable name="spacing">
109                            <xsl:call-template name="convert2twip">
110                                <xsl:with-param name="value" select="@style:line-spacing"/>
111                            </xsl:call-template>
112                        </xsl:variable>
113                        <xsl:attribute name="w:line">
114                            <xsl:value-of select="round($spacing div 0.567)"/>
115                        </xsl:attribute>
116                    </xsl:when>
117                </xsl:choose>
118                <xsl:if test="@fo:margin-top">
119                    <xsl:choose>
120                        <xsl:when test="contains(@fo:margin-top, '%')">
121                            <xsl:if test="../@style:parent-style-name">
122                                <xsl:variable name="parent-size">
123                                    <xsl:value-of select="key('paragraph-style', ../@style:parent-style-name)/style:paragraph-properties/@fo:margin-top"/>
124                                </xsl:variable>
125                                <xsl:variable name="w-number">
126                                    <xsl:call-template name="convert2twip">
127                                        <xsl:with-param name="value" select="$parent-size"/>
128                                    </xsl:call-template>
129                                </xsl:variable>
130                                <xsl:attribute name="w:before">
131                                    <xsl:value-of select="round($w-number div 100 * substring-before(@fo:margin-top, '%'))"/>
132                                </xsl:attribute>
133                            </xsl:if>
134                        </xsl:when>
135                        <xsl:otherwise>
136                            <xsl:attribute name="w:before">
137                                <xsl:call-template name="convert2twip">
138                                    <xsl:with-param name="value" select="@fo:margin-top"/>
139                                </xsl:call-template>
140                            </xsl:attribute>
141                        </xsl:otherwise>
142                    </xsl:choose>
143                </xsl:if>
144                <xsl:if test="@fo:margin-bottom">
145                    <xsl:choose>
146                        <xsl:when test="contains(@fo:margin-bottom, '%')">
147                            <xsl:if test="../@style:parent-style-name">
148                                <xsl:variable name="parent-size">
149                                    <xsl:value-of select="key('paragraph-style', ../@style:parent-style-name)/style:paragraph-properties/@fo:margin-bottom"/>
150                                </xsl:variable>
151                                <xsl:variable name="w-number">
152                                    <xsl:call-template name="convert2twip">
153                                        <xsl:with-param name="value" select="$parent-size"/>
154                                    </xsl:call-template>
155                                </xsl:variable>
156                                <xsl:attribute name="w:after">
157                                    <xsl:value-of select="round($w-number div 100 * substring-before(@fo:margin-bottom, '%'))"/>
158                                </xsl:attribute>
159                            </xsl:if>
160                        </xsl:when>
161                        <xsl:otherwise>
162                            <xsl:attribute name="w:after">
163                                <xsl:call-template name="convert2twip">
164                                    <xsl:with-param name="value" select="@fo:margin-bottom"/>
165                                </xsl:call-template>
166                            </xsl:attribute>
167                        </xsl:otherwise>
168                    </xsl:choose>
169                </xsl:if>
170            </w:spacing>
171            <w:ind>
172                <xsl:if test="@fo:margin-left">
173                    <xsl:choose>
174                        <xsl:when test="contains(@fo:margin-left, '%')">
175                            <xsl:if test="../@style:parent-style-name">
176                                <xsl:variable name="parent-size">
177                                    <xsl:value-of select="key('paragraph-style', ../@style:parent-style-name)/style:paragraph-properties/@fo:margin-left"/>
178                                </xsl:variable>
179                                <xsl:variable name="w-number">
180                                    <xsl:call-template name="convert2twip">
181                                        <xsl:with-param name="value" select="$parent-size"/>
182                                    </xsl:call-template>
183                                </xsl:variable>
184                                <xsl:attribute name="w:left">
185                                    <xsl:value-of select="round($w-number div 100 * substring-before(@fo:margin-left, '%'))"/>
186                                </xsl:attribute>
187                            </xsl:if>
188                        </xsl:when>
189                        <xsl:otherwise>
190                            <xsl:attribute name="w:left">
191                                <xsl:call-template name="convert2twip">
192                                    <xsl:with-param name="value" select="@fo:margin-left"/>
193                                </xsl:call-template>
194                            </xsl:attribute>
195                        </xsl:otherwise>
196                    </xsl:choose>
197                </xsl:if>
198                <xsl:if test="@fo:margin-right">
199                    <xsl:choose>
200                        <xsl:when test="contains(@fo:margin-right, '%')">
201                            <xsl:if test="../@style:parent-style-name">
202                                <xsl:variable name="parent-size">
203                                    <xsl:value-of select="key('paragraph-style', ../@style:parent-style-name)/style:paragraph-properties/@fo:margin-right"/>
204                                </xsl:variable>
205                                <xsl:variable name="w-number">
206                                    <xsl:call-template name="convert2twip">
207                                        <xsl:with-param name="value" select="$parent-size"/>
208                                    </xsl:call-template>
209                                </xsl:variable>
210                                <xsl:attribute name="w:right">
211                                    <xsl:value-of select="round($w-number div 100 * substring-before(@fo:margin-right, '%'))"/>
212                                </xsl:attribute>
213                            </xsl:if>
214                        </xsl:when>
215                        <xsl:otherwise>
216                            <xsl:attribute name="w:right">
217                                <xsl:call-template name="convert2twip">
218                                    <xsl:with-param name="value" select="@fo:margin-right"/>
219                                </xsl:call-template>
220                            </xsl:attribute>
221                        </xsl:otherwise>
222                    </xsl:choose>
223                </xsl:if>
224                <xsl:if test="@fo:text-indent">
225                    <xsl:choose>
226                        <!-- When @style:auto-text-indent='true' @fo:text-indent ignored, use 283 for all font size -->
227                        <xsl:when test="@style:auto-text-indent='true'">
228                            <xsl:attribute name="w:first-line">283</xsl:attribute>
229                        </xsl:when>
230                        <xsl:when test="contains(@fo:text-indent, '%')">
231                            <xsl:if test="../@style:parent-style-name">
232                                <xsl:variable name="parent-size">
233                                    <xsl:value-of select="key('paragraph-style', ../@style:parent-style-name)/style:paragraph-properties/@fo:text-indent"/>
234                                </xsl:variable>
235                                <xsl:variable name="w-number">
236                                    <xsl:call-template name="convert2twip">
237                                        <xsl:with-param name="value" select="$parent-size"/>
238                                    </xsl:call-template>
239                                </xsl:variable>
240                                <xsl:choose>
241                                    <xsl:when test="$w-number &lt; 0">
242                                        <xsl:attribute name="w:hanging">
243                                            <xsl:value-of select="round($w-number div -100 * substring-before(@fo:text-indent, '%'))"/>
244                                        </xsl:attribute>
245                                    </xsl:when>
246                                    <xsl:otherwise>
247                                        <xsl:attribute name="w:first-line">
248                                            <xsl:value-of select="round($w-number div 100 * substring-before(@fo:text-indent, '%'))"/>
249                                        </xsl:attribute>
250                                    </xsl:otherwise>
251                                </xsl:choose>
252                            </xsl:if>
253                        </xsl:when>
254                        <xsl:when test="starts-with(@fo:text-indent,'-')">
255                            <xsl:attribute name="w:hanging">
256                                <xsl:call-template name="convert2twip">
257                                    <xsl:with-param name="value" select="substring-after(@fo:text-indent,'-')"/>
258                                </xsl:call-template>
259                            </xsl:attribute>
260                        </xsl:when>
261                        <xsl:otherwise>
262                            <xsl:attribute name="w:first-line">
263                                <xsl:call-template name="convert2twip">
264                                    <xsl:with-param name="value" select="@fo:text-indent"/>
265                                </xsl:call-template>
266                            </xsl:attribute>
267                        </xsl:otherwise>
268                    </xsl:choose>
269                </xsl:if>
270            </w:ind>
271            <xsl:if test="contains(@fo:background-color, '#')">
272                <w:shd w:val="clear" w:color="auto" w:fill="{substring-after(@fo:background-color, '#')}"/>
273            </xsl:if>
274            <xsl:if test="@fo:keep-with-next='true'">
275                <w:keepNext/>
276            </xsl:if>
277            <xsl:choose>
278                <xsl:when test="@fo:widows | @fo:orphans">
279                    <w:widowControl w:val="on"/>
280                </xsl:when>
281                <xsl:otherwise>
282                    <w:widowControl w:val="off"/>
283                </xsl:otherwise>
284            </xsl:choose>
285            <xsl:if test="@style:break-inside = 'avoid'">
286                <w:keepLines/>
287            </xsl:if>
288            <xsl:if test="@fo:hyphenate = 'false'">
289                <w:suppressAutoHyphens/>
290            </xsl:if>
291            <xsl:if test="@style:snap-to-layout-grid='false'">
292                <w:snapToGrid w:val="off"/>
293            </xsl:if>
294            <xsl:if test="style:tab-stops">
295                <w:tabs>
296                    <xsl:for-each select="style:tab-stops/style:tab-stop">
297                        <w:tab>
298                            <xsl:choose>
299                                <xsl:when test="@style:type='char'">
300                                    <xsl:attribute name="w:val">decimal</xsl:attribute>
301                                </xsl:when>
302                                <xsl:when test="@style:type">
303                                    <xsl:attribute name="w:val">
304                                        <xsl:value-of select="@style:type"/>
305                                    </xsl:attribute>
306                                </xsl:when>
307                                <xsl:otherwise>
308                                    <xsl:attribute name="w:val">left</xsl:attribute>
309                                </xsl:otherwise>
310                            </xsl:choose>
311                            <xsl:if test="@style:leader-char">
312                                <xsl:choose>
313                                    <xsl:when test="@style:leader-char='-'">
314                                        <xsl:attribute name="w:leader">hyphen</xsl:attribute>
315                                    </xsl:when>
316                                    <xsl:when test="@style:leader-char='_'">
317                                        <xsl:attribute name="w:leader">underscore</xsl:attribute>
318                                    </xsl:when>
319                                    <xsl:when test="@style:leader-char='.'">
320                                        <xsl:attribute name="w:leader">dot</xsl:attribute>
321                                    </xsl:when>
322                                    <xsl:otherwise>
323                                        <xsl:attribute name="w:leader">dot</xsl:attribute>
324                                    </xsl:otherwise>
325                                </xsl:choose>
326                            </xsl:if>
327                            <xsl:if test="@style:position">
328                                <xsl:attribute name="w:pos">
329                                    <xsl:call-template name="convert2twip">
330                                        <xsl:with-param name="value" select="@style:position"/>
331                                    </xsl:call-template>
332                                </xsl:attribute>
333                            </xsl:if>
334                        </w:tab>
335                    </xsl:for-each>
336                </w:tabs>
337            </xsl:if>
338            <xsl:if test="@style:line-break='normal'">
339                <w:kinsoku w:val="off"/>
340            </xsl:if>
341            <xsl:if test="@style:punctuation-wrap='simple'">
342                <w:overflowPunct w:val="off"/>
343            </xsl:if>
344            <xsl:if test="@style:text-autospace='none'">
345                <w:autoSpaceDE w:val="off"/>
346                <w:autoSpaceDN w:val="off"/>
347            </xsl:if>
348            <xsl:if test="@style:vertical-align">
349                <xsl:element name="w:textAlignment">
350                    <xsl:choose>
351                        <xsl:when test="@style:vertical-align='middle'">
352                            <xsl:attribute name="w:val">center</xsl:attribute>
353                        </xsl:when>
354                        <xsl:otherwise>
355                            <xsl:attribute name="w:val">
356                                <xsl:value-of select="@style:vertical-align"/>
357                            </xsl:attribute>
358                        </xsl:otherwise>
359                    </xsl:choose>
360                </xsl:element>
361            </xsl:if>
362            <xsl:if test="@text:number-lines='false'">
363                <w:supressLineNumbers/>
364            </xsl:if>
365            <xsl:variable name="border-top" select="@fo:border-top | @fo:border"/>
366            <xsl:variable name="border-bottom" select="@fo:border-bottom | @fo:border"/>
367            <xsl:variable name="border-left" select="@fo:border-left | @fo:border"/>
368            <xsl:variable name="border-right" select="@fo:border-right | @fo:border"/>
369            <xsl:variable name="border-line-width-top" select="@style:border-line-width-top | @style:border-line-width "/>
370            <xsl:variable name="border-line-width-bottom" select="@style:border-line-width-bottom | @style:border-line-width"/>
371            <xsl:variable name="border-line-width-left" select="@style:border-line-width-left | @style:border-line-width"/>
372            <xsl:variable name="border-line-width-right" select="@style:border-line-width-right | @style:border-line-width"/>
373            <xsl:variable name="padding-top" select="@fo:padding-top | @fo:padding"/>
374            <xsl:variable name="padding-bottom" select="@fo:padding-bottom | @fo:padding"/>
375            <xsl:variable name="padding-left" select="@fo:padding-left | @fo:padding"/>
376            <xsl:variable name="padding-right" select="@fo:padding-right | @fo:padding"/>
377            <w:pBdr>
378                <xsl:if test="$border-top">
379                    <xsl:element name="w:top">
380                        <xsl:call-template name="get-border">
381                            <xsl:with-param name="so-border" select="$border-top"/>
382                            <xsl:with-param name="so-border-line-width" select="$border-line-width-top"/>
383                            <xsl:with-param name="so-border-position" select=" 'top' "/>
384                        </xsl:call-template>
385                        <xsl:attribute name="w:space">
386                            <xsl:call-template name="convert2pt">
387                                <xsl:with-param name="value" select="$padding-top"/>
388                            </xsl:call-template>
389                        </xsl:attribute>
390                        <xsl:if test="@style:shadow!='none'">
391                            <xsl:attribute name="w:shadow">on</xsl:attribute>
392                        </xsl:if>
393                    </xsl:element>
394                </xsl:if>
395                <xsl:if test="$border-bottom">
396                    <xsl:element name="w:bottom">
397                        <xsl:call-template name="get-border">
398                            <xsl:with-param name="so-border" select="$border-bottom"/>
399                            <xsl:with-param name="so-border-line-width" select="$border-line-width-bottom"/>
400                            <xsl:with-param name="so-border-position" select=" 'bottom' "/>
401                        </xsl:call-template>
402                        <xsl:attribute name="w:space">
403                            <xsl:call-template name="convert2pt">
404                                <xsl:with-param name="value" select="$padding-bottom"/>
405                            </xsl:call-template>
406                        </xsl:attribute>
407                        <xsl:if test="@style:shadow!='none'">
408                            <xsl:attribute name="w:shadow">on</xsl:attribute>
409                        </xsl:if>
410                    </xsl:element>
411                </xsl:if>
412                <xsl:if test="$border-left">
413                    <xsl:element name="w:left">
414                        <xsl:call-template name="get-border">
415                            <xsl:with-param name="so-border" select="$border-left"/>
416                            <xsl:with-param name="so-border-line-width" select="$border-line-width-left"/>
417                            <xsl:with-param name="so-border-position" select=" 'left' "/>
418                        </xsl:call-template>
419                        <xsl:attribute name="w:space">
420                            <xsl:call-template name="convert2pt">
421                                <xsl:with-param name="value" select="$padding-left"/>
422                            </xsl:call-template>
423                        </xsl:attribute>
424                        <xsl:if test="@style:shadow!='none'">
425                            <xsl:attribute name="w:shadow">on</xsl:attribute>
426                        </xsl:if>
427                    </xsl:element>
428                </xsl:if>
429                <xsl:if test="$border-right">
430                    <xsl:element name="w:right">
431                        <xsl:call-template name="get-border">
432                            <xsl:with-param name="so-border" select="$border-right"/>
433                            <xsl:with-param name="so-border-line-width" select="$border-line-width-right"/>
434                            <xsl:with-param name="so-border-position" select=" 'right' "/>
435                        </xsl:call-template>
436                        <xsl:attribute name="w:space">
437                            <xsl:call-template name="convert2pt">
438                                <xsl:with-param name="value" select="$padding-right"/>
439                            </xsl:call-template>
440                        </xsl:attribute>
441                        <xsl:if test="@style:shadow!='none'">
442                            <xsl:attribute name="w:shadow">on</xsl:attribute>
443                        </xsl:if>
444                    </xsl:element>
445                </xsl:if>
446                <xsl:if test="@style:shadow!='none' and not(@fo:border-top | @fo:border-bottom | @fo:border-left | @fo:border-right | @fo:border)">
447                    <xsl:element name="w:right">
448                        <xsl:attribute name="w:shadow">on</xsl:attribute>
449                        <xsl:attribute name="w:val">single</xsl:attribute>
450                        <xsl:variable name="shadow-size">
451                            <xsl:call-template name="convert2cm">
452                                <xsl:with-param name="value" select="substring-after(substring-after(@style:shadow, ' '), ' ')"/>
453                            </xsl:call-template>
454                        </xsl:variable>
455                        <xsl:attribute name="w:sz">
456                            <xsl:choose>
457                                <xsl:when test="$shadow-size &lt;= 0.08">12</xsl:when>
458                                <xsl:when test="$shadow-size &lt;= 0.14">18</xsl:when>
459                                <xsl:when test="$shadow-size &lt;= 0.20">24</xsl:when>
460                                <xsl:when test="$shadow-size &lt;= 0.25">36</xsl:when>
461                                <xsl:otherwise>48</xsl:otherwise>
462                            </xsl:choose>
463                        </xsl:attribute>
464                    </xsl:element>
465                    <xsl:element name="w:bottom">
466                        <xsl:attribute name="w:shadow">on</xsl:attribute>
467                        <xsl:attribute name="w:val">single</xsl:attribute>
468                        <xsl:variable name="shadow-size">
469                            <xsl:call-template name="convert2cm">
470                                <xsl:with-param name="value" select="substring-after(substring-after(@style:shadow, ' '), ' ')"/>
471                            </xsl:call-template>
472                        </xsl:variable>
473                        <xsl:attribute name="w:sz">
474                            <xsl:choose>
475                                <xsl:when test="$shadow-size &lt;= 0.08">12</xsl:when>
476                                <xsl:when test="$shadow-size &lt;= 0.14">18</xsl:when>
477                                <xsl:when test="$shadow-size &lt;= 0.20">24</xsl:when>
478                                <xsl:when test="$shadow-size &lt;= 0.25">36</xsl:when>
479                                <xsl:otherwise>48</xsl:otherwise>
480                            </xsl:choose>
481                        </xsl:attribute>
482                    </xsl:element>
483                </xsl:if>
484            </w:pBdr>
485            <w:ind>
486                <xsl:if test="$padding-left!=''">
487                    <xsl:attribute name="w:left">
488                        <xsl:call-template name="convert2twip">
489                            <xsl:with-param name="value" select="$padding-left"/>
490                        </xsl:call-template>
491                    </xsl:attribute>
492                </xsl:if>
493                <xsl:if test="$padding-right!='' ">
494                    <xsl:attribute name="w:right">
495                        <xsl:call-template name="convert2twip">
496                            <xsl:with-param name="value" select="$padding-right"/>
497                        </xsl:call-template>
498                    </xsl:attribute>
499                </xsl:if>
500            </w:ind>
501            <xsl:variable name="stylename">
502                <xsl:value-of select="../@style:name"/>
503            </xsl:variable>
504            <xsl:if test="/office:document/office:body//text:h[@text:style-name = $stylename]">
505                <xsl:variable name="headinglevel">
506                    <xsl:value-of select="/office:document/office:body//text:h[@text:style-name = $stylename]/@text:level"/>
507                </xsl:variable>
508                <xsl:if test="/office:document/office:styles/text:outline-style/text:outline-level-style[@text:level = $headinglevel]">
509                    <w:listPr>
510                        <w:ilvl w:val="{$headinglevel -1}"/>
511                        <w:ilfo w:val="1"/>
512                    </w:listPr>
513                </xsl:if>
514            </xsl:if>
515        </w:pPr>
516    </xsl:template>
517    <xsl:template match="style:text-properties" mode="character">
518        <w:rPr>
519            <xsl:if test="@svg:font-family | @style:font-name | @style:font-name-asian | @style:font-name-complex">
520                <w:rFonts>
521                    <xsl:variable name="fontname">
522                        <xsl:choose>
523                            <xsl:when test='starts-with(@svg:font-family,"&apos;")'>
524                                <xsl:value-of select='substring-before(substring-after(@svg:font-family,"&apos;"),"&apos;")'/>
525                            </xsl:when>
526                            <xsl:when test="@svg:font-family">
527                                <xsl:value-of select="@svg:font-family"/>
528                            </xsl:when>
529                            <xsl:when test="@style:font-name">
530                                <xsl:value-of select="@style:font-name"/>
531                            </xsl:when>
532                        </xsl:choose>
533                    </xsl:variable>
534                    <xsl:if test="string-length($fontname)!=0">
535                        <xsl:attribute name="w:ascii">
536                            <xsl:value-of select="$fontname"/>
537                        </xsl:attribute>
538                        <xsl:attribute name="w:h-ansi">
539                            <xsl:value-of select="$fontname"/>
540                        </xsl:attribute>
541                    </xsl:if>
542                    <xsl:if test="@style:font-name-asian">
543                        <xsl:attribute name="w:fareast">
544                            <xsl:value-of select="@style:font-name-asian"/>
545                        </xsl:attribute>
546                    </xsl:if>
547                    <xsl:if test="@style:font-name-complex">
548                        <xsl:attribute name="w:cs">
549                            <xsl:value-of select="@style:font-name-complex"/>
550                        </xsl:attribute>
551                    </xsl:if>
552                </w:rFonts>
553            </xsl:if>
554            <!-- relative font sizes not supported yet. -->
555            <xsl:if test="contains(@fo:font-size, 'pt')">
556                <w:sz w:val="{substring-before(@fo:font-size,'pt') * 2}"/>
557            </xsl:if>
558            <xsl:if test="contains(@fo:font-size-complex, 'pt')">
559                <w:sz-cs w:val="{substring-before(@fo:font-size-complex, 'pt') * 2}"/>
560            </xsl:if>
561            <xsl:if test="@fo:font-style = 'italic' or @fo:font-style-asian = 'italic'">
562                <w:i/>
563            </xsl:if>
564            <xsl:if test="@fo:font-style-complex = 'italic'">
565                <w:i-cs/>
566            </xsl:if>
567            <xsl:if test="@fo:font-weight = 'bold' or @fo:font-weight-asian = 'bold'">
568                <w:b/>
569            </xsl:if>
570            <xsl:if test="@fo:font-weight-complex = 'bold'">
571                <w:b-cs/>
572            </xsl:if>
573            <xsl:if test="@style:text-underline-style">
574                <w:u>
575                    <xsl:variable name="w-u">
576                        <xsl:choose>
577                            <xsl:when test="@style:text-underline-style = 'solid'">
578                                <xsl:choose>
579                                    <xsl:when test="@style:text-underline-type = 'double'">double</xsl:when>
580                                    <xsl:when test="@style:text-underline-width = 'bold'">thick</xsl:when>
581                                    <xsl:otherwise>single</xsl:otherwise>
582                                </xsl:choose>
583                            </xsl:when>
584                            <xsl:when test="@style:text-underline-style = 'dotted'">
585                                <xsl:choose>
586                                    <xsl:when test="@style:text-underline-type = 'double'">dotted-double</xsl:when>
587                                    <xsl:when test="@style:text-underline-width = 'bold'">dotted-heavy</xsl:when>
588                                    <xsl:otherwise>dotted</xsl:otherwise>
589                                </xsl:choose>
590                            </xsl:when>
591                            <xsl:when test="@style:text-underline-style = 'dash'">
592                                <xsl:choose>
593                                    <xsl:when test="@style:text-underline-type = 'double'">dashed-double</xsl:when>
594                                    <xsl:when test="@style:text-underline-width = 'bold'">dashed-heavy</xsl:when>
595                                    <xsl:otherwise>dash</xsl:otherwise>
596                                </xsl:choose>
597                            </xsl:when>
598                            <xsl:when test="@style:text-underline-style = 'long-dash'">
599                                <xsl:choose>
600                                    <xsl:when test="@style:text-underline-type = 'double'">dash-long-double</xsl:when>
601                                    <xsl:when test="@style:text-underline-width = 'bold'">dash-long-heavy</xsl:when>
602                                    <xsl:otherwise>dash-long</xsl:otherwise>
603                                </xsl:choose>
604                            </xsl:when>
605                            <xsl:when test="@style:text-underline-style = 'dot-dash'">
606                                <xsl:choose>
607                                    <xsl:when test="@style:text-underline-type = 'double'">dot-dash-double</xsl:when>
608                                    <xsl:when test="@style:text-underline-width = 'bold'">dash-dot-heavy</xsl:when>
609                                    <xsl:otherwise>dot-dash</xsl:otherwise>
610                                </xsl:choose>
611                            </xsl:when>
612                            <xsl:when test="@style:text-underline-style = 'dot-dot-dash'">
613                                <xsl:choose>
614                                    <xsl:when test="@style:text-underline-type = 'double'">dot-dot-dash-double</xsl:when>
615                                    <xsl:when test="@style:text-underline-width = 'bold'">dash-dot-dot-heavy</xsl:when>
616                                    <xsl:otherwise>dot-dot-dash</xsl:otherwise>
617                                </xsl:choose>
618                            </xsl:when>
619                            <xsl:when test="@style:text-underline-style = 'wave'">
620                                <xsl:choose>
621                                    <xsl:when test="@style:text-underline-type = 'double'">wavy-double</xsl:when>
622                                    <xsl:when test="@style:text-underline-width = 'bold'">wavy-heavy</xsl:when>
623                                    <xsl:otherwise>wave</xsl:otherwise>
624                                </xsl:choose>
625                            </xsl:when>
626                            <xsl:otherwise>
627                                <xsl:value-of select="@style:text-underline-style"/>
628                            </xsl:otherwise>
629                        </xsl:choose>
630                    </xsl:variable>
631                    <xsl:attribute name="w:val">
632                        <xsl:value-of select="$w-u"/>
633                    </xsl:attribute>
634                    <xsl:if test="contains(@style:text-underline-color,'#')">
635                        <xsl:attribute name="w:color">
636                            <xsl:value-of select="substring-after(@style:text-underline-color,'#')"/>
637                        </xsl:attribute>
638                    </xsl:if>
639                </w:u>
640            </xsl:if>
641            <xsl:if test="@style:text-shadow | @fo:text-shadow">
642                <w:shadow/>
643            </xsl:if>
644            <xsl:if test="string-length(@style:text-line-through-style) &gt; 0">
645                <xsl:choose>
646                    <xsl:when test="@style:text-line-through-type = 'double'">
647                        <w:dstrike/>
648                    </xsl:when>
649                    <xsl:when test="@style:text-line-through-style = 'solid'">
650                        <w:strike/>
651                    </xsl:when>
652                    <xsl:otherwise>
653                        <w:strike/>
654                    </xsl:otherwise>
655                </xsl:choose>
656            </xsl:if>
657            <xsl:if test="@fo:color">
658                <w:color>
659                    <xsl:choose>
660                        <xsl:when test="@fo:color != '#000000'">
661                            <xsl:attribute name="w:val">
662                                <xsl:value-of select="substring-after(@fo:color,'#')"/>
663                            </xsl:attribute>
664                        </xsl:when>
665                        <xsl:otherwise>
666                            <xsl:attribute name="w:val">auto</xsl:attribute>
667                        </xsl:otherwise>
668                    </xsl:choose>
669                </w:color>
670            </xsl:if>
671            <xsl:if test="@fo:font-variant = 'small-caps'">
672                <w:smallCaps/>
673            </xsl:if>
674            <xsl:if test="@fo:text-transform = 'uppercase'">
675                <w:caps/>
676            </xsl:if>
677            <xsl:if test="@style:font-relief = 'engraved'">
678                <w:imprint/>
679            </xsl:if>
680            <xsl:if test="@style:font-relief = 'embossed'">
681                <w:emboss/>
682            </xsl:if>
683            <xsl:if test="@style:text-outline = 'true'">
684                <w:outline/>
685            </xsl:if>
686            <xsl:if test="contains(@style:text-scale,'%')">
687                <w:w w:val="{substring-before(@style:text-scale,'%')}"/>
688            </xsl:if>
689            <xsl:if test="@style:text-emphasize">
690                <w:em>
691                    <xsl:choose>
692                        <xsl:when test="contains(@style:text-emphasize, 'accent')">
693                            <xsl:attribute name="w:val">comma</xsl:attribute>
694                        </xsl:when>
695                        <xsl:when test="contains(@style:text-emphasize, 'disc')">
696                            <xsl:attribute name="w:val">under-dot</xsl:attribute>
697                        </xsl:when>
698                        <xsl:when test="contains(@style:text-emphasize, 'none')">
699                            <xsl:attribute name="w:val">none</xsl:attribute>
700                        </xsl:when>
701                        <xsl:when test="contains(@style:text-emphasize, 'dot below')">
702                            <xsl:attribute name="w:val">under-dot</xsl:attribute>
703                        </xsl:when>
704                        <xsl:when test="contains(@style:text-emphasize, 'dot above')">
705                            <xsl:attribute name="w:val">dot</xsl:attribute>
706                        </xsl:when>
707                        <xsl:when test="contains(@style:text-emphasize, 'circle')">
708                            <xsl:attribute name="w:val">dot</xsl:attribute>
709                        </xsl:when>
710                    </xsl:choose>
711                </w:em>
712            </xsl:if>
713            <xsl:if test="@fo:letter-spacing != 'normal'">
714                <w:spacing>
715                    <xsl:attribute name="w:val">
716                        <xsl:call-template name="convert2twip">
717                            <xsl:with-param name="value" select="@fo:letter-spacing"/>
718                        </xsl:call-template>
719                    </xsl:attribute>
720                </w:spacing>
721            </xsl:if>
722            <xsl:if test="@style:text-blinking = 'true'">
723                <w:effect w:val="blink-background"/>
724            </xsl:if>
725            <xsl:if test="@fo:language | @fo:language-asian | @fo:language-complex">
726                <w:lang>
727                    <xsl:if test="@fo:language and @fo:country">
728                        <xsl:attribute name="w:val">
729                            <xsl:value-of select="concat(@fo:language, '-', @fo:country)"/>
730                        </xsl:attribute>
731                    </xsl:if>
732                    <xsl:if test="@fo:language-asian and @fo:country-asian">
733                        <xsl:attribute name="w:fareast">
734                            <xsl:value-of select="concat(@fo:language-asian, '-', @fo:country-asian)"/>
735                        </xsl:attribute>
736                    </xsl:if>
737                    <xsl:if test="@fo:language-complex and @fo:language-complex">
738                        <xsl:attribute name="w:bidi">
739                            <xsl:value-of select="concat(@fo:language-complex, '-', @fo:language-complex)"/>
740                        </xsl:attribute>
741                    </xsl:if>
742                </w:lang>
743            </xsl:if>
744            <xsl:if test="@style:text-position">
745                <xsl:variable name="position">
746                    <xsl:choose>
747                        <xsl:when test="starts-with(@style:text-position, 'super')">superscript_0</xsl:when>
748                        <xsl:when test="starts-with(@style:text-position, 'sub')">subscript_0</xsl:when>
749                        <xsl:when test="starts-with(@style:text-position, '-')">
750                            <xsl:value-of select="concat('subscript_', substring-before(@style:text-position,'%'))"/>
751                        </xsl:when>
752                        <xsl:otherwise>
753                            <xsl:value-of select="concat('superscript_', substring-before(@style:text-position,'%'))"/>
754                        </xsl:otherwise>
755                    </xsl:choose>
756                </xsl:variable>
757                <w:vertAlign>
758                    <xsl:attribute name="w:val">
759                        <xsl:value-of select="substring-before($position,'_')"/>
760                    </xsl:attribute>
761                </w:vertAlign>
762                <!-- Raised/Lowed position is difficult to map to MSWord w:position, Writer use %, but Word use half-point(not relative position). Since it's difficult to get font-size, use 12pt as default font-size -->
763                <w:position>
764                    <xsl:attribute name="w:val">
765                        <xsl:choose>
766                            <xsl:when test="substring-after($position, '_') = 0">0</xsl:when>
767                            <xsl:otherwise>
768                                <xsl:value-of select="round(substring-after($position, '_') div 6)"/>
769                            </xsl:otherwise>
770                        </xsl:choose>
771                    </xsl:attribute>
772                </w:position>
773            </xsl:if>
774            <xsl:if test="@text:display = 'true'">
775                <w:vanish/>
776            </xsl:if>
777            <xsl:if test="contains(@fo:background-color, '#')">
778                <w:shd w:val="clear" w:color="auto" w:fill="{substring-after(@fo:background-color, '#')}"/>
779            </xsl:if>
780        </w:rPr>
781    </xsl:template>
782    <xsl:template match="text:p | text:h">
783        <w:p>
784            <w:pPr>
785                <xsl:if test="@text:style-name">
786                    <w:pStyle w:val="{@text:style-name}"/>
787                </xsl:if>
788                <xsl:if test="@text:level">
789                    <w:outlineLvl w:val="{@text:level - 1}"/>
790                </xsl:if>
791                <xsl:variable name="following-paragraph-heading-table" select="following::*[(name()= 'text:p' or name()= 'text:h' or name()= 'table:table')]"/>
792                <xsl:variable name="following-section" select="following::text:section[1]"/>
793                <xsl:variable name="ancestor-section" select="ancestor::text:section"/>
794                <!-- if the following neighbour paragraph/heading are slave of one master style, or new section starts,
795				 then a new page will start -->
796                <xsl:variable name="next-is-new-page" select="boolean(key( 'slave-style', $following-paragraph-heading-table[1]/@*[name()='text:style-name' or name()='table:style-name']))"/>
797                <xsl:variable name="next-is-new-section">
798                    <xsl:if test="$following-section and generate-id($following-section/descendant::*[(name()= 'text:p' or name()= 'text:h' or name()= 'table:table') and position() =1]) = generate-id($following-paragraph-heading-table[1])">
799                        <xsl:value-of select="'yes'"/>
800                    </xsl:if>
801                </xsl:variable>
802                <xsl:variable name="next-is-section-end">
803                    <xsl:if test="$ancestor-section and generate-id($ancestor-section[1]/following::*[(name()= 'text:p' or name()= 'text:h' or name()= 'table:table') and position() =1]) = generate-id($following-paragraph-heading-table[1])">
804                        <xsl:value-of select="'yes'"/>
805                    </xsl:if>
806                </xsl:variable>
807                <xsl:if test="ancestor::office:body and not(ancestor::text:footnote or ancestor::text:endnote) and ($next-is-new-page or $next-is-new-section = 'yes' or $next-is-section-end = 'yes')">
808                    <w:sectPr>
809                        <xsl:apply-templates select="/office:document/office:styles/text:footnotes-configuration">
810                            <xsl:with-param name="within-section" select="'yes'"/>
811                        </xsl:apply-templates>
812                        <xsl:apply-templates select="/office:document/office:styles/text:endnotes-configuration">
813                            <xsl:with-param name="within-section" select="'yes'"/>
814                        </xsl:apply-templates>
815                        <xsl:choose>
816                            <xsl:when test="key( 'slave-style', @*[name()='text:style-name' or name()='table:style-name'])">
817                                <xsl:apply-templates select="key('master-page', key( 'slave-style', @*[name()='text:style-name' or name()='table:style-name'])[1]/@style:master-page-name)"/>
818                                <xsl:if test="$ancestor-section">
819                                    <xsl:apply-templates select="key('section-style',$ancestor-section[1]/@text:style-name)" mode="section">
820                                        <xsl:with-param name="master-page" select="key( 'page-layout', key('master-page', key( 'slave-style', @*[name()='text:style-name' or name()='table:style-name'])[1]/@style:master-page-name)/@style:page-layout-name)"/>
821                                    </xsl:apply-templates>
822                                </xsl:if>
823                                <xsl:if test="key( 'slave-style', @*[name()='text:style-name' or name()='table:style-name'])/style:paragraph-properties/@style:page-number">
824                                    <!-- in M$ word the header and footer associate with the w:sectPr, but in StarOffice writer the header and footer associate with the style:master-page -->
825                                    <xsl:variable name="pagenumber_start">
826                                        <xsl:value-of select=" key( 'slave-style', @*[name()='text:style-name' or name()='table:style-name'])/style:paragraph-properties/@style:page-number"/>
827                                    </xsl:variable>
828                                    <xsl:if test=" number($pagenumber_start)  &gt; 0 ">
829                                        <w:pgNumType w:start="{$pagenumber_start}"/>
830                                    </xsl:if>
831                                    <!-- comment out the below line to enable the header and footer display normally when style:page-number =0  -->
832                                    <!--w:pgNumType w:start="{key( 'slave-style', @*[name()='text:style-name' or name()='table:style-name'])/style:paragraph-properties/@style:page-number}"/ -->
833                                </xsl:if>
834                            </xsl:when>
835                            <xsl:otherwise>
836                                <xsl:variable name="preceding-style" select="preceding::*[(name()= 'text:p' or name()= 'text:h' or name()= 'table:table') and key( 'slave-style', @*[name()='text:style-name' or name()='table:style-name'])]"/>
837                                <xsl:choose>
838                                    <xsl:when test="$preceding-style">
839                                        <xsl:apply-templates select="key('master-page', key( 'slave-style', $preceding-style[1]/@*[name()='text:style-name' or name()='table:style-name'])[1]/@style:master-page-name)"/>
840                                    </xsl:when>
841                                    <xsl:otherwise>
842                                        <xsl:apply-templates select="/office:document/office:master-styles/style:master-page[1]"/>
843                                    </xsl:otherwise>
844                                </xsl:choose>
845                                <xsl:if test="$ancestor-section">
846                                    <xsl:choose>
847                                        <xsl:when test="$preceding-style">
848                                            <xsl:apply-templates select="key('section-style',$ancestor-section[1]/@text:style-name)" mode="section">
849                                                <xsl:with-param name="master-page" select="key( 'page-layout', key('master-page', key( 'slave-style', $preceding-style[1]/@*[name()='text:style-name' or name()='table:style-name'])[1]/@style:master-page-name)/@style:page-layout-name)"/>
850                                            </xsl:apply-templates>
851                                        </xsl:when>
852                                        <xsl:otherwise>
853                                            <xsl:apply-templates select="key('section-style',$ancestor-section[1]/@text:style-name)" mode="section">
854                                                <xsl:with-param name="master-page" select="/office:document/office:automatic-styles/style:page-layout[1]"/>
855                                            </xsl:apply-templates>
856                                        </xsl:otherwise>
857                                    </xsl:choose>
858                                </xsl:if>
859                            </xsl:otherwise>
860                        </xsl:choose>
861                    </w:sectPr>
862                </xsl:if>
863                <!-- add for office:annotation style G.Y. -->
864                <xsl:if test="name(..)= 'office:annotation' ">
865                    <w:pStyle w:val="CommentText"/>
866                </xsl:if>
867                <!-- add by wym for listPr -->
868                <xsl:if test="ancestor::text:ordered-list | ancestor::text:unordered-list | ancestor::text:list">
869                    <xsl:variable name="listname">
870                        <xsl:value-of select="ancestor::text:ordered-list/@text:style-name | ancestor::text:unordered-list/@text:style-name  | ancestor::text:list/@text:style-name"/>
871                    </xsl:variable>
872                    <xsl:variable name="currlevel">
873                        <xsl:value-of select="count(ancestor::text:list-item|ancestor::text:list-header)"/>
874                    </xsl:variable>
875                    <xsl:choose>
876                        <xsl:when test="string-length($listname)!=0 and $currlevel &lt; 10">
877                            <xsl:variable name="currlist">
878                                <xsl:apply-templates select="key('list-style', $listname)" mode="count"/>
879                            </xsl:variable>
880                            <w:listPr>
881                                <w:ilvl w:val="{number($currlevel)-1}"/>
882                                <w:ilfo w:val="{$currlist}"/>
883                            </w:listPr>
884                        </xsl:when>
885                        <xsl:when test="string-length($listname)!=0">
886                            <xsl:for-each select="key('list-style', $listname)">
887                                <xsl:variable name="spacebefore">
888                                    <xsl:choose>
889                                        <xsl:when test="*[@text:level=$currlevel]/style:list-level-properties/@text:space-before">
890                                            <xsl:call-template name="convert2twip">
891                                                <xsl:with-param name="value" select="*[@text:level=$currlevel]/style:list-level-properties/@text:space-before"/>
892                                            </xsl:call-template>
893                                        </xsl:when>
894                                        <xsl:otherwise>0</xsl:otherwise>
895                                    </xsl:choose>
896                                </xsl:variable>
897                                <xsl:variable name="space2text">
898                                    <xsl:choose>
899                                        <xsl:when test="*[@text:level=$currlevel]/style:list-level-properties/@text:min-label-width">
900                                            <xsl:call-template name="convert2twip">
901                                                <xsl:with-param name="value" select="*[@text:level=$currlevel]/style:list-level-properties/@text:min-label-width"/>
902                                            </xsl:call-template>
903                                        </xsl:when>
904                                        <xsl:otherwise>0</xsl:otherwise>
905                                    </xsl:choose>
906                                </xsl:variable>
907                                <w:ind w:left="{number($space2text)+number($spacebefore)}" w:hanging="{$space2text}"/>
908                            </xsl:for-each>
909                        </xsl:when>
910                        <xsl:otherwise>
911                            <w:listPr>
912                                <w:ilvl w:val="{number($currlevel)-1}"/>
913                                <w:ilfo w:val="1"/>
914                            </w:listPr>
915                        </xsl:otherwise>
916                    </xsl:choose>
917                </xsl:if>
918                <!-- end of listPr -->
919            </w:pPr>
920            <!-- get break column from style -->
921            <xsl:variable name="style" select="key('paragraph-style', @text:style-name)/style:paragraph-properties"/>
922            <xsl:if test="$style/@fo:break-before = 'column'">
923                <w:r>
924                    <w:br w:type="column"/>
925                </w:r>
926            </xsl:if>
927            <xsl:if test="parent::office:text and not(preceding-sibling::text:p)">
928                <xsl:call-template name="PageLevelGraphic"/>
929            </xsl:if>
930            <xsl:if test="parent::text:footnote-body and not(preceding-sibling::*)">
931                <w:r>
932                    <w:rPr>
933                        <w:rStyle w:val="{/office:document/office:styles/text:footnotes-configuration/@text:citation-style-name}"/>
934                    </w:rPr>
935                    <xsl:choose>
936                        <xsl:when test="../../text:footnote-citation/@text:label">
937                            <w:t>
938                                <xsl:value-of select="../../text:footnote-citation/@text:label"/>
939                            </w:t>
940                        </xsl:when>
941                        <xsl:otherwise>
942                            <w:footnoteRef/>
943                        </xsl:otherwise>
944                    </xsl:choose>
945                </w:r>
946                <w:r>
947                    <w:tab/>
948                </w:r>
949            </xsl:if>
950            <xsl:if test="parent::text:endnote-body and not(preceding-sibling::*)">
951                <w:r>
952                    <w:rPr>
953                        <w:rStyle w:val="{/office:document/office:styles/text:endnotes-configuration/@text:citation-style-name}"/>
954                    </w:rPr>
955                    <xsl:choose>
956                        <xsl:when test="../../text:endnote-citation/@text:label">
957                            <w:t>
958                                <xsl:value-of select="../../text:endnote-citation/@text:label"/>
959                            </w:t>
960                        </xsl:when>
961                        <xsl:otherwise>
962                            <w:endnoteRef/>
963                        </xsl:otherwise>
964                    </xsl:choose>
965                </w:r>
966                <w:r>
967                    <w:tab/>
968                </w:r>
969            </xsl:if>
970            <!-- newly added the endnote , footnote templates -->
971            <xsl:if test="../../@text:note-class='endnote'  and not(preceding-sibling::*)">
972                <xsl:message>
973                    <xsl:value-of select=" 'enter into ext:note-class= endnote' "/>
974                </xsl:message>
975                <w:r>
976                    <w:rPr>
977                        <w:rStyle w:val="Endnote_20_Symbol"/>
978                    </w:rPr>
979                    <xsl:choose>
980                        <xsl:when test="../../text:note-citation/@text:label">
981                            <w:t>
982                                <xsl:value-of select="../../text:note-citation/@text:label"/>
983                            </w:t>
984                        </xsl:when>
985                        <xsl:otherwise>
986                            <w:footnoteRef/>
987                        </xsl:otherwise>
988                    </xsl:choose>
989                </w:r>
990                <w:r>
991                    <w:tab/>
992                </w:r>
993            </xsl:if>
994            <xsl:if test="../../@text:note-class='footnote'  and not(preceding-sibling::*)">
995                <xsl:message>
996                    <xsl:value-of select=" 'enter into ext:note-class= footnote' "/>
997                </xsl:message>
998                <w:r>
999                    <w:rPr>
1000                        <w:rStyle w:val="Footnote_20_Symbol"/>
1001                    </w:rPr>
1002                    <xsl:choose>
1003                        <xsl:when test="../../text:note-citation/@text:label">
1004                            <w:t>
1005                                <xsl:value-of select="../../text:note-citation/@text:label"/>
1006                            </w:t>
1007                        </xsl:when>
1008                        <xsl:otherwise>
1009                            <w:footnoteRef/>
1010                        </xsl:otherwise>
1011                    </xsl:choose>
1012                </w:r>
1013                <w:r>
1014                    <w:tab/>
1015                </w:r>
1016            </xsl:if>
1017            <!-- apply inline-text-elements, many many many ... :( glu -->
1018            <xsl:apply-templates select="text:a | text:span | text() | text:hidden-text | text:line-break | text:tab-stop
1019             | text:s | text:note  | draw:*
1020             | text:page-number | text:page-count | text:subject | text:initial-creator | text:title | text:date | text:time
1021             | text:author-name | text:author-initials | text:chapter | text:file-name | text:sender-company
1022             | text:sender-firstname | text:sender-lastname | text:sender-initials | text:sender-street
1023             | text:sender-country | text:sender-postal-code | text:sender-city | text:sender-title | text:sender-position
1024             | text:sender-phone-private | text:sender-phone-work | text:sender-email | text:sender-fax
1025             | text:sender-state-or-province | text:word-count | text:paragraph-count | text:character-count
1026             | text:table-count | text:image-count | text:object-count | text:template-name | text:description
1027             | text:creation-time | text:creation-date | text:editing-cycles | text:editing-duration | text:keywords
1028             | text:print-time | text:print-date | text:creator | text:modification-time | text:modification-date
1029             | text:user-defined | text:printed-by | text:hidden-paragraph  | text:placeholder | text:drop-down
1030             | text:conditional-text  | text:text-input | text:execute-macro | text:variable-set | text:variable-input
1031             | text:user-field-input | text:variable-get | text:user-field-get | text:sequence | text:page-variable-set
1032             | text:page-variable-get | text:table-formula | text:database-display | text:database-next
1033             | text:database-select | text:database-row-number | text:database-name | text:reference-ref
1034             | text:bookmark-ref | text:footnote-ref  | text:endnote-ref | text:sequence-ref | text:expression
1035             | text:measure | text:dde-connection | text:sheet-name | text:bibliography-mark | text:script
1036             | text:page-continuation | office:annotation | text:bookmark-start | text:bookmark-end | text:bookmark
1037 "/>
1038            <!-- comment out the following line to replace the text:footnote , text:endnote with text:note in OASIS format -->
1039            <!--xsl:apply-templates select="text:a | text:span | text() | text:hidden-text | text:line-break | text:tab-stop
1040             | text:s | text:footnote | text:endnote | draw:*
1041             | text:page-number | text:page-count | text:subject | text:initial-creator | text:title | text:date | text:time
1042             | text:author-name | text:author-initials | text:chapter | text:file-name | text:sender-company
1043             | text:sender-firstname | text:sender-lastname | text:sender-initials | text:sender-street
1044             | text:sender-country | text:sender-postal-code | text:sender-city | text:sender-title | text:sender-position
1045             | text:sender-phone-private | text:sender-phone-work | text:sender-email | text:sender-fax
1046             | text:sender-state-or-province | text:word-count | text:paragraph-count | text:character-count
1047             | text:table-count | text:image-count | text:object-count | text:template-name | text:description
1048             | text:creation-time | text:creation-date | text:editing-cycles | text:editing-duration | text:keywords
1049             | text:print-time | text:print-date | text:creator | text:modification-time | text:modification-date
1050             | text:user-defined | text:printed-by | text:hidden-paragraph  | text:placeholder | text:drop-down
1051             | text:conditional-text  | text:text-input | text:execute-macro | text:variable-set | text:variable-input
1052             | text:user-field-input | text:variable-get | text:user-field-get | text:sequence | text:page-variable-set
1053             | text:page-variable-get | text:table-formula | text:database-display | text:database-next
1054             | text:database-select | text:database-row-number | text:database-name | text:reference-ref
1055             | text:bookmark-ref | text:footnote-ref  | text:endnote-ref | text:sequence-ref | text:expression
1056             | text:measure | text:dde-connection | text:sheet-name | text:bibliography-mark | text:script
1057             | text:page-continuation | office:annotation | text:bookmark-start | text:bookmark-end | text:bookmark
1058 "/-->
1059            <xsl:if test="$style/@fo:break-after">
1060                <w:r>
1061                    <w:br w:type="{$style/@fo:break-after}"/>
1062                </w:r>
1063            </xsl:if>
1064        </w:p>
1065    </xsl:template>
1066    <xsl:template match="text:span">
1067        <!-- apply inline-text-elements, many many many ... :( glu -->
1068        <xsl:apply-templates select="text:a | text() | text:hidden-text | text:line-break | text:tab-stop | text:s
1069             | text:note
1070             | text:page-number | text:page-count | text:subject | text:initial-creator | text:title | text:date | text:time
1071             | text:author-name | text:author-initials | text:chapter | text:file-name | text:sender-company
1072             | text:sender-firstname | text:sender-lastname | text:sender-initials | text:sender-street
1073             | text:sender-country | text:sender-postal-code | text:sender-city | text:sender-title | text:sender-position
1074             | text:sender-phone-private | text:sender-phone-work | text:sender-email | text:sender-fax
1075             | text:sender-state-or-province | text:word-count | text:paragraph-count | text:character-count
1076             | text:table-count | text:image-count | text:object-count | text:template-name | text:description
1077             | text:creation-time | text:creation-date | text:editing-cycles | text:editing-duration | text:keywords
1078             | text:print-time | text:print-date | text:creator | text:modification-time | text:modification-date
1079             | text:user-defined | text:printed-by | text:hidden-paragraph  | text:placeholder | text:drop-down
1080             | text:conditional-text  | text:text-input | text:execute-macro | text:variable-set | text:variable-input
1081             | text:user-field-input | text:variable-get | text:user-field-get | text:sequence | text:page-variable-set
1082             | text:page-variable-get | text:table-formula | text:database-display | text:database-next
1083             | text:database-select | text:database-row-number | text:database-name | text:reference-ref
1084             | text:bookmark-ref | text:footnote-ref  | text:endnote-ref | text:sequence-ref | text:expression
1085             | text:measure | text:dde-connection | text:sheet-name | text:bibliography-mark | text:script
1086             | text:page-continuation | office:annotation | text:bookmark-start | text:bookmark-end | text:bookmark
1087"/>
1088        <!-- comment out the following line to replace the text:footnote , text:endnote with text:note in OASIS format -->
1089        <!-- xsl:apply-templates select="text:a | text() | text:hidden-text | text:line-break | text:tab-stop | text:s
1090             | text:footnote | text:endnote
1091             | text:page-number | text:page-count | text:subject | text:initial-creator | text:title | text:date | text:time
1092             | text:author-name | text:author-initials | text:chapter | text:file-name | text:sender-company
1093             | text:sender-firstname | text:sender-lastname | text:sender-initials | text:sender-street
1094             | text:sender-country | text:sender-postal-code | text:sender-city | text:sender-title | text:sender-position
1095             | text:sender-phone-private | text:sender-phone-work | text:sender-email | text:sender-fax
1096             | text:sender-state-or-province | text:word-count | text:paragraph-count | text:character-count
1097             | text:table-count | text:image-count | text:object-count | text:template-name | text:description
1098             | text:creation-time | text:creation-date | text:editing-cycles | text:editing-duration | text:keywords
1099             | text:print-time | text:print-date | text:creator | text:modification-time | text:modification-date
1100             | text:user-defined | text:printed-by | text:hidden-paragraph  | text:placeholder | text:drop-down
1101             | text:conditional-text  | text:text-input | text:execute-macro | text:variable-set | text:variable-input
1102             | text:user-field-input | text:variable-get | text:user-field-get | text:sequence | text:page-variable-set
1103             | text:page-variable-get | text:table-formula | text:database-display | text:database-next
1104             | text:database-select | text:database-row-number | text:database-name | text:reference-ref
1105             | text:bookmark-ref | text:footnote-ref  | text:endnote-ref | text:sequence-ref | text:expression
1106             | text:measure | text:dde-connection | text:sheet-name | text:bibliography-mark | text:script
1107             | text:page-continuation | office:annotation | text:bookmark-start | text:bookmark-end | text:bookmark
1108"/-->
1109    </xsl:template>
1110    <xsl:template match="text()">
1111        <xsl:if test="string-length(normalize-space(.)) &gt; 0">
1112            <w:r>
1113                <xsl:if test="parent::text:span">
1114                    <w:rPr>
1115                        <w:rStyle w:val="{parent::text:span/@text:style-name}"/>
1116                    </w:rPr>
1117                </xsl:if>
1118                <w:t>
1119                    <xsl:value-of select="."/>
1120                </w:t>
1121            </w:r>
1122        </xsl:if>
1123    </xsl:template>
1124    <xsl:template match="text:hidden-text">
1125        <w:r>
1126            <w:rPr>
1127                <xsl:if test="parent::text:span">
1128                    <w:rStyle w:val="{parent::text:span/@text:style-name}"/>
1129                </xsl:if>
1130                <w:vanish/>
1131            </w:rPr>
1132            <w:t>
1133                <xsl:value-of select="@text:string-value"/>
1134            </w:t>
1135        </w:r>
1136    </xsl:template>
1137    <xsl:template match="text:line-break">
1138        <w:r>
1139            <xsl:if test="parent::text:span">
1140                <w:rPr>
1141                    <w:rStyle w:val="{parent::text:span/@text:style-name}"/>
1142                </w:rPr>
1143            </xsl:if>
1144            <w:br w:type="text-wrapping" w:clear="all"/>
1145        </w:r>
1146    </xsl:template>
1147    <xsl:template match="text:tab-stop">
1148        <w:r>
1149            <xsl:if test="parent::text:span">
1150                <w:rPr>
1151                    <w:rStyle w:val="{parent::text:span/@text:style-name}"/>
1152                </w:rPr>
1153            </xsl:if>
1154            <w:tab/>
1155        </w:r>
1156    </xsl:template>
1157    <xsl:template match="text:s">
1158        <w:r>
1159            <xsl:if test="parent::text:span">
1160                <w:rPr>
1161                    <w:rStyle w:val="{parent::text:span/@text:style-name}"/>
1162                </w:rPr>
1163            </xsl:if>
1164            <w:t>
1165                <xsl:if test="@text:c">
1166                    <xsl:call-template name="add-space">
1167                        <xsl:with-param name="number" select="@text:c"/>
1168                    </xsl:call-template>
1169                </xsl:if>
1170                <xsl:text> </xsl:text>
1171            </w:t>
1172        </w:r>
1173    </xsl:template>
1174    <xsl:template name="add-space">
1175        <xsl:param name="number"/>
1176        <xsl:if test="$number &gt; 1">
1177            <xsl:call-template name="add-space">
1178                <xsl:with-param name="number" select="$number - 1"/>
1179            </xsl:call-template>
1180            <xsl:text> </xsl:text>
1181        </xsl:if>
1182    </xsl:template>
1183    <xsl:template match="text:footnote">
1184        <w:r>
1185            <w:rPr>
1186                <w:rStyle w:val="{/office:document/office:styles/text:footnotes-configuration/@text:citation-body-style-name}"/>
1187            </w:rPr>
1188            <xsl:apply-templates select="text:footnote-body"/>
1189        </w:r>
1190    </xsl:template>
1191    <xsl:template match="text:footnote-body">
1192        <w:footnote>
1193            <xsl:if test="../text:footnote-citation/@text:label">
1194                <xsl:attribute name="w:suppressRef">on</xsl:attribute>
1195            </xsl:if>
1196            <xsl:apply-templates select="text:h | text:p | text:ordered-list | text:unordered-list | text:list"/>
1197        </w:footnote>
1198    </xsl:template>
1199    <xsl:template match="text:endnote">
1200        <w:r>
1201            <w:rPr>
1202                <w:rStyle w:val="{/office:document/office:styles/text:endnotes-configuration/@text:citation-body-style-name}"/>
1203            </w:rPr>
1204            <xsl:apply-templates select="text:endnote-body"/>
1205        </w:r>
1206    </xsl:template>
1207    <xsl:template match="text:endnote-body">
1208        <w:endnote>
1209            <xsl:if test="../text:endnote-citation/@text:label">
1210                <xsl:attribute name="w:suppressRef">on</xsl:attribute>
1211            </xsl:if>
1212            <xsl:apply-templates select="text:h | text:p | text:ordered-list | text:unordered-list | text:list"/>
1213        </w:endnote>
1214    </xsl:template>
1215    <xsl:template match="text:bookmark-start">
1216        <xsl:variable name="bookmark-id">
1217            <xsl:number from="/office:document/office:body" count="text:bookmark | text:bookmark-start" level="any" format="1"/>
1218        </xsl:variable>
1219        <aml:annotation aml:id="{$bookmark-id}" w:type="Word.Bookmark.Start" w:name="{@text:name}"/>
1220    </xsl:template>
1221    <xsl:template match="text:bookmark-end">
1222        <xsl:variable name="bookmark-id">
1223            <xsl:number from="/office:document/office:body" count="text:bookmark | text:bookmark-start" level="any" format="1"/>
1224        </xsl:variable>
1225        <aml:annotation aml:id="{$bookmark-id}" w:type="Word.Bookmark.End"/>
1226    </xsl:template>
1227    <xsl:template match="text:bookmark">
1228        <xsl:variable name="bookmark-id">
1229            <xsl:number from="/office:document/office:body" count="text:bookmark | text:bookmark-start" level="any" format="1"/>
1230        </xsl:variable>
1231        <aml:annotation aml:id="{$bookmark-id}" w:type="Word.Bookmark.Start" w:name="{@text:name}"/>
1232        <aml:annotation aml:id="{$bookmark-id}" w:type="Word.Bookmark.End"/>
1233    </xsl:template>
1234    <!-- newly added the endnote , footnote templates -->
1235    <xsl:template match="text:note">
1236        <xsl:choose>
1237            <xsl:when test="@text:note-class = 'endnote' ">
1238                <w:r>
1239                    <w:rPr>
1240                        <w:rStyle w:val="Endnote"/>
1241                    </w:rPr>
1242                    <xsl:apply-templates select="text:note-body"/>
1243                </w:r>
1244            </xsl:when>
1245            <xsl:when test="@text:note-class = 'footnote' ">
1246                <w:r>
1247                    <w:rPr>
1248                        <w:rStyle w:val="Footnote"/>
1249                    </w:rPr>
1250                    <xsl:apply-templates select="text:note-body"/>
1251                </w:r>
1252            </xsl:when>
1253        </xsl:choose>
1254    </xsl:template>
1255    <xsl:template match="text:note-body">
1256        <xsl:choose>
1257            <xsl:when test="../@text:note-class='endnote' ">
1258                <w:endnote>
1259                    <xsl:if test="../text:note-citation/@text:label">
1260                        <xsl:attribute name="w:suppressRef">on</xsl:attribute>
1261                    </xsl:if>
1262                    <xsl:apply-templates select="text:h | text:p | text:ordered-list | text:unordered-list | text:list"/>
1263                </w:endnote>
1264            </xsl:when>
1265            <xsl:when test="../@text:note-class='footnote' ">
1266                <w:footnote>
1267                    <xsl:if test="../text:note-citation/@text:label">
1268                        <xsl:attribute name="w:suppressRef">on</xsl:attribute>
1269                    </xsl:if>
1270                    <xsl:apply-templates select="text:h | text:p | text:ordered-list | text:unordered-list | text:list"/>
1271                </w:footnote>
1272            </xsl:when>
1273        </xsl:choose>
1274    </xsl:template>
1275</xsl:stylesheet>
1276