1
<?xml version="1.0" encoding="UTF-8"?>
4
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6
Copyright 2008 by Sun Microsystems, Inc.
8
OpenOffice.org - a multi-platform office productivity suite
10
$RCSfile: style_mapping_css.xsl,v $
14
This file is part of OpenOffice.org.
16
OpenOffice.org is free software: you can redistribute it and/or modify
17
it under the terms of the GNU Lesser General Public License version 3
18
only, as published by the Free Software Foundation.
20
OpenOffice.org is distributed in the hope that it will be useful,
21
but WITHOUT ANY WARRANTY; without even the implied warranty of
22
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
GNU Lesser General Public License version 3 for more details
24
(a copy is included in the LICENSE file that accompanied this code).
26
You should have received a copy of the GNU Lesser General Public License
27
version 3 along with OpenOffice.org. If not, see
28
<http://www.openoffice.org/license.html>
29
for a copy of the LGPLv3 License.
33
For further documentation and updates visit http://xml.openoffice.org/odf2xhtml
35
<xsl:stylesheet version="1.0" 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">
38
<!-- *** Properties with a 'fo:' prefix *** -->
39
<xsl:template match="@fo:background-color">
40
<xsl:text>background-color:</xsl:text>
41
<xsl:value-of select="."/>
42
<xsl:text>; </xsl:text>
45
<xsl:template match="@fo:border | @fo:border-top | @fo:border-bottom | @fo:border-left | @fo:border-right">
46
<xsl:variable name="borderType" select="substring-after(name(), ':')"/>
48
<xsl:when test=". = 'none'">
49
<xsl:value-of select="$borderType"/>
50
<xsl:text>-style:none; </xsl:text>
53
<xsl:variable name="borderWidth" select="substring-before(., ' ')"/>
54
<xsl:variable name="borderStyle" select="substring-before(substring-after(., ' '), ' ')"/>
55
<xsl:variable name="borderColor" select="substring-after(substring-after(., ' '), ' ')"/>
57
<!-- More information at template 'round-up-border-width' -->
58
<xsl:variable name="borderWidthFixed">
59
<xsl:call-template name="round-up-border-width">
60
<xsl:with-param name="borderWidth" select="$borderWidth"/>
61
<xsl:with-param name="multiplier">
63
<xsl:when test="$borderStyle = 'double'">3</xsl:when>
64
<xsl:otherwise>1</xsl:otherwise>
70
<xsl:value-of select="$borderType"/>
71
<xsl:text>-width:</xsl:text>
72
<xsl:value-of select="$borderWidthFixed"/>
73
<xsl:text>; </xsl:text>
74
<xsl:value-of select="$borderType"/>
75
<xsl:text>-style:</xsl:text>
76
<xsl:value-of select="$borderStyle"/>
77
<xsl:text>; </xsl:text>
78
<xsl:value-of select="$borderType"/>
79
<xsl:text>-color:</xsl:text>
80
<xsl:value-of select="$borderColor"/>
81
<xsl:text>; </xsl:text>
86
<!-- NOTE: Still there have to be placed a <br clear='all' /> to disable the flow!!!!-->
87
<xsl:template match="@fo:clear">
88
<xsl:text>clear:both; </xsl:text>
91
<!-- text-shadow is a CSS2 feature and yet not common used in user-agents -->
92
<xsl:template match="@fo:color |@svg:font-family |@fo:font-size |@fo:font-style |@fo:font-weight |@fo:text-indent |@fo:text-shadow">
93
<xsl:value-of select="substring-after(name(), ':')"/>
94
<xsl:text>:</xsl:text>
95
<xsl:value-of select="."/>
96
<xsl:text>; </xsl:text>
99
<!-- Maps fo:margin as well fo:margin-top, fo:margin-bottom, fo:padding-left, fo:margin-right -->
100
<!-- Maps fo:padding as well fo:padding-top, fo:padding-bottom, fo:padding-left, fo:padding-right -->
101
<xsl:template match="@fo:line-height | @fo:width |@fo:margin | @fo:margin-top | @fo:margin-bottom | @fo:margin-left | @fo:margin-right | @fo:padding | @fo:padding-top | @fo:padding-bottom | @fo:padding-left | @fo:padding-right">
102
<xsl:value-of select="substring-after(name(), ':')"/>
103
<xsl:text>:</xsl:text>
104
<!-- Map once erroneusly used inch shortage 'inch' to CSS shortage 'in' -->
106
<xsl:when test="contains(., 'inch')">
107
<xsl:value-of select="substring-before(.,'ch')"/>
110
<xsl:value-of select="."/>
113
<xsl:text>; </xsl:text>
116
<xsl:template match="@fo:text-align">
117
<!-- 'important' is necessary as table cell value alignment is decided by runtime over the valuetype
118
Otherwise a table cell style-class would always be outnumbered by the run-time alignment value -->
120
<xsl:when test="contains(., 'start')">
121
<xsl:text>text-align:left ! important; </xsl:text>
123
<xsl:when test="contains(., 'end')">
124
<xsl:text>text-align:right ! important; </xsl:text>
127
<xsl:text>text-align:</xsl:text>
128
<xsl:value-of select="."/>
129
<xsl:text> ! important; </xsl:text>
134
<xsl:template match="@style:vertical-align">
136
<xsl:when test="contains(., 'bottom')">
137
<xsl:text>vertical-align:bottom; </xsl:text>
139
<xsl:when test="contains(., 'middle')">
140
<xsl:text>vertical-align:middle; </xsl:text>
143
<xsl:text>vertical-align:top; </xsl:text>
148
<!-- *** Properties with a 'style:' prefix *** -->
149
<!-- NOTE: Can 'inside' | 'from-inside' better be handled:
150
<!ATTLIST * style:horizontal-pos (from-left|left|center|right|from-inside|inside|outside)#IMPLIED>-->
151
<xsl:template match="@style:horizontal-pos">
153
<xsl:when test=".='left'">
154
<xsl:text>text-align:left; </xsl:text>
156
<xsl:when test=". = 'right'">
157
<xsl:text>text-align:right; </xsl:text>
159
<xsl:when test=".='center'">
160
<xsl:text>text-align:center; </xsl:text>
162
<!-- NOTE: currently other values are not used.
163
If the property value is from-left or from-inside,
164
the svg:x attribute associated with the frame element specifies
165
the horizontal position of the frame.
166
Otherwise the svg:x attribute is ignored for text documents.
171
<xsl:template match="@style:column-width">
172
<xsl:text>width:</xsl:text>
174
<!-- changing the distance measure: inch to in -->
175
<xsl:when test="contains(., 'inch')">
176
<xsl:value-of select="substring-before(.,'ch')"/>
179
<xsl:value-of select="."/>
182
<xsl:text>; </xsl:text>
185
<xsl:template match="@style:text-underline-style">
186
<xsl:text>text-decoration:</xsl:text>
188
<!-- changing the distance measure: inch to in -->
189
<xsl:when test=".='none'">
190
<xsl:text>none ! important</xsl:text>
193
<xsl:text>underline</xsl:text>
196
<xsl:text>; </xsl:text>
199
<xsl:template match="@style:font-name">
200
<xsl:param name="globalData" />
202
<xsl:text>font-family:</xsl:text>
203
<xsl:variable name="content" select="."/>
204
<xsl:variable name="quote">'</xsl:variable>
205
<xsl:variable name="fontName" select="$globalData/office:font-face-decls/style:font-face[@style:name=$content]/@svg:font-family" />
206
<xsl:value-of select="translate($fontName, $quote, '')"/>
207
<xsl:text>; </xsl:text>
210
<xsl:template match="@style:row-height">
211
<xsl:text>height:</xsl:text>
213
<!-- changing the distance measure: inch to in -->
214
<xsl:when test="contains(., 'inch')">
215
<xsl:value-of select="substring-before(.,'ch')"/>
218
<xsl:value-of select="."/>
221
<xsl:text>; </xsl:text>
224
<xsl:template match="@svg:strikethrough-position">
225
<xsl:if test="not(.='none')">
226
<xsl:text>text-decoration:line-through; </xsl:text>
229
<xsl:template match="@style:text-position">
230
<xsl:if test="contains(., 'sub')">
231
<xsl:text>vertical-align:sub; </xsl:text>
232
<xsl:if test="contains(., '%')">
233
<xsl:text>font-size:</xsl:text>
234
<xsl:value-of select="substring-after(., 'sub ')"/>
235
<xsl:text>;</xsl:text>
238
<xsl:if test="contains(., 'super')">
239
<xsl:text>vertical-align:super; </xsl:text>
240
<xsl:if test="contains(., '%')">
241
<xsl:text>font-size:</xsl:text>
242
<xsl:value-of select="substring-after(., 'super ')"/>
243
<xsl:text>;</xsl:text>
248
<xsl:template match="@style:vertical-pos">
250
<xsl:when test=".='from-top'">
251
<xsl:text>vertical-align:top; </xsl:text>
254
<xsl:text>vertical-align:</xsl:text>
255
<xsl:value-of select="."/>
256
<xsl:text>; </xsl:text>
261
<xsl:template match="@style:width">
262
<xsl:text>width:</xsl:text>
264
<!-- changing the distance measure: inch to in -->
265
<xsl:when test="contains(., 'inch')">
266
<xsl:value-of select="substring-before(.,'ch')"/>
269
<xsl:value-of select="."/>
272
<xsl:text>; </xsl:text>
274
<xsl:template match="@style:wrap">
276
<xsl:when test=".='left'">
277
<xsl:text>float:right; </xsl:text>
279
<xsl:when test=".='right'">
280
<xsl:text>float:left; </xsl:text>
284
<!-- *** Properties with a no 'fo:' or 'style:' prefix *** -->
286
<xsl:template match="@table:align">
288
<xsl:when test=".='left'">
289
<!-- Note: problems with meeting minutes example
290
<xsl:text>float:right; </xsl:text> --></xsl:when>
291
<xsl:when test=".='right'">
292
<!-- Note: problems with meeting minutes example
293
<xsl:text>float:left; </xsl:text> --></xsl:when>
295
<xsl:text>float:none; </xsl:text>
300
<xsl:template match="style:background-image">
301
<xsl:text>background-image:url(</xsl:text>
302
<xsl:value-of select="@xlink:href"/>
303
<xsl:text>); </xsl:text>
305
<xsl:when test="@style:repeat = 'repeat'">
306
<xsl:text>background-repeat:repeat; </xsl:text>
309
<xsl:text>background-repeat:no-repeat; </xsl:text>
314
<!-- Changing border width measure to cm and enlarging border-width to the Mozilla browser(1.7)
315
visible minimum width
316
- 0.0133cm for solid style
317
- 0.0399cm for double style
318
as there are three border lines painted -->
319
<xsl:template name="round-up-border-width">
320
<xsl:param name="borderWidth"/>
321
<xsl:param name="multiplier"/>
323
<xsl:variable name="borderWidthByCentimeter">
324
<xsl:call-template name="convert2cm">
325
<xsl:with-param name="value" select="$borderWidth"/>
328
<xsl:variable name="minimalBorderWidth" select="0.0133 * $multiplier"/>
330
<xsl:when test="number($borderWidthByCentimeter) < $minimalBorderWidth">
331
<xsl:value-of select="$minimalBorderWidth"/>
332
<xsl:text>cm</xsl:text>
335
<xsl:value-of select="$borderWidthByCentimeter"/>
336
<xsl:text>cm</xsl:text>