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 / table_cells.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2010-12-01  |  12.8 KB  |  280 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. <!--
  29.     For further documentation and updates visit http://xml.openoffice.org/odf2xhtml
  30. -->
  31. <xsl:stylesheet version="1.0"
  32.     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  33.     xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
  34.     xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0"
  35.     xmlns:dc="http://purl.org/dc/elements/1.1/"
  36.     xmlns:dom="http://www.w3.org/2001/xml-events"
  37.     xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"
  38.     xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
  39.     xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
  40.     xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"
  41.     xmlns:math="http://www.w3.org/1998/Math/MathML"
  42.     xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0"
  43.     xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
  44.     xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
  45.     xmlns:ooo="http://openoffice.org/2004/office"
  46.     xmlns:oooc="http://openoffice.org/2004/calc"
  47.     xmlns:ooow="http://openoffice.org/2004/writer"
  48.     xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"
  49.     xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
  50.     xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
  51.     xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
  52.     xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
  53.     xmlns:xforms="http://www.w3.org/2002/xforms"
  54.     xmlns:xlink="http://www.w3.org/1999/xlink"
  55.     xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  56.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  57.     xmlns:xt="http://www.jclark.com/xt"
  58.     xmlns:common="http://exslt.org/common"
  59.     xmlns:xalan="http://xml.apache.org/xalan"
  60.     exclude-result-prefixes="chart config dc dom dr3d draw fo form math meta number office ooo oooc ooow script style svg table text xforms xlink xsd xsi xt common xalan">
  61.  
  62.  
  63.     <!-- *********************************** -->
  64.     <!-- *** write repeating table cells *** -->
  65.     <!-- *********************************** -->
  66.  
  67.  
  68.     <!-- matching cells to give out -> covered table cells are not written out -->
  69.     <xsl:template match="table:table-cell">
  70.         <xsl:param name="globalData" />
  71.         <!-- position of the current input cell to get the correct colum style (hidden are also counted)-->
  72.         <xsl:param name="allTableColumns" />
  73.         <xsl:param name="maxRowLength" />
  74.         <xsl:param name="tableDataType" />
  75.  
  76.  
  77.         <!-- The column position of the current cell has to be determined
  78.         to get the adequate column styles during later cell creation,
  79.         or hiding the cell when @table:visibility is not set to 'visible'.
  80.  
  81.         The position is archieved by adding up all table:number-columns-repeated of the preceding cells.
  82.             Step1: creating '$precedingCells/quantity/@table:number-columns-repeated').
  83.             Step2: sum(xxx:nodeset($precedingCells)/quantity) + 1        -->
  84.         <xsl:variable name="precedingCells">
  85.             <xsl:for-each select="preceding-sibling::*">
  86.                 <xsl:choose>
  87.                     <!-- maybe a parser is used, which reads the DTD files (e.g. Xerces),
  88.                         then '1' is the default for 'table:number-columns-repeated' -->
  89.                     <xsl:when test="not(@table:number-columns-repeated and @table:number-columns-repeated > 1)">
  90.                         <xsl:element name="quantity" namespace="">
  91.                             <xsl:text>1</xsl:text>
  92.                         </xsl:element>
  93.                     </xsl:when>
  94.                     <xsl:otherwise>
  95.                         <xsl:element name="quantity" namespace="">
  96.                             <xsl:value-of select="@table:number-columns-repeated" />
  97.                         </xsl:element>
  98.                     </xsl:otherwise>
  99.                 </xsl:choose>
  100.             </xsl:for-each>
  101.         </xsl:variable>
  102.  
  103.  
  104.  
  105.         <xsl:choose>
  106.             <xsl:when test="function-available('common:node-set')">
  107.                 <xsl:call-template name="create-table-cell">
  108.                     <!-- position of the current input cell to get the correct colum style (hidden are also counted)-->
  109.                     <xsl:with-param name="allTableColumns"  select="$allTableColumns" />
  110.                     <xsl:with-param name="maxRowLength"     select="$maxRowLength" />
  111.                     <xsl:with-param name="precedingColumns"   select="sum(common:node-set($precedingCells)/*)" />
  112.                     <xsl:with-param name="globalData"       select="$globalData" />
  113.                     <xsl:with-param name="tableDataType"    select="$tableDataType" />
  114.                 </xsl:call-template>
  115.             </xsl:when>
  116.             <xsl:when test="function-available('xalan:nodeset')">
  117.                 <xsl:call-template name="create-table-cell">
  118.                     <!-- position of the current input cell to get the correct colum style (hidden are also counted)-->
  119.                     <xsl:with-param name="allTableColumns"  select="$allTableColumns" />
  120.                     <xsl:with-param name="maxRowLength"     select="$maxRowLength" />
  121.                     <xsl:with-param name="precedingColumns"   select="sum(xalan:nodeset($precedingCells)/*)" />
  122.                     <xsl:with-param name="globalData"       select="$globalData" />
  123.                     <xsl:with-param name="tableDataType"    select="$tableDataType" />
  124.                 </xsl:call-template>
  125.             </xsl:when>
  126.             <xsl:when test="function-available('xt:node-set')">
  127.                 <xsl:call-template name="create-table-cell">
  128.                     <!-- position of the current input cell to get the correct colum style (hidden are also counted)-->
  129.                     <xsl:with-param name="allTableColumns"  select="$allTableColumns" />
  130.                     <xsl:with-param name="maxRowLength"     select="$maxRowLength" />
  131.                     <xsl:with-param name="precedingColumns"   select="sum(xt:node-set($precedingCells)/*)" />
  132.                     <xsl:with-param name="globalData"       select="$globalData" />
  133.                     <xsl:with-param name="tableDataType"    select="$tableDataType" />
  134.                 </xsl:call-template>
  135.             </xsl:when>
  136.             <xsl:otherwise>
  137.                 <xsl:message terminate="yes">ERROR: Function not found: nodeset</xsl:message>
  138.             </xsl:otherwise>
  139.         </xsl:choose>
  140.     </xsl:template>
  141.  
  142.  
  143.     <!-- current node is a table:table-cell -->
  144.     <xsl:template name="create-table-cell">
  145.         <!-- position of the current input cell to get the correct colum style (hidden are also counted)-->
  146.         <xsl:param name="allTableColumns" />
  147.         <xsl:param name="globalData" />
  148.         <xsl:param name="maxRowLength" />
  149.         <xsl:param name="precedingColumns" select="0" />
  150.         <xsl:param name="tableDataType" />
  151.  
  152.         <xsl:variable name="columnPosition" select="$precedingColumns + 1" />
  153.  
  154.         <xsl:if test="$debugEnabled">
  155.             <xsl:message>
  156.                 <xsl:text>
  157.                     table:table-cell #</xsl:text>
  158.                 <xsl:value-of select="$columnPosition" />
  159.                 <xsl:text> has been entered with node value: </xsl:text>
  160.                 <xsl:value-of select="." />
  161.                 <xsl:text>
  162.                     table:number-columns-repeated: </xsl:text>
  163.                 <xsl:value-of select="@table:number-columns-repeated" />
  164.                 <xsl:text>
  165.                     maxRowLength: </xsl:text>
  166.                 <xsl:value-of select="$maxRowLength" />
  167.             </xsl:message>
  168.         </xsl:if>
  169.  
  170.         <!-- only non hidden column will be given out -->
  171.         <xsl:variable name="currentTableColumn" select="$allTableColumns/table:table-column[position() = $columnPosition]" />
  172.         <xsl:if test="$currentTableColumn[not(@table:visibility = 'collapse' or @table:visibility = 'filter')]">
  173.             <xsl:choose>
  174.                 <!-- if parser reads DTD the default is set to '1' -->
  175.                 <xsl:when test="@table:number-columns-repeated > 1">
  176.                     <!-- writes multiple entries of a cell -->
  177.                     <xsl:call-template name="repeat-write-cell">
  178.                         <xsl:with-param name="globalData"               select="$globalData" />
  179.                         <xsl:with-param name="allTableColumns"          select="$allTableColumns" />
  180.                         <xsl:with-param name="columnPosition"           select="$columnPosition" />
  181.                         <xsl:with-param name="currentTableColumn"       select="$currentTableColumn" />
  182.                         <xsl:with-param name="maxRowLength"             select="$maxRowLength" />
  183.                         <xsl:with-param name="numberColumnsRepeated"    select="@table:number-columns-repeated" />
  184.                         <xsl:with-param name="tableDataType"            select="$tableDataType" />
  185.                     </xsl:call-template>
  186.                 </xsl:when>
  187.                 <xsl:otherwise>
  188.                     <!-- writes an entry of a cell -->
  189.                     <xsl:call-template name="write-cell">
  190.                         <xsl:with-param name="globalData"           select="$globalData" />
  191.                         <xsl:with-param name="allTableColumns"      select="$allTableColumns" />
  192.                         <xsl:with-param name="columnPosition"       select="$columnPosition" />
  193.                         <xsl:with-param name="currentTableColumn"   select="$currentTableColumn" />
  194.                         <xsl:with-param name="maxRowLength"         select="$maxRowLength" />
  195.                         <xsl:with-param name="tableDataType"        select="$tableDataType" />
  196.                     </xsl:call-template>
  197.                 </xsl:otherwise>
  198.             </xsl:choose>
  199.         </xsl:if>
  200.     </xsl:template>
  201.  
  202.  
  203.     <xsl:template name="repeat-write-cell">
  204.         <xsl:param name="globalData" />
  205.         <xsl:param name="allTableColumns" />
  206.         <xsl:param name="columnPosition" />
  207.         <xsl:param name="currentTableColumn" />
  208.         <xsl:param name="maxRowLength" />
  209.         <xsl:param name="numberColumnsRepeated" />
  210.         <xsl:param name="tableDataType" />
  211.  
  212.         <xsl:choose>
  213.             <!-- This is the current workaround for the flood of cells, simulation background by repeating cell -->
  214.             <xsl:when test="$numberColumnsRepeated > 1 and $maxRowLength > $columnPosition">
  215.  
  216.                 <!-- writes an entry of a cell -->
  217.                 <xsl:call-template name="write-cell">
  218.                     <xsl:with-param name="globalData"           select="$globalData" />
  219.                     <xsl:with-param name="allTableColumns"      select="$allTableColumns" />
  220.                     <xsl:with-param name="columnPosition"       select="$columnPosition" />
  221.                     <xsl:with-param name="currentTableColumn"   select="$currentTableColumn" />
  222.                     <xsl:with-param name="tableDataType"        select="$tableDataType" />
  223.                 </xsl:call-template>
  224.                 <!-- repeat calling this method until all elements written out -->
  225.                 <xsl:if test="$debugEnabled">
  226.                     <xsl:message>+++++++++ cell repetition +++++++++</xsl:message>
  227.                 </xsl:if>
  228.                 <xsl:call-template name="repeat-write-cell">
  229.                     <xsl:with-param name="globalData"               select="$globalData" />
  230.                     <xsl:with-param name="allTableColumns"          select="$allTableColumns" />
  231.                     <xsl:with-param name="columnPosition"           select="$columnPosition + 1" />
  232.                     <xsl:with-param name="currentTableColumn"       select="$allTableColumns/table:table-column[position() = ($columnPosition + 1)]" />
  233.                     <xsl:with-param name="maxRowLength"             select="$maxRowLength" />
  234.                     <xsl:with-param name="numberColumnsRepeated"    select="$numberColumnsRepeated - 1" />
  235.                     <xsl:with-param name="tableDataType"            select="$tableDataType" />
  236.                 </xsl:call-template>
  237.             </xsl:when>
  238.             <xsl:otherwise>
  239.                 <!-- This is the current workaround for the flood of cells, simulation background by repeating cell -->
  240.                 <!--      When the maxRowLength is reached a last entry of a cell is written -->
  241.                 <xsl:call-template name="write-cell">
  242.                     <xsl:with-param name="globalData"           select="$globalData" />
  243.                     <xsl:with-param name="allTableColumns"      select="$allTableColumns" />
  244.                     <xsl:with-param name="columnPosition"       select="$columnPosition" />
  245.                     <xsl:with-param name="currentTableColumn"   select="$currentTableColumn" />
  246.                     <xsl:with-param name="tableDataType"        select="$tableDataType" />
  247.                 </xsl:call-template>
  248.             </xsl:otherwise>
  249.         </xsl:choose>
  250.     </xsl:template>
  251.  
  252.  
  253.     <xsl:template name="write-cell">
  254.         <xsl:param name="globalData" />
  255.         <xsl:param name="allTableColumns" />
  256.         <xsl:param name="columnPosition" />
  257.         <xsl:param name="currentTableColumn" />
  258.         <xsl:param name="tableDataType" />
  259.  
  260.         <!-- a non hidden column will be give out -->
  261.         <xsl:choose>
  262.             <xsl:when test="$currentTableColumn[not(@table:visibility = 'collapse' or @table:visibility = 'filter')]">
  263.                 <xsl:call-template name="create-table-cell-content">
  264.                     <xsl:with-param name="globalData"           select="$globalData" />
  265.                     <xsl:with-param name="allTableColumns"      select="$allTableColumns" />
  266.                     <xsl:with-param name="columnPosition"       select="$columnPosition" />
  267.                     <xsl:with-param name="currentTableColumn"   select="$currentTableColumn" />
  268.                     <xsl:with-param name="tableDataType"        select="$tableDataType" />
  269.                 </xsl:call-template>
  270.             </xsl:when>
  271.             <!-- a hidden column -->
  272.             <xsl:otherwise>
  273.                 <xsl:if test="$debugEnabled">
  274.                     <xsl:message>table column is hidden!</xsl:message>
  275.                 </xsl:if>
  276.             </xsl:otherwise>
  277.         </xsl:choose>
  278.     </xsl:template>
  279. </xsl:stylesheet>
  280.