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_rows.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2010-12-01  |  8.7 KB  |  213 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.     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">
  58.  
  59.  
  60.     <xsl:param name="rowElement" select="'tr'" />
  61.  
  62.     <!-- ********************************** -->
  63.     <!-- *** write repeating table rows *** -->
  64.     <!-- ********************************** -->
  65.  
  66.     <!-- current node is a table:table -->
  67.     <xsl:template name="create-table-rows">
  68.         <xsl:param name="globalData" />
  69.         <xsl:param name="allVisibleTableRows" />
  70.         <xsl:param name="allTableColumns" />
  71.  
  72.         <!-- Some Office Calc documents simulate a background by repeating one of the later cells until end of used space
  73.              (The value of "table:number-columns-repeated" is enourmous). Writing out all these cells would be fatal in time
  74.              and output size. Therefore, this global variable shows us the longest row with content. -->
  75.         <xsl:variable name="maxRowLength" select="count($allTableColumns/table:table-column)" />
  76.         <xsl:if test="$debugEnabled">
  77.             <xsl:message>maxRowLength: <xsl:value-of select="$maxRowLength" /></xsl:message>
  78.             <xsl:call-template name="table-debug-allTableColumns">
  79.                 <xsl:with-param name="allTableColumns" select="$allTableColumns" />
  80.             </xsl:call-template>
  81.         </xsl:if>
  82.  
  83.         <!-- a table is a table header, when it has a "table:table-header-rows" ancestor -->
  84.         <xsl:variable name="tableDataType">
  85.             <xsl:choose>
  86.                 <xsl:when test="ancestor::table:table-header-rows">
  87.                     <xsl:text>th</xsl:text>
  88.                 </xsl:when>
  89.                 <xsl:otherwise>
  90.                     <xsl:text>td</xsl:text>
  91.                 </xsl:otherwise>
  92.             </xsl:choose>
  93.         </xsl:variable>
  94.  
  95.         <!-- removes repetition of rows, most probably done for background emulating -->
  96.         <xsl:for-each select="$allVisibleTableRows">
  97.             <xsl:choose>
  98.                 <xsl:when test="(last() or (last() - 1)) and @table:number-rows-repeated > 99">
  99.                     <xsl:call-template name="repeat-write-row">
  100.                         <xsl:with-param name="globalData"           select="$globalData" />
  101.                         <xsl:with-param name="allTableColumns"      select="$allTableColumns" />
  102.                         <xsl:with-param name="numberRowsRepeated"   select="1" />
  103.                         <xsl:with-param name="maxRowLength"         select="$maxRowLength" />
  104.                         <xsl:with-param name="tableDataType"        select="$tableDataType" />
  105.                     </xsl:call-template>
  106.                 </xsl:when>
  107.                 <xsl:otherwise>
  108.                     <xsl:call-template name="repeat-write-row">
  109.                         <xsl:with-param name="globalData"           select="$globalData" />
  110.                         <xsl:with-param name="allTableColumns"      select="$allTableColumns" />
  111.                         <xsl:with-param name="numberRowsRepeated"   select="@table:number-rows-repeated" />
  112.                         <xsl:with-param name="maxRowLength"         select="$maxRowLength" />
  113.                         <xsl:with-param name="tableDataType"        select="$tableDataType" />
  114.                     </xsl:call-template>
  115.                 </xsl:otherwise>
  116.             </xsl:choose>
  117.         </xsl:for-each>
  118.     </xsl:template>
  119.  
  120.  
  121.     <xsl:template name="repeat-write-row">
  122.         <xsl:param name="globalData" />
  123.         <xsl:param name="allTableColumns" />
  124.         <xsl:param name="numberRowsRepeated" select="1" />
  125.         <xsl:param name="maxRowLength" />
  126.         <xsl:param name="tableDataType" />
  127.  
  128.         <xsl:choose>
  129.             <!-- write an entry of a row and repeat calling this method until all elements are written out -->
  130.             <xsl:when test="$numberRowsRepeated > 1 and table:table-cell">
  131.                 <xsl:call-template name="write-row">
  132.                     <xsl:with-param name="globalData"       select="$globalData" />
  133.                     <xsl:with-param name="allTableColumns"  select="$allTableColumns" />
  134.                     <xsl:with-param name="maxRowLength"     select="$maxRowLength" />
  135.                     <xsl:with-param name="tableDataType"    select="$tableDataType" />
  136.                 </xsl:call-template>
  137.  
  138.                 <!-- NOTE: take variable from the output of repeated write-row and iterate giving out the variable -->
  139.                 <xsl:call-template name="repeat-write-row">
  140.                     <xsl:with-param name="globalData"           select="$globalData" />
  141.                     <xsl:with-param name="allTableColumns"      select="$allTableColumns" />
  142.                     <xsl:with-param name="maxRowLength"         select="$maxRowLength" />
  143.                     <xsl:with-param name="numberRowsRepeated"   select="$numberRowsRepeated - 1" />
  144.                     <xsl:with-param name="tableDataType"        select="$tableDataType" />
  145.                 </xsl:call-template>
  146.             </xsl:when>
  147.             <!-- write a single entry of a row -->
  148.             <xsl:otherwise>
  149.                 <xsl:call-template name="write-row">
  150.                     <xsl:with-param name="globalData"           select="$globalData" />
  151.                     <xsl:with-param name="allTableColumns"      select="$allTableColumns" />
  152.                     <xsl:with-param name="maxRowLength"         select="$maxRowLength" />
  153.                     <xsl:with-param name="tableDataType"        select="$tableDataType" />
  154.                 </xsl:call-template>
  155.             </xsl:otherwise>
  156.         </xsl:choose>
  157.     </xsl:template>
  158.  
  159.  
  160.     <xsl:template name="add-table-row-attributes">
  161.         <xsl:param name="globalData" />
  162.  
  163.         <!-- writing the style of the row -->
  164.         <xsl:if test="@table:style-name">
  165.             <xsl:call-template name='add-style-properties'>
  166.                 <xsl:with-param name="globalData" select="$globalData" />
  167.             </xsl:call-template>
  168.         </xsl:if>
  169.     </xsl:template>
  170.  
  171.     <xsl:template name="write-row">
  172.         <xsl:param name="globalData" />
  173.         <xsl:param name="allTableColumns" />
  174.         <xsl:param name="maxRowLength" />
  175.         <xsl:param name="tableDataType" />
  176.  
  177.  
  178.         <xsl:element namespace="{$namespace}" name="{$rowElement}">
  179.             <xsl:call-template name='add-table-row-attributes'>
  180.                 <xsl:with-param name="globalData" select="$globalData" />
  181.             </xsl:call-template>
  182.  
  183.             <xsl:if test="$debugEnabled">
  184.                 <xsl:message>'tr' element has been added!</xsl:message>
  185.             </xsl:if>
  186.  
  187.             <xsl:apply-templates select="table:table-cell">
  188.                 <xsl:with-param name="globalData"       select="$globalData" />
  189.                 <xsl:with-param name="allTableColumns"  select="$allTableColumns" />
  190.                 <xsl:with-param name="maxRowLength"     select="$maxRowLength" />
  191.                 <xsl:with-param name="tableDataType"    select="$tableDataType" />
  192.             </xsl:apply-templates>
  193.  
  194.         </xsl:element>
  195.     </xsl:template>
  196.  
  197.  
  198.     <!-- **************************** -->
  199.     <!-- *** HELPER: table styles *** -->
  200.     <!-- **************************** -->
  201.  
  202.     <xsl:template name="add-style-properties">
  203.         <xsl:param name="globalData" />
  204.         <xsl:param name="allTableColumns" />
  205.         <xsl:param name="node-position" />
  206.  
  207.         <xsl:attribute name="class">
  208.             <xsl:value-of select="translate(@table:style-name, '. %()/\+', '')" />
  209.         </xsl:attribute>
  210.     </xsl:template>
  211.  
  212. </xsl:stylesheet>
  213.