home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2012 March / maximum-cd-2012-03.iso / DiscContents / LibO_3.4.3_Win_x86_install_multi.exe / libreoffice1.cab / ooo2wordml_path.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2011-01-31  |  51.4 KB  |  859 lines

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