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 / table2.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2010-12-01  |  9.1 KB  |  223 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.     xmlns="http://www.w3.org/1999/xhtml">
  59.  
  60.  
  61.  
  62.     <!-- current node is a table:table -->
  63.     <xsl:template name="create-table-children">
  64.         <xsl:param name="globalData" />
  65.         <xsl:param name="allVisibleTableRows" />
  66.         <xsl:param name="allTableColumns" />
  67.  
  68.         <xsl:element name="colgroup">
  69.             <xsl:for-each select="$allTableColumns/table:table-column">
  70.                 <xsl:if test="not(@table:visibility = 'collapse' or @table:visibility = 'filter')">
  71.                     <xsl:element name="col">
  72.                         <xsl:variable name="value" select="$globalData/all-doc-styles/style[@style:name = current()/@table:style-name]/*/@style:column-width" />
  73.                         <xsl:if test="$value">
  74.                             <xsl:attribute name="width">
  75.                                 <!-- using the absolute width, problems with the relative in browser (in OOo style:rel-column-width) -->
  76.                                 <xsl:call-template name="convert2px">
  77.                                     <xsl:with-param name="value" select="$globalData/all-doc-styles/style[@style:name = current()/@table:style-name]/*/@style:column-width" />
  78.                                 </xsl:call-template>
  79.                             </xsl:attribute>
  80.                         </xsl:if>
  81.                     </xsl:element>
  82.                     <!-- *** the column-style ***
  83.                     <xsl:attribute name="width">
  84.                         <xsl:variable name="currentColumnStyleName" select="$allTableColumns/table:table-column[position() = $columnPosition]/@table:style-name" />
  85.                         <xsl:value-of select="$globalData/all-doc-styles/style[@style:name = $currentColumnStyleName]/*/@style:column-width" />
  86.                     </xsl:attribute>-->
  87.                 </xsl:if>
  88.             </xsl:for-each>
  89.         </xsl:element>
  90.  
  91.         <xsl:call-template name="create-table-rows">
  92.             <xsl:with-param name="globalData"           select="$globalData" />
  93.             <xsl:with-param name="allVisibleTableRows"  select="$allVisibleTableRows" />
  94.             <xsl:with-param name="allTableColumns"      select="$allTableColumns" />
  95.         </xsl:call-template>
  96.     </xsl:template>
  97.  
  98.  
  99.  
  100.     <!-- Creating the content of a table content using CSS styles -->
  101.     <xsl:template name="create-table-cell-content">
  102.         <xsl:param name="tableDataType" />
  103.         <xsl:param name="globalData" />
  104.         <xsl:param name="allTableColumns" />
  105.         <xsl:param name="columnPosition" />
  106.         <xsl:param name="currentTableColumn" />
  107.  
  108.         <xsl:element name="{$tableDataType}">
  109.  
  110.             <!-- if parser reads DTD the default is set to '1' -->
  111.             <xsl:if test="@table:number-columns-spanned and @table:number-columns-spanned > 1">
  112.                 <xsl:attribute name="colspan">
  113.                     <xsl:value-of select="@table:number-columns-spanned" />
  114.                 </xsl:attribute>
  115.             </xsl:if>
  116.             <!-- if parser reads DTD the default is set to '1' -->
  117.             <xsl:if test="@table:number-rows-spanned and @table:number-rows-spanned > 1">
  118.                 <xsl:attribute name="rowspan">
  119.                     <xsl:value-of select="@table:number-rows-spanned" />
  120.                 </xsl:attribute>
  121.             </xsl:if>
  122.  
  123.  
  124.             <!-- *** the cell-style *** -->
  125.             <!-- The cell style has no conclusion with the column style, so we switch the order/priorities due to browser issues
  126.  
  127.                 The cell-style depends on two attributes:
  128.  
  129.                 1) table:style-name - the style properties of cell. When they exist, a default alignement (cp. below) will be added for the
  130.                                       case of no alignment in the style exist.
  131.  
  132.                 2) office:value-type - the value type of the table-cell giving the default alignments.
  133.                                       By default a string value is left aligned, all other are aligned:right.
  134.             -->
  135.             <xsl:choose>
  136.                 <xsl:when test="@table:style-name">
  137.                     <xsl:call-template name="set-styles">
  138.                         <xsl:with-param name="globalData" select="$globalData" />
  139.                         <xsl:with-param name="styleName" select="@table:style-name" />
  140.                         <xsl:with-param name="currentTableColumn" select="$currentTableColumn" />
  141.                     </xsl:call-template>
  142.                 </xsl:when>
  143.                 <xsl:otherwise>
  144.                     <!-- Cells without a style use the 'table:default-cell-style-name'
  145.                          when there is no default cell style specified for the current column. -->
  146.                     <xsl:variable name="defaultCellStyleName" select="$currentTableColumn/@table:default-cell-style-name" />
  147.                     <xsl:choose>
  148.                         <xsl:when test="$defaultCellStyleName">
  149.                             <xsl:call-template name="set-styles">
  150.                                 <xsl:with-param name="globalData" select="$globalData" />
  151.                                 <xsl:with-param name="styleName" select="$defaultCellStyleName" />
  152.                                 <xsl:with-param name="currentTableColumn" select="$currentTableColumn" />
  153.                             </xsl:call-template>
  154.                         </xsl:when>
  155.                         <xsl:otherwise>
  156.                             <!-- No cell style exists, nor a default table cell style for the column -->
  157.                             <xsl:attribute name="style">
  158.                                 <!-- sets cell alignment dependent of cell value type -->
  159.                                 <xsl:call-template name="set-cell-alignment" />
  160.                             </xsl:attribute>
  161.                         </xsl:otherwise>
  162.                     </xsl:choose>
  163.                 </xsl:otherwise>
  164.             </xsl:choose>
  165.  
  166.             <xsl:if test="$debugEnabled">
  167.                 <xsl:message>A table cell '<xsl:value-of select="$tableDataType" />' element has been added!</xsl:message>
  168.             </xsl:if>
  169.  
  170.             <!-- empty cell tags produce problems with width CSS style on itself other table cells as well
  171.                 therefore an non breakable space ( / ) have been inserted.-->
  172.             <xsl:choose>
  173.                 <xsl:when test="node()">
  174.                     <xsl:call-template name="apply-styles-and-content">
  175.                         <xsl:with-param name="globalData" select="$globalData" />
  176.                     </xsl:call-template>
  177.                 </xsl:when>
  178.                 <xsl:otherwise>
  179.                     <xsl:call-template name="apply-styles-and-content">
  180.                         <xsl:with-param name="globalData" select="$globalData" />
  181.                     </xsl:call-template>
  182.                     <xsl:text> </xsl:text>
  183.                 </xsl:otherwise>
  184.             </xsl:choose>
  185.  
  186.         </xsl:element>
  187.     </xsl:template>
  188.  
  189.  
  190.     <!-- Sets the cell alignment by the 'office:value-type' of the 'table:table-cell'.
  191.          Strings have a left alignment, other values right -->
  192.     <xsl:template name="set-cell-alignment">
  193.         <xsl:choose>
  194.             <xsl:when test="@office:value-type and not(@office:value-type = 'string')">text-align:right; </xsl:when>
  195.             <xsl:otherwise>text-align:left;</xsl:otherwise>
  196.         </xsl:choose>
  197.     </xsl:template>
  198.  
  199.  
  200.  
  201.     <!-- Sets styles of a cell -->
  202.     <xsl:template name="set-styles">
  203.         <xsl:param name="globalData" />
  204.         <xsl:param name="styleName" />
  205.         <xsl:param name="currentTableColumn" />
  206.  
  207.         <xsl:attribute name="style">
  208.             <!-- sets cell alignment dependent of cell value type -->
  209.             <xsl:call-template name="set-cell-alignment" />
  210.  
  211.             <!-- set column style (disjunct of cell style) -->
  212.             <xsl:value-of select="$globalData/all-styles/style[@style:name = $currentTableColumn/@table:style-name]/final-properties" />
  213.  
  214.        </xsl:attribute>
  215.  
  216.        <!-- cell style header -->
  217.        <xsl:attribute name="class">
  218.            <xsl:value-of select="translate($styleName, '.,;: %()[]/\+', '_____________')"/>
  219.        </xsl:attribute>
  220.     </xsl:template>
  221. </xsl:stylesheet>
  222.  
  223.