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<!-- 25 For further documentation and updates visit http://xml.openoffice.org/odf2xhtml 26--> 27<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"> 28 29 30 <!-- *** Properties with a 'fo:' prefix *** --> 31 <xsl:template match="@fo:background-color"> 32 <xsl:text>background-color:</xsl:text> 33 <xsl:value-of select="."/> 34 <xsl:text>; </xsl:text> 35 </xsl:template> 36 37 <xsl:template match="@fo:border | @fo:border-top | @fo:border-bottom | @fo:border-left | @fo:border-right"> 38 <xsl:variable name="borderType" select="substring-after(name(), ':')"/> 39 <xsl:choose> 40 <xsl:when test=". = 'none'"> 41 <xsl:value-of select="$borderType"/> 42 <xsl:text>-style:none; </xsl:text> 43 </xsl:when> 44 <xsl:otherwise> 45 <xsl:variable name="borderWidth" select="substring-before(., ' ')"/> 46 <xsl:variable name="borderStyle" select="substring-before(substring-after(., ' '), ' ')"/> 47 <xsl:variable name="borderColor" select="substring-after(substring-after(., ' '), ' ')"/> 48 49 <!-- More information at template 'round-up-border-width' --> 50 <xsl:variable name="borderWidthFixed"> 51 <xsl:call-template name="round-up-border-width"> 52 <xsl:with-param name="borderWidth" select="$borderWidth"/> 53 <xsl:with-param name="multiplier"> 54 <xsl:choose> 55 <xsl:when test="$borderStyle = 'double'">3</xsl:when> 56 <xsl:otherwise>1</xsl:otherwise> 57 </xsl:choose> 58 </xsl:with-param> 59 </xsl:call-template> 60 </xsl:variable> 61 62 <xsl:value-of select="$borderType"/> 63 <xsl:text>-width:</xsl:text> 64 <xsl:value-of select="$borderWidthFixed"/> 65 <xsl:text>; </xsl:text> 66 <xsl:value-of select="$borderType"/> 67 <xsl:text>-style:</xsl:text> 68 <xsl:value-of select="$borderStyle"/> 69 <xsl:text>; </xsl:text> 70 <xsl:value-of select="$borderType"/> 71 <xsl:text>-color:</xsl:text> 72 <xsl:value-of select="$borderColor"/> 73 <xsl:text>; </xsl:text> 74 </xsl:otherwise> 75 </xsl:choose> 76 </xsl:template> 77 78 <!-- NOTE: Still there have to be placed a <br clear='all' /> to disable the flow!!!!--> 79 <xsl:template match="@fo:clear"> 80 <xsl:text>clear:both; </xsl:text> 81 </xsl:template> 82 83 <!-- text-shadow is a CSS2 feature and yet not common used in user-agents --> 84 <xsl:template match="@fo:color |@svg:font-family |@fo:font-size |@fo:font-style |@fo:font-weight |@fo:text-indent |@fo:text-shadow"> 85 <xsl:value-of select="substring-after(name(), ':')"/> 86 <xsl:text>:</xsl:text> 87 <xsl:value-of select="."/> 88 <xsl:text>; </xsl:text> 89 </xsl:template> 90 91 <!-- Maps fo:margin as well fo:margin-top, fo:margin-bottom, fo:padding-left, fo:margin-right --> 92 <!-- Maps fo:padding as well fo:padding-top, fo:padding-bottom, fo:padding-left, fo:padding-right --> 93 <xsl:template match="@fo:letter-spacing | @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"> 94 <xsl:value-of select="substring-after(name(), ':')"/> 95 <xsl:text>:</xsl:text> 96 <!-- Map once erroneusly used inch shortage 'inch' to CSS shortage 'in' --> 97 <xsl:choose> 98 <xsl:when test="contains(., 'inch')"> 99 <xsl:value-of select="substring-before(.,'ch')"/> 100 </xsl:when> 101 <xsl:otherwise> 102 <xsl:value-of select="."/> 103 </xsl:otherwise> 104 </xsl:choose> 105 <xsl:text>; </xsl:text> 106 </xsl:template> 107 108 <xsl:template match="@fo:text-align"> 109 <!-- 'important' is necessary as table cell value alignment is decided by runtime over the valuetype 110 Otherwise a table cell style-class would always be outnumbered by the run-time alignment value --> 111 <xsl:choose> 112 <xsl:when test="contains(., 'start')"> 113 <xsl:choose> 114 <xsl:when test="parent::*/@style:writing-mode and contains(parent::*/@style:writing-mode, 'rl')"> 115 <xsl:text>text-align:right ! important; </xsl:text> 116 </xsl:when> 117 <xsl:otherwise> 118 <xsl:text>text-align:left ! important; </xsl:text> 119 </xsl:otherwise> 120 </xsl:choose> 121 </xsl:when> 122 <xsl:when test="contains(., 'end')"> 123 <xsl:choose> 124 <xsl:when test="parent::*/@style:writing-mode and contains(parent::*/@style:writing-mode, 'rl')"> 125 <xsl:text>text-align:left ! important;</xsl:text> 126 </xsl:when> 127 <xsl:otherwise> 128 <xsl:text>text-align:right ! important; </xsl:text> 129 </xsl:otherwise> 130 </xsl:choose> 131 </xsl:when> 132 <xsl:otherwise> 133 <xsl:text>text-align:</xsl:text> 134 <xsl:value-of select="."/> 135 <xsl:text> ! important; </xsl:text> 136 </xsl:otherwise> 137 </xsl:choose> 138 </xsl:template> 139 140 <xsl:template match="@style:vertical-align"> 141 <xsl:choose> 142 <xsl:when test="contains(., 'bottom')"> 143 <xsl:text>vertical-align:bottom; </xsl:text> 144 </xsl:when> 145 <xsl:when test="contains(., 'middle')"> 146 <xsl:text>vertical-align:middle; </xsl:text> 147 </xsl:when> 148 <xsl:otherwise> 149 <xsl:text>vertical-align:top; </xsl:text> 150 </xsl:otherwise> 151 </xsl:choose> 152 </xsl:template> 153 154<!-- *** Properties with a 'style:' prefix *** --> 155 <!-- NOTE: Can 'inside' | 'from-inside' better be handled: 156 <!ATTLIST * style:horizontal-pos (from-left|left|center|right|from-inside|inside|outside)#IMPLIED>--> 157 <xsl:template match="@style:horizontal-pos"> 158 <xsl:choose> 159 <xsl:when test=".='left'"> 160 <xsl:text>text-align:left; </xsl:text> 161 </xsl:when> 162 <xsl:when test=". = 'right'"> 163 <xsl:text>text-align:right; </xsl:text> 164 </xsl:when> 165 <xsl:when test=".='center'"> 166 <xsl:text>text-align:center; </xsl:text> 167 </xsl:when> 168 <!-- NOTE: currently other values are not used. 169 If the property value is from-left or from-inside, 170 the svg:x attribute associated with the frame element specifies 171 the horizontal position of the frame. 172 Otherwise the svg:x attribute is ignored for text documents. 173 --> 174 </xsl:choose> 175 </xsl:template> 176 177 <xsl:template match="@style:column-width"> 178 <xsl:text>width:</xsl:text> 179 <xsl:choose> 180 <!-- changing the distance measure: inch to in --> 181 <xsl:when test="contains(., 'inch')"> 182 <xsl:value-of select="substring-before(.,'ch')"/> 183 </xsl:when> 184 <xsl:otherwise> 185 <xsl:value-of select="."/> 186 </xsl:otherwise> 187 </xsl:choose> 188 <xsl:text>; </xsl:text> 189 </xsl:template> 190 191 <xsl:template match="@style:text-underline-style"> 192 <xsl:text>text-decoration:</xsl:text> 193 <xsl:choose> 194 <!-- changing the distance measure: inch to in --> 195 <xsl:when test=".='none'"> 196 <xsl:text>none ! important</xsl:text> 197 </xsl:when> 198 <xsl:otherwise> 199 <xsl:text>underline</xsl:text> 200 </xsl:otherwise> 201 </xsl:choose> 202 <xsl:text>; </xsl:text> 203 </xsl:template> 204 205 <xsl:template match="@style:font-name"> 206 <xsl:param name="globalData" /> 207 208 <xsl:text>font-family:</xsl:text> 209 <xsl:variable name="content" select="."/> 210 <xsl:variable name="quote">'</xsl:variable> 211 <xsl:variable name="fontName" select="$globalData/office:font-face-decls/style:font-face[@style:name=$content]/@svg:font-family" /> 212 <xsl:value-of select="translate($fontName, $quote, '')"/> 213 <xsl:text>; </xsl:text> 214 </xsl:template> 215 216 <xsl:template match="@style:row-height"> 217 <xsl:text>height:</xsl:text> 218 <xsl:choose> 219 <!-- changing the distance measure: inch to in --> 220 <xsl:when test="contains(., 'inch')"> 221 <xsl:value-of select="substring-before(.,'ch')"/> 222 </xsl:when> 223 <xsl:otherwise> 224 <xsl:value-of select="."/> 225 </xsl:otherwise> 226 </xsl:choose> 227 <xsl:text>; </xsl:text> 228 </xsl:template> 229 230 <xsl:template match="@svg:strikethrough-position"> 231 <xsl:if test="not(.='none')"> 232 <xsl:text>text-decoration:line-through; </xsl:text> 233 </xsl:if> 234 </xsl:template> 235 <xsl:template match="@style:text-position"> 236 <xsl:if test="contains(., 'sub')"> 237 <xsl:text>vertical-align:sub; </xsl:text> 238 <xsl:if test="contains(., '%')"> 239 <xsl:text>font-size:</xsl:text> 240 <xsl:value-of select="substring-after(., 'sub ')"/> 241 <xsl:text>;</xsl:text> 242 </xsl:if> 243 </xsl:if> 244 <xsl:if test="contains(., 'super')"> 245 <xsl:text>vertical-align:super; </xsl:text> 246 <xsl:if test="contains(., '%')"> 247 <xsl:text>font-size:</xsl:text> 248 <xsl:value-of select="substring-after(., 'super ')"/> 249 <xsl:text>;</xsl:text> 250 </xsl:if> 251 </xsl:if> 252 </xsl:template> 253 254 <xsl:template match="@style:vertical-pos"> 255 <xsl:choose> 256 <xsl:when test=".='from-top'"> 257 <xsl:text>vertical-align:top; </xsl:text> 258 </xsl:when> 259 <xsl:otherwise> 260 <xsl:text>vertical-align:</xsl:text> 261 <xsl:value-of select="."/> 262 <xsl:text>; </xsl:text> 263 </xsl:otherwise> 264 </xsl:choose> 265 </xsl:template> 266 267 <xsl:template match="@style:width"> 268 <xsl:text>width:</xsl:text> 269 <xsl:choose> 270 <!-- changing the distance measure: inch to in --> 271 <xsl:when test="contains(., 'inch')"> 272 <xsl:value-of select="substring-before(.,'ch')"/> 273 </xsl:when> 274 <xsl:otherwise> 275 <xsl:value-of select="."/> 276 </xsl:otherwise> 277 </xsl:choose> 278 <xsl:text>; </xsl:text> 279 </xsl:template> 280 <xsl:template match="@style:wrap"> 281 <xsl:choose> 282 <xsl:when test=".='left'"> 283 <xsl:text>float:right; </xsl:text> 284 </xsl:when> 285 <xsl:when test=".='right'"> 286 <xsl:text>float:left; </xsl:text> 287 </xsl:when> 288 </xsl:choose> 289 </xsl:template> 290 <xsl:template match="@style:writing-mode"> 291 <xsl:text>writing-mode:</xsl:text> 292 <xsl:value-of select="."/> 293 <xsl:text>; </xsl:text> 294 </xsl:template> 295 <!-- *** Properties with a no 'fo:' or 'style:' prefix *** --> 296 <xsl:template match="@table:align"> 297 <xsl:choose> 298 <xsl:when test=".='left'"> 299 <!-- Note: problems with meeting minutes example 300 <xsl:text>float:right; </xsl:text> --></xsl:when> 301 <xsl:when test=".='right'"> 302 <!-- Note: problems with meeting minutes example 303 <xsl:text>float:left; </xsl:text> --></xsl:when> 304 <xsl:otherwise> 305 <xsl:text>float:none; </xsl:text> 306 </xsl:otherwise> 307 </xsl:choose> 308 </xsl:template> 309 310 <xsl:template match="style:background-image"> 311 <xsl:text>background-image:url(</xsl:text> 312 <xsl:value-of select="@xlink:href"/> 313 <xsl:text>); </xsl:text> 314 <xsl:choose> 315 <xsl:when test="@style:repeat = 'repeat'"> 316 <xsl:text>background-repeat:repeat; </xsl:text> 317 </xsl:when> 318 <xsl:otherwise> 319 <xsl:text>background-repeat:no-repeat; </xsl:text> 320 </xsl:otherwise> 321 </xsl:choose> 322 </xsl:template> 323 324 <!-- Changing border width measure to cm and enlarging border-width to the Mozilla browser(1.7) 325 visible minimum width 326 - 0.0133cm for solid style 327 - 0.0399cm for double style 328 as there are three border lines painted --> 329 <xsl:template name="round-up-border-width"> 330 <xsl:param name="borderWidth"/> 331 <xsl:param name="multiplier"/> 332 333 <xsl:variable name="borderWidthByCentimeter"> 334 <xsl:call-template name="convert2cm"> 335 <xsl:with-param name="value" select="$borderWidth"/> 336 </xsl:call-template> 337 </xsl:variable> 338 <xsl:variable name="minimalBorderWidth" select="0.0133 * $multiplier"/> 339 <xsl:choose> 340 <xsl:when test="number($borderWidthByCentimeter) < $minimalBorderWidth"> 341 <xsl:value-of select="$minimalBorderWidth"/> 342 <xsl:text>cm</xsl:text> 343 </xsl:when> 344 <xsl:otherwise> 345 <xsl:value-of select="$borderWidthByCentimeter"/> 346 <xsl:text>cm</xsl:text> 347 </xsl:otherwise> 348 </xsl:choose> 349 </xsl:template> 350</xsl:stylesheet> 351 352