home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2005 June / PCpro_2005_06.ISO / files / opensource / openoffice / openofficeorg2.cab / ooo2wordml_path.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2005-01-31  |  52.5 KB  |  885 lines

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