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.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2010-12-01  |  6.9 KB  |  165 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.     <!-- table row handling -->
  61.     <xsl:include href="table_rows.xsl" />
  62.     <!-- table column handling -->
  63.     <xsl:include href="table_columns.xsl" />
  64.     <!-- table cell handling -->
  65.     <xsl:include href="table_cells.xsl" />
  66.  
  67.     <xsl:param name="tableElement" select="'table'" />
  68.  
  69.     <!-- ******************* -->
  70.     <!-- *** main table  *** -->
  71.     <!-- ******************* -->
  72.  
  73.  
  74.     <xsl:template match="table:table" name="table:table">
  75.         <xsl:param name="globalData" />
  76.  
  77.         <!-- The table will only be created if the table:scenario is active -->
  78.         <xsl:if test="not(table:scenario) or table:scenario/@table:is-active">
  79.             <xsl:call-template name="create-table">
  80.                 <xsl:with-param name="globalData" select="$globalData" />
  81.             </xsl:call-template>
  82.         </xsl:if>
  83.     </xsl:template>
  84.  
  85.  
  86.  
  87.     <xsl:template name="create-table">
  88.         <xsl:param name="globalData" />
  89.  
  90.         <!-- by default '1', for each new sub/inner/nested table the number counts one up -->
  91.         <xsl:variable name="tableLevel" select="count(ancestor-or-self::table:table)" />
  92.         <!-- collecting all visible "table:table-row" elements of the table -->
  93.         <xsl:variable name="allVisibleTableRows" select="table:table-row[not(@table:visibility = 'collapse' or @table:visibility = 'filter')][count(ancestor-or-self::table:table) = $tableLevel] |
  94.                                                          table:table-header-rows/descendant::table:table-row[not(@table:visibility = 'collapse' or @table:visibility = 'filter')][count(ancestor-or-self::table:table) = $tableLevel] |
  95.                                                          table:table-row-group/descendant::table:table-row[not(@table:visibility = 'collapse' or @table:visibility = 'filter')][count(ancestor-or-self::table:table) = $tableLevel]" />
  96.         <!-- As the alignment of a table is by 'align' attribut is deprecated and as the CSS 'float' attribute not well displayed,
  97.              we do a trick by encapsulating the table with a aligned 'div' element-->
  98.         <xsl:variable name="table-alignment" select="key('styles', @style:name = current()/@table:style-name)/*/@table:align" />
  99.         <xsl:choose>
  100.             <xsl:when test="string-length($table-alignment) != 0">
  101.                 <xsl:element namespace="{$namespace}" name="div">
  102.                     <xsl:attribute name="style">
  103.                         <xsl:choose>
  104.                             <xsl:when test='$table-alignment="left" or $table-alignment="margins"'>
  105.                                 <xsl:text>text-align:left</xsl:text>
  106.                             </xsl:when>
  107.                             <xsl:when test='$table-alignment="right"'>
  108.                                 <xsl:text>text-align:right</xsl:text>
  109.                             </xsl:when>
  110.                             <xsl:when test='$table-alignment="center"'>
  111.                                 <xsl:text>text-align:center</xsl:text>
  112.                             </xsl:when>
  113.                         </xsl:choose>
  114.                     </xsl:attribute>
  115.                     <xsl:call-template name="create-table-element">
  116.                         <xsl:with-param name="globalData" select="$globalData" />
  117.                         <xsl:with-param name="allVisibleTableRows" select="$allVisibleTableRows" />
  118.                     </xsl:call-template>
  119.                 </xsl:element>
  120.             </xsl:when>
  121.             <xsl:otherwise>
  122.                 <xsl:call-template name="create-table-element">
  123.                     <xsl:with-param name="globalData" select="$globalData" />
  124.                     <xsl:with-param name="allVisibleTableRows" select="$allVisibleTableRows" />
  125.                 </xsl:call-template>
  126.             </xsl:otherwise>
  127.         </xsl:choose>
  128.     </xsl:template>
  129.  
  130.  
  131.     <xsl:template name="create-table-element">
  132.         <xsl:param name="globalData" />
  133.         <xsl:param name="allVisibleTableRows" />
  134.  
  135.         <xsl:element namespace="{$namespace}" name="{$tableElement}">
  136.             <xsl:attribute name="border">0</xsl:attribute>
  137.             <xsl:attribute name="cellspacing">0</xsl:attribute>
  138.             <xsl:attribute name="cellpadding">0</xsl:attribute>
  139.             <xsl:choose>
  140.                 <xsl:when test='name()="table:table"'>
  141.                     <xsl:variable name="value" select="$globalData/all-doc-styles/style[@style:name = current()/@table:style-name]/*/@style:rel-width" />
  142.                     <xsl:if test="$value">
  143.                         <xsl:attribute name="width">
  144.                             <xsl:value-of select="$value" />
  145.                         </xsl:attribute>
  146.                     </xsl:if>
  147.                 </xsl:when>
  148.                 <xsl:otherwise>
  149.                     <xsl:attribute name="width">100%</xsl:attribute>
  150.                 </xsl:otherwise>
  151.             </xsl:choose>
  152.  
  153.             <xsl:apply-templates select="@table:style-name">
  154.                 <xsl:with-param name="globalData" select="$globalData" />
  155.             </xsl:apply-templates>
  156.  
  157.             <xsl:call-template name="create-column-style-variable">
  158.                 <xsl:with-param name="globalData" select="$globalData" />
  159.                 <xsl:with-param name="allVisibleTableRows" select="$allVisibleTableRows" />
  160.             </xsl:call-template>
  161.         </xsl:element>
  162.     </xsl:template>
  163.  
  164. </xsl:stylesheet>
  165.