1<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: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:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" 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="w wx aml o dt v" xmlns:an="urn:flr:annotate"> 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<an:page-layout-properties 24 context-node-input="w:sectPr" 25 context-node-output="style:page-layout-properties"> 26<an:so-supported select="w:pgMar/@w:gutter"/> 27<an:so-supported select="w:pgSz/@w:code"/> 28</an:page-layout-properties> 29 30<xsl:template name="page-layout-properties"> 31 32<!-- NOTE: "div 567.0" converts from twips to cm --> 33<xsl:attribute name="fo:margin-top"> 34 <xsl:variable name="header-margin"> 35 <xsl:choose> 36 <xsl:when test="w:pgMar/@w:header"> 37 <xsl:value-of select="w:pgMar/@w:header"/> 38 </xsl:when> 39 <xsl:otherwise>720</xsl:otherwise> 40 </xsl:choose> 41 </xsl:variable> 42 <xsl:variable name="margin-top"> 43 <xsl:choose> 44 <xsl:when test="w:hdr"> 45 <xsl:choose> 46 <xsl:when test="w:pgMar/@w:top >= $header-margin"> 47 <xsl:value-of select="$header-margin"/> 48 </xsl:when> 49 <xsl:otherwise> 50 <xsl:value-of select="w:pgMar/@w:top"/> 51 </xsl:otherwise> 52 </xsl:choose> 53 </xsl:when> 54 <xsl:otherwise> 55 <xsl:value-of select="w:pgMar/@w:top"/> 56 </xsl:otherwise> 57 </xsl:choose> 58 </xsl:variable> 59 <xsl:value-of select="concat($margin-top div 567.0, 'cm')"/> 60</xsl:attribute> 61<xsl:attribute name="fo:margin-bottom"> 62 <xsl:variable name="footer-margin"> 63 <xsl:choose> 64 <xsl:when test="w:pgMar/@w:footer"> 65 <xsl:value-of select="w:pgMar/@w:footer"/> 66 </xsl:when> 67 <xsl:otherwise>720</xsl:otherwise> 68 </xsl:choose> 69 </xsl:variable> 70 <xsl:variable name="margin-bottom"> 71 <xsl:choose> 72 <xsl:when test="w:ftr"> 73 <xsl:value-of select="$footer-margin"/> 74 </xsl:when> 75 <xsl:otherwise> 76 <xsl:value-of select="w:pgMar/@w:bottom"/> 77 </xsl:otherwise> 78 </xsl:choose> 79 </xsl:variable> 80 <xsl:value-of select="concat($margin-bottom div 567.0, 'cm')"/> 81</xsl:attribute> 82<xsl:attribute name="fo:margin-left"> 83 <xsl:value-of select="concat(w:pgMar/@w:left div 567.0, 'cm')"/> 84</xsl:attribute> 85<xsl:attribute name="fo:margin-right"> 86 <xsl:value-of select="concat(w:pgMar/@w:right div 567.0, 'cm')"/> 87</xsl:attribute> 88 89<xsl:attribute name="fo:page-width"> 90 <xsl:value-of select="concat(w:pgSz/@w:w div 567.0, 'cm')"/> 91</xsl:attribute> 92<xsl:attribute name="fo:page-height"> 93 <xsl:value-of select="concat(w:pgSz/@w:h div 567.0, 'cm')"/> 94</xsl:attribute> 95<xsl:attribute name="style:footnote-max-height"> 96 <xsl:value-of select="'0cm'"/> 97</xsl:attribute> 98<xsl:attribute name="style:print-orientation"> 99 <xsl:choose> 100 <xsl:when test="w:pgSz/@w:orient"> 101 <xsl:value-of select="w:pgSz/@w:orient"/> 102 </xsl:when> 103 <xsl:otherwise>portrait</xsl:otherwise> 104 </xsl:choose> 105</xsl:attribute> 106<xsl:apply-templates select="//w:bgPict"/> 107<xsl:call-template name="column-properties"/> 108</xsl:template> 109 110 111<an:column-properties 112 context-node-input="w:sectPr" 113 context-node-output="style:page-layout-properties"> 114<an:so-supported select="w:cols/@w:sep"/> 115</an:column-properties> 116<xsl:template name="column-properties"> 117<style:columns> 118<xsl:attribute name="fo:column-count"> 119 <xsl:choose> 120 <xsl:when test="w:cols/@w:num"> 121 <xsl:value-of select="w:cols/@w:num"/> 122 </xsl:when> 123 <xsl:otherwise>1</xsl:otherwise> 124 </xsl:choose> 125</xsl:attribute> 126 127<xsl:if test="not(w:cols/w:col)"> 128<!-- bug in the OASIS spec resp. bug in xmloff --> 129<xsl:attribute name="fo:column-gap"> 130 <xsl:value-of select="concat(w:cols/@w:space div 567.0, 'cm')"/> 131</xsl:attribute> 132</xsl:if> 133 134<xsl:for-each select="w:cols/w:col"> 135 <style:column> 136 <xsl:attribute name="style:rel-width"> 137 <xsl:value-of select="concat(@w:w, '*')"/> 138 </xsl:attribute> 139 <xsl:attribute name="fo:start-indent"> 140 <xsl:value-of select="'0cm'"/> 141 </xsl:attribute> 142 <xsl:attribute name="fo:end-indent"> 143 <xsl:choose> 144 <xsl:when test="@w:space"> 145 <xsl:value-of select="concat(@w:space div 567.0, 'cm')"/> 146 </xsl:when> 147 <xsl:otherwise>0cm</xsl:otherwise> 148 </xsl:choose> 149 </xsl:attribute> 150 </style:column> 151</xsl:for-each> 152</style:columns> 153</xsl:template> 154 155<an:text-properties 156 context-node-input="w:rPr" 157 context-node-output="style:text-properties"> 158</an:text-properties > 159<xsl:template name="text-properties"> 160<xsl:variable name="b-value"> 161 <xsl:choose> 162 <xsl:when test="w:b/@val"> 163 <xsl:value-of select="w:b/@val"/> 164 </xsl:when> 165 <xsl:otherwise> 166 <xsl:value-of select="local-name(w:b)"/> 167 </xsl:otherwise> 168 </xsl:choose> 169</xsl:variable> 170<!-- could be simplified: is "b" actually a valid value of w:b/@val ? --> 171<xsl:variable name="font-weight"> 172 <xsl:choose> 173 <xsl:when test="$b-value = 'on'">bold</xsl:when> 174 <xsl:when test="$b-value = 'off'">normal</xsl:when> 175 <xsl:when test="$b-value = 'b'">bold</xsl:when> 176 <xsl:otherwise></xsl:otherwise> 177 </xsl:choose> 178</xsl:variable> 179<xsl:attribute name="fo:font-weight"> 180 <xsl:value-of select="$font-weight"/> 181</xsl:attribute> 182<xsl:attribute name="style:font-weight-asian"> 183 <xsl:value-of select="$font-weight"/> 184</xsl:attribute> 185<xsl:attribute name="style:font-weight-complex"> 186 <xsl:variable name="b-cs-value"> 187 <xsl:choose> 188 <xsl:when test="w:b-cs/@val"> 189 <xsl:value-of select="w:b-cs/@val"/> 190 </xsl:when> 191 <xsl:otherwise> 192 <xsl:value-of select="local-name(w:b-cs)"/> 193 </xsl:otherwise> 194 </xsl:choose> 195 </xsl:variable> 196 <!-- could be simplified: is "b-cs" actually a valid value of w:b-cs/@val --> 197 <xsl:choose> 198 <xsl:when test="$b-cs-value = 'on'">bold</xsl:when> 199 <xsl:when test="$b-cs-value = 'off'">normal</xsl:when> 200 <xsl:when test="$b-cs-value = 'b-cs'">bold</xsl:when> 201 <xsl:otherwise></xsl:otherwise> 202 </xsl:choose> 203</xsl:attribute> 204<xsl:variable name="i-value"> 205 <xsl:choose> 206 <xsl:when test="w:i/@val"> 207 <xsl:value-of select="w:i/@val"/> 208 </xsl:when> 209 <xsl:otherwise> 210 <xsl:value-of select="local-name(w:i)"/> 211 </xsl:otherwise> 212 </xsl:choose> 213</xsl:variable> 214<!-- could be simplified: is "i" actually a valid value of w:i/@val ? --> 215<xsl:variable name="font-style"> 216 <xsl:choose> 217 <xsl:when test="$i-value = 'on'">italic</xsl:when> 218 <xsl:when test="$i-value = 'off'">normal</xsl:when> 219 <xsl:when test="$i-value = 'i'">italic</xsl:when> 220 <xsl:otherwise></xsl:otherwise> 221 </xsl:choose> 222</xsl:variable> 223<xsl:attribute name="fo:font-style"> 224 <xsl:value-of select="$font-style"/> 225</xsl:attribute> 226<xsl:attribute name="style:font-style-asian"> 227 <xsl:value-of select="$font-style"/> 228</xsl:attribute> 229<xsl:attribute name="style:font-style-complex"> 230 <xsl:variable name="i-cs-value"> 231 <xsl:choose> 232 <xsl:when test="w:i-cs/@val"> 233 <xsl:value-of select="w:i-cs/@val"/> 234 </xsl:when> 235 <xsl:otherwise> 236 <xsl:value-of select="local-name(w:i-cs)"/> 237 </xsl:otherwise> 238 </xsl:choose> 239 </xsl:variable> 240 <!-- could be simplified: is "i-cs" actually a valid value of w:i-cs/@val --> 241 <xsl:choose> 242 <xsl:when test="$i-cs-value = 'on'">italic</xsl:when> 243 <xsl:when test="$i-cs-value = 'off'">normal</xsl:when> 244 <xsl:when test="$i-cs-value = 'i-cs'">italic</xsl:when> 245 <xsl:otherwise></xsl:otherwise> 246 </xsl:choose> 247</xsl:attribute> 248<xsl:attribute name="fo:text-transform"> 249 <xsl:variable name="caps-value"> 250 <xsl:choose> 251 <xsl:when test="w:caps/@val"> 252 <xsl:value-of select="w:caps/@val"/> 253 </xsl:when> 254 <xsl:otherwise> 255 <xsl:value-of select="local-name(w:caps)"/> 256 </xsl:otherwise> 257 </xsl:choose> 258 </xsl:variable> 259 <!-- could be simplified: is "caps" actually a valid value of w:caps/@val --> 260 <xsl:choose> 261 <xsl:when test="$caps-value = 'on'">uppercase</xsl:when> 262 <xsl:when test="$caps-value = 'off'">normal</xsl:when> 263 <xsl:when test="$caps-value = 'caps'">uppercase</xsl:when> 264 <xsl:otherwise></xsl:otherwise> 265 </xsl:choose> 266</xsl:attribute> 267<xsl:attribute name="fo:font-variant"> 268 <xsl:variable name="small-caps-value"> 269 <xsl:choose> 270 <xsl:when test="w:smallCaps/@val"> 271 <xsl:value-of select="w:smallCaps/@val"/> 272 </xsl:when> 273 <xsl:otherwise> 274 <xsl:value-of select="local-name(w:smallCaps)"/> 275 </xsl:otherwise> 276 </xsl:choose> 277 </xsl:variable> 278 <!-- could be simplified: is "smallCaps" actually a valid value of w:smallCaps/@val --> 279 <xsl:choose> 280 <xsl:when test="$small-caps-value = 'on'">small-caps</xsl:when> 281 <xsl:when test="$small-caps-value = 'off'">normal</xsl:when> 282 <xsl:when test="$small-caps-value = 'smallCaps'">small-caps</xsl:when> 283 <xsl:otherwise></xsl:otherwise> 284 </xsl:choose> 285</xsl:attribute> 286</xsl:template> 287 288</xsl:stylesheet> 289