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 name="ListStyles"> 26 <w:lists> 27 <xsl:if test="descendant::text:list-level-style-image"> 28 <xsl:call-template name="PicLists"/> 29 </xsl:if> 30 <xsl:apply-templates select="office:styles/text:outline-style | office:styles/text:list-style | office:automatic-styles/text:list-style" mode="style"/> 31 <xsl:for-each select="office:styles/text:outline-style | office:styles/text:list-style | office:automatic-styles/text:list-style"> 32 <w:list w:ilfo="{position()}"> 33 <w:ilst w:val="{position()-1}"/> 34 </w:list> 35 </xsl:for-each> 36 </w:lists> 37 </xsl:template> 38 <xsl:template match="text:list-style | text:outline-style" mode="style"> 39 <w:listDef w:listDefId="{position()-1}"> 40 <xsl:if test="name(..)='office:styles' and name()!='text:outline-style'"> 41 <w:styleLink w:val="{@style:name}"/> 42 </xsl:if> 43 <xsl:for-each select="text:list-level-style-number | text:list-level-style-bullet | text:list-level-style-image | text:outline-level-style"> 44 <xsl:if test="@text:level < 10"> 45 <w:lvl w:ilvl="{ @text:level - 1 }"> 46 <xsl:if test="name()='text:outline-level-style'"> 47 <xsl:variable name="headinglevel"> 48 <xsl:value-of select="@text:level"/> 49 </xsl:variable> 50 <xsl:if test="/office:document/office:body//text:h[@text:level=$headinglevel and @text:style-name]"> 51 <xsl:element name="w:pStyle"> 52 <xsl:attribute name="w:val"><xsl:value-of select="/office:document/office:body//text:h[@text:level=$headinglevel]/@text:style-name"/></xsl:attribute> 53 </xsl:element> 54 </xsl:if> 55 </xsl:if> 56 <xsl:choose> 57 <xsl:when test="@text:start-value"> 58 <w:start w:val="{@text:start-value}"/> 59 </xsl:when> 60 <xsl:otherwise> 61 <w:start w:val="1"/> 62 </xsl:otherwise> 63 </xsl:choose> 64 <xsl:choose> 65 <xsl:when test="@text:bullet-char"> 66 <w:nfc w:val="23"/> 67 </xsl:when> 68 <xsl:when test="@style:num-format"> 69 <xsl:call-template name="convert_list_number"> 70 <xsl:with-param name="number-format" select="@style:num-format"/> 71 </xsl:call-template> 72 </xsl:when> 73 </xsl:choose> 74 <xsl:choose> 75 <xsl:when test="name()='text:list-level-style-image'"> 76 <w:lvlText w:val="."/> 77 <w:lvlPicBulletId> 78 <xsl:attribute name="w:val"><xsl:value-of select="count(preceding::text:list-level-style-image)"/></xsl:attribute> 79 </w:lvlPicBulletId> 80 </xsl:when> 81 <xsl:when test="@text:bullet-char"> 82 <w:lvlText w:val="{@text:bullet-char}"/> 83 </xsl:when> 84 <xsl:when test="@text:display-levels and not(../@text:consecutive-numbering='true')"> 85 <xsl:variable name="levelText"> 86 <xsl:call-template name="displaylevel"> 87 <xsl:with-param name="number" select="@text:display-levels"/> 88 <xsl:with-param name="textlevel" select="@text:level"/> 89 </xsl:call-template> 90 </xsl:variable> 91 <w:lvlText w:val="{concat(@style:num-prefix, substring-after($levelText, '.'), @style:num-suffix)}"/> 92 </xsl:when> 93 <xsl:otherwise> 94 <w:lvlText w:val="{concat(@style:num-prefix, '%', @text:level, @style:num-suffix)}"/> 95 </xsl:otherwise> 96 </xsl:choose> 97 <xsl:choose> 98 <xsl:when test="style:list-level-properties/@fo:text-align = 'end'"> 99 <w:lvlJc w:val="right"/> 100 </xsl:when> 101 <xsl:when test="style:list-level-properties/@fo:text-align = 'center'"> 102 <w:lvlJc w:val="center"/> 103 </xsl:when> 104 <xsl:otherwise> 105 <w:lvlJc w:val="left"/> 106 </xsl:otherwise> 107 </xsl:choose> 108 <xsl:choose> 109 <xsl:when test="style:list-level-properties/@text:space-before | style:list-level-properties/@text:min-label-width | style:list-level-properties/@text:min-label-distance"> 110 <xsl:call-template name="list_position"/> 111 </xsl:when> 112 <xsl:otherwise> 113 <w:suff w:val="Nothing"/> 114 </xsl:otherwise> 115 </xsl:choose> 116 <xsl:apply-templates select="key('text-style',@text:style-name)/style:text-properties" mode="character"/> 117 <xsl:apply-templates select="style:text-properties" mode="character"/> 118 </w:lvl> 119 </xsl:if> 120 </xsl:for-each> 121 </w:listDef> 122 </xsl:template> 123 <xsl:template match="text:list-style" mode="count"> 124 <xsl:value-of select="count(preceding::text:list-style | preceding::text:outline-style)+1"/> 125 </xsl:template> 126 <xsl:template match="text:unordered-list | text:ordered-list | text:list"> 127 <xsl:apply-templates select="text:unordered-list | text:ordered-list | text:list-item | text:list-header | text:list"/> 128 </xsl:template> 129 <xsl:template match="text:list-item | text:list-header"> 130 <xsl:apply-templates select="text:unordered-list | text:ordered-list | text:list | text:p | text:h"/> 131 </xsl:template> 132 <xsl:template name="displaylevel"> 133 <xsl:param name="number"/> 134 <xsl:param name="textlevel"/> 135 <xsl:if test="$number > 1"> 136 <xsl:call-template name="displaylevel"> 137 <xsl:with-param name="number" select="$number -1"/> 138 <xsl:with-param name="textlevel" select="number($textlevel)-1"/> 139 </xsl:call-template> 140 </xsl:if> 141 <xsl:value-of select="concat('.','%',$textlevel)"/> 142 </xsl:template> 143 <xsl:template name="list_position"> 144 <xsl:variable name="spacebefore"> 145 <xsl:choose> 146 <xsl:when test="style:list-level-properties/@text:space-before"> 147 <xsl:call-template name="convert2twip"> 148 <xsl:with-param name="value" select="style:list-level-properties/@text:space-before"/> 149 </xsl:call-template> 150 </xsl:when> 151 <xsl:otherwise>0</xsl:otherwise> 152 </xsl:choose> 153 </xsl:variable> 154 <xsl:variable name="space2text"> 155 <xsl:choose> 156 <xsl:when test="style:list-level-properties/@text:min-label-width"> 157 <xsl:call-template name="convert2twip"> 158 <xsl:with-param name="value" select="style:list-level-properties/@text:min-label-width"/> 159 </xsl:call-template> 160 </xsl:when> 161 <xsl:otherwise>0</xsl:otherwise> 162 </xsl:choose> 163 </xsl:variable> 164 <xsl:variable name="spacedistance"> 165 <xsl:choose> 166 <xsl:when test="style:list-level-properties/@text:min-label-distance"> 167 <xsl:call-template name="convert2twip"> 168 <xsl:with-param name="value" select="style:list-level-properties/@text:min-label-distance"/> 169 </xsl:call-template> 170 </xsl:when> 171 <xsl:otherwise>0</xsl:otherwise> 172 </xsl:choose> 173 </xsl:variable> 174 <xsl:if test="$spacedistance='0' and $space2text='0'"> 175 <w:suff w:val="Nothing"/> 176 </xsl:if> 177 <w:pPr> 178 <xsl:if test="$spacedistance!='0' or $space2text!='0'"> 179 <w:tabs> 180 <w:tab> 181 <xsl:attribute name="w:val">list</xsl:attribute> 182 <xsl:attribute name="w:pos"><xsl:choose><xsl:when test="number($spacedistance) > number($space2text)"><xsl:value-of select="number($spacebefore)+number($spacedistance)+150"/></xsl:when><xsl:otherwise><xsl:value-of select="number($spacebefore)+number($space2text)+150"/></xsl:otherwise></xsl:choose></xsl:attribute> 183 <!-- Since SO MinSpaceDistance is width after number or bullet, MS TabSpaceAfter include the number or bullet width. So +150 --> 184 </w:tab> 185 </w:tabs> 186 </xsl:if> 187 <w:ind w:left="{number($space2text)+number($spacebefore)}" w:hanging="{$space2text}"/> 188 <!-- w:pos(MS TabSpaceAfter) = text:space-before + MAX(text:min-label-distance,text:min-label-width) + ( Symbol width ); w:left(MS IndentAt)= text:space-before + text:min-label-width; w:hanging(MS IndentAt - MS AlignedAt)=text:min-label-width --> 189 </w:pPr> 190 </xsl:template> 191 <xsl:template name="PicLists"> 192 <xsl:for-each select="descendant::text:list-level-style-image"> 193 <w:listPicBullet w:listPicBulletId="{position()-1}"> 194 <w:pict> 195 <v:shape> 196 <xsl:variable name="Picwidth"> 197 <xsl:call-template name="convert2pt"> 198 <xsl:with-param name="value" select="style:list-level-properties/@fo:width"/> 199 </xsl:call-template> 200 </xsl:variable> 201 <xsl:variable name="Picheight"> 202 <xsl:call-template name="convert2pt"> 203 <xsl:with-param name="value" select="style:list-level-properties/@fo:height"/> 204 </xsl:call-template> 205 </xsl:variable> 206 <xsl:attribute name="style"><xsl:value-of select="concat('width:', number($Picwidth*1), 'pt;height:', number($Picheight*1), 'pt')"/></xsl:attribute> 207 <xsl:attribute name="o:bullet">t</xsl:attribute> 208 <v:stroke joinstyle="miter"/> 209 <w:binData w:name="{concat('wordml://SOpicbullet', position(), '.gif')}"> 210 <xsl:value-of select="office:binary-data"/> 211 </w:binData> 212 <v:imagedata src="{concat('wordml://SOpicbullet', position(), '.gif')}" o:title="{concat('SOpicbullet', position())}"/> 213 </v:shape> 214 </w:pict> 215 </w:listPicBullet> 216 </xsl:for-each> 217 </xsl:template> 218 <xsl:template name="convert_list_number"> 219 <xsl:param name="number-format"/> 220 <xsl:choose> 221 <xsl:when test="$number-format = 'a'"> 222 <!-- nfcLCLetter: Lowercase alpah --> 223 <w:nfc w:val="4"/> 224 </xsl:when> 225 <xsl:when test="$number-format = 'A'"> 226 <!-- nfcUCLetter: Uppercase alpha --> 227 <w:nfc w:val="3"/> 228 </xsl:when> 229 <xsl:when test="$number-format = 'i'"> 230 <!-- nfcLCRoman: Lowercase roman --> 231 <w:nfc w:val="2"/> 232 </xsl:when> 233 <xsl:when test="$number-format = 'I'"> 234 <!-- nfcUCRoman: Uppercase roman --> 235 <w:nfc w:val="1"/> 236 </xsl:when> 237 <xsl:when test="$number-format = '1, 2, 3, ...'"> 238 <!-- '1, 2, 3, ...' also seems: decimal-full-width2 --> 239 <w:nfc w:val="14"/> 240 </xsl:when> 241 <xsl:when test="$number-format = '①, ②, ③, ...'"> 242 <w:nfc w:val="18"/> 243 </xsl:when> 244 <xsl:when test="$number-format = '一, 二, 三, ...'"> 245 <!-- '一, 二, 三, ...' also seems: ideograph-digital, japanese-counting, japanese-digital-ten-thousand, 246 taiwanese-counting, taiwanese-counting-thousand, taiwanese-digital, chinese-counting, korean-digital2 --> 247 <w:nfc w:val="10"/> 248 </xsl:when> 249 <xsl:when test="$number-format = '壹, 贰, 叁, ...'"> 250 <w:nfc w:val="38"/> 251 </xsl:when> 252 <xsl:when test="$number-format = '壹, 貳, 參, ...'"> 253 <w:nfc w:val="34"/> 254 </xsl:when> 255 <xsl:when test="$number-format = '甲, 乙, 丙, ...'"> 256 <w:nfc w:val="30"/> 257 </xsl:when> 258 <xsl:when test="$number-format = '子, 丑, 寅, ...'"> 259 <w:nfc w:val="31"/> 260 </xsl:when> 261 <xsl:when test="$number-format = '壱, 弐, 参, ...'"> 262 <w:nfc w:val="16"/> 263 </xsl:when> 264 <xsl:when test="$number-format = 'ア, イ, ウ, ...'"> 265 <w:nfc w:val="12"/> 266 </xsl:when> 267 <xsl:when test="$number-format = 'ア, イ, ウ, ...'"> 268 <w:nfc w:val="20"/> 269 </xsl:when> 270 <xsl:when test="$number-format = 'イ, ロ, ハ, ...'"> 271 <w:nfc w:val="13"/> 272 </xsl:when> 273 <xsl:when test="$number-format = 'イ, ロ, ハ, ...'"> 274 <w:nfc w:val="21"/> 275 </xsl:when> 276 <xsl:when test="$number-format = '일, 이, 삼, ...'"> 277 <!-- '일, 이, 삼, ...' also seems: korean-counting --> 278 <w:nfc w:val="41"/> 279 </xsl:when> 280 <xsl:when test="$number-format = 'ㄱ, ㄴ, ㄷ, ...' or $number-format = '㉠, ㉡, ㉢, ...'"> 281 <!-- mapping circled to uncirled --> 282 <w:nfc w:val="25"/> 283 </xsl:when> 284 <xsl:when test='$number-format = "가, 나, 다, ..." or $number-format = "㉮, ㉯, ㉰, ..."'> 285 <!-- mapping circled to uncirled --> 286 <w:nfc w:val="24"/> 287 </xsl:when> 288 <xsl:when test="$number-format ='أ, ب, ت, ...'"> 289 <!-- 46. hebrew-1--> 290 <w:nfc w:val="46"/> 291 </xsl:when> 292 <xsl:when test="$number-format = 'ก, ข, ฃ, ...'"> 293 <!--53. thai-letters not match well !--> 294 <w:nfc w:val="53"/> 295 </xsl:when> 296 <xsl:when test="$number-format='א, ב, ג, ...'"> 297 <!--45. arabic-alpha--> 298 <w:nfc w:val="45"/> 299 </xsl:when> 300 <xsl:when test="string-length($number-format)=0"> 301 <w:nfc w:val="255"/> 302 </xsl:when> 303 <xsl:when test="$number-format = 'Native Numbering'"> 304 <xsl:variable name="locale" select="/office:document/office:meta/dc:language"/> 305 <xsl:choose> 306 <xsl:when test="starts-with($locale, 'th-')"> 307 <!-- for Thai, mapping thai-numbers, thai-counting to thai-numbers --> 308 <w:nfc w:val="54"/> 309 </xsl:when> 310 <xsl:when test="starts-with($locale, 'hi-')"> 311 <!-- for Hindi, mapping hindi-vowels, hindi-consonants, hindi-counting to hindi-numbers --> 312 <w:nfc w:val="51"/> 313 </xsl:when> 314 <xsl:when test="starts-with($locale, 'ar-')"> 315 <!-- for Arabic, mapping arabic-abjad to arabic-alpha --> 316 <w:nfc w:val="45"/> 317 </xsl:when> 318 <xsl:when test="starts-with($locale, 'he-')"> 319 <!-- for Hebrew, mapping hebrew-2 to --> 320 <w:nfc w:val="46"/> 321 </xsl:when> 322 <xsl:when test="starts-with($locale, 'ru-')"> 323 <!-- for Russian, mapping russian-upper to russian-lower --> 324 <w:nfc w:val="58"/> 325 </xsl:when> 326 <xsl:when test="starts-with($locale, 'vi-')"> 327 <!-- for Vietnamese --> 328 <w:nfc w:val="56"/> 329 </xsl:when> 330 </xsl:choose> 331 </xsl:when> 332 <!-- unsupported: ordinal, cardinal-text, ordinal-text, hex, chicago, bullet, ideograph-zodiac-traditional, 333 chinese-not-impl, korean-legal, none --> 334 </xsl:choose> 335 </xsl:template> 336</xsl:stylesheet> 337