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 / ooo2wordml_table.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2010-12-01  |  25.5 KB  |  417 lines

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3.  
  4.   DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  5.   
  6.   Copyright 2000, 2010 Oracle and/or its affiliates.
  7.  
  8.   OpenOffice.org - a multi-platform office productivity suite
  9.  
  10.   This file is part of OpenOffice.org.
  11.  
  12.   OpenOffice.org is free software: you can redistribute it and/or modify
  13.   it under the terms of the GNU Lesser General Public License version 3
  14.   only, as published by the Free Software Foundation.
  15.  
  16.   OpenOffice.org is distributed in the hope that it will be useful,
  17.   but WITHOUT ANY WARRANTY; without even the implied warranty of
  18.   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  19.   GNU Lesser General Public License version 3 for more details
  20.   (a copy is included in the LICENSE file that accompanied this code).
  21.  
  22.   You should have received a copy of the GNU Lesser General Public License
  23.   version 3 along with OpenOffice.org.  If not, see
  24.   <http://www.openoffice.org/license.html>
  25.   for a copy of the LGPLv3 License.
  26.  
  27. -->
  28. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml" xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:aml="http://schemas.microsoft.com/aml/2001/core" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" exclude-result-prefixes="office table style text draw svg   dc config xlink meta oooc dom ooo chart math dr3d form script ooow draw">
  29.     <xsl:key name="table-style" match="style:style[@style:family='table']" use="@style:name"/>
  30.     <xsl:key name="table-column-style" match="style:style[@style:family='table-column']" use="@style:name"/>
  31.     <xsl:key name="table-row-style" match="style:style[@style:family='table-row']" use="@style:name"/>
  32.     <xsl:key name="table-cell-style" match="style:style[@style:family='table-cell']" use="@style:name"/>
  33.     <xsl:template match="style:table-properties" mode="table">
  34.         <xsl:param name="within-body"/>
  35.         <xsl:if test="$within-body = 'yes'">
  36.             <w:tblW>
  37.                 <xsl:choose>
  38.                     <xsl:when test="@style:rel-width">
  39.                         <xsl:attribute name="w:w"><xsl:value-of select="substring-before(@style:rel-width, '%') * 50"/></xsl:attribute>
  40.                         <xsl:attribute name="w:type">pct</xsl:attribute>
  41.                     </xsl:when>
  42.                     <xsl:when test="@style:width">
  43.                         <xsl:attribute name="w:w"><xsl:call-template name="convert2twip"><xsl:with-param name="value" select="@style:width"/></xsl:call-template></xsl:attribute>
  44.                         <xsl:attribute name="w:type">dxa</xsl:attribute>
  45.                     </xsl:when>
  46.                     <xsl:otherwise>
  47.                         <xsl:attribute name="w:w">0</xsl:attribute>
  48.                         <xsl:attribute name="w:type">auto</xsl:attribute>
  49.                     </xsl:otherwise>
  50.                 </xsl:choose>
  51.             </w:tblW>
  52.         </xsl:if>
  53.         <w:tblInd>
  54.             <xsl:choose>
  55.                 <xsl:when test="@fo:margin-left">
  56.                     <xsl:attribute name="w:w"><xsl:call-template name="convert2twip"><xsl:with-param name="value" select="@fo:margin-left"/></xsl:call-template></xsl:attribute>
  57.                     <xsl:attribute name="w:type">dxa</xsl:attribute>
  58.                 </xsl:when>
  59.                 <xsl:otherwise>
  60.                     <xsl:attribute name="w:w">0</xsl:attribute>
  61.                     <xsl:attribute name="w:type">auto</xsl:attribute>
  62.                 </xsl:otherwise>
  63.             </xsl:choose>
  64.         </w:tblInd>
  65.         <xsl:if test="@table:align">
  66.             <w:jc>
  67.                 <xsl:choose>
  68.                     <xsl:when test="@table:align = 'left' or @table:align= 'center' or @table:align = 'right'">
  69.                         <xsl:attribute name="w:val"><xsl:value-of select="@table:align"/></xsl:attribute>
  70.                     </xsl:when>
  71.                     <xsl:otherwise>
  72.                         <xsl:attribute name="w:val">left</xsl:attribute>
  73.                     </xsl:otherwise>
  74.                 </xsl:choose>
  75.             </w:jc>
  76.         </xsl:if>
  77.     </xsl:template>
  78.     <xsl:template match="table:table">
  79.         <!--fix for issue i32030 pagebreak before-->
  80.         <xsl:if test="key('table-style', @table:style-name)/style:table-properties/@fo:break-before">
  81.             <xsl:variable name="table-break-before" select="key('table-style', @table:style-name)/style:table-properties/@fo:break-before"/>
  82.             <xsl:choose>
  83.                 <xsl:when test="$table-break-before = 'page' ">
  84.                     <w:p>
  85.                         <w:r>
  86.                             <w:br w:type="page"/>
  87.                         </w:r>
  88.                     </w:p>
  89.                 </xsl:when>
  90.                 <xsl:when test="$table-break-before = 'column' ">
  91.                     <w:p>
  92.                         <w:r>
  93.                             <w:br w:type="column"/>
  94.                         </w:r>
  95.                     </w:p>
  96.                 </xsl:when>
  97.             </xsl:choose>
  98.         </xsl:if>
  99.         <w:tbl>
  100.             <w:tblPr>
  101.                 <xsl:if test="not (@table:is-sub-table) or (@table:is-sub-table = 'false' )">
  102.                     <w:tblStyle w:val="{@table:style-name}"/>
  103.                     <xsl:apply-templates select="key('table-style', @table:style-name)/style:table-properties" mode="table">
  104.                         <xsl:with-param name="within-body" select="'yes'"/>
  105.                     </xsl:apply-templates>
  106.                 </xsl:if>
  107.                 <xsl:if test="@table:is-sub-table ='true' ">
  108.                     <w:tblW w:type="dxa">
  109.                         <xsl:variable name="sub-table-width">
  110.                             <xsl:call-template name="caculate-sub-table-width">
  111.                                 <xsl:with-param name="sub-table-column-node" select="table:table-column[1]"/>
  112.                                 <xsl:with-param name="total-sub-table-width" select="0"/>
  113.                             </xsl:call-template>
  114.                         </xsl:variable>
  115.                         <xsl:attribute name="w:w"><xsl:value-of select="$sub-table-width"/></xsl:attribute>
  116.                     </w:tblW>
  117.                     <!--w:tblLayout w:type="Fixed"/-->
  118.                 </xsl:if>
  119.             </w:tblPr>
  120.             <w:tblGrid>
  121.                 <xsl:apply-templates select="table:table-column"/>
  122.             </w:tblGrid>
  123.             <xsl:apply-templates select="table:table-header-rows/table:table-row | table:table-row"/>
  124.         </w:tbl>
  125.         <!--fix for issue i32030 pagebreak after-->
  126.         <xsl:if test="key('table-style', @table:style-name)/style:table-properties/@fo:break-after">
  127.             <xsl:variable name="table-break-after" select="   key('table-style', @table:style-name)/style:table-properties/@fo:break-after"/>
  128.             <xsl:choose>
  129.                 <xsl:when test="$table-break-after = 'page' ">
  130.                     <w:p>
  131.                         <w:r>
  132.                             <w:br w:type="page"/>
  133.                         </w:r>
  134.                     </w:p>
  135.                 </xsl:when>
  136.                 <xsl:when test="$table-break-after = 'column' ">
  137.                     <w:p>
  138.                         <w:r>
  139.                             <w:br w:type="column"/>
  140.                         </w:r>
  141.                     </w:p>
  142.                 </xsl:when>
  143.             </xsl:choose>
  144.         </xsl:if>
  145.         <xsl:if test="name(..)= 'table:table-cell' ">
  146.             <w:p/>
  147.         </xsl:if>
  148.     </xsl:template>
  149.     <xsl:template name="caculate-sub-table-width">
  150.         <xsl:param name="sub-table-column-node"/>
  151.         <xsl:param name="total-sub-table-width"/>
  152.         <xsl:variable name="column-width" select="key('table-column-style', $sub-table-column-node/@table:style-name)/style:table-column-properties/@style:column-width"/>
  153.         <xsl:variable name="column-width-in-twip">
  154.             <xsl:call-template name="convert2twip">
  155.                 <xsl:with-param name="value" select="$column-width"/>
  156.             </xsl:call-template>
  157.         </xsl:variable>
  158.         <xsl:choose>
  159.             <xsl:when test="$sub-table-column-node/following-sibling::table:table-column">
  160.                 <xsl:choose>
  161.                     <xsl:when test="$sub-table-column-node/@table:number-columns-repeated">
  162.                         <xsl:call-template name="caculate-sub-table-width">
  163.                             <xsl:with-param name="sub-table-column-node" select="$sub-table-column-node/following-sibling::table:table-column[ 1]"/>
  164.                             <xsl:with-param name="total-sub-table-width" select="$total-sub-table-width + $column-width-in-twip *  $sub-table-column-node/@table:number-columns-repeated"/>
  165.                         </xsl:call-template>
  166.                     </xsl:when>
  167.                     <xsl:otherwise>
  168.                         <xsl:call-template name="caculate-sub-table-width">
  169.                             <xsl:with-param name="sub-table-column-node" select="$sub-table-column-node/following-sibling::table:table-column[1]"/>
  170.                             <xsl:with-param name="total-sub-table-width" select="$total-sub-table-width + $column-width-in-twip "/>
  171.                         </xsl:call-template>
  172.                     </xsl:otherwise>
  173.                 </xsl:choose>
  174.             </xsl:when>
  175.             <xsl:otherwise>
  176.                 <xsl:choose>
  177.                     <xsl:when test="$sub-table-column-node/@table:number-columns-repeated">
  178.                         <xsl:value-of select="$total-sub-table-width + $column-width-in-twip *  $sub-table-column-node/@table:number-columns-repeated"/>
  179.                     </xsl:when>
  180.                     <xsl:otherwise>
  181.                         <xsl:value-of select="$total-sub-table-width + $column-width-in-twip "/>
  182.                     </xsl:otherwise>
  183.                 </xsl:choose>
  184.             </xsl:otherwise>
  185.         </xsl:choose>
  186.     </xsl:template>
  187.     <xsl:template match="table:table-column">
  188.         <xsl:variable name="column-width" select="key('table-column-style', @table:style-name)/style:table-column-properties/@style:column-width"/>
  189.         <xsl:variable name="column-width-in-twip">
  190.             <xsl:call-template name="convert2twip">
  191.                 <xsl:with-param name="value" select="$column-width"/>
  192.             </xsl:call-template>
  193.         </xsl:variable>
  194.         <xsl:choose>
  195.             <!-- if table:table-column has attribute table:number-columns-repeated, then call the recursion
  196.             temple repeat-gridcol to produce multiple w:gridCol in MS word. Gary.Yang   -->
  197.             <xsl:when test="@table:number-columns-repeated">
  198.                 <xsl:call-template name="repeat-gridcol">
  199.                     <xsl:with-param name="grid-repeat-count" select="@table:number-columns-repeated"/>
  200.                     <xsl:with-param name="column-width" select="$column-width-in-twip"/>
  201.                 </xsl:call-template>
  202.             </xsl:when>
  203.             <xsl:otherwise>
  204.                 <w:gridCol w:w="{$column-width-in-twip}"/>
  205.             </xsl:otherwise>
  206.         </xsl:choose>
  207.     </xsl:template>
  208.     <!--recursion template for produce multiple w:gridCol  Gary.Yang-->
  209.     <xsl:template name="repeat-gridcol">
  210.         <xsl:param name="grid-repeat-count"/>
  211.         <xsl:param name="column-width"/>
  212.         <xsl:if test="$grid-repeat-count > 0">
  213.             <w:gridCol w:w="{$column-width}"/>
  214.             <xsl:call-template name="repeat-gridcol">
  215.                 <xsl:with-param name="grid-repeat-count" select="$grid-repeat-count - 1"/>
  216.                 <xsl:with-param name="column-width" select="$column-width"/>
  217.             </xsl:call-template>
  218.         </xsl:if>
  219.     </xsl:template>
  220.     <xsl:template match="table:table-row">
  221.         <xsl:element name="w:tr">
  222.             <xsl:element name="w:trPr">
  223.                 <xsl:if test="parent::table:table-header-rows">
  224.                     <!-- fix for  Issue 32034-->
  225.                     <w:tblHeader>on</w:tblHeader>
  226.                 </xsl:if>
  227.                 <xsl:variable name="row-height" select="key('table-row-style', @table:style-name)/style:table-row-properties/@style:row-height"/>
  228.                 <xsl:if test="$row-height">
  229.                     <w:trHeight>
  230.                         <xsl:attribute name="w:val"><xsl:call-template name="convert2twip"><xsl:with-param name="value" select="$row-height"/></xsl:call-template></xsl:attribute>
  231.                     </w:trHeight>
  232.                 </xsl:if>
  233.             </xsl:element>
  234.             <!--end of w:trPr-->
  235.             <xsl:apply-templates select="table:table-cell "/>
  236.         </xsl:element>
  237.     </xsl:template>
  238.     <xsl:template match="table:table-cell ">
  239.         <xsl:element name="w:tc">
  240.             <xsl:element name="w:tcPr">
  241.                 <!-- to caclate the table-cell width Gary.Yang -->
  242.                 <xsl:choose>
  243.                     <!--when the table-cell  contains the sub-table -->
  244.                     <xsl:when test="table:table/@table:is-sub-table= 'true' ">
  245.                         <xsl:variable name="table-cell-width">
  246.                             <xsl:call-template name="caculate-sub-table-width">
  247.                                 <xsl:with-param name="sub-table-column-node" select="table:table/table:table-column[1]"/>
  248.                                 <xsl:with-param name="total-sub-table-width" select="0"/>
  249.                             </xsl:call-template>
  250.                         </xsl:variable>
  251.                         <w:tcW w:type="dxa">
  252.                             <xsl:attribute name="w:w"><xsl:value-of select="$table-cell-width"/></xsl:attribute>
  253.                         </w:tcW>
  254.                     </xsl:when>
  255.                     <xsl:otherwise>
  256.                         <!-- when the table-cell doesn't contain the sub-table -->
  257.                         <xsl:variable name="table-cell-width">
  258.                             <xsl:call-template name="caculate-table-cell-width">
  259.                                 <xsl:with-param name="table-cell-position" select="position()"/>
  260.                                 <xsl:with-param name="table-column" select="ancestor::table:table[1]/table:table-column[1]"/>
  261.                             </xsl:call-template>
  262.                         </xsl:variable>
  263.                         <w:tcW w:type="dxa">
  264.                             <xsl:attribute name="w:w"><xsl:value-of select="$table-cell-width"/></xsl:attribute>
  265.                         </w:tcW>
  266.                         <!-- for performance issue, we can set w:type to auto that makes the cell width auto fit the content. -->
  267.                         <!--w:tcW w:w="0" w:type="auto"/-->
  268.                     </xsl:otherwise>
  269.                 </xsl:choose>
  270.                 <xsl:if test="@table:number-columns-spanned">
  271.                     <w:gridSpan w:val="{@table:number-columns-spanned}"/>
  272.                 </xsl:if>
  273.                 <xsl:variable name="cell-style-properties" select="key('table-cell-style', @table:style-name)/style:table-cell-properties"/>
  274.                 <xsl:if test="$cell-style-properties/@fo:background-color">
  275.                     <w:shd w:val="solid" w:color="{substring-after($cell-style-properties/@fo:background-color,'#')}"/>
  276.                 </xsl:if>
  277.                 <xsl:if test="$cell-style-properties/@fo:vertical-align">
  278.                     <xsl:choose>
  279.                         <xsl:when test="$cell-style-properties/@fo:vertical-align = 'middle'">
  280.                             <w:vAlign w:val="center"/>
  281.                         </xsl:when>
  282.                         <xsl:when test="$cell-style-properties/@fo:vertical-align = 'Automatic'">
  283.                             <w:vAlign w:val="both"/>
  284.                         </xsl:when>
  285.                         <xsl:otherwise>
  286.                             <w:vAlign w:val="{$cell-style-properties/@fo:vertical-align}"/>
  287.                         </xsl:otherwise>
  288.                     </xsl:choose>
  289.                 </xsl:if>
  290.                 <w:tcMar>
  291.                     <xsl:if test="$cell-style-properties/@fo:padding-top">
  292.                         <w:top w:type="dxa">
  293.                             <xsl:attribute name="w:w"><xsl:call-template name="convert2twip"><xsl:with-param name="value" select="$cell-style-properties/@fo:padding-top"/></xsl:call-template></xsl:attribute>
  294.                         </w:top>
  295.                     </xsl:if>
  296.                     <xsl:if test="$cell-style-properties/@fo:padding-bottom">
  297.                         <w:bottom w:type="dxa">
  298.                             <xsl:attribute name="w:w"><xsl:call-template name="convert2twip"><xsl:with-param name="value" select="$cell-style-properties/@fo:padding-bottom"/></xsl:call-template></xsl:attribute>
  299.                         </w:bottom>
  300.                     </xsl:if>
  301.                     <xsl:if test="$cell-style-properties/@fo:padding-left">
  302.                         <w:left w:type="dxa">
  303.                             <xsl:attribute name="w:w"><xsl:call-template name="convert2twip"><xsl:with-param name="value" select="$cell-style-properties/@fo:padding-left"/></xsl:call-template></xsl:attribute>
  304.                         </w:left>
  305.                     </xsl:if>
  306.                     <xsl:if test="$cell-style-properties/@fo:padding-right">
  307.                         <w:right w:type="dxa">
  308.                             <xsl:attribute name="w:w"><xsl:call-template name="convert2twip"><xsl:with-param name="value" select="$cell-style-properties/@fo:padding-right"/></xsl:call-template></xsl:attribute>
  309.                         </w:right>
  310.                     </xsl:if>
  311.                 </w:tcMar>
  312.                 <!-- the following code is to get the cell borders if they exsits Gary.Yang-->
  313.                 <xsl:variable name="border-top" select="$cell-style-properties/@fo:border-top | $cell-style-properties/@fo:border"/>
  314.                 <xsl:variable name="border-bottom" select="$cell-style-properties/@fo:border-bottom | $cell-style-properties/@fo:border"/>
  315.                 <xsl:variable name="border-left" select="$cell-style-properties/@fo:border-left | $cell-style-properties/@fo:border"/>
  316.                 <xsl:variable name="border-right" select="$cell-style-properties/@fo:border-right | $cell-style-properties/@fo:border"/>
  317.                 <xsl:variable name="border-line-width-top" select="$cell-style-properties/@style:border-line-width-top | $cell-style-properties/@style:border-line-width "/>
  318.                 <xsl:variable name="border-line-width-bottom" select="$cell-style-properties/@style:border-line-width-bottom | $cell-style-properties/@style:border-line-width"/>
  319.                 <xsl:variable name="border-line-width-left" select="$cell-style-properties/@style:border-line-width-left | $cell-style-properties/@style:border-line-width"/>
  320.                 <xsl:variable name="border-line-width-right" select="$cell-style-properties/@style:border-line-width-right | $cell-style-properties/@style:border-line-width"/>
  321.                 <xsl:element name="w:tcBorders">
  322.                     <xsl:if test="$border-top">
  323.                         <xsl:element name="w:top">
  324.                             <xsl:call-template name="get-border">
  325.                                 <xsl:with-param name="so-border" select="$border-top"/>
  326.                                 <xsl:with-param name="so-border-line-width" select="$border-line-width-top"/>
  327.                                 <xsl:with-param name="so-border-position" select=" 'top' "/>
  328.                             </xsl:call-template>
  329.                         </xsl:element>
  330.                     </xsl:if>
  331.                     <xsl:if test="$border-bottom">
  332.                         <xsl:element name="w:bottom">
  333.                             <xsl:call-template name="get-border">
  334.                                 <xsl:with-param name="so-border" select="$border-bottom"/>
  335.                                 <xsl:with-param name="so-border-line-width" select="$border-line-width-bottom"/>
  336.                                 <xsl:with-param name="so-border-position" select=" 'bottom' "/>
  337.                             </xsl:call-template>
  338.                         </xsl:element>
  339.                     </xsl:if>
  340.                     <xsl:if test="$border-left">
  341.                         <xsl:element name="w:left">
  342.                             <xsl:call-template name="get-border">
  343.                                 <xsl:with-param name="so-border" select="$border-left"/>
  344.                                 <xsl:with-param name="so-border-line-width" select="$border-line-width-left"/>
  345.                                 <xsl:with-param name="so-border-position" select=" 'left' "/>
  346.                             </xsl:call-template>
  347.                         </xsl:element>
  348.                     </xsl:if>
  349.                     <xsl:if test="$border-right">
  350.                         <xsl:element name="w:right">
  351.                             <xsl:call-template name="get-border">
  352.                                 <xsl:with-param name="so-border" select="$border-right"/>
  353.                                 <xsl:with-param name="so-border-line-width" select="$border-line-width-right"/>
  354.                                 <xsl:with-param name="so-border-position" select=" 'right' "/>
  355.                             </xsl:call-template>
  356.                         </xsl:element>
  357.                     </xsl:if>
  358.                 </xsl:element>
  359.             </xsl:element>
  360.             <xsl:if test="not (*) ">
  361.                 <w:p/>
  362.             </xsl:if>
  363.             <xsl:apply-templates select=" text:p | table:table | text:h | office:annotation"/>
  364.         </xsl:element>
  365.     </xsl:template>
  366.     <xsl:template name="caculate-table-cell-width">
  367.         <xsl:param name="table-cell-position"/>
  368.         <xsl:param name="table-column"/>
  369.         <xsl:choose>
  370.             <xsl:when test="$table-column/@table:number-columns-repeated">
  371.                 <xsl:choose>
  372.                     <xsl:when test="($table-cell-position - $table-column/@table:number-columns-repeated) <= 0">
  373.                         <xsl:variable name="table-cell-width" select="key('table-column-style', $table-column/@table:style-name)/style:table-column-properties/@style:column-width"/>
  374.                         <xsl:variable name="table-cell-width-in-twip">
  375.                             <xsl:call-template name="convert2twip">
  376.                                 <xsl:with-param name="value" select="$table-cell-width"/>
  377.                             </xsl:call-template>
  378.                         </xsl:variable>
  379.                         <xsl:value-of select="$table-cell-width-in-twip"/>
  380.                     </xsl:when>
  381.                     <xsl:otherwise>
  382.                         <xsl:call-template name="caculate-table-cell-width">
  383.                             <xsl:with-param name="table-cell-position" select="$table-cell-position - $table-column/@table:number-columns-repeated"/>
  384.                             <xsl:with-param name="table-column" select="$table-column/following-sibling::table:table-column[1]"/>
  385.                         </xsl:call-template>
  386.                     </xsl:otherwise>
  387.                 </xsl:choose>
  388.             </xsl:when>
  389.             <xsl:otherwise>
  390.                 <!-- if the $table-column doesn't contain the table:number-columns-repeated attribute -->
  391.                 <xsl:choose>
  392.                     <xsl:when test="($table-cell-position - 1) = 0">
  393.                         <xsl:variable name="table-cell-width" select="key('table-column-style', $table-column/@table:style-name)/style:table-column-properties/@style:column-width"/>
  394.                         <xsl:variable name="table-cell-width-in-twip">
  395.                             <xsl:call-template name="convert2twip">
  396.                                 <xsl:with-param name="value" select="$table-cell-width"/>
  397.                             </xsl:call-template>
  398.                         </xsl:variable>
  399.                         <xsl:value-of select="$table-cell-width-in-twip"/>
  400.                     </xsl:when>
  401.                     <xsl:when test="($table-cell-position - 1) > 0">
  402.                         <xsl:call-template name="caculate-table-cell-width">
  403.                             <xsl:with-param name="table-cell-position" select=" $table-cell-position - 1 "/>
  404.                             <xsl:with-param name="table-column" select="$table-column/following-sibling::table:table-column[1]"/>
  405.                         </xsl:call-template>
  406.                     </xsl:when>
  407.                     <xsl:otherwise>
  408.                         <xsl:message>
  409.                             <xsl:value-of select=" 'caculate table cell width wrong ' "/>
  410.                         </xsl:message>
  411.                     </xsl:otherwise>
  412.                 </xsl:choose>
  413.             </xsl:otherwise>
  414.         </xsl:choose>
  415.     </xsl:template>
  416. </xsl:stylesheet>
  417.