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_columns.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2010-12-01  |  10.7 KB  |  244 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.     <xsl:param name="tableColumnElement"            select="'col'" />
  63.  
  64.     <!-- ******************************************** -->
  65.     <!-- *** Create table columns style variable  *** -->
  66.     <!-- ******************************************** -->
  67.  
  68.     <!-- current node is a table:table -->
  69.     <xsl:template name="create-column-style-variable">
  70.         <xsl:param name="globalData" />
  71.         <xsl:param name="allVisibleTableRows" />
  72.  
  73.         <!-- all columns of the table -->
  74.         <xsl:variable name="allTableColumns" select="table:table-column |
  75.                                                      table:table-column-group/descendant::table:table-column |
  76.                                                      table:table-header-columns/descendant::table:table-column" />
  77.         <!-- allTableColumns: Containing all columns of the table, hidden and viewed.
  78.             - if a column is hidden, if table:visibility has the value 'collapse' or 'filter', otherwise the value is 'visible'
  79.             - if a column is being repeated, each repeated column is explicitly written as entry in this variable.
  80.               Later (during template "write-cell") the style of the column will be mixed with the cell-style by using
  81.               the position() of the column entry and comparing it with the iterating cell number. -->
  82.         <xsl:variable name="allTableColumns-RTF">
  83.             <xsl:for-each select="$allTableColumns">
  84.                 <xsl:call-template name="adding-column-styles-entries">
  85.                     <xsl:with-param name="globalData"       select="$globalData" />
  86.                     <xsl:with-param name="allTableColumns"  select="$allTableColumns" />
  87.                 </xsl:call-template>
  88.             </xsl:for-each>
  89.         </xsl:variable>
  90.  
  91.         <xsl:choose>
  92.             <xsl:when test="function-available('common:node-set')">
  93.                 <xsl:call-template name="create-table-children">
  94.                     <xsl:with-param name="globalData"           select="$globalData" />
  95.                     <xsl:with-param name="allVisibleTableRows"  select="$allVisibleTableRows" />
  96.                     <xsl:with-param name="allTableColumns"      select="common:node-set($allTableColumns-RTF)" />
  97.                 </xsl:call-template>
  98.             </xsl:when>
  99.             <xsl:when test="function-available('xalan:nodeset')">
  100.                 <xsl:call-template name="create-table-children">
  101.                     <xsl:with-param name="globalData"           select="$globalData" />
  102.                     <xsl:with-param name="allVisibleTableRows"  select="$allVisibleTableRows" />
  103.                     <xsl:with-param name="allTableColumns"      select="xalan:nodeset($allTableColumns-RTF)" />
  104.                 </xsl:call-template>
  105.             </xsl:when>
  106.             <xsl:when test="function-available('xt:node-set')">
  107.                 <xsl:call-template name="create-table-children">
  108.                     <xsl:with-param name="globalData"           select="$globalData" />
  109.                     <xsl:with-param name="allVisibleTableRows"  select="$allVisibleTableRows" />
  110.                     <xsl:with-param name="allTableColumns"      select="xt:node-set($allTableColumns-RTF)" />
  111.                 </xsl:call-template>
  112.             </xsl:when>
  113.         </xsl:choose>
  114.     </xsl:template>
  115.  
  116.     <!-- current node is a table:table -->
  117.     <xsl:template name="create-table-children">
  118.         <xsl:param name="globalData" />
  119.         <xsl:param name="allVisibleTableRows" />
  120.         <xsl:param name="allTableColumns" />
  121.  
  122.  
  123.         <xsl:for-each select="$allTableColumns/table:table-column">
  124.             <xsl:if test="not(@table:visibility = 'collapse' or @table:visibility = 'filter')">
  125.  
  126.                 <xsl:call-template name="create-column-element">
  127.                     <xsl:with-param name="globalData"           select="$globalData" />
  128.                     <xsl:with-param name="allVisibleTableRows"  select="$allVisibleTableRows" />
  129.                     <xsl:with-param name="allTableColumns"      select="$allTableColumns" />
  130.                 </xsl:call-template>
  131.             </xsl:if>
  132.         </xsl:for-each>
  133.  
  134.         <xsl:call-template name="create-table-rows">
  135.             <xsl:with-param name="globalData"           select="$globalData" />
  136.             <xsl:with-param name="allVisibleTableRows"  select="$allVisibleTableRows" />
  137.             <xsl:with-param name="allTableColumns"      select="$allTableColumns" />
  138.         </xsl:call-template>
  139.     </xsl:template>
  140.  
  141.     <!-- To be OVERWRITTEN -->
  142.     <xsl:template name="create-column-element" />
  143.  
  144.     <!-- current node is a table:table-column -->
  145.     <xsl:template name="adding-column-styles-entries">
  146.         <xsl:param name="globalData" />
  147.         <xsl:param name="allTableColumns" />
  148.  
  149.         <xsl:choose>
  150.             <!-- if parser reads DTD the default is set to '1' -->
  151.             <xsl:when test="not(@table:number-columns-repeated and @table:number-columns-repeated > 1)">
  152.                 <!-- writes an entry of a column in the columns-variable -->
  153.                 <xsl:copy-of select="." />
  154.             </xsl:when>
  155.             <!-- No higher repetition of cells greater than 99 for the last and second last column.
  156.                  This is a workaround for some sample document (Waehrungsumrechner.sxc),
  157.                  having 230 repeated columns in the second last column to emulate background -->
  158.             <!-- NOTE: Testcase with a table containing table:table-column-group and/or table:table-header-columns -->
  159.             <xsl:when test="(last() or (last() - 1)) and @table:number-columns-repeated > 99">
  160.                 <!-- writes an entry of a column in the columns-variable -->
  161.                 <xsl:call-template name="repeat-adding-table-column">
  162.                     <xsl:with-param name="numberColumnsRepeated"    select="1" />
  163.                 </xsl:call-template>
  164.             </xsl:when>
  165.             <xsl:otherwise>
  166.                 <!-- repeated colums will be written explicit several times in the variable-->
  167.                 <xsl:call-template name="repeat-adding-table-column">
  168.                     <xsl:with-param name="numberColumnsRepeated"    select="@table:number-columns-repeated" />
  169.                 </xsl:call-template>
  170.             </xsl:otherwise>
  171.         </xsl:choose>
  172.      </xsl:template>
  173.  
  174.  
  175.     <!-- WRITES THE REPEATED COLUMN STYLE EXPLICIT AS AN ELEMENT IN THE COLUMNS-VARIABLE -->
  176.     <!-- current node is a table:table-column -->
  177.     <xsl:template name="repeat-adding-table-column">
  178.         <xsl:param name="table:table-column" />
  179.         <xsl:param name="numberColumnsRepeated" />
  180.  
  181.  
  182.         <xsl:choose>
  183.             <xsl:when test="$numberColumnsRepeated > 1">
  184.                 <!-- writes an entry of a column in the columns-variable -->
  185.                 <xsl:copy-of select="." />
  186.                 <!-- repeat calling this method until all elements written out -->
  187.                 <xsl:call-template name="repeat-adding-table-column">
  188.                     <xsl:with-param name="numberColumnsRepeated"    select="$numberColumnsRepeated - 1" />
  189.                 </xsl:call-template>
  190.             </xsl:when>
  191.             <xsl:otherwise>
  192.                 <!-- writes an entry of a column in the columns-variable -->
  193.                 <xsl:copy-of select="." />
  194.             </xsl:otherwise>
  195.         </xsl:choose>
  196.     </xsl:template>
  197.  
  198.  
  199.     <!--debugEnabled-START-->
  200.     <!-- giving out the 'allColumnStyle' variable:
  201.         For each 'table:table-column' of the 'allTableColumns' variable the style-name is given out.
  202.         In case of 'column-hidden-flag' attribute the text 'Column is hidden is given out.-->
  203.     <!-- current node is a table:table -->
  204.     <xsl:template name="table-debug-allTableColumns">
  205.         <xsl:param name="allTableColumns" />
  206.  
  207.         <!-- debug output as table summary attribut in html -->
  208.         <xsl:attribute name="summary">
  209.             <xsl:call-template name="table-debug-column-out">
  210.                 <xsl:with-param name="allTableColumns" select="$allTableColumns" />
  211.             </xsl:call-template>
  212.         </xsl:attribute>
  213.         <!-- debug output to console -->
  214.         <xsl:message>
  215.             <xsl:call-template name="table-debug-column-out">
  216.                 <xsl:with-param name="allTableColumns" select="$allTableColumns" />
  217.             </xsl:call-template>
  218.         </xsl:message>
  219.     </xsl:template>
  220.  
  221.     <!-- current node is a table:table -->
  222.     <xsl:template name="table-debug-column-out">
  223.         <xsl:param name="allTableColumns" />
  224.             <xsl:text>
  225.             DebugInformation: For each 'table:table-column' of the 'allTableColumns' variable the style-name is given out.
  226.                               In case of table:visibility attribute unequal 'visible' the 'column is hidden' no text is given out.
  227.             </xsl:text>
  228.                 <xsl:for-each select="$allTableColumns/table:table-column">
  229.                 <xsl:choose>
  230.                 <xsl:when test="@table:visibility = 'collapse' or @table:visibility = 'filter' ">
  231.             <xsl:text>  </xsl:text><xsl:value-of select="@table:style-name" /><xsl:text>column is hidden</xsl:text><xsl:text>
  232.             </xsl:text>
  233.                 </xsl:when>
  234.                 <xsl:otherwise>
  235.             <xsl:text>  </xsl:text><xsl:value-of select="@table:style-name" /><xsl:text> </xsl:text><xsl:value-of select="@table:default-cell-style-name" /><xsl:text>
  236.             </xsl:text>
  237.                 </xsl:otherwise>
  238.                 </xsl:choose>
  239.                            </xsl:for-each>
  240.     </xsl:template>
  241.     <!--debugEnabled-END-->
  242.  
  243. </xsl:stylesheet>
  244.