home *** CD-ROM | disk | FTP | other *** search
/ Freelog 125 / Freelog_MarsAvril2015_No125.iso / Bureautique / LibreOffice / LibreOffice_4.3.5_Win_x86.msi / table_columns.xsl < prev    next >
Extensible Markup Language  |  2014-05-25  |  11KB  |  235 lines

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3.  * This file is part of the LibreOffice project.
  4.  *
  5.  * This Source Code Form is subject to the terms of the Mozilla Public
  6.  * License, v. 2.0. If a copy of the MPL was not distributed with this
  7.  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  8.  *
  9.  * This file incorporates work covered by the following license notice:
  10.  *
  11.  *   Licensed to the Apache Software Foundation (ASF) under one or more
  12.  *   contributor license agreements. See the NOTICE file distributed
  13.  *   with this work for additional information regarding copyright
  14.  *   ownership. The ASF licenses this file to you under the Apache
  15.  *   License, Version 2.0 (the "License"); you may not use this file
  16.  *   except in compliance with the License. You may obtain a copy of
  17.  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  18.  -->
  19. <!--
  20.     For further documentation and updates visit http://xml.openoffice.org/odf2xhtml
  21. -->
  22. <xsl:stylesheet version="1.0"
  23.     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  24.     xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
  25.     xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0"
  26.     xmlns:dc="http://purl.org/dc/elements/1.1/"
  27.     xmlns:dom="http://www.w3.org/2001/xml-events"
  28.     xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"
  29.     xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
  30.     xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
  31.     xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"
  32.     xmlns:math="http://www.w3.org/1998/Math/MathML"
  33.     xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0"
  34.     xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
  35.     xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
  36.     xmlns:ooo="http://openoffice.org/2004/office"
  37.     xmlns:oooc="http://openoffice.org/2004/calc"
  38.     xmlns:ooow="http://openoffice.org/2004/writer"
  39.     xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"
  40.     xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
  41.     xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
  42.     xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
  43.     xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
  44.     xmlns:xforms="http://www.w3.org/2002/xforms"
  45.     xmlns:xlink="http://www.w3.org/1999/xlink"
  46.     xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  47.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  48.     xmlns:xt="http://www.jclark.com/xt"
  49.     xmlns:common="http://exslt.org/common"
  50.     xmlns:xalan="http://xml.apache.org/xalan"
  51.     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">
  52.  
  53.     <xsl:param name="tableColumnElement"            select="'col'" />
  54.  
  55.     <!-- ******************************************** -->
  56.     <!-- *** Create table columns style variable  *** -->
  57.     <!-- ******************************************** -->
  58.  
  59.     <!-- current node is a table:table -->
  60.     <xsl:template name="create-column-style-variable">
  61.         <xsl:param name="globalData" />
  62.         <xsl:param name="allVisibleTableRows" />
  63.  
  64.         <!-- all columns of the table -->
  65.         <xsl:variable name="allTableColumns" select="table:table-column |
  66.                                                      table:table-column-group/descendant::table:table-column |
  67.                                                      table:table-header-columns/descendant::table:table-column" />
  68.         <!-- allTableColumns: Containing all columns of the table, hidden and viewed.
  69.             - if a column is hidden, if table:visibility has the value 'collapse' or 'filter', otherwise the value is 'visible'
  70.             - if a column is being repeated, each repeated column is explicitly written as entry in this variable.
  71.               Later (during template "write-cell") the style of the column will be mixed with the cell-style by using
  72.               the position() of the column entry and comparing it with the iterating cell number. -->
  73.         <xsl:variable name="allTableColumns-RTF">
  74.             <xsl:for-each select="$allTableColumns">
  75.                 <xsl:call-template name="adding-column-styles-entries">
  76.                     <xsl:with-param name="globalData"       select="$globalData" />
  77.                     <xsl:with-param name="allTableColumns"  select="$allTableColumns" />
  78.                 </xsl:call-template>
  79.             </xsl:for-each>
  80.         </xsl:variable>
  81.  
  82.         <xsl:choose>
  83.             <xsl:when test="function-available('common:node-set')">
  84.                 <xsl:call-template name="create-table-children">
  85.                     <xsl:with-param name="globalData"           select="$globalData" />
  86.                     <xsl:with-param name="allVisibleTableRows"  select="$allVisibleTableRows" />
  87.                     <xsl:with-param name="allTableColumns"      select="common:node-set($allTableColumns-RTF)" />
  88.                 </xsl:call-template>
  89.             </xsl:when>
  90.             <xsl:when test="function-available('xalan:nodeset')">
  91.                 <xsl:call-template name="create-table-children">
  92.                     <xsl:with-param name="globalData"           select="$globalData" />
  93.                     <xsl:with-param name="allVisibleTableRows"  select="$allVisibleTableRows" />
  94.                     <xsl:with-param name="allTableColumns"      select="xalan:nodeset($allTableColumns-RTF)" />
  95.                 </xsl:call-template>
  96.             </xsl:when>
  97.             <xsl:when test="function-available('xt:node-set')">
  98.                 <xsl:call-template name="create-table-children">
  99.                     <xsl:with-param name="globalData"           select="$globalData" />
  100.                     <xsl:with-param name="allVisibleTableRows"  select="$allVisibleTableRows" />
  101.                     <xsl:with-param name="allTableColumns"      select="xt:node-set($allTableColumns-RTF)" />
  102.                 </xsl:call-template>
  103.             </xsl:when>
  104.         </xsl:choose>
  105.     </xsl:template>
  106.  
  107.     <!-- current node is a table:table -->
  108.     <xsl:template name="create-table-children">
  109.         <xsl:param name="globalData" />
  110.         <xsl:param name="allVisibleTableRows" />
  111.         <xsl:param name="allTableColumns" />
  112.  
  113.  
  114.         <xsl:for-each select="$allTableColumns/table:table-column">
  115.             <xsl:if test="not(@table:visibility = 'collapse' or @table:visibility = 'filter')">
  116.  
  117.                 <xsl:call-template name="create-column-element">
  118.                     <xsl:with-param name="globalData"           select="$globalData" />
  119.                     <xsl:with-param name="allVisibleTableRows"  select="$allVisibleTableRows" />
  120.                     <xsl:with-param name="allTableColumns"      select="$allTableColumns" />
  121.                 </xsl:call-template>
  122.             </xsl:if>
  123.         </xsl:for-each>
  124.  
  125.         <xsl:call-template name="create-table-rows">
  126.             <xsl:with-param name="globalData"           select="$globalData" />
  127.             <xsl:with-param name="allVisibleTableRows"  select="$allVisibleTableRows" />
  128.             <xsl:with-param name="allTableColumns"      select="$allTableColumns" />
  129.         </xsl:call-template>
  130.     </xsl:template>
  131.  
  132.     <!-- To be OVERWRITTEN -->
  133.     <xsl:template name="create-column-element" />
  134.  
  135.     <!-- current node is a table:table-column -->
  136.     <xsl:template name="adding-column-styles-entries">
  137.         <xsl:param name="globalData" />
  138.         <xsl:param name="allTableColumns" />
  139.  
  140.         <xsl:choose>
  141.             <!-- if parser reads DTD the default is set to '1' -->
  142.             <xsl:when test="not(@table:number-columns-repeated and @table:number-columns-repeated > 1)">
  143.                 <!-- writes an entry of a column in the columns-variable -->
  144.                 <xsl:copy-of select="." />
  145.             </xsl:when>
  146.             <!-- No higher repetition of cells greater than 99 for the last and second last column.
  147.                  This is a workaround for some sample document (Waehrungsumrechner.sxc),
  148.                  having 230 repeated columns in the second last column to emulate background -->
  149.             <!-- NOTE: Testcase with a table containing table:table-column-group and/or table:table-header-columns -->
  150.             <xsl:when test="(last() or (last() - 1)) and @table:number-columns-repeated > 99">
  151.                 <!-- writes an entry of a column in the columns-variable -->
  152.                 <xsl:call-template name="repeat-adding-table-column">
  153.                     <xsl:with-param name="numberColumnsRepeated"    select="1" />
  154.                 </xsl:call-template>
  155.             </xsl:when>
  156.             <xsl:otherwise>
  157.                 <!-- repeated columns will be written explicit several times in the variable-->
  158.                 <xsl:call-template name="repeat-adding-table-column">
  159.                     <xsl:with-param name="numberColumnsRepeated"    select="@table:number-columns-repeated" />
  160.                 </xsl:call-template>
  161.             </xsl:otherwise>
  162.         </xsl:choose>
  163.      </xsl:template>
  164.  
  165.  
  166.     <!-- WRITES THE REPEATED COLUMN STYLE EXPLICIT AS AN ELEMENT IN THE COLUMNS-VARIABLE -->
  167.     <!-- current node is a table:table-column -->
  168.     <xsl:template name="repeat-adding-table-column">
  169.         <xsl:param name="table:table-column" />
  170.         <xsl:param name="numberColumnsRepeated" />
  171.  
  172.  
  173.         <xsl:choose>
  174.             <xsl:when test="$numberColumnsRepeated > 1">
  175.                 <!-- writes an entry of a column in the columns-variable -->
  176.                 <xsl:copy-of select="." />
  177.                 <!-- repeat calling this method until all elements written out -->
  178.                 <xsl:call-template name="repeat-adding-table-column">
  179.                     <xsl:with-param name="numberColumnsRepeated"    select="$numberColumnsRepeated - 1" />
  180.                 </xsl:call-template>
  181.             </xsl:when>
  182.             <xsl:otherwise>
  183.                 <!-- writes an entry of a column in the columns-variable -->
  184.                 <xsl:copy-of select="." />
  185.             </xsl:otherwise>
  186.         </xsl:choose>
  187.     </xsl:template>
  188.  
  189.  
  190.     <!--debugEnabled-START-->
  191.     <!-- giving out the 'allColumnStyle' variable:
  192.         For each 'table:table-column' of the 'allTableColumns' variable the style-name is given out.
  193.         In case of 'column-hidden-flag' attribute the text 'Column is hidden is given out.-->
  194.     <!-- current node is a table:table -->
  195.     <xsl:template name="table-debug-allTableColumns">
  196.         <xsl:param name="allTableColumns" />
  197.  
  198.         <!-- debug output as table summary attribute in html -->
  199.         <xsl:attribute name="summary">
  200.             <xsl:call-template name="table-debug-column-out">
  201.                 <xsl:with-param name="allTableColumns" select="$allTableColumns" />
  202.             </xsl:call-template>
  203.         </xsl:attribute>
  204.         <!-- debug output to console -->
  205.         <xsl:message>
  206.             <xsl:call-template name="table-debug-column-out">
  207.                 <xsl:with-param name="allTableColumns" select="$allTableColumns" />
  208.             </xsl:call-template>
  209.         </xsl:message>
  210.     </xsl:template>
  211.  
  212.     <!-- current node is a table:table -->
  213.     <xsl:template name="table-debug-column-out">
  214.         <xsl:param name="allTableColumns" />
  215.             <xsl:text>
  216.             DebugInformation: For each 'table:table-column' of the 'allTableColumns' variable the style-name is given out.
  217.                               In case of table:visibility attribute unequal 'visible' the 'column is hidden' no text is given out.
  218.             </xsl:text>
  219.                 <xsl:for-each select="$allTableColumns/table:table-column">
  220.                 <xsl:choose>
  221.                 <xsl:when test="@table:visibility = 'collapse' or @table:visibility = 'filter' ">
  222.             <xsl:text>  </xsl:text><xsl:value-of select="@table:style-name" /><xsl:text>column is hidden</xsl:text><xsl:text>
  223.             </xsl:text>
  224.                 </xsl:when>
  225.                 <xsl:otherwise>
  226.             <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>
  227.             </xsl:text>
  228.                 </xsl:otherwise>
  229.                 </xsl:choose>
  230.                            </xsl:for-each>
  231.     </xsl:template>
  232.     <!--debugEnabled-END-->
  233.  
  234. </xsl:stylesheet>
  235.