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:include href="../../common/math.xsl"/> 26 <xsl:template name="test-arc"> 27 <xsl:call-template name="svg-arc2vml-arc"> 28 <!-- M 125,75 a100,50 0 ?,? 100,50 --> 29 <xsl:with-param name="x0" select="125"/> 30 <xsl:with-param name="y0" select="75"/> 31 <xsl:with-param name="rx" select="100"/> 32 <xsl:with-param name="ry" select="50"/> 33 <xsl:with-param name="x-axis-rotation" select="0"/> 34 <xsl:with-param name="large-arc-flag" select="0"/> 35 <xsl:with-param name="sweep-flag" select="0"/> 36 <xsl:with-param name="x" select="225"/> 37 <xsl:with-param name="y" select="125"/> 38 </xsl:call-template> 39 </xsl:template> 40 <xsl:template name="test"> 41 <xsl:call-template name="svgpath2vmlpath"> 42 <xsl:with-param name="svg-path" select="'M 36.0 162.0 C 38.0 168.0 39.0-172.0 40.0 176.0 S 42.0 184.0 144.0 188.0'"/> 43 </xsl:call-template> 44 </xsl:template> 45 <xsl:template name="svgpath2vmlpath"> 46 <xsl:param name="svg-path"/> 47 <xsl:param name="vml-path" select="''"/> 48 <xsl:param name="position" select="1"/> 49 <xsl:param name="last-command" select="'M'"/> 50 <xsl:param name="current-x" select="'0'"/> 51 <xsl:param name="current-y" select="'0'"/> 52 <xsl:variable name="command-and-newpos"> 53 <xsl:call-template name="get-path-command"> 54 <xsl:with-param name="svg-path" select="$svg-path"/> 55 <xsl:with-param name="position" select="$position"/> 56 <xsl:with-param name="last-command" select="$last-command"/> 57 </xsl:call-template> 58 </xsl:variable> 59 <xsl:variable name="command" select="substring-before($command-and-newpos , ':')"/> 60 <xsl:variable name="newpos" select="substring-after($command-and-newpos , ':')"/> 61 <xsl:choose> 62 <xsl:when test="$command = 'M' "> 63 <!-- absolute moveto --> 64 <xsl:variable name="new-vml-path" select="concat($vml-path ,' m ' ) "/> 65 <xsl:variable name="num-and-pos"> 66 <xsl:call-template name="get-number-after"> 67 <xsl:with-param name="svg-path" select="$svg-path"/> 68 <xsl:with-param name="position" select="$newpos"/> 69 <xsl:with-param name="count" select="2"/> 70 </xsl:call-template> 71 </xsl:variable> 72 <xsl:call-template name="svgpath2vmlpath"> 73 <xsl:with-param name="svg-path" select="$svg-path"/> 74 <xsl:with-param name="vml-path" select=" concat($new-vml-path , substring-before( $num-and-pos , ':') , ' ') "/> 75 <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':') "/> 76 <xsl:with-param name="last-command" select="'L'"/> 77 <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':') , ' ') "/> 78 <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':') , ' ') "/> 79 </xsl:call-template> 80 </xsl:when> 81 <xsl:when test="$command = 'm' "> 82 <!-- relative moveto --> 83 <xsl:variable name="new-vml-path" select="concat($vml-path ,' t ' ) "/> 84 <xsl:variable name="num-and-pos"> 85 <xsl:call-template name="get-number-after"> 86 <xsl:with-param name="svg-path" select="$svg-path"/> 87 <xsl:with-param name="position" select="$newpos"/> 88 <xsl:with-param name="count" select="2"/> 89 </xsl:call-template> 90 </xsl:variable> 91 <xsl:call-template name="svgpath2vmlpath"> 92 <xsl:with-param name="svg-path" select="$svg-path"/> 93 <xsl:with-param name="vml-path" select=" concat($new-vml-path , substring-before( $num-and-pos , ':') , ' ') "/> 94 <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':') "/> 95 <xsl:with-param name="last-command" select="'l'"/> 96 <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':') , ' ') + $current-x"/> 97 <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':') , ' ') + $current-y "/> 98 </xsl:call-template> 99 </xsl:when> 100 <xsl:when test="$command = 'L' "> 101 <!-- absolute lineto --> 102 <xsl:variable name="new-vml-path" select="concat($vml-path ,' l ' ) "/> 103 <xsl:variable name="num-and-pos"> 104 <xsl:call-template name="get-number-after"> 105 <xsl:with-param name="svg-path" select="$svg-path"/> 106 <xsl:with-param name="position" select="$newpos"/> 107 <xsl:with-param name="count" select="2"/> 108 </xsl:call-template> 109 </xsl:variable> 110 <xsl:call-template name="svgpath2vmlpath"> 111 <xsl:with-param name="svg-path" select="$svg-path"/> 112 <xsl:with-param name="vml-path" select=" concat($new-vml-path , substring-before( $num-and-pos , ':') , ' ') "/> 113 <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':') "/> 114 <xsl:with-param name="last-command" select="$command"/> 115 <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':') , ' ') "/> 116 <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':') , ' ') "/> 117 </xsl:call-template> 118 </xsl:when> 119 <xsl:when test="$command = 'l' "> 120 <!-- relative lineto --> 121 <xsl:variable name="new-vml-path" select="concat($vml-path ,' r ' ) "/> 122 <xsl:variable name="num-and-pos"> 123 <xsl:call-template name="get-number-after"> 124 <xsl:with-param name="svg-path" select="$svg-path"/> 125 <xsl:with-param name="position" select="$newpos"/> 126 <xsl:with-param name="count" select="2"/> 127 </xsl:call-template> 128 </xsl:variable> 129 <xsl:call-template name="svgpath2vmlpath"> 130 <xsl:with-param name="svg-path" select="$svg-path"/> 131 <xsl:with-param name="vml-path" select=" concat($new-vml-path , substring-before( $num-and-pos , ':') , ' ') "/> 132 <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':') "/> 133 <xsl:with-param name="last-command" select="$command"/> 134 <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':') , ' ') + $current-x "/> 135 <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':') , ' ') + $current-y "/> 136 </xsl:call-template> 137 </xsl:when> 138 <xsl:when test="$command = 'H' "> 139 <!-- absolute horizontal lineto --> 140 <xsl:variable name="new-vml-path" select="concat($vml-path ,' l ' ) "/> 141 <xsl:variable name="num-and-pos"> 142 <xsl:call-template name="get-number-after"> 143 <xsl:with-param name="svg-path" select="$svg-path"/> 144 <xsl:with-param name="position" select="$newpos"/> 145 <xsl:with-param name="count" select="1"/> 146 </xsl:call-template> 147 </xsl:variable> 148 <xsl:call-template name="svgpath2vmlpath"> 149 <xsl:with-param name="svg-path" select="$svg-path"/> 150 <xsl:with-param name="vml-path" select=" concat($new-vml-path , substring-before( $num-and-pos , ':') , ' ' , $current-y , ' ') "/> 151 <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':') "/> 152 <xsl:with-param name="last-command" select="$command"/> 153 <xsl:with-param name="current-x" select=" substring-before( $num-and-pos , ':') "/> 154 <xsl:with-param name="current-y" select=" $current-y"/> 155 </xsl:call-template> 156 </xsl:when> 157 <xsl:when test="$command = 'h' "> 158 <!-- relative horizontal lineto --> 159 <xsl:variable name="new-vml-path" select="concat($vml-path ,' l ' ) "/> 160 <xsl:variable name="num-and-pos"> 161 <xsl:call-template name="get-number-after"> 162 <xsl:with-param name="svg-path" select="$svg-path"/> 163 <xsl:with-param name="position" select="$newpos"/> 164 <xsl:with-param name="count" select="1"/> 165 </xsl:call-template> 166 </xsl:variable> 167 <xsl:call-template name="svgpath2vmlpath"> 168 <xsl:with-param name="svg-path" select="$svg-path"/> 169 <xsl:with-param name="vml-path" select=" concat($new-vml-path , substring-before( $num-and-pos , ':') + $current-x , ' ' , $current-y , ' ') "/> 170 <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':') "/> 171 <xsl:with-param name="last-command" select="$command"/> 172 <xsl:with-param name="current-x" select=" substring-before( $num-and-pos , ':') + $current-x"/> 173 <xsl:with-param name="current-y" select=" $current-y"/> 174 </xsl:call-template> 175 </xsl:when> 176 <xsl:when test="$command = 'V' "> 177 <!-- absolute vertical lineto --> 178 <xsl:variable name="new-vml-path" select="concat($vml-path ,' l ' ) "/> 179 <xsl:variable name="num-and-pos"> 180 <xsl:call-template name="get-number-after"> 181 <xsl:with-param name="svg-path" select="$svg-path"/> 182 <xsl:with-param name="position" select="$newpos"/> 183 <xsl:with-param name="count" select="1"/> 184 </xsl:call-template> 185 </xsl:variable> 186 <xsl:call-template name="svgpath2vmlpath"> 187 <xsl:with-param name="svg-path" select="$svg-path"/> 188 <xsl:with-param name="vml-path" select=" concat($new-vml-path , $current-x , ' ' , substring-before( $num-and-pos , ':') , ' ' ) "/> 189 <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':') "/> 190 <xsl:with-param name="last-command" select="$command"/> 191 <xsl:with-param name="current-x" select=" $current-x"/> 192 <xsl:with-param name="current-y" select=" substring-before( $num-and-pos , ':') "/> 193 </xsl:call-template> 194 </xsl:when> 195 <xsl:when test="$command = 'v' "> 196 <!-- relative horizontal lineto --> 197 <xsl:variable name="new-vml-path" select="concat($vml-path ,' l ' ) "/> 198 <xsl:variable name="num-and-pos"> 199 <xsl:call-template name="get-number-after"> 200 <xsl:with-param name="svg-path" select="$svg-path"/> 201 <xsl:with-param name="position" select="$newpos"/> 202 <xsl:with-param name="count" select="1"/> 203 </xsl:call-template> 204 </xsl:variable> 205 <xsl:call-template name="svgpath2vmlpath"> 206 <xsl:with-param name="svg-path" select="$svg-path"/> 207 <xsl:with-param name="vml-path" select=" concat($new-vml-path , $current-x , ' ' , substring-before( $num-and-pos , ':') + $current-y , ' ' ) "/> 208 <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':') "/> 209 <xsl:with-param name="last-command" select="$command"/> 210 <xsl:with-param name="current-x" select=" $current-x"/> 211 <xsl:with-param name="current-y" select=" substring-before( $num-and-pos , ':') "/> 212 </xsl:call-template> 213 </xsl:when> 214 <xsl:when test="$command = 'C' "> 215 <!-- absolute curveto --> 216 <xsl:variable name="new-vml-path" select="concat($vml-path ,' c ' ) "/> 217 <xsl:variable name="control-and-pos"> 218 <xsl:call-template name="get-number-after"> 219 <xsl:with-param name="svg-path" select="$svg-path"/> 220 <xsl:with-param name="position" select="$newpos"/> 221 <xsl:with-param name="count" select="4"/> 222 </xsl:call-template> 223 </xsl:variable> 224 <xsl:variable name="num-and-pos"> 225 <xsl:call-template name="get-number-after"> 226 <xsl:with-param name="svg-path" select="$svg-path"/> 227 <xsl:with-param name="position" select="substring-after( $control-and-pos , ':') "/> 228 <xsl:with-param name="count" select="2"/> 229 </xsl:call-template> 230 </xsl:variable> 231 <xsl:call-template name="svgpath2vmlpath"> 232 <xsl:with-param name="svg-path" select="$svg-path"/> 233 <xsl:with-param name="vml-path" select=" concat($new-vml-path , substring-before( $control-and-pos , ':') , ' ' , substring-before( $num-and-pos , ':') , ' ') "/> 234 <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':') "/> 235 <xsl:with-param name="last-command" select="$command"/> 236 <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':') , ' ') "/> 237 <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':') , ' ') "/> 238 </xsl:call-template> 239 </xsl:when> 240 <xsl:when test="$command = 'c' "> 241 <!-- relative curveto --> 242 <xsl:variable name="new-vml-path" select="concat($vml-path ,' v ' ) "/> 243 <xsl:variable name="control-and-pos"> 244 <xsl:call-template name="get-number-after"> 245 <xsl:with-param name="svg-path" select="$svg-path"/> 246 <xsl:with-param name="position" select="$newpos"/> 247 <xsl:with-param name="count" select="4"/> 248 </xsl:call-template> 249 </xsl:variable> 250 <xsl:variable name="num-and-pos"> 251 <xsl:call-template name="get-number-after"> 252 <xsl:with-param name="svg-path" select="$svg-path"/> 253 <xsl:with-param name="position" select="substring-after( $control-and-pos , ':') "/> 254 <xsl:with-param name="count" select="2"/> 255 </xsl:call-template> 256 </xsl:variable> 257 <xsl:call-template name="svgpath2vmlpath"> 258 <xsl:with-param name="svg-path" select="$svg-path"/> 259 <xsl:with-param name="vml-path" select=" concat($new-vml-path , substring-before( $control-and-pos , ':') , ' ' , substring-before( $num-and-pos , ':') , ' ') "/> 260 <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':') "/> 261 <xsl:with-param name="last-command" select="$command"/> 262 <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':') , ' ') + $current-x "/> 263 <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':') , ' ') + $current-y "/> 264 </xsl:call-template> 265 </xsl:when> 266 <xsl:when test="$command = 'S' "> 267 <!-- absolute shorthand/smooth curveto --> 268 <xsl:variable name="new-vml-path" select="concat($vml-path ,' c ' ) "/> 269 <xsl:variable name="control-and-pos"> 270 <xsl:call-template name="get-number-after"> 271 <xsl:with-param name="svg-path" select="$svg-path"/> 272 <xsl:with-param name="position" select="$newpos"/> 273 <xsl:with-param name="count" select="2"/> 274 </xsl:call-template> 275 </xsl:variable> 276 <xsl:variable name="num-and-pos"> 277 <xsl:call-template name="get-number-after"> 278 <xsl:with-param name="svg-path" select="$svg-path"/> 279 <xsl:with-param name="position" select="substring-after( $control-and-pos , ':') "/> 280 <xsl:with-param name="count" select="2"/> 281 </xsl:call-template> 282 </xsl:variable> 283 <xsl:variable name="control-1"> 284 <xsl:choose> 285 <xsl:when test="string-length(translate($last-command, 'CcSs','') )= 0 "> 286 <xsl:variable name="previous-control-2"> 287 <xsl:call-template name="get-number-before"> 288 <xsl:with-param name="svg-path" select="$svg-path"/> 289 <xsl:with-param name="position" select="$position"/> 290 <xsl:with-param name="count" select="2"/> 291 <xsl:with-param name="skipcount" select="2"/> 292 </xsl:call-template> 293 </xsl:variable> 294 <xsl:value-of select="substring-before($previous-control-2 , ':') "/> 295 </xsl:when> 296 <xsl:otherwise> 297 <xsl:value-of select="substring-before($control-and-pos, ':') "/> 298 </xsl:otherwise> 299 </xsl:choose> 300 </xsl:variable> 301 <xsl:call-template name="svgpath2vmlpath"> 302 <xsl:with-param name="svg-path" select="$svg-path"/> 303 <xsl:with-param name="vml-path" select=" concat($new-vml-path , $control-1 , ' ' , substring-before( $control-and-pos , ':') , ' ' , substring-before( $num-and-pos , ':') , ' ') "/> 304 <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':') "/> 305 <xsl:with-param name="last-command" select="$command"/> 306 <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':') , ' ') "/> 307 <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':') , ' ') "/> 308 </xsl:call-template> 309 </xsl:when> 310 <xsl:when test="$command = 's' "> 311 <!-- absolute shorthand/smooth curveto --> 312 <xsl:variable name="new-vml-path" select="concat($vml-path ,' v ' ) "/> 313 <xsl:variable name="control-and-pos"> 314 <xsl:call-template name="get-number-after"> 315 <xsl:with-param name="svg-path" select="$svg-path"/> 316 <xsl:with-param name="position" select="$newpos"/> 317 <xsl:with-param name="count" select="2"/> 318 </xsl:call-template> 319 </xsl:variable> 320 <xsl:variable name="num-and-pos"> 321 <xsl:call-template name="get-number-after"> 322 <xsl:with-param name="svg-path" select="$svg-path"/> 323 <xsl:with-param name="position" select="substring-after( $control-and-pos , ':') "/> 324 <xsl:with-param name="count" select="2"/> 325 </xsl:call-template> 326 </xsl:variable> 327 <xsl:variable name="control-1"> 328 <xsl:choose> 329 <xsl:when test="string-length(translate($last-command, 'CcSs' , '')) = 0 "> 330 <xsl:variable name="previous-control-2"> 331 <xsl:call-template name="get-number-before"> 332 <xsl:with-param name="svg-path" select="$svg-path"/> 333 <xsl:with-param name="position" select="$position"/> 334 <xsl:with-param name="count" select="2"/> 335 <xsl:with-param name="skipcount" select="2"/> 336 </xsl:call-template> 337 </xsl:variable> 338 <xsl:value-of select="substring-before($previous-control-2 , ':') "/> 339 </xsl:when> 340 <xsl:otherwise> 341 <xsl:value-of select="substring-before($control-and-pos, ':') "/> 342 </xsl:otherwise> 343 </xsl:choose> 344 </xsl:variable> 345 <xsl:call-template name="svgpath2vmlpath"> 346 <xsl:with-param name="svg-path" select="$svg-path"/> 347 <xsl:with-param name="vml-path" select=" concat($new-vml-path , $control-1 , ' ' , substring-before( $control-and-pos , ':') , ' ' , substring-before( $num-and-pos , ':') , ' ') "/> 348 <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':') "/> 349 <xsl:with-param name="last-command" select="$command"/> 350 <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':') , ' ') + $current-x "/> 351 <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':') , ' ') + $current-y "/> 352 </xsl:call-template> 353 </xsl:when> 354 <xsl:when test="$command = 'Q' "> 355 <!-- absolute quadratic bézier curves --> 356 <xsl:variable name="new-vml-path" select="concat($vml-path ,' qb ' ) "/> 357 <xsl:variable name="control-and-pos"> 358 <xsl:call-template name="get-number-after"> 359 <xsl:with-param name="svg-path" select="$svg-path"/> 360 <xsl:with-param name="position" select="$newpos"/> 361 <xsl:with-param name="count" select="2"/> 362 </xsl:call-template> 363 </xsl:variable> 364 <xsl:variable name="num-and-pos"> 365 <xsl:call-template name="get-number-after"> 366 <xsl:with-param name="svg-path" select="$svg-path"/> 367 <xsl:with-param name="position" select="substring-after( $control-and-pos , ':') "/> 368 <xsl:with-param name="count" select="2"/> 369 </xsl:call-template> 370 </xsl:variable> 371 <xsl:call-template name="svgpath2vmlpath"> 372 <xsl:with-param name="svg-path" select="$svg-path"/> 373 <xsl:with-param name="vml-path" select=" concat($new-vml-path , substring-before( $control-and-pos , ':') , ' ' , substring-before( $num-and-pos , ':') , ' ') "/> 374 <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':') "/> 375 <xsl:with-param name="last-command" select="$command"/> 376 <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':') , ' ') "/> 377 <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':') , ' ') "/> 378 </xsl:call-template> 379 </xsl:when> 380 <xsl:when test="$command = 'q' "> 381 <!-- relative quadratic bézier curves --> 382 <xsl:variable name="control-and-pos"> 383 <xsl:call-template name="get-number-after"> 384 <xsl:with-param name="svg-path" select="$svg-path"/> 385 <xsl:with-param name="position" select="$newpos"/> 386 <xsl:with-param name="count" select="2"/> 387 </xsl:call-template> 388 </xsl:variable> 389 <xsl:variable name="control" select="substring-before( $control-and-pos , ':') "/> 390 <xsl:variable name="new-vml-path" select="concat($vml-path ,' qb ' , substring-before($control,' ') + $current-x , ' ' , substring-after($control , ' ') + $current-y ) "/> 391 <xsl:variable name="num-and-pos"> 392 <xsl:call-template name="get-number-after"> 393 <xsl:with-param name="svg-path" select="$svg-path"/> 394 <xsl:with-param name="position" select="substring-after( $control-and-pos , ':') "/> 395 <xsl:with-param name="count" select="2"/> 396 </xsl:call-template> 397 </xsl:variable> 398 <xsl:variable name="number" select="substring-before($num-and-pos, ':')"/> 399 <xsl:variable name="absolute-number" select="concat(substring-before($number, ' ') + $current-x , ' ' , substring-after($number, ' ') + $current-y)"/> 400 <xsl:call-template name="svgpath2vmlpath"> 401 <xsl:with-param name="svg-path" select="$svg-path"/> 402 <xsl:with-param name="vml-path" select=" concat($new-vml-path , ' ' , $absolute-number , ' ') "/> 403 <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':') "/> 404 <xsl:with-param name="last-command" select="$command"/> 405 <xsl:with-param name="current-x" select=" substring-before( $absolute-number , ' ') "/> 406 <xsl:with-param name="current-y" select=" substring-after( $absolute-number , ' ') "/> 407 </xsl:call-template> 408 </xsl:when> 409 <xsl:when test="$command = 'Z' or $command = 'z' "> 410 <!-- closepath --> 411 <xsl:variable name="new-vml-path" select="concat($vml-path ,' x ' ) "/> 412 <xsl:call-template name="svgpath2vmlpath"> 413 <xsl:with-param name="svg-path" select="$svg-path"/> 414 <xsl:with-param name="vml-path" select=" concat($new-vml-path , ' ') "/> 415 <xsl:with-param name="position" select=" $newpos "/> 416 <xsl:with-param name="last-command" select="$command"/> 417 <xsl:with-param name="current-x" select=" $current-x "/> 418 <xsl:with-param name="current-y" select=" $current-y"/> 419 </xsl:call-template> 420 </xsl:when> 421 <xsl:otherwise> 422 <xsl:value-of select="$vml-path"/> 423 </xsl:otherwise> 424 </xsl:choose> 425 </xsl:template> 426 <xsl:template name="get-number-before"> 427 <!-- get $count number of number before current position , output format:number1 number2 ... numberN:newpostion 428 skip $skipcount of numbers 429 --> 430 <xsl:param name="svg-path"/> 431 <xsl:param name="position" select="1"/> 432 <xsl:param name="count" select="1"/> 433 <xsl:param name="skipcount" select="0"/> 434 <xsl:param name="number" select="''"/> 435 <xsl:choose> 436 <xsl:when test="$count = 0"> 437 <xsl:value-of select=" concat($number , ':' , $position) "/> 438 </xsl:when> 439 <xsl:otherwise> 440 <xsl:variable name="num-pos"> 441 <xsl:call-template name="get-number-position"> 442 <xsl:with-param name="svg-path" select="$svg-path"/> 443 <xsl:with-param name="position" select="$position"/> 444 <xsl:with-param name="direction" select="-1"/> 445 </xsl:call-template> 446 </xsl:variable> 447 <xsl:variable name="previous-num-and-pos"> 448 <xsl:call-template name="get-previous-number"> 449 <xsl:with-param name="svg-path" select="$svg-path"/> 450 <xsl:with-param name="position" select="$num-pos"/> 451 </xsl:call-template> 452 </xsl:variable> 453 <xsl:if test="$skipcount > 0"> 454 <xsl:call-template name="get-number-before"> 455 <xsl:with-param name="svg-path" select="$svg-path"/> 456 <xsl:with-param name="position" select="substring-after($previous-num-and-pos , ':')"/> 457 <xsl:with-param name="count" select="$count"/> 458 <xsl:with-param name="skipcount" select="$skipcount - 1"/> 459 <xsl:with-param name="number" select="$number"/> 460 </xsl:call-template> 461 </xsl:if> 462 <xsl:if test="$skipcount = 0"> 463 <xsl:variable name="new-number"> 464 <xsl:if test="not($count = 1)"> 465 <xsl:value-of select="' '"/> 466 </xsl:if> 467 <xsl:value-of select=" concat( substring-before($previous-num-and-pos , ':') , $number ) "/> 468 </xsl:variable> 469 <xsl:call-template name="get-number-before"> 470 <xsl:with-param name="svg-path" select="$svg-path"/> 471 <xsl:with-param name="position" select="substring-after($previous-num-and-pos , ':')"/> 472 <xsl:with-param name="count" select="$count - 1"/> 473 <xsl:with-param name="skipcount" select="0"/> 474 <xsl:with-param name="number" select="$new-number"/> 475 </xsl:call-template> 476 </xsl:if> 477 </xsl:otherwise> 478 </xsl:choose> 479 </xsl:template> 480 <xsl:template name="get-number-after"> 481 <!-- get $count number of number after current position, output format:number1 number2 ... numberN:newpostion 482 skip $skipcount of numbers 483 --> 484 <xsl:param name="svg-path"/> 485 <xsl:param name="position" select="1"/> 486 <xsl:param name="count" select="1"/> 487 <xsl:param name="skipcount" select="0"/> 488 <xsl:param name="number" select="''"/> 489 <xsl:choose> 490 <xsl:when test="$count = 0"> 491 <xsl:value-of select=" concat($number , ':' , $position) "/> 492 </xsl:when> 493 <xsl:otherwise> 494 <xsl:variable name="num-pos"> 495 <xsl:call-template name="get-number-position"> 496 <xsl:with-param name="svg-path" select="$svg-path"/> 497 <xsl:with-param name="position" select="$position"/> 498 <xsl:with-param name="direction" select="1"/> 499 </xsl:call-template> 500 </xsl:variable> 501 <xsl:variable name="next-num-and-pos"> 502 <xsl:call-template name="get-next-number"> 503 <xsl:with-param name="svg-path" select="$svg-path"/> 504 <xsl:with-param name="position" select="$num-pos"/> 505 </xsl:call-template> 506 </xsl:variable> 507 <xsl:if test="$skipcount > 0"> 508 <xsl:call-template name="get-number-after"> 509 <xsl:with-param name="svg-path" select="$svg-path"/> 510 <xsl:with-param name="position" select="substring-after($next-num-and-pos , ':')"/> 511 <xsl:with-param name="count" select="$count"/> 512 <xsl:with-param name="skipcount" select="$skipcount - 1"/> 513 <xsl:with-param name="number" select="$number"/> 514 </xsl:call-template> 515 </xsl:if> 516 <xsl:if test="$skipcount = 0"> 517 <xsl:variable name="new-number"> 518 <xsl:value-of select=" concat( $number , substring-before($next-num-and-pos , ':') ) "/> 519 <xsl:if test="not($count = 1)"> 520 <xsl:value-of select="' '"/> 521 </xsl:if> 522 </xsl:variable> 523 <xsl:call-template name="get-number-after"> 524 <xsl:with-param name="svg-path" select="$svg-path"/> 525 <xsl:with-param name="position" select="substring-after($next-num-and-pos , ':')"/> 526 <xsl:with-param name="count" select="$count - 1"/> 527 <xsl:with-param name="skipcount" select="0"/> 528 <xsl:with-param name="number" select="$new-number"/> 529 </xsl:call-template> 530 </xsl:if> 531 </xsl:otherwise> 532 </xsl:choose> 533 </xsl:template> 534 <xsl:template name="get-number-position"> 535 <!-- get the next number start position, direction should be 1 or -1--> 536 <xsl:param name="svg-path"/> 537 <xsl:param name="position"/> 538 <xsl:param name="direction" select="1"/> 539 <xsl:choose> 540 <xsl:when test="$direction = 1 and $position > string-length($svg-path) ">0</xsl:when> 541 <xsl:when test="$direction = -1 and not($position > 0)">0</xsl:when> 542 <xsl:otherwise> 543 <xsl:variable name="curr-char"> 544 <xsl:if test="$direction = 1"> 545 <xsl:value-of select="substring($svg-path, $position , 1)"/> 546 </xsl:if> 547 <xsl:if test="$direction = -1"> 548 <xsl:value-of select="substring($svg-path, $position -1 , 1)"/> 549 </xsl:if> 550 </xsl:variable> 551 <xsl:choose> 552 <xsl:when test="string-length(translate($curr-char , '+-.0123456789' ,'')) = 0 "> 553 <!-- number start--> 554 <xsl:value-of select="$position"/> 555 </xsl:when> 556 <xsl:otherwise> 557 <xsl:call-template name="get-number-position"> 558 <xsl:with-param name="svg-path" select="$svg-path"/> 559 <xsl:with-param name="position" select="$position + $direction"/> 560 <xsl:with-param name="direction" select="$direction"/> 561 </xsl:call-template> 562 </xsl:otherwise> 563 </xsl:choose> 564 </xsl:otherwise> 565 </xsl:choose> 566 </xsl:template> 567 <xsl:template name="get-next-number"> 568 <!-- get the next number from current position--> 569 <xsl:param name="svg-path"/> 570 <xsl:param name="position"/> 571 <xsl:param name="number" select="''"/> 572 <xsl:choose> 573 <xsl:when test="$position > string-length($svg-path) "> 574 <xsl:value-of select=" concat(round($number) , ':' , $position) "/> 575 </xsl:when> 576 <xsl:otherwise> 577 <xsl:variable name="curr-char" select="substring($svg-path, $position , 1)"/> 578 <xsl:choose> 579 <xsl:when test="string-length(translate($curr-char , '.0123456789' ,'')) = 0 "> 580 <!-- is number --> 581 <xsl:call-template name="get-next-number"> 582 <xsl:with-param name="svg-path" select="$svg-path"/> 583 <xsl:with-param name="position" select="$position +1"/> 584 <xsl:with-param name="number" select="concat( $number, $curr-char) "/> 585 </xsl:call-template> 586 </xsl:when> 587 <xsl:when test="string-length(translate($curr-char , '+-' ,'') ) = 0 and string-length($number) = 0"> 588 <!-- is number --> 589 <xsl:call-template name="get-next-number"> 590 <xsl:with-param name="svg-path" select="$svg-path"/> 591 <xsl:with-param name="position" select="$position +1"/> 592 <xsl:with-param name="number" select="concat( $number, $curr-char) "/> 593 </xsl:call-template> 594 </xsl:when> 595 <xsl:otherwise> 596 <xsl:value-of select="concat( round($number) , ':' , $position)"/> 597 </xsl:otherwise> 598 </xsl:choose> 599 </xsl:otherwise> 600 </xsl:choose> 601 </xsl:template> 602 <xsl:template name="get-previous-number"> 603 <!-- get the previous number from current position--> 604 <xsl:param name="svg-path"/> 605 <xsl:param name="position"/> 606 <xsl:param name="number" select="''"/> 607 <xsl:choose> 608 <xsl:when test="not($position > 0)"> 609 <xsl:value-of select="concat( round($number ), ':0')"/> 610 </xsl:when> 611 <xsl:otherwise> 612 <xsl:variable name="curr-char" select="substring($svg-path, $position -1 , 1)"/> 613 <xsl:choose> 614 <xsl:when test="string-length(translate($curr-char , '.0123456789' ,'')) = 0 "> 615 <!-- is number --> 616 <xsl:call-template name="get-previous-number"> 617 <xsl:with-param name="svg-path" select="$svg-path"/> 618 <xsl:with-param name="position" select="$position -1"/> 619 <xsl:with-param name="number" select="concat($curr-char , $number) "/> 620 </xsl:call-template> 621 </xsl:when> 622 <xsl:when test="string-length(translate($curr-char , '+-' ,'') ) = 0 and string-length($number) = 0"> 623 <!-- skip it --> 624 <xsl:call-template name="get-previous-number"> 625 <xsl:with-param name="svg-path" select="$svg-path"/> 626 <xsl:with-param name="position" select="$position -1"/> 627 <xsl:with-param name="number" select="$number "/> 628 </xsl:call-template> 629 </xsl:when> 630 <xsl:when test="string-length(translate($curr-char , '+-' ,'') ) = 0 and string-length($number) > 0"> 631 <!-- finsh it with +/- --> 632 <xsl:value-of select="concat( round( concat( $curr-char, $number)) , ':' , $position)"/> 633 </xsl:when> 634 <xsl:otherwise> 635 <xsl:value-of select="concat( round($number) , ':' , $position)"/> 636 </xsl:otherwise> 637 </xsl:choose> 638 </xsl:otherwise> 639 </xsl:choose> 640 </xsl:template> 641 <xsl:template name="get-path-command"> 642 <xsl:param name="svg-path"/> 643 <xsl:param name="position" select="1"/> 644 <xsl:param name="last-command"/> 645 <xsl:choose> 646 <xsl:when test="$position > string-length($svg-path) "/> 647 <xsl:otherwise> 648 <xsl:variable name="curr-char" select="substring($svg-path, $position , 1)"/> 649 <xsl:choose> 650 <xsl:when test="string-length(translate($curr-char , 'MmZzLlHhVvCcSsQqTtAa' ,'')) = 0 "> 651 <!-- "MmZzLlHhVvCcSsQqTtAa" are all possiable command chars --> 652 <xsl:value-of select="concat( $curr-char , ':' , $position +1)"/> 653 </xsl:when> 654 <xsl:when test="string-length(translate($curr-char , '+-.0123456789' ,'')) = 0 "> 655 <!-- number start, use last command --> 656 <xsl:if test="string-length($last-command) = 0"> 657 <xsl:message>ooo2wordml_path.xsl: Find undefined command</xsl:message> 658 </xsl:if> 659 <xsl:value-of select="concat( $last-command , ':' , $position )"/> 660 </xsl:when> 661 <xsl:when test="string-length(translate($curr-char , ',	  ' ,'')) = 0 "> 662 <!-- space or ',' should be skip --> 663 <xsl:call-template name="get-path-command"> 664 <xsl:with-param name="svg-path" select="$svg-path"/> 665 <xsl:with-param name="position" select="$position +1"/> 666 <xsl:with-param name="last-command" select="$last-command"/> 667 </xsl:call-template> 668 </xsl:when> 669 <xsl:otherwise> 670 <xsl:message>ooo2wordml_path.xsl: Find undefined command:<xsl:value-of select="$curr-char"/> 671 </xsl:message> 672 </xsl:otherwise> 673 </xsl:choose> 674 </xsl:otherwise> 675 </xsl:choose> 676 </xsl:template> 677 <xsl:template name="svg-arc2vml-arc"> 678 <xsl:param name="x0"/> 679 <xsl:param name="y0"/> 680 <xsl:param name="rx"/> 681 <xsl:param name="ry"/> 682 <xsl:param name="x-axis-rotation" select="0"/> 683 <xsl:param name="large-arc-flag" select="0"/> 684 <xsl:param name="sweep-flag" select="0"/> 685 <xsl:param name="x"/> 686 <xsl:param name="y"/> 687 <!-- Compute 1/2 distance between current and final point --> 688 <xsl:variable name="dx2" select="($x0 - $x) div 2"/> 689 <xsl:variable name="dy2" select="($y0 - $y) div 2"/> 690 <!-- Convert from degrees to radians --> 691 <xsl:variable name="rotation-radian" select="$x-axis-rotation * $pi div 180"/> 692 <!-- Compute (x1, y1). What are x1,y1?--> 693 <xsl:variable name="cos-rotation"> 694 <xsl:call-template name="cos"> 695 <xsl:with-param name="x" select="$rotation-radian"/> 696 </xsl:call-template> 697 </xsl:variable> 698 <xsl:variable name="sin-rotation"> 699 <xsl:call-template name="sin"> 700 <xsl:with-param name="x" select="$rotation-radian"/> 701 </xsl:call-template> 702 </xsl:variable> 703 <xsl:variable name="x1" select="$cos-rotation * $dx2 + $sin-rotation * $dy2"/> 704 <xsl:variable name="y1" select="-1 * $sin-rotation * $dx2 + $cos-rotation * $dy2"/> 705 <!-- Make sure radii are large enough --> 706 <xsl:variable name="rx-abs"> 707 <xsl:call-template name="abs"> 708 <xsl:with-param name="x" select="$rx"/> 709 </xsl:call-template> 710 </xsl:variable> 711 <xsl:variable name="ry-abs"> 712 <xsl:call-template name="abs"> 713 <xsl:with-param name="x" select="$ry"/> 714 </xsl:call-template> 715 </xsl:variable> 716 <xsl:variable name="rx-sq" select="$rx-abs * $rx-abs"/> 717 <xsl:variable name="ry-sq" select="$ry-abs * $ry-abs"/> 718 <xsl:variable name="x1-sq" select="$x1 * $x1"/> 719 <xsl:variable name="y1-sq" select="$y1 * $y1"/> 720 <xsl:variable name="radius-check" select=" $x1-sq div $rx-sq + $y1-sq div $ry-sq "/> 721 <xsl:variable name="radius-check-sqrt"> 722 <xsl:call-template name="sqrt"> 723 <xsl:with-param name="x" select="$radius-check"/> 724 </xsl:call-template> 725 </xsl:variable> 726 <xsl:variable name="new-rx"> 727 <xsl:choose> 728 <xsl:when test="$radius-check > 1"> 729 <xsl:value-of select="$rx-abs * $radius-check-sqrt"/> 730 </xsl:when> 731 <xsl:otherwise> 732 <xsl:value-of select="$rx-abs"/> 733 </xsl:otherwise> 734 </xsl:choose> 735 </xsl:variable> 736 <xsl:variable name="new-ry"> 737 <xsl:choose> 738 <xsl:when test="$radius-check > 1"> 739 <xsl:value-of select="$ry-abs * $radius-check-sqrt"/> 740 </xsl:when> 741 <xsl:otherwise> 742 <xsl:value-of select="$ry-abs"/> 743 </xsl:otherwise> 744 </xsl:choose> 745 </xsl:variable> 746 <xsl:variable name="new-ry-sq"> 747 <xsl:choose> 748 <xsl:when test="$radius-check > 1"> 749 <xsl:value-of select="$new-ry * $new-ry"/> 750 </xsl:when> 751 <xsl:otherwise> 752 <xsl:value-of select="$ry-sq"/> 753 </xsl:otherwise> 754 </xsl:choose> 755 </xsl:variable> 756 <xsl:variable name="new-rx-sq"> 757 <xsl:choose> 758 <xsl:when test="$radius-check > 1"> 759 <xsl:value-of select="$new-rx * $new-rx"/> 760 </xsl:when> 761 <xsl:otherwise> 762 <xsl:value-of select="$rx-sq"/> 763 </xsl:otherwise> 764 </xsl:choose> 765 </xsl:variable> 766 <!-- Step 2: Compute (cx1, cy1) --> 767 <xsl:variable name="sign"> 768 <xsl:choose> 769 <xsl:when test="$large-arc-flag = $sweep-flag">-1</xsl:when> 770 <xsl:otherwise>1</xsl:otherwise> 771 </xsl:choose> 772 </xsl:variable> 773 <xsl:variable name="unchecked-sq" select=" (($new-rx-sq * $new-ry-sq) - ($new-rx-sq * $y1-sq) - ($new-ry-sq * $x1-sq)) div (($new-rx-sq * $y1-sq) + ($new-ry-sq * $x1-sq)) "/> 774 <xsl:variable name="sq"> 775 <xsl:choose> 776 <xsl:when test=" $unchecked-sq < 0">0</xsl:when> 777 <xsl:otherwise> 778 <xsl:value-of select="$unchecked-sq"/> 779 </xsl:otherwise> 780 </xsl:choose> 781 </xsl:variable> 782 <xsl:variable name="sq-sqrt"> 783 <xsl:call-template name="sqrt"> 784 <xsl:with-param name="x" select="$sq"/> 785 </xsl:call-template> 786 </xsl:variable> 787 <xsl:variable name="coef" select="$sign * $sq-sqrt "/> 788 <xsl:variable name="cx1" select="$coef * $new-rx * $y1 div $new-ry"/> 789 <xsl:variable name="cy1" select=" -1 * $coef * $new-ry * $x1 div $new-rx"/> 790 <!-- Step 3: Compute (cx, cy) from (cx1, cy1) --> 791 <xsl:variable name="sx2" select="($x0 +$x) div 2 "/> 792 <xsl:variable name="sy2" select="($y0 +$y) div 2 "/> 793 <xsl:variable name="tmp1" select="$cos-rotation * $cx1 "/> 794 <xsl:variable name="tmp2" select="$cos-rotation * $cx1 "/> 795 <xsl:variable name="cx" select=" $sx2 + ( $cos-rotation * $cx1 - $sin-rotation * $cy1 ) "/> 796 <xsl:variable name="cy" select=" $sy2 + ( $sin-rotation * $cx1 + $cos-rotation * $cy1 ) "/> 797 <!-- Step 4: Compute angle start and angle extent --> 798 <xsl:variable name="ux" select="( $x1 - $cx1) div $new-rx"/> 799 <xsl:variable name="uy" select="( $y1 - $cy1) div $new-ry"/> 800 <xsl:variable name="vx" select="( - 1 * $x1 - $cx1) div $new-rx"/> 801 <xsl:variable name="vy" select="(- 1 * $y1 - $cy1) div $new-ry"/> 802 <xsl:variable name="n"> 803 <xsl:call-template name="sqrt"> 804 <xsl:with-param name="x" select=" ($ux * $ux) + ($uy * $uy) "/> 805 </xsl:call-template> 806 </xsl:variable> 807 <!-- 1 * ux + 0 * uy --> 808 <xsl:variable name="p" select="$ux"/> 809 <xsl:variable name="uy-sign"> 810 <xsl:choose> 811 <xsl:when test=" $uy < 0 ">-1</xsl:when> 812 <xsl:otherwise>1</xsl:otherwise> 813 </xsl:choose> 814 </xsl:variable> 815 <xsl:variable name="acos-pn"> 816 <xsl:call-template name="acos"> 817 <xsl:with-param name="x" select="$p div $n"/> 818 </xsl:call-template> 819 </xsl:variable> 820 <xsl:variable name="theta" select="( $uy-sign * $acos-pn * 180 div $pi ) mod 360 "/> 821 <xsl:variable name="n-delta"> 822 <xsl:call-template name="sqrt"> 823 <xsl:with-param name="x" select="($ux * $ux + $uy * $uy) * ($vx * $vx + $vy * $vy)"/> 824 </xsl:call-template> 825 </xsl:variable> 826 <xsl:variable name="p-delta" select="$ux * $vx + $uy * $vy"/> 827 <xsl:variable name="vy-sign"> 828 <xsl:choose> 829 <xsl:when test="($ux * $vy - $uy * $vx) < 0 ">-1</xsl:when> 830 <xsl:otherwise>1</xsl:otherwise> 831 </xsl:choose> 832 </xsl:variable> 833 <xsl:variable name="acos-pn-delta"> 834 <xsl:call-template name="acos"> 835 <xsl:with-param name="x" select="$p-delta div $n-delta"/> 836 </xsl:call-template> 837 </xsl:variable> 838 <xsl:variable name="unchecked-delta" select="$vy-sign * $acos-pn-delta * 180 div $pi "/> 839 <xsl:variable name="delta"> 840 <xsl:choose> 841 <xsl:when test=" $sweep-flag = 0 and $unchecked-delta > 0 "> 842 <xsl:value-of select=" ($unchecked-delta - 360) mod 360 "/> 843 </xsl:when> 844 <xsl:when test=" $sweep-flag = 1 and $unchecked-delta < 0 "> 845 <xsl:value-of select=" ($unchecked-delta + 360) mod 360 "/> 846 </xsl:when> 847 <xsl:otherwise> 848 <xsl:value-of select=" $unchecked-delta mod 360 "/> 849 </xsl:otherwise> 850 </xsl:choose> 851 </xsl:variable> 852 <xsl:value-of select="concat ($cx, ' ' , $cy, ' ' , $rx, ' ' , $ry, ' ' , $theta, ' ' , $delta, ' ' , $x-axis-rotation) "/> 853 </xsl:template> 854</xsl:stylesheet> 855