home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2011 June / maximum-cd-2011-06.iso / DiscContents / LibO_3.3.1_Win_x86_install_multi.exe / libreoffice1.cab / styles.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2010-12-01  |  29.1 KB  |  696 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"
  29.     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  30.     xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
  31.     xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0"
  32.     xmlns:dc="http://purl.org/dc/elements/1.1/"
  33.     xmlns:dom="http://www.w3.org/2001/xml-events"
  34.     xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"
  35.     xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
  36.     xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
  37.     xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"
  38.     xmlns:math="http://www.w3.org/1998/Math/MathML"
  39.     xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0"
  40.     xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
  41.     xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
  42.     xmlns:ooo="http://openoffice.org/2004/office"
  43.     xmlns:oooc="http://openoffice.org/2004/calc"
  44.     xmlns:ooow="http://openoffice.org/2004/writer"
  45.     xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"
  46.     xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
  47.     xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
  48.     xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
  49.     xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
  50.     xmlns:xlink="http://www.w3.org/1999/xlink"
  51.     xmlns:xt="http://www.jclark.com/xt"
  52.     xmlns:common="http://exslt.org/common"
  53.     xmlns:xalan="http://xml.apache.org/xalan"
  54.     xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:c="urn:schemas-microsoft-com:office:component:spreadsheet" xmlns:html="http://www.w3.org/TR/REC-html40" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:x2="http://schemas.microsoft.com/office/excel/2003/xml" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  55.     exclude-result-prefixes="chart config dc dom dr3d draw fo form math meta number office ooo oooc ooow script style svg table text xlink xt common xalan">
  56.  
  57.     <!-- Used in case of 'style:map', conditional formatting, where a style references to another -->
  58.     <xsl:key name="styles" match="/*/office:styles/style:style | /*/office:automatic-styles/style:style" use="@style:name" />
  59.     <!--
  60.         Mapping of OOo style:name and style:family to excel ss:ID
  61.         Styles form style:style map from style:name to ss:Name
  62.         style:parent-style map to ss:Parent
  63.     -->
  64.     <!--   default styles of the application
  65.     <xsl:template match="style:default-style" mode="styles" >
  66.         <xsl:call-template name="style:style">
  67.             <xsl:with-param name="styleName" select="'Default'" />
  68.         </xsl:call-template>
  69.     </xsl:template>
  70.      -->
  71.  
  72.     <xsl:template match="style:style" mode="styles">
  73.         <xsl:param name="isAutomatic" />
  74.         <xsl:param name="styleName" select="@style:name" />
  75.         <xsl:param name="styleParentName" select="@style:parent-style-name" />
  76.  
  77.         <!-- only row styles used by cells are exported,
  78.             as usual row style properties are already exported as row attributes -->
  79.         <xsl:if test="not(@style:family='table-row') or @style:family='table-row' and key('getCellByStyle', '.')">
  80.             <xsl:element name="Style">
  81.                 <xsl:attribute name="ss:ID">
  82.                     <!-- neglecting that a style is only unique in conjunction with it's family name -->
  83.                     <xsl:value-of select="@style:name" />
  84.                 </xsl:attribute>
  85.                 <xsl:choose>
  86.                     <xsl:when test="not($isAutomatic)">
  87.                         <xsl:choose>
  88.                             <xsl:when test="@style:display-name">
  89.                                 <xsl:attribute name="ss:Name"><xsl:value-of select="@style:display-name"/></xsl:attribute>
  90.                             </xsl:when>
  91.                             <xsl:otherwise>
  92.                                 <xsl:attribute name="ss:Name"><xsl:value-of select="@style:name" /></xsl:attribute>
  93.                             </xsl:otherwise>
  94.                         </xsl:choose>
  95.                         <xsl:choose>
  96.                             <!-- when a non-allowed parent style is found
  97.                                 (in spreadsheetml no style with ss:Name is able to have a ss:Parent)  -->
  98.                             <xsl:when test="@style:parent-style-name">
  99.                                 <!-- styles have to be merged (flatting heritance tree) -->
  100.                                 <xsl:variable name="stylePropertiesContainer">
  101.                                     <xsl:call-template name="merge-all-parent-styles">
  102.                                         <xsl:with-param name="currentStyle" select="." />
  103.                                     </xsl:call-template>
  104.                                 </xsl:variable>
  105.                                 <xsl:choose>
  106.                                     <xsl:when test="function-available('xalan:nodeset')">
  107.                                         <xsl:call-template name="write-style-properties">
  108.                                             <xsl:with-param name="styleProperties" select="xalan:nodeset($stylePropertiesContainer)/*" />
  109.                                         </xsl:call-template>
  110.                                     </xsl:when>
  111.                                     <xsl:when test="function-available('common:node-set')">
  112.                                         <xsl:call-template name="write-style-properties">
  113.                                             <xsl:with-param name="styleProperties" select="common:node-set($stylePropertiesContainer)/*" />
  114.                                         </xsl:call-template>
  115.                                     </xsl:when>
  116.                                     <xsl:when test="function-available('xt:node-set')">
  117.                                         <xsl:call-template name="write-style-properties">
  118.                                             <xsl:with-param name="styleProperties" select="xt:node-set($stylePropertiesContainer)/*" />
  119.                                         </xsl:call-template>
  120.                                     </xsl:when>
  121.                                     <xsl:otherwise>
  122.                                         <xsl:message terminate="yes">WARNING: The required node set function was not found!</xsl:message>
  123.                                     </xsl:otherwise>
  124.                                 </xsl:choose>
  125.                             </xsl:when>
  126.                             <xsl:otherwise>
  127.                                 <xsl:call-template name="write-style-properties" />
  128.                             </xsl:otherwise>
  129.                         </xsl:choose>
  130.                     </xsl:when>
  131.                     <xsl:otherwise>
  132.                         <!-- automatic styles are implicit inherting from a style called 'Default',
  133.                         furthermore nor in spreadsheetml nor in OpenDocument automatic styles are able to inherit from each other -->
  134.                         <xsl:choose>
  135.                             <xsl:when test="@style:parent-style-name and not(@style:parent-style-name = 'Default')">
  136.                                 <xsl:attribute name="ss:Parent"><xsl:value-of select="@style:parent-style-name" /></xsl:attribute>
  137.                             </xsl:when>
  138.                         </xsl:choose>
  139.                         <xsl:call-template name="write-style-properties" />
  140.                     </xsl:otherwise>
  141.                 </xsl:choose>
  142.             </xsl:element>
  143.         </xsl:if>
  144.     </xsl:template>
  145.  
  146.     <!-- resolving the style inheritance by starting from uppermost parent and
  147.          overriding exisiting style properties by new found child properties -->
  148.     <xsl:template name="merge-all-parent-styles">
  149.         <xsl:param name="currentStyle" />
  150.  
  151.         <xsl:choose>
  152.             <!-- in case of a parent, styles have to be merged (flatting heritance tree) -->
  153.             <xsl:when test="$currentStyle/@style:parent-style-name">
  154.                 <!-- collect parent style properties -->
  155.                 <xsl:variable name="parentStyleContainer">
  156.                     <!-- take a look if the parent style has a parent himself -->
  157.                     <xsl:call-template name="merge-all-parent-styles" >
  158.                         <xsl:with-param name="currentStyle" select="key('styles', $currentStyle/@style:parent-style-name)" />
  159.                     </xsl:call-template>
  160.                 </xsl:variable>
  161.                 <xsl:choose>
  162.                     <xsl:when test="function-available('xalan:nodeset')">
  163.                         <xsl:call-template name="merge-style-properties">
  164.                             <xsl:with-param name="childStyleContainer"  select="$currentStyle" />
  165.                             <xsl:with-param name="parentStyleContainer" select="xalan:nodeset($parentStyleContainer)" />
  166.                         </xsl:call-template>
  167.                     </xsl:when>
  168.                     <xsl:when test="function-available('common:node-set')">
  169.                         <xsl:call-template name="merge-style-properties">
  170.                             <xsl:with-param name="childStyleContainer"  select="$currentStyle" />
  171.                             <xsl:with-param name="parentStyleContainer" select="common:node-set($parentStyleContainer)" />
  172.                         </xsl:call-template>
  173.                     </xsl:when>
  174.                     <xsl:when test="function-available('xt:node-set')">
  175.                         <xsl:call-template name="merge-style-properties">
  176.                             <xsl:with-param name="childStyleContainer"  select="$currentStyle" />
  177.                             <xsl:with-param name="parentStyleContainer" select="xt:node-set($parentStyleContainer)" />
  178.                         </xsl:call-template>
  179.                     </xsl:when>
  180.                     <xsl:otherwise>
  181.                         <xsl:message terminate="yes">WARNING: The required node-set function was not found!</xsl:message>
  182.                     </xsl:otherwise>
  183.                 </xsl:choose>
  184.             </xsl:when>
  185.             <!-- called for top parents (or styles without parents) -->
  186.             <xsl:otherwise>
  187.                 <xsl:copy-of select="$currentStyle/*"/>
  188.             </xsl:otherwise>
  189.         </xsl:choose>
  190.     </xsl:template>
  191.  
  192.     <xsl:template name="merge-style-properties">
  193.         <xsl:param name="childStyleContainer" />
  194.         <xsl:param name="parentStyleContainer" />
  195.  
  196.         <xsl:choose>
  197.             <xsl:when test="$parentStyleContainer/*">
  198.                 <xsl:apply-templates select="$parentStyleContainer/*" mode="inheritance">
  199.                     <xsl:with-param name="childStyleContainer" select="$childStyleContainer" />
  200.                 </xsl:apply-templates>
  201.             </xsl:when>
  202.             <xsl:otherwise>
  203.                 <xsl:copy-of select="$childStyleContainer/*"/>
  204.             </xsl:otherwise>
  205.         </xsl:choose>
  206.     </xsl:template>
  207.  
  208.     <xsl:template match="*" mode="inheritance">
  209.         <xsl:param name="childStyleContainer" />
  210.  
  211.         <!-- create an element named equal to the current properties parent element (e.g. style:table-cell-properties) -->
  212.         <xsl:element name="{name()}" namespace="urn:oasis:names:tc:opendocument:xmlns:style:1.0">
  213.             <!-- attributes will be automatically replaced    -->
  214.             <xsl:copy-of select="@*" />
  215.             <xsl:copy-of select="$childStyleContainer/*[name() = name(current()    )]/@*"/>
  216.  
  217.             <!-- elements are not needed yet, will be neglected for simplicity reasons -->
  218.         </xsl:element>
  219.     </xsl:template>
  220.  
  221.     <xsl:key match="/*/office:styles/number:date-style |
  222.                     /*/office:styles/number:time-style |
  223.                     /*/office:styles/number:number-style |
  224.                     /*/office:styles/number:percentage-style |
  225.                     /*/office:styles/number:currency-style |
  226.                     /*/office:automatic-styles/number:date-style |
  227.                     /*/office:automatic-styles/number:time-style |
  228.                     /*/office:automatic-styles/number:number-style  |
  229.                     /*/office:automatic-styles/number:percentage-style |
  230.                     /*/office:automatic-styles/number:currency-style" name="number-style" use="@style:name" />
  231.  
  232.  
  233.     <xsl:template name="write-style-properties">
  234.         <xsl:param name="styleProperties" select="key('styles', @style:name)/*" />
  235.  
  236.         <xsl:call-template name="Alignment">
  237.             <xsl:with-param name="styleProperties" select="$styleProperties" />
  238.         </xsl:call-template>
  239.         <xsl:call-template name="Border">
  240.             <xsl:with-param name="styleProperties" select="$styleProperties" />
  241.         </xsl:call-template>
  242.         <xsl:call-template name="Font">
  243.             <xsl:with-param name="styleProperties" select="$styleProperties" />
  244.             <xsl:with-param name="styleParentName" select="@style:parent-style-name" />
  245.         </xsl:call-template>
  246.         <xsl:call-template name="Interior">
  247.             <xsl:with-param name="styleProperties" select="$styleProperties" />
  248.         </xsl:call-template>
  249.         <xsl:call-template name="NumberFormat">
  250.             <xsl:with-param name="styleProperties" select="$styleProperties" />
  251.         </xsl:call-template>
  252.     </xsl:template>
  253.  
  254.     <!-- context is element 'style:style' -->
  255.     <xsl:template name="NumberFormat">
  256.         <xsl:if test="@style:data-style-name">
  257.             <xsl:variable name="numberStyleName" select="@style:data-style-name" />
  258.             <xsl:variable name="numberStyle" select="key('number-style', $numberStyleName)" />
  259.  
  260.             <xsl:element name="NumberFormat">
  261.                 <xsl:attribute name="ss:Format">
  262.                 <xsl:choose>
  263.                     <xsl:when test="not($numberStyle/node())">
  264.                         <!-- Excel2003sp1 issue: 'General' and 'General Number' is not supported -->
  265.                          <xsl:text>General</xsl:text>
  266.                     </xsl:when>
  267.                     <xsl:when test="name($numberStyle) = 'number:number-style'">
  268.                         <xsl:choose>
  269.                             <xsl:when test="$numberStyle/number:scientific-number">
  270.                                 <xsl:text>Scientific</xsl:text>
  271.                             </xsl:when>
  272.                             <!-- Excel2003sp1 issue: 'General Number' not supported -->
  273.                             <xsl:when test="$numberStyle/number:number/@number:decimal-places and
  274.                                             $numberStyle/number:number/@number:decimal-places='0'">
  275.                                 <xsl:text>General</xsl:text>
  276.                             </xsl:when>
  277.                             <xsl:when test="$numberStyle/number:text">
  278.                                 <xsl:choose>
  279.                                     <xsl:when test="$numberStyle/number:text = 'No' or $numberStyle/number:text = 'Nein'">
  280.                                         <xsl:text>Yes/No</xsl:text>
  281.                                     </xsl:when>
  282.                                     <xsl:when test="$numberStyle/number:text = 'False' or $numberStyle/number:text = 'Falsch'">
  283.                                         <xsl:text>True/False</xsl:text>
  284.                                     </xsl:when>
  285.                                     <xsl:when test="$numberStyle/number:text = 'Off' or $numberStyle/number:text = 'Aus'">
  286.                                         <xsl:text>On/Off</xsl:text>
  287.                                     </xsl:when>
  288.                                     <!-- Excel2003sp1 issue: currency is saved as 'float' -->
  289.                                     <xsl:when test="$numberStyle/number:currency-symbol">
  290.                                         <xsl:choose>
  291.                                             <xsl:when test="contains($numberStyle/number:currency-symbol, 'Γé¼')">
  292.                                                 <xsl:text>Euro Currency</xsl:text>
  293.                                             </xsl:when>
  294.                                             <xsl:otherwise>
  295.                                                 <xsl:text>Currency</xsl:text>
  296.                                             </xsl:otherwise>
  297.                                         </xsl:choose>
  298.                                     </xsl:when>
  299.                                     <!-- Excel2003sp1 issue: 'Currency' is saved as 'float' -->
  300.                                     <xsl:when test="contains($numberStyle/number:text, '$')">
  301.                                         <xsl:text>Currency</xsl:text>
  302.                                     </xsl:when>
  303.                                     <!-- OASIS XML adapation -->
  304.                                     <xsl:otherwise>
  305.                                         <xsl:text>General</xsl:text>
  306.                                     </xsl:otherwise>
  307.                                 </xsl:choose>
  308.                             </xsl:when>
  309.                             <xsl:when test="$numberStyle/number:grouping">
  310.                                 <xsl:text>Standard</xsl:text>
  311.                             </xsl:when>
  312.                             <xsl:otherwise>
  313.                                 <xsl:text>Fixed</xsl:text>
  314.                             </xsl:otherwise>
  315.                         </xsl:choose>
  316.                     </xsl:when>
  317.                     <xsl:when test="name($numberStyle) = 'number:time-style'">
  318.                         <xsl:choose>
  319.                             <xsl:when test="$numberStyle/number:am-pm">
  320.                                 <xsl:choose>
  321.                                     <xsl:when test="$numberStyle/number:seconds">
  322.                                         <xsl:text>Long Time</xsl:text>
  323.                                     </xsl:when>
  324.                                     <xsl:otherwise>
  325.                                         <xsl:text>Medium Time</xsl:text>
  326.                                     </xsl:otherwise>
  327.                                 </xsl:choose>
  328.                             </xsl:when>
  329.                             <xsl:otherwise>
  330.                                 <xsl:text>Short Time</xsl:text>
  331.                             </xsl:otherwise>
  332.                         </xsl:choose>
  333.                     </xsl:when>
  334.                     <xsl:when test="name($numberStyle) = 'number:percentage-style'">
  335.                         <xsl:text>Percent</xsl:text>
  336.                     </xsl:when>
  337.                     <xsl:when test="name($numberStyle) = 'number:currency-style'">
  338.                         <xsl:choose>
  339.                             <xsl:when test="contains($numberStyle/number:currency-symbol, 'Γé¼')">
  340.                                 <xsl:text>Euro Currency</xsl:text>
  341.                             </xsl:when>
  342.                             <xsl:otherwise>
  343.                                 <xsl:text>Currency</xsl:text>
  344.                             </xsl:otherwise>
  345.                         </xsl:choose>
  346.                     </xsl:when>
  347.                     <xsl:otherwise>
  348.                         <xsl:choose>
  349.                             <xsl:when test="$numberStyle/number:month">
  350.                                 <xsl:choose>
  351.                                     <xsl:when test="$numberStyle/number:month/@number:textual and
  352.                                                     $numberStyle/number:month/@number:textual=true()">
  353.                                         <xsl:text>Medium Date</xsl:text>
  354.                                         <!--  Excel2003 sp1 issue: No difference between 'Long Date' and 'Medium Date' -->
  355.                                     </xsl:when>
  356.                                     <xsl:when test="$numberStyle/number:hours">
  357.                                         <xsl:text>General Date</xsl:text>
  358.                                     </xsl:when>
  359.                                     <xsl:when test="$numberStyle/number:year/@number:style and
  360.                                                     $numberStyle/number:year/@number:style='long'">
  361.                                         <xsl:text>Short Date</xsl:text>
  362.                                     </xsl:when>
  363.                                     <!-- OASIS XML adapation -->
  364.                                     <xsl:otherwise>
  365.                                         <xsl:text>Short Date</xsl:text>
  366.                                     </xsl:otherwise>
  367.                                 </xsl:choose>
  368.                             </xsl:when>
  369.                             <!-- OASIS XML adapation -->
  370.                             <xsl:otherwise>
  371.                                 <xsl:text>General</xsl:text>
  372.                             </xsl:otherwise>
  373.                         </xsl:choose>
  374.                     </xsl:otherwise>
  375.                 </xsl:choose>
  376.                 </xsl:attribute>
  377.             </xsl:element>
  378.         </xsl:if>
  379.     </xsl:template>
  380.  
  381.     <xsl:template name="Alignment">
  382.         <xsl:param name="styleProperties" />
  383.  
  384.         <!-- An empty Alignment element, might overwrite parents setting by
  385.              the default attributes -->
  386.         <xsl:if test="$styleProperties/@fo:text-align or
  387.                       $styleProperties/@style:vertical-align or
  388.                       $styleProperties/@fo:wrap-option or
  389.                       $styleProperties/@fo:margin-left or
  390.                       $styleProperties/@style:rotation-angle or
  391.                       $styleProperties/@style:direction">
  392.             <xsl:element name="Alignment">
  393.                 <xsl:if test="$styleProperties/@fo:text-align">
  394.                     <xsl:attribute name="ss:Horizontal">
  395.                         <xsl:choose>
  396.                             <xsl:when test="$styleProperties/@fo:text-align = 'center'">Center</xsl:when>
  397.                             <xsl:when test="$styleProperties/@fo:text-align = 'end'">Right</xsl:when>
  398.                             <xsl:when test="$styleProperties/@fo:text-align = 'justify'">Justify</xsl:when>
  399.                             <xsl:otherwise>Left</xsl:otherwise>
  400.                         </xsl:choose>
  401.                     </xsl:attribute>
  402.                 </xsl:if>
  403.                 <xsl:if test="$styleProperties/@style:vertical-align">
  404.                     <xsl:attribute name="ss:Vertical">
  405.                         <xsl:choose>
  406.                             <xsl:when test="$styleProperties/@style:vertical-align = 'top'">Top</xsl:when>
  407.                             <xsl:when test="$styleProperties/@style:vertical-align = 'bottom'">Bottom</xsl:when>
  408.                             <xsl:when test="$styleProperties/@style:vertical-align = 'middle'">Center</xsl:when>
  409.                             <xsl:otherwise>Automatic</xsl:otherwise>
  410.                         </xsl:choose>
  411.                     </xsl:attribute>
  412.                 </xsl:if>
  413.                 <xsl:if test="$styleProperties/@fo:wrap-option = 'wrap'">
  414.                     <xsl:attribute name="ss:WrapText">1</xsl:attribute>
  415.                 </xsl:if>
  416.                 <xsl:if test="$styleProperties/@fo:margin-left">
  417.                     <xsl:attribute name="ss:Indent">
  418.                         <xsl:variable name="margin">
  419.                             <xsl:call-template name="convert2pt">
  420.                                 <xsl:with-param name="value" select="$styleProperties/@fo:margin-left" />
  421.                                 <xsl:with-param name="rounding-factor" select="1" />
  422.                             </xsl:call-template>
  423.                         </xsl:variable>
  424.                         <!-- one ss:Indent is equal to 10 points -->
  425.                         <xsl:value-of select="number($margin) div 10"/>
  426.                     </xsl:attribute>
  427.                 </xsl:if>
  428.                 <!-- Excel is only able to rotate between 90 and -90 degree (inclusive).
  429.                      Other degrees will be mapped by 180 degrees -->
  430.                 <xsl:if test="$styleProperties/@style:rotation-angle">
  431.                     <xsl:attribute name="ss:Rotate">
  432.                         <xsl:choose>
  433.                             <xsl:when test="$styleProperties/@style:rotation-angle > 90">
  434.                                 <xsl:choose>
  435.                                     <xsl:when test="$styleProperties/@style:rotation-angle >= 270">
  436.                                         <xsl:value-of select="$styleProperties/@style:rotation-angle - 360" />
  437.                                     </xsl:when>
  438.                                     <xsl:otherwise>
  439.                                         <xsl:value-of select="$styleProperties/@style:rotation-angle - 180" />
  440.                                     </xsl:otherwise>
  441.                                 </xsl:choose>
  442.                             </xsl:when>
  443.                             <xsl:when test="$styleProperties/@style:rotation-angle < -90">
  444.                                 <xsl:choose>
  445.                                     <xsl:when test="$styleProperties/@style:rotation-angle <= -270">
  446.                                         <xsl:value-of select="$styleProperties/@style:rotation-angle + 360" />
  447.                                     </xsl:when>
  448.                                     <xsl:otherwise>
  449.                                         <xsl:value-of select="$styleProperties/@style:rotation-angle + 180" />
  450.                                     </xsl:otherwise>
  451.                                 </xsl:choose>
  452.                             </xsl:when>
  453.                             <xsl:otherwise>
  454.                                 <xsl:value-of select="$styleProperties/@style:rotation-angle" />
  455.                             </xsl:otherwise>
  456.                         </xsl:choose>
  457.                     </xsl:attribute>
  458.                 </xsl:if>
  459.                 <xsl:if test="$styleProperties/@style:direction = 'ttb'">
  460.                     <xsl:attribute name="ss:VerticalText">1</xsl:attribute>
  461.                 </xsl:if>
  462.             </xsl:element>
  463.         </xsl:if>
  464.     </xsl:template>
  465.  
  466.  
  467.     <xsl:template name="Border">
  468.         <xsl:param name="styleProperties" />
  469.  
  470.         <!-- An empty border element, might overwrite parents setting by
  471.              the default attributes -->
  472.         <xsl:if test="$styleProperties/@fo:border or
  473.                       $styleProperties/@fo:border-bottom or
  474.                       $styleProperties/@fo:border-left or
  475.                       $styleProperties/@fo:border-right or
  476.                       $styleProperties/@fo:border-top">
  477.             <xsl:element name="Borders">
  478.                 <xsl:if test="$styleProperties/@fo:border-bottom and not($styleProperties/@fo:border-bottom = 'none')">
  479.                     <xsl:element name="Border">
  480.                         <xsl:attribute name="ss:Position">Bottom</xsl:attribute>
  481.                         <xsl:call-template name="border-attributes">
  482.                             <xsl:with-param name="border_properties" select="$styleProperties/@fo:border-bottom" />
  483.                         </xsl:call-template>
  484.                     </xsl:element>
  485.                 </xsl:if>
  486.                 <xsl:if test="$styleProperties/@fo:border-left and not($styleProperties/@fo:border-left = 'none')">
  487.                     <xsl:element name="Border">
  488.                         <xsl:attribute name="ss:Position">Left</xsl:attribute>
  489.                         <xsl:call-template name="border-attributes">
  490.                             <xsl:with-param name="border_properties" select="$styleProperties/@fo:border-left" />
  491.                         </xsl:call-template>
  492.                     </xsl:element>
  493.                 </xsl:if>
  494.                 <xsl:if test="$styleProperties/@fo:border-right and not($styleProperties/@fo:border-right = 'none')">
  495.                     <xsl:element name="Border">
  496.                         <xsl:attribute name="ss:Position">Right</xsl:attribute>
  497.                         <xsl:call-template name="border-attributes">
  498.                             <xsl:with-param name="border_properties" select="$styleProperties/@fo:border-right" />
  499.                         </xsl:call-template>
  500.                     </xsl:element>
  501.                 </xsl:if>
  502.                 <xsl:if test="$styleProperties/@fo:border-top  and not($styleProperties/@fo:border-top = 'none')">
  503.                     <xsl:element name="Border">
  504.                         <xsl:attribute name="ss:Position">Top</xsl:attribute>
  505.                         <xsl:call-template name="border-attributes">
  506.                             <xsl:with-param name="border_properties" select="$styleProperties/@fo:border-top" />
  507.                         </xsl:call-template>
  508.                     </xsl:element>
  509.                 </xsl:if>
  510.                 <!-- write out all table border  -->
  511.                 <xsl:if test="$styleProperties/@fo:border and not($styleProperties/@fo:border = 'none')">
  512.                     <xsl:element name="Border">
  513.                         <xsl:attribute name="ss:Position">Bottom</xsl:attribute>
  514.                         <xsl:call-template name="border-attributes">
  515.                             <xsl:with-param name="border_properties" select="$styleProperties/@fo:border" />
  516.                         </xsl:call-template>
  517.                     </xsl:element>
  518.                     <xsl:element name="Border">
  519.                         <xsl:attribute name="ss:Position">Left</xsl:attribute>
  520.                         <xsl:call-template name="border-attributes">
  521.                             <xsl:with-param name="border_properties" select="$styleProperties/@fo:border" />
  522.                         </xsl:call-template>
  523.                     </xsl:element>
  524.                     <xsl:element name="Border">
  525.                         <xsl:attribute name="ss:Position">Right</xsl:attribute>
  526.                         <xsl:call-template name="border-attributes">
  527.                             <xsl:with-param name="border_properties" select="$styleProperties/@fo:border" />
  528.                         </xsl:call-template>
  529.                     </xsl:element>
  530.                     <xsl:element name="Border">
  531.                         <xsl:attribute name="ss:Position">Top</xsl:attribute>
  532.                         <xsl:call-template name="border-attributes">
  533.                             <xsl:with-param name="border_properties" select="$styleProperties/@fo:border" />
  534.                         </xsl:call-template>
  535.                     </xsl:element>
  536.                 </xsl:if>
  537.             </xsl:element>
  538.         </xsl:if>
  539.     </xsl:template>
  540.  
  541.  
  542.     <xsl:template name="border-attributes">
  543.         <xsl:param name="border_properties" />
  544.  
  545.         <xsl:variable name="border-width">
  546.             <xsl:call-template name="convert2cm">
  547.                 <xsl:with-param name="value" select="substring-before($border_properties, ' ')" />
  548.             </xsl:call-template>
  549.         </xsl:variable>
  550.         <xsl:variable name="border-style" select="substring-before(substring-after($border_properties, ' '), ' ')" />
  551.         <xsl:variable name="border-color" select="substring-after(substring-after($border_properties, ' '), ' ')" />
  552. <!--
  553.         <xsl:message>border-width:<xsl:value-of select="$border-width" /></xsl:message>
  554.         <xsl:message>border-style:<xsl:value-of select="$border-style" /></xsl:message>
  555.         <xsl:message>border-color:<xsl:value-of select="$border-color" /></xsl:message>
  556.  -->
  557.  
  558.         <!-- Dash, Dot, DashDot, DashDotDot, SlantDashDot are not supported yet -->
  559.         <xsl:attribute name="ss:LineStyle">
  560.             <xsl:choose>
  561.                 <xsl:when test="$border-style = 'none'">None</xsl:when>
  562.                 <xsl:when test="$border-style = 'double'">Double</xsl:when>
  563.                 <xsl:otherwise>Continuous</xsl:otherwise>
  564.             </xsl:choose>
  565.         </xsl:attribute>
  566.  
  567.         <xsl:attribute name="ss:Weight">
  568.             <xsl:choose>
  569.                 <!-- 0: Hairline -->
  570.                 <xsl:when test="$border-width <= 0.002">0</xsl:when>
  571.                 <!-- 1: Thin -->
  572.                 <xsl:when test="$border-width <= 0.035">1</xsl:when>
  573.                 <!-- 2: Medium -->
  574.                 <xsl:when test="$border-width <= 0.088">2</xsl:when>
  575.                 <!-- 3: Thick -->
  576.                 <xsl:otherwise>3</xsl:otherwise>
  577.             </xsl:choose>
  578.         </xsl:attribute>
  579.  
  580.         <xsl:attribute name="ss:Color">
  581.             <xsl:choose>
  582.                 <xsl:when test="$border-color"><xsl:value-of select="$border-color" /></xsl:when>
  583.                 <xsl:otherwise>Automatic</xsl:otherwise>
  584.             </xsl:choose>
  585.         </xsl:attribute>
  586.     </xsl:template>
  587.  
  588.  
  589.     <xsl:template name="Font">
  590.         <xsl:param name="styleProperties" />
  591.         <xsl:param name="styleParentName" />
  592.  
  593.         <!-- An empty font element, might overwrite parents setting by
  594.              the default attributes -->
  595.         <xsl:if test="$styleProperties/@style:font-weight or
  596.                       $styleProperties/@fo:color or
  597.                       $styleProperties/@style:font-name or
  598.                       $styleProperties/@fo:font-style or
  599.                       $styleProperties/@style:text-outline or
  600.                       $styleProperties/@style:text-shadow or
  601.                       $styleProperties/@style:font-size or
  602.                       $styleProperties/@style:text-line-through-style or
  603.                       $styleProperties/@style:text-underline-type or
  604.                       $styleProperties/@style:text-underline-style or
  605.                       $styleProperties/@style:text-position">
  606.  
  607.  
  608.             <xsl:element name="Font">
  609.                 <xsl:call-template name="getParentBold">
  610.                     <xsl:with-param name="styleProperties" select="$styleProperties" />
  611.                     <xsl:with-param name="styleParentName" select="$styleParentName" />
  612.                 </xsl:call-template>
  613.                 <xsl:if test="$styleProperties/@fo:color">
  614.                     <xsl:attribute name="ss:Color"><xsl:value-of select="$styleProperties/@fo:color" /></xsl:attribute>
  615.                 </xsl:if>
  616.                 <xsl:if test="$styleProperties/@style:font-name">
  617.                     <xsl:attribute name="ss:FontName"><xsl:value-of select="$styleProperties/@style:font-name" /></xsl:attribute>
  618.                 </xsl:if>
  619.                 <xsl:if test="$styleProperties/@fo:font-style = 'italic'">
  620.                     <xsl:attribute name="ss:Italic">1</xsl:attribute>
  621.                 </xsl:if>
  622.                 <xsl:if test="$styleProperties/@style:text-outline = 'true'">
  623.                     <xsl:attribute name="ss:Outline">1</xsl:attribute>
  624.                 </xsl:if>
  625.                 <xsl:if test="$styleProperties/@style:text-shadow = 'shadow'">
  626.                     <xsl:attribute name="ss:Shadow">1</xsl:attribute>
  627.                 </xsl:if>
  628.                 <xsl:if test="$styleProperties/@fo:font-size">
  629.                     <xsl:attribute name="ss:Size">
  630.                         <xsl:call-template name="convert2pt">
  631.                             <xsl:with-param name="value" select="$styleProperties/@fo:font-size" />
  632.                         </xsl:call-template>
  633.                     </xsl:attribute>
  634.                 </xsl:if>
  635.                 <xsl:if test="$styleProperties/@style:text-line-through-style and $styleProperties/@style:text-line-through-style != 'none'">
  636.                     <xsl:attribute name="ss:StrikeThrough">1</xsl:attribute>
  637.                 </xsl:if>
  638.                 <xsl:if test="($styleProperties/@style:text-underline-type and $styleProperties/@style:text-underline-type != 'none') or
  639.                               ($styleProperties/@style:text-underline-style and $styleProperties/@style:text-underline-style != 'none')">
  640.                     <xsl:attribute name="ss:Underline">
  641.                         <xsl:choose>
  642.                             <xsl:when test="$styleProperties/@style:text-underline-type = 'double'">Double</xsl:when>
  643.                             <xsl:otherwise>Single</xsl:otherwise>
  644.                         </xsl:choose>
  645.                     </xsl:attribute>
  646.                 </xsl:if>
  647.                 <xsl:if test="$styleProperties/@style:text-position">
  648.                     <xsl:attribute name="ss:VerticalAlign">
  649.                         <xsl:choose>
  650.                             <xsl:when test="substring-before($styleProperties/@style:text-position, '% ') > 0">Superscript</xsl:when>
  651.                             <xsl:otherwise>Subscript</xsl:otherwise>
  652.                         </xsl:choose>
  653.                     </xsl:attribute>
  654.                 </xsl:if>
  655.             </xsl:element>
  656.         </xsl:if>
  657.     </xsl:template>
  658.  
  659.     <xsl:template name="Interior">
  660.         <xsl:param name="styleProperties" />
  661.         <xsl:if test="$styleProperties/@fo:background-color and not($styleProperties/@fo:background-color = 'transparent')">
  662.             <xsl:element name="Interior">
  663.                 <xsl:attribute name="ss:Color">
  664.                     <xsl:value-of select="$styleProperties/@fo:background-color" />
  665.                 </xsl:attribute>
  666.                 <!-- Background color (i.e. Interior/ss:Color) not shown without ss:Pattern (or with 'none')
  667.                 Therefore a default is set -->
  668.                 <xsl:attribute name="ss:Pattern">Solid</xsl:attribute>
  669.             </xsl:element>
  670.         </xsl:if>
  671.     </xsl:template>
  672.  
  673.     <!-- Excel issue workaround: <Font ss:Bold="1"> is not inherited -->
  674.     <xsl:template name="getParentBold">
  675.         <xsl:param name="styleProperties" />
  676.         <xsl:param name="styleParentName" />
  677.         <xsl:param name="styleName" />
  678.  
  679.         <xsl:if test="$styleParentName and $styleParentName != $styleName">
  680.             <xsl:choose>
  681.                 <xsl:when test="$styleProperties/@fo:font-weight = 'bold'">
  682.                     <xsl:attribute name="ss:Bold">1</xsl:attribute>
  683.                 </xsl:when>
  684.                 <xsl:otherwise>
  685.                     <xsl:call-template name="getParentBold">
  686.                         <xsl:with-param name="styleProperties" select="key('styles', $styleParentName)/*" />
  687.                         <xsl:with-param name="styleParentName" select="key('styles', $styleParentName)/@style:parent-style-name" />
  688.                         <xsl:with-param name="styleName" select="$styleParentName" />
  689.                     </xsl:call-template>
  690.                 </xsl:otherwise>
  691.             </xsl:choose>
  692.         </xsl:if>
  693.     </xsl:template>
  694.  
  695. </xsl:stylesheet>
  696.