update
This commit is contained in:
@@ -0,0 +1,428 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
* This file is part of the LibreOffice project.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* This file incorporates work covered by the following license notice:
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed
|
||||
* with this work for additional information regarding copyright
|
||||
* ownership. The ASF licenses this file to you under the Apache
|
||||
* License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
||||
-->
|
||||
<!--
|
||||
For further documentation and updates visit http://xml.openoffice.org/odf2xhtml
|
||||
-->
|
||||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:java="http://xml.apache.org/xslt/java" xmlns:urlencoder="http://www.jclark.com/xt/java/java.net.URLEncoder" 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 java urlencoder">
|
||||
|
||||
|
||||
<xsl:include href="table_of_content.xsl"/>
|
||||
|
||||
|
||||
<!-- ****************** -->
|
||||
<!-- *** Whitespace *** -->
|
||||
<!-- ****************** -->
|
||||
|
||||
<xsl:template match="text:s">
|
||||
<xsl:call-template name="write-breakable-whitespace">
|
||||
<xsl:with-param name="whitespaces" select="@text:c"/>
|
||||
</xsl:call-template>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<!--write the number of 'whitespaces' -->
|
||||
<xsl:template name="write-breakable-whitespace">
|
||||
<xsl:param name="whitespaces"/>
|
||||
|
||||
<!--write two space chars as the normal white space character will be stripped
|
||||
and the other is able to break -->
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:if test="$whitespaces >= 2">
|
||||
<xsl:call-template name="write-breakable-whitespace-2">
|
||||
<xsl:with-param name="whitespaces" select="$whitespaces - 1"/>
|
||||
</xsl:call-template>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<!--write the number of 'whitespaces' -->
|
||||
<xsl:template name="write-breakable-whitespace-2">
|
||||
<xsl:param name="whitespaces"/>
|
||||
<!--write two space chars as the normal white space character will be stripped
|
||||
and the other is able to break -->
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:if test="$whitespaces >= 2">
|
||||
<xsl:call-template name="write-breakable-whitespace">
|
||||
<xsl:with-param name="whitespaces" select="$whitespaces - 1"/>
|
||||
</xsl:call-template>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<!-- currentSolution: 8 non-breakable-spaces instead of a TAB is an approximation.
|
||||
Sometimes less spaces than 8 might be needed and the output might be more difficult to read-->
|
||||
<xsl:template match="text:tab">
|
||||
<xsl:param name="globalData"/>
|
||||
|
||||
<xsl:call-template name="write-breakable-whitespace">
|
||||
<xsl:with-param name="whitespaces" select="8"/>
|
||||
</xsl:call-template>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
|
||||
<!-- *************** -->
|
||||
<!-- *** Textbox *** -->
|
||||
<!-- *************** -->
|
||||
|
||||
<!-- ID / NAME of text-box -->
|
||||
<xsl:template match="@draw:name">
|
||||
<xsl:attribute name="id">
|
||||
<xsl:choose>
|
||||
<xsl:when test="number(substring(.,1,1))">
|
||||
<!-- Heuristic: If the first character is a number a 'a_' will be set
|
||||
as prefix, as id have to be of type NMTOKEN -->
|
||||
<xsl:value-of select="concat('a_',translate(., '
&<>.,;: %()[]/\+', '___________________________'))"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="translate(., '
&<>.,;: %()[]/\+', '___________________________')"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:attribute>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template match="text:line-break">
|
||||
<xsl:param name="listIndent"/>
|
||||
|
||||
<xsl:element namespace="{$namespace}" name="br"/>
|
||||
|
||||
<!-- line breaks in lists need an indent similar to the list label -->
|
||||
<xsl:if test="$listIndent">
|
||||
<xsl:element namespace="{$namespace}" name="span">
|
||||
<!-- some locales use , instead of . so replace it -->
|
||||
<xsl:attribute name="style">margin-left:<xsl:value-of select="translate($listIndent, ',', '.')"/>cm</xsl:attribute>
|
||||
</xsl:element>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<!-- currently there have to be an explicit call of the style attribute nodes, maybe the attributes nodes have no priority only order relevant-->
|
||||
<xsl:template name="apply-styles-and-content">
|
||||
<xsl:param name="globalData"/>
|
||||
<xsl:param name="footnotePrefix" />
|
||||
<xsl:apply-templates select="@*">
|
||||
<xsl:with-param name="globalData" select="$globalData"/>
|
||||
</xsl:apply-templates>
|
||||
<!-- the footnote symbol is the prefix for a footnote in the footer -->
|
||||
<xsl:copy-of select="$footnotePrefix"/>
|
||||
<xsl:apply-templates select="node()">
|
||||
<xsl:with-param name="globalData" select="$globalData"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<!-- ******************* -->
|
||||
<!-- *** References *** -->
|
||||
<!-- ******************* -->
|
||||
|
||||
<xsl:template match="text:reference-ref | text:sequence-ref | text:bookmark-ref">
|
||||
<xsl:param name="globalData"/>
|
||||
<xsl:if test="*|text()">
|
||||
<xsl:element namespace="{$namespace}" name="a">
|
||||
<xsl:attribute name="href">
|
||||
<xsl:text>#</xsl:text>
|
||||
<xsl:choose>
|
||||
<xsl:when test="number(substring(@text:ref-name,1,1))">
|
||||
<!-- Heuristic: If the first character is a number a 'a_' will be set
|
||||
as prefix, as id have to be of type NMTOKEN -->
|
||||
<xsl:value-of select="concat('a_',translate(@text:ref-name, '
&<>.,;: %()[]/\+', '___________________________'))"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="translate(@text:ref-name, '
&<>.,;: %()[]/\+', '___________________________')"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:attribute>
|
||||
|
||||
<xsl:apply-templates select="@* | node()">
|
||||
<xsl:with-param name="globalData" select="$globalData"/>
|
||||
</xsl:apply-templates>
|
||||
|
||||
</xsl:element>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="@text:name">
|
||||
<xsl:attribute name="id">
|
||||
<xsl:choose>
|
||||
<xsl:when test="number(substring(.,1,1))">
|
||||
<!-- Heuristic: If the first character is a number a 'a_' will be set
|
||||
as prefix, as id have to be of type NMTOKEN -->
|
||||
<xsl:value-of select="concat('a_',translate(., '
&<>.,;: %()[]/\+', '___________________________'))"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="translate(., '
&<>.,;: %()[]/\+', '___________________________')"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:attribute>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="text:sequence">
|
||||
<xsl:param name="globalData"/>
|
||||
|
||||
<xsl:element namespace="{$namespace}" name="a">
|
||||
<xsl:apply-templates select="@*" />
|
||||
<xsl:attribute name="id">
|
||||
<xsl:choose>
|
||||
<xsl:when test="number(substring(@text:ref-name,1,1))">
|
||||
<!-- Heuristic: If the first character is a number a 'a_' will be set
|
||||
as prefix, as id have to be of type NMTOKEN -->
|
||||
<xsl:value-of select="concat('a_',translate(@text:ref-name, '
&<>.,;: %()[]/\+', '___________________________'))"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="translate(@text:ref-name, '
&<>.,;: %()[]/\+', '___________________________')"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:attribute>
|
||||
</xsl:element>
|
||||
|
||||
<xsl:apply-templates>
|
||||
<xsl:with-param name="globalData" select="$globalData"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="text:reference-mark">
|
||||
<xsl:param name="globalData"/>
|
||||
|
||||
<xsl:element namespace="{$namespace}" name="a">
|
||||
<xsl:apply-templates select="@*" />
|
||||
<xsl:attribute name="id">
|
||||
<xsl:choose>
|
||||
<xsl:when test="number(substring(@text:name,1,1))">
|
||||
<!-- Heuristic: If the first character is a number a 'a_' will be set
|
||||
as prefix, as id have to be of type NMTOKEN -->
|
||||
<xsl:value-of select="concat('a_',translate(@text:name, '
&<>.,;: %()[]/\+', '___________________________'))"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="translate(@text:name, '
&<>.,;: %()[]/\+', '___________________________')"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:attribute>
|
||||
</xsl:element>
|
||||
|
||||
<xsl:apply-templates>
|
||||
<xsl:with-param name="globalData" select="$globalData"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template match="text:reference-mark-start">
|
||||
<xsl:param name="globalData"/>
|
||||
|
||||
<xsl:element namespace="{$namespace}" name="a">
|
||||
<xsl:apply-templates select="@*" />
|
||||
</xsl:element>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="text:bibliography-mark">
|
||||
<xsl:param name="globalData"/>
|
||||
|
||||
<xsl:element namespace="{$namespace}" name="a">
|
||||
<xsl:apply-templates select="@* | node()">
|
||||
<xsl:with-param name="globalData" select="$globalData"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:element>
|
||||
</xsl:template>
|
||||
|
||||
<!-- @text:title exist only in text:bibliography-mark -->
|
||||
<xsl:template match="@text:title">
|
||||
<xsl:attribute name="title">
|
||||
<xsl:value-of select="."/>
|
||||
</xsl:attribute>
|
||||
</xsl:template>
|
||||
|
||||
<!-- @text:url exist only in text:bibliography-mark -->
|
||||
<xsl:template match="@text:url">
|
||||
<xsl:attribute name="href">
|
||||
<xsl:value-of select="."/>
|
||||
</xsl:attribute>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="text:user-defined">
|
||||
<xsl:apply-templates/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="office:annotation">
|
||||
<xsl:element name="span">
|
||||
<xsl:attribute name="title">annotation</xsl:attribute>
|
||||
<xsl:attribute name="class">annotation_style_by_filter</xsl:attribute>
|
||||
<xsl:apply-templates select="@*" />
|
||||
<br/>
|
||||
<xsl:text>[ANNOTATION:</xsl:text>
|
||||
<br/>
|
||||
<xsl:apply-templates select="*" mode="annotation"/>
|
||||
<xsl:text>]</xsl:text>
|
||||
</xsl:element>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="text:p" mode="annotation">
|
||||
<br/>
|
||||
<xsl:element name="span">
|
||||
<xsl:text>NOTE: '</xsl:text>
|
||||
<xsl:apply-templates />
|
||||
<xsl:text>'</xsl:text>
|
||||
</xsl:element>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="dc:creator" mode="annotation">
|
||||
<br/>
|
||||
<xsl:element name="span">
|
||||
<xsl:attribute name="title">dc:creator</xsl:attribute>
|
||||
<xsl:text>BY '</xsl:text>
|
||||
<xsl:apply-templates />
|
||||
<xsl:text>'</xsl:text>
|
||||
</xsl:element>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="dc:date" mode="annotation">
|
||||
<br/>
|
||||
<xsl:element name="span">
|
||||
<xsl:attribute name="title">dc:date</xsl:attribute>
|
||||
<xsl:text>ON '</xsl:text>
|
||||
<xsl:apply-templates />
|
||||
<xsl:text>'</xsl:text>
|
||||
</xsl:element>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="meta:date-string" mode="annotation">
|
||||
<br/>
|
||||
<xsl:element name="span">
|
||||
<xsl:attribute name="title">meta-date-string</xsl:attribute>
|
||||
<xsl:text>META DATE '</xsl:text>
|
||||
<xsl:apply-templates />
|
||||
<xsl:text>'</xsl:text>
|
||||
</xsl:element>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<!-- *************** -->
|
||||
<!-- *** HELPER *** -->
|
||||
<!-- *************** -->
|
||||
|
||||
|
||||
<xsl:template name="create-href">
|
||||
<xsl:param name="href"/>
|
||||
<xsl:param name="mimetype"/>
|
||||
|
||||
<xsl:choose>
|
||||
<!-- internal OOo URL used in content tables -->
|
||||
<xsl:when test="contains($href, '%7Coutline') or contains($href, '|outline')">
|
||||
<!-- the simplest workaround for content tables in a single document is to create an anchor from every heading element.
|
||||
Downside: multiple identical headings won't refer always to the first.
|
||||
-->
|
||||
<xsl:text>#</xsl:text>
|
||||
<xsl:variable name="title">
|
||||
<xsl:apply-templates mode="concatenate"/>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:value-of select="concat('a_', translate(normalize-space($title), '.,;: %()[]/\+', '_____________'))"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="self::draw:image[office:binary-data]">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$mimetype">
|
||||
<xsl:text>data:</xsl:text><xsl:value-of select="$mimetype"/><xsl:text>;base64,</xsl:text><xsl:value-of select="office:binary-data"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:text>data:image/*;base64,</xsl:text><xsl:value-of select="office:binary-data"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:choose>
|
||||
<!-- in case of packed open office document -->
|
||||
<xsl:when test="starts-with($sourceBaseURL, 'jar:') or $isPackageFormat">
|
||||
<xsl:choose>
|
||||
<!-- for images relative to open office document -->
|
||||
<xsl:when test="starts-with($href, '../')">
|
||||
<!-- creating an absolute http URL to the packed image file (removing the '.')-->
|
||||
<xsl:value-of select="concat(substring-after(substring-before($sourceBaseURL, '!'), 'jar:'), '/', $href, $optionalURLSuffix)"/>
|
||||
</xsl:when>
|
||||
<!-- for absolute URLs & absolute paths -->
|
||||
<xsl:when test="contains($href, ':') or starts-with($href, '/')">
|
||||
<xsl:value-of select="concat($href, $optionalURLSuffix)"/>
|
||||
</xsl:when>
|
||||
<!-- for images jared in open office document -->
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="concat($sourceBaseURL, $href, $optionalURLSuffix)"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:choose>
|
||||
<!-- for absolute URLs & Paths -->
|
||||
<xsl:when test="contains($href, ':') or starts-with($href, '/')">
|
||||
<xsl:value-of select="concat($href, $optionalURLSuffix)"/>
|
||||
</xsl:when>
|
||||
<!-- for relative URLs -->
|
||||
<xsl:when test="starts-with($href, '#')">
|
||||
<!-- intra document ref -->
|
||||
<xsl:value-of select="$href"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="concat($sourceBaseURL, $href, $optionalURLSuffix)"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="text()" mode="concatenate">
|
||||
<xsl:value-of select="."/>
|
||||
</xsl:template>
|
||||
<xsl:template match="*" mode="concatenate">
|
||||
<xsl:apply-templates mode="concatenate"/>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<!-- ******************** -->
|
||||
<!-- *** Common Rules *** -->
|
||||
<!-- ******************** -->
|
||||
|
||||
<!-- ignore / neglect the following elements -->
|
||||
<xsl:template match="draw:custom-shape | draw:g | office:forms | text:alphabetical-index-mark | text:alphabetical-index-mark-end | text:alphabetical-index-mark-start | text:bibliography-source | text:number | text:reference-mark-end | text:sequence-decls | text:soft-page-break | text:table-of-content-source | text:tracked-changes | text:user-field-decls"/>
|
||||
|
||||
<!-- default template used by purpose-->
|
||||
<xsl:template match="text:bibliography | text:change-end | text:change-start">
|
||||
<xsl:param name="globalData"/>
|
||||
|
||||
<xsl:apply-templates>
|
||||
<xsl:with-param name="globalData" select="$globalData"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:template>
|
||||
|
||||
<!-- default template for not recognized elements -->
|
||||
<xsl:template match="*">
|
||||
<xsl:param name="globalData"/>
|
||||
<xsl:message>Using default element rule for ODF element '<xsl:value-of select="name()"/>'.</xsl:message>
|
||||
|
||||
<xsl:apply-templates>
|
||||
<xsl:with-param name="globalData" select="$globalData"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="@*"/>
|
||||
|
||||
<!-- allowing all matched text nodes -->
|
||||
<xsl:template match="text()">
|
||||
<xsl:value-of select="."/>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
||||
@@ -0,0 +1,130 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
* This file is part of the LibreOffice project.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* This file incorporates work covered by the following license notice:
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed
|
||||
* with this work for additional information regarding copyright
|
||||
* ownership. The ASF licenses this file to you under the Apache
|
||||
* License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
||||
-->
|
||||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml" xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:aml="http://schemas.microsoft.com/aml/2001/core" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" exclude-result-prefixes="office table style text draw svg dc config xlink meta oooc dom ooo chart math dr3d form script ooow draw">
|
||||
<xsl:template match="office:meta">
|
||||
<o:DocumentProperties>
|
||||
<o:Title>
|
||||
<xsl:value-of select="dc:title"/>
|
||||
</o:Title>
|
||||
<o:Subject>
|
||||
<xsl:value-of select="dc:subject"/>
|
||||
</o:Subject>
|
||||
<o:Keywords>
|
||||
<xsl:for-each select="meta:keywords/meta:keyword">
|
||||
<xsl:value-of select="."/>
|
||||
<xsl:if test="position()!=last()">, </xsl:if>
|
||||
</xsl:for-each>
|
||||
</o:Keywords>
|
||||
<o:Description>
|
||||
<xsl:value-of select="dc:description"/>
|
||||
</o:Description>
|
||||
<o:Category>
|
||||
<xsl:value-of select="meta:user-defined[@meta:name = 'Category']"/>
|
||||
</o:Category>
|
||||
<o:Author>
|
||||
<xsl:value-of select="meta:initial-creator"/>
|
||||
</o:Author>
|
||||
<o:LastAuthor>
|
||||
<xsl:value-of select="dc:creator"/>
|
||||
</o:LastAuthor>
|
||||
<o:Manager>
|
||||
<xsl:value-of select="meta:user-defined[@meta:name = 'Manager']"/>
|
||||
</o:Manager>
|
||||
<o:Company>
|
||||
<xsl:value-of select="meta:user-defined[@meta:name = 'Company']"/>
|
||||
</o:Company>
|
||||
<o:HyperlinkBase>
|
||||
<xsl:value-of select="meta:user-defined[@meta:name = 'HyperlinkBase']"/>
|
||||
</o:HyperlinkBase>
|
||||
<o:Revision>
|
||||
<xsl:value-of select="meta:editing-cycles"/>
|
||||
</o:Revision>
|
||||
<!-- PresentationFormat, Guid, AppName, Version -->
|
||||
<o:TotalTime>
|
||||
<xsl:if test="meta:editing-duration">
|
||||
<xsl:variable name="hours">
|
||||
<xsl:choose>
|
||||
<xsl:when test="contains(meta:editing-duration, 'H')">
|
||||
<xsl:value-of select="substring-before( substring-after( meta:editing-duration, 'PT'), 'H')"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>0</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="minutes">
|
||||
<xsl:choose>
|
||||
<xsl:when test="contains(meta:editing-duration, 'M') and contains(meta:editing-duration, 'H')">
|
||||
<xsl:value-of select="substring-before( substring-after( meta:editing-duration, 'H'), 'M')"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="contains(meta:editing-duration, 'M')">
|
||||
<xsl:value-of select="substring-before( substring-after( meta:editing-duration, 'PT'), 'M')"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>0</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<xsl:value-of select="$hours * 60 + $minutes"/>
|
||||
</xsl:if>
|
||||
</o:TotalTime>
|
||||
<o:LastPrinted>
|
||||
<xsl:if test="meta:print-date">
|
||||
<xsl:value-of select="concat( meta:print-date, 'Z')"/>
|
||||
</xsl:if>
|
||||
</o:LastPrinted>
|
||||
<o:Created>
|
||||
<xsl:if test="meta:creation-date">
|
||||
<xsl:value-of select="concat( meta:creation-date, 'Z')"/>
|
||||
</xsl:if>
|
||||
</o:Created>
|
||||
<o:LastSaved>
|
||||
<xsl:if test="dc:date">
|
||||
<xsl:value-of select="concat( dc:date, 'Z')"/>
|
||||
</xsl:if>
|
||||
</o:LastSaved>
|
||||
<o:Pages>
|
||||
<xsl:value-of select="meta:document-statistic/@meta:page-count"/>
|
||||
</o:Pages>
|
||||
<o:Words>
|
||||
<xsl:value-of select="meta:document-statistic/@meta:word-count"/>
|
||||
</o:Words>
|
||||
<o:Characters>
|
||||
<xsl:value-of select="meta:document-statistic/@meta:character-count"/>
|
||||
</o:Characters>
|
||||
<!-- CharactersWithSpaces, Bytes, Lines -->
|
||||
<o:Paragraphs>
|
||||
<xsl:value-of select="meta:document-statistic/@meta:paragraph-count"/>
|
||||
</o:Paragraphs>
|
||||
</o:DocumentProperties>
|
||||
<o:CustomDocumentProperties>
|
||||
<o:Editor dt:dt="string">
|
||||
<xsl:value-of select="meta:generator"/>
|
||||
</o:Editor>
|
||||
<o:Language dt:dt="string">
|
||||
<xsl:value-of select="dc:language"/>
|
||||
</o:Language>
|
||||
<xsl:for-each select="meta:user-defined">
|
||||
<!-- transfer strings to XML QName, necessary to convert several characters -->
|
||||
<!-- {} -->
|
||||
<xsl:variable name="foo">.,| ~`!@#$%^*()&<>+=[];:"/\?{}'</xsl:variable>
|
||||
<xsl:element name="{concat( 'o:', translate(@meta:name,string($foo),'_'))}">
|
||||
<xsl:attribute name="dt:dt">string</xsl:attribute>
|
||||
<xsl:value-of select="."/>
|
||||
</xsl:element>
|
||||
</xsl:for-each>
|
||||
</o:CustomDocumentProperties>
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>
|
||||
@@ -0,0 +1,832 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
* This file is part of the LibreOffice project.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* This file incorporates work covered by the following license notice:
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed
|
||||
* with this work for additional information regarding copyright
|
||||
* ownership. The ASF licenses this file to you under the Apache
|
||||
* License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
||||
-->
|
||||
<!--
|
||||
For further documentation and updates visit http://xml.openoffice.org/odf2xhtml
|
||||
-->
|
||||
<xsl:stylesheet version="1.0"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
|
||||
xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0"
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:dom="http://www.w3.org/2001/xml-events"
|
||||
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"
|
||||
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
|
||||
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
|
||||
xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"
|
||||
xmlns:math="http://www.w3.org/1998/Math/MathML"
|
||||
xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0"
|
||||
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
|
||||
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
|
||||
xmlns:ooo="http://openoffice.org/2004/office"
|
||||
xmlns:oooc="http://openoffice.org/2004/calc"
|
||||
xmlns:ooow="http://openoffice.org/2004/writer"
|
||||
xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"
|
||||
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
|
||||
xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
|
||||
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
|
||||
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
|
||||
xmlns:xforms="http://www.w3.org/2002/xforms"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:xt="http://www.jclark.com/xt"
|
||||
xmlns:common="http://exslt.org/common"
|
||||
xmlns:xalan="http://xml.apache.org/xalan"
|
||||
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">
|
||||
|
||||
|
||||
|
||||
<!-- ***************************************** -->
|
||||
<!-- *** Gathering office style properties *** -->
|
||||
<!-- ***************************************** -->
|
||||
|
||||
<!-- REASON FOR STYLESHEET:
|
||||
In the OpenOffice documents styles are represented by a hierarchy.
|
||||
(e.g. most styles are inherited from a default style).
|
||||
Many other languages (as XHTML/CSS) do not support inherited styles.
|
||||
The style inheritance have to be made flat/absolute for each style.
|
||||
|
||||
A further reason was, that the earlier style collection mechanism
|
||||
had problems with CSS inline, which do not inherit from XML office defaults
|
||||
nor font:family defaults as the style header does
|
||||
(cp. stylesheet 'style_collector.xsl' and the 'write-default-styles' template)
|
||||
|
||||
RESULT OF STYLESHEET:
|
||||
All styles will be returned in a variable containing styles with their inherited *:
|
||||
|
||||
<all-styles>
|
||||
<style style:family="foo" style:name="x1">
|
||||
<* fo:padding-left="0cm" fo:margin-right="0cm" />
|
||||
</style>
|
||||
<style style:family="muh" style:name="x2" >
|
||||
<* fo:padding-left="3cm" ... />
|
||||
</style>
|
||||
...
|
||||
|
||||
</all-styles>
|
||||
-->
|
||||
|
||||
|
||||
<xsl:template name="collect-global-odf-properties">
|
||||
<!-- to access the variable as a node-set by XPATH expressions, it is necessary to convert it
|
||||
from a result-tree-fragment (RTF) to a node set by a in a XSLT 1.0 non standardized function -->
|
||||
<xsl:variable name="globalDataRTF">
|
||||
<xsl:call-template name="collect-document-links-RTF" />
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="function-available('common:node-set')">
|
||||
<xsl:call-template name="collect-style-properties">
|
||||
<xsl:with-param name="globalData" select="common:node-set($globalDataRTF)" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="function-available('xalan:nodeset')">
|
||||
<xsl:call-template name="collect-style-properties">
|
||||
<xsl:with-param name="globalData" select="xalan:nodeset($globalDataRTF)" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="function-available('xt:node-set')">
|
||||
<xsl:call-template name="collect-style-properties">
|
||||
<xsl:with-param name="globalData" select="xt:node-set($globalDataRTF)" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:message terminate="yes">The required node-set function was not found!</xsl:message>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
|
||||
<xsl:template name="collect-style-properties">
|
||||
<xsl:param name="globalData" />
|
||||
|
||||
<!-- Add the input file references to the new collected style properties -->
|
||||
<xsl:variable name="globalDataRTF">
|
||||
<xsl:copy-of select="$globalData" />
|
||||
<xsl:call-template name="collect-style-properties-RTF">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="function-available('common:node-set')">
|
||||
<xsl:call-template name="map-odf-style-properties">
|
||||
<xsl:with-param name="globalData" select="common:node-set($globalDataRTF)" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="function-available('xalan:nodeset')">
|
||||
<xsl:call-template name="map-odf-style-properties">
|
||||
<xsl:with-param name="globalData" select="xalan:nodeset($globalDataRTF)" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="function-available('xt:node-set')">
|
||||
<xsl:call-template name="map-odf-style-properties">
|
||||
<xsl:with-param name="globalData" select="xt:node-set($globalDataRTF)" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:message terminate="yes">The required node-set function was not found!</xsl:message>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template name="collect-document-links-RTF">
|
||||
<!-- works for zipped office files, unzipped office files as for flat filter single office file format as well -->
|
||||
<xsl:variable name="documentLinksRTF">
|
||||
<xsl:choose>
|
||||
<xsl:when test="office:document-content">
|
||||
<xsl:element name="styles-file" namespace="">
|
||||
<xsl:copy-of select="document(concat($sourceBaseURL, 'styles.xml'), .)" />
|
||||
</xsl:element>
|
||||
<xsl:element name="meta-file" namespace="">
|
||||
<xsl:copy-of select="document(concat($sourceBaseURL, 'meta.xml'), .)" />
|
||||
</xsl:element>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:element name="styles-file" namespace="">
|
||||
<xsl:copy-of select="/" />
|
||||
</xsl:element>
|
||||
<xsl:element name="meta-file" namespace="">
|
||||
<xsl:copy-of select="/" />
|
||||
</xsl:element>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="function-available('common:node-set')">
|
||||
<xsl:call-template name="collect-document-links">
|
||||
<xsl:with-param name="documentLinks" select="common:node-set($documentLinksRTF)" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="function-available('xalan:nodeset')">
|
||||
<xsl:call-template name="collect-document-links">
|
||||
<xsl:with-param name="documentLinks" select="xalan:nodeset($documentLinksRTF)" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="function-available('xt:node-set')">
|
||||
<xsl:call-template name="collect-document-links">
|
||||
<xsl:with-param name="documentLinks" select="xt:node-set($documentLinksRTF)" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:message terminate="yes">The required node-set function was not found!</xsl:message>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template name="collect-document-links">
|
||||
<xsl:param name="documentLinks" />
|
||||
|
||||
<xsl:element name="styles-file" namespace="">
|
||||
<xsl:copy-of select="$documentLinks/styles-file/*" />
|
||||
</xsl:element>
|
||||
|
||||
<xsl:element name="meta-file" namespace="">
|
||||
<xsl:copy-of select="$documentLinks/meta-file/*" />
|
||||
</xsl:element>
|
||||
|
||||
<xsl:copy-of select="$documentLinks/styles-file/*/office:styles" />
|
||||
<xsl:copy-of select="$documentLinks/styles-file/*/office:font-face-decls" />
|
||||
|
||||
<!-- office:automatic-styles may be contained in two files (i.e. content.xml and styles.xml).
|
||||
Wild card necessary as top level element differs from flat office files ("SampleName.fsxw") -->
|
||||
<xsl:copy-of select="/*/office:automatic-styles" />
|
||||
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template name="collect-style-properties-RTF">
|
||||
<xsl:param name="globalData" />
|
||||
|
||||
<!--** DEFAULT STYLES: First adding some office defaults unwritten in XML -->
|
||||
<xsl:variable name="defaultOfficeStyle-RTF">
|
||||
<xsl:element name="style" namespace="">
|
||||
<xsl:element name="style:properties" />
|
||||
</xsl:element>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="function-available('common:node-set')">
|
||||
<xsl:call-template name="collect-properties-defaults">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="defaultOfficeStyle" select="common:node-set($defaultOfficeStyle-RTF)" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="function-available('xalan:nodeset')">
|
||||
<xsl:call-template name="collect-properties-defaults">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="defaultOfficeStyle" select="xalan:nodeset($defaultOfficeStyle-RTF)" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="function-available('xt:node-set')">
|
||||
<xsl:call-template name="collect-properties-defaults">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="defaultOfficeStyle" select="xt:node-set($defaultOfficeStyle-RTF)" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:message terminate="yes">ERROR: Function not found: 'Nodeset'</xsl:message>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template name="collect-properties-defaults">
|
||||
<xsl:param name="globalData" />
|
||||
<xsl:param name="defaultOfficeStyle" />
|
||||
|
||||
<!--** DEFAULT STYLES: Adding the default styles of a style:family, by adding each office:styles/style:default-style element **-->
|
||||
<xsl:variable name="defaultFamilyStyles-RTF">
|
||||
<xsl:for-each select="$globalData/office:styles/style:default-style">
|
||||
<xsl:element name="style" namespace="">
|
||||
<xsl:copy-of select="@style:family" />
|
||||
<xsl:call-template name="create-inherited-style-properties">
|
||||
<xsl:with-param name="inheritedStyleProperties" select="$defaultOfficeStyle/style/*" />
|
||||
</xsl:call-template>
|
||||
</xsl:element>
|
||||
</xsl:for-each>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="function-available('common:node-set')">
|
||||
<xsl:call-template name="collect-properties">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="defaultOfficeStyle" select="$defaultOfficeStyle" />
|
||||
<xsl:with-param name="defaultFamilyStyles" select="common:node-set($defaultFamilyStyles-RTF)" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="function-available('xalan:nodeset')">
|
||||
<xsl:call-template name="collect-properties">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="defaultOfficeStyle" select="$defaultOfficeStyle" />
|
||||
<xsl:with-param name="defaultFamilyStyles" select="xalan:nodeset($defaultFamilyStyles-RTF)" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="function-available('xt:node-set')">
|
||||
<xsl:call-template name="collect-properties">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="defaultOfficeStyle" select="$defaultOfficeStyle" />
|
||||
<xsl:with-param name="defaultFamilyStyles" select="xt:node-set($defaultFamilyStyles-RTF)" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:message terminate="yes">ERROR: Function not found: nodeset</xsl:message>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template name="collect-properties">
|
||||
<xsl:param name="globalData" />
|
||||
<xsl:param name="defaultOfficeStyle" />
|
||||
<xsl:param name="defaultFamilyStyles" />
|
||||
|
||||
<!--** traversee all style trees - branch after branch - collecting style properties **-->
|
||||
<xsl:element name="all-doc-styles" namespace="">
|
||||
|
||||
<!-- Background Information:
|
||||
|
||||
There are two different types of styles in the Office:
|
||||
1) The office:styles from the user pre-defined style templates
|
||||
2) The automatic:styles, which are created whenever a user uses explicit style formatting.
|
||||
|
||||
The office:styles only have parent styles in the office:styles,
|
||||
but automatic:styles may inherit from both office:styles and themself.
|
||||
-->
|
||||
|
||||
<!--** traversee all office:styles trees beginning with the top-level styles **-->
|
||||
<xsl:for-each select="$globalData/office:styles/style:style[not(@style:parent-style-name)]">
|
||||
<!-- Looking for parents from style:family
|
||||
<xsl:for-each select="$globalData/office:styles/style:style[@style:family=current()/@style:family][not(@style:parent-style-name)]"> -->
|
||||
<xsl:choose>
|
||||
<xsl:when test="$defaultFamilyStyles/style[@style:family=current()/@style:family]">
|
||||
<xsl:call-template name="inherit-style-for-self-and-children">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="inheritedStyleProperties" select="$defaultFamilyStyles/style[@style:family=current()/@style:family]/*" />
|
||||
<xsl:with-param name="searchOnlyInAutomaticStyles" select="false()" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:call-template name="inherit-style-for-self-and-children">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="inheritedStyleProperties" select="$defaultOfficeStyle/style/*" />
|
||||
<xsl:with-param name="searchOnlyInAutomaticStyles" select="false()" />
|
||||
</xsl:call-template>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<!--** creates a style element with style:name and style:family attribute and
|
||||
an element representing the absolute style properties style:property ** -->
|
||||
</xsl:for-each>
|
||||
|
||||
<!--** traversee all office:automatic-styles trees beginning with the top-level styles **-->
|
||||
<xsl:for-each select="$globalData/office:automatic-styles/style:style[not(@style:parent-style-name)]">
|
||||
<!--** creates a style element with style:name and style:family attribute and
|
||||
an element representing the absolute style properties style:property ** -->
|
||||
<xsl:choose>
|
||||
<xsl:when test="$defaultFamilyStyles/style[@style:family=current()/@style:family]">
|
||||
<xsl:call-template name="inherit-style-for-self-and-children">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="inheritedStyleProperties" select="$defaultFamilyStyles/style[@style:family=current()/@style:family]/*" />
|
||||
<xsl:with-param name="searchOnlyInAutomaticStyles" select="true()" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:call-template name="inherit-style-for-self-and-children">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="inheritedStyleProperties" select="$defaultOfficeStyle/style/*" />
|
||||
<xsl:with-param name="searchOnlyInAutomaticStyles" select="true()" />
|
||||
</xsl:call-template>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
|
||||
</xsl:for-each>
|
||||
|
||||
</xsl:element>
|
||||
<!-- debug output in case only styles should be given out (regression test) -->
|
||||
<xsl:if test="$onlyStyleOutputEnabled">
|
||||
<xsl:element name="defaultOfficeStyle" namespace="">
|
||||
<xsl:copy-of select="$defaultOfficeStyle" />
|
||||
</xsl:element>
|
||||
<xsl:element name="defaultFamilyStyles" namespace="">
|
||||
<xsl:copy-of select="$defaultFamilyStyles" />
|
||||
</xsl:element>
|
||||
</xsl:if>
|
||||
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template name="inherit-style-for-self-and-children">
|
||||
<xsl:param name="globalData" />
|
||||
<xsl:param name="inheritedStyleProperties" />
|
||||
<xsl:param name="searchOnlyInAutomaticStyles" />
|
||||
|
||||
<!--** create an absolute style by inheriting properties from the given parent properties **-->
|
||||
<xsl:variable name="newStyleProperties-RTF">
|
||||
<xsl:call-template name="create-inherited-style-properties">
|
||||
<xsl:with-param name="inheritedStyleProperties" select="$inheritedStyleProperties" />
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:choose>
|
||||
<xsl:when test="function-available('common:node-set')">
|
||||
<xsl:variable name="newStyleProperties" select="common:node-set($newStyleProperties-RTF)" />
|
||||
|
||||
<xsl:element name="style" namespace="">
|
||||
<xsl:copy-of select="@style:family" />
|
||||
<xsl:copy-of select="@style:name" />
|
||||
<xsl:copy-of select="$newStyleProperties" />
|
||||
</xsl:element>
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="$searchOnlyInAutomaticStyles">
|
||||
<xsl:call-template name="get-children">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="searchOnlyInAutomaticStyles" select="true()" />
|
||||
<xsl:with-param name="inheritedStyleProperties" select="$newStyleProperties/*" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<!--** for all automatic-children of the current office:styles **-->
|
||||
<xsl:call-template name="get-children">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="searchOnlyInAutomaticStyles" select="false()" />
|
||||
<xsl:with-param name="inheritedStyleProperties" select="$newStyleProperties/*" />
|
||||
</xsl:call-template>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:when test="function-available('xalan:nodeset')">
|
||||
<xsl:variable name="newStyleProperties" select="xalan:nodeset($newStyleProperties-RTF)" />
|
||||
|
||||
<xsl:element name="style" namespace="">
|
||||
<xsl:copy-of select="@style:family" />
|
||||
<xsl:copy-of select="@style:name" />
|
||||
<xsl:copy-of select="$newStyleProperties" />
|
||||
</xsl:element>
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="$searchOnlyInAutomaticStyles">
|
||||
<xsl:call-template name="get-children">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="searchOnlyInAutomaticStyles" select="true()" />
|
||||
<xsl:with-param name="inheritedStyleProperties" select="$newStyleProperties/*" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<!--** for all automatic-children of the current office:styles **-->
|
||||
<xsl:call-template name="get-children">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="searchOnlyInAutomaticStyles" select="false()" />
|
||||
<xsl:with-param name="inheritedStyleProperties" select="$newStyleProperties/*" />
|
||||
</xsl:call-template>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:when test="function-available('xt:node-set')">
|
||||
<xsl:variable name="newStyleProperties" select="xt:node-set($newStyleProperties-RTF)" />
|
||||
|
||||
<xsl:element name="style" namespace="">
|
||||
<xsl:copy-of select="@style:family" />
|
||||
<xsl:copy-of select="@style:name" />
|
||||
<xsl:copy-of select="$newStyleProperties" />
|
||||
</xsl:element>
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="$searchOnlyInAutomaticStyles">
|
||||
<xsl:call-template name="get-children">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="searchOnlyInAutomaticStyles" select="true()" />
|
||||
<xsl:with-param name="inheritedStyleProperties" select="$newStyleProperties/*" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<!--** for all automatic-children of the current office:styles **-->
|
||||
<xsl:call-template name="get-children">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="searchOnlyInAutomaticStyles" select="false()" />
|
||||
<xsl:with-param name="inheritedStyleProperties" select="$newStyleProperties/*" />
|
||||
</xsl:call-template>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:message terminate="yes">ERROR: Function not found: nodeset</xsl:message>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template name="get-children">
|
||||
<xsl:param name="globalData" />
|
||||
<xsl:param name="searchOnlyInAutomaticStyles" />
|
||||
<xsl:param name="inheritedStyleProperties" select="*" />
|
||||
|
||||
<!-- QUESTION: Parent style is only unique by name and family, but what about cross family inheritance? -->
|
||||
<!-- For each child style (that is every style which has the given parentStyleName as style:parent-style-name and the same style:family -->
|
||||
<xsl:variable name="parentStyleFamily" select="@style:family" />
|
||||
<xsl:variable name="parentStyleName" select="@style:name" />
|
||||
<xsl:if test="not($searchOnlyInAutomaticStyles)">
|
||||
<xsl:for-each select="$globalData/office:styles/style:style[@style:family=$parentStyleFamily and @style:parent-style-name=$parentStyleName]">
|
||||
<xsl:call-template name="inherit-style-for-self-and-children">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="inheritedStyleProperties" select="$inheritedStyleProperties" />
|
||||
<xsl:with-param name="searchOnlyInAutomaticStyles" select="$searchOnlyInAutomaticStyles" />
|
||||
</xsl:call-template>
|
||||
</xsl:for-each>
|
||||
</xsl:if>
|
||||
<xsl:for-each select="$globalData/office:automatic-styles/style:style[@style:family=$parentStyleFamily and @style:parent-style-name=$parentStyleName]">
|
||||
<xsl:call-template name="inherit-style-for-self-and-children">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="inheritedStyleProperties" select="$inheritedStyleProperties" />
|
||||
<xsl:with-param name="searchOnlyInAutomaticStyles" select="$searchOnlyInAutomaticStyles" />
|
||||
</xsl:call-template>
|
||||
</xsl:for-each>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template name="create-inherited-style-properties">
|
||||
<xsl:param name="inheritedStyleProperties" />
|
||||
|
||||
<xsl:element name="style:properties">
|
||||
<!-- Writing all inherited style properties -->
|
||||
<xsl:for-each select="$inheritedStyleProperties/@*">
|
||||
<xsl:sort select="name()" />
|
||||
<xsl:copy-of select="." />
|
||||
</xsl:for-each>
|
||||
|
||||
<!-- split border into border parts for better activation-check on style:joint-border feature -->
|
||||
<xsl:if test="*/@fo:border">
|
||||
<xsl:attribute name="fo:border-top"><xsl:value-of select="*/@fo:border"/></xsl:attribute>
|
||||
<xsl:attribute name="fo:border-left"><xsl:value-of select="*/@fo:border"/></xsl:attribute>
|
||||
<xsl:attribute name="fo:border-bottom"><xsl:value-of select="*/@fo:border"/></xsl:attribute>
|
||||
<xsl:attribute name="fo:border-right"><xsl:value-of select="*/@fo:border"/></xsl:attribute>
|
||||
</xsl:if>
|
||||
|
||||
<!--All current attributes will override already inserted attributes of the same name
|
||||
XSLT Spec: "Adding an attribute to an element replaces any existing attribute of that element with the same expanded-name." -->
|
||||
<xsl:for-each select="*/@*[name() != 'style:font-size-rel'][name() != 'fo:border']">
|
||||
<xsl:copy-of select="." />
|
||||
</xsl:for-each>
|
||||
|
||||
<xsl:if test="*/@style:font-size-rel">
|
||||
<!--
|
||||
The intheritedStyleProperties should include an absolute Font Size, but
|
||||
<style:properties
|
||||
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
|
||||
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
|
||||
style:font-name="Courier New"
|
||||
fo:language="en"
|
||||
fo:country="US"
|
||||
style:font-name-asian=Courier New"
|
||||
style:font-name-complex="Courier New"/>
|
||||
-->
|
||||
<xsl:variable name="fontSizeAbsolute">
|
||||
<xsl:call-template name="convert2pt">
|
||||
<xsl:with-param name="value" select="$inheritedStyleProperties/@fo:font-size" />
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:variable name="fontSizeRelative">
|
||||
<xsl:call-template name="convert2pt">
|
||||
<xsl:with-param name="value" select="*/@style:font-size-rel" />
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:attribute name="fo:font-size">
|
||||
<xsl:value-of select="$fontSizeAbsolute + $fontSizeRelative"/>
|
||||
<xsl:text>pt</xsl:text>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
|
||||
<!-- providing tabulator indentation -->
|
||||
<xsl:copy-of select="$inheritedStyleProperties/style:tab-stops"/>
|
||||
<xsl:copy-of select="*/style:tab-stops"/>
|
||||
</xsl:element>
|
||||
</xsl:template>
|
||||
|
||||
<!-- debugging & testing purpose -->
|
||||
<xsl:template name="write-collected-styles">
|
||||
<xsl:param name="globalData" />
|
||||
|
||||
<xsl:message><all-doc-styles></xsl:message>
|
||||
<xsl:for-each select="$globalData/all-doc-styles/style">
|
||||
<xsl:message><style</xsl:message>
|
||||
<xsl:message>style:family="<xsl:value-of select="current()/@style:family" />"></xsl:message>
|
||||
<xsl:message>style:name="<xsl:value-of select="current()/@style:name" />" </xsl:message>
|
||||
<xsl:message> <*</xsl:message>
|
||||
<xsl:for-each select="*/@*">
|
||||
<xsl:message>
|
||||
<xsl:text></xsl:text>
|
||||
<xsl:value-of select="name()" />="<xsl:value-of select="." />"</xsl:message>
|
||||
</xsl:for-each>
|
||||
<xsl:message>/></xsl:message>
|
||||
<xsl:message></style></xsl:message>
|
||||
</xsl:for-each>
|
||||
<xsl:message></all-doc-styles></xsl:message>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="map-odf-style-properties">
|
||||
<xsl:param name="globalData" />
|
||||
|
||||
<xsl:choose>
|
||||
<!--+++++ DEBUG STYLE OUTPUT FOR REGRESSION TEST +++++-->
|
||||
<!-- create styles file from the style variable (testing switch) -->
|
||||
<xsl:when test="$onlyStyleOutputEnabled">
|
||||
|
||||
<xsl:element name="debug-output" namespace="">
|
||||
<xsl:copy-of select="$globalData" />
|
||||
<xsl:call-template name="map-odf-properties">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
</xsl:call-template>
|
||||
</xsl:element>
|
||||
</xsl:when>
|
||||
|
||||
<!-- create XHTML file -->
|
||||
<xsl:otherwise>
|
||||
<!-- to access the variable like a node-set it is necessary to convert it
|
||||
from a result-tree-fragment (RTF) to a node set using the James Clark extension -->
|
||||
<xsl:variable name="globalDataRTF">
|
||||
<!-- raw properties still needed for table width attribute creation -->
|
||||
<xsl:copy-of select="$globalData" />
|
||||
<xsl:call-template name="map-odf-properties">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="function-available('common:node-set')">
|
||||
<xsl:call-template name="start-main">
|
||||
<xsl:with-param name="globalData" select="common:node-set($globalDataRTF)" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="function-available('xalan:nodeset')">
|
||||
<xsl:call-template name="start-main">
|
||||
<xsl:with-param name="globalData" select="xalan:nodeset($globalDataRTF)" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="function-available('xt:node-set')">
|
||||
<xsl:call-template name="start-main">
|
||||
<xsl:with-param name="globalData" select="xt:node-set($globalDataRTF)" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:message terminate="yes">ERROR: Function not found: nodeset</xsl:message>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<!-- REASON FOR TEMPLATE:
|
||||
The OpenOffice style properties gathered in the variable 'globalData' have to be mapped to the CSS style format
|
||||
-->
|
||||
<xsl:template name="map-odf-properties">
|
||||
<xsl:param name="globalData" />
|
||||
<xsl:element name="all-styles" namespace="">
|
||||
<xsl:for-each select="$globalData/all-doc-styles/style">
|
||||
<xsl:sort select="@style:family" />
|
||||
<xsl:sort select="@style:name" />
|
||||
|
||||
<xsl:call-template name="writeUsedStyles">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="style" select="."/>
|
||||
</xsl:call-template>
|
||||
</xsl:for-each>
|
||||
</xsl:element>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:key name="elementUsingStyle" match="*" use="@text:style-name | @draw:style-name | @draw:text-style-name | @table:style-name | @table:default-cell-style-name"/>
|
||||
<xsl:key name="listLabelStyleInStyles" match="/*/office:styles/text:list-style/* |
|
||||
/*/office:styles/style:graphic-properties/text:list-style/*" use="@text:style-name"/>
|
||||
|
||||
<xsl:key name="listLabelStyleInContent" match="/*/office:automatic-styles/text:list-style/* | /*/office:automatic-styles/style:graphic-properties/text:list-style/*" use="@text:style-name"/>
|
||||
|
||||
|
||||
<xsl:variable name="documentRoot" select="/" />
|
||||
<xsl:template name="writeUsedStyles">
|
||||
<xsl:param name="globalData" />
|
||||
<xsl:param name="style"/>
|
||||
|
||||
<!-- for-each changes the key environment from the previously globalData back to the document root -->
|
||||
<xsl:for-each select="$documentRoot">
|
||||
<!-- only styles, which are used in the content are written as CSS styles -->
|
||||
<xsl:choose>
|
||||
<xsl:when test="key('elementUsingStyle', $style/@style:name)/@* or key('listLabelStyleInContent', $style/@style:name)/@*">
|
||||
<xsl:call-template name="writeUsedStyles2">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="style" select="$style" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:choose>
|
||||
<xsl:when test="not(office:document-content)">
|
||||
<xsl:if test="key('listLabelStyleInStyles', $style/@style:name)/@* or /*/office:styles/text:notes-configuration[@text:citation-style-name = $style/@style:name or /*/office:styles/@text:citation-body-style-name=$style/@style:name]">
|
||||
<!-- if there are consecutive paragraphs with borders (OR background AND margin ), only the first and the last have the top/bottom border
|
||||
unless style:join-border="false" -->
|
||||
<xsl:call-template name="writeUsedStyles2">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="style" select="$style" />
|
||||
</xsl:call-template>
|
||||
</xsl:if>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:for-each select="document($stylesFileURL)">
|
||||
<xsl:if test="key('listLabelStyleInStyles', $style/@style:name)/@* or /*/office:styles/text:notes-configuration[@text:citation-style-name = $style/@style:name or /*/office:styles/@text:citation-body-style-name=$style/@style:name]">
|
||||
<!-- if there are consecutive paragraphs with borders (OR background AND margin ), only the first and the last have the top/bottom border
|
||||
unless style:join-border="false" -->
|
||||
<xsl:call-template name="writeUsedStyles2">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="style" select="$style" />
|
||||
</xsl:call-template>
|
||||
</xsl:if>
|
||||
</xsl:for-each>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:for-each>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="writeUsedStyles2">
|
||||
<xsl:param name="globalData" />
|
||||
<xsl:param name="style"/>
|
||||
<!-- activation-check on style:joint-border feature -->
|
||||
<xsl:choose>
|
||||
<xsl:when test="
|
||||
$style/@style:family='paragraph'
|
||||
and
|
||||
(
|
||||
$style/*/@fo:border-top
|
||||
or
|
||||
$style/*/@fo:border-bottom
|
||||
)
|
||||
and
|
||||
(
|
||||
not($style/*/@fo:border-top='none' and
|
||||
$style/*/@fo:border-left='none' and
|
||||
$style/*/@fo:border-right='none' and
|
||||
$style/*/@fo:border-bottom='none')
|
||||
)
|
||||
and
|
||||
(
|
||||
not($style/*/@style:join-border)
|
||||
or $style/*/@style:join-border = 'true'
|
||||
)">
|
||||
<xsl:element name="style" namespace="">
|
||||
<xsl:copy-of select="$style/@style:family" />
|
||||
<xsl:attribute name="style:name"><xsl:value-of select="concat($style/@style:name, '_borderStart')" /></xsl:attribute>
|
||||
<xsl:element name="final-properties" namespace="">
|
||||
<xsl:apply-templates select="$style/*/@*[not(name() = 'fo:border-bottom')][not(name() = 'fo:padding-bottom')][not(name() = 'fo:margin-bottom')][not(name() = 'fo:margin')]">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
</xsl:apply-templates>
|
||||
<xsl:apply-templates mode="paragraphMerge" select="$style/*/@*[name() = 'fo:margin-bottom' or name() = 'fo:margin']">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
</xsl:apply-templates>
|
||||
<xsl:text> border-bottom-style:none; </xsl:text>
|
||||
</xsl:element>
|
||||
</xsl:element>
|
||||
<xsl:element name="style" namespace="">
|
||||
<xsl:copy-of select="$style/@style:family" />
|
||||
<xsl:attribute name="style:name"><xsl:value-of select="concat($style/@style:name, '_borderSides')" /></xsl:attribute>
|
||||
<xsl:element name="final-properties" namespace="">
|
||||
<xsl:apply-templates select="$style/*/@*[not(name() = 'fo:border-top') and not(name() = 'fo:border-bottom')][not(name() = 'fo:padding-top') and not(name() = 'fo:padding-bottom')][not(name() = 'fo:margin-top') and not(name() = 'fo:margin-bottom')][not(name() = 'fo:margin')]">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
</xsl:apply-templates>
|
||||
<xsl:apply-templates mode="paragraphMerge" select="$style/*/@*[name() = 'fo:margin-top' or name() = 'fo:margin-bottom' or name() = 'fo:margin']">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
</xsl:apply-templates>
|
||||
<xsl:text> border-top-style:none; border-bottom-style:none; </xsl:text>
|
||||
</xsl:element>
|
||||
</xsl:element>
|
||||
<xsl:element name="style" namespace="">
|
||||
<xsl:copy-of select="$style/@style:family" />
|
||||
<xsl:attribute name="style:name"><xsl:value-of select="concat($style/@style:name, '_borderEnd')" /></xsl:attribute>
|
||||
<xsl:element name="final-properties" namespace="">
|
||||
<xsl:apply-templates select="$style/*/@*[not(name() = 'fo:border-top')][not(name() = 'fo:padding-top')][not(name() = 'fo:margin-top')][not(name() = 'fo:margin')]">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
</xsl:apply-templates>
|
||||
<xsl:apply-templates mode="paragraphMerge" select="$style/*/@*[name() = 'fo:margin-top' or name() = 'fo:margin']">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
</xsl:apply-templates>
|
||||
<xsl:text> border-top-style:none;</xsl:text>
|
||||
</xsl:element>
|
||||
</xsl:element>
|
||||
<xsl:element name="style" namespace="">
|
||||
<xsl:copy-of select="$style/@style:family" />
|
||||
<xsl:copy-of select="$style/@style:name" />
|
||||
<!-- the original name bears the trigger: 'mergedBorder' flag-->
|
||||
<xsl:attribute name="mergedBorders"><xsl:value-of select="true()" /></xsl:attribute>
|
||||
<xsl:element name="final-properties" namespace="">
|
||||
<xsl:apply-templates select="$style/*/@*">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
</xsl:apply-templates>
|
||||
</xsl:element>
|
||||
</xsl:element>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:choose>
|
||||
<xsl:when test="not(key('listLabelStyleInStyles', $style/@style:name)/@*)">
|
||||
<xsl:element name="style" namespace="">
|
||||
<xsl:copy-of select="$style/@style:family" />
|
||||
<xsl:copy-of select="$style/@style:name" />
|
||||
<xsl:element name="final-properties" namespace="">
|
||||
<xsl:apply-templates select="$style/*/@*">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
</xsl:apply-templates>
|
||||
</xsl:element>
|
||||
</xsl:element>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:element name="style" namespace="">
|
||||
<xsl:attribute name="style:family">none</xsl:attribute>
|
||||
<xsl:attribute name="style:name"><xsl:value-of select="$style/@style:name"/></xsl:attribute>
|
||||
<xsl:element name="final-properties" namespace="">
|
||||
<xsl:apply-templates select="$style/*/@*">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
</xsl:apply-templates>
|
||||
</xsl:element>
|
||||
</xsl:element>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
<!-- workaround AOOO#119401 suspicious property fo:margin="100%" in paragraph style -->
|
||||
<xsl:template match="@fo:margin[string(.) = '100%']" mode="paragraphMerge"/>
|
||||
|
||||
<xsl:template mode="paragraphMerge" match="@fo:margin | @fo:margin-top | @fo:margin-bottom | @fo:margin-left | @fo:margin-right">
|
||||
<xsl:text>padding</xsl:text>
|
||||
<xsl:value-of select="substring-after(name(), 'fo:margin')"/>
|
||||
<xsl:text>:</xsl:text>
|
||||
<!-- Map once erroneously used inch shortage 'inch' to CSS shortage 'in' -->
|
||||
<xsl:choose>
|
||||
<xsl:when test="contains(., 'inch')">
|
||||
<xsl:value-of select="substring-before(.,'ch')"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="."/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:text>; </xsl:text>
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>
|
||||
@@ -0,0 +1,380 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
* This file is part of the LibreOffice project.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* This file incorporates work covered by the following license notice:
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed
|
||||
* with this work for additional information regarding copyright
|
||||
* ownership. The ASF licenses this file to you under the Apache
|
||||
* License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
||||
-->
|
||||
<!--
|
||||
For further documentation and updates visit http://xml.openoffice.org/odf2xhtml
|
||||
-->
|
||||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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">
|
||||
|
||||
|
||||
<!-- *** Properties with a 'fo:' prefix *** -->
|
||||
<xsl:template match="@fo:background-color">
|
||||
<xsl:text>background-color:</xsl:text>
|
||||
<xsl:value-of select="."/>
|
||||
<xsl:text>; </xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="@fo:border | @fo:border-top | @fo:border-bottom | @fo:border-left | @fo:border-right">
|
||||
<xsl:variable name="borderType" select="substring-after(name(), ':')"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test=". = 'none'">
|
||||
<xsl:value-of select="$borderType"/>
|
||||
<xsl:text>-style:none; </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:variable name="borderWidth" select="substring-before(., ' ')"/>
|
||||
<xsl:variable name="borderStyle" select="substring-before(substring-after(., ' '), ' ')"/>
|
||||
<xsl:variable name="borderColor" select="substring-after(substring-after(., ' '), ' ')"/>
|
||||
|
||||
<!-- More information at template 'round-up-border-width' -->
|
||||
<xsl:variable name="borderWidthFixed">
|
||||
<xsl:call-template name="round-up-border-width">
|
||||
<xsl:with-param name="borderWidth" select="$borderWidth"/>
|
||||
<xsl:with-param name="multiplier">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$borderStyle = 'double'">3</xsl:when>
|
||||
<xsl:otherwise>1</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:with-param>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:value-of select="$borderType"/>
|
||||
<xsl:text>-width:</xsl:text>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$borderWidth = '0.05pt'">thin</xsl:when>
|
||||
<xsl:otherwise><xsl:value-of select="$borderWidthFixed"/></xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:text>; </xsl:text>
|
||||
<xsl:value-of select="$borderType"/>
|
||||
<xsl:text>-style:</xsl:text>
|
||||
<xsl:value-of select="$borderStyle"/>
|
||||
<xsl:text>; </xsl:text>
|
||||
<xsl:value-of select="$borderType"/>
|
||||
<xsl:text>-color:</xsl:text>
|
||||
<xsl:value-of select="$borderColor"/>
|
||||
<xsl:text>; </xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<!-- NOTE: Still there have to be placed a <br clear='all' /> to disable the flow!!!!-->
|
||||
<xsl:template match="@fo:clear">
|
||||
<xsl:text>clear:both; </xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<!-- text-shadow is a CSS2 feature and yet not common used in user-agents -->
|
||||
<xsl:template match="@fo:color |@fo:font-size |@fo:font-style |@fo:font-weight |@fo:text-indent |@fo:text-shadow |@text:display">
|
||||
<xsl:value-of select="substring-after(name(), ':')"/>
|
||||
<xsl:text>:</xsl:text>
|
||||
<xsl:value-of select="."/>
|
||||
<xsl:text>; </xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<!-- text-shadow is a CSS2 feature and yet not common used in user-agents -->
|
||||
<xsl:template match="@svg:font-family">
|
||||
<xsl:value-of select="substring-after(name(), ':')"/>
|
||||
<xsl:text>:"</xsl:text>
|
||||
<xsl:value-of select="."/>
|
||||
<xsl:text>"; </xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<!-- workaround AOOO#119401 suspicious property fo:margin="100%" in paragraph style -->
|
||||
<xsl:template match="@fo:margin[string(.) = '100%']"/>
|
||||
|
||||
<!-- Maps fo:margin as well fo:margin-top, fo:margin-bottom, fo:padding-left, fo:margin-right -->
|
||||
<!-- Maps fo:padding as well fo:padding-top, fo:padding-bottom, fo:padding-left, fo:padding-right -->
|
||||
<xsl:template match="@fo:letter-spacing | @fo:line-height | @fo:width |@fo:margin | @fo:margin-top | @fo:margin-bottom | @fo:margin-left | @fo:margin-right | @fo:padding | @fo:padding-top | @fo:padding-bottom | @fo:padding-left | @fo:padding-right">
|
||||
<xsl:value-of select="local-name(.)"/>
|
||||
<xsl:text>:</xsl:text>
|
||||
<!-- Map once erroneously used inch shortage 'inch' to CSS shortage 'in' -->
|
||||
<xsl:choose>
|
||||
<xsl:when test="contains(., 'inch')">
|
||||
<xsl:value-of select="substring-before(.,'ch')"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="."/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:text>; </xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="@fo:text-align">
|
||||
<!-- 'important' is necessary as table cell value alignment is decided by runtime over the valuetype
|
||||
Otherwise a table cell style-class would always be outnumbered by the run-time alignment value -->
|
||||
<xsl:choose>
|
||||
<xsl:when test="contains(., 'start')">
|
||||
<xsl:choose>
|
||||
<xsl:when test="parent::*/@style:writing-mode and contains(parent::*/@style:writing-mode, 'rl')">
|
||||
<xsl:text>text-align:right ! important; </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:text>text-align:left ! important; </xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:when test="contains(., 'end')">
|
||||
<xsl:choose>
|
||||
<xsl:when test="parent::*/@style:writing-mode and contains(parent::*/@style:writing-mode, 'rl')">
|
||||
<xsl:text>text-align:right ! important;</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:text>text-align:left ! important; </xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:text>text-align:</xsl:text>
|
||||
<xsl:value-of select="."/>
|
||||
<xsl:text> ! important; </xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="@style:vertical-align">
|
||||
<xsl:choose>
|
||||
<xsl:when test="contains(., 'bottom')">
|
||||
<xsl:text>vertical-align:bottom; </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="contains(., 'middle')">
|
||||
<xsl:text>vertical-align:middle; </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:text>vertical-align:top; </xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<!-- *** Properties with a 'style:' prefix *** -->
|
||||
<!-- NOTE: Can 'inside' | 'from-inside' better be handled:
|
||||
<!ATTLIST * style:horizontal-pos (from-left|left|center|right|from-inside|inside|outside)#IMPLIED>-->
|
||||
<xsl:template match="@style:horizontal-pos">
|
||||
<xsl:choose>
|
||||
<xsl:when test=".='left'">
|
||||
<xsl:text>text-align:left; </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test=". = 'right'">
|
||||
<xsl:text>text-align:right; </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test=".='center'">
|
||||
<xsl:text>text-align:center; </xsl:text>
|
||||
</xsl:when>
|
||||
<!-- NOTE: currently other values are not used.
|
||||
If the property value is from-left or from-inside,
|
||||
the svg:x attribute associated with the frame element specifies
|
||||
the horizontal position of the frame.
|
||||
Otherwise the svg:x attribute is ignored for text documents.
|
||||
-->
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="@style:column-width">
|
||||
<xsl:text>width:</xsl:text>
|
||||
<xsl:choose>
|
||||
<!-- changing the distance measure: inch to in -->
|
||||
<xsl:when test="contains(., 'inch')">
|
||||
<xsl:value-of select="substring-before(.,'ch')"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="."/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:text>; </xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="@style:text-underline-style">
|
||||
<xsl:text>text-decoration:</xsl:text>
|
||||
<xsl:choose>
|
||||
<!-- changing the distance measure: inch to in -->
|
||||
<xsl:when test=".='none'">
|
||||
<xsl:text>none ! important</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:text>underline</xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:text>; </xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="@style:font-name">
|
||||
<xsl:param name="globalData" />
|
||||
|
||||
<xsl:text>font-family:</xsl:text>
|
||||
<xsl:variable name="content" select="."/>
|
||||
<xsl:variable name="fontName" select="$globalData/office:font-face-decls/style:font-face[@style:name=$content]/@svg:font-family" />
|
||||
<xsl:value-of select="$fontName"/>
|
||||
<xsl:text>; </xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="@style:row-height">
|
||||
<xsl:text>height:</xsl:text>
|
||||
<xsl:choose>
|
||||
<!-- changing the distance measure: inch to in -->
|
||||
<xsl:when test="contains(., 'inch')">
|
||||
<xsl:value-of select="substring-before(.,'ch')"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="."/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:text>; </xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="@svg:strikethrough-position">
|
||||
<xsl:if test="not(.='none')">
|
||||
<xsl:text>text-decoration:line-through; </xsl:text>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
<xsl:template match="@style:text-position">
|
||||
<xsl:if test="contains(., 'sub')">
|
||||
<xsl:text>vertical-align:sub; </xsl:text>
|
||||
<xsl:if test="contains(., '%')">
|
||||
<xsl:text>font-size:</xsl:text>
|
||||
<xsl:value-of select="substring-after(., 'sub ')"/>
|
||||
<xsl:text>;</xsl:text>
|
||||
</xsl:if>
|
||||
</xsl:if>
|
||||
<xsl:if test="contains(., 'super')">
|
||||
<xsl:text>vertical-align:super; </xsl:text>
|
||||
<xsl:if test="contains(., '%')">
|
||||
<xsl:text>font-size:</xsl:text>
|
||||
<xsl:value-of select="substring-after(., 'super ')"/>
|
||||
<xsl:text>;</xsl:text>
|
||||
</xsl:if>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="@style:vertical-pos">
|
||||
<xsl:choose>
|
||||
<xsl:when test=".='from-top'">
|
||||
<xsl:text>vertical-align:top; </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:text>vertical-align:</xsl:text>
|
||||
<xsl:value-of select="."/>
|
||||
<xsl:text>; </xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="@style:width">
|
||||
<xsl:text>width:</xsl:text>
|
||||
<xsl:choose>
|
||||
<!-- changing the distance measure: inch to in -->
|
||||
<xsl:when test="contains(., 'inch')">
|
||||
<xsl:value-of select="substring-before(.,'ch')"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="."/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:text>; </xsl:text>
|
||||
</xsl:template>
|
||||
<xsl:template match="@style:wrap">
|
||||
<xsl:choose>
|
||||
<xsl:when test=".='left'">
|
||||
<xsl:text>float:right; </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test=".='right'">
|
||||
<xsl:text>float:left; </xsl:text>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
<xsl:template match="@style:writing-mode">
|
||||
<xsl:text>writing-mode:</xsl:text>
|
||||
<xsl:choose>
|
||||
<xsl:when test=".='rl-tb'">
|
||||
<xsl:text>horizontal-tb; direction:rtl; </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test=".='lr-tb'">
|
||||
<xsl:text>horizontal-tb; direction:ltr; </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test=".='tb-rl'">
|
||||
<xsl:text>vertical-rl; </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test=".='tb-lr'">
|
||||
<xsl:text>vertical-lr; </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:text>horizontal-tb; direction:ltr;</xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
<!-- *** Properties with a no 'fo:' or 'style:' prefix *** -->
|
||||
<xsl:template match="@table:align">
|
||||
<xsl:choose>
|
||||
<xsl:when test=".='left'">
|
||||
<xsl:if test="not(../@fo:margin-left)">margin-left:0px; </xsl:if>
|
||||
<xsl:text>margin-right:auto;</xsl:text></xsl:when>
|
||||
<xsl:when test=".='right'">
|
||||
<xsl:text>margin-left:auto</xsl:text>
|
||||
<xsl:if test="not(../@fo:margin-right)">
|
||||
; margin-right: 0px;
|
||||
</xsl:if>
|
||||
</xsl:when>
|
||||
<xsl:when test=".='center'">
|
||||
margin-left:auto;margin-right:auto;
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:text>float:none; </xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="style:background-image">
|
||||
<xsl:text>background-image:url(</xsl:text>
|
||||
<xsl:value-of select="@xlink:href"/>
|
||||
<xsl:text>); </xsl:text>
|
||||
<xsl:choose>
|
||||
<xsl:when test="@style:repeat = 'repeat'">
|
||||
<xsl:text>background-repeat:repeat; </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:text>background-repeat:no-repeat; </xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<!-- Changing border width measure to cm and enlarging border-width to the Mozilla browser(1.7)
|
||||
visible minimum width
|
||||
- 0.0133cm for solid style
|
||||
- 0.0399cm for double style
|
||||
as there are three border lines painted -->
|
||||
<xsl:decimal-format name = "unifiedFormat" decimal-separator = "." />
|
||||
<xsl:template name="round-up-border-width">
|
||||
<xsl:param name="borderWidth"/>
|
||||
<xsl:param name="multiplier"/>
|
||||
|
||||
<xsl:variable name="borderWidthByCentimeter">
|
||||
<xsl:call-template name="convert2cm">
|
||||
<xsl:with-param name="value" select="$borderWidth"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="minimalBorderWidth" select="0.0133 * $multiplier"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="number($borderWidthByCentimeter) < $minimalBorderWidth">
|
||||
<xsl:value-of select="format-number($minimalBorderWidth,'0.######','unifiedFormat')"/>
|
||||
<xsl:text>cm</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="format-number($borderWidthByCentimeter,'0.######','unifiedFormat')"/>
|
||||
<xsl:text>cm</xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>
|
||||
@@ -0,0 +1,155 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
* This file is part of the LibreOffice project.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* This file incorporates work covered by the following license notice:
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed
|
||||
* with this work for additional information regarding copyright
|
||||
* ownership. The ASF licenses this file to you under the Apache
|
||||
* License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
||||
-->
|
||||
<!--
|
||||
For further documentation and updates visit http://xml.openoffice.org/odf2xhtml
|
||||
-->
|
||||
<xsl:stylesheet version="1.0"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
|
||||
xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0"
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:dom="http://www.w3.org/2001/xml-events"
|
||||
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"
|
||||
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
|
||||
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
|
||||
xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"
|
||||
xmlns:math="http://www.w3.org/1998/Math/MathML"
|
||||
xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0"
|
||||
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
|
||||
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
|
||||
xmlns:ooo="http://openoffice.org/2004/office"
|
||||
xmlns:oooc="http://openoffice.org/2004/calc"
|
||||
xmlns:ooow="http://openoffice.org/2004/writer"
|
||||
xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"
|
||||
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
|
||||
xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
|
||||
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
|
||||
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
|
||||
xmlns:xforms="http://www.w3.org/2002/xforms"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
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">
|
||||
|
||||
|
||||
<!-- table row handling -->
|
||||
<xsl:include href="table_rows.xsl" />
|
||||
<!-- table column handling -->
|
||||
<xsl:include href="table_columns.xsl" />
|
||||
<!-- table cell handling -->
|
||||
<xsl:include href="table_cells.xsl" />
|
||||
|
||||
<xsl:param name="tableElement" select="'table'" />
|
||||
|
||||
<!-- ******************* -->
|
||||
<!-- *** main table *** -->
|
||||
<!-- ******************* -->
|
||||
|
||||
|
||||
<xsl:template match="table:table" name="table:table">
|
||||
<xsl:param name="globalData" />
|
||||
|
||||
<!-- The table will only be created if the table:scenario is active -->
|
||||
<xsl:if test="not(table:scenario) or table:scenario/@table:is-active">
|
||||
<xsl:call-template name="create-table">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
</xsl:call-template>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
|
||||
<xsl:template name="create-table">
|
||||
<xsl:param name="globalData" />
|
||||
|
||||
<!-- by default '1', for each new sub/inner/nested table the number counts one up -->
|
||||
<xsl:variable name="tableLevel" select="count(ancestor-or-self::table:table)" />
|
||||
<!-- collecting all visible "table:table-row" elements of the table -->
|
||||
<xsl:variable name="allVisibleTableRows" select="table:table-row[not(@table:visibility = 'collapse' or @table:visibility = 'filter')][count(ancestor-or-self::table:table) = $tableLevel] |
|
||||
table:table-header-rows/descendant::table:table-row[not(@table:visibility = 'collapse' or @table:visibility = 'filter')][count(ancestor-or-self::table:table) = $tableLevel] |
|
||||
table:table-row-group/descendant::table:table-row[not(@table:visibility = 'collapse' or @table:visibility = 'filter')][count(ancestor-or-self::table:table) = $tableLevel]" />
|
||||
<!-- As the alignment of a table is by 'align' attribute is deprecated and as the CSS 'float' attribute not well displayed,
|
||||
we do a trick by encapsulating the table with an aligned 'div' element-->
|
||||
<xsl:variable name="table-alignment" select="key('styles', @style:name = current()/@table:style-name)/*/@table:align" />
|
||||
<xsl:choose>
|
||||
<xsl:when test="string-length($table-alignment) != 0">
|
||||
<xsl:element namespace="{$namespace}" name="div">
|
||||
<xsl:attribute name="style">
|
||||
<xsl:choose>
|
||||
<xsl:when test='$table-alignment="left" or $table-alignment="margins"'>
|
||||
<xsl:text>text-align:left</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test='$table-alignment="right"'>
|
||||
<xsl:text>text-align:right</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test='$table-alignment="center"'>
|
||||
<xsl:text>text-align:center</xsl:text>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
</xsl:attribute>
|
||||
<xsl:call-template name="create-table-element">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="allVisibleTableRows" select="$allVisibleTableRows" />
|
||||
</xsl:call-template>
|
||||
</xsl:element>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:call-template name="create-table-element">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="allVisibleTableRows" select="$allVisibleTableRows" />
|
||||
</xsl:call-template>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template name="create-table-element">
|
||||
<xsl:param name="globalData" />
|
||||
<xsl:param name="allVisibleTableRows" />
|
||||
|
||||
<xsl:element namespace="{$namespace}" name="{$tableElement}">
|
||||
<xsl:attribute name="border">0</xsl:attribute>
|
||||
<xsl:attribute name="cellspacing">0</xsl:attribute>
|
||||
<xsl:attribute name="cellpadding">0</xsl:attribute>
|
||||
<xsl:choose>
|
||||
<xsl:when test='name()="table:table"'>
|
||||
<xsl:variable name="value" select="$globalData/all-doc-styles/style[@style:name = current()/@table:style-name]/*/@style:rel-width" />
|
||||
<xsl:if test="$value">
|
||||
<xsl:attribute name="width">
|
||||
<xsl:value-of select="$value" />
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:attribute name="width">100%</xsl:attribute>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
|
||||
<xsl:apply-templates select="@table:style-name">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
</xsl:apply-templates>
|
||||
|
||||
<xsl:call-template name="create-column-style-variable">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="allVisibleTableRows" select="$allVisibleTableRows" />
|
||||
</xsl:call-template>
|
||||
</xsl:element>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
||||
@@ -0,0 +1,270 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
* This file is part of the LibreOffice project.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* This file incorporates work covered by the following license notice:
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed
|
||||
* with this work for additional information regarding copyright
|
||||
* ownership. The ASF licenses this file to you under the Apache
|
||||
* License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
||||
-->
|
||||
<!--
|
||||
For further documentation and updates visit http://xml.openoffice.org/odf2xhtml
|
||||
-->
|
||||
<xsl:stylesheet version="1.0"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
|
||||
xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0"
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:dom="http://www.w3.org/2001/xml-events"
|
||||
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"
|
||||
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
|
||||
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
|
||||
xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"
|
||||
xmlns:math="http://www.w3.org/1998/Math/MathML"
|
||||
xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0"
|
||||
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
|
||||
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
|
||||
xmlns:ooo="http://openoffice.org/2004/office"
|
||||
xmlns:oooc="http://openoffice.org/2004/calc"
|
||||
xmlns:ooow="http://openoffice.org/2004/writer"
|
||||
xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"
|
||||
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
|
||||
xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
|
||||
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
|
||||
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
|
||||
xmlns:xforms="http://www.w3.org/2002/xforms"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:xt="http://www.jclark.com/xt"
|
||||
xmlns:common="http://exslt.org/common"
|
||||
xmlns:xalan="http://xml.apache.org/xalan"
|
||||
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">
|
||||
|
||||
|
||||
<!-- *********************************** -->
|
||||
<!-- *** write repeating table cells *** -->
|
||||
<!-- *********************************** -->
|
||||
|
||||
|
||||
<!-- matching cells to give out -> covered table cells are not written out -->
|
||||
<xsl:template match="table:table-cell">
|
||||
<xsl:param name="globalData" />
|
||||
<!-- position of the current input cell to get the correct column style (hidden are also counted)-->
|
||||
<xsl:param name="allTableColumns" />
|
||||
<xsl:param name="maxRowLength" />
|
||||
<xsl:param name="tableDataType" />
|
||||
|
||||
|
||||
<!-- The column position of the current cell has to be determined
|
||||
to get the adequate column styles during later cell creation,
|
||||
or hiding the cell when @table:visibility is not set to 'visible'.
|
||||
|
||||
The position is archived by adding up all table:number-columns-repeated of the preceding cells.
|
||||
Step1: creating '$precedingCells/quantity/@table:number-columns-repeated').
|
||||
Step2: sum(xxx:nodeset($precedingCells)/quantity) + 1 -->
|
||||
<xsl:variable name="precedingCells">
|
||||
<xsl:for-each select="preceding-sibling::*">
|
||||
<xsl:choose>
|
||||
<!-- maybe a parser is used, which reads the DTD files (e.g. Xerces),
|
||||
then '1' is the default for 'table:number-columns-repeated' -->
|
||||
<xsl:when test="not(@table:number-columns-repeated and @table:number-columns-repeated > 1)">
|
||||
<xsl:element name="quantity" namespace="">
|
||||
<xsl:text>1</xsl:text>
|
||||
</xsl:element>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:element name="quantity" namespace="">
|
||||
<xsl:value-of select="@table:number-columns-repeated" />
|
||||
</xsl:element>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:for-each>
|
||||
</xsl:variable>
|
||||
|
||||
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="function-available('common:node-set')">
|
||||
<xsl:call-template name="create-table-cell">
|
||||
<!-- position of the current input cell to get the correct column style (hidden are also counted)-->
|
||||
<xsl:with-param name="allTableColumns" select="$allTableColumns" />
|
||||
<xsl:with-param name="maxRowLength" select="$maxRowLength" />
|
||||
<xsl:with-param name="precedingColumns" select="sum(common:node-set($precedingCells)/*)" />
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="tableDataType" select="$tableDataType" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="function-available('xalan:nodeset')">
|
||||
<xsl:call-template name="create-table-cell">
|
||||
<!-- position of the current input cell to get the correct column style (hidden are also counted)-->
|
||||
<xsl:with-param name="allTableColumns" select="$allTableColumns" />
|
||||
<xsl:with-param name="maxRowLength" select="$maxRowLength" />
|
||||
<xsl:with-param name="precedingColumns" select="sum(xalan:nodeset($precedingCells)/*)" />
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="tableDataType" select="$tableDataType" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="function-available('xt:node-set')">
|
||||
<xsl:call-template name="create-table-cell">
|
||||
<!-- position of the current input cell to get the correct column style (hidden are also counted)-->
|
||||
<xsl:with-param name="allTableColumns" select="$allTableColumns" />
|
||||
<xsl:with-param name="maxRowLength" select="$maxRowLength" />
|
||||
<xsl:with-param name="precedingColumns" select="sum(xt:node-set($precedingCells)/*)" />
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="tableDataType" select="$tableDataType" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:message terminate="yes">ERROR: Function not found: nodeset</xsl:message>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<!-- current node is a table:table-cell -->
|
||||
<xsl:template name="create-table-cell">
|
||||
<!-- position of the current input cell to get the correct column style (hidden are also counted)-->
|
||||
<xsl:param name="allTableColumns" />
|
||||
<xsl:param name="globalData" />
|
||||
<xsl:param name="maxRowLength" />
|
||||
<xsl:param name="precedingColumns" select="0" />
|
||||
<xsl:param name="tableDataType" />
|
||||
|
||||
<xsl:variable name="columnPosition" select="$precedingColumns + 1" />
|
||||
|
||||
<xsl:if test="$debugEnabled">
|
||||
<xsl:message>
|
||||
<xsl:text>
|
||||
table:table-cell #</xsl:text>
|
||||
<xsl:value-of select="$columnPosition" />
|
||||
<xsl:text> has been entered with node value: </xsl:text>
|
||||
<xsl:value-of select="." />
|
||||
<xsl:text>
|
||||
table:number-columns-repeated: </xsl:text>
|
||||
<xsl:value-of select="@table:number-columns-repeated" />
|
||||
<xsl:text>
|
||||
maxRowLength: </xsl:text>
|
||||
<xsl:value-of select="$maxRowLength" />
|
||||
</xsl:message>
|
||||
</xsl:if>
|
||||
|
||||
<!-- only non hidden column will be given out -->
|
||||
<xsl:variable name="currentTableColumn" select="$allTableColumns/table:table-column[position() = $columnPosition]" />
|
||||
<xsl:if test="$currentTableColumn[not(@table:visibility = 'collapse' or @table:visibility = 'filter')]">
|
||||
<xsl:choose>
|
||||
<!-- if parser reads DTD the default is set to '1' -->
|
||||
<xsl:when test="@table:number-columns-repeated > 1">
|
||||
<!-- writes multiple entries of a cell -->
|
||||
<xsl:call-template name="repeat-write-cell">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="allTableColumns" select="$allTableColumns" />
|
||||
<xsl:with-param name="columnPosition" select="$columnPosition" />
|
||||
<xsl:with-param name="currentTableColumn" select="$currentTableColumn" />
|
||||
<xsl:with-param name="maxRowLength" select="$maxRowLength" />
|
||||
<xsl:with-param name="numberColumnsRepeated" select="@table:number-columns-repeated" />
|
||||
<xsl:with-param name="tableDataType" select="$tableDataType" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<!-- writes an entry of a cell -->
|
||||
<xsl:call-template name="write-cell">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="allTableColumns" select="$allTableColumns" />
|
||||
<xsl:with-param name="columnPosition" select="$columnPosition" />
|
||||
<xsl:with-param name="currentTableColumn" select="$currentTableColumn" />
|
||||
<xsl:with-param name="maxRowLength" select="$maxRowLength" />
|
||||
<xsl:with-param name="tableDataType" select="$tableDataType" />
|
||||
</xsl:call-template>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template name="repeat-write-cell">
|
||||
<xsl:param name="globalData" />
|
||||
<xsl:param name="allTableColumns" />
|
||||
<xsl:param name="columnPosition" />
|
||||
<xsl:param name="currentTableColumn" />
|
||||
<xsl:param name="maxRowLength" />
|
||||
<xsl:param name="numberColumnsRepeated" />
|
||||
<xsl:param name="tableDataType" />
|
||||
|
||||
<xsl:choose>
|
||||
<!-- This is the current workaround for the flood of cells, simulation background by repeating cell -->
|
||||
<xsl:when test="$numberColumnsRepeated > 1 and $maxRowLength > $columnPosition">
|
||||
|
||||
<!-- writes an entry of a cell -->
|
||||
<xsl:call-template name="write-cell">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="allTableColumns" select="$allTableColumns" />
|
||||
<xsl:with-param name="columnPosition" select="$columnPosition" />
|
||||
<xsl:with-param name="currentTableColumn" select="$currentTableColumn" />
|
||||
<xsl:with-param name="tableDataType" select="$tableDataType" />
|
||||
</xsl:call-template>
|
||||
<!-- repeat calling this method until all elements written out -->
|
||||
<xsl:if test="$debugEnabled">
|
||||
<xsl:message>+++++++++ cell repetition +++++++++</xsl:message>
|
||||
</xsl:if>
|
||||
<xsl:call-template name="repeat-write-cell">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="allTableColumns" select="$allTableColumns" />
|
||||
<xsl:with-param name="columnPosition" select="$columnPosition + 1" />
|
||||
<xsl:with-param name="currentTableColumn" select="$allTableColumns/table:table-column[position() = ($columnPosition + 1)]" />
|
||||
<xsl:with-param name="maxRowLength" select="$maxRowLength" />
|
||||
<xsl:with-param name="numberColumnsRepeated" select="$numberColumnsRepeated - 1" />
|
||||
<xsl:with-param name="tableDataType" select="$tableDataType" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<!-- This is the current workaround for the flood of cells, simulation background by repeating cell -->
|
||||
<!-- When the maxRowLength is reached a last entry of a cell is written -->
|
||||
<xsl:call-template name="write-cell">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="allTableColumns" select="$allTableColumns" />
|
||||
<xsl:with-param name="columnPosition" select="$columnPosition" />
|
||||
<xsl:with-param name="currentTableColumn" select="$currentTableColumn" />
|
||||
<xsl:with-param name="tableDataType" select="$tableDataType" />
|
||||
</xsl:call-template>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template name="write-cell">
|
||||
<xsl:param name="globalData" />
|
||||
<xsl:param name="allTableColumns" />
|
||||
<xsl:param name="columnPosition" />
|
||||
<xsl:param name="currentTableColumn" />
|
||||
<xsl:param name="tableDataType" />
|
||||
|
||||
<!-- a non hidden column will be give out -->
|
||||
<xsl:choose>
|
||||
<xsl:when test="$currentTableColumn[not(@table:visibility = 'collapse' or @table:visibility = 'filter')]">
|
||||
<xsl:call-template name="create-table-cell-content">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="allTableColumns" select="$allTableColumns" />
|
||||
<xsl:with-param name="columnPosition" select="$columnPosition" />
|
||||
<xsl:with-param name="currentTableColumn" select="$currentTableColumn" />
|
||||
<xsl:with-param name="tableDataType" select="$tableDataType" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<!-- a hidden column -->
|
||||
<xsl:otherwise>
|
||||
<xsl:if test="$debugEnabled">
|
||||
<xsl:message>table column is hidden!</xsl:message>
|
||||
</xsl:if>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>
|
||||
@@ -0,0 +1,232 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
* This file is part of the LibreOffice project.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* This file incorporates work covered by the following license notice:
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed
|
||||
* with this work for additional information regarding copyright
|
||||
* ownership. The ASF licenses this file to you under the Apache
|
||||
* License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
||||
-->
|
||||
<!--
|
||||
For further documentation and updates visit http://xml.openoffice.org/odf2xhtml
|
||||
-->
|
||||
<xsl:stylesheet version="1.0"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
|
||||
xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0"
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:dom="http://www.w3.org/2001/xml-events"
|
||||
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"
|
||||
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
|
||||
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
|
||||
xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"
|
||||
xmlns:math="http://www.w3.org/1998/Math/MathML"
|
||||
xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0"
|
||||
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
|
||||
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
|
||||
xmlns:ooo="http://openoffice.org/2004/office"
|
||||
xmlns:oooc="http://openoffice.org/2004/calc"
|
||||
xmlns:ooow="http://openoffice.org/2004/writer"
|
||||
xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"
|
||||
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
|
||||
xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
|
||||
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
|
||||
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
|
||||
xmlns:xforms="http://www.w3.org/2002/xforms"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:xt="http://www.jclark.com/xt"
|
||||
xmlns:common="http://exslt.org/common"
|
||||
xmlns:xalan="http://xml.apache.org/xalan"
|
||||
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">
|
||||
|
||||
<xsl:param name="tableColumnElement" select="'col'" />
|
||||
|
||||
<!-- ******************************************** -->
|
||||
<!-- *** Create table columns style variable *** -->
|
||||
<!-- ******************************************** -->
|
||||
|
||||
<!-- current node is a table:table -->
|
||||
<xsl:template name="create-column-style-variable">
|
||||
<xsl:param name="globalData" />
|
||||
<xsl:param name="allVisibleTableRows" />
|
||||
|
||||
<!-- all columns of the table -->
|
||||
<xsl:variable name="allTableColumns" select="table:table-column |
|
||||
table:table-column-group/descendant::table:table-column |
|
||||
table:table-header-columns/descendant::table:table-column" />
|
||||
<!-- allTableColumns: Containing all columns of the table, hidden and viewed.
|
||||
- if a column is hidden, if table:visibility has the value 'collapse' or 'filter', otherwise the value is 'visible'
|
||||
- if a column is being repeated, each repeated column is explicitly written as entry in this variable.
|
||||
Later (during template "write-cell") the style of the column will be mixed with the cell-style by using
|
||||
the position() of the column entry and comparing it with the iterating cell number. -->
|
||||
<xsl:variable name="allTableColumns-RTF">
|
||||
<xsl:for-each select="$allTableColumns">
|
||||
<xsl:call-template name="adding-column-styles-entries">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="allTableColumns" select="$allTableColumns" />
|
||||
</xsl:call-template>
|
||||
</xsl:for-each>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="function-available('common:node-set')">
|
||||
<xsl:call-template name="create-table-children">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="allVisibleTableRows" select="$allVisibleTableRows" />
|
||||
<xsl:with-param name="allTableColumns" select="common:node-set($allTableColumns-RTF)" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="function-available('xalan:nodeset')">
|
||||
<xsl:call-template name="create-table-children">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="allVisibleTableRows" select="$allVisibleTableRows" />
|
||||
<xsl:with-param name="allTableColumns" select="xalan:nodeset($allTableColumns-RTF)" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="function-available('xt:node-set')">
|
||||
<xsl:call-template name="create-table-children">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="allVisibleTableRows" select="$allVisibleTableRows" />
|
||||
<xsl:with-param name="allTableColumns" select="xt:node-set($allTableColumns-RTF)" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<!-- current node is a table:table -->
|
||||
<xsl:template name="create-table-children">
|
||||
<xsl:param name="globalData" />
|
||||
<xsl:param name="allVisibleTableRows" />
|
||||
<xsl:param name="allTableColumns" />
|
||||
|
||||
|
||||
<xsl:for-each select="$allTableColumns/table:table-column">
|
||||
<xsl:if test="not(@table:visibility = 'collapse' or @table:visibility = 'filter')">
|
||||
|
||||
<xsl:call-template name="create-column-element">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="allVisibleTableRows" select="$allVisibleTableRows" />
|
||||
<xsl:with-param name="allTableColumns" select="$allTableColumns" />
|
||||
</xsl:call-template>
|
||||
</xsl:if>
|
||||
</xsl:for-each>
|
||||
|
||||
<xsl:call-template name="create-table-rows">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="allVisibleTableRows" select="$allVisibleTableRows" />
|
||||
<xsl:with-param name="allTableColumns" select="$allTableColumns" />
|
||||
</xsl:call-template>
|
||||
</xsl:template>
|
||||
|
||||
<!-- To be OVERWRITTEN -->
|
||||
<xsl:template name="create-column-element" />
|
||||
|
||||
<!-- current node is a table:table-column -->
|
||||
<xsl:template name="adding-column-styles-entries">
|
||||
<xsl:param name="globalData" />
|
||||
<xsl:param name="allTableColumns" />
|
||||
|
||||
<xsl:choose>
|
||||
<!-- if parser reads DTD the default is set to '1' -->
|
||||
<xsl:when test="not(@table:number-columns-repeated and @table:number-columns-repeated > 1)">
|
||||
<!-- writes an entry of a column in the columns-variable -->
|
||||
<xsl:copy-of select="." />
|
||||
</xsl:when>
|
||||
<!-- No higher repetition of cells greater than 99 for the last and second last column.
|
||||
This is a workaround for some sample document (Waehrungsumrechner.sxc),
|
||||
having 230 repeated columns in the second last column to emulate background -->
|
||||
<!-- NOTE: Testcase with a table containing table:table-column-group and/or table:table-header-columns -->
|
||||
<xsl:when test="(last() or (last() - 1)) and @table:number-columns-repeated > 99">
|
||||
<!-- writes an entry of a column in the columns-variable -->
|
||||
<xsl:call-template name="repeat-adding-table-column">
|
||||
<xsl:with-param name="numberColumnsRepeated" select="1" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<!-- repeated columns will be written explicit several times in the variable-->
|
||||
<xsl:call-template name="repeat-adding-table-column">
|
||||
<xsl:with-param name="numberColumnsRepeated" select="@table:number-columns-repeated" />
|
||||
</xsl:call-template>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<!-- WRITES THE REPEATED COLUMN STYLE EXPLICIT AS AN ELEMENT IN THE COLUMNS-VARIABLE -->
|
||||
<!-- current node is a table:table-column -->
|
||||
<xsl:template name="repeat-adding-table-column">
|
||||
<xsl:param name="table:table-column" />
|
||||
<xsl:param name="numberColumnsRepeated" />
|
||||
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="$numberColumnsRepeated > 1">
|
||||
<!-- writes an entry of a column in the columns-variable -->
|
||||
<xsl:copy-of select="." />
|
||||
<!-- repeat calling this method until all elements written out -->
|
||||
<xsl:call-template name="repeat-adding-table-column">
|
||||
<xsl:with-param name="numberColumnsRepeated" select="$numberColumnsRepeated - 1" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<!-- writes an entry of a column in the columns-variable -->
|
||||
<xsl:copy-of select="." />
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<!--debugEnabled-START-->
|
||||
<!-- giving out the 'allColumnStyle' variable:
|
||||
For each 'table:table-column' of the 'allTableColumns' variable the style-name is given out.
|
||||
In case of 'column-hidden-flag' attribute the text 'Column is hidden is given out.-->
|
||||
<!-- current node is a table:table -->
|
||||
<xsl:template name="table-debug-allTableColumns">
|
||||
<xsl:param name="allTableColumns" />
|
||||
|
||||
<!-- debug output as table summary attribute in html -->
|
||||
<xsl:attribute name="summary">
|
||||
<xsl:call-template name="table-debug-column-out">
|
||||
<xsl:with-param name="allTableColumns" select="$allTableColumns" />
|
||||
</xsl:call-template>
|
||||
</xsl:attribute>
|
||||
<!-- debug output to console -->
|
||||
<xsl:message>
|
||||
<xsl:call-template name="table-debug-column-out">
|
||||
<xsl:with-param name="allTableColumns" select="$allTableColumns" />
|
||||
</xsl:call-template>
|
||||
</xsl:message>
|
||||
</xsl:template>
|
||||
|
||||
<!-- current node is a table:table -->
|
||||
<xsl:template name="table-debug-column-out">
|
||||
<xsl:param name="allTableColumns" />
|
||||
<xsl:text>
|
||||
DebugInformation: For each 'table:table-column' of the 'allTableColumns' variable the style-name is given out.
|
||||
In case of table:visibility attribute unequal 'visible' the 'column is hidden' no text is given out.
|
||||
</xsl:text>
|
||||
<xsl:for-each select="$allTableColumns/table:table-column">
|
||||
<xsl:choose>
|
||||
<xsl:when test="@table:visibility = 'collapse' or @table:visibility = 'filter' ">
|
||||
<xsl:text> </xsl:text><xsl:value-of select="@table:style-name" /><xsl:text>column is hidden</xsl:text><xsl:text></xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<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></xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:for-each>
|
||||
</xsl:template>
|
||||
<!--debugEnabled-END-->
|
||||
|
||||
</xsl:stylesheet>
|
||||
@@ -0,0 +1,203 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
* This file is part of the LibreOffice project.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* This file incorporates work covered by the following license notice:
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed
|
||||
* with this work for additional information regarding copyright
|
||||
* ownership. The ASF licenses this file to you under the Apache
|
||||
* License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
||||
-->
|
||||
<!--
|
||||
For further documentation and updates visit http://xml.openoffice.org/odf2xhtml
|
||||
-->
|
||||
<xsl:stylesheet version="1.0"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
|
||||
xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0"
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:dom="http://www.w3.org/2001/xml-events"
|
||||
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"
|
||||
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
|
||||
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
|
||||
xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"
|
||||
xmlns:math="http://www.w3.org/1998/Math/MathML"
|
||||
xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0"
|
||||
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
|
||||
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
|
||||
xmlns:ooo="http://openoffice.org/2004/office"
|
||||
xmlns:oooc="http://openoffice.org/2004/calc"
|
||||
xmlns:ooow="http://openoffice.org/2004/writer"
|
||||
xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"
|
||||
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
|
||||
xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
|
||||
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
|
||||
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
|
||||
xmlns:xforms="http://www.w3.org/2002/xforms"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
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">
|
||||
|
||||
|
||||
<xsl:param name="rowElement" select="'tr'" />
|
||||
|
||||
<!-- ********************************** -->
|
||||
<!-- *** write repeating table rows *** -->
|
||||
<!-- ********************************** -->
|
||||
|
||||
<!-- current node is a table:table -->
|
||||
<xsl:template name="create-table-rows">
|
||||
<xsl:param name="globalData" />
|
||||
<xsl:param name="allVisibleTableRows" />
|
||||
<xsl:param name="allTableColumns" />
|
||||
|
||||
<!-- Some Office Calc documents simulate a background by repeating one of the later cells until end of used space
|
||||
(The value of "table:number-columns-repeated" is enormous). Writing out all these cells would be fatal in time
|
||||
and output size. Therefore, this global variable shows us the longest row with content. -->
|
||||
<xsl:variable name="maxRowLength" select="count($allTableColumns/table:table-column)" />
|
||||
<xsl:if test="$debugEnabled">
|
||||
<xsl:message>maxRowLength: <xsl:value-of select="$maxRowLength" /></xsl:message>
|
||||
<xsl:call-template name="table-debug-allTableColumns">
|
||||
<xsl:with-param name="allTableColumns" select="$allTableColumns" />
|
||||
</xsl:call-template>
|
||||
</xsl:if>
|
||||
|
||||
<!-- a table is a table header, when it has a "table:table-header-rows" ancestor -->
|
||||
<xsl:variable name="tableDataType">
|
||||
<xsl:choose>
|
||||
<xsl:when test="ancestor::table:table-header-rows">
|
||||
<xsl:text>th</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:text>td</xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
|
||||
<!-- removes repetition of rows, most probably done for background emulating -->
|
||||
<xsl:for-each select="$allVisibleTableRows">
|
||||
<xsl:choose>
|
||||
<xsl:when test="(last() or (last() - 1)) and @table:number-rows-repeated > 99">
|
||||
<xsl:call-template name="repeat-write-row">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="allTableColumns" select="$allTableColumns" />
|
||||
<xsl:with-param name="numberRowsRepeated" select="1" />
|
||||
<xsl:with-param name="maxRowLength" select="$maxRowLength" />
|
||||
<xsl:with-param name="tableDataType" select="$tableDataType" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:call-template name="repeat-write-row">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="allTableColumns" select="$allTableColumns" />
|
||||
<xsl:with-param name="numberRowsRepeated" select="@table:number-rows-repeated" />
|
||||
<xsl:with-param name="maxRowLength" select="$maxRowLength" />
|
||||
<xsl:with-param name="tableDataType" select="$tableDataType" />
|
||||
</xsl:call-template>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:for-each>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template name="repeat-write-row">
|
||||
<xsl:param name="globalData" />
|
||||
<xsl:param name="allTableColumns" />
|
||||
<xsl:param name="numberRowsRepeated" select="1" />
|
||||
<xsl:param name="maxRowLength" />
|
||||
<xsl:param name="tableDataType" />
|
||||
|
||||
<xsl:choose>
|
||||
<!-- write an entry of a row and repeat calling this method until all elements are written out -->
|
||||
<xsl:when test="$numberRowsRepeated > 1 and table:table-cell">
|
||||
<xsl:call-template name="write-row">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="allTableColumns" select="$allTableColumns" />
|
||||
<xsl:with-param name="maxRowLength" select="$maxRowLength" />
|
||||
<xsl:with-param name="tableDataType" select="$tableDataType" />
|
||||
</xsl:call-template>
|
||||
|
||||
<!-- NOTE: take variable from the output of repeated write-row and iterate giving out the variable -->
|
||||
<xsl:call-template name="repeat-write-row">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="allTableColumns" select="$allTableColumns" />
|
||||
<xsl:with-param name="maxRowLength" select="$maxRowLength" />
|
||||
<xsl:with-param name="numberRowsRepeated" select="$numberRowsRepeated - 1" />
|
||||
<xsl:with-param name="tableDataType" select="$tableDataType" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<!-- write a single entry of a row -->
|
||||
<xsl:otherwise>
|
||||
<xsl:call-template name="write-row">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="allTableColumns" select="$allTableColumns" />
|
||||
<xsl:with-param name="maxRowLength" select="$maxRowLength" />
|
||||
<xsl:with-param name="tableDataType" select="$tableDataType" />
|
||||
</xsl:call-template>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template name="add-table-row-attributes">
|
||||
<xsl:param name="globalData" />
|
||||
|
||||
<!-- writing the style of the row -->
|
||||
<xsl:if test="@table:style-name">
|
||||
<xsl:call-template name='add-style-properties'>
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
</xsl:call-template>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="write-row">
|
||||
<xsl:param name="globalData" />
|
||||
<xsl:param name="allTableColumns" />
|
||||
<xsl:param name="maxRowLength" />
|
||||
<xsl:param name="tableDataType" />
|
||||
|
||||
|
||||
<xsl:element namespace="{$namespace}" name="{$rowElement}">
|
||||
<xsl:call-template name='add-table-row-attributes'>
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
</xsl:call-template>
|
||||
|
||||
<xsl:if test="$debugEnabled">
|
||||
<xsl:message>'tr' element has been added!</xsl:message>
|
||||
</xsl:if>
|
||||
|
||||
<xsl:apply-templates select="table:table-cell">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="allTableColumns" select="$allTableColumns" />
|
||||
<xsl:with-param name="maxRowLength" select="$maxRowLength" />
|
||||
<xsl:with-param name="tableDataType" select="$tableDataType" />
|
||||
</xsl:apply-templates>
|
||||
|
||||
</xsl:element>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<!-- **************************** -->
|
||||
<!-- *** HELPER: table styles *** -->
|
||||
<!-- **************************** -->
|
||||
|
||||
<xsl:template name="add-style-properties">
|
||||
<xsl:param name="globalData" />
|
||||
<xsl:param name="allTableColumns" />
|
||||
<xsl:param name="node-position" />
|
||||
|
||||
<xsl:attribute name="class">
|
||||
<xsl:value-of select="translate(@table:style-name, '. %()/\+', '')" />
|
||||
</xsl:attribute>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
||||
@@ -0,0 +1,579 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
* This file is part of the LibreOffice project.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* This file incorporates work covered by the following license notice:
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed
|
||||
* with this work for additional information regarding copyright
|
||||
* ownership. The ASF licenses this file to you under the Apache
|
||||
* License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
||||
-->
|
||||
<!--
|
||||
For further documentation and updates visit http://xml.openoffice.org/odf2xhtml
|
||||
-->
|
||||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:java="http://xml.apache.org/xslt/java" xmlns:sxg="http://www.jclark.com/xt/java/org.openoffice.xslt.OOoMasterDocument" xmlns:common="http://exslt.org/common" xmlns:xt="http://www.jclark.com/xt" xmlns:xalan="http://xml.apache.org/xalan" 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 java sxg xt common xalan">
|
||||
|
||||
<!-- ****************************** -->
|
||||
<!-- *** Table of Content *** -->
|
||||
<!-- ****************************** -->
|
||||
|
||||
<xsl:param name="currentChildContentRef" />
|
||||
<xsl:param name="contentTableHeadings" />
|
||||
<xsl:param name="contentTableURL" />
|
||||
<xsl:template match="text:table-of-content">
|
||||
<xsl:param name="globalData"/>
|
||||
|
||||
<xsl:apply-templates>
|
||||
<xsl:with-param name="globalData" select="$globalData"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template match="text:index-body">
|
||||
<xsl:param name="globalData"/>
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="parent::table-of-content and */text:tab[1] or */*/text:tab[1]">
|
||||
<xsl:call-template name="createIndexBodyTable">
|
||||
<xsl:with-param name="globalData" select="$globalData"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:apply-templates>
|
||||
<xsl:with-param name="globalData" select="$globalData"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="text:index-title" mode="content-table">
|
||||
<xsl:param name="globalData"/>
|
||||
|
||||
<xsl:apply-templates>
|
||||
<xsl:with-param name="globalData" select="$globalData"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="createIndexBodyTable">
|
||||
<xsl:param name="globalData"/>
|
||||
<xsl:variable name="allStyleTabStops-RTF">
|
||||
<xsl:element name="style:tab-stops">
|
||||
<xsl:call-template name="get-tab-stops">
|
||||
<xsl:with-param name="globalData" select="$globalData"/>
|
||||
<xsl:with-param name="styleName" select="current()/@text:style-name"/>
|
||||
|
||||
<!--
|
||||
Currently only the style of text:index-body is recognized, but not of a paragraph child containing the text:tab element!
|
||||
<xsl:with-param name="styleName" select="descendant-or-self::*/@text:style-name"/>
|
||||
|
||||
The column width needs to be tabstop plus fo:margin-left paragraph-properties
|
||||
-->
|
||||
</xsl:call-template>
|
||||
</xsl:element>
|
||||
</xsl:variable>
|
||||
<xsl:element namespace="{$namespace}" name="table">
|
||||
|
||||
<xsl:attribute name="border">0</xsl:attribute>
|
||||
<xsl:attribute name="cellspacing">0</xsl:attribute>
|
||||
<xsl:attribute name="cellpadding">0</xsl:attribute>
|
||||
<xsl:if test="parent::*/@text:style-name">
|
||||
<!-- parent as index:body has no style -->
|
||||
<xsl:variable name="value" select="$globalData/all-doc-styles/style[@style:name = current()/parent::*/@text:style-name]/*/@style:rel-width"/>
|
||||
<xsl:if test="$value">
|
||||
<xsl:attribute name="width">
|
||||
<xsl:value-of select="$value"/>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
<xsl:attribute name="class">
|
||||
<xsl:value-of select="translate(parent::*/@text:style-name, '.,;: %()[]/\+', '_____________')"/>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
|
||||
<xsl:element namespace="{$namespace}" name="colgroup">
|
||||
<xsl:choose>
|
||||
<xsl:when test="function-available('common:node-set')">
|
||||
<xsl:call-template name="create-col-element">
|
||||
<xsl:with-param name="lastNodePosition" select="count(common:node-set($allStyleTabStops-RTF)/style:tab-stops/style:tab-stop)"/>
|
||||
<xsl:with-param name="allStyleTabStops" select="common:node-set($allStyleTabStops-RTF)"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="function-available('xalan:nodeset')">
|
||||
<xsl:call-template name="create-col-element">
|
||||
<xsl:with-param name="lastNodePosition" select="count(xalan:nodeset($allStyleTabStops-RTF)/style:tab-stops/style:tab-stop)"/>
|
||||
<xsl:with-param name="allStyleTabStops" select="xalan:nodeset($allStyleTabStops-RTF)"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="function-available('xt:node-set')">
|
||||
<xsl:call-template name="create-col-element">
|
||||
<xsl:with-param name="lastNodePosition" select="count(xt:node-set($allStyleTabStops-RTF)/style:tab-stops/style:tab-stop)"/>
|
||||
<xsl:with-param name="allStyleTabStops" select="xt:node-set($allStyleTabStops-RTF)"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:message terminate="yes">ERROR: Function not found: nodeset</xsl:message>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:element>
|
||||
|
||||
<!-- add table data -->
|
||||
<xsl:choose>
|
||||
<xsl:when test="function-available('common:node-set')">
|
||||
<xsl:apply-templates mode="content-table">
|
||||
<xsl:with-param name="globalData" select="$globalData"/>
|
||||
<xsl:with-param name="allStyleTabStops" select="common:node-set($allStyleTabStops-RTF)"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:when>
|
||||
<xsl:when test="function-available('xalan:nodeset')">
|
||||
<xsl:apply-templates mode="content-table">
|
||||
<xsl:with-param name="globalData" select="$globalData"/>
|
||||
<xsl:with-param name="allStyleTabStops" select="xalan:nodeset($allStyleTabStops-RTF)"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:when>
|
||||
<xsl:when test="function-available('xt:node-set')">
|
||||
<xsl:apply-templates mode="content-table">
|
||||
<xsl:with-param name="globalData" select="$globalData"/>
|
||||
<xsl:with-param name="allStyleTabStops" select="xt:node-set($allStyleTabStops-RTF)"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:message terminate="yes">ERROR: Function not found: nodeset</xsl:message>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
|
||||
</xsl:element>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<!-- ************************************************ -->
|
||||
<!-- *** Create Table for Content Table Paragraph *** -->
|
||||
<!-- ************************************************ -->
|
||||
|
||||
<!-- Usually the paragraphs in a content-table are ordered by tab-stops, which can not be displayed correctly by XHTML/CSS
|
||||
Therefore they will be simulated by a table -->
|
||||
<xsl:template match="text:p" mode="content-table">
|
||||
<xsl:param name="globalData"/>
|
||||
<xsl:param name="allStyleTabStops"/>
|
||||
|
||||
<!-- all elements before the first tabStop -->
|
||||
<xsl:variable name="testNo-RTF">
|
||||
<xsl:apply-templates select="node()" mode="cell-content"/>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="function-available('common:node-set')">
|
||||
<xsl:variable name="tabNodePositions" select="common:node-set($testNo-RTF)"/>
|
||||
<xsl:element namespace="{$namespace}" name="tr">
|
||||
<xsl:call-template name="create-td-elements">
|
||||
<xsl:with-param name="lastNodePosition" select="count($allStyleTabStops/style:tab-stops/style:tab-stop)"/>
|
||||
<xsl:with-param name="position" select="1"/>
|
||||
<xsl:with-param name="allStyleTabStops" select="$allStyleTabStops"/>
|
||||
<xsl:with-param name="tabNodePositions" select="$tabNodePositions"/>
|
||||
<xsl:with-param name="globalData" select="$globalData"/>
|
||||
</xsl:call-template>
|
||||
</xsl:element>
|
||||
</xsl:when>
|
||||
<xsl:when test="function-available('xalan:nodeset')">
|
||||
<xsl:variable name="tabNodePositions" select="xalan:nodeset($testNo-RTF)"/>
|
||||
<xsl:element namespace="{$namespace}" name="tr">
|
||||
<xsl:call-template name="create-td-elements">
|
||||
<xsl:with-param name="lastNodePosition" select="count($allStyleTabStops/style:tab-stops/style:tab-stop)"/>
|
||||
<xsl:with-param name="position" select="1"/>
|
||||
<xsl:with-param name="allStyleTabStops" select="$allStyleTabStops"/>
|
||||
<xsl:with-param name="tabNodePositions" select="$tabNodePositions"/>
|
||||
<xsl:with-param name="globalData" select="$globalData"/>
|
||||
</xsl:call-template>
|
||||
</xsl:element>
|
||||
</xsl:when>
|
||||
<xsl:when test="function-available('xt:node-set')">
|
||||
<xsl:variable name="tabNodePositions" select="xt:node-set($testNo-RTF)"/>
|
||||
<xsl:element namespace="{$namespace}" name="tr">
|
||||
<xsl:call-template name="create-td-elements">
|
||||
<xsl:with-param name="lastNodePosition" select="count($allStyleTabStops/style:tab-stops/style:tab-stop)"/>
|
||||
<xsl:with-param name="position" select="1"/>
|
||||
<xsl:with-param name="allStyleTabStops" select="$allStyleTabStops"/>
|
||||
<xsl:with-param name="tabNodePositions" select="$tabNodePositions"/>
|
||||
<xsl:with-param name="globalData" select="$globalData"/>
|
||||
</xsl:call-template>
|
||||
</xsl:element>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:message terminate="yes">ERROR: Function not found: nodeset</xsl:message>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<!-- Gathering all style:tab-stops from a style-hierarchy as siblings -->
|
||||
<xsl:template name="get-tab-stops">
|
||||
<xsl:param name="globalData"/>
|
||||
<xsl:param name="styleName"/>
|
||||
<xsl:variable name="tabStyle" select="key('styles', $styleName)"/>
|
||||
|
||||
<xsl:if test="$tabStyle/*/style:tab-stops/style:tab-stop/@style:position">
|
||||
<xsl:for-each select="$tabStyle/*/style:tab-stops/style:tab-stop">
|
||||
<xsl:copy-of select="."/>
|
||||
</xsl:for-each>
|
||||
</xsl:if>
|
||||
|
||||
<xsl:if test="$tabStyle/@style:parent-style-name">
|
||||
<xsl:call-template name="get-tab-stops">
|
||||
<xsl:with-param name="globalData" select="$globalData"/>
|
||||
<xsl:with-param name="styleName" select="$tabStyle/@style:parent-style-name"/>
|
||||
</xsl:call-template>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="create-col-element">
|
||||
<xsl:param name="lastNodePosition"/>
|
||||
<xsl:param name="allStyleTabStops"/>
|
||||
|
||||
<xsl:for-each select="$allStyleTabStops/style:tab-stops/style:tab-stop">
|
||||
<xsl:element namespace="{$namespace}" name="col">
|
||||
<xsl:attribute name="style">
|
||||
<xsl:text>width: </xsl:text>
|
||||
<xsl:choose>
|
||||
<xsl:when test="contains(@style:position, 'cm')">
|
||||
<xsl:call-template name="create-cell-width">
|
||||
<xsl:with-param name="width" select="number(substring-before(@style:position,'cm'))"/>
|
||||
<xsl:with-param name="unit" select="'cm'"/>
|
||||
<xsl:with-param name="position" select="position() - 1"/>
|
||||
<xsl:with-param name="allStyleTabStops" select="$allStyleTabStops"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="contains(@style:position, 'in')">
|
||||
<xsl:call-template name="create-cell-width">
|
||||
<xsl:with-param name="width" select="number(substring-before(@style:position,'in'))"/>
|
||||
<xsl:with-param name="unit" select="'in'"/>
|
||||
<xsl:with-param name="position" select="position() - 1"/>
|
||||
<xsl:with-param name="allStyleTabStops" select="$allStyleTabStops"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="contains(@style:position, 'ch')">
|
||||
<xsl:call-template name="create-cell-width">
|
||||
<xsl:with-param name="width" select="number(substring-before(@style:position,'ch'))"/>
|
||||
<xsl:with-param name="unit" select="'ch'"/>
|
||||
<xsl:with-param name="position" select="position() - 1"/>
|
||||
<xsl:with-param name="allStyleTabStops" select="$allStyleTabStops"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="contains(@style:position, 'pt')">
|
||||
<xsl:call-template name="create-cell-width">
|
||||
<xsl:with-param name="width" select="number(substring-before(@style:position,'pt'))"/>
|
||||
<xsl:with-param name="unit" select="'pt'"/>
|
||||
<xsl:with-param name="position" select="position() - 1"/>
|
||||
<xsl:with-param name="allStyleTabStops" select="$allStyleTabStops"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
|
||||
</xsl:attribute>
|
||||
</xsl:element>
|
||||
</xsl:for-each>
|
||||
|
||||
</xsl:template>
|
||||
<!--
|
||||
Scenarios tabstops
|
||||
|
||||
1) style:type of style:tab-stop is 'right' and earlier tabStop is not right
|
||||
-> Earlier text-nodes and following text-nodes, will be put into an inner table, with two TD first aligned left, with preceding textnodes, the latter aligned right.
|
||||
|
||||
2) style:type is 'right' and earlier tabStop is right
|
||||
-> following text-nodes, will be put into a right aligned TD
|
||||
|
||||
3) style:type is 'non-right' and earlier tabStop 'non-right' as well
|
||||
-> put the preceding tab stops into a TD (left aligned is default)
|
||||
|
||||
4) first style:type would have no right preceding tabStop
|
||||
-> works well with first scenarios 1 and 3
|
||||
|
||||
5) last style:type would be a special case, if it would be left aligned, but this won't happen in our case... :D
|
||||
|
||||
Scenarios unmatched:
|
||||
- text:styleposition 'center' will not be matched in our case (effort for nothing), there will be only 'right' and not 'right'
|
||||
- If the last tabStop is not from text:styleposition 'right', the length of the last cell is undefined and a document length must be found.
|
||||
Not happens in our master document case. Also the algorithm below would have to be expanded (cp. scenario 5).
|
||||
|
||||
-->
|
||||
<xsl:template name="create-td-elements">
|
||||
<xsl:param name="globalData"/>
|
||||
<xsl:param name="lastNodePosition"/>
|
||||
<xsl:param name="position"/>
|
||||
<xsl:param name="allStyleTabStops"/>
|
||||
<xsl:param name="tabNodePositions"/>
|
||||
|
||||
<xsl:variable name="currentTabStop" select="$allStyleTabStops/style:tab-stops/style:tab-stop[$position]"/>
|
||||
<xsl:variable name="earlierTabStop" select="$allStyleTabStops/style:tab-stops/style:tab-stop[$position - 1]"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="not($currentTabStop/@style:position) and not($earlierTabStop/@style:position)">
|
||||
<!-- in case no TAB STOP is being set -->
|
||||
<xsl:element namespace="{$namespace}" name="td">
|
||||
<xsl:element namespace="{$namespace}" name="p">
|
||||
<xsl:if test="$position = 1">
|
||||
<xsl:attribute name="class">
|
||||
<xsl:value-of select="translate(@text:style-name, '.,;: %()[]/\+', '_____________')"/>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
<xsl:apply-templates mode="content-table">
|
||||
<xsl:with-param name="globalData" select="$globalData"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:element>
|
||||
</xsl:element>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$currentTabStop/@style:type = 'right'">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$earlierTabStop/@style:type = 'right'">
|
||||
<!--
|
||||
2) style:type is 'right' and earlier tabStop is right
|
||||
-> following text-nodes, will be put into a right aligned TD -->
|
||||
<xsl:element namespace="{$namespace}" name="td">
|
||||
<xsl:attribute name="style">
|
||||
<xsl:text>align: right</xsl:text>
|
||||
</xsl:attribute>
|
||||
<xsl:element namespace="{$namespace}" name="p">
|
||||
<xsl:if test="$position = 1">
|
||||
<xsl:attribute name="class">
|
||||
<xsl:value-of select="translate(@text:style-name, '.,;: %()[]/\+', '_____________')"/>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
<xsl:call-template name="grab-cell-content-before-tab-stop">
|
||||
<xsl:with-param name="globalData" select="$globalData"/>
|
||||
<xsl:with-param name="endingTabStopPosition" select="$position + 1"/>
|
||||
<xsl:with-param name="lastNodePosition" select="$lastNodePosition"/>
|
||||
<xsl:with-param name="tabNodePositions" select="$tabNodePositions"/>
|
||||
</xsl:call-template>
|
||||
</xsl:element>
|
||||
</xsl:element>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:element namespace="{$namespace}" name="td">
|
||||
<xsl:element namespace="{$namespace}" name="p">
|
||||
<xsl:if test="$position = 1">
|
||||
<xsl:attribute name="class">
|
||||
<xsl:value-of select="translate(@text:style-name, '.,;: %()[]/\+', '_____________')"/>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
<xsl:call-template name="grab-cell-content-before-tab-stop">
|
||||
<xsl:with-param name="globalData" select="$globalData"/>
|
||||
<xsl:with-param name="endingTabStopPosition" select="$position"/>
|
||||
<xsl:with-param name="lastNodePosition" select="$lastNodePosition"/>
|
||||
<xsl:with-param name="tabNodePositions" select="$tabNodePositions"/>
|
||||
</xsl:call-template>
|
||||
</xsl:element>
|
||||
</xsl:element>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$earlierTabStop/@style:type = 'right'"></xsl:when>
|
||||
<xsl:otherwise>
|
||||
<!--
|
||||
3) style:type is 'non-right' and earlier tabStop 'non-right' as well
|
||||
-> put the preceding tab stops into a TD (left aligned is default) -->
|
||||
<xsl:element namespace="{$namespace}" name="p">
|
||||
<xsl:if test="$position = 1">
|
||||
<xsl:attribute name="class">
|
||||
<xsl:value-of select="translate(@text:style-name, '.,;: %()[]/\+', '_____________')"/>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
<xsl:element namespace="{$namespace}" name="td">
|
||||
<xsl:call-template name="grab-cell-content-before-tab-stop">
|
||||
<xsl:with-param name="globalData" select="$globalData"/>
|
||||
<xsl:with-param name="endingTabStopPosition" select="$position"/>
|
||||
<xsl:with-param name="lastNodePosition" select="$lastNodePosition"/>
|
||||
<xsl:with-param name="tabNodePositions" select="$tabNodePositions"/>
|
||||
</xsl:call-template>
|
||||
</xsl:element>
|
||||
</xsl:element>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
|
||||
<xsl:if test="$position != $lastNodePosition">
|
||||
<xsl:call-template name="create-td-elements">
|
||||
<xsl:with-param name="globalData" select="$globalData"/>
|
||||
<xsl:with-param name="lastNodePosition" select="$lastNodePosition"/>
|
||||
<xsl:with-param name="position" select="$position + 1"/>
|
||||
<xsl:with-param name="allStyleTabStops" select="$allStyleTabStops"/>
|
||||
<xsl:with-param name="tabNodePositions" select="$tabNodePositions"/>
|
||||
</xsl:call-template>
|
||||
</xsl:if>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="grab-cell-content-before-tab-stop">
|
||||
<xsl:param name="globalData"/>
|
||||
<xsl:param name="endingTabStopPosition"/>
|
||||
<xsl:param name="tabNodePositions"/>
|
||||
<xsl:param name="lastNodePosition"/>
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="$endingTabStopPosition = 1">
|
||||
<xsl:apply-templates mode="content-table" select="node()[position() < $tabNodePositions/tab-stop-node-position[$endingTabStopPosition]]">
|
||||
<xsl:with-param name="globalData" select="$globalData"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:when>
|
||||
<xsl:when test="$endingTabStopPosition > $lastNodePosition">
|
||||
<xsl:apply-templates mode="content-table" select="node()[position() > $tabNodePositions/tab-stop-node-position[$endingTabStopPosition - 1]]">
|
||||
<xsl:with-param name="globalData" select="$globalData"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:variable name="nodesOfNextColumn" select="node()[position() < $tabNodePositions/tab-stop-node-position[$endingTabStopPosition]][position() > $tabNodePositions/tab-stop-node-position[$endingTabStopPosition - 1]]"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$nodesOfNextColumn != ''">
|
||||
<xsl:apply-templates mode="content-table" select="$nodesOfNextColumn">
|
||||
<xsl:with-param name="globalData" select="$globalData"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:apply-templates mode="content-table">
|
||||
<xsl:with-param name="globalData" select="$globalData"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<!-- As the span width will be mapped to column width, the preceding span widths have to be subtracted -->
|
||||
<xsl:template name="create-cell-width">
|
||||
<xsl:param name="width"/>
|
||||
<xsl:param name="unit"/>
|
||||
<xsl:param name="position"/>
|
||||
<xsl:param name="allStyleTabStops"/>
|
||||
|
||||
<xsl:choose>
|
||||
<!-- beyond second width -->
|
||||
<xsl:when test="$position > 1">
|
||||
<xsl:call-template name="create-cell-width">
|
||||
<xsl:with-param name="width" select="$width - number(substring-before($allStyleTabStops/style:tab-stops/style:tab-stop[$position]/@style:position,$unit))"/>
|
||||
<xsl:with-param name="unit" select="$unit"/>
|
||||
<xsl:with-param name="position" select="$position - 1"/>
|
||||
<xsl:with-param name="allStyleTabStops" select="$allStyleTabStops"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<!-- second width -->
|
||||
<xsl:when test="$position = 1">
|
||||
<xsl:value-of select="concat($width - number(substring-before($allStyleTabStops/style:tab-stops/style:tab-stop[$position]/@style:position,$unit)), $unit)"/>
|
||||
</xsl:when>
|
||||
<!-- first width -->
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="concat($width, $unit)"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<!-- ************************************** -->
|
||||
<!-- CREATION OF A CONTENT TABLE LINK -->
|
||||
<!-- ************************************** -->
|
||||
|
||||
<xsl:key name="bookmark" match="text:bookmark | text:bookmark-start" use="@text:name"/>
|
||||
|
||||
<!-- content table link -->
|
||||
<xsl:template match="text:a" mode="content-table">
|
||||
<xsl:param name="globalData"/>
|
||||
|
||||
<xsl:variable name="name" select="substring(@xlink:href,2)"/>
|
||||
|
||||
<xsl:variable name="text">
|
||||
<xsl:choose>
|
||||
<!-- heuristic assumption that first in a content table row, there is numbering (if at all) and then the text,
|
||||
furthermore that a tab will separate the to be neglected page number -->
|
||||
<xsl:when test="text:tab">
|
||||
<xsl:call-template name="write-text-without-line-numbers">
|
||||
<xsl:with-param name="textCount" select="count(text())"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="text()"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
|
||||
<!-- REFERENCE HANDLING - HREF -->
|
||||
<xsl:element namespace="{$namespace}" name="a">
|
||||
<xsl:attribute name="href">
|
||||
<xsl:text>#</xsl:text>
|
||||
<xsl:choose>
|
||||
<xsl:when test="key('bookmark',$name)">
|
||||
<xsl:value-of select="$name"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select='concat("a_", translate(normalize-space($text), "
&<>.,;: %()[]/\+", "_______________________________"))'/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:attribute>
|
||||
<xsl:value-of select="$text"/>
|
||||
</xsl:element>
|
||||
</xsl:template>
|
||||
|
||||
<!-- Heuristic: write out text separated by elements, leaving the last number out (mostly text number) -->
|
||||
<xsl:template name="write-text-without-line-numbers">
|
||||
<xsl:param name="textCount"/>
|
||||
<xsl:param name="textNodeNumber" select="1"/>
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="$textCount > $textNodeNumber">
|
||||
<xsl:value-of select="text()[$textNodeNumber]"/>
|
||||
<xsl:call-template name="write-text-without-line-numbers">
|
||||
<xsl:with-param name="textCount" select="$textCount"/>
|
||||
<xsl:with-param name="textNodeNumber" select="$textNodeNumber + 1"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:if test="not(number(text()[$textNodeNumber]) > -1)">
|
||||
<xsl:value-of select="text()[$textNodeNumber]"/>
|
||||
</xsl:if>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="text:s" mode="content-table">
|
||||
<xsl:call-template name="write-breakable-whitespace">
|
||||
<xsl:with-param name="whitespaces" select="@text:c"/>
|
||||
</xsl:call-template>
|
||||
</xsl:template>
|
||||
|
||||
<!-- ******************** -->
|
||||
<!-- *** Common Rules *** -->
|
||||
<!-- ******************** -->
|
||||
|
||||
<xsl:template match="*" mode="content-table">
|
||||
<xsl:param name="globalData"/>
|
||||
|
||||
<xsl:apply-templates select=".">
|
||||
<xsl:with-param name="globalData" select="$globalData"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="*" mode="cell-content">
|
||||
<xsl:if test="name() = 'text:tab' or *[name() = 'text:tab']">
|
||||
<xsl:element name="tab-stop-node-position" namespace="">
|
||||
<xsl:value-of select="position()"/>
|
||||
</xsl:element>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="text()" mode="content-table">
|
||||
<!-- Heuristic to remove page numbers (useless in HTML) in the content table
|
||||
usually after a tab -->
|
||||
<xsl:if test="name(preceding-sibling::*[1]) != 'text:tab' and not(number() > -1)">
|
||||
<xsl:value-of select="."/>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
||||
@@ -0,0 +1,631 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
* This file is part of the LibreOffice project.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* This file incorporates work covered by the following license notice:
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed
|
||||
* with this work for additional information regarding copyright
|
||||
* ownership. The ASF licenses this file to you under the Apache
|
||||
* License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
||||
-->
|
||||
<xsl:stylesheet version="1.0"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
|
||||
xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0"
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:dom="http://www.w3.org/2001/xml-events"
|
||||
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"
|
||||
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
|
||||
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
|
||||
xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"
|
||||
xmlns:math="http://www.w3.org/1998/Math/MathML"
|
||||
xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0"
|
||||
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
|
||||
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
|
||||
xmlns:ooo="http://openoffice.org/2004/office"
|
||||
xmlns:oooc="http://openoffice.org/2004/calc"
|
||||
xmlns:ooow="http://openoffice.org/2004/writer"
|
||||
xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"
|
||||
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
|
||||
xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
|
||||
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
|
||||
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xmlns:xt="http://www.jclark.com/xt"
|
||||
xmlns:common="http://exslt.org/common"
|
||||
xmlns:xalan="http://xml.apache.org/xalan"
|
||||
xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:c="urn:schemas-microsoft-com:office:component:spreadsheet" xmlns:html="http://www.w3.org/TR/REC-html40" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:x2="http://schemas.microsoft.com/office/excel/2003/xml" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
exclude-result-prefixes="chart config dc dom dr3d draw fo form math meta number office ooo oooc ooow script style svg table text xlink xt common xalan">
|
||||
|
||||
|
||||
<!-- Mapping @table:formula to @ss:Formula translating the expression syntax -->
|
||||
<xsl:template match="@table:formula">
|
||||
<xsl:param name="calculatedCellPosition" />
|
||||
<xsl:param name="calculatedRowPosition" />
|
||||
|
||||
<xsl:attribute name="ss:Formula">
|
||||
<xsl:call-template name="translate-formular-expression">
|
||||
<xsl:with-param name="rowPos" select="$calculatedRowPosition" />
|
||||
<xsl:with-param name="columnPos" select="$calculatedCellPosition" />
|
||||
<xsl:with-param name="expression" select="." />
|
||||
</xsl:call-template>
|
||||
</xsl:attribute>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<!-- Translate OOOC formula expressions of table cells to spreadsheetml expression
|
||||
|
||||
For example:
|
||||
"oooc:=ROUNDDOWN(123.321;2)"
|
||||
to "=ROUNDDOWN(123.321,2)"
|
||||
"oooc:=([.B2]-[.C2])"
|
||||
to "=(RC[-2]-RC[-1])"
|
||||
"oooc:=DCOUNTA([.E14:.F21];[.F14];[.H14:.I15])"
|
||||
to "=DCOUNTA(R[-17]C[3]:R[-10]C[4],R[-17]C[4],R[-17]C[6]:R[-16]C[7])" -->
|
||||
<xsl:template name="translate-formular-expression">
|
||||
<!-- return position or range for formula or other -->
|
||||
<xsl:param name="rowPos" /> <!-- the position in row (vertical) of cell -->
|
||||
<xsl:param name="columnPos" /> <!-- the position in column (horizontal of cell) -->
|
||||
<xsl:param name="expression" /> <!-- the expression string to be converted -->
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="$expression != ''">
|
||||
<xsl:choose>
|
||||
<!-- OASIS Open Document XML formular expressions -->
|
||||
<xsl:when test="starts-with($expression,'oooc:')">
|
||||
<!-- giving out the '=', which will be removed with 'oooc:=' to enable recursive string parsing -->
|
||||
<xsl:text>=</xsl:text>
|
||||
<xsl:call-template name="function-parameter-mapping">
|
||||
<xsl:with-param name="rowPos" select="$rowPos" />
|
||||
<xsl:with-param name="columnPos" select="$columnPos" />
|
||||
<!-- 1) remove 'oooc:=' prefix and exchange ';' with ',' -->
|
||||
<xsl:with-param name="expression" select="translate(substring($expression,7),';',',')"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="$expression" />
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="$expression" />
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<!-- As the function API of our Office and MS Office show differences in the argumentlists,
|
||||
- sometimes the last parameter have to be neglected
|
||||
- sometimes a default have to be added
|
||||
these exchanges have to be done as well -->
|
||||
<xsl:template name="function-parameter-mapping">
|
||||
<xsl:param name="rowPos" /> <!-- the position in row (vertical of cell) -->
|
||||
<xsl:param name="columnPos" /> <!-- the position in column (horizontal of cell) -->
|
||||
<xsl:param name="expression" /> <!-- expression to be exchanged -->
|
||||
|
||||
<!-- Choose if the expression contains one of the function, which might need changes -->
|
||||
<xsl:choose>
|
||||
<!-- if not contain one of the functions, which need parameter mapping -->
|
||||
<xsl:when test="not(contains($expression, 'ADDRESS(') or
|
||||
contains($expression, 'CEILING(') or
|
||||
contains($expression, 'FLOOR(') or
|
||||
contains($expression, 'IF(') or
|
||||
contains($expression, 'ROUND('))">
|
||||
<!-- simply translate possibly existing column & row references -->
|
||||
<xsl:call-template name="translate-oooc-expression">
|
||||
<xsl:with-param name="rowPos" select="$rowPos" />
|
||||
<xsl:with-param name="columnPos" select="$columnPos" />
|
||||
<xsl:with-param name="expression" select="$expression"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<!-- functions to be mapped -->
|
||||
<xsl:otherwise>
|
||||
<xsl:variable name="functionPrefix" select="substring-before($expression, '(')" />
|
||||
<xsl:variable name="expressionSuffix" select="substring-after($expression, '(')" />
|
||||
|
||||
<!-- translate in case the expression contains row/cell references aside of the function name -->
|
||||
<xsl:call-template name="translate-oooc-expression">
|
||||
<xsl:with-param name="rowPos" select="$rowPos" />
|
||||
<xsl:with-param name="columnPos" select="$columnPos" />
|
||||
<xsl:with-param name="expression" select="$functionPrefix"/>
|
||||
</xsl:call-template>
|
||||
<!-- Prefix do not include the bracket -->
|
||||
<xsl:text>(</xsl:text>
|
||||
<xsl:choose>
|
||||
<xsl:when test="not(contains($functionPrefix, 'ADDRESS') or
|
||||
contains($functionPrefix, 'CEILING') or
|
||||
contains($functionPrefix, 'FLOOR') or
|
||||
(contains($functionPrefix, 'IF') and not(
|
||||
contains($functionPrefix, 'COUNTIF') or
|
||||
contains($functionPrefix, 'SUMIF'))) or
|
||||
contains($functionPrefix, 'ROUND'))">
|
||||
<xsl:call-template name="function-parameter-mapping">
|
||||
<xsl:with-param name="rowPos" select="$rowPos" />
|
||||
<xsl:with-param name="columnPos" select="$columnPos" />
|
||||
<xsl:with-param name="expression" select="$expressionSuffix"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:choose>
|
||||
<xsl:when test="contains($functionPrefix, 'ADDRESS')">
|
||||
<xsl:call-template name="find-parameters">
|
||||
<xsl:with-param name="rowPos" select="$rowPos" />
|
||||
<xsl:with-param name="columnPos" select="$columnPos" />
|
||||
<xsl:with-param name="expressionSuffix" select="$expressionSuffix"/>
|
||||
<xsl:with-param name="parameterRemoval" select="4" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="contains($functionPrefix, 'CEILING') or
|
||||
contains($functionPrefix, 'FLOOR')">
|
||||
<xsl:call-template name="find-parameters">
|
||||
<xsl:with-param name="rowPos" select="$rowPos" />
|
||||
<xsl:with-param name="columnPos" select="$columnPos" />
|
||||
<xsl:with-param name="expressionSuffix" select="$expressionSuffix"/>
|
||||
<xsl:with-param name="parameterRemoval" select="3" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="contains($functionPrefix, 'IF')">
|
||||
<xsl:if test="not(contains($functionPrefix, 'COUNTIF') or
|
||||
contains($functionPrefix, 'SUMIF'))">
|
||||
<xsl:call-template name="find-parameters">
|
||||
<xsl:with-param name="rowPos" select="$rowPos" />
|
||||
<xsl:with-param name="columnPos" select="$columnPos" />
|
||||
<xsl:with-param name="expressionSuffix" select="$expressionSuffix"/>
|
||||
<xsl:with-param name="parameterAddition" select="'true'" />
|
||||
<xsl:with-param name="additonAfterLastParameter" select="2" />
|
||||
</xsl:call-template>
|
||||
</xsl:if>
|
||||
</xsl:when>
|
||||
<xsl:when test="contains($functionPrefix, 'ROUND')">
|
||||
<xsl:call-template name="find-parameters">
|
||||
<xsl:with-param name="rowPos" select="$rowPos" />
|
||||
<xsl:with-param name="columnPos" select="$columnPos" />
|
||||
<xsl:with-param name="expressionSuffix" select="$expressionSuffix"/>
|
||||
<xsl:with-param name="parameterAddition" select="'null'" />
|
||||
<xsl:with-param name="additonAfterLastParameter" select="1" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<!-- Each parameter of the argumentlist have to be determined.
|
||||
Due to the low level string functionality in XSLT it becomes a clumsy task -->
|
||||
<xsl:template name="find-parameters">
|
||||
<!-- used for mapping of row/column reference -->
|
||||
<xsl:param name="rowPos" /> <!-- the position in row (vertical of cell) -->
|
||||
<xsl:param name="columnPos" /> <!-- the position in column (horizontal of cell) -->
|
||||
<!-- used for mapping of parameter -->
|
||||
<xsl:param name="parameterRemoval" />
|
||||
<xsl:param name="parameterAddition" />
|
||||
<xsl:param name="additonAfterLastParameter" />
|
||||
<!-- used as helper to find a parameter -->
|
||||
<xsl:param name="expressionSuffix" />
|
||||
<xsl:param name="parameterNumber" select="1" />
|
||||
|
||||
<xsl:variable name="parameter">
|
||||
<xsl:call-template name="getParameter">
|
||||
<xsl:with-param name="expressionSuffix" select="$expressionSuffix"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:choose>
|
||||
<!-- if it is not the last parameter -->
|
||||
<xsl:when test="starts-with(substring-after($expressionSuffix, $parameter), ',')">
|
||||
<!-- searches the argument for functions to be mapped -->
|
||||
<xsl:if test="not($parameterRemoval = $parameterNumber)">
|
||||
<xsl:call-template name="function-parameter-mapping">
|
||||
<xsl:with-param name="rowPos" select="$rowPos" />
|
||||
<xsl:with-param name="columnPos" select="$columnPos" />
|
||||
<xsl:with-param name="expression">
|
||||
<xsl:choose>
|
||||
<!-- in case a character will be removed the preceding won't make a comma -->
|
||||
<xsl:when test="$parameterRemoval = ($parameterNumber + 1)">
|
||||
<xsl:value-of select="$parameter" />
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="concat($parameter, ',')" />
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:with-param>
|
||||
</xsl:call-template>
|
||||
</xsl:if>
|
||||
<!-- searches for the next parameter -->
|
||||
<xsl:call-template name="find-parameters">
|
||||
<xsl:with-param name="rowPos" select="$rowPos" />
|
||||
<xsl:with-param name="columnPos" select="$columnPos" />
|
||||
<xsl:with-param name="expressionSuffix" select="substring-after(substring-after($expressionSuffix, $parameter),',')"/>
|
||||
<xsl:with-param name="parameterAddition" select="$parameterAddition" />
|
||||
<xsl:with-param name="parameterRemoval" select="$parameterRemoval" />
|
||||
<xsl:with-param name="additonAfterLastParameter" select="$additonAfterLastParameter" />
|
||||
<xsl:with-param name="parameterNumber" select="$parameterNumber + 1" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<!-- the last parameter -->
|
||||
<xsl:choose>
|
||||
<xsl:when test="$parameterRemoval = $parameterNumber">
|
||||
<!-- searches the rest of the expression for functions to be mapped -->
|
||||
<xsl:call-template name="function-parameter-mapping">
|
||||
<xsl:with-param name="rowPos" select="$rowPos" />
|
||||
<xsl:with-param name="columnPos" select="$columnPos" />
|
||||
<xsl:with-param name="expression" select="substring-after($expressionSuffix, $parameter)"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="$parameterAddition and ($parameterNumber = $additonAfterLastParameter)">
|
||||
<!-- searches the rest of the expression for functions to be mapped -->
|
||||
<xsl:call-template name="function-parameter-mapping">
|
||||
<xsl:with-param name="rowPos" select="$rowPos" />
|
||||
<xsl:with-param name="columnPos" select="$columnPos" />
|
||||
<xsl:with-param name="expression" select="$parameter" />
|
||||
</xsl:call-template>
|
||||
<!-- searches last parameter and additional parameters for functions to be mapped -->
|
||||
<xsl:call-template name="function-parameter-mapping">
|
||||
<xsl:with-param name="rowPos" select="$rowPos" />
|
||||
<xsl:with-param name="columnPos" select="$columnPos" />
|
||||
<!-- for the final parameter the latter substring is the ')' -->
|
||||
<xsl:with-param name="expression" select="concat(',', $parameterAddition, substring-after($expressionSuffix, $parameter))"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<!-- searches the argument for functions to be mapped -->
|
||||
<xsl:call-template name="function-parameter-mapping">
|
||||
<xsl:with-param name="rowPos" select="$rowPos" />
|
||||
<xsl:with-param name="columnPos" select="$columnPos" />
|
||||
<xsl:with-param name="expression" select="$parameter" />
|
||||
</xsl:call-template>
|
||||
<!-- searches the rest of the expression for functions to be mapped -->
|
||||
<xsl:call-template name="function-parameter-mapping">
|
||||
<xsl:with-param name="rowPos" select="$rowPos" />
|
||||
<xsl:with-param name="columnPos" select="$columnPos" />
|
||||
<xsl:with-param name="expression" select="substring-after($expressionSuffix, $parameter)"/>
|
||||
</xsl:call-template>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="getParameter">
|
||||
<xsl:param name="closingBracketCount" select="0" />
|
||||
<xsl:param name="openingBracketCount" select="0" />
|
||||
<xsl:param name="expressionSuffix" />
|
||||
<xsl:param name="parameterCandidate">
|
||||
<xsl:choose>
|
||||
<!-- if there are multiple parameter -->
|
||||
<xsl:when test="contains(substring-before($expressionSuffix, ')'), ',')">
|
||||
<xsl:value-of select="substring-before($expressionSuffix, ',')"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="substring-before($expressionSuffix, ')')"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:param>
|
||||
<xsl:param name="earlierCandidate" select="$parameterCandidate" />
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="contains($parameterCandidate, '(') or contains($parameterCandidate, ')')">
|
||||
<xsl:choose>
|
||||
<!-- contains only closing bracket(s) -->
|
||||
<xsl:when test="contains($parameterCandidate, '(') and not(contains($parameterCandidate, ')'))">
|
||||
<xsl:call-template name="getParameter">
|
||||
<xsl:with-param name="openingBracketCount" select="$openingBracketCount + 1" />
|
||||
<xsl:with-param name="closingBracketCount" select="$closingBracketCount" />
|
||||
<xsl:with-param name="parameterCandidate" select="substring-after($parameterCandidate, '(')" />
|
||||
<xsl:with-param name="earlierCandidate" select="$earlierCandidate" />
|
||||
<xsl:with-param name="expressionSuffix" select="$expressionSuffix"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<!-- contains only opening bracket(s) -->
|
||||
<xsl:when test="not(contains($parameterCandidate, '(')) and contains($parameterCandidate, ')')">
|
||||
<xsl:call-template name="getParameter">
|
||||
<xsl:with-param name="openingBracketCount" select="$openingBracketCount" />
|
||||
<xsl:with-param name="closingBracketCount" select="$closingBracketCount + 1" />
|
||||
<xsl:with-param name="parameterCandidate" select="substring-after($parameterCandidate, ')')" />
|
||||
<xsl:with-param name="earlierCandidate" select="$earlierCandidate" />
|
||||
<xsl:with-param name="expressionSuffix" select="$expressionSuffix"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:choose>
|
||||
<xsl:when test="string-length(substring-before($parameterCandidate, '(')) <
|
||||
string-length(substring-before($parameterCandidate, ')'))">
|
||||
<xsl:call-template name="getParameter">
|
||||
<xsl:with-param name="openingBracketCount" select="$openingBracketCount + 1" />
|
||||
<xsl:with-param name="closingBracketCount" select="$closingBracketCount" />
|
||||
<xsl:with-param name="parameterCandidate" select="substring-after($parameterCandidate, '(')" />
|
||||
<xsl:with-param name="earlierCandidate" select="$earlierCandidate" />
|
||||
<xsl:with-param name="expressionSuffix" select="$expressionSuffix"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:call-template name="getParameter">
|
||||
<xsl:with-param name="openingBracketCount" select="$openingBracketCount" />
|
||||
<xsl:with-param name="closingBracketCount" select="$closingBracketCount + 1" />
|
||||
<xsl:with-param name="parameterCandidate" select="substring-after($parameterCandidate, ')')" />
|
||||
<xsl:with-param name="earlierCandidate" select="$earlierCandidate" />
|
||||
<xsl:with-param name="expressionSuffix" select="$expressionSuffix"/>
|
||||
</xsl:call-template>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$openingBracketCount = $closingBracketCount">
|
||||
<xsl:value-of select="$earlierCandidate" />
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="$earlierCandidate" />
|
||||
<xsl:variable name="parameterCandidate2">
|
||||
<xsl:variable name="formularAfterCandidate" select="substring-after($expressionSuffix, $earlierCandidate)" />
|
||||
<xsl:variable name="parameterTillBracket" select="concat(substring-before($formularAfterCandidate,')'),')')" />
|
||||
<xsl:variable name="parameterTillComma" select="substring-before(substring-after($expressionSuffix, $parameterTillBracket),',')" />
|
||||
<xsl:choose>
|
||||
<xsl:when test="string-length($parameterTillComma) > 0 and
|
||||
not(contains($parameterTillComma, '('))">
|
||||
<xsl:choose>
|
||||
<xsl:when test="starts-with($formularAfterCandidate, ',')">
|
||||
<xsl:value-of select="concat(',',substring-before(substring-after($formularAfterCandidate,','),','))"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="substring-before($formularAfterCandidate,',')"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="$parameterTillBracket"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<xsl:call-template name="getParameter">
|
||||
<xsl:with-param name="closingBracketCount" select="$closingBracketCount" />
|
||||
<xsl:with-param name="openingBracketCount" select="$openingBracketCount" />
|
||||
<xsl:with-param name="parameterCandidate" select="$parameterCandidate2" />
|
||||
<xsl:with-param name="earlierCandidate" select="$parameterCandidate2" />
|
||||
<xsl:with-param name="expressionSuffix" select="$expressionSuffix" />
|
||||
</xsl:call-template>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<!-- Mapping table-cell definitions by exchangomg all table cell definitions:
|
||||
a) a pair of cells e.g. "[.E14:.F21]" to "R[-17]C[3]:R[-10]C[4]"
|
||||
b) a single cell e.g. "[.F14]" to "R[-17]"-->
|
||||
<xsl:template name="translate-oooc-expression">
|
||||
<xsl:param name="rowPos" /> <!-- the position in row (vertical of cell) -->
|
||||
<xsl:param name="columnPos" /> <!-- the position in column (horizontal of cell) -->
|
||||
<xsl:param name="expression" /> <!-- expression to be exchanged -->
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="contains($expression, '[')">
|
||||
|
||||
<!-- Giving out the part before '[.' -->
|
||||
<xsl:value-of select="substring-before($expression, '[')" />
|
||||
|
||||
<!-- Mapping cell definitions
|
||||
1) a pair of cells e.g. "[.E14:.F21]" to "R[-17]C[3]:R[-10]C[4]"
|
||||
2) a single cell e.g. "[.F14]" to "R[-17]"-->
|
||||
<xsl:variable name="remainingExpression" select="substring-after($expression, '[')"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="contains(substring-before($remainingExpression, ']'), ':')">
|
||||
<xsl:call-template name="translate-cell-expression">
|
||||
<xsl:with-param name="rowPos" select="$rowPos" />
|
||||
<xsl:with-param name="columnPos" select="$columnPos" />
|
||||
<xsl:with-param name="expression" select="substring-before($remainingExpression, ':')" />
|
||||
</xsl:call-template>
|
||||
<xsl:value-of select="':'" />
|
||||
<xsl:call-template name="translate-cell-expression">
|
||||
<xsl:with-param name="rowPos" select="$rowPos" />
|
||||
<xsl:with-param name="columnPos" select="$columnPos" />
|
||||
<xsl:with-param name="expression" select="substring-after(substring-before($remainingExpression, ']'), ':')" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:call-template name="translate-cell-expression">
|
||||
<xsl:with-param name="rowPos" select="$rowPos" />
|
||||
<xsl:with-param name="columnPos" select="$columnPos" />
|
||||
<xsl:with-param name="expression" select="substring-before($remainingExpression, ']')" />
|
||||
</xsl:call-template>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:call-template name="translate-oooc-expression">
|
||||
<xsl:with-param name="rowPos" select="$rowPos" />
|
||||
<xsl:with-param name="columnPos" select="$columnPos" />
|
||||
<xsl:with-param name="expression" select="substring-after($remainingExpression,']')"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<!-- Giving out the remaining part -->
|
||||
<xsl:value-of select="$expression" />
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<!-- A cell expression has usually starts with a '.' otherwise it references to a sheet -->
|
||||
<xsl:template name="translate-cell-expression">
|
||||
<xsl:param name="rowPos" /> <!-- the vertical position of the current cell -->
|
||||
<xsl:param name="columnPos" /> <!-- the horizontal position of the current cell -->
|
||||
<xsl:param name="targetRowPos" select="0"/> <!-- the vertical position of the target cell -->
|
||||
<xsl:param name="targetColumnPos" select="0"/> <!-- the horizontal position of the target cell -->
|
||||
<xsl:param name="charPos" select="0"/> <!-- current column position (needed for multiplying) -->
|
||||
<xsl:param name="digitPos" select="0"/> <!-- current row position (needed for multiplying) -->
|
||||
<xsl:param name="expression" /> <!-- expression to be parsed by character -->
|
||||
<xsl:param name="isRow" select="true()"/> <!-- the string (e.g. $D39 is parsed character per character from the back,
|
||||
first the row, later the column is parsed -->
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="starts-with($expression, '.')">
|
||||
<xsl:variable name="expLength" select="string-length($expression)" />
|
||||
<xsl:choose>
|
||||
<!-- parsing from the end, till only the '.' remains -->
|
||||
<xsl:when test="$expLength != 1">
|
||||
<xsl:variable name="token" select="substring($expression, $expLength)" />
|
||||
<xsl:choose>
|
||||
<xsl:when test="$token='0' or $token='1' or $token='2' or $token='3' or $token='4' or $token='5' or $token='6' or $token='7' or $token='8' or $token='9'">
|
||||
<xsl:variable name="multiplier">
|
||||
<xsl:call-template name="calculate-square-numbers">
|
||||
<xsl:with-param name="base" select="10" />
|
||||
<xsl:with-param name="exponent" select="$digitPos"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:call-template name="translate-cell-expression">
|
||||
<xsl:with-param name="columnPos" select="$columnPos" />
|
||||
<xsl:with-param name="rowPos" select="$rowPos" />
|
||||
<xsl:with-param name="targetColumnPos" select="$targetColumnPos" />
|
||||
<xsl:with-param name="targetRowPos" select="$targetRowPos + $multiplier * $token" />
|
||||
<xsl:with-param name="digitPos" select="$digitPos + 1" />
|
||||
<xsl:with-param name="charPos" select="$charPos" />
|
||||
<!-- removing the last character-->
|
||||
<xsl:with-param name="expression" select="substring($expression, 1, $expLength - 1)" />
|
||||
<xsl:with-param name="isRow" select="true()" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="$token = '$'">
|
||||
<xsl:choose>
|
||||
<!-- if this is the first '$' after '.' (column-->
|
||||
<xsl:when test="$expLength = 2">
|
||||
<xsl:text>C</xsl:text><xsl:value-of select="$targetColumnPos"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:text>R</xsl:text><xsl:value-of select="$targetRowPos"/>
|
||||
<xsl:call-template name="translate-cell-expression">
|
||||
<xsl:with-param name="columnPos" select="$columnPos" />
|
||||
<xsl:with-param name="rowPos" select="$rowPos" />
|
||||
<xsl:with-param name="targetColumnPos" select="$targetColumnPos" />
|
||||
<xsl:with-param name="targetRowPos" select="$targetRowPos" />
|
||||
<xsl:with-param name="charPos" select="$charPos" />
|
||||
<!-- removing the last character-->
|
||||
<xsl:with-param name="expression" select="substring($expression, 1, $expLength - 1)" />
|
||||
<xsl:with-param name="isRow" select="false()" />
|
||||
</xsl:call-template>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<!-- in case of a letter -->
|
||||
<xsl:otherwise>
|
||||
<xsl:if test="$isRow">
|
||||
<xsl:text>R</xsl:text>
|
||||
<xsl:if test="$targetRowPos != $rowPos">
|
||||
<xsl:text>[</xsl:text><xsl:value-of select="$targetRowPos - $rowPos"/><xsl:text>]</xsl:text>
|
||||
</xsl:if>
|
||||
</xsl:if>
|
||||
<xsl:variable name="multiplier">
|
||||
<xsl:call-template name="calculate-square-numbers">
|
||||
<xsl:with-param name="base" select="26" />
|
||||
<xsl:with-param name="exponent" select="$charPos"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="tokenNumber">
|
||||
<xsl:call-template name="character-to-number">
|
||||
<xsl:with-param name="character" select="$token" />
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:call-template name="translate-cell-expression">
|
||||
<xsl:with-param name="columnPos" select="$columnPos" />
|
||||
<xsl:with-param name="rowPos" select="$rowPos" />
|
||||
<xsl:with-param name="targetColumnPos" select="$targetColumnPos + $multiplier * $tokenNumber" />
|
||||
<xsl:with-param name="targetRowPos" select="$targetRowPos" />
|
||||
<xsl:with-param name="digitPos" select="$digitPos" />
|
||||
<xsl:with-param name="charPos" select="$charPos + 1" />
|
||||
<!-- removing the last character-->
|
||||
<xsl:with-param name="expression" select="substring($expression, 1, $expLength - 1)" />
|
||||
<xsl:with-param name="isRow" select="false()" />
|
||||
</xsl:call-template>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:text>C</xsl:text>
|
||||
<xsl:if test="$targetColumnPos != $columnPos">
|
||||
<xsl:text>[</xsl:text><xsl:value-of select="$targetColumnPos - $columnPos"/><xsl:text>]</xsl:text>
|
||||
</xsl:if>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:variable name="sheetName" select="substring-before($expression, '.')" />
|
||||
<xsl:value-of select="$sheetName"/><xsl:text>!</xsl:text>
|
||||
<xsl:call-template name="translate-cell-expression">
|
||||
<xsl:with-param name="rowPos" select="$rowPos" />
|
||||
<xsl:with-param name="columnPos" select="$columnPos" />
|
||||
<xsl:with-param name="expression" select="substring-after($expression, $sheetName)" />
|
||||
</xsl:call-template>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template name="calculate-square-numbers">
|
||||
<xsl:param name="base" />
|
||||
<xsl:param name="exponent" />
|
||||
<xsl:param name="return" select="1" />
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="$exponent > '1'">
|
||||
<xsl:call-template name="calculate-square-numbers">
|
||||
<xsl:with-param name="base" select="$base" />
|
||||
<xsl:with-param name="exponent" select="$exponent - 1"/>
|
||||
<xsl:with-param name="return" select="$return * $base" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="$exponent = '1'">
|
||||
<xsl:value-of select="$return * $base"/>
|
||||
</xsl:when>
|
||||
<!-- if exponent is equal '0' -->
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="1"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template name="character-to-number">
|
||||
<xsl:param name="character" />
|
||||
<xsl:choose>
|
||||
<xsl:when test="$character = 'A'">1</xsl:when>
|
||||
<xsl:when test="$character = 'B'">2</xsl:when>
|
||||
<xsl:when test="$character = 'C'">3</xsl:when>
|
||||
<xsl:when test="$character = 'D'">4</xsl:when>
|
||||
<xsl:when test="$character = 'E'">5</xsl:when>
|
||||
<xsl:when test="$character = 'F'">6</xsl:when>
|
||||
<xsl:when test="$character = 'G'">7</xsl:when>
|
||||
<xsl:when test="$character = 'H'">8</xsl:when>
|
||||
<xsl:when test="$character = 'I'">9</xsl:when>
|
||||
<xsl:when test="$character = 'J'">10</xsl:when>
|
||||
<xsl:when test="$character = 'K'">11</xsl:when>
|
||||
<xsl:when test="$character = 'L'">12</xsl:when>
|
||||
<xsl:when test="$character = 'M'">13</xsl:when>
|
||||
<xsl:when test="$character = 'N'">14</xsl:when>
|
||||
<xsl:when test="$character = 'O'">15</xsl:when>
|
||||
<xsl:when test="$character = 'P'">16</xsl:when>
|
||||
<xsl:when test="$character = 'Q'">17</xsl:when>
|
||||
<xsl:when test="$character = 'R'">18</xsl:when>
|
||||
<xsl:when test="$character = 'S'">19</xsl:when>
|
||||
<xsl:when test="$character = 'T'">20</xsl:when>
|
||||
<xsl:when test="$character = 'U'">21</xsl:when>
|
||||
<xsl:when test="$character = 'V'">22</xsl:when>
|
||||
<xsl:when test="$character = 'W'">23</xsl:when>
|
||||
<xsl:when test="$character = 'X'">24</xsl:when>
|
||||
<xsl:when test="$character = 'Y'">25</xsl:when>
|
||||
<xsl:when test="$character = 'Z'">26</xsl:when>
|
||||
<xsl:otherwise/>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
||||
@@ -0,0 +1,408 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
* This file is part of the LibreOffice project.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* This file incorporates work covered by the following license notice:
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed
|
||||
* with this work for additional information regarding copyright
|
||||
* ownership. The ASF licenses this file to you under the Apache
|
||||
* License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
||||
-->
|
||||
<xsl:stylesheet version="1.0"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
|
||||
xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0"
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:dom="http://www.w3.org/2001/xml-events"
|
||||
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"
|
||||
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
|
||||
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
|
||||
xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"
|
||||
xmlns:math="http://www.w3.org/1998/Math/MathML"
|
||||
xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0"
|
||||
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
|
||||
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
|
||||
xmlns:ooo="http://openoffice.org/2004/office"
|
||||
xmlns:oooc="http://openoffice.org/2004/calc"
|
||||
xmlns:ooow="http://openoffice.org/2004/writer"
|
||||
xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"
|
||||
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
|
||||
xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
|
||||
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
|
||||
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:c="urn:schemas-microsoft-com:office:component:spreadsheet" xmlns:html="http://www.w3.org/TR/REC-html40" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:x2="http://schemas.microsoft.com/office/excel/2003/xml" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
exclude-result-prefixes="chart config dc dom dr3d draw fo form math meta number office ooo oooc ooow script style svg table text xlink">
|
||||
|
||||
|
||||
<!--+++++ INCLUDED XSL MODULES +++++-->
|
||||
|
||||
<!-- helper collection, to convert measures (e.g. inch to pixel using DPI (dots per inch) parameter)-->
|
||||
<xsl:import href="../../common/measure_conversion.xsl" />
|
||||
|
||||
<!-- excel table handling -->
|
||||
<xsl:include href="table.xsl" />
|
||||
|
||||
<!-- mapping rules of office style properties to Excel style properties -->
|
||||
<xsl:include href="style_mapping.xsl" />
|
||||
|
||||
<!-- creating the Excel styles element -->
|
||||
<xsl:include href="styles.xsl" />
|
||||
|
||||
<!-- mapping formular Expressions -->
|
||||
<xsl:include href="formular.xsl" />
|
||||
|
||||
<xsl:output method = "xml"
|
||||
indent = "no"
|
||||
encoding = "UTF-8"
|
||||
omit-xml-declaration = "no" />
|
||||
|
||||
<xsl:strip-space elements="ss:Data html:Data" />
|
||||
|
||||
|
||||
<!-- common table handling -->
|
||||
<xsl:variable name="namespace" select="'urn:schemas-microsoft-com:office:spreadsheet'" />
|
||||
|
||||
<!--+++++ PARAMETER SECTION +++++-->
|
||||
|
||||
<!-- OPTIONAL: (MANDATORY: for all input document with relative external links): parameter is a (relative) URL to the target directory.
|
||||
Relative links from the office document (e.g. to external graphics) will get this parameter as a prefix -->
|
||||
<xsl:param name="targetBaseURL" select="'./'" />
|
||||
|
||||
<!-- OPTIONAL: (MANDATORY: for input document with relative internal links)
|
||||
To access contents of an office file (content like the meta.xml, styles.xml file or graphics) a URL could be chosen.
|
||||
This could be even a JAR URL. The sourceBase of the content URL "jar:file:/C:/temp/Test.sxw!/content.xml" would be
|
||||
"jar:file:/C:/temp/Test.sxw!/" for example.
|
||||
When working with OpenOffice API a Package-URL encoded over HTTP can be used to access the jared contents of the jared document. -->
|
||||
<xsl:param name="sourceBaseURL" select="'./'" />
|
||||
|
||||
<!-- OPTIONAL: (MANDATORY: for session management by URL rewriting)
|
||||
Useful for WebApplications: if a HTTP session is not cookie based, URL rewriting is being used (the session is appended to the URL).
|
||||
This URL session is used for example when links to graphics are created by XSLT. Otherwise the user has to log again in for every graphic he likes to see. -->
|
||||
<xsl:param name="optionalURLSuffix" />
|
||||
|
||||
<!-- OPTIONAL: URL to office meta file (flat xml use the URL to the input file) -->
|
||||
<xsl:param name="metaFileURL" />
|
||||
|
||||
<!-- OPTIONAL: URL to office meta file (flat xml use the URL to the input file) -->
|
||||
<xsl:param name="stylesFileURL" />
|
||||
|
||||
<!-- OPTIONAL: in case of using a different processor than a JAVA XSLT, you can unable the Java functionality
|
||||
(e.g. encoding chapter names for the content-table as href and anchors ) -->
|
||||
<xsl:param name="java" select="true()" />
|
||||
<xsl:param name="javaEnabled" select="boolean($java)" />
|
||||
|
||||
<!-- OPTIONAL: for activating the debug mode set the variable here to 'true()' or give any value from outside -->
|
||||
<xsl:param name="debug" select="false()" />
|
||||
<xsl:param name="debugEnabled" select="boolean($debug)" />
|
||||
|
||||
<!-- matching configuration entries -->
|
||||
<xsl:key name="config" use="@config:name"
|
||||
match="/*/office:settings/config:config-item-set/config:config-item-map-indexed/config:config-item-map-entry/config:config-item |
|
||||
/*/office:settings/config:config-item-set/config:config-item-map-indexed/config:config-item-map-entry/config:config-item-map-named/config:config-item-map-entry/config:config-item" />
|
||||
|
||||
<xsl:key name="colors" match="/*/office:styles//@*[name() = 'fo:background-color' or name() = 'fo:color'] |
|
||||
/*/office:automatic-styles//@*[name() = 'fo:background-color' or name() = 'fo:color']" use="/" />
|
||||
<xsl:key name="colorRGB" match="@fo:background-color | @fo:color" use="." />
|
||||
<!-- *************************** -->
|
||||
<!-- *** Built up Excel file *** -->
|
||||
<!-- *************************** -->
|
||||
<xsl:template match="/">
|
||||
<xsl:processing-instruction name="mso-application">progid="Excel.Sheet"</xsl:processing-instruction>
|
||||
<!-- Note: for debugging purpose include schema location
|
||||
<Workbook xsi:schemaLocation="urn:schemas-microsoft-com:office:spreadsheet <YOUR_SCHEMA_URL>/excelss.xsd"> -->
|
||||
<Workbook>
|
||||
<!-- adding some default settings -->
|
||||
<OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office">
|
||||
<Colors>
|
||||
<xsl:for-each select="key('colors', /)
|
||||
[generate-id(.) =
|
||||
generate-id(key('colorRGB', .)[1]) and starts-with(., '#')] ">
|
||||
<xsl:sort select="." />
|
||||
<Color>
|
||||
<Index><xsl:value-of select="position() + 2" /></Index>
|
||||
<RGB><xsl:value-of select="." /></RGB>
|
||||
</Color>
|
||||
</xsl:for-each>
|
||||
<xsl:for-each select="key('config', 'TabColor')[not(.=preceding::config:config-item)]">
|
||||
<xsl:sort select="." />
|
||||
<Color>
|
||||
<Index><xsl:value-of select="56 - position()" /></Index>
|
||||
<RGB>
|
||||
<xsl:call-template name="colordecimal2rgb">
|
||||
<xsl:with-param name="colordecimal" select="."/>
|
||||
</xsl:call-template>
|
||||
</RGB>
|
||||
</Color>
|
||||
</xsl:for-each>
|
||||
</Colors>
|
||||
</OfficeDocumentSettings>
|
||||
<ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
|
||||
<xsl:if test="key('config', 'HasSheetTabs') = 'false'">
|
||||
<xsl:element name="HideWorkbookTabs" />
|
||||
</xsl:if>
|
||||
<WindowHeight>9000</WindowHeight>
|
||||
<WindowWidth>13860</WindowWidth>
|
||||
<WindowTopX>240</WindowTopX>
|
||||
<WindowTopY>75</WindowTopY>
|
||||
<ProtectStructure>False</ProtectStructure>
|
||||
<ProtectWindows>False</ProtectWindows>
|
||||
</ExcelWorkbook>
|
||||
<!-- Note: the following handling will exchange the default, later
|
||||
<x:ExcelWorkbook>
|
||||
<xsl:apply-templates select="table:calculation-settings" />
|
||||
</x:ExcelWorkbook>
|
||||
-->
|
||||
<xsl:element name="Styles">
|
||||
<!-- our application default will not be used for export to Excel
|
||||
<xsl:apply-templates select="/*/office:styles/style:default-style" mode="styles" />-->
|
||||
<xsl:apply-templates select="/*/office:styles/style:style" mode="styles" />
|
||||
<xsl:apply-templates select="/*/office:automatic-styles/style:style" mode="styles" >
|
||||
<xsl:with-param name="isAutomatic" select="true()" />
|
||||
</xsl:apply-templates>
|
||||
</xsl:element>
|
||||
<xsl:apply-templates select="/*/office:body" />
|
||||
</Workbook>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="colordecimal2rgb">
|
||||
<xsl:param name="colordecimal"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$colordecimal <= 16777215 and $colordecimal >= 65536">
|
||||
<xsl:variable name="redValue" select="floor(($colordecimal) div 65536)"/>
|
||||
<xsl:variable name="greenValue" select="floor(($colordecimal - ($redValue*65536)) div 256)"/>
|
||||
<xsl:variable name="blueValue" select="$colordecimal - ($redValue*65536) - ($greenValue*256)"/>
|
||||
<xsl:call-template name="dec_rgb2Hex">
|
||||
<xsl:with-param name="decRedValue" select="$redValue"/>
|
||||
<xsl:with-param name="decGreenValue" select="$greenValue"/>
|
||||
<xsl:with-param name="decBlueValue" select="$blueValue"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="$colordecimal <= 65535 and $colordecimal >= 256">
|
||||
<xsl:variable name="redValue" select="0"/>
|
||||
<xsl:variable name="greenValue" select="$colordecimal div 256"/>
|
||||
<xsl:variable name="blueValue" select="$colordecimal - ($greenValue*256)"/>
|
||||
<xsl:call-template name="dec_rgb2Hex">
|
||||
<xsl:with-param name="decRedValue" select="$redValue"/>
|
||||
<xsl:with-param name="decGreenValue" select="$greenValue"/>
|
||||
<xsl:with-param name="decBlueValue" select="$blueValue"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="$colordecimal <= 255 and $colordecimal >= 0">
|
||||
<xsl:variable name="redValue" select="0"/>
|
||||
<xsl:variable name="greenValue" select="0"/>
|
||||
<xsl:variable name="blueValue" select="$colordecimal"/>
|
||||
<xsl:call-template name="dec_rgb2Hex">
|
||||
<xsl:with-param name="decRedValue" select="$redValue"/>
|
||||
<xsl:with-param name="decGreenValue" select="$greenValue"/>
|
||||
<xsl:with-param name="decBlueValue" select="$blueValue"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise/>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
<xsl:template name="dec_rgb2Hex">
|
||||
<xsl:param name="decRedValue"/>
|
||||
<xsl:param name="decGreenValue"/>
|
||||
<xsl:param name="decBlueValue"/>
|
||||
<xsl:variable name="hexRedValue">
|
||||
<xsl:variable name="tmpHexRedValue">
|
||||
<xsl:call-template name="decimal2hex">
|
||||
<xsl:with-param name="dec-number" select="$decRedValue"/>
|
||||
<xsl:with-param name="last-value" select="'H'"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:choose>
|
||||
<xsl:when test="string-length($tmpHexRedValue) = 1">
|
||||
<xsl:value-of select="concat('0',$tmpHexRedValue)"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="$tmpHexRedValue"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="hexGreenValue">
|
||||
<xsl:variable name="tmpHexGreenValue">
|
||||
<xsl:call-template name="decimal2hex">
|
||||
<xsl:with-param name="dec-number" select="$decGreenValue"/>
|
||||
<xsl:with-param name="last-value" select="'H'"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:choose>
|
||||
<xsl:when test="string-length($tmpHexGreenValue) = 1">
|
||||
<xsl:value-of select="concat('0',$tmpHexGreenValue)"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="$tmpHexGreenValue"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="hexBlueValue">
|
||||
<xsl:variable name="tmpHexBlueValue">
|
||||
<xsl:call-template name="decimal2hex">
|
||||
<xsl:with-param name="dec-number" select="$decBlueValue"/>
|
||||
<xsl:with-param name="last-value" select="'H'"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:choose>
|
||||
<xsl:when test="string-length($tmpHexBlueValue) = 1">
|
||||
<xsl:value-of select="concat('0',$tmpHexBlueValue)"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="$tmpHexBlueValue"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<xsl:value-of select="concat('#',$hexRedValue,$hexGreenValue,$hexBlueValue)"/>
|
||||
</xsl:template>
|
||||
<xsl:template name="decimal2hex">
|
||||
<!-- transforms a decimal number to a hex number,only for two-bit hex(less than 256 in decimal) currently -->
|
||||
<xsl:param name="dec-number"/>
|
||||
<xsl:param name="last-value"/>
|
||||
<xsl:variable name="current-value">
|
||||
<xsl:call-template name="decNumber2hex">
|
||||
<xsl:with-param name="dec-value">
|
||||
<xsl:if test="$dec-number > 15">
|
||||
<xsl:value-of select="floor($dec-number div 16)"/>
|
||||
</xsl:if>
|
||||
<xsl:if test="$dec-number < 16">
|
||||
<xsl:value-of select="$dec-number"/>
|
||||
</xsl:if>
|
||||
</xsl:with-param>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:if test="$dec-number > 15">
|
||||
<xsl:call-template name="decimal2hex">
|
||||
<xsl:with-param name="dec-number" select="$dec-number mod 16"/>
|
||||
<xsl:with-param name="last-value" select="concat($last-value,$current-value)"/>
|
||||
</xsl:call-template>
|
||||
</xsl:if>
|
||||
<xsl:if test="$dec-number < 16">
|
||||
<xsl:value-of select="substring-after(concat($last-value,$current-value),'H')"/>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="decNumber2hex">
|
||||
<!-- return a hex number for a decimal character -->
|
||||
<xsl:param name="dec-value"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$dec-value = 10">
|
||||
<xsl:value-of select="'A'"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$dec-value = 11">
|
||||
<xsl:value-of select="'B'"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$dec-value = 12">
|
||||
<xsl:value-of select="'C'"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$dec-value = 13">
|
||||
<xsl:value-of select="'D'"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$dec-value = 14">
|
||||
<xsl:value-of select="'E'"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$dec-value = 15">
|
||||
<xsl:value-of select="'F'"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="$dec-value"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
<xsl:template name="GetTabColorIndex">
|
||||
<xsl:param name="SheetColor"/>
|
||||
<xsl:for-each select="key('config', 'TabColor')[not(.=preceding::config:config-item)]">
|
||||
<xsl:sort select="." />
|
||||
<xsl:variable name="tmpColor" select="."/>
|
||||
<xsl:if test=". = $SheetColor" >
|
||||
<xsl:value-of select="56 - position()"/>
|
||||
</xsl:if>
|
||||
</xsl:for-each>
|
||||
</xsl:template>
|
||||
<xsl:template match="office:body">
|
||||
<!-- office:body table:table children are spreadsheets -->
|
||||
<xsl:apply-templates />
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="office:spreadsheet">
|
||||
<xsl:apply-templates />
|
||||
</xsl:template>
|
||||
|
||||
<!-- office:body table:table children are spreadsheets -->
|
||||
<xsl:template match="office:spreadsheet/table:table">
|
||||
<xsl:element name="ss:Worksheet">
|
||||
<xsl:variable name="TableName">
|
||||
<xsl:value-of select="@table:name" />
|
||||
</xsl:variable>
|
||||
<xsl:attribute name="ss:Name">
|
||||
<xsl:value-of select="$TableName" />
|
||||
</xsl:attribute>
|
||||
<xsl:call-template name="table:table" />
|
||||
<xsl:element name="x:WorksheetOptions">
|
||||
<xsl:if test="key('config', 'ShowGrid') = 'false'">
|
||||
<xsl:element name="x:DoNotDisplayGridlines" />
|
||||
</xsl:if>
|
||||
<xsl:if test="key('config', 'HasColumnRowHeaders') = 'false'">
|
||||
<xsl:element name="x:DoNotDisplayHeadings" />
|
||||
</xsl:if>
|
||||
<xsl:if test="key('config', 'IsOutlineSymbolsSet') = 'false'">
|
||||
<xsl:element name="x:DoNotDisplayOutline" />
|
||||
</xsl:if>
|
||||
<xsl:if test="key('config', 'ShowZeroValues') = 'false'">
|
||||
<xsl:element name="x:DoNotDisplayZeros" />
|
||||
</xsl:if>
|
||||
<xsl:if test="/*/office:settings/config:config-item-set/config:config-item-map-indexed/config:config-item-map-entry/config:config-item-map-named/config:config-item-map-entry[@config:name=$TableName]/config:config-item[@config:name='TabColor']">
|
||||
<xsl:element name="x:TabColorIndex">
|
||||
<xsl:variable name="TabColorIndex">
|
||||
<xsl:call-template name="GetTabColorIndex">
|
||||
<xsl:with-param name="SheetColor" select="/*/office:settings/config:config-item-set/config:config-item-map-indexed/config:config-item-map-entry/config:config-item-map-named/config:config-item-map-entry[@config:name=$TableName]/config:config-item[@config:name='TabColor']"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:value-of select="$TabColorIndex"/>
|
||||
</xsl:element>
|
||||
</xsl:if>
|
||||
</xsl:element>
|
||||
</xsl:element>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="table:decls" mode="ExcelWorkbook">
|
||||
<xsl:apply-templates mode="ExcelWorkbook" />
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="table:calculation-settings" mode="ExcelWorkbook">
|
||||
<xsl:if test="table:precision-as-shown">
|
||||
<x:PrecisionAsDisplayed/>
|
||||
</xsl:if>
|
||||
<xsl:if test="table:null-date/@office:date-value='1904-01-01'">
|
||||
<x:Date1904/>
|
||||
</xsl:if>
|
||||
<xsl:apply-templates select="table:iteration" />
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="table:iteration" mode="ExcelWorkbook">
|
||||
<xsl:element name="x:ExcelWorkbook">
|
||||
<xsl:if test="@table:status = 'enable'">
|
||||
<x:Iteration/>
|
||||
</xsl:if>
|
||||
<xsl:if test="@table:steps">
|
||||
<xsl:element name="x:MaxIterations">
|
||||
<xsl:value-of select="@table:steps" />
|
||||
</xsl:element>
|
||||
</xsl:if>
|
||||
<xsl:if test="@table:maximum-difference">
|
||||
<xsl:element name="x:MaxChange">
|
||||
<xsl:value-of select="@table:maximum-difference" />
|
||||
</xsl:element>
|
||||
</xsl:if>
|
||||
</xsl:element>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
||||
@@ -0,0 +1,381 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
* This file is part of the LibreOffice project.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* This file incorporates work covered by the following license notice:
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed
|
||||
* with this work for additional information regarding copyright
|
||||
* ownership. The ASF licenses this file to you under the Apache
|
||||
* License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
||||
-->
|
||||
<xsl:stylesheet version="1.0"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
|
||||
xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0"
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:dom="http://www.w3.org/2001/xml-events"
|
||||
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"
|
||||
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
|
||||
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
|
||||
xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"
|
||||
xmlns:math="http://www.w3.org/1998/Math/MathML"
|
||||
xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0"
|
||||
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
|
||||
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
|
||||
xmlns:ooo="http://openoffice.org/2004/office"
|
||||
xmlns:oooc="http://openoffice.org/2004/calc"
|
||||
xmlns:ooow="http://openoffice.org/2004/writer"
|
||||
xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"
|
||||
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
|
||||
xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
|
||||
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
|
||||
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xmlns:xt="http://www.jclark.com/xt"
|
||||
xmlns:common="http://exslt.org/common"
|
||||
xmlns:xalan="http://xml.apache.org/xalan"
|
||||
xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:c="urn:schemas-microsoft-com:office:component:spreadsheet" xmlns:html="http://www.w3.org/TR/REC-html40" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:x2="http://schemas.microsoft.com/office/excel/2003/xml" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
exclude-result-prefixes="chart config dc dom dr3d draw fo form math meta number office ooo oooc ooow script style svg table text xlink xt common xalan">
|
||||
|
||||
<xsl:variable name="namespace-html" select="'http://www.w3.org/TR/REC-html40'" />
|
||||
|
||||
<xsl:template match="@table:style-name | @table:default-cell-style-name">
|
||||
<xsl:if test="not(name() = 'Default')">
|
||||
<xsl:attribute name="ss:StyleID">
|
||||
<xsl:value-of select="." />
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:key match="table:table-cell" name="getCellByStyle" use="@table:style-name"/>
|
||||
<xsl:template match="@table:style-name" mode="table-row">
|
||||
<!-- only row styles used by cells are exported,
|
||||
as usual row style properties are already written as row attributes -->
|
||||
<xsl:if test="key('getCellByStyle', '.')">
|
||||
<xsl:attribute name="ss:StyleID">
|
||||
<xsl:value-of select="." />
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="style-and-contents">
|
||||
<xsl:param name="cellStyleName" />
|
||||
|
||||
<!-- WorkAround of Excel2003 issue:
|
||||
Styles from the CellStyle will not be inherited to HTML content (e.g. Colour style).
|
||||
-->
|
||||
<xsl:choose>
|
||||
<xsl:when test="@text:style-name">
|
||||
<xsl:variable name="styles">
|
||||
<xsl:copy-of select="key('styles', @text:style-name)/*" />
|
||||
<xsl:copy-of select="key('styles', $cellStyleName)/*" />
|
||||
</xsl:variable>
|
||||
<xsl:choose>
|
||||
<xsl:when test="function-available('xalan:nodeset')">
|
||||
<xsl:call-template name="create-nested-format-tags">
|
||||
<xsl:with-param name="styles" select="xalan:nodeset($styles)" />
|
||||
<xsl:with-param name="cellStyleName" select="$cellStyleName" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="function-available('xt:node-set')">
|
||||
<xsl:call-template name="create-nested-format-tags">
|
||||
<xsl:with-param name="styles" select="xt:node-set($styles)" />
|
||||
<xsl:with-param name="cellStyleName" select="$cellStyleName" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="function-available('common:node-set')">
|
||||
<xsl:call-template name="create-nested-format-tags">
|
||||
<xsl:with-param name="styles" select="common:node-set($styles)" />
|
||||
<xsl:with-param name="cellStyleName" select="$cellStyleName" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:message terminate="yes">The required node-set function was not found!</xsl:message>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:when test="@table:style-name">
|
||||
<xsl:variable name="styles">
|
||||
<xsl:copy-of select="key('styles', @text:style-name)/*" />
|
||||
<xsl:copy-of select="key('styles', $cellStyleName)/*" />
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="function-available('xalan:nodeset')">
|
||||
<xsl:call-template name="create-nested-format-tags">
|
||||
<xsl:with-param name="styles" select="xalan:nodeset($styles)" />
|
||||
<xsl:with-param name="cellStyleName" select="$cellStyleName" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="function-available('xt:node-set')">
|
||||
<xsl:call-template name="create-nested-format-tags">
|
||||
<xsl:with-param name="styles" select="xt:node-set($styles)" />
|
||||
<xsl:with-param name="cellStyleName" select="$cellStyleName" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="function-available('common:node-set')">
|
||||
<xsl:call-template name="create-nested-format-tags">
|
||||
<xsl:with-param name="styles" select="common:node-set($styles)" />
|
||||
<xsl:with-param name="cellStyleName" select="$cellStyleName" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:message terminate="yes">The required node-set function was not found!</xsl:message>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:apply-templates>
|
||||
<xsl:with-param name="cellStyleName" select="$cellStyleName" />
|
||||
</xsl:apply-templates>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<!-- *********************************** -->
|
||||
<!-- *** creating nested format tags *** -->
|
||||
<!-- *********************************** -->
|
||||
|
||||
<!-- Bold -->
|
||||
<xsl:template name="create-nested-format-tags">
|
||||
<xsl:param name="styles" />
|
||||
<xsl:param name="cellStyleName" />
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="$styles/*/@fo:font-weight = 'bold' or $styles/*/@fo:font-weight = 'bolder'">
|
||||
<xsl:element namespace="{$namespace-html}" name="B">
|
||||
<xsl:call-template name="italic">
|
||||
<xsl:with-param name="styles" select="$styles" />
|
||||
<xsl:with-param name="cellStyleName" select="$cellStyleName" />
|
||||
</xsl:call-template>
|
||||
</xsl:element>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:call-template name="italic">
|
||||
<xsl:with-param name="styles" select="$styles" />
|
||||
<xsl:with-param name="cellStyleName" select="$cellStyleName" />
|
||||
</xsl:call-template>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<!-- Italic -->
|
||||
<xsl:template name="italic">
|
||||
<xsl:param name="styles" />
|
||||
<xsl:param name="cellStyleName" />
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="$styles/*/@fo:font-style = 'italic' or $styles/*/@fo:font-style = 'oblique'">
|
||||
<xsl:element namespace="{$namespace-html}" name="I">
|
||||
<xsl:call-template name="underline">
|
||||
<xsl:with-param name="styles" select="$styles" />
|
||||
<xsl:with-param name="cellStyleName" select="$cellStyleName" />
|
||||
</xsl:call-template>
|
||||
</xsl:element>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:call-template name="underline">
|
||||
<xsl:with-param name="styles" select="$styles" />
|
||||
<xsl:with-param name="cellStyleName" select="$cellStyleName" />
|
||||
</xsl:call-template>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<!-- Underline -->
|
||||
<xsl:template name="underline">
|
||||
<xsl:param name="styles" />
|
||||
<xsl:param name="cellStyleName" />
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="$styles/*/@style:text-underline-type and not($styles/*/@style:text-underline-type = 'none')">
|
||||
<xsl:element namespace="{$namespace-html}" name="U">
|
||||
<xsl:call-template name="strikethrough">
|
||||
<xsl:with-param name="styles" select="$styles" />
|
||||
<xsl:with-param name="cellStyleName" select="$cellStyleName" />
|
||||
</xsl:call-template>
|
||||
</xsl:element>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:call-template name="strikethrough">
|
||||
<xsl:with-param name="styles" select="$styles" />
|
||||
<xsl:with-param name="cellStyleName" select="$cellStyleName" />
|
||||
</xsl:call-template>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<!-- strikethrough -->
|
||||
<xsl:template name="strikethrough">
|
||||
<xsl:param name="styles" />
|
||||
<xsl:param name="cellStyleName" />
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="$styles/*/@style:text-line-through-style and not($styles/*/@style:text-line-through-style = 'none')">
|
||||
<xsl:element namespace="{$namespace-html}" name="S">
|
||||
<xsl:call-template name="super-subscript">
|
||||
<xsl:with-param name="styles" select="$styles" />
|
||||
<xsl:with-param name="cellStyleName" select="$cellStyleName" />
|
||||
</xsl:call-template>
|
||||
</xsl:element>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:call-template name="super-subscript">
|
||||
<xsl:with-param name="styles" select="$styles" />
|
||||
<xsl:with-param name="cellStyleName" select="$cellStyleName" />
|
||||
</xsl:call-template>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
|
||||
<!-- superscript & subscript -->
|
||||
<xsl:template name="super-subscript">
|
||||
<xsl:param name="styles" />
|
||||
<xsl:param name="cellStyleName" />
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="$styles/*/@style:text-position">
|
||||
<xsl:variable name="textPosition" select="number(substring-before($styles/*/@style:text-position, '% '))" />
|
||||
<xsl:choose>
|
||||
<xsl:when test="$textPosition > 0">
|
||||
<xsl:element namespace="{$namespace-html}" name="Sup">
|
||||
<xsl:call-template name="align">
|
||||
<xsl:with-param name="styles" select="$styles" />
|
||||
<xsl:with-param name="cellStyleName" select="$cellStyleName" />
|
||||
</xsl:call-template>
|
||||
</xsl:element>
|
||||
</xsl:when>
|
||||
<xsl:when test="$textPosition < 0">
|
||||
<xsl:element namespace="{$namespace-html}" name="Sub">
|
||||
<xsl:call-template name="align">
|
||||
<xsl:with-param name="styles" select="$styles" />
|
||||
<xsl:with-param name="cellStyleName" select="$cellStyleName" />
|
||||
</xsl:call-template>
|
||||
</xsl:element>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:call-template name="align">
|
||||
<xsl:with-param name="styles" select="$styles" />
|
||||
<xsl:with-param name="cellStyleName" select="$cellStyleName" />
|
||||
</xsl:call-template>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:call-template name="align">
|
||||
<xsl:with-param name="styles" select="$styles" />
|
||||
<xsl:with-param name="cellStyleName" select="$cellStyleName" />
|
||||
</xsl:call-template>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<!-- Alignment - normally called by strikethrough, but no DIV elements in HTML -->
|
||||
<xsl:template name="align">
|
||||
<xsl:param name="styles" />
|
||||
<xsl:param name="cellStyleName" />
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="$styles/*/@fo:font-align">
|
||||
<xsl:element namespace="{$namespace-html}" name="DIV">
|
||||
<xsl:attribute name="html:style">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$styles/*/@fo:font-align = 'start'">
|
||||
<xsl:text>text-align:left;</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="$styles/*/@fo:font-align = 'end'">
|
||||
<xsl:text>text-align:right;</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:text>text-align:center;</xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:attribute>
|
||||
<xsl:call-template name="font">
|
||||
<xsl:with-param name="styles" select="$styles" />
|
||||
<xsl:with-param name="cellStyleName" select="$cellStyleName" />
|
||||
</xsl:call-template>
|
||||
</xsl:element>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:call-template name="font">
|
||||
<xsl:with-param name="styles" select="$styles" />
|
||||
<xsl:with-param name="cellStyleName" select="$cellStyleName" />
|
||||
</xsl:call-template>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<!-- Font (size and color) -->
|
||||
<xsl:template name="font">
|
||||
<xsl:param name="styles" />
|
||||
<xsl:param name="cellStyleName" />
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="$styles/*/@style:font-name or
|
||||
$styles/*/@fo:font-size or
|
||||
$styles/*/@fo:color">
|
||||
<xsl:element namespace="{$namespace-html}" name="Font">
|
||||
<xsl:if test="$styles/*/@style:font-name">
|
||||
<xsl:attribute name="html:Face">
|
||||
<xsl:value-of select="$styles/*/@style:font-name" />
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
<xsl:if test="$styles/*/@fo:color">
|
||||
<xsl:attribute name="html:Color">
|
||||
<xsl:value-of select="$styles/*/@fo:color" />
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
<xsl:if test="$styles/*/@fo:font-size">
|
||||
<!-- WORKAROUND TO EXCEL2003 issue where nested FONT elements with size attributes result in unloadable documents -->
|
||||
<!-- Only create size attribute if parent do not have already one -->
|
||||
|
||||
<!--<xsl:choose>
|
||||
<xsl:when test="not(key('styles', parent::*/@text:style-name)/*/@fo:font-size)"> -->
|
||||
<xsl:if test="not(key('styles', parent::*/@text:style-name)/*/@fo:font-size)">
|
||||
<xsl:attribute name="html:Size">
|
||||
<xsl:call-template name="convert2pt">
|
||||
<xsl:with-param name="value" select="$styles/*/@fo:font-size" />
|
||||
<xsl:with-param name="cellStyleName" select="$cellStyleName" />
|
||||
</xsl:call-template>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
<!--</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:message>Due Excel issue we have to neglect size from @text:style-name '<xsl:value-of select="@text:style-name"/>'!</xsl:message>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>-->
|
||||
</xsl:if>
|
||||
<!-- get the embedded content -->
|
||||
<xsl:apply-templates>
|
||||
<xsl:with-param name="cellStyleName" select="$cellStyleName" />
|
||||
</xsl:apply-templates>
|
||||
</xsl:element>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<!-- get the embedded content -->
|
||||
<xsl:apply-templates>
|
||||
<xsl:with-param name="cellStyleName" select="$cellStyleName" />
|
||||
</xsl:apply-templates>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
||||
@@ -0,0 +1,686 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
* This file is part of the LibreOffice project.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* This file incorporates work covered by the following license notice:
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed
|
||||
* with this work for additional information regarding copyright
|
||||
* ownership. The ASF licenses this file to you under the Apache
|
||||
* License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
||||
-->
|
||||
<xsl:stylesheet version="1.0"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
|
||||
xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0"
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:dom="http://www.w3.org/2001/xml-events"
|
||||
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"
|
||||
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
|
||||
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
|
||||
xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"
|
||||
xmlns:math="http://www.w3.org/1998/Math/MathML"
|
||||
xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0"
|
||||
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
|
||||
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
|
||||
xmlns:ooo="http://openoffice.org/2004/office"
|
||||
xmlns:oooc="http://openoffice.org/2004/calc"
|
||||
xmlns:ooow="http://openoffice.org/2004/writer"
|
||||
xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"
|
||||
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
|
||||
xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
|
||||
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
|
||||
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xmlns:xt="http://www.jclark.com/xt"
|
||||
xmlns:common="http://exslt.org/common"
|
||||
xmlns:xalan="http://xml.apache.org/xalan"
|
||||
xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:c="urn:schemas-microsoft-com:office:component:spreadsheet" xmlns:html="http://www.w3.org/TR/REC-html40" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:x2="http://schemas.microsoft.com/office/excel/2003/xml" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
exclude-result-prefixes="chart config dc dom dr3d draw fo form math meta number office ooo oooc ooow script style svg table text xlink xt common xalan">
|
||||
|
||||
<!-- Used in case of 'style:map', conditional formatting, where a style references to another -->
|
||||
<xsl:key name="styles" match="/*/office:styles/style:style | /*/office:automatic-styles/style:style" use="@style:name" />
|
||||
<!--
|
||||
Mapping of OOo style:name and style:family to excel ss:ID
|
||||
Styles form style:style map from style:name to ss:Name
|
||||
style:parent-style map to ss:Parent
|
||||
-->
|
||||
<!-- default styles of the application
|
||||
<xsl:template match="style:default-style" mode="styles" >
|
||||
<xsl:call-template name="style:style">
|
||||
<xsl:with-param name="styleName" select="'Default'" />
|
||||
</xsl:call-template>
|
||||
</xsl:template>
|
||||
-->
|
||||
|
||||
<xsl:template match="style:style" mode="styles">
|
||||
<xsl:param name="isAutomatic" />
|
||||
<xsl:param name="styleName" select="@style:name" />
|
||||
<xsl:param name="styleParentName" select="@style:parent-style-name" />
|
||||
|
||||
<!-- only row styles used by cells are exported,
|
||||
as usual row style properties are already exported as row attributes -->
|
||||
<xsl:if test="not(@style:family='table-row') or @style:family='table-row' and key('getCellByStyle', '.')">
|
||||
<xsl:element name="Style">
|
||||
<xsl:attribute name="ss:ID">
|
||||
<!-- neglecting that a style is only unique in conjunction with its family name -->
|
||||
<xsl:value-of select="@style:name" />
|
||||
</xsl:attribute>
|
||||
<xsl:choose>
|
||||
<xsl:when test="not($isAutomatic)">
|
||||
<xsl:choose>
|
||||
<xsl:when test="@style:display-name">
|
||||
<xsl:attribute name="ss:Name"><xsl:value-of select="@style:display-name"/></xsl:attribute>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:attribute name="ss:Name"><xsl:value-of select="@style:name" /></xsl:attribute>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:choose>
|
||||
<!-- when a non-allowed parent style is found
|
||||
(in spreadsheetml no style with ss:Name is able to have a ss:Parent) -->
|
||||
<xsl:when test="@style:parent-style-name">
|
||||
<!-- styles have to be merged (flatting heritance tree) -->
|
||||
<xsl:variable name="stylePropertiesContainer">
|
||||
<xsl:call-template name="merge-all-parent-styles">
|
||||
<xsl:with-param name="currentStyle" select="." />
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:choose>
|
||||
<xsl:when test="function-available('xalan:nodeset')">
|
||||
<xsl:call-template name="write-style-properties">
|
||||
<xsl:with-param name="styleProperties" select="xalan:nodeset($stylePropertiesContainer)/*" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="function-available('common:node-set')">
|
||||
<xsl:call-template name="write-style-properties">
|
||||
<xsl:with-param name="styleProperties" select="common:node-set($stylePropertiesContainer)/*" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="function-available('xt:node-set')">
|
||||
<xsl:call-template name="write-style-properties">
|
||||
<xsl:with-param name="styleProperties" select="xt:node-set($stylePropertiesContainer)/*" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:message terminate="yes">WARNING: The required node set function was not found!</xsl:message>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:call-template name="write-style-properties" />
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<!-- automatic styles are implicit inheriting from a style called 'Default',
|
||||
furthermore nor in spreadsheetml nor in OpenDocument automatic styles are able to inherit from each other -->
|
||||
<xsl:choose>
|
||||
<xsl:when test="@style:parent-style-name and not(@style:parent-style-name = 'Default')">
|
||||
<xsl:attribute name="ss:Parent"><xsl:value-of select="@style:parent-style-name" /></xsl:attribute>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
<xsl:call-template name="write-style-properties" />
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:element>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<!-- resolving the style inheritance by starting from uppermost parent and
|
||||
overriding existing style properties by new found child properties -->
|
||||
<xsl:template name="merge-all-parent-styles">
|
||||
<xsl:param name="currentStyle" />
|
||||
|
||||
<xsl:choose>
|
||||
<!-- in case of a parent, styles have to be merged (flatting heritance tree) -->
|
||||
<xsl:when test="$currentStyle/@style:parent-style-name">
|
||||
<!-- collect parent style properties -->
|
||||
<xsl:variable name="parentStyleContainer">
|
||||
<!-- take a look if the parent style has a parent himself -->
|
||||
<xsl:call-template name="merge-all-parent-styles" >
|
||||
<xsl:with-param name="currentStyle" select="key('styles', $currentStyle/@style:parent-style-name)" />
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:choose>
|
||||
<xsl:when test="function-available('xalan:nodeset')">
|
||||
<xsl:call-template name="merge-style-properties">
|
||||
<xsl:with-param name="childStyleContainer" select="$currentStyle" />
|
||||
<xsl:with-param name="parentStyleContainer" select="xalan:nodeset($parentStyleContainer)" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="function-available('common:node-set')">
|
||||
<xsl:call-template name="merge-style-properties">
|
||||
<xsl:with-param name="childStyleContainer" select="$currentStyle" />
|
||||
<xsl:with-param name="parentStyleContainer" select="common:node-set($parentStyleContainer)" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="function-available('xt:node-set')">
|
||||
<xsl:call-template name="merge-style-properties">
|
||||
<xsl:with-param name="childStyleContainer" select="$currentStyle" />
|
||||
<xsl:with-param name="parentStyleContainer" select="xt:node-set($parentStyleContainer)" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:message terminate="yes">WARNING: The required node-set function was not found!</xsl:message>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<!-- called for top parents (or styles without parents) -->
|
||||
<xsl:otherwise>
|
||||
<xsl:copy-of select="$currentStyle/*"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="merge-style-properties">
|
||||
<xsl:param name="childStyleContainer" />
|
||||
<xsl:param name="parentStyleContainer" />
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="$parentStyleContainer/*">
|
||||
<xsl:apply-templates select="$parentStyleContainer/*" mode="inheritance">
|
||||
<xsl:with-param name="childStyleContainer" select="$childStyleContainer" />
|
||||
</xsl:apply-templates>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:copy-of select="$childStyleContainer/*"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="*" mode="inheritance">
|
||||
<xsl:param name="childStyleContainer" />
|
||||
|
||||
<!-- create an element named equal to the current properties parent element (e.g. style:table-cell-properties) -->
|
||||
<xsl:element name="{name()}" namespace="urn:oasis:names:tc:opendocument:xmlns:style:1.0">
|
||||
<!-- attributes will be automatically replaced -->
|
||||
<xsl:copy-of select="@*" />
|
||||
<xsl:copy-of select="$childStyleContainer/*[name() = name(current() )]/@*"/>
|
||||
|
||||
<!-- elements are not needed yet, will be neglected for simplicity reasons -->
|
||||
</xsl:element>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:key match="/*/office:styles/number:date-style |
|
||||
/*/office:styles/number:time-style |
|
||||
/*/office:styles/number:number-style |
|
||||
/*/office:styles/number:percentage-style |
|
||||
/*/office:styles/number:currency-style |
|
||||
/*/office:automatic-styles/number:date-style |
|
||||
/*/office:automatic-styles/number:time-style |
|
||||
/*/office:automatic-styles/number:number-style |
|
||||
/*/office:automatic-styles/number:percentage-style |
|
||||
/*/office:automatic-styles/number:currency-style" name="number-style" use="@style:name" />
|
||||
|
||||
|
||||
<xsl:template name="write-style-properties">
|
||||
<xsl:param name="styleProperties" select="key('styles', @style:name)/*" />
|
||||
|
||||
<xsl:call-template name="Alignment">
|
||||
<xsl:with-param name="styleProperties" select="$styleProperties" />
|
||||
</xsl:call-template>
|
||||
<xsl:call-template name="Border">
|
||||
<xsl:with-param name="styleProperties" select="$styleProperties" />
|
||||
</xsl:call-template>
|
||||
<xsl:call-template name="Font">
|
||||
<xsl:with-param name="styleProperties" select="$styleProperties" />
|
||||
<xsl:with-param name="styleParentName" select="@style:parent-style-name" />
|
||||
</xsl:call-template>
|
||||
<xsl:call-template name="Interior">
|
||||
<xsl:with-param name="styleProperties" select="$styleProperties" />
|
||||
</xsl:call-template>
|
||||
<xsl:call-template name="NumberFormat">
|
||||
<xsl:with-param name="styleProperties" select="$styleProperties" />
|
||||
</xsl:call-template>
|
||||
</xsl:template>
|
||||
|
||||
<!-- context is element 'style:style' -->
|
||||
<xsl:template name="NumberFormat">
|
||||
<xsl:if test="@style:data-style-name">
|
||||
<xsl:variable name="numberStyleName" select="@style:data-style-name" />
|
||||
<xsl:variable name="numberStyle" select="key('number-style', $numberStyleName)" />
|
||||
|
||||
<xsl:element name="NumberFormat">
|
||||
<xsl:attribute name="ss:Format">
|
||||
<xsl:choose>
|
||||
<xsl:when test="not($numberStyle/node())">
|
||||
<!-- Excel2003sp1 issue: 'General' and 'General Number' is not supported -->
|
||||
<xsl:text>General</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="name($numberStyle) = 'number:number-style'">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$numberStyle/number:scientific-number">
|
||||
<xsl:text>Scientific</xsl:text>
|
||||
</xsl:when>
|
||||
<!-- Excel2003sp1 issue: 'General Number' not supported -->
|
||||
<xsl:when test="$numberStyle/number:number/@number:decimal-places and
|
||||
$numberStyle/number:number/@number:decimal-places='0'">
|
||||
<xsl:text>General</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="$numberStyle/number:text">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$numberStyle/number:text = 'No' or $numberStyle/number:text = 'Nein'">
|
||||
<xsl:text>Yes/No</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="$numberStyle/number:text = 'False' or $numberStyle/number:text = 'Falsch'">
|
||||
<xsl:text>True/False</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="$numberStyle/number:text = 'Off' or $numberStyle/number:text = 'Aus'">
|
||||
<xsl:text>On/Off</xsl:text>
|
||||
</xsl:when>
|
||||
<!-- Excel2003sp1 issue: currency is saved as 'float' -->
|
||||
<xsl:when test="$numberStyle/number:currency-symbol">
|
||||
<xsl:choose>
|
||||
<xsl:when test="contains($numberStyle/number:currency-symbol, '€')">
|
||||
<xsl:text>Euro Currency</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:text>Currency</xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<!-- Excel2003sp1 issue: 'Currency' is saved as 'float' -->
|
||||
<xsl:when test="contains($numberStyle/number:text, '$')">
|
||||
<xsl:text>Currency</xsl:text>
|
||||
</xsl:when>
|
||||
<!-- OASIS XML adaptation -->
|
||||
<xsl:otherwise>
|
||||
<xsl:text>General</xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:when test="$numberStyle/number:grouping">
|
||||
<xsl:text>Standard</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:text>Fixed</xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:when test="name($numberStyle) = 'number:time-style'">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$numberStyle/number:am-pm">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$numberStyle/number:seconds">
|
||||
<xsl:text>Long Time</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:text>Medium Time</xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:text>Short Time</xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:when test="name($numberStyle) = 'number:percentage-style'">
|
||||
<xsl:text>Percent</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="name($numberStyle) = 'number:currency-style'">
|
||||
<xsl:choose>
|
||||
<xsl:when test="contains($numberStyle/number:currency-symbol, '€')">
|
||||
<xsl:text>Euro Currency</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:text>Currency</xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$numberStyle/number:month">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$numberStyle/number:month/@number:textual and
|
||||
$numberStyle/number:month/@number:textual=true()">
|
||||
<xsl:text>Medium Date</xsl:text>
|
||||
<!-- Excel2003 sp1 issue: No difference between 'Long Date' and 'Medium Date' -->
|
||||
</xsl:when>
|
||||
<xsl:when test="$numberStyle/number:hours">
|
||||
<xsl:text>General Date</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="$numberStyle/number:year/@number:style and
|
||||
$numberStyle/number:year/@number:style='long'">
|
||||
<xsl:text>Short Date</xsl:text>
|
||||
</xsl:when>
|
||||
<!-- OASIS XML adaptation -->
|
||||
<xsl:otherwise>
|
||||
<xsl:text>Short Date</xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<!-- OASIS XML adaptation -->
|
||||
<xsl:otherwise>
|
||||
<xsl:text>General</xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:attribute>
|
||||
</xsl:element>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="Alignment">
|
||||
<xsl:param name="styleProperties" />
|
||||
|
||||
<!-- An empty Alignment element, might overwrite parents setting by
|
||||
the default attributes -->
|
||||
<xsl:if test="$styleProperties/@fo:text-align or
|
||||
$styleProperties/@style:vertical-align or
|
||||
$styleProperties/@fo:wrap-option or
|
||||
$styleProperties/@fo:margin-left or
|
||||
$styleProperties/@style:rotation-angle or
|
||||
$styleProperties/@style:direction">
|
||||
<xsl:element name="Alignment">
|
||||
<xsl:if test="$styleProperties/@fo:text-align">
|
||||
<xsl:attribute name="ss:Horizontal">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$styleProperties/@fo:text-align = 'center'">Center</xsl:when>
|
||||
<xsl:when test="$styleProperties/@fo:text-align = 'end'">Right</xsl:when>
|
||||
<xsl:when test="$styleProperties/@fo:text-align = 'justify'">Justify</xsl:when>
|
||||
<xsl:otherwise>Left</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
<xsl:if test="$styleProperties/@style:vertical-align">
|
||||
<xsl:attribute name="ss:Vertical">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$styleProperties/@style:vertical-align = 'top'">Top</xsl:when>
|
||||
<xsl:when test="$styleProperties/@style:vertical-align = 'bottom'">Bottom</xsl:when>
|
||||
<xsl:when test="$styleProperties/@style:vertical-align = 'middle'">Center</xsl:when>
|
||||
<xsl:otherwise>Automatic</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
<xsl:if test="$styleProperties/@fo:wrap-option = 'wrap'">
|
||||
<xsl:attribute name="ss:WrapText">1</xsl:attribute>
|
||||
</xsl:if>
|
||||
<xsl:if test="$styleProperties/@fo:margin-left">
|
||||
<xsl:attribute name="ss:Indent">
|
||||
<xsl:variable name="margin">
|
||||
<xsl:call-template name="convert2pt">
|
||||
<xsl:with-param name="value" select="$styleProperties/@fo:margin-left" />
|
||||
<xsl:with-param name="rounding-factor" select="1" />
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<!-- one ss:Indent is equal to 10 points -->
|
||||
<xsl:value-of select="number($margin) div 10"/>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
<!-- Excel is only able to rotate between 90 and -90 degree (inclusive).
|
||||
Other degrees will be mapped by 180 degrees -->
|
||||
<xsl:if test="$styleProperties/@style:rotation-angle">
|
||||
<xsl:attribute name="ss:Rotate">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$styleProperties/@style:rotation-angle > 90">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$styleProperties/@style:rotation-angle >= 270">
|
||||
<xsl:value-of select="$styleProperties/@style:rotation-angle - 360" />
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="$styleProperties/@style:rotation-angle - 180" />
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:when test="$styleProperties/@style:rotation-angle < -90">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$styleProperties/@style:rotation-angle <= -270">
|
||||
<xsl:value-of select="$styleProperties/@style:rotation-angle + 360" />
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="$styleProperties/@style:rotation-angle + 180" />
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="$styleProperties/@style:rotation-angle" />
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
<xsl:if test="$styleProperties/@style:direction = 'ttb'">
|
||||
<xsl:attribute name="ss:VerticalText">1</xsl:attribute>
|
||||
</xsl:if>
|
||||
</xsl:element>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template name="Border">
|
||||
<xsl:param name="styleProperties" />
|
||||
|
||||
<!-- An empty border element, might overwrite parents setting by
|
||||
the default attributes -->
|
||||
<xsl:if test="$styleProperties/@fo:border or
|
||||
$styleProperties/@fo:border-bottom or
|
||||
$styleProperties/@fo:border-left or
|
||||
$styleProperties/@fo:border-right or
|
||||
$styleProperties/@fo:border-top">
|
||||
<xsl:element name="Borders">
|
||||
<xsl:if test="$styleProperties/@fo:border-bottom and not($styleProperties/@fo:border-bottom = 'none')">
|
||||
<xsl:element name="Border">
|
||||
<xsl:attribute name="ss:Position">Bottom</xsl:attribute>
|
||||
<xsl:call-template name="border-attributes">
|
||||
<xsl:with-param name="border_properties" select="$styleProperties/@fo:border-bottom" />
|
||||
</xsl:call-template>
|
||||
</xsl:element>
|
||||
</xsl:if>
|
||||
<xsl:if test="$styleProperties/@fo:border-left and not($styleProperties/@fo:border-left = 'none')">
|
||||
<xsl:element name="Border">
|
||||
<xsl:attribute name="ss:Position">Left</xsl:attribute>
|
||||
<xsl:call-template name="border-attributes">
|
||||
<xsl:with-param name="border_properties" select="$styleProperties/@fo:border-left" />
|
||||
</xsl:call-template>
|
||||
</xsl:element>
|
||||
</xsl:if>
|
||||
<xsl:if test="$styleProperties/@fo:border-right and not($styleProperties/@fo:border-right = 'none')">
|
||||
<xsl:element name="Border">
|
||||
<xsl:attribute name="ss:Position">Right</xsl:attribute>
|
||||
<xsl:call-template name="border-attributes">
|
||||
<xsl:with-param name="border_properties" select="$styleProperties/@fo:border-right" />
|
||||
</xsl:call-template>
|
||||
</xsl:element>
|
||||
</xsl:if>
|
||||
<xsl:if test="$styleProperties/@fo:border-top and not($styleProperties/@fo:border-top = 'none')">
|
||||
<xsl:element name="Border">
|
||||
<xsl:attribute name="ss:Position">Top</xsl:attribute>
|
||||
<xsl:call-template name="border-attributes">
|
||||
<xsl:with-param name="border_properties" select="$styleProperties/@fo:border-top" />
|
||||
</xsl:call-template>
|
||||
</xsl:element>
|
||||
</xsl:if>
|
||||
<!-- write out all table border -->
|
||||
<xsl:if test="$styleProperties/@fo:border and not($styleProperties/@fo:border = 'none')">
|
||||
<xsl:element name="Border">
|
||||
<xsl:attribute name="ss:Position">Bottom</xsl:attribute>
|
||||
<xsl:call-template name="border-attributes">
|
||||
<xsl:with-param name="border_properties" select="$styleProperties/@fo:border" />
|
||||
</xsl:call-template>
|
||||
</xsl:element>
|
||||
<xsl:element name="Border">
|
||||
<xsl:attribute name="ss:Position">Left</xsl:attribute>
|
||||
<xsl:call-template name="border-attributes">
|
||||
<xsl:with-param name="border_properties" select="$styleProperties/@fo:border" />
|
||||
</xsl:call-template>
|
||||
</xsl:element>
|
||||
<xsl:element name="Border">
|
||||
<xsl:attribute name="ss:Position">Right</xsl:attribute>
|
||||
<xsl:call-template name="border-attributes">
|
||||
<xsl:with-param name="border_properties" select="$styleProperties/@fo:border" />
|
||||
</xsl:call-template>
|
||||
</xsl:element>
|
||||
<xsl:element name="Border">
|
||||
<xsl:attribute name="ss:Position">Top</xsl:attribute>
|
||||
<xsl:call-template name="border-attributes">
|
||||
<xsl:with-param name="border_properties" select="$styleProperties/@fo:border" />
|
||||
</xsl:call-template>
|
||||
</xsl:element>
|
||||
</xsl:if>
|
||||
</xsl:element>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template name="border-attributes">
|
||||
<xsl:param name="border_properties" />
|
||||
|
||||
<xsl:variable name="border-width">
|
||||
<xsl:call-template name="convert2cm">
|
||||
<xsl:with-param name="value" select="substring-before($border_properties, ' ')" />
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="border-style" select="substring-before(substring-after($border_properties, ' '), ' ')" />
|
||||
<xsl:variable name="border-color" select="substring-after(substring-after($border_properties, ' '), ' ')" />
|
||||
<!--
|
||||
<xsl:message>border-width:<xsl:value-of select="$border-width" /></xsl:message>
|
||||
<xsl:message>border-style:<xsl:value-of select="$border-style" /></xsl:message>
|
||||
<xsl:message>border-color:<xsl:value-of select="$border-color" /></xsl:message>
|
||||
-->
|
||||
|
||||
<!-- Dash, Dot, DashDot, DashDotDot, SlantDashDot are not supported yet -->
|
||||
<xsl:attribute name="ss:LineStyle">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$border-style = 'none'">None</xsl:when>
|
||||
<xsl:when test="$border-style = 'double'">Double</xsl:when>
|
||||
<xsl:otherwise>Continuous</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:attribute>
|
||||
|
||||
<xsl:attribute name="ss:Weight">
|
||||
<xsl:choose>
|
||||
<!-- 0: Hairline -->
|
||||
<xsl:when test="$border-width <= 0.002">0</xsl:when>
|
||||
<!-- 1: Thin -->
|
||||
<xsl:when test="$border-width <= 0.035">1</xsl:when>
|
||||
<!-- 2: Medium -->
|
||||
<xsl:when test="$border-width <= 0.088">2</xsl:when>
|
||||
<!-- 3: Thick -->
|
||||
<xsl:otherwise>3</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:attribute>
|
||||
|
||||
<xsl:attribute name="ss:Color">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$border-color"><xsl:value-of select="$border-color" /></xsl:when>
|
||||
<xsl:otherwise>Automatic</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:attribute>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template name="Font">
|
||||
<xsl:param name="styleProperties" />
|
||||
<xsl:param name="styleParentName" />
|
||||
|
||||
<!-- An empty font element, might overwrite parents setting by
|
||||
the default attributes -->
|
||||
<xsl:if test="$styleProperties/@style:font-weight or
|
||||
$styleProperties/@fo:color or
|
||||
$styleProperties/@style:font-name or
|
||||
$styleProperties/@fo:font-style or
|
||||
$styleProperties/@style:text-outline or
|
||||
$styleProperties/@style:text-shadow or
|
||||
$styleProperties/@style:font-size or
|
||||
$styleProperties/@style:text-line-through-style or
|
||||
$styleProperties/@style:text-underline-type or
|
||||
$styleProperties/@style:text-underline-style or
|
||||
$styleProperties/@style:text-position">
|
||||
|
||||
|
||||
<xsl:element name="Font">
|
||||
<xsl:call-template name="getParentBold">
|
||||
<xsl:with-param name="styleProperties" select="$styleProperties" />
|
||||
<xsl:with-param name="styleParentName" select="$styleParentName" />
|
||||
</xsl:call-template>
|
||||
<xsl:if test="$styleProperties/@fo:color">
|
||||
<xsl:attribute name="ss:Color"><xsl:value-of select="$styleProperties/@fo:color" /></xsl:attribute>
|
||||
</xsl:if>
|
||||
<xsl:if test="$styleProperties/@style:font-name">
|
||||
<xsl:attribute name="ss:FontName"><xsl:value-of select="$styleProperties/@style:font-name" /></xsl:attribute>
|
||||
</xsl:if>
|
||||
<xsl:if test="$styleProperties/@fo:font-style = 'italic'">
|
||||
<xsl:attribute name="ss:Italic">1</xsl:attribute>
|
||||
</xsl:if>
|
||||
<xsl:if test="$styleProperties/@style:text-outline = 'true'">
|
||||
<xsl:attribute name="ss:Outline">1</xsl:attribute>
|
||||
</xsl:if>
|
||||
<xsl:if test="$styleProperties/@style:text-shadow = 'shadow'">
|
||||
<xsl:attribute name="ss:Shadow">1</xsl:attribute>
|
||||
</xsl:if>
|
||||
<xsl:if test="$styleProperties/@fo:font-size">
|
||||
<xsl:attribute name="ss:Size">
|
||||
<xsl:call-template name="convert2pt">
|
||||
<xsl:with-param name="value" select="$styleProperties/@fo:font-size" />
|
||||
</xsl:call-template>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
<xsl:if test="$styleProperties/@style:text-line-through-style and $styleProperties/@style:text-line-through-style != 'none'">
|
||||
<xsl:attribute name="ss:StrikeThrough">1</xsl:attribute>
|
||||
</xsl:if>
|
||||
<xsl:if test="($styleProperties/@style:text-underline-type and $styleProperties/@style:text-underline-type != 'none') or
|
||||
($styleProperties/@style:text-underline-style and $styleProperties/@style:text-underline-style != 'none')">
|
||||
<xsl:attribute name="ss:Underline">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$styleProperties/@style:text-underline-type = 'double'">Double</xsl:when>
|
||||
<xsl:otherwise>Single</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
<xsl:if test="$styleProperties/@style:text-position">
|
||||
<xsl:attribute name="ss:VerticalAlign">
|
||||
<xsl:choose>
|
||||
<xsl:when test="substring-before($styleProperties/@style:text-position, '% ') > 0">Superscript</xsl:when>
|
||||
<xsl:otherwise>Subscript</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
</xsl:element>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="Interior">
|
||||
<xsl:param name="styleProperties" />
|
||||
<xsl:if test="$styleProperties/@fo:background-color and not($styleProperties/@fo:background-color = 'transparent')">
|
||||
<xsl:element name="Interior">
|
||||
<xsl:attribute name="ss:Color">
|
||||
<xsl:value-of select="$styleProperties/@fo:background-color" />
|
||||
</xsl:attribute>
|
||||
<!-- Background color (i.e. Interior/ss:Color) not shown without ss:Pattern (or with 'none')
|
||||
Therefore a default is set -->
|
||||
<xsl:attribute name="ss:Pattern">Solid</xsl:attribute>
|
||||
</xsl:element>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<!-- Excel issue workaround: <Font ss:Bold="1"> is not inherited -->
|
||||
<xsl:template name="getParentBold">
|
||||
<xsl:param name="styleProperties" />
|
||||
<xsl:param name="styleParentName" />
|
||||
<xsl:param name="styleName" />
|
||||
|
||||
<xsl:if test="$styleParentName and $styleParentName != $styleName">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$styleProperties/@fo:font-weight = 'bold'">
|
||||
<xsl:attribute name="ss:Bold">1</xsl:attribute>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:call-template name="getParentBold">
|
||||
<xsl:with-param name="styleProperties" select="key('styles', $styleParentName)/*" />
|
||||
<xsl:with-param name="styleParentName" select="key('styles', $styleParentName)/@style:parent-style-name" />
|
||||
<xsl:with-param name="styleName" select="$styleParentName" />
|
||||
</xsl:call-template>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
||||
@@ -0,0 +1,928 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
* This file is part of the LibreOffice project.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* This file incorporates work covered by the following license notice:
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed
|
||||
* with this work for additional information regarding copyright
|
||||
* ownership. The ASF licenses this file to you under the Apache
|
||||
* License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
||||
-->
|
||||
<xsl:stylesheet version="1.0"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
|
||||
xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0"
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:dom="http://www.w3.org/2001/xml-events"
|
||||
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"
|
||||
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
|
||||
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
|
||||
xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"
|
||||
xmlns:math="http://www.w3.org/1998/Math/MathML"
|
||||
xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0"
|
||||
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
|
||||
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
|
||||
xmlns:ooo="http://openoffice.org/2004/office"
|
||||
xmlns:oooc="http://openoffice.org/2004/calc"
|
||||
xmlns:ooow="http://openoffice.org/2004/writer"
|
||||
xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"
|
||||
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
|
||||
xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
|
||||
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
|
||||
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xmlns:xt="http://www.jclark.com/xt"
|
||||
xmlns:common="http://exslt.org/common"
|
||||
xmlns:xalan="http://xml.apache.org/xalan"
|
||||
xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:c="urn:schemas-microsoft-com:office:component:spreadsheet" xmlns:html="http://www.w3.org/TR/REC-html40" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:x2="http://schemas.microsoft.com/office/excel/2003/xml" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
exclude-result-prefixes="chart config dc dom dr3d draw fo form math meta number office ooo oooc ooow script style svg table text xlink xt common xalan">
|
||||
|
||||
|
||||
<!-- ************** -->
|
||||
<!-- *** Table *** -->
|
||||
<!-- ************** -->
|
||||
|
||||
<!-- check existence of default cell style -->
|
||||
<xsl:variable name="firstDefaultCellStyle" select="descendant::table:table-column/@table:default-cell-style-name" />
|
||||
|
||||
|
||||
<xsl:template match="table:table" name="table:table">
|
||||
<xsl:element name="Table">
|
||||
<xsl:apply-templates select="@table:style-name" />
|
||||
|
||||
<!-- find all columns in the table -->
|
||||
<xsl:variable name="columnNodes" select="descendant::table:table-column" />
|
||||
<!-- calculate the overall column amount -->
|
||||
<xsl:variable name="maxColumnNo">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$columnNodes/@table:number-columns-repeated">
|
||||
<xsl:value-of select="count($columnNodes)
|
||||
+ number(sum($columnNodes/@table:number-columns-repeated))
|
||||
- count($columnNodes/@table:number-columns-repeated)" />
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="count($columnNodes)"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<!-- create columns -->
|
||||
<xsl:apply-templates select="$columnNodes[1]">
|
||||
<xsl:with-param name="columnNodes" select="$columnNodes" />
|
||||
<xsl:with-param name="maxColumnNo" select="$maxColumnNo" />
|
||||
</xsl:apply-templates>
|
||||
|
||||
<!-- create rows -->
|
||||
<xsl:choose>
|
||||
<xsl:when test="not($columnNodes/@table:number-columns-repeated)">
|
||||
<xsl:call-template name="optimized-row-handling">
|
||||
<xsl:with-param name="rowNodes" select="descendant::table:table-row" />
|
||||
<xsl:with-param name="columnNodes" select="$columnNodes" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<!-- To be able to match from a cell to the corresponding column to match @table:default-cell-style-name,
|
||||
the repeated columns are being resolved by copying them in a helper variable -->
|
||||
<xsl:variable name="columnNodes-RTF">
|
||||
<xsl:for-each select="$columnNodes">
|
||||
<xsl:call-template name="adding-column-styles-entries" />
|
||||
</xsl:for-each>
|
||||
</xsl:variable>
|
||||
<xsl:choose>
|
||||
<xsl:when test="function-available('xalan:nodeset')">
|
||||
<xsl:call-template name="optimized-row-handling">
|
||||
<xsl:with-param name="rowNodes" select="descendant::table:table-row" />
|
||||
<xsl:with-param name="columnNodes" select="xalan:nodeset($columnNodes-RTF)" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="function-available('common:node-set')">
|
||||
<xsl:call-template name="optimized-row-handling">
|
||||
<xsl:with-param name="rowNodes" select="descendant::table:table-row" />
|
||||
<xsl:with-param name="columnNodes" select="common:node-set($columnNodes-RTF)" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="function-available('xt:node-set')">
|
||||
<xsl:call-template name="optimized-row-handling">
|
||||
<xsl:with-param name="rowNodes" select="descendant::table:table-row" />
|
||||
<xsl:with-param name="columnNodes" select="xt:node-set($columnNodes-RTF)" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:element>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<!-- **************** -->
|
||||
<!-- *** Columns *** -->
|
||||
<!-- **************** -->
|
||||
|
||||
<xsl:template match="table:table-column">
|
||||
<xsl:param name="columnNodes" />
|
||||
<xsl:param name="currentColumnNumber" select="1" />
|
||||
<xsl:param name="setIndex" select="false()" />
|
||||
<xsl:param name="maxColumnNo" />
|
||||
|
||||
<xsl:element name="Column">
|
||||
<xsl:if test="@table:visibility = 'collapse' or @table:visibility = 'filter'">
|
||||
<xsl:attribute name="ss:Hidden">1</xsl:attribute>
|
||||
</xsl:if>
|
||||
|
||||
<xsl:if test="@table:number-columns-repeated">
|
||||
<xsl:attribute name="ss:Span">
|
||||
<xsl:value-of select="@table:number-columns-repeated - 1" />
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
|
||||
<xsl:if test="$setIndex">
|
||||
<xsl:attribute name="ss:Index">
|
||||
<xsl:value-of select="$currentColumnNumber" />
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="@style:use-optimal-column-width = 'true'">
|
||||
<xsl:attribute name="ss:AutoFitWidth">1</xsl:attribute>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:variable name="width" select="key('styles', @table:style-name)/style:table-column-properties/@style:column-width" />
|
||||
<xsl:if test="$width">
|
||||
<xsl:attribute name="ss:Width">
|
||||
<!-- using the absolute width in point -->
|
||||
<xsl:call-template name="convert2pt">
|
||||
<xsl:with-param name="value" select="$width" />
|
||||
</xsl:call-template>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
|
||||
<xsl:if test="@table:number-columns-repeated">
|
||||
<xsl:attribute name="ss:Span">
|
||||
<xsl:value-of select="@table:number-columns-repeated - 1" />
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
</xsl:element>
|
||||
|
||||
<xsl:variable name="columnNumber">
|
||||
<xsl:choose>
|
||||
<xsl:when test="@table:number-columns-repeated">
|
||||
<xsl:value-of select="$currentColumnNumber + @table:number-columns-repeated"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="$currentColumnNumber"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<xsl:if test="$columnNumber < $maxColumnNo">
|
||||
<xsl:variable name="nextColumnNodes" select="$columnNodes[position() != 1]" />
|
||||
<xsl:choose>
|
||||
<xsl:when test="@table:number-columns-repeated">
|
||||
<xsl:apply-templates select="$nextColumnNodes[1]">
|
||||
<xsl:with-param name="columnNodes" select="$nextColumnNodes" />
|
||||
<xsl:with-param name="currentColumnNumber" select="$columnNumber" />
|
||||
<xsl:with-param name="maxColumnNo" select="$maxColumnNo" />
|
||||
<xsl:with-param name="setIndex" select="true()" />
|
||||
</xsl:apply-templates>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:apply-templates select="$nextColumnNodes[1]">
|
||||
<xsl:with-param name="columnNodes" select="$nextColumnNodes" />
|
||||
<xsl:with-param name="currentColumnNumber" select="$columnNumber + 1" />
|
||||
<xsl:with-param name="maxColumnNo" select="$maxColumnNo" />
|
||||
</xsl:apply-templates>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<!-- current node is a table:table-column -->
|
||||
<xsl:template name="adding-column-styles-entries">
|
||||
<xsl:choose>
|
||||
<xsl:when test="not(@table:number-columns-repeated and @table:number-columns-repeated > 1)">
|
||||
<!-- writes an entry of a column in the columns-variable -->
|
||||
<xsl:copy-of select="." />
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<!-- repeated columns will be written explicit several times in the variable-->
|
||||
<xsl:call-template name="repeat-adding-table-column">
|
||||
<xsl:with-param name="numberColumnsRepeated" select="@table:number-columns-repeated" />
|
||||
</xsl:call-template>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<!-- current node is a table:table-column -->
|
||||
<!-- duplicates column elements in case of column-repeated attribute -->
|
||||
<xsl:template name="repeat-adding-table-column">
|
||||
<xsl:param name="table:table-column" />
|
||||
<xsl:param name="numberColumnsRepeated" />
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="$numberColumnsRepeated > 1">
|
||||
<!-- writes an entry of a column in the columns-variable -->
|
||||
<xsl:copy-of select="." />
|
||||
<!-- repeat calling this method until all elements written out -->
|
||||
<xsl:call-template name="repeat-adding-table-column">
|
||||
<xsl:with-param name="numberColumnsRepeated" select="$numberColumnsRepeated - 1" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<!-- writes an entry of a column in the columns-variable -->
|
||||
<xsl:copy-of select="." />
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<!-- ************* -->
|
||||
<!-- *** Rows *** -->
|
||||
<!-- ************* -->
|
||||
|
||||
|
||||
<!-- Recursions are much faster when the stack size is small -->
|
||||
<xsl:template name="optimized-row-handling">
|
||||
<xsl:param name="rowNodes" />
|
||||
<xsl:param name="columnNodes" />
|
||||
<xsl:param name="offset" select="0"/>
|
||||
<xsl:param name="threshold" select="10"/>
|
||||
|
||||
<xsl:variable name="rowCount" select="count($rowNodes)"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$rowCount <= $threshold">
|
||||
<xsl:apply-templates select="$rowNodes[1]">
|
||||
<xsl:with-param name="rowNodes" select="$rowNodes" />
|
||||
<xsl:with-param name="offset" select="$offset" />
|
||||
<xsl:with-param name="columnNodes" select="$columnNodes" />
|
||||
</xsl:apply-templates>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:variable name="rowCountHalf" select="floor($rowCount div 2)"/>
|
||||
<xsl:variable name="rowNodesSetA" select="$rowNodes[position() <= $rowCountHalf]"/>
|
||||
<xsl:variable name="rowNodesSetB" select="$rowNodes[position() > $rowCountHalf]"/>
|
||||
<!-- to keep track of the rownumber, the repeated rows have to kept into accounts -->
|
||||
<xsl:variable name="rowsCreatedByRepetition">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$rowNodesSetA/@table:number-rows-repeated">
|
||||
<xsl:value-of select="number(sum($rowNodesSetA/@table:number-rows-repeated))
|
||||
- count($rowNodesSetA/@table:number-rows-repeated)" />
|
||||
</xsl:when>
|
||||
<xsl:otherwise>0</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$rowCountHalf > $threshold">
|
||||
<xsl:call-template name="optimized-row-handling">
|
||||
<xsl:with-param name="rowNodes" select="$rowNodesSetA"/>
|
||||
<xsl:with-param name="offset" select="$offset" />
|
||||
<xsl:with-param name="columnNodes" select="$columnNodes" />
|
||||
</xsl:call-template>
|
||||
<xsl:call-template name="optimized-row-handling">
|
||||
<xsl:with-param name="rowNodes" select="$rowNodesSetB"/>
|
||||
<xsl:with-param name="offset" select="$offset + $rowCountHalf + $rowsCreatedByRepetition" />
|
||||
<xsl:with-param name="columnNodes" select="$columnNodes" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:apply-templates select="$rowNodesSetA[1]">
|
||||
<xsl:with-param name="rowNodes" select="$rowNodesSetA"/>
|
||||
<xsl:with-param name="offset" select="$offset" />
|
||||
<xsl:with-param name="columnNodes" select="$columnNodes" />
|
||||
</xsl:apply-templates>
|
||||
<xsl:apply-templates select="$rowNodesSetB[1]">
|
||||
<xsl:with-param name="rowNodes" select="$rowNodesSetB" />
|
||||
<xsl:with-param name="offset" select="$offset + $rowCountHalf + $rowsCreatedByRepetition" />
|
||||
<xsl:with-param name="columnNodes" select="$columnNodes" />
|
||||
</xsl:apply-templates>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<!--
|
||||
Rows as "table:table-row" might be grouped in
|
||||
"table:table-header-rows" or "table:table-row-group"
|
||||
This row-tree will be traversed providing each Row with its
|
||||
calculatedRowPosition and earlierRowNumber.
|
||||
By this repeated empty rows might be neglected in the spreadsheetml output,
|
||||
as the following row will notice the 'gap' and provide @ss:Index,
|
||||
which results in filling up the gap by a row without style and content.
|
||||
|
||||
In Excel created rows by ss:Index are 'default' rows.
|
||||
-->
|
||||
<xsl:template match="table:table-row">
|
||||
<xsl:param name="earlierRowNumber" select="0" />
|
||||
<xsl:param name="offset" />
|
||||
<xsl:param name="calculatedRowPosition" select="$offset + 1" />
|
||||
<xsl:param name="rowNodes" />
|
||||
<xsl:param name="columnNodes" />
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="@table:number-rows-repeated > 1">
|
||||
<xsl:call-template name="write-table-row">
|
||||
<xsl:with-param name="earlierRowNumber" select="$earlierRowNumber" />
|
||||
<xsl:with-param name="calculatedRowPosition" select="$calculatedRowPosition" />
|
||||
<xsl:with-param name="columnNodes" select="$columnNodes" />
|
||||
</xsl:call-template>
|
||||
<xsl:if test="@table:number-rows-repeated > 2 and (table:table-cell/@office:value-type or $firstDefaultCellStyle != '')">
|
||||
<!-- In case a cell is being repeated, the cell will be created
|
||||
in a variable, which is as many times given out, as being repeated -->
|
||||
<xsl:variable name="tableRow">
|
||||
<xsl:call-template name="write-table-row">
|
||||
<xsl:with-param name="columnNodes" select="$columnNodes" />
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:call-template name="optimized-row-repeating">
|
||||
<xsl:with-param name="tableRow" select="$tableRow" />
|
||||
<xsl:with-param name="repetition" select="@table:number-rows-repeated - 1" />
|
||||
<xsl:with-param name="columnNodes" select="$columnNodes" />
|
||||
</xsl:call-template>
|
||||
</xsl:if>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:call-template name="write-table-row">
|
||||
<xsl:with-param name="earlierRowNumber" select="$earlierRowNumber" />
|
||||
<xsl:with-param name="calculatedRowPosition" select="$calculatedRowPosition" />
|
||||
<xsl:with-param name="columnNodes" select="$columnNodes" />
|
||||
</xsl:call-template>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
|
||||
<xsl:variable name="nextRowNodes" select="$rowNodes[position()!=1]" />
|
||||
<xsl:choose>
|
||||
<xsl:when test="@table:number-rows-repeated > 1">
|
||||
<xsl:apply-templates select="$nextRowNodes[1]">
|
||||
<xsl:with-param name="earlierRowNumber" select="$calculatedRowPosition" />
|
||||
<xsl:with-param name="calculatedRowPosition" select="$calculatedRowPosition + @table:number-rows-repeated" />
|
||||
<xsl:with-param name="rowNodes" select="$nextRowNodes" />
|
||||
<xsl:with-param name="columnNodes" select="$columnNodes" />
|
||||
</xsl:apply-templates>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:apply-templates select="$nextRowNodes[1]">
|
||||
<xsl:with-param name="earlierRowNumber" select="$calculatedRowPosition" />
|
||||
<xsl:with-param name="calculatedRowPosition" select="$calculatedRowPosition + 1" />
|
||||
<xsl:with-param name="rowNodes" select="$nextRowNodes" />
|
||||
<xsl:with-param name="columnNodes" select="$columnNodes" />
|
||||
</xsl:apply-templates>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="write-table-row">
|
||||
<xsl:param name="earlierRowNumber" select="0" />
|
||||
<xsl:param name="calculatedRowPosition" select="1" />
|
||||
<xsl:param name="columnNodes" />
|
||||
|
||||
<xsl:element name="Row">
|
||||
<xsl:if test="@table:visibility = 'collapse' or @table:visibility = 'filter'">
|
||||
<xsl:attribute name="ss:Hidden">1</xsl:attribute>
|
||||
</xsl:if>
|
||||
<xsl:if test="not($earlierRowNumber + 1 = $calculatedRowPosition)">
|
||||
<xsl:attribute name="ss:Index"><xsl:value-of select="$calculatedRowPosition" /></xsl:attribute>
|
||||
</xsl:if>
|
||||
|
||||
<!-- writing the style of the row -->
|
||||
<xsl:apply-templates select="@table:style-name" mode="table-row" />
|
||||
|
||||
<xsl:variable name="rowProperties" select="key('styles', @table:style-name)/*" />
|
||||
<xsl:if test="$rowProperties/@style:use-optimal-row-height = 'false'">
|
||||
<!-- default is '1', therefore write only '0' -->
|
||||
<xsl:attribute name="ss:AutoFitHeight">0</xsl:attribute>
|
||||
</xsl:if>
|
||||
|
||||
<xsl:variable name="height" select="$rowProperties/@style:row-height" />
|
||||
<xsl:if test="$height">
|
||||
<xsl:attribute name="ss:Height">
|
||||
<!-- using the absolute height in point -->
|
||||
<xsl:call-template name="convert2pt">
|
||||
<xsl:with-param name="value" select="$height" />
|
||||
</xsl:call-template>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
<xsl:apply-templates select="table:table-cell[1]">
|
||||
<xsl:with-param name="calculatedRowPosition" select="$calculatedRowPosition" />
|
||||
<xsl:with-param name="cellNodes" select="table:table-cell" />
|
||||
<xsl:with-param name="columnNodes" select="$columnNodes" />
|
||||
</xsl:apply-templates>
|
||||
</xsl:element>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<!-- Recursions are much faster when the stack size is small -->
|
||||
<xsl:template name="optimized-row-repeating">
|
||||
<xsl:param name="tableRow" />
|
||||
<xsl:param name="repetition" />
|
||||
<!-- resource optimization: instead of '1' it will be '1000' and the column is not full -->
|
||||
<xsl:param name="thresholdmax" select="512"/>
|
||||
<xsl:param name="thresholdmin" select="256"/>
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="$repetition <= $thresholdmax">
|
||||
<xsl:copy-of select="$tableRow" />
|
||||
<xsl:if test="$repetition >= $thresholdmin">
|
||||
<xsl:call-template name="optimized-row-repeating">
|
||||
<xsl:with-param name="repetition" select="$repetition - 1"/>
|
||||
<xsl:with-param name="tableRow" select="$tableRow" />
|
||||
</xsl:call-template>
|
||||
</xsl:if>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:if test="$repetition mod 2 = 1">
|
||||
<xsl:copy-of select="$tableRow" />
|
||||
</xsl:if>
|
||||
<xsl:variable name="repetitionHalf" select="floor($repetition div 2)"/>
|
||||
<xsl:call-template name="optimized-row-repeating">
|
||||
<xsl:with-param name="repetition" select="$repetitionHalf"/>
|
||||
<xsl:with-param name="tableRow" select="$tableRow" />
|
||||
</xsl:call-template>
|
||||
<xsl:call-template name="optimized-row-repeating">
|
||||
<xsl:with-param name="repetition" select="$repetitionHalf"/>
|
||||
<xsl:with-param name="tableRow" select="$tableRow" />
|
||||
</xsl:call-template>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
|
||||
<!-- ************** -->
|
||||
<!-- *** Cells *** -->
|
||||
<!-- ************** -->
|
||||
|
||||
<!-- Table cells are able to be repeated by attribute in StarOffice,
|
||||
but not in Excel. If more cells are repeated -->
|
||||
<xsl:template name="table:table-cell" match="table:table-cell">
|
||||
<xsl:param name="calculatedCellPosition" select="1" /><!-- the later table position of the current cell -->
|
||||
<xsl:param name="calculatedRowPosition" /><!-- the later table position of the current row -->
|
||||
<xsl:param name="setIndex" select="false()" /> <!-- if not '0' @ss:Index used for neglecting repeated empty cells -->
|
||||
<xsl:param name="repetition" select="@table:number-columns-repeated" /> <!-- used for explicit written out cells -->
|
||||
<xsl:param name="repetitionCellPosition" select="$calculatedCellPosition" /><!-- during repetition formula needs exact cell positioning -->
|
||||
<xsl:param name="nextMatchedCellPosition"><!-- the later table position of the next cell -->
|
||||
<xsl:choose>
|
||||
<xsl:when test="not(@table:number-columns-repeated) and not(@table:number-columns-spanned)">
|
||||
<xsl:value-of select="$calculatedCellPosition + 1" />
|
||||
</xsl:when>
|
||||
<xsl:when test="not(@table:number-columns-spanned)">
|
||||
<xsl:value-of select="$calculatedCellPosition + @table:number-columns-repeated" />
|
||||
</xsl:when>
|
||||
<xsl:when test="not(@table:number-columns-repeated)">
|
||||
<xsl:value-of select="$calculatedCellPosition + @table:number-columns-spanned" />
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="$calculatedCellPosition + @table:number-columns-spanned * @table:number-columns-repeated" />
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:param>
|
||||
<xsl:param name="cellNodes" /><!-- cells to be handled -->
|
||||
<xsl:param name="columnNodes" />
|
||||
|
||||
<xsl:choose>
|
||||
<!-- in case a repetition took place -->
|
||||
<xsl:when test="$repetition > 0">
|
||||
<xsl:choose>
|
||||
<!-- In case of no cell content (text, subelements, attribute, except repeated style) the ss:Index could be used -->
|
||||
<xsl:when test="not(text()) and not(*) and not(@*[name() != 'table:number-columns-repeated'])">
|
||||
<xsl:choose>
|
||||
<xsl:when test="count($cellNodes) = 1">
|
||||
<xsl:call-template name="create-table-cell">
|
||||
<xsl:with-param name="setIndex" select="true()" />
|
||||
<xsl:with-param name="calculatedCellPosition" select="$nextMatchedCellPosition - 1" />
|
||||
<xsl:with-param name="calculatedRowPosition" select="$calculatedRowPosition" />
|
||||
<xsl:with-param name="columnNodes" select="$columnNodes" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:apply-templates select="$cellNodes[2]">
|
||||
<xsl:with-param name="calculatedCellPosition" select="$nextMatchedCellPosition" />
|
||||
<xsl:with-param name="calculatedRowPosition" select="$calculatedRowPosition" />
|
||||
<xsl:with-param name="setIndex" select="true()" />
|
||||
<xsl:with-param name="cellNodes" select="$cellNodes[position() != 1]" />
|
||||
<xsl:with-param name="columnNodes" select="$columnNodes" />
|
||||
</xsl:apply-templates>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<!-- Fastest cell repetition by creating cell once and copying, works not for
|
||||
a) cells with formula (need of actual cell position)
|
||||
b) cells, which start with ss:Index (as ss:Index is not allowed to be repeated) -->
|
||||
<xsl:when test="not(@table:formula) and not($setIndex)">
|
||||
<!-- In case a non-empty cell is being repeated, the cell will be created
|
||||
in a variable, which is as many times given out, as being repeated -->
|
||||
<xsl:variable name="tableCell">
|
||||
<xsl:call-template name="create-table-cell">
|
||||
<xsl:with-param name="setIndex" select="false()" /><!-- copied cells may not have indices -->
|
||||
<xsl:with-param name="columnNodes" select="$columnNodes" />
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:call-template name="repeat-copy-table-cell">
|
||||
<xsl:with-param name="tableCell" select="$tableCell" />
|
||||
<xsl:with-param name="repetition" select="$repetition" />
|
||||
<xsl:with-param name="columnNodes" select="$columnNodes" />
|
||||
</xsl:call-template>
|
||||
<xsl:apply-templates select="$cellNodes[2]">
|
||||
<xsl:with-param name="calculatedCellPosition" select="$nextMatchedCellPosition" />
|
||||
<xsl:with-param name="calculatedRowPosition" select="$calculatedRowPosition" />
|
||||
<xsl:with-param name="cellNodes" select="$cellNodes[position() != 1]" />
|
||||
<xsl:with-param name="columnNodes" select="$columnNodes" />
|
||||
</xsl:apply-templates>
|
||||
</xsl:when>
|
||||
<!-- explicit writing (instead of copying) of cell for the cases mentioned above -->
|
||||
<xsl:otherwise>
|
||||
<xsl:call-template name="create-table-cell">
|
||||
<xsl:with-param name="setIndex" select="$setIndex" /><!-- a possible Index will be created -->
|
||||
<xsl:with-param name="calculatedCellPosition" select="$repetitionCellPosition" />
|
||||
<xsl:with-param name="calculatedRowPosition" select="$calculatedRowPosition" />
|
||||
<xsl:with-param name="columnNodes" select="$columnNodes" />
|
||||
</xsl:call-template>
|
||||
<xsl:choose>
|
||||
<!-- as long there is a repetition (higher '1') stay on the same cell node -->
|
||||
<xsl:when test="$repetition > 1">
|
||||
<xsl:call-template name="table:table-cell">
|
||||
<xsl:with-param name="calculatedCellPosition" select="$nextMatchedCellPosition" />
|
||||
<xsl:with-param name="calculatedRowPosition" select="$calculatedRowPosition" />
|
||||
<xsl:with-param name="repetitionCellPosition">
|
||||
<xsl:choose>
|
||||
<xsl:when test="@table:number-columns-spanned">
|
||||
<xsl:value-of select="$repetitionCellPosition + @table:number-columns-spanned" />
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="$repetitionCellPosition + 1"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:with-param>
|
||||
<xsl:with-param name="nextMatchedCellPosition" select="$nextMatchedCellPosition" />
|
||||
<xsl:with-param name="repetition" select="$repetition - 1" />
|
||||
<xsl:with-param name="cellNodes" select="$cellNodes" />
|
||||
<xsl:with-param name="columnNodes" select="$columnNodes" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:apply-templates select="$cellNodes[2]">
|
||||
<xsl:with-param name="calculatedCellPosition" select="$nextMatchedCellPosition" />
|
||||
<xsl:with-param name="calculatedRowPosition" select="$calculatedRowPosition" />
|
||||
<xsl:with-param name="cellNodes" select="$cellNodes[position() != 1]" />
|
||||
<xsl:with-param name="columnNodes" select="$columnNodes" />
|
||||
</xsl:apply-templates>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<!-- in case no repetition took place -->
|
||||
<xsl:choose>
|
||||
<!-- neglect an empty cell by using ss:Index Attribute -->
|
||||
<xsl:when test="not(text()) and not(*) and not(@*)">
|
||||
<xsl:choose>
|
||||
<!-- if it is the last cell, write this cell -->
|
||||
<xsl:when test="count($cellNodes) = 1">
|
||||
<xsl:call-template name="create-table-cell">
|
||||
<xsl:with-param name="setIndex" select="true()" />
|
||||
<xsl:with-param name="calculatedCellPosition" select="$nextMatchedCellPosition - 1" />
|
||||
<xsl:with-param name="calculatedRowPosition" select="$calculatedRowPosition" />
|
||||
<xsl:with-param name="columnNodes" select="$columnNodes" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:apply-templates select="$cellNodes[2]">
|
||||
<xsl:with-param name="setIndex" select="true()" />
|
||||
<xsl:with-param name="calculatedCellPosition" select="$nextMatchedCellPosition" />
|
||||
<xsl:with-param name="calculatedRowPosition" select="$calculatedRowPosition" />
|
||||
<xsl:with-param name="cellNodes" select="$cellNodes[position() != 1]" />
|
||||
<xsl:with-param name="columnNodes" select="$columnNodes" />
|
||||
</xsl:apply-templates>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<!-- create cell and use/unset the ss:Index -->
|
||||
<xsl:call-template name="create-table-cell">
|
||||
<xsl:with-param name="setIndex" select="$setIndex" />
|
||||
<xsl:with-param name="calculatedCellPosition" select="$calculatedCellPosition" />
|
||||
<xsl:with-param name="calculatedRowPosition" select="$calculatedRowPosition" />
|
||||
<xsl:with-param name="columnNodes" select="$columnNodes" />
|
||||
</xsl:call-template>
|
||||
<xsl:apply-templates select="$cellNodes[2]">
|
||||
<xsl:with-param name="calculatedCellPosition" select="$nextMatchedCellPosition" />
|
||||
<xsl:with-param name="calculatedRowPosition" select="$calculatedRowPosition" />
|
||||
<xsl:with-param name="cellNodes" select="$cellNodes[position() != 1]" />
|
||||
<xsl:with-param name="columnNodes" select="$columnNodes" />
|
||||
</xsl:apply-templates>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<!-- Copies the variable 'tableCell' to the output as often as 'repetition' -->
|
||||
<xsl:template name="repeat-copy-table-cell">
|
||||
<xsl:param name="tableCell" />
|
||||
<xsl:param name="repetition" />
|
||||
|
||||
<xsl:if test="$repetition > 0">
|
||||
<xsl:copy-of select="$tableCell"/>
|
||||
<xsl:call-template name="repeat-copy-table-cell">
|
||||
<xsl:with-param name="tableCell" select="$tableCell" />
|
||||
<xsl:with-param name="repetition" select="$repetition - 1" />
|
||||
</xsl:call-template>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="create-table-cell">
|
||||
<xsl:param name="setIndex" select="false()" />
|
||||
<xsl:param name="calculatedCellPosition" />
|
||||
<xsl:param name="calculatedRowPosition" />
|
||||
<xsl:param name="columnNodes" />
|
||||
|
||||
<xsl:element name="Cell" namespace="urn:schemas-microsoft-com:office:spreadsheet">
|
||||
<xsl:if test="$setIndex">
|
||||
<xsl:attribute name="ss:Index">
|
||||
<xsl:value-of select="$calculatedCellPosition"/>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
<xsl:if test="@table:number-columns-spanned > 1">
|
||||
<xsl:attribute name="ss:MergeAcross">
|
||||
<xsl:value-of select="@table:number-columns-spanned - 1" />
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
<xsl:if test="@table:number-rows-spanned > 1">
|
||||
<xsl:attribute name="ss:MergeDown">
|
||||
<xsl:value-of select="@table:number-rows-spanned - 1" />
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
<xsl:variable name="link" select="descendant::text:a/@xlink:href" />
|
||||
<xsl:if test="$link">
|
||||
<xsl:attribute name="ss:HRef">
|
||||
<xsl:value-of select="$link" />
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
<xsl:choose>
|
||||
<xsl:when test="@table:style-name">
|
||||
<xsl:apply-templates select="@table:style-name" />
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:if test="$firstDefaultCellStyle != ''">
|
||||
<xsl:variable name="defaultCellStyle" select="$columnNodes/table:table-column[position() = $calculatedCellPosition]/@table:default-cell-style-name" />
|
||||
<xsl:if test="$defaultCellStyle">
|
||||
<xsl:if test="not($defaultCellStyle = 'Default')">
|
||||
<xsl:attribute name="ss:StyleID"><xsl:value-of select="$defaultCellStyle"/></xsl:attribute>
|
||||
</xsl:if>
|
||||
</xsl:if>
|
||||
</xsl:if>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:apply-templates select="@table:formula">
|
||||
<xsl:with-param name="calculatedCellPosition" select="$calculatedCellPosition" />
|
||||
<xsl:with-param name="calculatedRowPosition" select="$calculatedRowPosition" />
|
||||
</xsl:apply-templates>
|
||||
<xsl:choose>
|
||||
<xsl:when test="*">
|
||||
<!-- in case it is not an empty cell
|
||||
|
||||
As the sequence of comment and data is opposite in Excel and Calc no match work here, in both comments exist only once
|
||||
Possible Table Content of interest: text:h|text:p|text:list -->
|
||||
<xsl:if test="text:h | text:p | text:list">
|
||||
<xsl:variable name="valueType">
|
||||
<xsl:choose>
|
||||
<xsl:when test="@office:value-type">
|
||||
<xsl:value-of select="@office:value-type" />
|
||||
</xsl:when>
|
||||
<xsl:otherwise>string</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<xsl:call-template name="ss:Data">
|
||||
<xsl:with-param name="valueType" select="$valueType" />
|
||||
<xsl:with-param name="cellStyleName" select="@table:style-name" />
|
||||
</xsl:call-template>
|
||||
</xsl:if>
|
||||
|
||||
<xsl:if test="office:annotation">
|
||||
<xsl:element name="Comment">
|
||||
<xsl:if test="office:annotation/@office:author">
|
||||
<xsl:attribute name="ss:Author"><xsl:value-of select="office:annotation/@office:author" /></xsl:attribute>
|
||||
</xsl:if>
|
||||
<xsl:if test="office:annotation/@office:display = 'true'">
|
||||
<xsl:attribute name="ss:ShowAlways">1</xsl:attribute>
|
||||
</xsl:if>
|
||||
<!-- ss:Data is obligatory, but not the same as the ss:Cell ss:Data child, as it has no attributes -->
|
||||
<ss:Data xmlns="http://www.w3.org/TR/REC-html40">
|
||||
<xsl:for-each select="office:annotation/text:p">
|
||||
<xsl:choose>
|
||||
<xsl:when test="*">
|
||||
<!-- paragraph style have to be neglected due to Excel error,
|
||||
which does not allow shadowing their HTML attributes -->
|
||||
<xsl:for-each select="*">
|
||||
<xsl:call-template name="style-and-contents" />
|
||||
</xsl:for-each>
|
||||
</xsl:when>
|
||||
<xsl:when test="@text:style-name">
|
||||
<xsl:call-template name="style-and-contents" />
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<!-- if no style is set, BOLD is set as default -->
|
||||
<B>
|
||||
<xsl:call-template name="style-and-contents" />
|
||||
</B>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:for-each>
|
||||
</ss:Data>
|
||||
</xsl:element>
|
||||
</xsl:if>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
</xsl:element>
|
||||
</xsl:template>
|
||||
|
||||
<!-- comments are handled separately in the cell -->
|
||||
<xsl:template match="office:annotation" />
|
||||
<xsl:template match="dc:date" />
|
||||
|
||||
<xsl:template name="ss:Data">
|
||||
<!-- the default value is 'String' in the office -->
|
||||
<xsl:param name="valueType" select="'string'" />
|
||||
<xsl:param name="cellStyleName" />
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="descendant::*/@text:style-name">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$valueType = 'string'">
|
||||
<ss:Data ss:Type="String" xmlns="http://www.w3.org/TR/REC-html40">
|
||||
<xsl:apply-templates>
|
||||
<xsl:with-param name="cellStyleName" select="$cellStyleName" />
|
||||
</xsl:apply-templates>
|
||||
</ss:Data>
|
||||
</xsl:when>
|
||||
<xsl:when test="$valueType = 'boolean'">
|
||||
<ss:Data ss:Type="Boolean" xmlns="http://www.w3.org/TR/REC-html40">
|
||||
<xsl:apply-templates>
|
||||
<xsl:with-param name="cellStyleName" select="$cellStyleName" />
|
||||
</xsl:apply-templates>
|
||||
</ss:Data>
|
||||
</xsl:when>
|
||||
<xsl:when test="$valueType = 'date'">
|
||||
<ss:Data ss:Type="DateTime" xmlns="http://www.w3.org/TR/REC-html40">
|
||||
<xsl:apply-templates>
|
||||
<xsl:with-param name="cellStyleName" select="$cellStyleName" />
|
||||
</xsl:apply-templates>
|
||||
</ss:Data>
|
||||
</xsl:when>
|
||||
<!-- float, time, percentage, currency (no 'Error' setting) -->
|
||||
<xsl:otherwise>
|
||||
<ss:Data ss:Type="Number" xmlns="http://www.w3.org/TR/REC-html40">
|
||||
<xsl:apply-templates>
|
||||
<xsl:with-param name="cellStyleName" select="$cellStyleName" />
|
||||
</xsl:apply-templates>
|
||||
</ss:Data>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:element name="Data">
|
||||
<xsl:call-template name="ss:Type">
|
||||
<xsl:with-param name="valueType" select="$valueType" />
|
||||
</xsl:call-template>
|
||||
</xsl:element>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template name="ss:Type">
|
||||
<xsl:param name="valueType" select="'string'" />
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="$valueType = 'string'">
|
||||
<xsl:attribute name="ss:Type">String</xsl:attribute>
|
||||
<xsl:apply-templates select="*"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$valueType = 'boolean'">
|
||||
<xsl:attribute name="ss:Type">Boolean</xsl:attribute>
|
||||
<xsl:choose>
|
||||
<xsl:when test="@office:boolean-value = 'true'">1</xsl:when>
|
||||
<xsl:otherwise>0</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:when test="$valueType = 'date' or $valueType = 'time'">
|
||||
<!-- issue in Excel: can not have an empty 'DateTime' cell -->
|
||||
<xsl:attribute name="ss:Type">DateTime</xsl:attribute>
|
||||
<!-- Gathering information of two StarOffice date/time attributes
|
||||
Excel always needs both pieces of information in one attribute -->
|
||||
<xsl:choose>
|
||||
<xsl:when test="@office:date-value">
|
||||
<!-- office:date-value may contain time (after 'T')-->
|
||||
<xsl:choose>
|
||||
<xsl:when test="contains(@office:date-value, 'T')">
|
||||
<!-- in case time is also part of the date -->
|
||||
<xsl:value-of select="substring-before(@office:date-value, 'T')" />
|
||||
<xsl:text>T</xsl:text>
|
||||
<xsl:value-of select="substring-after(@office:date-value,'T')" />
|
||||
<xsl:if test="not(contains(@office:date-value,'.'))">
|
||||
<xsl:text>.</xsl:text>
|
||||
</xsl:if>
|
||||
<xsl:text>000</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="@office:time-value">
|
||||
<!-- contains date and time (time will be evaluated later -->
|
||||
<xsl:value-of select="@office:date-value" />
|
||||
<xsl:text>T</xsl:text>
|
||||
<xsl:choose>
|
||||
<xsl:when test="@table:formula or contains(@office:time-value,',')">
|
||||
<!-- customized number types not implemented yet -->
|
||||
<xsl:text>00:00:00.000</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="translate(substring-after(@office:time-value,'PT'),'HMS','::.')" />
|
||||
<xsl:if test="not(contains(@office:time-value,'S'))">
|
||||
<xsl:text>.</xsl:text>
|
||||
</xsl:if>
|
||||
<xsl:text>000</xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="@office:date-value" />
|
||||
<xsl:text>T00:00:00.000</xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:if test="@office:time-value">
|
||||
<xsl:text>1899-12-31T</xsl:text>
|
||||
<xsl:choose>
|
||||
<xsl:when test="@table:formula or contains(@office:time-value,',')">
|
||||
<!-- customized number types not implemented yet -->
|
||||
<xsl:text>00:00:00.000</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="translate(substring-after(@office:time-value,'PT'),'HMS','::.')" />
|
||||
<xsl:if test="not(contains(@office:time-value,'S'))">
|
||||
<xsl:text>.</xsl:text>
|
||||
</xsl:if>
|
||||
<xsl:text>000</xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:if>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<!-- float, percentage, currency (no 'Error' setting) -->
|
||||
<xsl:otherwise>
|
||||
<xsl:attribute name="ss:Type">Number</xsl:attribute>
|
||||
<xsl:value-of select="@office:value" />
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<!-- ******************** -->
|
||||
<!-- *** Common Rules *** -->
|
||||
<!-- ******************** -->
|
||||
|
||||
<xsl:template match="*">
|
||||
<xsl:param name="cellStyleName" />
|
||||
|
||||
<!-- LineBreak in Cell -->
|
||||
<xsl:if test="preceding-sibling::text:p[1]"><xsl:text> </xsl:text></xsl:if>
|
||||
<xsl:call-template name="style-and-contents">
|
||||
<xsl:with-param name="cellStyleName" select="$cellStyleName" />
|
||||
</xsl:call-template>
|
||||
</xsl:template>
|
||||
|
||||
<!-- disabling draw:frames -->
|
||||
<xsl:template match="draw:frame" />
|
||||
|
||||
<xsl:template match="text:s">
|
||||
<xsl:call-template name="write-breakable-whitespace">
|
||||
<xsl:with-param name="whitespaces" select="@text:c" />
|
||||
</xsl:call-template>
|
||||
</xsl:template>
|
||||
|
||||
<!--write the number of 'whitespaces' -->
|
||||
<xsl:template name="write-breakable-whitespace">
|
||||
<xsl:param name="whitespaces" />
|
||||
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:if test="$whitespaces >= 1">
|
||||
<xsl:call-template name="write-breakable-whitespace">
|
||||
<xsl:with-param name="whitespaces" select="$whitespaces - 1" />
|
||||
</xsl:call-template>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<!-- allowing all matched text nodes -->
|
||||
<xsl:template match="text()"><xsl:value-of select="." /></xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,209 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
* This file is part of the LibreOffice project.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* This file incorporates work covered by the following license notice:
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed
|
||||
* with this work for additional information regarding copyright
|
||||
* ownership. The ASF licenses this file to you under the Apache
|
||||
* License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
||||
-->
|
||||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml" xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:aml="http://schemas.microsoft.com/aml/2001/core" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" exclude-result-prefixes="office table style text draw svg dc config xlink meta oooc dom ooo chart math dr3d form script ooow draw">
|
||||
<xsl:output method="xml" indent="no" encoding="UTF-8" version="1.0" standalone="yes"/>
|
||||
<xsl:include href="../../common/measure_conversion.xsl"/>
|
||||
<xsl:include href="../common/ooo2ms_docpr.xsl"/>
|
||||
<xsl:include href="ooo2wordml_settings.xsl"/>
|
||||
<xsl:include href="ooo2wordml_border.xsl"/>
|
||||
<xsl:include href="ooo2wordml_page.xsl"/>
|
||||
<xsl:include href="ooo2wordml_text.xsl"/>
|
||||
<xsl:include href="ooo2wordml_list.xsl"/>
|
||||
<xsl:include href="ooo2wordml_field.xsl"/>
|
||||
<xsl:include href="ooo2wordml_table.xsl"/>
|
||||
<xsl:include href="ooo2wordml_draw.xsl"/>
|
||||
<xsl:include href="ooo2wordml_path.xsl"/>
|
||||
<xsl:key name="paragraph-style" match="style:style[@style:family='paragraph']" use="@style:name"/>
|
||||
<xsl:key name="text-style" match="style:style[@style:family='text']" use="@style:name"/>
|
||||
<xsl:key name="section-style" match="style:style[@style:family='section']" use="@style:name"/>
|
||||
<xsl:key name="master-page" match="style:master-page" use="@style:name"/>
|
||||
<xsl:key name="page-layout" match="style:page-layout" use="@style:name"/>
|
||||
<xsl:key name="slave-style" match="style:style[string-length(normalize-space(@style:master-page-name)) > 0]" use="@style:name"/>
|
||||
<xsl:key name="list-style" match="office:styles/text:list-style | office:automatic-styles/text:list-style" use="@style:name"/>
|
||||
<xsl:key name="graphics-style" match="style:style[@style:family='graphic']" use="@style:name"/>
|
||||
<xsl:template match="/">
|
||||
<xsl:apply-templates select="office:document"/>
|
||||
</xsl:template>
|
||||
<xsl:template match="office:document">
|
||||
<xsl:processing-instruction name="mso-application">progid="Word.Document"</xsl:processing-instruction>
|
||||
<xsl:variable name="embeddedObjPresent">
|
||||
<xsl:choose>
|
||||
<xsl:when test="//draw:object-ole[1]">yes</xsl:when>
|
||||
<xsl:otherwise>no</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<w:wordDocument xml:space="preserve" w:embeddedObjPresent="{$embeddedObjPresent}">
|
||||
<xsl:apply-templates select="office:meta"/>
|
||||
<xsl:apply-templates select="office:font-face-decls"/>
|
||||
<xsl:if test="office:styles/text:outline-style | office:styles/text:list-style | office:automatic-styles/text:list-style">
|
||||
<xsl:call-template name="ListStyles"/>
|
||||
</xsl:if>
|
||||
<w:styles>
|
||||
<xsl:apply-templates select="office:styles"/>
|
||||
<xsl:apply-templates select="office:automatic-styles"/>
|
||||
<xsl:call-template name="add_hyperlink_style"/>
|
||||
<!--add for hyperlink character style G.Y.-->
|
||||
<xsl:call-template name="add_comments_style"/>
|
||||
<!--add for comments style G.Y.-->
|
||||
</w:styles>
|
||||
<xsl:call-template name="export-oledata"/>
|
||||
<xsl:apply-templates select="office:settings"/>
|
||||
<xsl:apply-templates select="office:body"/>
|
||||
</w:wordDocument>
|
||||
</xsl:template>
|
||||
<xsl:template match="office:body">
|
||||
<xsl:call-template name="page-background"/>
|
||||
<xsl:apply-templates select="office:text"/>
|
||||
</xsl:template>
|
||||
<xsl:template match="office:font-face-decls">
|
||||
<!-- get default font from default paragraph properties -->
|
||||
<w:fonts>
|
||||
<xsl:variable name="default-paragraph-properties" select="/office:document/office:styles/style:default-style[@style:family = 'paragraph']/style:paragraph-properties"/>
|
||||
<w:defaultFonts w:ascii="{$default-paragraph-properties/@style:font-name}" w:h-ansi="{$default-paragraph-properties/@style:font-name}" w:fareast="{$default-paragraph-properties/@style:font-name-asian}" w:cs="{$default-paragraph-properties/@style:font-name-complex}"/>
|
||||
<xsl:for-each select="style:font-face">
|
||||
<w:font w:name="{@style:name}">
|
||||
<xsl:if test="@style:font-charset = 'x-symbol'">
|
||||
<w:charset w:val="02"/>
|
||||
</xsl:if>
|
||||
<xsl:choose>
|
||||
<xsl:when test="@style:font-family-generic = 'swiss'">
|
||||
<w:family w:val="Swiss"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="@style:font-family-generic = 'modern'">
|
||||
<w:family w:val="Modern"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="@style:font-family-generic = 'roman'">
|
||||
<w:family w:val="Roman"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="@style:font-family-generic = 'script'">
|
||||
<w:family w:val="Script"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="@style:font-family-generic = 'decorative'">
|
||||
<w:family w:val="Decorative"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="@style:font-family-generic = 'system'">
|
||||
<w:family w:val="System"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<w:family w:val="System"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<w:pitch w:val="{@style:font-pitch}"/>
|
||||
</w:font>
|
||||
</xsl:for-each>
|
||||
</w:fonts>
|
||||
</xsl:template>
|
||||
<xsl:template match="office:styles | office:automatic-styles">
|
||||
<xsl:for-each select="*[(name()='style:style' or name()='style:default-style') and (@style:family= 'paragraph' or @style:family= 'text' or @style:family='table')]">
|
||||
<xsl:variable name="style-name">
|
||||
<xsl:choose>
|
||||
<xsl:when test="name() = 'style:default-style'">
|
||||
<xsl:value-of select="concat('default-', @style:family, '-style')"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="@style:name"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<w:style w:styleId="{$style-name}">
|
||||
<xsl:choose>
|
||||
<xsl:when test="@style:family = 'paragraph'">
|
||||
<xsl:attribute name="w:type">paragraph</xsl:attribute>
|
||||
</xsl:when>
|
||||
<xsl:when test="@style:family = 'text'">
|
||||
<xsl:attribute name="w:type">character</xsl:attribute>
|
||||
</xsl:when>
|
||||
<xsl:when test="@style:family = 'table'">
|
||||
<xsl:attribute name="w:type">table</xsl:attribute>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
<xsl:if test="name() = 'style:default-style'">
|
||||
<xsl:attribute name="w:default">on</xsl:attribute>
|
||||
</xsl:if>
|
||||
<xsl:choose>
|
||||
<xsl:when test="@style:parent-style-name">
|
||||
<w:basedOn w:val="{@style:parent-style-name}"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="name() = 'style:style' and @style:family= 'paragraph'">
|
||||
<w:basedOn w:val="{concat('default-', @style:family, '-style')}"/>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
<w:name w:val="{$style-name}"/>
|
||||
<xsl:if test="parent::office:automatic-styles">
|
||||
<w:hidden w:val="on"/>
|
||||
</xsl:if>
|
||||
<xsl:if test="@style:next-style-name">
|
||||
<w:next w:val="{@style:next-style-name}"/>
|
||||
</xsl:if>
|
||||
<xsl:choose>
|
||||
<xsl:when test="@style:family = 'paragraph'">
|
||||
<xsl:apply-templates select="style:paragraph-properties" mode="paragraph"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="@style:family = 'table'">
|
||||
<w:tblPr>
|
||||
<xsl:apply-templates select="style:table-properties" mode="table"/>
|
||||
</w:tblPr>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
<xsl:apply-templates select="style:text-properties" mode="character"/>
|
||||
</w:style>
|
||||
</xsl:for-each>
|
||||
</xsl:template>
|
||||
<xsl:template match="office:text">
|
||||
<w:body>
|
||||
<xsl:apply-templates select="text:p | text:h | text:section | text:unordered-list | text:ordered-list | text:list |table:table"/>
|
||||
<xsl:variable name="paragraph-heading-table" select=".//*[name() = 'text:p' or name() = 'text:h' or name() = 'table:table']"/>
|
||||
<xsl:variable name="page" select="$paragraph-heading-table[key( 'slave-style', @*[name()='text:style-name' or name()='table:style-name'])]"/>
|
||||
<w:sectPr>
|
||||
<!--w:type w:val="continuous"/ -->
|
||||
<xsl:apply-templates select="/office:document/office:styles/text:footnotes-configuration">
|
||||
<xsl:with-param name="within-section" select="'yes'"/>
|
||||
</xsl:apply-templates>
|
||||
<xsl:apply-templates select="/office:document/office:styles/text:endnotes-configuration">
|
||||
<xsl:with-param name="within-section" select="'yes'"/>
|
||||
</xsl:apply-templates>
|
||||
<xsl:choose>
|
||||
<xsl:when test="count($page) > 0">
|
||||
<xsl:apply-templates select="key('master-page', key( 'slave-style', $page[last()]/@*[name()='text:style-name' or name()='table:style-name'])/@style:master-page-name)"/>
|
||||
<xsl:if test="key( 'slave-style', $page[last()]/@*[name()='text:style-name' or name()='table:style-name'])/style:paragraph-properties/@style:page-number">
|
||||
<!-- in M$ word the header and footer associate with the w:sectPr, but in StarOffice writer the header and footer associate with the style:master-page -->
|
||||
<xsl:variable name="pagenumber_start">
|
||||
<xsl:value-of select=" key( 'slave-style', $page[last()]/@*[name()='text:style-name' or name()='table:style-name'])/style:paragraph-properties/@style:page-number"/>
|
||||
</xsl:variable>
|
||||
<xsl:if test=" number($pagenumber_start) > 0 ">
|
||||
<w:pgNumType w:start="{$pagenumber_start}"/>
|
||||
</xsl:if>
|
||||
<!-- comment out the below line to enable the header and footer display normally when style:page-number =0 -->
|
||||
<!-- w:pgNumType w:start="{key( 'slave-style', $page[last()]/@*[name()='text:style-name' or name()='table:style-name'])/style:paragraph-properties/@style:page-number}"/-->
|
||||
</xsl:if>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:apply-templates select="/office:document/office:master-styles/style:master-page[1]"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:if test="$paragraph-heading-table[last()]/ancestor::text:section">
|
||||
<xsl:apply-templates select="key('section-style',$paragraph-heading-table[last()]/ancestor::text:section[1]/@text:style-name)" mode="section"/>
|
||||
</xsl:if>
|
||||
</w:sectPr>
|
||||
</w:body>
|
||||
</xsl:template>
|
||||
<xsl:template match="text:section">
|
||||
<xsl:apply-templates select="text:p | text:h | text:section | text:unordered-list | text:ordered-list | text:list | table:table"/>
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>
|
||||
@@ -0,0 +1,144 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
* This file is part of the LibreOffice project.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* This file incorporates work covered by the following license notice:
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed
|
||||
* with this work for additional information regarding copyright
|
||||
* ownership. The ASF licenses this file to you under the Apache
|
||||
* License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
||||
-->
|
||||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml" xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:aml="http://schemas.microsoft.com/aml/2001/core" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" exclude-result-prefixes="office table style text draw svg dc config xlink meta oooc dom ooo chart math dr3d form script ooow draw">
|
||||
<!-- multiple usage: get size, type, color of table-cell, paragraph, and page borders. -->
|
||||
<xsl:template name="get-border-size">
|
||||
<xsl:param name="border"/>
|
||||
<xsl:param name="border-line-width"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$border = 'none' or $border = 'hidden'">
|
||||
<xsl:text>none;0</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:variable name="border-value">
|
||||
<xsl:call-template name="convert2cm">
|
||||
<xsl:with-param name="value" select="$border"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="border-style">
|
||||
<xsl:choose>
|
||||
<xsl:when test="contains($border,'solid')">solid</xsl:when>
|
||||
<xsl:when test="contains($border,'double')">double</xsl:when>
|
||||
<xsl:otherwise>none</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<!-- MS word and SO writer borders Mapping
|
||||
MS word Borders SO borders
|
||||
w:val="single" w:sz="0" 0.05pt(0.002cm);solid
|
||||
w:val="single" w:sz="12" 1.00pt(0.035cm);solid
|
||||
w:val="single" w:sz="18" 2.50pt(0.088cm);solid
|
||||
w:val="single" w:sz="36" 4.00pt(0.141cm);solid
|
||||
w:val="single" w:sz="48" 5.00pt(0.176cm);solid
|
||||
w:val="double" w:sz="2" 1.10pt(0.039cm);double
|
||||
w:val="double" w:sz="6" 2.60pt(0.092cm);double
|
||||
w:val="thin-thick-small-gap" w:sz="12" 3.00pt(0.105cm);double
|
||||
w:val="thin-thick-large-gap" w:sz="18" 3.55pt(0.125cm);double
|
||||
w:val="thick-thin-medium-gap" w:sz="24" 4.50pt(0.158cm);double
|
||||
w:val="thin-thick-medium-gap" w:sz="24" 5.05pt(0.178cm);double
|
||||
w:val="thin-thick-small-gap" w:sz="24" 6.00pt(0.211cm);double
|
||||
w:val="thin-thick-medium-gap" w:sz="36" 6.55pt(0.231cm);double
|
||||
w:val="double" w:sz="18" 7.50pt(0.264cm);double
|
||||
w:val="thin-thick-medium-gap" w:sz="48" 9.00pt(0.317cm);double;style:border-line-width="0.088cm 0.088cm 0.141cm"
|
||||
w:val="double" w:sz="24" 9.00pt(0.317cm);double;style:border-line-width="0.141cm 0.088cm 0.088cm"
|
||||
we adjust the criteria by adding about 1/2 range of this current criteria and next criteria. Gary. Yang -->
|
||||
<xsl:variable name="microsoft-border-style-size">
|
||||
<xsl:choose>
|
||||
<xsl:when test=" $border-style = 'solid'">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$border-value <= 0.018">single;0</xsl:when>
|
||||
<xsl:when test="$border-value <= 0.055">single;12</xsl:when>
|
||||
<xsl:when test="$border-value <= 0.110">single;18</xsl:when>
|
||||
<xsl:when test="$border-value <= 0.155">single;36</xsl:when>
|
||||
<xsl:when test="$border-value <= 0.198">single;48</xsl:when>
|
||||
<xsl:otherwise>single;48</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:when test="$border-style = 'double'">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$border-value < 0.064">double;2</xsl:when>
|
||||
<xsl:when test="$border-value < 0.098">double;6</xsl:when>
|
||||
<xsl:when test="$border-value < 0.115">thin-thick-small-gap;12</xsl:when>
|
||||
<xsl:when test="$border-value < 0.135">thin-thick-large-gap;18</xsl:when>
|
||||
<xsl:when test="$border-value < 0.168">thick-thin-medium-gap;24</xsl:when>
|
||||
<xsl:when test="$border-value < 0.190">thin-thick-medium-gap;24</xsl:when>
|
||||
<xsl:when test="$border-value < 0.221">thin-thick-small-gap;24</xsl:when>
|
||||
<xsl:when test="$border-value < 0.241">thin-thick-medium-gap;36</xsl:when>
|
||||
<xsl:when test="$border-value < 0.300">double;18</xsl:when>
|
||||
<xsl:when test="$border-value < 0.430">
|
||||
<xsl:variable name="border-inner-line-value">
|
||||
<xsl:call-template name="convert2cm">
|
||||
<xsl:with-param name="value" select="$border-line-width"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:if test="$border-inner-line-value < 0.10">thin-thick-medium-gap;48</xsl:if>
|
||||
<xsl:if test="$border-inner-line-value > 0.10">double;24</xsl:if>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>double;24</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>none;0</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<xsl:value-of select="$microsoft-border-style-size"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
<!-- get bottom and right border style, size, color -->
|
||||
<xsl:template name="get-border">
|
||||
<xsl:param name="so-border"/>
|
||||
<xsl:param name="so-border-line-width"/>
|
||||
<xsl:param name="so-border-position"/>
|
||||
<xsl:variable name="ms-style-width">
|
||||
<xsl:call-template name="get-border-size">
|
||||
<xsl:with-param name="border" select="$so-border"/>
|
||||
<xsl:with-param name="border-line-width" select="$so-border-line-width"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$so-border-position = 'bottom' or $so-border-position = 'right'">
|
||||
<!-- if border style is bottom or right border we need to change the thin-thick to thick-thin; Vice Versa -->
|
||||
<xsl:choose>
|
||||
<xsl:when test="substring-before($ms-style-width, '-')='thin'">
|
||||
<xsl:attribute name="w:val"><xsl:value-of select="concat( 'thick-thin', substring-after(substring-before($ms-style-width, ';'), 'k' ))"/></xsl:attribute>
|
||||
</xsl:when>
|
||||
<xsl:when test="substring-before($ms-style-width, '-')='thick'">
|
||||
<xsl:attribute name="w:val"><xsl:value-of select="concat( 'thin-thick', substring-after(substring-before($ms-style-width, ';'), 'n' ))"/></xsl:attribute>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:attribute name="w:val"><xsl:value-of select="substring-before($ms-style-width, ';')"/></xsl:attribute>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:attribute name="w:sz"><xsl:value-of select="substring-after($ms-style-width,';')"/></xsl:attribute>
|
||||
</xsl:when>
|
||||
<xsl:when test="$so-border-position = 'top' or $so-border-position = 'left'">
|
||||
<xsl:attribute name="w:val"><xsl:value-of select="substring-before($ms-style-width,';')"/></xsl:attribute>
|
||||
<xsl:attribute name="w:sz"><xsl:value-of select="substring-after($ms-style-width,';')"/></xsl:attribute>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
<!--get border color -->
|
||||
<xsl:choose>
|
||||
<xsl:when test="contains($so-border,'#')">
|
||||
<xsl:attribute name="w:color"><xsl:value-of select="substring-after($so-border, '#')"/></xsl:attribute>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:attribute name="w:color">auto</xsl:attribute>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>
|
||||
@@ -0,0 +1,275 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
* This file is part of the LibreOffice project.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* This file incorporates work covered by the following license notice:
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed
|
||||
* with this work for additional information regarding copyright
|
||||
* ownership. The ASF licenses this file to you under the Apache
|
||||
* License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
||||
-->
|
||||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml" xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:aml="http://schemas.microsoft.com/aml/2001/core" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" exclude-result-prefixes="office table style text draw svg dc config xlink meta oooc dom ooo chart math dr3d form script ooow draw">
|
||||
<xsl:template name="ooo_custom_draw2ms_word_draw_map">
|
||||
<xsl:param name="ooo_predefined_type"/>
|
||||
<!-- all ooo draw names are get from EnhancedCustomShapeGeometry.idl-->
|
||||
<xsl:choose>
|
||||
<xsl:when test="$ooo_predefined_type = 'isosceles-triangle' ">
|
||||
<xsl:value-of select=" '#_x0000_t5' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'right-triangle' ">
|
||||
<xsl:value-of select=" '#_x0000_t6' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'trapezoid' ">
|
||||
<xsl:value-of select=" '#_x0000_t8' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'diamond' ">
|
||||
<xsl:value-of select=" '#_x0000_t4' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'hexagon' ">
|
||||
<xsl:value-of select=" '#_x0000_t9' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'parallelogram' ">
|
||||
<xsl:value-of select=" '#_x0000_t7' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'pentagon' ">
|
||||
<xsl:value-of select=" '#_x0000_t56' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'octagon' ">
|
||||
<xsl:value-of select=" '#_x0000_t10' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'cross' ">
|
||||
<xsl:value-of select=" '#_x0000_t11' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'ring' ">
|
||||
<xsl:value-of select=" '#_x0000_t23' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'block-arc' ">
|
||||
<xsl:value-of select=" '#_x0000_t95' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'can' ">
|
||||
<xsl:value-of select=" '#_x0000_t22' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'cube' ">
|
||||
<xsl:value-of select=" '#_x0000_t16' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'paper' ">
|
||||
<xsl:value-of select=" '#_x0000_t65' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'smiley' ">
|
||||
<xsl:value-of select=" '#_x0000_t96' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'sun' ">
|
||||
<xsl:value-of select=" '#_x0000_t183' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'moon' ">
|
||||
<xsl:value-of select=" '#_x0000_t184' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'heart' ">
|
||||
<xsl:value-of select=" '#_x0000_t74' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'forbidden' ">
|
||||
<xsl:value-of select=" '#_x0000_t57' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'left-bracket' ">
|
||||
<xsl:value-of select=" '#_x0000_t85' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'right-bracket' ">
|
||||
<xsl:value-of select=" '#_x0000_t86' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'left-brace' ">
|
||||
<xsl:value-of select=" '#_x0000_t87' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'right-brace' ">
|
||||
<xsl:value-of select=" '#_x0000_t88' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'bracket-pair' ">
|
||||
<xsl:value-of select=" '#_x0000_t185' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'brace-pair' ">
|
||||
<xsl:value-of select=" '#_x0000_t186' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'quad-bevel' ">
|
||||
<xsl:value-of select=" '#_x0000_t189' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'left-arrow' ">
|
||||
<xsl:value-of select=" '#_x0000_t66' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'down-arrow' ">
|
||||
<xsl:value-of select=" '#_x0000_t67' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'up-arrow' ">
|
||||
<xsl:value-of select=" '#_x0000_t68' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'right-arrow' ">
|
||||
<xsl:value-of select=" '#_x0000_t13' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'left-right-arrow' ">
|
||||
<xsl:value-of select=" '#_x0000_t69' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'up-down-arrow' ">
|
||||
<xsl:value-of select=" '#_x0000_t70' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'mso-spt89' ">
|
||||
<xsl:value-of select=" '#_x0000_t89' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'quad-arrow' ">
|
||||
<xsl:value-of select=" '#_x0000_t76' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'notched-right-arrow' ">
|
||||
<xsl:value-of select=" '#_x0000_t94' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'pentagon-right' ">
|
||||
<xsl:value-of select=" '#_x0000_t177' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'chevron' ">
|
||||
<xsl:value-of select=" '#_x0000_t55' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'up-arrow-callout' ">
|
||||
<xsl:value-of select=" '#_x0000_t79' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'down-arrow-callout' ">
|
||||
<xsl:value-of select=" '#_x0000_t80' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'up-down-arrow-callout' ">
|
||||
<xsl:value-of select=" '#_x0000_t82' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'circular-arrow' ">
|
||||
<xsl:value-of select=" '#_x0000_t103' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'flowchart-process' ">
|
||||
<xsl:value-of select=" '#_x0000_t109' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'flowchart-alternate-process' ">
|
||||
<xsl:value-of select=" '#_x0000_t116' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'flowchart-decision' ">
|
||||
<xsl:value-of select=" '#_x0000_t110' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'flowchart-data' ">
|
||||
<xsl:value-of select=" '#_x0000_t111' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'flowchart-predefined-process' ">
|
||||
<xsl:value-of select=" '#_x0000_t112' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'flowchart-internal-storage' ">
|
||||
<xsl:value-of select=" '#_x0000_t113' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'flowchart-document' ">
|
||||
<xsl:value-of select=" '#_x0000_t114' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'flowchart-multidocument' ">
|
||||
<xsl:value-of select=" '#_x0000_t115' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'flowchart-terminator' ">
|
||||
<xsl:value-of select=" '#_x0000_t116' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'flowchart-preparation' ">
|
||||
<xsl:value-of select=" '#_x0000_t117' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'flowchart-manual-input' ">
|
||||
<xsl:value-of select=" '#_x0000_t118' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'flowchart-manual-operation' ">
|
||||
<xsl:value-of select=" '#_x0000_t119' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'flowchart-connector' ">
|
||||
<xsl:value-of select=" '#_x0000_t120' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'flowchart-off-page-connector' ">
|
||||
<xsl:value-of select=" '#_x0000_t177' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'flowchart-card' ">
|
||||
<xsl:value-of select=" '#_x0000_t121' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'flowchart-punched-tape' ">
|
||||
<xsl:value-of select=" '#_x0000_t122' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'flowchart-summing-junction' ">
|
||||
<xsl:value-of select=" '#_x0000_t123' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'flowchart-or' ">
|
||||
<xsl:value-of select=" '#_x0000_t124' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'flowchart-collate' ">
|
||||
<xsl:value-of select=" '#_x0000_t125' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'flowchart-sort' ">
|
||||
<xsl:value-of select=" '#_x0000_t126' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'flowchart-extract' ">
|
||||
<xsl:value-of select=" '#_x0000_t127' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'flowchart-merge' ">
|
||||
<xsl:value-of select=" '#_x0000_t128' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'flowchart-stored-data' ">
|
||||
<xsl:value-of select=" '#_x0000_t130' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'flowchart-delay' ">
|
||||
<xsl:value-of select=" '#_x0000_t135' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'flowchart-sequential-access' ">
|
||||
<xsl:value-of select=" '#_x0000_t131' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'flowchart-magnetic-disk' ">
|
||||
<xsl:value-of select=" '#_x0000_t132' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'flowchart-direct-access-storage' ">
|
||||
<xsl:value-of select=" '#_x0000_t133' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'flowchart-display' ">
|
||||
<xsl:value-of select=" '#_x0000_t134' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'rectangular-callout' ">
|
||||
<xsl:value-of select=" '#_x0000_t61' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'round-rectangular-callout' ">
|
||||
<xsl:value-of select=" '#_x0000_t62' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'round-callout' ">
|
||||
<xsl:value-of select=" '#_x0000_t63' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'cloud-callout' ">
|
||||
<xsl:value-of select=" '#_x0000_t106' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'line-callout-1' ">
|
||||
<xsl:value-of select=" '#_x0000_t50' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'line-callout-2' ">
|
||||
<xsl:value-of select=" '#_x0000_t51' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'line-callout-3' ">
|
||||
<xsl:value-of select=" '#_x0000_t47' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'bang' ">
|
||||
<xsl:value-of select=" '#_x0000_t72' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'star4' ">
|
||||
<xsl:value-of select=" '#_x0000_t187' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'star5' ">
|
||||
<xsl:value-of select=" '#_x0000_t12' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'star8' ">
|
||||
<xsl:value-of select=" '#_x0000_t58' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'star24' ">
|
||||
<xsl:value-of select=" '#_x0000_t92' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'vertical-scroll' ">
|
||||
<xsl:value-of select=" '#_x0000_t97' "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$ooo_predefined_type = 'horizontal-scroll' ">
|
||||
<xsl:value-of select=" '#_x0000_t98' "/>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,726 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
* This file is part of the LibreOffice project.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* This file incorporates work covered by the following license notice:
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed
|
||||
* with this work for additional information regarding copyright
|
||||
* ownership. The ASF licenses this file to you under the Apache
|
||||
* License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
||||
-->
|
||||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml" xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:aml="http://schemas.microsoft.com/aml/2001/core" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" exclude-result-prefixes="office table style text draw svg dc config xlink meta oooc dom ooo chart math dr3d form script ooow draw">
|
||||
<!-- the following are common used fields -->
|
||||
<xsl:template match="text:page-number | text:page-count | text:subject | text:initial-creator | text:title | text:date
|
||||
| text:time | text:page-variable-get | text:author-name | text:author-initials | text:file-name | text:sender-company
|
||||
| text:sender-initials | text:sender-phone-work | text:word-count | text:paragraph-count | text:character-count
|
||||
| text:description | text:creation-time | text:creation-date | text:editing-cycles | text:editing-duration
|
||||
| text:keywords | text:print-time | text:print-date | text:creator | text:modification-time | text:modification-date
|
||||
| text:user-defined | text:variable-get | text:user-field-get | text:sequence | text:database-name ">
|
||||
<w:fldSimple>
|
||||
<xsl:variable name="attribute_value1">
|
||||
<xsl:choose>
|
||||
<xsl:when test="name() = 'text:page-number' or name() = 'text:page-variable-get' ">
|
||||
<xsl:text> PAGE </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="name() = 'text:page-count' ">
|
||||
<xsl:text> NUMPAGES </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test=" name() = 'text:subject' ">
|
||||
<xsl:text> SUBJECT </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="name() = 'text:initial-creator' ">
|
||||
<xsl:text> AUTHOR </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test=" name() = 'text:title' ">
|
||||
<xsl:text> TITLE </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="name() = 'text:date' ">
|
||||
<xsl:text> DATE </xsl:text>
|
||||
<!-- ATM, this template just return null date format, it might be developed in the future -->
|
||||
<xsl:call-template name="field_get_date_format">
|
||||
<xsl:with-param name="field_date_stylename" select="@style:data-style-name"/>
|
||||
<xsl:with-param name="field_date_value" select="@text:date-value"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test=" name() = 'text:time' ">
|
||||
<xsl:text> TIME </xsl:text>
|
||||
<!-- ATM, this template just return null time format, it might be developed in the future -->
|
||||
<xsl:call-template name="field_get_time_format">
|
||||
<xsl:with-param name="field_time_stylename" select="@style:data-style-name"/>
|
||||
<xsl:with-param name="field_time_value" select="@text:time-value"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="name() = 'text:author-name' ">
|
||||
<xsl:text> AUTHOR </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="name() = 'text:author-initials' ">
|
||||
<xsl:text> USERINITIALS </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="name() = 'text:file-name' ">
|
||||
<xsl:choose>
|
||||
<xsl:when test="@text:display='name-and-extension' or @text:display='name' ">
|
||||
<xsl:text> FILENAME </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test=" @text:display='full' or @text:display='path' ">
|
||||
<xsl:text>FILENAME \p </xsl:text>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:when test=" name() = 'text:sender-company' ">
|
||||
<xsl:text> DOCPROPERTY Company </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="name() = 'text:sender-initials' ">
|
||||
<xsl:text> USERINITIALS </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="name() = 'text:sender-phone-work' ">
|
||||
<xsl:text> DOCPROPERTY "Telephone number" </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="name() = 'text:word-count' ">
|
||||
<xsl:text> DOCPROPERTY Words </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="name() = 'text:paragraph-count' ">
|
||||
<xsl:text> DOCPROPERTY Paragraphs </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="name() = 'text:character-count' ">
|
||||
<xsl:text> DOCPROPERTY CharactersWithSpaces </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="name() = 'text:description' ">
|
||||
<xsl:text> COMMENTS </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="name() = 'text:creation-time' ">
|
||||
<xsl:text> DOCPROPERTY CreateTime </xsl:text>
|
||||
<!-- ATM, this template just return null time format, it might be developed in the future -->
|
||||
<xsl:call-template name="field_get_time_format">
|
||||
<xsl:with-param name="field_time_stylename" select="@style:data-style-name"/>
|
||||
<xsl:with-param name="field_time_value" select="@text:time-value"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test=" name()= 'text:creation-date' ">
|
||||
<xsl:text> CREATEDATE </xsl:text>
|
||||
<!-- ATM, this template just return null date format, it might be developed in the future -->
|
||||
<xsl:call-template name="field_get_date_format">
|
||||
<xsl:with-param name="field_date_stylename" select="@style:data-style-name"/>
|
||||
<xsl:with-param name="field_date_value" select="@text:date-value"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test=" name() = 'text:editing-cycles' ">
|
||||
<xsl:text> REVNUM \* Arabic </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test=" name() = 'text:editing-duration' ">
|
||||
<xsl:text> EDITTIME </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test=" name() = 'text:keywords' ">
|
||||
<xsl:text> KEYWORDS </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test=" name() = 'text:print-time' ">
|
||||
<xsl:text>DOCPROPERTY LastPrinted </xsl:text>
|
||||
<!-- ATM, this template just return null time format, it might be developed in the future -->
|
||||
<xsl:call-template name="field_get_time_format">
|
||||
<xsl:with-param name="field_time_stylename" select="@style:data-style-name"/>
|
||||
<xsl:with-param name="field_time_value" select="@text:time-value"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test=" name() = 'text:print-date' ">
|
||||
<xsl:text>DOCPROPERTY LastPrinted </xsl:text>
|
||||
<!-- ATM, this template just return null date format, it might be developed in the future -->
|
||||
<xsl:call-template name="field_get_date_format">
|
||||
<xsl:with-param name="field_date_stylename" select="@style:data-style-name"/>
|
||||
<xsl:with-param name="field_date_value" select="@text:date-value"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test=" name() = 'text:creator' ">
|
||||
<xsl:text> LASTSAVEDBY </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test=" name() = 'text:modification-time' ">
|
||||
<xsl:text> DOCPROPERTY LastSavedTime </xsl:text>
|
||||
<!-- ATM, this template just return null time format, it might be developed in the future -->
|
||||
<xsl:call-template name="field_get_time_format">
|
||||
<xsl:with-param name="field_time_stylename" select="@style:data-style-name"/>
|
||||
<xsl:with-param name="field_time_value" select="@text:time-value"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test=" name() = 'text:modification-date' ">
|
||||
<xsl:text> SAVEDATE </xsl:text>
|
||||
<!-- ATM, this template just return null date format, it might be developed in the future -->
|
||||
<xsl:call-template name="field_get_date_format">
|
||||
<xsl:with-param name="field_date_stylename" select="@style:data-style-name"/>
|
||||
<xsl:with-param name="field_date_value" select="@text:date-value"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test=" name() = 'text:user-defined' ">
|
||||
<xsl:text> DOCPROPERTY </xsl:text>
|
||||
<xsl:text>"</xsl:text>
|
||||
<xsl:value-of select="translate(string(@text:name), ' ', '')"/>
|
||||
<xsl:text>"</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="name() = 'text:variable-get' or name() = 'text:user-field-get' ">
|
||||
<xsl:value-of select="concat ('DOCVARIABLE ', @text:name)"/>
|
||||
</xsl:when>
|
||||
<xsl:when test=" name() = 'text:sequence' ">
|
||||
<xsl:value-of select="concat(' SEQ "',@text:name, '"') "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="name() = 'text:database-name' ">
|
||||
<xsl:value-of select="concat (' DATABASE ', @text:database-name, '.' , @text:table-name)"/>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
<!-- Get number style format for number fields -->
|
||||
<xsl:if test="@style:num-format">
|
||||
<xsl:call-template name="field_get_number_format">
|
||||
<xsl:with-param name="field_number_format_style" select="@style:num-format"/>
|
||||
</xsl:call-template>
|
||||
</xsl:if>
|
||||
<xsl:text> \* MERGEFORMAT </xsl:text>
|
||||
</xsl:variable>
|
||||
<xsl:attribute name="w:instr">
|
||||
<xsl:value-of select="$attribute_value1"/>
|
||||
</xsl:attribute>
|
||||
<w:r>
|
||||
<w:rPr>
|
||||
<xsl:choose>
|
||||
<xsl:when test="@style:num-format = '가, 나, 다, ...' or @style:num-format ='일, 이, 삼, ...' or @style:num-format ='ㄱ, ㄴ, ㄷ, ...' ">
|
||||
<w:rFonts w:fareast="Batang" w:hint="fareast"/>
|
||||
<!--wx:font wx:val="Batang"/ -->
|
||||
<w:lang w:fareast="KO"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="@style:num-format = 'ア, イ, ウ, ...' or @style:num-format = 'ア, イ, ウ, ...' or @style:num-format = 'イ, ロ, ハ, ...' or @style:num-format = 'イ, ロ, ハ, ...' or @style:num-format ='壱, 弐, 参, ...' ">
|
||||
<w:rFonts w:fareast="MS Mincho" w:hint="fareast"/>
|
||||
<!--wx:font wx:val="MS Mincho"/ -->
|
||||
<w:lang w:fareast="JA"/>
|
||||
</xsl:when>
|
||||
<xsl:when test=" @style:num-format ='壹, 貳, 參, ...' or @style:num-format ='壹, 貳, 參, ...' or @style:num-format ='壹, 贰, 叁, ...'or @style:num-format = '一, 二, 三, ...' ">
|
||||
<w:rFonts w:hint="fareast"/>
|
||||
<!--wx:font wx:val="宋体"/ -->
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
<w:noProof/>
|
||||
</w:rPr>
|
||||
<w:t>
|
||||
<xsl:value-of select="."/>
|
||||
</w:t>
|
||||
</w:r>
|
||||
</w:fldSimple>
|
||||
</xsl:template>
|
||||
<xsl:template name="field_get_number_format">
|
||||
<!-- this template get the various of number formats for number type field-->
|
||||
<xsl:param name="field_number_format_style"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test=" $field_number_format_style = '1, 2, 3, ...' or $field_number_format_style = '1' ">
|
||||
<xsl:text> \* Arabic </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="$field_number_format_style = '①, ②, ③, ...' ">
|
||||
<xsl:text> \* CircleNum </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="$field_number_format_style = 'i' ">
|
||||
<xsl:text> \* roman </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="$field_number_format_style = 'I' ">
|
||||
<xsl:text> \* ROMAN </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="$field_number_format_style = '一, 二, 三, ...'">
|
||||
<xsl:text> \* CHINESENUM3 </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test=" $field_number_format_style ='壹, 貳, 參, ...' or $field_number_format_style ='壹, 貳, 參, ...' or $field_number_format_style ='壹, 贰, 叁, ...' ">
|
||||
<xsl:text> \* CHINESENUM2 </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="$field_number_format_style = '壱, 弐, 参, ...' ">
|
||||
<xsl:text> \* DBNUM3 </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="$field_number_format_style = '子, 丑, 寅, ...' ">
|
||||
<xsl:text> \* ZODIAC2 </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test=" $field_number_format_style ='甲, 乙, 丙, ...' ">
|
||||
<xsl:text> \* ZODIAC1 </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="$field_number_format_style = 'イ, ロ, ハ, ...' or $field_number_format_style = 'イ, ロ, ハ, ...' ">
|
||||
<xsl:text> \* Iroha </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="$field_number_format_style ='ア, イ, ウ, ...' or $field_number_format_style ='ア, イ, ウ, ...' ">
|
||||
<xsl:text> \* Aiueo </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="$field_number_format_style = '일, 이, 삼, ...' ">
|
||||
<xsl:text> \* DBNUM1 </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="$field_number_format_style ='ㄱ, ㄴ, ㄷ, ...' or $field_number_format_style = '㉠, ㉡, ㉢, ...' ">
|
||||
<xsl:text> \* Chosung </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="$field_number_format_style = '가, 나, 다, ...' or $field_number_format_style = '㉮, ㉯, ㉰, ...' ">
|
||||
<xsl:text> \* Ganada </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="$field_number_format_style = 'ア, イ, ウ, ...' or $field_number_format_style = 'ア, イ, ウ, ...' ">
|
||||
<xsl:text> \* Aiueo </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="$field_number_format_style ='a' ">
|
||||
<xsl:text> \* alphabetic </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="$field_number_format_style ='A' ">
|
||||
<xsl:text> \* ALPHABETIC </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="$field_number_format_style = 'א, י, ק, ...' ">
|
||||
<xsl:text> \* hebrew1 </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="$field_number_format_style = 'א, ב, ג, ...' ">
|
||||
<xsl:text> \* hebrew2 </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="$field_number_format_style = 'أ, ب, ت, ...' ">
|
||||
<xsl:text> \* ArabicAlpha </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="$field_number_format_style = 'ก, ข, ฃ, ...' ">
|
||||
<xsl:text> \* ThaiLetter </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:text> </xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
<xsl:template name="field_get_date_format">
|
||||
<xsl:param name="field_date_stylename"/>
|
||||
<xsl:param name="field_date_value"/>
|
||||
<!-- this template return null date format ATM-->
|
||||
<xsl:text/>
|
||||
</xsl:template>
|
||||
<xsl:template name="field_get_time_format">
|
||||
<xsl:param name="field_time_stylename"/>
|
||||
<xsl:param name="field_time_value"/>
|
||||
<!-- this template return null date format ATM-->
|
||||
<xsl:text/>
|
||||
</xsl:template>
|
||||
<xsl:template match="text:template-name">
|
||||
<xsl:choose>
|
||||
<xsl:when test="@text:display='title' or @text:display= 'area' ">
|
||||
<!-- directly export the content -->
|
||||
<w:r>
|
||||
<w:rPr>
|
||||
<w:noProof/>
|
||||
</w:rPr>
|
||||
<w:t>
|
||||
<xsl:value-of select="."/>
|
||||
</w:t>
|
||||
</w:r>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<w:fldSimple>
|
||||
<xsl:variable name="template_attribute_value">
|
||||
<xsl:choose>
|
||||
<xsl:when test="@text:display='name-and-extension' or @text:display= 'name' ">
|
||||
<xsl:text> TEMPLATE </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test=" @text:display='full' or @text:display='path' ">
|
||||
<xsl:text>TEMPLATE \p </xsl:text>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
<xsl:text>\* MERGEFORMAT </xsl:text>
|
||||
</xsl:variable>
|
||||
<xsl:attribute name="w:instr">
|
||||
<xsl:value-of select="$template_attribute_value"/>
|
||||
</xsl:attribute>
|
||||
<w:r>
|
||||
<w:rPr>
|
||||
<w:noProof/>
|
||||
</w:rPr>
|
||||
<w:t>
|
||||
<xsl:value-of select="."/>
|
||||
</w:t>
|
||||
</w:r>
|
||||
</w:fldSimple>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
<xsl:template match="text:text-input | text:variable-input | text:user-field-input">
|
||||
<w:fldSimple>
|
||||
<xsl:variable name="text-input-attribute">
|
||||
<xsl:text>FILLIN </xsl:text>
|
||||
<xsl:if test="@text:description">
|
||||
<xsl:value-of select="@text:description"/>
|
||||
</xsl:if>
|
||||
<xsl:text> \* MERGEFORMAT</xsl:text>
|
||||
</xsl:variable>
|
||||
<xsl:attribute name="w:instr">
|
||||
<xsl:value-of select="$text-input-attribute"/>
|
||||
</xsl:attribute>
|
||||
<w:r>
|
||||
<w:rPr>
|
||||
<w:noProof/>
|
||||
</w:rPr>
|
||||
<xsl:call-template name="field_convert_linebreak">
|
||||
<xsl:with-param name="field_input_text" select="text()"/>
|
||||
</xsl:call-template>
|
||||
</w:r>
|
||||
</w:fldSimple>
|
||||
</xsl:template>
|
||||
<xsl:template name="field_convert_linebreak">
|
||||
<!-- this template convert the linebreak (
 and 
) in continuous text to Ms word element<w:br/> -->
|
||||
<xsl:param name="field_input_text"/>
|
||||
<xsl:if test="not (contains($field_input_text,'
'))">
|
||||
<w:t>
|
||||
<xsl:value-of select="$field_input_text"/>
|
||||
</w:t>
|
||||
</xsl:if>
|
||||
<xsl:if test="contains($field_input_text,'
')">
|
||||
<w:t>
|
||||
<xsl:value-of select="translate(substring-before($field_input_text,'
'),'
','')"/>
|
||||
</w:t>
|
||||
<w:br/>
|
||||
<xsl:call-template name="field_convert_linebreak">
|
||||
<xsl:with-param name="field_input_text" select="substring-after($field_input_text,'
')"/>
|
||||
</xsl:call-template>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
<xsl:template name="field_declare">
|
||||
<!-- this template export the field declaration to w:docpr -->
|
||||
<xsl:param name="simple_field_variable_declares"/>
|
||||
<xsl:param name="user_field_variable_declares"/>
|
||||
<xsl:param name="field_sequence_declares"/>
|
||||
<w:docVars>
|
||||
<xsl:if test="$simple_field_variable_declares/text:variable-decl">
|
||||
<xsl:for-each select="$simple_field_variable_declares/text:variable-decl">
|
||||
<w:docVar w:name="{@text:name}" w:val="default value"/>
|
||||
</xsl:for-each>
|
||||
</xsl:if>
|
||||
<xsl:if test="$user_field_variable_declares/text:user-field-decl">
|
||||
<xsl:for-each select="$user_field_variable_declares/text:user-field-decl">
|
||||
<w:docVar w:name="{@text:name}" w:val="{@text:string-value}"/>
|
||||
</xsl:for-each>
|
||||
</xsl:if>
|
||||
<xsl:if test="$field_sequence_declares/text:sequence-decl">
|
||||
<!-- do nothing for sequence declares when exporting to MS word-->
|
||||
</xsl:if>
|
||||
</w:docVars>
|
||||
</xsl:template>
|
||||
<xsl:template match="text:reference-ref | text:bookmark-ref | text:footnote-ref
|
||||
| text:endnote-ref ">
|
||||
<!-- this template is for reference fields -->
|
||||
<w:r>
|
||||
<w:fldChar w:fldCharType="begin"/>
|
||||
</w:r>
|
||||
<xsl:variable name="complicate_field_instruction">
|
||||
<xsl:choose>
|
||||
<xsl:when test=" name() = 'text:reference-ref' ">
|
||||
<xsl:choose>
|
||||
<xsl:when test=" string(@text:reference-format) = 'page' ">
|
||||
<xsl:value-of select="concat(' PAGEREF ', @text:ref-name, '\h') "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="string(@text:reference-format) = 'chapter' ">
|
||||
<xsl:value-of select="concat(' REF ', @text:ref-name, '\n \h') "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="string(@text:reference-format) = 'text' ">
|
||||
<xsl:value-of select="concat ( ' REF ' , @text:ref-name, ' \h') "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="string(@text:reference-format) = 'direction' ">
|
||||
<xsl:value-of select="concat(' REF ', @text:ref-name, ' \p \h' ) "/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="concat ( ' PAGEREF ', @text:ref-name, '\h')"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:when test="name() = 'text:footnote-ref' or name() = 'text:endnote-ref' ">
|
||||
<xsl:choose>
|
||||
<xsl:when test=" string(@text:reference-format) = 'page' ">
|
||||
<xsl:value-of select="concat(' PAGEREF ', @text:ref-name, '\h') "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="string(@text:reference-format) = 'chapter' ">
|
||||
<xsl:value-of select="concat(' REF ', @text:ref-name, '\n \h') "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="string(@text:reference-format) = 'text' ">
|
||||
<xsl:value-of select="concat ( ' NOTEREF ' , @text:ref-name, ' \h') "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="string(@text:reference-format) = 'direction' ">
|
||||
<xsl:value-of select="concat(' PAGEREF ', @text:ref-name, ' \p \h' ) "/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="concat ( ' PAGEREF ', @text:ref-name, '\h')"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:when test="name() = 'text:bookmark-ref' ">
|
||||
<xsl:choose>
|
||||
<xsl:when test=" string(@text:reference-format) = 'page' ">
|
||||
<xsl:value-of select="concat(' PAGEREF ', @text:ref-name, '\h') "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="string(@text:reference-format) = 'chapter' ">
|
||||
<xsl:value-of select="concat(' PAGEREF ', @text:ref-name, ' \h') "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="string(@text:reference-format) = 'text' ">
|
||||
<xsl:value-of select="concat ( ' REF ' , @text:ref-name, ' \h') "/>
|
||||
</xsl:when>
|
||||
<xsl:when test="string(@text:reference-format) = 'direction' ">
|
||||
<xsl:value-of select="concat(' REF ', @text:ref-name, ' \p \h' ) "/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="concat ( ' PAGEREF ', @text:ref-name, '\h')"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<!--start to combine the complicate field instruction -->
|
||||
<w:r>
|
||||
<w:instrText>
|
||||
<xsl:value-of select="$complicate_field_instruction"/>
|
||||
</w:instrText>
|
||||
</w:r>
|
||||
<w:r>
|
||||
<w:fldChar w:fldCharType="separate"/>
|
||||
</w:r>
|
||||
<w:r>
|
||||
<w:rPr>
|
||||
<w:noProof/>
|
||||
</w:rPr>
|
||||
<w:t>
|
||||
<xsl:value-of select="."/>
|
||||
</w:t>
|
||||
</w:r>
|
||||
<w:r>
|
||||
<w:fldChar w:fldCharType="end"/>
|
||||
</w:r>
|
||||
</xsl:template>
|
||||
<xsl:template match="text:chapter | text:sender-firstname | text:sender-lastname
|
||||
| text:sender-street | text:sender-country | text:sender-postal-code
|
||||
| text:sender-city | text:sender-title | text:sender-position
|
||||
| text:sender-phone-private | text:sender-email | text:sender-fax
|
||||
| text:sender-state-or-province | text:table-count | text:image-count
|
||||
| text:object-count | text:printed-by | text:hidden-paragraph
|
||||
| text:placeholder | text:drop-down | text:conditional-text
|
||||
| text:variable-set | text:table-formula | text:database-display
|
||||
| text:database-next | text:database-select | text:database-row-number
|
||||
| text:sequence-ref | text:expression | text:sheet-name | text:dde-connection">
|
||||
<!-- this template just export content of staroffice fields that do not have the corresponding fields in MS word ATM -->
|
||||
<w:r>
|
||||
<w:rPr>
|
||||
<w:noProof/>
|
||||
</w:rPr>
|
||||
<w:t>
|
||||
<xsl:value-of select="."/>
|
||||
</w:t>
|
||||
</w:r>
|
||||
</xsl:template>
|
||||
<xsl:template match="text:execute-macro | text:variable-decls | text:variable-decl | text:user-field-decls | text:variable-decl | text:sequence-decls | text:sequence-decl | text:page-variable-set | text:bibliography-mark | text:script | text:page-continuation ">
|
||||
<!-- this template is to ignore matched elements when exporting writer to word -->
|
||||
</xsl:template>
|
||||
<xsl:template match="text:a ">
|
||||
<xsl:call-template name="export_hyoerlink"/>
|
||||
</xsl:template>
|
||||
<xsl:template name="export_hyoerlink">
|
||||
<!-- all params are used by draw -->
|
||||
<xsl:param name="TargetMeasure"/>
|
||||
<xsl:param name="x-adjust"/>
|
||||
<xsl:param name="y-adjust"/>
|
||||
<xsl:param name="force-draw"/>
|
||||
<!-- this template processes the hyperlink in writer -->
|
||||
<xsl:variable name="hyperlink_filename">
|
||||
<xsl:choose>
|
||||
<xsl:when test="contains(@xlink:href, '#')">
|
||||
<xsl:value-of select="substring-before(@xlink:href, '#')"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="@xlink:href"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="hyperlink_bookmark">
|
||||
<xsl:if test="contains(@xlink:href, '#')">
|
||||
<xsl:choose>
|
||||
<xsl:when test="contains(@xlink:href, '%7C')">
|
||||
<xsl:call-template name="translate_string">
|
||||
<xsl:with-param name="t_input_string" select="substring-before( substring-after(@xlink:href, '#'), '%7C')"/>
|
||||
<xsl:with-param name="t_pattern_string" select=" '%20' "/>
|
||||
<xsl:with-param name="t_substitute_string" select=" ' ' "/>
|
||||
<xsl:with-param name="t_output_string" select=" '' "/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:call-template name="translate_string">
|
||||
<xsl:with-param name="t_input_string" select="substring-after(@xlink:href, '#')"/>
|
||||
<xsl:with-param name="t_pattern_string" select=" '%20' "/>
|
||||
<xsl:with-param name="t_substitute_string" select=" ' ' "/>
|
||||
<xsl:with-param name="t_output_string" select=" '' "/>
|
||||
</xsl:call-template>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:if>
|
||||
</xsl:variable>
|
||||
<w:hlink>
|
||||
<xsl:if test="@xlink:href">
|
||||
<xsl:attribute name="w:dest">
|
||||
<xsl:value-of select="$hyperlink_filename"/>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
<xsl:if test="contains(@xlink:href, '#')">
|
||||
<xsl:attribute name="w:bookmark">
|
||||
<xsl:value-of select="$hyperlink_bookmark"/>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
<xsl:if test="@office:target-frame-name">
|
||||
<xsl:attribute name="w:target">
|
||||
<xsl:value-of select="@office:target-frame-name"/>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
<xsl:if test="@office:name">
|
||||
<xsl:attribute name="w:screenTip">
|
||||
<xsl:value-of select="@office:name"/>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
<w:r>
|
||||
<w:rPr>
|
||||
<w:rStyle w:val="Hyperlink"/>
|
||||
</w:rPr>
|
||||
<!--apply inline-text-elements, many many many ... -->
|
||||
<xsl:apply-templates select="text:a | text:span | text() | text:hidden-text
|
||||
| text:line-break | text:tab-stop | text:s | text:page-number | text:page-count | text:subject
|
||||
| text:initial-creator | text:title | text:date | text:time | text:author-name
|
||||
| text:author-initials | text:chapter | text:file-name | text:sender-company
|
||||
| text:sender-firstname | text:sender-lastname | text:sender-initials | text:sender-street
|
||||
| text:sender-country | text:sender-postal-code | text:sender-city | text:sender-title
|
||||
| text:sender-position | text:sender-phone-private | text:sender-phone-work
|
||||
| text:sender-email | text:sender-fax | text:sender-state-or-province | text:word-count
|
||||
| text:paragraph-count | text:character-count | text:table-count | text:image-count
|
||||
| text:object-count | text:template-name | text:description | text:creation-time
|
||||
| text:creation-date | text:editing-cycles | text:editing-duration | text:keywords
|
||||
| text:print-time | text:print-date | text:creator | text:modification-time
|
||||
| text:modification-date | text:user-defined | text:printed-by | text:hidden-paragraph
|
||||
| text:placeholder | text:drop-down | text:conditional-text | text:text-input
|
||||
| text:execute-macro | text:variable-set | text:variable-input
|
||||
| text:user-field-input | text:variable-get | text:user-field-get | text:sequence
|
||||
| text:page-variable-set | text:page-variable-get | text:table-formula
|
||||
| text:database-display | text:database-next| text:database-select
|
||||
| text:database-row-number | text:database-name | text:reference-ref
|
||||
| text:bookmark-ref | text:footnote-ref | text:endnote-ref | text:sequence-ref
|
||||
| text:expression | text:measure | text:dde-connection | text:sheet-name
|
||||
| text:bibliography-mark | text:script | text:page-continuation | office:annotation
|
||||
| draw:*">
|
||||
<xsl:with-param name="TargetMeasure" select="$TargetMeasure"/>
|
||||
<xsl:with-param name="x-adjust" select="$x-adjust"/>
|
||||
<xsl:with-param name="y-adjust" select="$y-adjust"/>
|
||||
<xsl:with-param name="force-draw" select="$force-draw"/>
|
||||
</xsl:apply-templates>
|
||||
</w:r>
|
||||
</w:hlink>
|
||||
</xsl:template>
|
||||
<xsl:template name="translate_string">
|
||||
<!-- this template is to replace the substring matched t_pattern_string in t_t_input_string with t_substitute_string G.Y.-->
|
||||
<xsl:param name="t_input_string"/>
|
||||
<xsl:param name="t_pattern_string"/>
|
||||
<xsl:param name="t_substitute_string"/>
|
||||
<xsl:param name="t_output_string"/>
|
||||
<xsl:variable name="t_temp_output_string">
|
||||
<xsl:if test="contains($t_input_string, $t_pattern_string) ">
|
||||
<xsl:value-of select="concat($t_output_string, substring-before($t_input_string,$t_pattern_string), $t_substitute_string) "/>
|
||||
</xsl:if>
|
||||
<xsl:if test="not (contains($t_input_string, $t_pattern_string)) ">
|
||||
<xsl:value-of select="$t_output_string"/>
|
||||
</xsl:if>
|
||||
</xsl:variable>
|
||||
<xsl:if test="contains($t_input_string, $t_pattern_string) ">
|
||||
<xsl:call-template name="translate_string">
|
||||
<xsl:with-param name="t_input_string" select="substring-after($t_input_string,$t_pattern_string)"/>
|
||||
<xsl:with-param name="t_pattern_string" select="$t_pattern_string"/>
|
||||
<xsl:with-param name="t_substitute_string" select="$t_substitute_string"/>
|
||||
<xsl:with-param name="t_output_string" select="$t_temp_output_string"/>
|
||||
</xsl:call-template>
|
||||
</xsl:if>
|
||||
<xsl:if test="not (contains($t_input_string, $t_pattern_string))">
|
||||
<xsl:value-of select="concat($t_temp_output_string, $t_input_string)"/>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
<xsl:template name="add_hyperlink_style">
|
||||
<!--this template is to add the hyperlink related style -->
|
||||
<w:style w:type="character" w:styleId="Hyperlink">
|
||||
<w:name w:val="Hyperlink"/>
|
||||
<w:rsid w:val="006A55B0"/>
|
||||
<w:rPr>
|
||||
<w:color w:val="000080"/>
|
||||
<w:u w:val="single"/>
|
||||
</w:rPr>
|
||||
</w:style>
|
||||
<w:style w:type="character" w:styleId="FollowedHyperlink">
|
||||
<w:name w:val="FollowedHyperlink"/>
|
||||
<w:rsid w:val="006A55B0"/>
|
||||
<w:rPr>
|
||||
<w:color w:val="800000"/>
|
||||
<w:u w:val="single"/>
|
||||
</w:rPr>
|
||||
</w:style>
|
||||
</xsl:template>
|
||||
<xsl:template match="office:annotation">
|
||||
<!-- this template export writer note to word comments -->
|
||||
<xsl:variable name="comments_aml_id">
|
||||
<xsl:call-template name="unique_amlid_generator"/>
|
||||
</xsl:variable>
|
||||
<aml:annotation w:type="Word.Comment.Start">
|
||||
<xsl:attribute name="aml:id">
|
||||
<xsl:value-of select="$comments_aml_id"/>
|
||||
</xsl:attribute>
|
||||
</aml:annotation>
|
||||
<aml:annotation w:type="Word.Comment.End">
|
||||
<xsl:attribute name="aml:id">
|
||||
<xsl:value-of select="$comments_aml_id"/>
|
||||
</xsl:attribute>
|
||||
</aml:annotation>
|
||||
<!-- export aml:annotation content-->
|
||||
<w:r>
|
||||
<w:rPr>
|
||||
<w:rStyle w:val="CommentReference"/>
|
||||
</w:rPr>
|
||||
<aml:annotation aml:author="{@office:author}" aml:createdate="{@office:create-date}" w:type="Word.Comment" w:initials="{@office:author}">
|
||||
<xsl:attribute name="aml:id">
|
||||
<xsl:value-of select="$comments_aml_id"/>
|
||||
</xsl:attribute>
|
||||
<aml:content>
|
||||
<xsl:apply-templates select="text:p"/>
|
||||
</aml:content>
|
||||
</aml:annotation>
|
||||
</w:r>
|
||||
<!-- end of export aml:annotation content-->
|
||||
</xsl:template>
|
||||
<xsl:template name="unique_amlid_generator">
|
||||
<!-- this template generate unique id for aml:id, ATM it only counts the office:annotation, some other elements might be added later -->
|
||||
<xsl:number count="office:annotation" from="/office:document/office:body" level="any" format="1"/>
|
||||
</xsl:template>
|
||||
<xsl:template name="add_comments_style">
|
||||
<w:style w:type="character" w:styleId="CommentReference">
|
||||
<w:name w:val="annotation reference"/>
|
||||
<w:basedOn w:val="DefaultParagraphFont"/>
|
||||
<w:semiHidden/>
|
||||
<w:rsid w:val="007770B7"/>
|
||||
<w:rPr>
|
||||
<w:sz w:val="16"/>
|
||||
<w:sz-cs w:val="16"/>
|
||||
</w:rPr>
|
||||
</w:style>
|
||||
<w:style w:type="paragraph" w:styleId="CommentText">
|
||||
<w:name w:val="annotation text"/>
|
||||
<w:basedOn w:val="Normal"/>
|
||||
<w:semiHidden/>
|
||||
<w:rsid w:val="007770B7"/>
|
||||
<w:pPr>
|
||||
<w:pStyle w:val="CommentText"/>
|
||||
</w:pPr>
|
||||
<w:rPr>
|
||||
<w:sz w:val="20"/>
|
||||
<w:sz-cs w:val="20"/>
|
||||
</w:rPr>
|
||||
</w:style>
|
||||
<w:style w:type="paragraph" w:styleId="CommentSubject">
|
||||
<w:name w:val="annotation subject"/>
|
||||
<w:basedOn w:val="CommentText"/>
|
||||
<w:next w:val="CommentText"/>
|
||||
<w:semiHidden/>
|
||||
<w:rsid w:val="007770B7"/>
|
||||
<w:pPr>
|
||||
<w:pStyle w:val="CommentSubject"/>
|
||||
</w:pPr>
|
||||
<w:rPr>
|
||||
<w:b/>
|
||||
<w:b-cs/>
|
||||
</w:rPr>
|
||||
</w:style>
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>
|
||||
@@ -0,0 +1,349 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
* This file is part of the LibreOffice project.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* This file incorporates work covered by the following license notice:
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed
|
||||
* with this work for additional information regarding copyright
|
||||
* ownership. The ASF licenses this file to you under the Apache
|
||||
* License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
||||
-->
|
||||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml" xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:aml="http://schemas.microsoft.com/aml/2001/core" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" exclude-result-prefixes="office table style text draw svg dc config xlink meta oooc dom ooo chart math dr3d form script ooow draw">
|
||||
<xsl:template name="ListStyles">
|
||||
<w:lists>
|
||||
<xsl:if test="descendant::text:list-level-style-image">
|
||||
<xsl:call-template name="PicLists"/>
|
||||
</xsl:if>
|
||||
<xsl:apply-templates select="office:styles/text:outline-style | office:styles/text:list-style | office:automatic-styles/text:list-style" mode="style"/>
|
||||
<xsl:for-each select="office:styles/text:outline-style | office:styles/text:list-style | office:automatic-styles/text:list-style">
|
||||
<w:list w:ilfo="{position()}">
|
||||
<w:ilst w:val="{position()-1}"/>
|
||||
</w:list>
|
||||
</xsl:for-each>
|
||||
</w:lists>
|
||||
</xsl:template>
|
||||
<xsl:template match="text:list-style | text:outline-style" mode="style">
|
||||
<w:listDef w:listDefId="{position()-1}">
|
||||
<xsl:if test="name(..)='office:styles' and name()!='text:outline-style'">
|
||||
<w:styleLink w:val="{@style:name}"/>
|
||||
</xsl:if>
|
||||
<xsl:for-each select="text:list-level-style-number | text:list-level-style-bullet | text:list-level-style-image | text:outline-level-style">
|
||||
<xsl:if test="@text:level < 10">
|
||||
<w:lvl w:ilvl="{ @text:level - 1 }">
|
||||
<xsl:if test="name()='text:outline-level-style'">
|
||||
<xsl:variable name="headinglevel">
|
||||
<xsl:value-of select="@text:level"/>
|
||||
</xsl:variable>
|
||||
<xsl:if test="/office:document/office:body//text:h[@text:level=$headinglevel and @text:style-name]">
|
||||
<xsl:element name="w:pStyle">
|
||||
<xsl:attribute name="w:val"><xsl:value-of select="/office:document/office:body//text:h[@text:level=$headinglevel]/@text:style-name"/></xsl:attribute>
|
||||
</xsl:element>
|
||||
</xsl:if>
|
||||
</xsl:if>
|
||||
<xsl:choose>
|
||||
<xsl:when test="@text:start-value">
|
||||
<w:start w:val="{@text:start-value}"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<w:start w:val="1"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:choose>
|
||||
<xsl:when test="@text:bullet-char">
|
||||
<w:nfc w:val="23"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="@style:num-format">
|
||||
<xsl:call-template name="convert_list_number">
|
||||
<xsl:with-param name="number-format" select="@style:num-format"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
<xsl:choose>
|
||||
<xsl:when test="name()='text:list-level-style-image'">
|
||||
<w:lvlText w:val="."/>
|
||||
<w:lvlPicBulletId>
|
||||
<xsl:attribute name="w:val"><xsl:value-of select="count(preceding::text:list-level-style-image)"/></xsl:attribute>
|
||||
</w:lvlPicBulletId>
|
||||
</xsl:when>
|
||||
<xsl:when test="@text:bullet-char">
|
||||
<w:lvlText w:val="{@text:bullet-char}"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="@text:display-levels and not(../@text:consecutive-numbering='true')">
|
||||
<xsl:variable name="levelText">
|
||||
<xsl:call-template name="displaylevel">
|
||||
<xsl:with-param name="number" select="@text:display-levels"/>
|
||||
<xsl:with-param name="textlevel" select="@text:level"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<w:lvlText w:val="{concat(@style:num-prefix, substring-after($levelText, '.'), @style:num-suffix)}"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<w:lvlText w:val="{concat(@style:num-prefix, '%', @text:level, @style:num-suffix)}"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:choose>
|
||||
<xsl:when test="style:list-level-properties/@fo:text-align = 'end'">
|
||||
<w:lvlJc w:val="right"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="style:list-level-properties/@fo:text-align = 'center'">
|
||||
<w:lvlJc w:val="center"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<w:lvlJc w:val="left"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:choose>
|
||||
<xsl:when test="style:list-level-properties/@text:space-before | style:list-level-properties/@text:min-label-width | style:list-level-properties/@text:min-label-distance">
|
||||
<xsl:call-template name="list_position"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<w:suff w:val="Nothing"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:apply-templates select="key('text-style',@text:style-name)/style:text-properties" mode="character"/>
|
||||
<xsl:apply-templates select="style:text-properties" mode="character"/>
|
||||
</w:lvl>
|
||||
</xsl:if>
|
||||
</xsl:for-each>
|
||||
</w:listDef>
|
||||
</xsl:template>
|
||||
<xsl:template match="text:list-style" mode="count">
|
||||
<xsl:value-of select="count(preceding::text:list-style | preceding::text:outline-style)+1"/>
|
||||
</xsl:template>
|
||||
<xsl:template match="text:unordered-list | text:ordered-list | text:list">
|
||||
<xsl:apply-templates select="text:unordered-list | text:ordered-list | text:list-item | text:list-header | text:list"/>
|
||||
</xsl:template>
|
||||
<xsl:template match="text:list-item | text:list-header">
|
||||
<xsl:apply-templates select="text:unordered-list | text:ordered-list | text:list | text:p | text:h"/>
|
||||
</xsl:template>
|
||||
<xsl:template name="displaylevel">
|
||||
<xsl:param name="number"/>
|
||||
<xsl:param name="textlevel"/>
|
||||
<xsl:if test="$number > 1">
|
||||
<xsl:call-template name="displaylevel">
|
||||
<xsl:with-param name="number" select="$number -1"/>
|
||||
<xsl:with-param name="textlevel" select="number($textlevel)-1"/>
|
||||
</xsl:call-template>
|
||||
</xsl:if>
|
||||
<xsl:value-of select="concat('.','%',$textlevel)"/>
|
||||
</xsl:template>
|
||||
<xsl:template name="list_position">
|
||||
<xsl:variable name="spacebefore">
|
||||
<xsl:choose>
|
||||
<xsl:when test="style:list-level-properties/@text:space-before">
|
||||
<xsl:call-template name="convert2twip">
|
||||
<xsl:with-param name="value" select="style:list-level-properties/@text:space-before"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>0</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="space2text">
|
||||
<xsl:choose>
|
||||
<xsl:when test="style:list-level-properties/@text:min-label-width">
|
||||
<xsl:call-template name="convert2twip">
|
||||
<xsl:with-param name="value" select="style:list-level-properties/@text:min-label-width"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>0</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="spacedistance">
|
||||
<xsl:choose>
|
||||
<xsl:when test="style:list-level-properties/@text:min-label-distance">
|
||||
<xsl:call-template name="convert2twip">
|
||||
<xsl:with-param name="value" select="style:list-level-properties/@text:min-label-distance"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>0</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<xsl:if test="$spacedistance='0' and $space2text='0'">
|
||||
<w:suff w:val="Nothing"/>
|
||||
</xsl:if>
|
||||
<w:pPr>
|
||||
<xsl:if test="$spacedistance!='0' or $space2text!='0'">
|
||||
<w:tabs>
|
||||
<w:tab>
|
||||
<xsl:attribute name="w:val">list</xsl:attribute>
|
||||
<xsl:attribute name="w:pos"><xsl:choose><xsl:when test="number($spacedistance) > number($space2text)"><xsl:value-of select="number($spacebefore)+number($spacedistance)+150"/></xsl:when><xsl:otherwise><xsl:value-of select="number($spacebefore)+number($space2text)+150"/></xsl:otherwise></xsl:choose></xsl:attribute>
|
||||
<!-- Since SO MinSpaceDistance is width after number or bullet, MS TabSpaceAfter include the number or bullet width. So +150 -->
|
||||
</w:tab>
|
||||
</w:tabs>
|
||||
</xsl:if>
|
||||
<w:ind w:left="{number($space2text)+number($spacebefore)}" w:hanging="{$space2text}"/>
|
||||
<!-- w:pos(MS TabSpaceAfter) = text:space-before + MAX(text:min-label-distance,text:min-label-width) + ( Symbol width ); w:left(MS IndentAt)= text:space-before + text:min-label-width; w:hanging(MS IndentAt - MS AlignedAt)=text:min-label-width -->
|
||||
</w:pPr>
|
||||
</xsl:template>
|
||||
<xsl:template name="PicLists">
|
||||
<xsl:for-each select="descendant::text:list-level-style-image">
|
||||
<w:listPicBullet w:listPicBulletId="{position()-1}">
|
||||
<w:pict>
|
||||
<v:shape>
|
||||
<xsl:variable name="Picwidth">
|
||||
<xsl:call-template name="convert2pt">
|
||||
<xsl:with-param name="value" select="style:list-level-properties/@fo:width"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="Picheight">
|
||||
<xsl:call-template name="convert2pt">
|
||||
<xsl:with-param name="value" select="style:list-level-properties/@fo:height"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:attribute name="style"><xsl:value-of select="concat('width:', number($Picwidth*1), 'pt;height:', number($Picheight*1), 'pt')"/></xsl:attribute>
|
||||
<xsl:attribute name="o:bullet">t</xsl:attribute>
|
||||
<v:stroke joinstyle="miter"/>
|
||||
<w:binData w:name="{concat('wordml://SOpicbullet', position(), '.gif')}">
|
||||
<xsl:value-of select="office:binary-data"/>
|
||||
</w:binData>
|
||||
<v:imagedata src="{concat('wordml://SOpicbullet', position(), '.gif')}" o:title="{concat('SOpicbullet', position())}"/>
|
||||
</v:shape>
|
||||
</w:pict>
|
||||
</w:listPicBullet>
|
||||
</xsl:for-each>
|
||||
</xsl:template>
|
||||
<xsl:template name="convert_list_number">
|
||||
<xsl:param name="number-format"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$number-format = 'a'">
|
||||
<!-- nfcLCLetter: Lowercase alpha -->
|
||||
<w:nfc w:val="4"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$number-format = 'A'">
|
||||
<!-- nfcUCLetter: Uppercase alpha -->
|
||||
<w:nfc w:val="3"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$number-format = 'i'">
|
||||
<!-- nfcLCRoman: Lowercase roman -->
|
||||
<w:nfc w:val="2"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$number-format = 'I'">
|
||||
<!-- nfcUCRoman: Uppercase roman -->
|
||||
<w:nfc w:val="1"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$number-format = '1st'">
|
||||
<!-- nfcUCOrdinal: Ordinal indicator -->
|
||||
<w:nfc w:val="5"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$number-format = 'One'">
|
||||
<!-- nfcCardText: Cardinal -->
|
||||
<w:nfc w:val="6"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$number-format = 'First'">
|
||||
<!-- nfcOrdText: Ordinal -->
|
||||
<w:nfc w:val="7"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$number-format = '1, 2, 3, ...'">
|
||||
<!-- '1, 2, 3, ...' also seems: decimal-full-width2 -->
|
||||
<w:nfc w:val="14"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$number-format = '①, ②, ③, ...'">
|
||||
<w:nfc w:val="18"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$number-format = '一, 二, 三, ...'">
|
||||
<!-- '一, 二, 三, ...' also seems: ideograph-digital, japanese-counting, japanese-digital-ten-thousand,
|
||||
taiwanese-counting, taiwanese-counting-thousand, taiwanese-digital, chinese-counting, korean-digital2 -->
|
||||
<w:nfc w:val="10"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$number-format = '壹, 贰, 叁, ...'">
|
||||
<w:nfc w:val="38"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$number-format = '壹, 貳, 參, ...'">
|
||||
<w:nfc w:val="34"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$number-format = '甲, 乙, 丙, ...'">
|
||||
<w:nfc w:val="30"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$number-format = '子, 丑, 寅, ...'">
|
||||
<w:nfc w:val="31"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$number-format = '壱, 弐, 参, ...'">
|
||||
<w:nfc w:val="16"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$number-format = 'ア, イ, ウ, ...'">
|
||||
<w:nfc w:val="12"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$number-format = 'ア, イ, ウ, ...'">
|
||||
<w:nfc w:val="20"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$number-format = 'イ, ロ, ハ, ...'">
|
||||
<w:nfc w:val="13"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$number-format = 'イ, ロ, ハ, ...'">
|
||||
<w:nfc w:val="21"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$number-format = '일, 이, 삼, ...'">
|
||||
<w:nfc w:val="42"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$number-format = '하나, 둘, 셋, ...'">
|
||||
<w:nfc w:val="43"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$number-format = 'ㄱ, ㄴ, ㄷ, ...' or $number-format = '㉠, ㉡, ㉢, ...'">
|
||||
<!-- mapping circled to uncircled -->
|
||||
<w:nfc w:val="25"/>
|
||||
</xsl:when>
|
||||
<xsl:when test='$number-format = "가, 나, 다, ..." or $number-format = "㉮, ㉯, ㉰, ..."'>
|
||||
<!-- mapping circled to uncircled -->
|
||||
<w:nfc w:val="24"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$number-format ='أ, ب, ت, ...'">
|
||||
<!-- 46. arabic-alpha-->
|
||||
<w:nfc w:val="46"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$number-format = 'ก, ข, ฃ, ...'">
|
||||
<!--53. thai-letters not match well !-->
|
||||
<w:nfc w:val="53"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$number-format='א, י, ק, ...'">
|
||||
<!--45. hebrew-1-->
|
||||
<w:nfc w:val="45"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$number-format='א, ב, ג, ...'">
|
||||
<!--47. hebrew-2-->
|
||||
<w:nfc w:val="47"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="string-length($number-format)=0">
|
||||
<w:nfc w:val="255"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$number-format = 'Native Numbering'">
|
||||
<xsl:variable name="locale" select="/office:document/office:meta/dc:language"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="starts-with($locale, 'th-')">
|
||||
<!-- for Thai, mapping thai-numbers, thai-counting to thai-numbers -->
|
||||
<w:nfc w:val="54"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="starts-with($locale, 'hi-')">
|
||||
<!-- for Hindi, mapping hindi-vowels, hindi-consonants, hindi-counting to hindi-numbers -->
|
||||
<w:nfc w:val="51"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="starts-with($locale, 'ar-')">
|
||||
<!-- for Arabic, mapping arabic-abjad to arabic-alpha -->
|
||||
<w:nfc w:val="45"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="starts-with($locale, 'he-')">
|
||||
<!-- for Hebrew, mapping hebrew-2 to -->
|
||||
<w:nfc w:val="46"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="starts-with($locale, 'ru-')">
|
||||
<!-- for Russian, mapping russian-upper to russian-lower -->
|
||||
<w:nfc w:val="58"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="starts-with($locale, 'vi-')">
|
||||
<!-- for Vietnamese -->
|
||||
<w:nfc w:val="56"/>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<!-- unsupported: hex, chicago, bullet, ideograph-zodiac-traditional,
|
||||
chinese-not-impl, korean-legal, none -->
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>
|
||||
@@ -0,0 +1,392 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
* This file is part of the LibreOffice project.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* This file incorporates work covered by the following license notice:
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed
|
||||
* with this work for additional information regarding copyright
|
||||
* ownership. The ASF licenses this file to you under the Apache
|
||||
* License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
||||
-->
|
||||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml" xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:aml="http://schemas.microsoft.com/aml/2001/core" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" exclude-result-prefixes="office table style text draw svg dc config xlink meta oooc dom ooo chart math dr3d form script ooow draw">
|
||||
<xsl:template name="page-background">
|
||||
<xsl:choose>
|
||||
<xsl:when test="/office:document/office:automatic-styles/style:page-layout/style:page-layout-properties/style:background-image[string-length(office:binary-data/text()) > 0]">
|
||||
<w:bgPict>
|
||||
<xsl:apply-templates select="/office:document/office:automatic-styles/style:page-layout/style:page-layout-properties/style:background-image[string-length(office:binary-data/text()) > 0]" mode="bgPict"/>
|
||||
</w:bgPict>
|
||||
</xsl:when>
|
||||
<xsl:when test="/office:document/office:automatic-styles/style:page-layout/style:page-layout-properties[string-length(@fo:background-color) > 0]">
|
||||
<w:bgPict>
|
||||
<xsl:apply-templates select="/office:document/office:automatic-styles/style:page-layout/style:page-layout-properties[string-length(@fo:background-color) > 0]" mode="bgPict"/>
|
||||
</w:bgPict>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
<xsl:template match="style:background-image" mode="bgPict">
|
||||
<xsl:variable name="binName" select="concat('wordml://',generate-id(.))"/>
|
||||
<w:binData w:name="{$binName}">
|
||||
<xsl:value-of select="translate(office:binary-data/text(),'	  ','' ) "/>
|
||||
</w:binData>
|
||||
<w:background w:bgcolor="{parent::style:page-layout-properties/@fo:background-color}" w:background="{$binName}"/>
|
||||
</xsl:template>
|
||||
<xsl:template match="style:page-layout-properties" mode="bgPict">
|
||||
<w:background w:bgcolor="{@fo:background-color}"/>
|
||||
</xsl:template>
|
||||
<xsl:template match="style:master-page">
|
||||
<xsl:apply-templates select="key( 'page-layout', @style:page-layout-name)"/>
|
||||
<xsl:if test="style:header">
|
||||
<w:hdr w:type="odd">
|
||||
<xsl:apply-templates select="style:header/text:p | style:header/table:table"/>
|
||||
<!-- change style:header//text:p to style:header/text:p and add table:table here, fix for Issue 32035 -->
|
||||
</w:hdr>
|
||||
</xsl:if>
|
||||
<xsl:if test="style:header-left">
|
||||
<w:hdr w:type="even">
|
||||
<xsl:apply-templates select="style:header-left/text:p | style:header-left/table:table"/>
|
||||
<!-- change style:header//text:p to style:header/text:p and add table:table here, fix for Issue 32035 -->
|
||||
</w:hdr>
|
||||
</xsl:if>
|
||||
<xsl:if test="style:footer">
|
||||
<w:ftr w:type="odd">
|
||||
<xsl:apply-templates select="style:footer/text:p | style:footer/table:table"/>
|
||||
<!-- change style:header//text:p to style:header/text:p and add table:table here, fix for Issue 32035 -->
|
||||
</w:ftr>
|
||||
</xsl:if>
|
||||
<xsl:if test="style:footer-left">
|
||||
<w:ftr w:type="even">
|
||||
<xsl:apply-templates select="style:footer-left/text:p | style:footer-left/table:table"/>
|
||||
<!-- change style:header//text:p to style:header/text:p and add table:table here, fix for Issue 32035 -->
|
||||
</w:ftr>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
<xsl:template match="style:page-layout">
|
||||
<xsl:choose>
|
||||
<xsl:when test="@style:page-usage = 'left'">
|
||||
<w:type w:val="even-page"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="@style:page-usage = 'right'">
|
||||
<w:type w:val="odd-page"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="@style:page-usage = 'all'">
|
||||
<w:type w:val="next-page"/>
|
||||
</xsl:when>
|
||||
<!-- for mirrored, and default -->
|
||||
<xsl:otherwise>
|
||||
<w:type w:val="next-page"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:variable name="page-width">
|
||||
<xsl:if test="style:page-layout-properties/@fo:page-width">
|
||||
<xsl:call-template name="convert2twip">
|
||||
<xsl:with-param name="value" select="style:page-layout-properties/@fo:page-width"/>
|
||||
</xsl:call-template>
|
||||
</xsl:if>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="margin-left">
|
||||
<xsl:if test="style:page-layout-properties/@fo:margin-left">
|
||||
<xsl:call-template name="convert2twip">
|
||||
<xsl:with-param name="value" select="style:page-layout-properties/@fo:margin-left"/>
|
||||
</xsl:call-template>
|
||||
</xsl:if>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="margin-right">
|
||||
<xsl:if test="style:page-layout-properties/@fo:margin-right">
|
||||
<xsl:call-template name="convert2twip">
|
||||
<xsl:with-param name="value" select="style:page-layout-properties/@fo:margin-right"/>
|
||||
</xsl:call-template>
|
||||
</xsl:if>
|
||||
</xsl:variable>
|
||||
<w:pgSz>
|
||||
<xsl:if test="style:page-layout-properties/@fo:page-width">
|
||||
<xsl:attribute name="w:w">
|
||||
<xsl:value-of select="$page-width"/>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
<xsl:if test="style:page-layout-properties/@fo:page-height">
|
||||
<xsl:attribute name="w:h">
|
||||
<xsl:call-template name="convert2twip">
|
||||
<xsl:with-param name="value" select="style:page-layout-properties/@fo:page-height"/>
|
||||
</xsl:call-template>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
<xsl:if test="style:page-layout-properties/@style:print-orientation">
|
||||
<xsl:attribute name="w:orient">
|
||||
<xsl:value-of select="style:page-layout-properties/@style:print-orientation"/>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
</w:pgSz>
|
||||
<w:pgMar>
|
||||
<xsl:if test="style:page-layout-properties/@fo:margin-top">
|
||||
<xsl:variable name="top-margin">
|
||||
<xsl:call-template name="convert2twip">
|
||||
<xsl:with-param name="value" select="style:page-layout-properties/@fo:margin-top"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:attribute name="w:top">
|
||||
<xsl:value-of select="$top-margin"/>
|
||||
</xsl:attribute>
|
||||
<xsl:if test="style:header-style/style:page-layout-properties/@fo:min-height">
|
||||
<xsl:variable name="header-height">
|
||||
<xsl:call-template name="convert2twip">
|
||||
<xsl:with-param name="value" select="style:header-style/style:page-layout-properties/@fo:min-height"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:attribute name="w:header">
|
||||
<xsl:value-of select="$top-margin - $header-height"/>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
</xsl:if>
|
||||
<xsl:if test="style:page-layout-properties/@fo:margin-bottom">
|
||||
<xsl:variable name="bottom-margin">
|
||||
<xsl:call-template name="convert2twip">
|
||||
<xsl:with-param name="value" select="style:page-layout-properties/@fo:margin-bottom"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:attribute name="w:bottom">
|
||||
<xsl:value-of select="$bottom-margin"/>
|
||||
</xsl:attribute>
|
||||
<xsl:if test="style:footer-style/style:page-layout-properties/@fo:min-height">
|
||||
<xsl:variable name="footer-height">
|
||||
<xsl:call-template name="convert2twip">
|
||||
<xsl:with-param name="value" select="style:footer-style/style:page-layout-properties/@fo:min-height"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:attribute name="w:footer">
|
||||
<xsl:value-of select="$bottom-margin - $footer-height"/>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
</xsl:if>
|
||||
<xsl:if test="style:page-layout-properties/@fo:margin-left">
|
||||
<xsl:attribute name="w:left">
|
||||
<xsl:value-of select="$margin-left"/>
|
||||
</xsl:attribute>
|
||||
<xsl:attribute name="w:gutter">
|
||||
<xsl:value-of select="'0'"/>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
<xsl:if test="style:page-layout-properties/@fo:margin-right">
|
||||
<xsl:attribute name="w:right">
|
||||
<xsl:value-of select="$margin-right"/>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
</w:pgMar>
|
||||
<xsl:variable name="border-top" select="style:page-layout-properties/@fo:border-top | style:page-layout-properties/@fo:border"/>
|
||||
<xsl:variable name="border-bottom" select="style:page-layout-properties/@fo:border-bottom | style:page-layout-properties/@fo:border"/>
|
||||
<xsl:variable name="border-left" select="style:page-layout-properties/@fo:border-left | style:page-layout-properties/@fo:border"/>
|
||||
<xsl:variable name="border-right" select="style:page-layout-properties/@fo:border-right | style:page-layout-properties/@fo:border"/>
|
||||
<xsl:variable name="border-line-width-top" select="style:page-layout-properties/@style:border-line-width-top | style:page-layout-properties/@style:border-line-width "/>
|
||||
<xsl:variable name="border-line-width-bottom" select="style:page-layout-properties/@style:border-line-width-bottom | style:page-layout-properties/@style:border-line-width"/>
|
||||
<xsl:variable name="border-line-width-left" select="style:page-layout-properties/@style:border-line-width-left | style:page-layout-properties/@style:border-line-width"/>
|
||||
<xsl:variable name="border-line-width-right" select="style:page-layout-properties/@style:border-line-width-right | style:page-layout-properties/@style:border-line-width"/>
|
||||
<xsl:variable name="padding-top" select="style:page-layout-properties/@fo:padding-top | style:page-layout-properties/@fo:padding"/>
|
||||
<xsl:variable name="padding-bottom" select="style:page-layout-properties/@fo:padding-bottom | style:page-layout-properties/@fo:padding"/>
|
||||
<xsl:variable name="padding-left" select="style:page-layout-properties/@fo:padding-left | style:page-layout-properties/@fo:padding"/>
|
||||
<xsl:variable name="padding-right" select="style:page-layout-properties/@fo:padding-right | style:page-layout-properties/@fo:padding"/>
|
||||
<w:pgBorders w:offset-from="text">
|
||||
<xsl:if test="$border-top">
|
||||
<xsl:element name="w:top">
|
||||
<xsl:call-template name="get-border">
|
||||
<xsl:with-param name="so-border" select="$border-top"/>
|
||||
<xsl:with-param name="so-border-line-width" select="$border-line-width-top"/>
|
||||
<xsl:with-param name="so-border-position" select=" 'top' "/>
|
||||
</xsl:call-template>
|
||||
<xsl:attribute name="w:space">
|
||||
<xsl:call-template name="convert2pt">
|
||||
<xsl:with-param name="value" select="$padding-top"/>
|
||||
</xsl:call-template>
|
||||
</xsl:attribute>
|
||||
<xsl:if test="style:page-layout-properties/@style:shadow!='none'">
|
||||
<xsl:attribute name="w:shadow">on</xsl:attribute>
|
||||
</xsl:if>
|
||||
</xsl:element>
|
||||
</xsl:if>
|
||||
<xsl:if test="$border-bottom">
|
||||
<xsl:element name="w:bottom">
|
||||
<xsl:call-template name="get-border">
|
||||
<xsl:with-param name="so-border" select="$border-bottom"/>
|
||||
<xsl:with-param name="so-border-line-width" select="$border-line-width-bottom"/>
|
||||
<xsl:with-param name="so-border-position" select=" 'bottom' "/>
|
||||
</xsl:call-template>
|
||||
<xsl:attribute name="w:space">
|
||||
<xsl:call-template name="convert2pt">
|
||||
<xsl:with-param name="value" select="$padding-bottom"/>
|
||||
</xsl:call-template>
|
||||
</xsl:attribute>
|
||||
<xsl:if test="style:page-layout-properties/@style:shadow!='none'">
|
||||
<xsl:attribute name="w:shadow">on</xsl:attribute>
|
||||
</xsl:if>
|
||||
</xsl:element>
|
||||
</xsl:if>
|
||||
<xsl:if test="$border-left">
|
||||
<xsl:element name="w:left">
|
||||
<xsl:call-template name="get-border">
|
||||
<xsl:with-param name="so-border" select="$border-left"/>
|
||||
<xsl:with-param name="so-border-line-width" select="$border-line-width-left"/>
|
||||
<xsl:with-param name="so-border-position" select=" 'left' "/>
|
||||
</xsl:call-template>
|
||||
<xsl:attribute name="w:space">
|
||||
<xsl:call-template name="convert2pt">
|
||||
<xsl:with-param name="value" select="$padding-left"/>
|
||||
</xsl:call-template>
|
||||
</xsl:attribute>
|
||||
<xsl:if test="style:page-layout-properties/@style:shadow!='none'">
|
||||
<xsl:attribute name="w:shadow">on</xsl:attribute>
|
||||
</xsl:if>
|
||||
</xsl:element>
|
||||
</xsl:if>
|
||||
<xsl:if test="$border-right">
|
||||
<xsl:element name="w:right">
|
||||
<xsl:call-template name="get-border">
|
||||
<xsl:with-param name="so-border" select="$border-right"/>
|
||||
<xsl:with-param name="so-border-line-width" select="$border-line-width-right"/>
|
||||
<xsl:with-param name="so-border-position" select=" 'right' "/>
|
||||
</xsl:call-template>
|
||||
<xsl:attribute name="w:space">
|
||||
<xsl:call-template name="convert2pt">
|
||||
<xsl:with-param name="value" select="$padding-right"/>
|
||||
</xsl:call-template>
|
||||
</xsl:attribute>
|
||||
<xsl:if test="style:page-layout-properties/@style:shadow!='none'">
|
||||
<xsl:attribute name="w:shadow">on</xsl:attribute>
|
||||
</xsl:if>
|
||||
</xsl:element>
|
||||
</xsl:if>
|
||||
</w:pgBorders>
|
||||
<xsl:variable name="valid-width">
|
||||
<xsl:value-of select="$page-width - $margin-left - $margin-right"/>
|
||||
</xsl:variable>
|
||||
<xsl:apply-templates select="style:page-layout-properties/style:columns">
|
||||
<xsl:with-param name="page-width" select="$valid-width"/>
|
||||
</xsl:apply-templates>
|
||||
<xsl:apply-templates select="/office:document/office:styles/text:linenumbering-configuration"/>
|
||||
</xsl:template>
|
||||
<xsl:template match="text:linenumbering-configuration">
|
||||
<xsl:if test="not(@text:number-lines = 'false')">
|
||||
<xsl:element name="w:lnNumType">
|
||||
<xsl:if test="@text:increment">
|
||||
<xsl:attribute name="w:count-by">
|
||||
<xsl:value-of select="@text:increment"/>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
<xsl:if test="@text:offset">
|
||||
<xsl:attribute name="w:distance">
|
||||
<xsl:call-template name="convert2twip">
|
||||
<xsl:with-param name="value" select="@text:offset"/>
|
||||
</xsl:call-template>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
<xsl:attribute name="w:restart">continuous</xsl:attribute>
|
||||
</xsl:element>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
<xsl:template match="style:style" mode="section">
|
||||
<xsl:param name="master-page"/>
|
||||
<xsl:variable name="page-width">
|
||||
<xsl:call-template name="convert2twip">
|
||||
<xsl:with-param name="value" select="$master-page/style:page-layout-properties/@fo:page-width"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="margin-left">
|
||||
<xsl:call-template name="convert2twip">
|
||||
<xsl:with-param name="value" select="$master-page/style:page-layout-properties/@fo:margin-left"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="margin-right">
|
||||
<xsl:call-template name="convert2twip">
|
||||
<xsl:with-param name="value" select="$master-page/style:page-layout-properties/@fo:margin-right"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="valid-width">
|
||||
<xsl:value-of select="$page-width - $margin-left - $margin-right"/>
|
||||
</xsl:variable>
|
||||
<w:type w:val="continuous"/>
|
||||
<xsl:apply-templates select="style:section-properties/style:columns">
|
||||
<xsl:with-param name="page-width" select="$valid-width"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:template>
|
||||
<xsl:template match="style:columns">
|
||||
<xsl:param name="page-width"/>
|
||||
<w:cols w:num="{@fo:column-count}">
|
||||
<xsl:if test="@fo:column-gap">
|
||||
<xsl:attribute name="w:space">
|
||||
<xsl:call-template name="convert2twip">
|
||||
<xsl:with-param name="value" select="@fo:column-gap"/>
|
||||
</xsl:call-template>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
<xsl:if test="style:column-sep">
|
||||
<xsl:attribute name="w:sep">on</xsl:attribute>
|
||||
</xsl:if>
|
||||
<xsl:choose>
|
||||
<xsl:when test="not(style:column)">
|
||||
<xsl:attribute name="w:equalWidth">on</xsl:attribute>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:attribute name="w:equalWidth">off</xsl:attribute>
|
||||
<xsl:variable name="column-relative-width">
|
||||
<xsl:call-template name="get-sum-column-width">
|
||||
<xsl:with-param name="current-column" select="style:column[1]"/>
|
||||
<xsl:with-param name="current-width" select="'0'"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:for-each select="style:column">
|
||||
<xsl:element name="w:col">
|
||||
<xsl:attribute name="w:w">
|
||||
<xsl:value-of select="floor(substring-before(@style:rel-width,'*') * $page-width div $column-relative-width)"/>
|
||||
</xsl:attribute>
|
||||
<xsl:if test="@fo:margin-right">
|
||||
<xsl:variable name="margin-right">
|
||||
<xsl:call-template name="convert2twip">
|
||||
<xsl:with-param name="value" select="@fo:margin-right"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:choose>
|
||||
<xsl:when test="following-sibling::style:column">
|
||||
<xsl:variable name="margin-left">
|
||||
<xsl:call-template name="convert2twip">
|
||||
<xsl:with-param name="value" select="@fo:margin-left"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:attribute name="w:space">
|
||||
<xsl:value-of select="$margin-right + $margin-left"/>
|
||||
</xsl:attribute>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:attribute name="w:space">
|
||||
<xsl:value-of select="$margin-right"/>
|
||||
</xsl:attribute>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:if>
|
||||
</xsl:element>
|
||||
</xsl:for-each>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</w:cols>
|
||||
</xsl:template>
|
||||
<xsl:template name="get-sum-column-width">
|
||||
<xsl:param name="current-column"/>
|
||||
<xsl:param name="current-width"/>
|
||||
<xsl:variable name="new-width" select="$current-width + substring-before($current-column/@style:rel-width,'*')"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$current-column/following-sibling::style:column">
|
||||
<xsl:call-template name="get-sum-column-width">
|
||||
<xsl:with-param name="current-column" select="$current-column/following-sibling::style:column[1]"/>
|
||||
<xsl:with-param name="current-width" select="$new-width"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="$new-width"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>
|
||||
@@ -0,0 +1,849 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
* This file is part of the LibreOffice project.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* This file incorporates work covered by the following license notice:
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed
|
||||
* with this work for additional information regarding copyright
|
||||
* ownership. The ASF licenses this file to you under the Apache
|
||||
* License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
||||
-->
|
||||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml" xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:aml="http://schemas.microsoft.com/aml/2001/core" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" exclude-result-prefixes="office table style text draw svg dc config xlink meta oooc dom ooo chart math dr3d form script ooow draw">
|
||||
<xsl:include href="../../common/math.xsl"/>
|
||||
<xsl:template name="test-arc">
|
||||
<xsl:call-template name="svg-arc2vml-arc">
|
||||
<!-- M 125,75 a100,50 0 ?,? 100,50 -->
|
||||
<xsl:with-param name="x0" select="125"/>
|
||||
<xsl:with-param name="y0" select="75"/>
|
||||
<xsl:with-param name="rx" select="100"/>
|
||||
<xsl:with-param name="ry" select="50"/>
|
||||
<xsl:with-param name="x-axis-rotation" select="0"/>
|
||||
<xsl:with-param name="large-arc-flag" select="0"/>
|
||||
<xsl:with-param name="sweep-flag" select="0"/>
|
||||
<xsl:with-param name="x" select="225"/>
|
||||
<xsl:with-param name="y" select="125"/>
|
||||
</xsl:call-template>
|
||||
</xsl:template>
|
||||
<xsl:template name="test">
|
||||
<xsl:call-template name="svgpath2vmlpath">
|
||||
<xsl:with-param name="svg-path" select="'M 36.0 162.0 C 38.0 168.0 39.0-172.0 40.0 176.0 S 42.0 184.0 144.0 188.0'"/>
|
||||
</xsl:call-template>
|
||||
</xsl:template>
|
||||
<xsl:template name="svgpath2vmlpath">
|
||||
<xsl:param name="svg-path"/>
|
||||
<xsl:param name="vml-path" select="''"/>
|
||||
<xsl:param name="position" select="1"/>
|
||||
<xsl:param name="last-command" select="'M'"/>
|
||||
<xsl:param name="current-x" select="'0'"/>
|
||||
<xsl:param name="current-y" select="'0'"/>
|
||||
<xsl:variable name="command-and-newpos">
|
||||
<xsl:call-template name="get-path-command">
|
||||
<xsl:with-param name="svg-path" select="$svg-path"/>
|
||||
<xsl:with-param name="position" select="$position"/>
|
||||
<xsl:with-param name="last-command" select="$last-command"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="command" select="substring-before($command-and-newpos , ':')"/>
|
||||
<xsl:variable name="newpos" select="substring-after($command-and-newpos , ':')"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$command = 'M' ">
|
||||
<!-- absolute moveto -->
|
||||
<xsl:variable name="new-vml-path" select="concat($vml-path ,' m ' ) "/>
|
||||
<xsl:variable name="num-and-pos">
|
||||
<xsl:call-template name="get-number-after">
|
||||
<xsl:with-param name="svg-path" select="$svg-path"/>
|
||||
<xsl:with-param name="position" select="$newpos"/>
|
||||
<xsl:with-param name="count" select="2"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:call-template name="svgpath2vmlpath">
|
||||
<xsl:with-param name="svg-path" select="$svg-path"/>
|
||||
<xsl:with-param name="vml-path" select=" concat($new-vml-path , substring-before( $num-and-pos , ':') , ' ') "/>
|
||||
<xsl:with-param name="position" select=" substring-after( $num-and-pos , ':') "/>
|
||||
<xsl:with-param name="last-command" select="'L'"/>
|
||||
<xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':') , ' ') "/>
|
||||
<xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':') , ' ') "/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="$command = 'm' ">
|
||||
<!-- relative moveto -->
|
||||
<xsl:variable name="new-vml-path" select="concat($vml-path ,' t ' ) "/>
|
||||
<xsl:variable name="num-and-pos">
|
||||
<xsl:call-template name="get-number-after">
|
||||
<xsl:with-param name="svg-path" select="$svg-path"/>
|
||||
<xsl:with-param name="position" select="$newpos"/>
|
||||
<xsl:with-param name="count" select="2"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:call-template name="svgpath2vmlpath">
|
||||
<xsl:with-param name="svg-path" select="$svg-path"/>
|
||||
<xsl:with-param name="vml-path" select=" concat($new-vml-path , substring-before( $num-and-pos , ':') , ' ') "/>
|
||||
<xsl:with-param name="position" select=" substring-after( $num-and-pos , ':') "/>
|
||||
<xsl:with-param name="last-command" select="'l'"/>
|
||||
<xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':') , ' ') + $current-x"/>
|
||||
<xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':') , ' ') + $current-y "/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="$command = 'L' ">
|
||||
<!-- absolute lineto -->
|
||||
<xsl:variable name="new-vml-path" select="concat($vml-path ,' l ' ) "/>
|
||||
<xsl:variable name="num-and-pos">
|
||||
<xsl:call-template name="get-number-after">
|
||||
<xsl:with-param name="svg-path" select="$svg-path"/>
|
||||
<xsl:with-param name="position" select="$newpos"/>
|
||||
<xsl:with-param name="count" select="2"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:call-template name="svgpath2vmlpath">
|
||||
<xsl:with-param name="svg-path" select="$svg-path"/>
|
||||
<xsl:with-param name="vml-path" select=" concat($new-vml-path , substring-before( $num-and-pos , ':') , ' ') "/>
|
||||
<xsl:with-param name="position" select=" substring-after( $num-and-pos , ':') "/>
|
||||
<xsl:with-param name="last-command" select="$command"/>
|
||||
<xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':') , ' ') "/>
|
||||
<xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':') , ' ') "/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="$command = 'l' ">
|
||||
<!-- relative lineto -->
|
||||
<xsl:variable name="new-vml-path" select="concat($vml-path ,' r ' ) "/>
|
||||
<xsl:variable name="num-and-pos">
|
||||
<xsl:call-template name="get-number-after">
|
||||
<xsl:with-param name="svg-path" select="$svg-path"/>
|
||||
<xsl:with-param name="position" select="$newpos"/>
|
||||
<xsl:with-param name="count" select="2"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:call-template name="svgpath2vmlpath">
|
||||
<xsl:with-param name="svg-path" select="$svg-path"/>
|
||||
<xsl:with-param name="vml-path" select=" concat($new-vml-path , substring-before( $num-and-pos , ':') , ' ') "/>
|
||||
<xsl:with-param name="position" select=" substring-after( $num-and-pos , ':') "/>
|
||||
<xsl:with-param name="last-command" select="$command"/>
|
||||
<xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':') , ' ') + $current-x "/>
|
||||
<xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':') , ' ') + $current-y "/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="$command = 'H' ">
|
||||
<!-- absolute horizontal lineto -->
|
||||
<xsl:variable name="new-vml-path" select="concat($vml-path ,' l ' ) "/>
|
||||
<xsl:variable name="num-and-pos">
|
||||
<xsl:call-template name="get-number-after">
|
||||
<xsl:with-param name="svg-path" select="$svg-path"/>
|
||||
<xsl:with-param name="position" select="$newpos"/>
|
||||
<xsl:with-param name="count" select="1"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:call-template name="svgpath2vmlpath">
|
||||
<xsl:with-param name="svg-path" select="$svg-path"/>
|
||||
<xsl:with-param name="vml-path" select=" concat($new-vml-path , substring-before( $num-and-pos , ':') , ' ' , $current-y , ' ') "/>
|
||||
<xsl:with-param name="position" select=" substring-after( $num-and-pos , ':') "/>
|
||||
<xsl:with-param name="last-command" select="$command"/>
|
||||
<xsl:with-param name="current-x" select=" substring-before( $num-and-pos , ':') "/>
|
||||
<xsl:with-param name="current-y" select=" $current-y"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="$command = 'h' ">
|
||||
<!-- relative horizontal lineto -->
|
||||
<xsl:variable name="new-vml-path" select="concat($vml-path ,' l ' ) "/>
|
||||
<xsl:variable name="num-and-pos">
|
||||
<xsl:call-template name="get-number-after">
|
||||
<xsl:with-param name="svg-path" select="$svg-path"/>
|
||||
<xsl:with-param name="position" select="$newpos"/>
|
||||
<xsl:with-param name="count" select="1"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:call-template name="svgpath2vmlpath">
|
||||
<xsl:with-param name="svg-path" select="$svg-path"/>
|
||||
<xsl:with-param name="vml-path" select=" concat($new-vml-path , substring-before( $num-and-pos , ':') + $current-x , ' ' , $current-y , ' ') "/>
|
||||
<xsl:with-param name="position" select=" substring-after( $num-and-pos , ':') "/>
|
||||
<xsl:with-param name="last-command" select="$command"/>
|
||||
<xsl:with-param name="current-x" select=" substring-before( $num-and-pos , ':') + $current-x"/>
|
||||
<xsl:with-param name="current-y" select=" $current-y"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="$command = 'V' ">
|
||||
<!-- absolute vertical lineto -->
|
||||
<xsl:variable name="new-vml-path" select="concat($vml-path ,' l ' ) "/>
|
||||
<xsl:variable name="num-and-pos">
|
||||
<xsl:call-template name="get-number-after">
|
||||
<xsl:with-param name="svg-path" select="$svg-path"/>
|
||||
<xsl:with-param name="position" select="$newpos"/>
|
||||
<xsl:with-param name="count" select="1"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:call-template name="svgpath2vmlpath">
|
||||
<xsl:with-param name="svg-path" select="$svg-path"/>
|
||||
<xsl:with-param name="vml-path" select=" concat($new-vml-path , $current-x , ' ' , substring-before( $num-and-pos , ':') , ' ' ) "/>
|
||||
<xsl:with-param name="position" select=" substring-after( $num-and-pos , ':') "/>
|
||||
<xsl:with-param name="last-command" select="$command"/>
|
||||
<xsl:with-param name="current-x" select=" $current-x"/>
|
||||
<xsl:with-param name="current-y" select=" substring-before( $num-and-pos , ':') "/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="$command = 'v' ">
|
||||
<!-- relative horizontal lineto -->
|
||||
<xsl:variable name="new-vml-path" select="concat($vml-path ,' l ' ) "/>
|
||||
<xsl:variable name="num-and-pos">
|
||||
<xsl:call-template name="get-number-after">
|
||||
<xsl:with-param name="svg-path" select="$svg-path"/>
|
||||
<xsl:with-param name="position" select="$newpos"/>
|
||||
<xsl:with-param name="count" select="1"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:call-template name="svgpath2vmlpath">
|
||||
<xsl:with-param name="svg-path" select="$svg-path"/>
|
||||
<xsl:with-param name="vml-path" select=" concat($new-vml-path , $current-x , ' ' , substring-before( $num-and-pos , ':') + $current-y , ' ' ) "/>
|
||||
<xsl:with-param name="position" select=" substring-after( $num-and-pos , ':') "/>
|
||||
<xsl:with-param name="last-command" select="$command"/>
|
||||
<xsl:with-param name="current-x" select=" $current-x"/>
|
||||
<xsl:with-param name="current-y" select=" substring-before( $num-and-pos , ':') "/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="$command = 'C' ">
|
||||
<!-- absolute curveto -->
|
||||
<xsl:variable name="new-vml-path" select="concat($vml-path ,' c ' ) "/>
|
||||
<xsl:variable name="control-and-pos">
|
||||
<xsl:call-template name="get-number-after">
|
||||
<xsl:with-param name="svg-path" select="$svg-path"/>
|
||||
<xsl:with-param name="position" select="$newpos"/>
|
||||
<xsl:with-param name="count" select="4"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="num-and-pos">
|
||||
<xsl:call-template name="get-number-after">
|
||||
<xsl:with-param name="svg-path" select="$svg-path"/>
|
||||
<xsl:with-param name="position" select="substring-after( $control-and-pos , ':') "/>
|
||||
<xsl:with-param name="count" select="2"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:call-template name="svgpath2vmlpath">
|
||||
<xsl:with-param name="svg-path" select="$svg-path"/>
|
||||
<xsl:with-param name="vml-path" select=" concat($new-vml-path , substring-before( $control-and-pos , ':') , ' ' , substring-before( $num-and-pos , ':') , ' ') "/>
|
||||
<xsl:with-param name="position" select=" substring-after( $num-and-pos , ':') "/>
|
||||
<xsl:with-param name="last-command" select="$command"/>
|
||||
<xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':') , ' ') "/>
|
||||
<xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':') , ' ') "/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="$command = 'c' ">
|
||||
<!-- relative curveto -->
|
||||
<xsl:variable name="new-vml-path" select="concat($vml-path ,' v ' ) "/>
|
||||
<xsl:variable name="control-and-pos">
|
||||
<xsl:call-template name="get-number-after">
|
||||
<xsl:with-param name="svg-path" select="$svg-path"/>
|
||||
<xsl:with-param name="position" select="$newpos"/>
|
||||
<xsl:with-param name="count" select="4"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="num-and-pos">
|
||||
<xsl:call-template name="get-number-after">
|
||||
<xsl:with-param name="svg-path" select="$svg-path"/>
|
||||
<xsl:with-param name="position" select="substring-after( $control-and-pos , ':') "/>
|
||||
<xsl:with-param name="count" select="2"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:call-template name="svgpath2vmlpath">
|
||||
<xsl:with-param name="svg-path" select="$svg-path"/>
|
||||
<xsl:with-param name="vml-path" select=" concat($new-vml-path , substring-before( $control-and-pos , ':') , ' ' , substring-before( $num-and-pos , ':') , ' ') "/>
|
||||
<xsl:with-param name="position" select=" substring-after( $num-and-pos , ':') "/>
|
||||
<xsl:with-param name="last-command" select="$command"/>
|
||||
<xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':') , ' ') + $current-x "/>
|
||||
<xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':') , ' ') + $current-y "/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="$command = 'S' ">
|
||||
<!-- absolute shorthand/smooth curveto -->
|
||||
<xsl:variable name="new-vml-path" select="concat($vml-path ,' c ' ) "/>
|
||||
<xsl:variable name="control-and-pos">
|
||||
<xsl:call-template name="get-number-after">
|
||||
<xsl:with-param name="svg-path" select="$svg-path"/>
|
||||
<xsl:with-param name="position" select="$newpos"/>
|
||||
<xsl:with-param name="count" select="2"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="num-and-pos">
|
||||
<xsl:call-template name="get-number-after">
|
||||
<xsl:with-param name="svg-path" select="$svg-path"/>
|
||||
<xsl:with-param name="position" select="substring-after( $control-and-pos , ':') "/>
|
||||
<xsl:with-param name="count" select="2"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="control-1">
|
||||
<xsl:choose>
|
||||
<xsl:when test="string-length(translate($last-command, 'CcSs','') )= 0 ">
|
||||
<xsl:variable name="previous-control-2">
|
||||
<xsl:call-template name="get-number-before">
|
||||
<xsl:with-param name="svg-path" select="$svg-path"/>
|
||||
<xsl:with-param name="position" select="$position"/>
|
||||
<xsl:with-param name="count" select="2"/>
|
||||
<xsl:with-param name="skipcount" select="2"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:value-of select="substring-before($previous-control-2 , ':') "/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="substring-before($control-and-pos, ':') "/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<xsl:call-template name="svgpath2vmlpath">
|
||||
<xsl:with-param name="svg-path" select="$svg-path"/>
|
||||
<xsl:with-param name="vml-path" select=" concat($new-vml-path , $control-1 , ' ' , substring-before( $control-and-pos , ':') , ' ' , substring-before( $num-and-pos , ':') , ' ') "/>
|
||||
<xsl:with-param name="position" select=" substring-after( $num-and-pos , ':') "/>
|
||||
<xsl:with-param name="last-command" select="$command"/>
|
||||
<xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':') , ' ') "/>
|
||||
<xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':') , ' ') "/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="$command = 's' ">
|
||||
<!-- absolute shorthand/smooth curveto -->
|
||||
<xsl:variable name="new-vml-path" select="concat($vml-path ,' v ' ) "/>
|
||||
<xsl:variable name="control-and-pos">
|
||||
<xsl:call-template name="get-number-after">
|
||||
<xsl:with-param name="svg-path" select="$svg-path"/>
|
||||
<xsl:with-param name="position" select="$newpos"/>
|
||||
<xsl:with-param name="count" select="2"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="num-and-pos">
|
||||
<xsl:call-template name="get-number-after">
|
||||
<xsl:with-param name="svg-path" select="$svg-path"/>
|
||||
<xsl:with-param name="position" select="substring-after( $control-and-pos , ':') "/>
|
||||
<xsl:with-param name="count" select="2"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="control-1">
|
||||
<xsl:choose>
|
||||
<xsl:when test="string-length(translate($last-command, 'CcSs' , '')) = 0 ">
|
||||
<xsl:variable name="previous-control-2">
|
||||
<xsl:call-template name="get-number-before">
|
||||
<xsl:with-param name="svg-path" select="$svg-path"/>
|
||||
<xsl:with-param name="position" select="$position"/>
|
||||
<xsl:with-param name="count" select="2"/>
|
||||
<xsl:with-param name="skipcount" select="2"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:value-of select="substring-before($previous-control-2 , ':') "/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="substring-before($control-and-pos, ':') "/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<xsl:call-template name="svgpath2vmlpath">
|
||||
<xsl:with-param name="svg-path" select="$svg-path"/>
|
||||
<xsl:with-param name="vml-path" select=" concat($new-vml-path , $control-1 , ' ' , substring-before( $control-and-pos , ':') , ' ' , substring-before( $num-and-pos , ':') , ' ') "/>
|
||||
<xsl:with-param name="position" select=" substring-after( $num-and-pos , ':') "/>
|
||||
<xsl:with-param name="last-command" select="$command"/>
|
||||
<xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':') , ' ') + $current-x "/>
|
||||
<xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':') , ' ') + $current-y "/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="$command = 'Q' ">
|
||||
<!-- absolute quadratic bézier curves -->
|
||||
<xsl:variable name="new-vml-path" select="concat($vml-path ,' qb ' ) "/>
|
||||
<xsl:variable name="control-and-pos">
|
||||
<xsl:call-template name="get-number-after">
|
||||
<xsl:with-param name="svg-path" select="$svg-path"/>
|
||||
<xsl:with-param name="position" select="$newpos"/>
|
||||
<xsl:with-param name="count" select="2"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="num-and-pos">
|
||||
<xsl:call-template name="get-number-after">
|
||||
<xsl:with-param name="svg-path" select="$svg-path"/>
|
||||
<xsl:with-param name="position" select="substring-after( $control-and-pos , ':') "/>
|
||||
<xsl:with-param name="count" select="2"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:call-template name="svgpath2vmlpath">
|
||||
<xsl:with-param name="svg-path" select="$svg-path"/>
|
||||
<xsl:with-param name="vml-path" select=" concat($new-vml-path , substring-before( $control-and-pos , ':') , ' ' , substring-before( $num-and-pos , ':') , ' ') "/>
|
||||
<xsl:with-param name="position" select=" substring-after( $num-and-pos , ':') "/>
|
||||
<xsl:with-param name="last-command" select="$command"/>
|
||||
<xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':') , ' ') "/>
|
||||
<xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':') , ' ') "/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="$command = 'q' ">
|
||||
<!-- relative quadratic bézier curves -->
|
||||
<xsl:variable name="control-and-pos">
|
||||
<xsl:call-template name="get-number-after">
|
||||
<xsl:with-param name="svg-path" select="$svg-path"/>
|
||||
<xsl:with-param name="position" select="$newpos"/>
|
||||
<xsl:with-param name="count" select="2"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="control" select="substring-before( $control-and-pos , ':') "/>
|
||||
<xsl:variable name="new-vml-path" select="concat($vml-path ,' qb ' , substring-before($control,' ') + $current-x , ' ' , substring-after($control , ' ') + $current-y ) "/>
|
||||
<xsl:variable name="num-and-pos">
|
||||
<xsl:call-template name="get-number-after">
|
||||
<xsl:with-param name="svg-path" select="$svg-path"/>
|
||||
<xsl:with-param name="position" select="substring-after( $control-and-pos , ':') "/>
|
||||
<xsl:with-param name="count" select="2"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="number" select="substring-before($num-and-pos, ':')"/>
|
||||
<xsl:variable name="absolute-number" select="concat(substring-before($number, ' ') + $current-x , ' ' , substring-after($number, ' ') + $current-y)"/>
|
||||
<xsl:call-template name="svgpath2vmlpath">
|
||||
<xsl:with-param name="svg-path" select="$svg-path"/>
|
||||
<xsl:with-param name="vml-path" select=" concat($new-vml-path , ' ' , $absolute-number , ' ') "/>
|
||||
<xsl:with-param name="position" select=" substring-after( $num-and-pos , ':') "/>
|
||||
<xsl:with-param name="last-command" select="$command"/>
|
||||
<xsl:with-param name="current-x" select=" substring-before( $absolute-number , ' ') "/>
|
||||
<xsl:with-param name="current-y" select=" substring-after( $absolute-number , ' ') "/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="$command = 'Z' or $command = 'z' ">
|
||||
<!-- closepath -->
|
||||
<xsl:variable name="new-vml-path" select="concat($vml-path ,' x ' ) "/>
|
||||
<xsl:call-template name="svgpath2vmlpath">
|
||||
<xsl:with-param name="svg-path" select="$svg-path"/>
|
||||
<xsl:with-param name="vml-path" select=" concat($new-vml-path , ' ') "/>
|
||||
<xsl:with-param name="position" select=" $newpos "/>
|
||||
<xsl:with-param name="last-command" select="$command"/>
|
||||
<xsl:with-param name="current-x" select=" $current-x "/>
|
||||
<xsl:with-param name="current-y" select=" $current-y"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="$vml-path"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
<xsl:template name="get-number-before">
|
||||
<!-- get $count number of number before current position , output format:number1 number2 ... numberN:newposition
|
||||
skip $skipcount of numbers
|
||||
-->
|
||||
<xsl:param name="svg-path"/>
|
||||
<xsl:param name="position" select="1"/>
|
||||
<xsl:param name="count" select="1"/>
|
||||
<xsl:param name="skipcount" select="0"/>
|
||||
<xsl:param name="number" select="''"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$count = 0">
|
||||
<xsl:value-of select=" concat($number , ':' , $position) "/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:variable name="num-pos">
|
||||
<xsl:call-template name="get-number-position">
|
||||
<xsl:with-param name="svg-path" select="$svg-path"/>
|
||||
<xsl:with-param name="position" select="$position"/>
|
||||
<xsl:with-param name="direction" select="-1"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="previous-num-and-pos">
|
||||
<xsl:call-template name="get-previous-number">
|
||||
<xsl:with-param name="svg-path" select="$svg-path"/>
|
||||
<xsl:with-param name="position" select="$num-pos"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:if test="$skipcount > 0">
|
||||
<xsl:call-template name="get-number-before">
|
||||
<xsl:with-param name="svg-path" select="$svg-path"/>
|
||||
<xsl:with-param name="position" select="substring-after($previous-num-and-pos , ':')"/>
|
||||
<xsl:with-param name="count" select="$count"/>
|
||||
<xsl:with-param name="skipcount" select="$skipcount - 1"/>
|
||||
<xsl:with-param name="number" select="$number"/>
|
||||
</xsl:call-template>
|
||||
</xsl:if>
|
||||
<xsl:if test="$skipcount = 0">
|
||||
<xsl:variable name="new-number">
|
||||
<xsl:if test="not($count = 1)">
|
||||
<xsl:value-of select="' '"/>
|
||||
</xsl:if>
|
||||
<xsl:value-of select=" concat( substring-before($previous-num-and-pos , ':') , $number ) "/>
|
||||
</xsl:variable>
|
||||
<xsl:call-template name="get-number-before">
|
||||
<xsl:with-param name="svg-path" select="$svg-path"/>
|
||||
<xsl:with-param name="position" select="substring-after($previous-num-and-pos , ':')"/>
|
||||
<xsl:with-param name="count" select="$count - 1"/>
|
||||
<xsl:with-param name="skipcount" select="0"/>
|
||||
<xsl:with-param name="number" select="$new-number"/>
|
||||
</xsl:call-template>
|
||||
</xsl:if>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
<xsl:template name="get-number-after">
|
||||
<!-- get $count number of number after current position, output format:number1 number2 ... numberN:newposition
|
||||
skip $skipcount of numbers
|
||||
-->
|
||||
<xsl:param name="svg-path"/>
|
||||
<xsl:param name="position" select="1"/>
|
||||
<xsl:param name="count" select="1"/>
|
||||
<xsl:param name="skipcount" select="0"/>
|
||||
<xsl:param name="number" select="''"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$count = 0">
|
||||
<xsl:value-of select=" concat($number , ':' , $position) "/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:variable name="num-pos">
|
||||
<xsl:call-template name="get-number-position">
|
||||
<xsl:with-param name="svg-path" select="$svg-path"/>
|
||||
<xsl:with-param name="position" select="$position"/>
|
||||
<xsl:with-param name="direction" select="1"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="next-num-and-pos">
|
||||
<xsl:call-template name="get-next-number">
|
||||
<xsl:with-param name="svg-path" select="$svg-path"/>
|
||||
<xsl:with-param name="position" select="$num-pos"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:if test="$skipcount > 0">
|
||||
<xsl:call-template name="get-number-after">
|
||||
<xsl:with-param name="svg-path" select="$svg-path"/>
|
||||
<xsl:with-param name="position" select="substring-after($next-num-and-pos , ':')"/>
|
||||
<xsl:with-param name="count" select="$count"/>
|
||||
<xsl:with-param name="skipcount" select="$skipcount - 1"/>
|
||||
<xsl:with-param name="number" select="$number"/>
|
||||
</xsl:call-template>
|
||||
</xsl:if>
|
||||
<xsl:if test="$skipcount = 0">
|
||||
<xsl:variable name="new-number">
|
||||
<xsl:value-of select=" concat( $number , substring-before($next-num-and-pos , ':') ) "/>
|
||||
<xsl:if test="not($count = 1)">
|
||||
<xsl:value-of select="' '"/>
|
||||
</xsl:if>
|
||||
</xsl:variable>
|
||||
<xsl:call-template name="get-number-after">
|
||||
<xsl:with-param name="svg-path" select="$svg-path"/>
|
||||
<xsl:with-param name="position" select="substring-after($next-num-and-pos , ':')"/>
|
||||
<xsl:with-param name="count" select="$count - 1"/>
|
||||
<xsl:with-param name="skipcount" select="0"/>
|
||||
<xsl:with-param name="number" select="$new-number"/>
|
||||
</xsl:call-template>
|
||||
</xsl:if>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
<xsl:template name="get-number-position">
|
||||
<!-- get the next number start position, direction should be 1 or -1-->
|
||||
<xsl:param name="svg-path"/>
|
||||
<xsl:param name="position"/>
|
||||
<xsl:param name="direction" select="1"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$direction = 1 and $position > string-length($svg-path) ">0</xsl:when>
|
||||
<xsl:when test="$direction = -1 and not($position > 0)">0</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:variable name="curr-char">
|
||||
<xsl:if test="$direction = 1">
|
||||
<xsl:value-of select="substring($svg-path, $position , 1)"/>
|
||||
</xsl:if>
|
||||
<xsl:if test="$direction = -1">
|
||||
<xsl:value-of select="substring($svg-path, $position -1 , 1)"/>
|
||||
</xsl:if>
|
||||
</xsl:variable>
|
||||
<xsl:choose>
|
||||
<xsl:when test="string-length(translate($curr-char , '+-.0123456789' ,'')) = 0 ">
|
||||
<!-- number start-->
|
||||
<xsl:value-of select="$position"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:call-template name="get-number-position">
|
||||
<xsl:with-param name="svg-path" select="$svg-path"/>
|
||||
<xsl:with-param name="position" select="$position + $direction"/>
|
||||
<xsl:with-param name="direction" select="$direction"/>
|
||||
</xsl:call-template>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
<xsl:template name="get-next-number">
|
||||
<!-- get the next number from current position-->
|
||||
<xsl:param name="svg-path"/>
|
||||
<xsl:param name="position"/>
|
||||
<xsl:param name="number" select="''"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$position > string-length($svg-path) ">
|
||||
<xsl:value-of select=" concat(round($number) , ':' , $position) "/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:variable name="curr-char" select="substring($svg-path, $position , 1)"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="string-length(translate($curr-char , '.0123456789' ,'')) = 0 ">
|
||||
<!-- is number -->
|
||||
<xsl:call-template name="get-next-number">
|
||||
<xsl:with-param name="svg-path" select="$svg-path"/>
|
||||
<xsl:with-param name="position" select="$position +1"/>
|
||||
<xsl:with-param name="number" select="concat( $number, $curr-char) "/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="string-length(translate($curr-char , '+-' ,'') ) = 0 and string-length($number) = 0">
|
||||
<!-- is number -->
|
||||
<xsl:call-template name="get-next-number">
|
||||
<xsl:with-param name="svg-path" select="$svg-path"/>
|
||||
<xsl:with-param name="position" select="$position +1"/>
|
||||
<xsl:with-param name="number" select="concat( $number, $curr-char) "/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="concat( round($number) , ':' , $position)"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
<xsl:template name="get-previous-number">
|
||||
<!-- get the previous number from current position-->
|
||||
<xsl:param name="svg-path"/>
|
||||
<xsl:param name="position"/>
|
||||
<xsl:param name="number" select="''"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="not($position > 0)">
|
||||
<xsl:value-of select="concat( round($number ), ':0')"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:variable name="curr-char" select="substring($svg-path, $position -1 , 1)"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="string-length(translate($curr-char , '.0123456789' ,'')) = 0 ">
|
||||
<!-- is number -->
|
||||
<xsl:call-template name="get-previous-number">
|
||||
<xsl:with-param name="svg-path" select="$svg-path"/>
|
||||
<xsl:with-param name="position" select="$position -1"/>
|
||||
<xsl:with-param name="number" select="concat($curr-char , $number) "/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="string-length(translate($curr-char , '+-' ,'') ) = 0 and string-length($number) = 0">
|
||||
<!-- skip it -->
|
||||
<xsl:call-template name="get-previous-number">
|
||||
<xsl:with-param name="svg-path" select="$svg-path"/>
|
||||
<xsl:with-param name="position" select="$position -1"/>
|
||||
<xsl:with-param name="number" select="$number "/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="string-length(translate($curr-char , '+-' ,'') ) = 0 and string-length($number) > 0">
|
||||
<!-- finish it with +/- -->
|
||||
<xsl:value-of select="concat( round( concat( $curr-char, $number)) , ':' , $position)"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="concat( round($number) , ':' , $position)"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
<xsl:template name="get-path-command">
|
||||
<xsl:param name="svg-path"/>
|
||||
<xsl:param name="position" select="1"/>
|
||||
<xsl:param name="last-command"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$position > string-length($svg-path) "/>
|
||||
<xsl:otherwise>
|
||||
<xsl:variable name="curr-char" select="substring($svg-path, $position , 1)"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="string-length(translate($curr-char , 'MmZzLlHhVvCcSsQqTtAa' ,'')) = 0 ">
|
||||
<!-- "MmZzLlHhVvCcSsQqTtAa" are all possible command chars -->
|
||||
<xsl:value-of select="concat( $curr-char , ':' , $position +1)"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="string-length(translate($curr-char , '+-.0123456789' ,'')) = 0 ">
|
||||
<!-- number start, use last command -->
|
||||
<xsl:if test="string-length($last-command) = 0">
|
||||
<xsl:message>ooo2wordml_path.xsl: Find undefined command</xsl:message>
|
||||
</xsl:if>
|
||||
<xsl:value-of select="concat( $last-command , ':' , $position )"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="string-length(translate($curr-char , ',	  ' ,'')) = 0 ">
|
||||
<!-- space or ',' should be skip -->
|
||||
<xsl:call-template name="get-path-command">
|
||||
<xsl:with-param name="svg-path" select="$svg-path"/>
|
||||
<xsl:with-param name="position" select="$position +1"/>
|
||||
<xsl:with-param name="last-command" select="$last-command"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:message>ooo2wordml_path.xsl: Find undefined command:<xsl:value-of select="$curr-char"/>
|
||||
</xsl:message>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
<xsl:template name="svg-arc2vml-arc">
|
||||
<xsl:param name="x0"/>
|
||||
<xsl:param name="y0"/>
|
||||
<xsl:param name="rx"/>
|
||||
<xsl:param name="ry"/>
|
||||
<xsl:param name="x-axis-rotation" select="0"/>
|
||||
<xsl:param name="large-arc-flag" select="0"/>
|
||||
<xsl:param name="sweep-flag" select="0"/>
|
||||
<xsl:param name="x"/>
|
||||
<xsl:param name="y"/>
|
||||
<!-- Compute 1/2 distance between current and final point -->
|
||||
<xsl:variable name="dx2" select="($x0 - $x) div 2"/>
|
||||
<xsl:variable name="dy2" select="($y0 - $y) div 2"/>
|
||||
<!-- Convert from degrees to radians -->
|
||||
<xsl:variable name="rotation-radian" select="$x-axis-rotation * $pi div 180"/>
|
||||
<!-- Compute (x1, y1). What are x1,y1?-->
|
||||
<xsl:variable name="cos-rotation">
|
||||
<xsl:call-template name="cos">
|
||||
<xsl:with-param name="x" select="$rotation-radian"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="sin-rotation">
|
||||
<xsl:call-template name="sin">
|
||||
<xsl:with-param name="x" select="$rotation-radian"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="x1" select="$cos-rotation * $dx2 + $sin-rotation * $dy2"/>
|
||||
<xsl:variable name="y1" select="-1 * $sin-rotation * $dx2 + $cos-rotation * $dy2"/>
|
||||
<!-- Make sure radii are large enough -->
|
||||
<xsl:variable name="rx-abs">
|
||||
<xsl:call-template name="abs">
|
||||
<xsl:with-param name="x" select="$rx"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="ry-abs">
|
||||
<xsl:call-template name="abs">
|
||||
<xsl:with-param name="x" select="$ry"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="rx-sq" select="$rx-abs * $rx-abs"/>
|
||||
<xsl:variable name="ry-sq" select="$ry-abs * $ry-abs"/>
|
||||
<xsl:variable name="x1-sq" select="$x1 * $x1"/>
|
||||
<xsl:variable name="y1-sq" select="$y1 * $y1"/>
|
||||
<xsl:variable name="radius-check" select=" $x1-sq div $rx-sq + $y1-sq div $ry-sq "/>
|
||||
<xsl:variable name="radius-check-sqrt">
|
||||
<xsl:call-template name="sqrt">
|
||||
<xsl:with-param name="x" select="$radius-check"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="new-rx">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$radius-check > 1">
|
||||
<xsl:value-of select="$rx-abs * $radius-check-sqrt"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="$rx-abs"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="new-ry">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$radius-check > 1">
|
||||
<xsl:value-of select="$ry-abs * $radius-check-sqrt"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="$ry-abs"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="new-ry-sq">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$radius-check > 1">
|
||||
<xsl:value-of select="$new-ry * $new-ry"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="$ry-sq"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="new-rx-sq">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$radius-check > 1">
|
||||
<xsl:value-of select="$new-rx * $new-rx"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="$rx-sq"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<!-- Step 2: Compute (cx1, cy1) -->
|
||||
<xsl:variable name="sign">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$large-arc-flag = $sweep-flag">-1</xsl:when>
|
||||
<xsl:otherwise>1</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="unchecked-sq" select=" (($new-rx-sq * $new-ry-sq) - ($new-rx-sq * $y1-sq) - ($new-ry-sq * $x1-sq)) div (($new-rx-sq * $y1-sq) + ($new-ry-sq * $x1-sq)) "/>
|
||||
<xsl:variable name="sq">
|
||||
<xsl:choose>
|
||||
<xsl:when test=" $unchecked-sq < 0">0</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="$unchecked-sq"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="sq-sqrt">
|
||||
<xsl:call-template name="sqrt">
|
||||
<xsl:with-param name="x" select="$sq"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="coef" select="$sign * $sq-sqrt "/>
|
||||
<xsl:variable name="cx1" select="$coef * $new-rx * $y1 div $new-ry"/>
|
||||
<xsl:variable name="cy1" select=" -1 * $coef * $new-ry * $x1 div $new-rx"/>
|
||||
<!-- Step 3: Compute (cx, cy) from (cx1, cy1) -->
|
||||
<xsl:variable name="sx2" select="($x0 +$x) div 2 "/>
|
||||
<xsl:variable name="sy2" select="($y0 +$y) div 2 "/>
|
||||
<xsl:variable name="tmp1" select="$cos-rotation * $cx1 "/>
|
||||
<xsl:variable name="tmp2" select="$cos-rotation * $cx1 "/>
|
||||
<xsl:variable name="cx" select=" $sx2 + ( $cos-rotation * $cx1 - $sin-rotation * $cy1 ) "/>
|
||||
<xsl:variable name="cy" select=" $sy2 + ( $sin-rotation * $cx1 + $cos-rotation * $cy1 ) "/>
|
||||
<!-- Step 4: Compute angle start and angle extent -->
|
||||
<xsl:variable name="ux" select="( $x1 - $cx1) div $new-rx"/>
|
||||
<xsl:variable name="uy" select="( $y1 - $cy1) div $new-ry"/>
|
||||
<xsl:variable name="vx" select="( - 1 * $x1 - $cx1) div $new-rx"/>
|
||||
<xsl:variable name="vy" select="(- 1 * $y1 - $cy1) div $new-ry"/>
|
||||
<xsl:variable name="n">
|
||||
<xsl:call-template name="sqrt">
|
||||
<xsl:with-param name="x" select=" ($ux * $ux) + ($uy * $uy) "/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<!-- 1 * ux + 0 * uy -->
|
||||
<xsl:variable name="p" select="$ux"/>
|
||||
<xsl:variable name="uy-sign">
|
||||
<xsl:choose>
|
||||
<xsl:when test=" $uy < 0 ">-1</xsl:when>
|
||||
<xsl:otherwise>1</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="acos-pn">
|
||||
<xsl:call-template name="acos">
|
||||
<xsl:with-param name="x" select="$p div $n"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="theta" select="( $uy-sign * $acos-pn * 180 div $pi ) mod 360 "/>
|
||||
<xsl:variable name="n-delta">
|
||||
<xsl:call-template name="sqrt">
|
||||
<xsl:with-param name="x" select="($ux * $ux + $uy * $uy) * ($vx * $vx + $vy * $vy)"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="p-delta" select="$ux * $vx + $uy * $vy"/>
|
||||
<xsl:variable name="vy-sign">
|
||||
<xsl:choose>
|
||||
<xsl:when test="($ux * $vy - $uy * $vx) < 0 ">-1</xsl:when>
|
||||
<xsl:otherwise>1</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="acos-pn-delta">
|
||||
<xsl:call-template name="acos">
|
||||
<xsl:with-param name="x" select="$p-delta div $n-delta"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="unchecked-delta" select="$vy-sign * $acos-pn-delta * 180 div $pi "/>
|
||||
<xsl:variable name="delta">
|
||||
<xsl:choose>
|
||||
<xsl:when test=" $sweep-flag = 0 and $unchecked-delta > 0 ">
|
||||
<xsl:value-of select=" ($unchecked-delta - 360) mod 360 "/>
|
||||
</xsl:when>
|
||||
<xsl:when test=" $sweep-flag = 1 and $unchecked-delta < 0 ">
|
||||
<xsl:value-of select=" ($unchecked-delta + 360) mod 360 "/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select=" $unchecked-delta mod 360 "/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<xsl:value-of select="concat ($cx, ' ' , $cy, ' ' , $rx, ' ' , $ry, ' ' , $theta, ' ' , $delta, ' ' , $x-axis-rotation) "/>
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>
|
||||
@@ -0,0 +1,308 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
* This file is part of the LibreOffice project.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* This file incorporates work covered by the following license notice:
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed
|
||||
* with this work for additional information regarding copyright
|
||||
* ownership. The ASF licenses this file to you under the Apache
|
||||
* License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
||||
-->
|
||||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml" xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:aml="http://schemas.microsoft.com/aml/2001/core" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" exclude-result-prefixes="office table style text draw svg dc config xlink meta oooc dom ooo chart math dr3d form script ooow draw">
|
||||
<xsl:template match="office:settings">
|
||||
<w:docPr>
|
||||
<w:displayBackgroundShape/>
|
||||
<xsl:variable name="view-settings" select="config:config-item-set[@config:name = 'view-settings']"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$view-settings/config:config-item[@config:name = 'InBrowseMode'] = 'true'">
|
||||
<w:view w:val="outline"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<w:view w:val="print"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:variable name="views" select="$view-settings/config:config-item-map-indexed[@config:name = 'Views']"/>
|
||||
<w:zoom w:percent="{$views/config:config-item-map-entry/config:config-item[@config:name = 'ZoomFactor']}">
|
||||
<xsl:variable name="zoom-type" select="$views/config:config-item-map-entry/config:config-item[@config:name = 'ZoomType']"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$zoom-type = '3'">
|
||||
<xsl:attribute name="w:val">best-fit</xsl:attribute>
|
||||
</xsl:when>
|
||||
<xsl:when test="$zoom-type = '2'">
|
||||
<xsl:attribute name="w:val">full-page</xsl:attribute>
|
||||
</xsl:when>
|
||||
<xsl:when test="$zoom-type = '1'">
|
||||
<xsl:attribute name="w:val">text-fit</xsl:attribute>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
</w:zoom>
|
||||
<w:defaultTabStop>
|
||||
<xsl:attribute name="w:val"><xsl:call-template name="convert2twip"><xsl:with-param name="value" select="/office:document/office:styles/style:default-style[@style:family='paragraph']/style:paragraph-properties/@style:tab-stop-distance"/></xsl:call-template></xsl:attribute>
|
||||
</w:defaultTabStop>
|
||||
<xsl:if test="../office:master-styles/style:master-page/style:header-left">
|
||||
<w:evenAndOddHeaders/>
|
||||
</xsl:if>
|
||||
<xsl:apply-templates select="/office:document/office:styles/text:footnotes-configuration"/>
|
||||
<xsl:apply-templates select="/office:document/office:styles/text:endnotes-configuration"/>
|
||||
<!-- add the variables declaration in w:docpr G.Y. Begin-->
|
||||
<xsl:if test="/office:document/office:body/office:text/text:variable-decls | /office:document/office:body/office:text/text:user-field-decls |/office:document/office:body/office:text/text:sequence-decls ">
|
||||
<xsl:call-template name="field_declare">
|
||||
<xsl:with-param name="simple_field_variable_declares" select="/office:document/office:body/office:text/text:variable-decls"/>
|
||||
<xsl:with-param name="user_field_variable_declares" select=" /office:document/office:body/office:text/text:user-field-decls"/>
|
||||
<xsl:with-param name="field_sequence_declares" select="/office:document/office:body/office:text/text:sequence-decls"/>
|
||||
</xsl:call-template>
|
||||
</xsl:if>
|
||||
<!--add the variables declaration in w:docpr G.Y. End-->
|
||||
</w:docPr>
|
||||
</xsl:template>
|
||||
<xsl:template match="text:footnotes-configuration">
|
||||
<xsl:param name="within-section"/>
|
||||
<w:footnotePr>
|
||||
<xsl:choose>
|
||||
<xsl:when test="@text:footnotes-position = 'document'">
|
||||
<w:pos w:val="beneath-text"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<w:pos w:val="page-bottom"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:if test="@text:start-value">
|
||||
<w:numStart w:val="{@text:start-value + 1}"/>
|
||||
</xsl:if>
|
||||
<xsl:if test="@style:num-format">
|
||||
<xsl:call-template name="convert-number-format">
|
||||
<xsl:with-param name="number-format" select="@style:num-format"/>
|
||||
<xsl:with-param name="number-prefix" select="@style:num-prefix"/>
|
||||
<xsl:with-param name="number-suffix" select="@style:num-suffix"/>
|
||||
</xsl:call-template>
|
||||
</xsl:if>
|
||||
<xsl:if test="@text:start-numbering-at">
|
||||
<xsl:choose>
|
||||
<xsl:when test="@text:start-numbering-at = 'document'">
|
||||
<w:numRestart w:val="continuous"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="@text:start-numbering-at = 'page'">
|
||||
<w:numRestart w:val="each-page"/>
|
||||
</xsl:when>
|
||||
<!-- convert "chapter" to "section" -->
|
||||
<xsl:otherwise>
|
||||
<w:numRestart w:val="each-sect"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:if>
|
||||
<xsl:if test="$within-section != 'yes'">
|
||||
<!-- because in SO/OOo footnote-sep is defined within every page-layout, but in Word XML footnote separator
|
||||
is defined solely in docPr, so not trouble to find the proper footnote-sep definition. -->
|
||||
<w:footnote w:type="separator">
|
||||
<w:p>
|
||||
<w:r>
|
||||
<w:separator/>
|
||||
</w:r>
|
||||
</w:p>
|
||||
</w:footnote>
|
||||
<w:footnote w:type="continuation-separator">
|
||||
<w:p>
|
||||
<w:r>
|
||||
<w:continuationSeparator/>
|
||||
<xsl:if test="text:footnote-continuation-notice-backward">
|
||||
<w:t>
|
||||
<xsl:value-of select="text:footnote-continuation-notice-backward"/>
|
||||
</w:t>
|
||||
</xsl:if>
|
||||
</w:r>
|
||||
</w:p>
|
||||
</w:footnote>
|
||||
<xsl:if test="text:footnote-continuation-notice-forward">
|
||||
<w:footnote w:type="continuation-notice">
|
||||
<w:p>
|
||||
<w:r>
|
||||
<w:t>
|
||||
<xsl:value-of select="text:footnote-continuation-notice-forward"/>
|
||||
</w:t>
|
||||
</w:r>
|
||||
</w:p>
|
||||
</w:footnote>
|
||||
</xsl:if>
|
||||
</xsl:if>
|
||||
</w:footnotePr>
|
||||
</xsl:template>
|
||||
<xsl:template match="text:endnotes-configuration">
|
||||
<xsl:param name="within-section"/>
|
||||
<w:endnotePr>
|
||||
<w:pos w:val="sect-end"/>
|
||||
<xsl:if test="@text:start-value">
|
||||
<w:numStart w:val="{@text:start-value + 1}"/>
|
||||
</xsl:if>
|
||||
<xsl:if test="@style:num-format">
|
||||
<xsl:call-template name="convert-number-format">
|
||||
<xsl:with-param name="number-format" select="@style:num-format"/>
|
||||
<xsl:with-param name="number-prefix" select="@style:num-prefix"/>
|
||||
<xsl:with-param name="number-suffix" select="@style:num-suffix"/>
|
||||
</xsl:call-template>
|
||||
</xsl:if>
|
||||
<w:numRestart w:val="each-sect"/>
|
||||
<xsl:if test="$within-section != 'yes'">
|
||||
<w:endnote w:type="separator">
|
||||
<w:p>
|
||||
<w:r>
|
||||
<w:separator/>
|
||||
</w:r>
|
||||
</w:p>
|
||||
</w:endnote>
|
||||
<w:endnote w:type="continuation-separator">
|
||||
<w:p>
|
||||
<w:r>
|
||||
<w:continuationSeparator/>
|
||||
</w:r>
|
||||
</w:p>
|
||||
</w:endnote>
|
||||
</xsl:if>
|
||||
</w:endnotePr>
|
||||
</xsl:template>
|
||||
<xsl:template name="convert-number-format">
|
||||
<xsl:param name="number-format"/>
|
||||
<xsl:param name="number-prefix"/>
|
||||
<xsl:param name="number-suffix"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$number-format = '1' and normalize-space($number-prefix) = '0'">
|
||||
<w:numFmt w:val="decimal-zero"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$number-format = '1' and normalize-space($number-suffix) = '.'">
|
||||
<w:numFmt w:val="decimal-enclosed-fullstop"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$number-format = '1' and normalize-space($number-prefix) = '(' and normalize-space($number-prefix) = ')'">
|
||||
<w:numFmt w:val="decimal-enclosed-paren"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$number-format = '1' and normalize-space($number-prefix) = '-' and normalize-space($number-prefix) = '-'">
|
||||
<w:numFmt w:val="number-in-dash"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$number-format = '1'">
|
||||
<!-- '1' also seems: decimal-half-width -->
|
||||
<w:numFmt w:val="decimal"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$number-format = 'a'">
|
||||
<w:numFmt w:val="lower-letter"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$number-format = 'A'">
|
||||
<w:numFmt w:val="upper-letter"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$number-format = 'i'">
|
||||
<w:numFmt w:val="lower-roman"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$number-format = 'I'">
|
||||
<w:numFmt w:val="upper-roman"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$number-format = '1, 2, 3, ...'">
|
||||
<!-- '1, 2, 3, ...' also seems: decimal-full-width2 -->
|
||||
<w:numFmt w:val="decimal-full-width"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$number-format = '①, ②, ③, ...'">
|
||||
<!-- decimal-enclosed-circle seems same -->
|
||||
<w:numFmt w:val="decimal-enclosed-circle-chinese"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$number-format = '一, 二, 三, ...' and normalize-space($number-prefix) = '(' and normalize-space($number-suffix) = ')'">
|
||||
<w:numFmt w:val="ideograph-enclosed-circle"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$number-format = '一, 二, 三, ...'">
|
||||
<!-- '一, 二, 三, ...' also seems: ideograph-digital, japanese-counting, japanese-digital-ten-thousand,
|
||||
taiwanese-counting, taiwanese-counting-thousand, taiwanese-digital, chinese-counting, korean-digital2 -->
|
||||
<w:numFmt w:val="chinese-counting-thousand"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$number-format = '壹, 贰, 叁, ...'">
|
||||
<w:numFmt w:val="chinese-legal-simplified"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$number-format = '壹, 貳, 參, ...'">
|
||||
<w:numFmt w:val="ideograph-legal-traditional"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$number-format = '甲, 乙, 丙, ...'">
|
||||
<w:numFmt w:val="ideograph-traditional"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$number-format = '子, 丑, 寅, ...'">
|
||||
<w:numFmt w:val="ideograph-zodiac"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$number-format = '壱, 弐, 参, ...'">
|
||||
<w:numFmt w:val="japanese-legal"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$number-format = 'ア, イ, ウ, ...'">
|
||||
<w:numFmt w:val="aiueo-full-width"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$number-format = 'ア, イ, ウ, ...'">
|
||||
<w:numFmt w:val="aiueo"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$number-format = 'イ, ロ, ハ, ...'">
|
||||
<w:numFmt w:val="iroha-full-width"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$number-format = 'イ, ロ, ハ, ...'">
|
||||
<w:numFmt w:val="iroha"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$number-format = '일, 이, 삼, ...'">
|
||||
<w:numFmt w:val="korean-counting"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$number-format = '하나, 둘, 셋, ...'">
|
||||
<w:numFmt w:val="korean-legal"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$number-format = 'ㄱ, ㄴ, ㄷ, ...' or $number-format = '㉠, ㉡, ㉢, ...'">
|
||||
<!-- mapping circled to uncircled -->
|
||||
<w:numFmt w:val="chosung"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$number-format = '가, 나, 다, ...' or $number-format = '㉮, ㉯, ㉰, ...'">
|
||||
<!-- mapping circled to uncircled -->
|
||||
<w:numFmt w:val="ganada"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$number-format = 'أ, ب, ت, ...'">
|
||||
<w:numFmt w:val="arabic-alpha"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$number-format = 'ก, ข, ฃ, ...'">
|
||||
<w:numFmt w:val="thai-letters"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$number-format = 'א, י, ק, ...'">
|
||||
<w:numFmt w:val="hebrew-1"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$number-format = 'א, ב, ג, ...'">
|
||||
<w:numFmt w:val="hebrew-2"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$number-format = 'Native Numbering'">
|
||||
<xsl:variable name="locale" select="/office:document/office:meta/dc:language"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="starts-with($locale, 'th-')">
|
||||
<!-- for Thai, mapping thai-numbers, thai-counting to thai-letters -->
|
||||
<w:numFmt w:val="thai-letters"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="starts-with($locale, 'hi-')">
|
||||
<!-- for Hindi, mapping hindi-vowels, hindi-consonants, hindi-counting to hindi-numbers -->
|
||||
<w:numFmt w:val="hindi-numbers"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="starts-with($locale, 'ar-')">
|
||||
<!-- for Arabic, mapping arabic-abjad to arabic-alpha -->
|
||||
<w:numFmt w:val="arabic-alpha"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="starts-with($locale, 'he-')">
|
||||
<!-- for Hebrew, mapping hebrew-2 to -->
|
||||
<w:numFmt w:val="hebrew-1"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="starts-with($locale, 'ru-')">
|
||||
<!-- for Russian, mapping russian-upper to russian-lower -->
|
||||
<w:numFmt w:val="russian-lower"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="starts-with($locale, 'vi-')">
|
||||
<!-- for Vietnamese -->
|
||||
<w:numFmt w:val="vietnamese-counting"/>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<!-- unsupported: ordinal, cardinal-text, ordinal-text, hex, chicago, bullet, ideograph-zodiac-traditional,
|
||||
chinese-not-impl -->
|
||||
<xsl:otherwise>
|
||||
<w:numFmt w:val="decimal"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>
|
||||
@@ -0,0 +1,407 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
* This file is part of the LibreOffice project.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* This file incorporates work covered by the following license notice:
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed
|
||||
* with this work for additional information regarding copyright
|
||||
* ownership. The ASF licenses this file to you under the Apache
|
||||
* License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
||||
-->
|
||||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml" xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:aml="http://schemas.microsoft.com/aml/2001/core" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" exclude-result-prefixes="office table style text draw svg dc config xlink meta oooc dom ooo chart math dr3d form script ooow draw">
|
||||
<xsl:key name="table-style" match="style:style[@style:family='table']" use="@style:name"/>
|
||||
<xsl:key name="table-column-style" match="style:style[@style:family='table-column']" use="@style:name"/>
|
||||
<xsl:key name="table-row-style" match="style:style[@style:family='table-row']" use="@style:name"/>
|
||||
<xsl:key name="table-cell-style" match="style:style[@style:family='table-cell']" use="@style:name"/>
|
||||
<xsl:template match="style:table-properties" mode="table">
|
||||
<xsl:param name="within-body"/>
|
||||
<xsl:if test="$within-body = 'yes'">
|
||||
<w:tblW>
|
||||
<xsl:choose>
|
||||
<xsl:when test="@style:rel-width">
|
||||
<xsl:attribute name="w:w"><xsl:value-of select="substring-before(@style:rel-width, '%') * 50"/></xsl:attribute>
|
||||
<xsl:attribute name="w:type">pct</xsl:attribute>
|
||||
</xsl:when>
|
||||
<xsl:when test="@style:width">
|
||||
<xsl:attribute name="w:w"><xsl:call-template name="convert2twip"><xsl:with-param name="value" select="@style:width"/></xsl:call-template></xsl:attribute>
|
||||
<xsl:attribute name="w:type">dxa</xsl:attribute>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:attribute name="w:w">0</xsl:attribute>
|
||||
<xsl:attribute name="w:type">auto</xsl:attribute>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</w:tblW>
|
||||
</xsl:if>
|
||||
<w:tblInd>
|
||||
<xsl:choose>
|
||||
<xsl:when test="@fo:margin-left">
|
||||
<xsl:attribute name="w:w"><xsl:call-template name="convert2twip"><xsl:with-param name="value" select="@fo:margin-left"/></xsl:call-template></xsl:attribute>
|
||||
<xsl:attribute name="w:type">dxa</xsl:attribute>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:attribute name="w:w">0</xsl:attribute>
|
||||
<xsl:attribute name="w:type">auto</xsl:attribute>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</w:tblInd>
|
||||
<xsl:if test="@table:align">
|
||||
<w:jc>
|
||||
<xsl:choose>
|
||||
<xsl:when test="@table:align = 'left' or @table:align= 'center' or @table:align = 'right'">
|
||||
<xsl:attribute name="w:val"><xsl:value-of select="@table:align"/></xsl:attribute>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:attribute name="w:val">left</xsl:attribute>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</w:jc>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
<xsl:template match="table:table">
|
||||
<!--fix for issue i32030 pagebreak before-->
|
||||
<xsl:if test="key('table-style', @table:style-name)/style:table-properties/@fo:break-before">
|
||||
<xsl:variable name="table-break-before" select="key('table-style', @table:style-name)/style:table-properties/@fo:break-before"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$table-break-before = 'page' ">
|
||||
<w:p>
|
||||
<w:r>
|
||||
<w:br w:type="page"/>
|
||||
</w:r>
|
||||
</w:p>
|
||||
</xsl:when>
|
||||
<xsl:when test="$table-break-before = 'column' ">
|
||||
<w:p>
|
||||
<w:r>
|
||||
<w:br w:type="column"/>
|
||||
</w:r>
|
||||
</w:p>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
</xsl:if>
|
||||
<w:tbl>
|
||||
<w:tblPr>
|
||||
<xsl:if test="not (@table:is-sub-table) or (@table:is-sub-table = 'false' )">
|
||||
<w:tblStyle w:val="{@table:style-name}"/>
|
||||
<xsl:apply-templates select="key('table-style', @table:style-name)/style:table-properties" mode="table">
|
||||
<xsl:with-param name="within-body" select="'yes'"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:if>
|
||||
<xsl:if test="@table:is-sub-table ='true' ">
|
||||
<w:tblW w:type="dxa">
|
||||
<xsl:variable name="sub-table-width">
|
||||
<xsl:call-template name="calculate-sub-table-width">
|
||||
<xsl:with-param name="sub-table-column-node" select="table:table-column[1]"/>
|
||||
<xsl:with-param name="total-sub-table-width" select="0"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:attribute name="w:w"><xsl:value-of select="$sub-table-width"/></xsl:attribute>
|
||||
</w:tblW>
|
||||
<!--w:tblLayout w:type="Fixed"/-->
|
||||
</xsl:if>
|
||||
</w:tblPr>
|
||||
<w:tblGrid>
|
||||
<xsl:apply-templates select="table:table-column"/>
|
||||
</w:tblGrid>
|
||||
<xsl:apply-templates select="table:table-header-rows/table:table-row | table:table-row"/>
|
||||
</w:tbl>
|
||||
<!--fix for issue i32030 pagebreak after-->
|
||||
<xsl:if test="key('table-style', @table:style-name)/style:table-properties/@fo:break-after">
|
||||
<xsl:variable name="table-break-after" select=" key('table-style', @table:style-name)/style:table-properties/@fo:break-after"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$table-break-after = 'page' ">
|
||||
<w:p>
|
||||
<w:r>
|
||||
<w:br w:type="page"/>
|
||||
</w:r>
|
||||
</w:p>
|
||||
</xsl:when>
|
||||
<xsl:when test="$table-break-after = 'column' ">
|
||||
<w:p>
|
||||
<w:r>
|
||||
<w:br w:type="column"/>
|
||||
</w:r>
|
||||
</w:p>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
</xsl:if>
|
||||
<xsl:if test="name(..)= 'table:table-cell' ">
|
||||
<w:p/>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
<xsl:template name="calculate-sub-table-width">
|
||||
<xsl:param name="sub-table-column-node"/>
|
||||
<xsl:param name="total-sub-table-width"/>
|
||||
<xsl:variable name="column-width" select="key('table-column-style', $sub-table-column-node/@table:style-name)/style:table-column-properties/@style:column-width"/>
|
||||
<xsl:variable name="column-width-in-twip">
|
||||
<xsl:call-template name="convert2twip">
|
||||
<xsl:with-param name="value" select="$column-width"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$sub-table-column-node/following-sibling::table:table-column">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$sub-table-column-node/@table:number-columns-repeated">
|
||||
<xsl:call-template name="calculate-sub-table-width">
|
||||
<xsl:with-param name="sub-table-column-node" select="$sub-table-column-node/following-sibling::table:table-column[ 1]"/>
|
||||
<xsl:with-param name="total-sub-table-width" select="$total-sub-table-width + $column-width-in-twip * $sub-table-column-node/@table:number-columns-repeated"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:call-template name="calculate-sub-table-width">
|
||||
<xsl:with-param name="sub-table-column-node" select="$sub-table-column-node/following-sibling::table:table-column[1]"/>
|
||||
<xsl:with-param name="total-sub-table-width" select="$total-sub-table-width + $column-width-in-twip "/>
|
||||
</xsl:call-template>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$sub-table-column-node/@table:number-columns-repeated">
|
||||
<xsl:value-of select="$total-sub-table-width + $column-width-in-twip * $sub-table-column-node/@table:number-columns-repeated"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="$total-sub-table-width + $column-width-in-twip "/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
<xsl:template match="table:table-column">
|
||||
<xsl:variable name="column-width" select="key('table-column-style', @table:style-name)/style:table-column-properties/@style:column-width"/>
|
||||
<xsl:variable name="column-width-in-twip">
|
||||
<xsl:call-template name="convert2twip">
|
||||
<xsl:with-param name="value" select="$column-width"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:choose>
|
||||
<!-- if table:table-column has attribute table:number-columns-repeated, then call the recursion
|
||||
temple repeat-gridcol to produce multiple w:gridCol in MS word. Gary.Yang -->
|
||||
<xsl:when test="@table:number-columns-repeated">
|
||||
<xsl:call-template name="repeat-gridcol">
|
||||
<xsl:with-param name="grid-repeat-count" select="@table:number-columns-repeated"/>
|
||||
<xsl:with-param name="column-width" select="$column-width-in-twip"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<w:gridCol w:w="{$column-width-in-twip}"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
<!--recursion template for produce multiple w:gridCol Gary.Yang-->
|
||||
<xsl:template name="repeat-gridcol">
|
||||
<xsl:param name="grid-repeat-count"/>
|
||||
<xsl:param name="column-width"/>
|
||||
<xsl:if test="$grid-repeat-count > 0">
|
||||
<w:gridCol w:w="{$column-width}"/>
|
||||
<xsl:call-template name="repeat-gridcol">
|
||||
<xsl:with-param name="grid-repeat-count" select="$grid-repeat-count - 1"/>
|
||||
<xsl:with-param name="column-width" select="$column-width"/>
|
||||
</xsl:call-template>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
<xsl:template match="table:table-row">
|
||||
<xsl:element name="w:tr">
|
||||
<xsl:element name="w:trPr">
|
||||
<xsl:if test="parent::table:table-header-rows">
|
||||
<!-- fix for Issue 32034-->
|
||||
<w:tblHeader>on</w:tblHeader>
|
||||
</xsl:if>
|
||||
<xsl:variable name="row-height" select="key('table-row-style', @table:style-name)/style:table-row-properties/@style:row-height"/>
|
||||
<xsl:if test="$row-height">
|
||||
<w:trHeight>
|
||||
<xsl:attribute name="w:val"><xsl:call-template name="convert2twip"><xsl:with-param name="value" select="$row-height"/></xsl:call-template></xsl:attribute>
|
||||
</w:trHeight>
|
||||
</xsl:if>
|
||||
</xsl:element>
|
||||
<!--end of w:trPr-->
|
||||
<xsl:apply-templates select="table:table-cell "/>
|
||||
</xsl:element>
|
||||
</xsl:template>
|
||||
<xsl:template match="table:table-cell ">
|
||||
<xsl:element name="w:tc">
|
||||
<xsl:element name="w:tcPr">
|
||||
<!-- to calculate the table-cell width Gary.Yang -->
|
||||
<xsl:choose>
|
||||
<!--when the table-cell contains the sub-table -->
|
||||
<xsl:when test="table:table/@table:is-sub-table= 'true' ">
|
||||
<xsl:variable name="table-cell-width">
|
||||
<xsl:call-template name="calculate-sub-table-width">
|
||||
<xsl:with-param name="sub-table-column-node" select="table:table/table:table-column[1]"/>
|
||||
<xsl:with-param name="total-sub-table-width" select="0"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<w:tcW w:type="dxa">
|
||||
<xsl:attribute name="w:w"><xsl:value-of select="$table-cell-width"/></xsl:attribute>
|
||||
</w:tcW>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<!-- when the table-cell doesn't contain the sub-table -->
|
||||
<xsl:variable name="table-cell-width">
|
||||
<xsl:call-template name="calculate-table-cell-width">
|
||||
<xsl:with-param name="table-cell-position" select="position()"/>
|
||||
<xsl:with-param name="table-column" select="ancestor::table:table[1]/table:table-column[1]"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<w:tcW w:type="dxa">
|
||||
<xsl:attribute name="w:w"><xsl:value-of select="$table-cell-width"/></xsl:attribute>
|
||||
</w:tcW>
|
||||
<!-- for performance issue, we can set w:type to auto that makes the cell width auto fit the content. -->
|
||||
<!--w:tcW w:w="0" w:type="auto"/-->
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:if test="@table:number-columns-spanned">
|
||||
<w:gridSpan w:val="{@table:number-columns-spanned}"/>
|
||||
</xsl:if>
|
||||
<xsl:variable name="cell-style-properties" select="key('table-cell-style', @table:style-name)/style:table-cell-properties"/>
|
||||
<xsl:if test="$cell-style-properties/@fo:background-color">
|
||||
<w:shd w:val="solid" w:color="{substring-after($cell-style-properties/@fo:background-color,'#')}"/>
|
||||
</xsl:if>
|
||||
<xsl:if test="$cell-style-properties/@fo:vertical-align">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$cell-style-properties/@fo:vertical-align = 'middle'">
|
||||
<w:vAlign w:val="center"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$cell-style-properties/@fo:vertical-align = 'Automatic'">
|
||||
<w:vAlign w:val="both"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<w:vAlign w:val="{$cell-style-properties/@fo:vertical-align}"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:if>
|
||||
<w:tcMar>
|
||||
<xsl:if test="$cell-style-properties/@fo:padding-top">
|
||||
<w:top w:type="dxa">
|
||||
<xsl:attribute name="w:w"><xsl:call-template name="convert2twip"><xsl:with-param name="value" select="$cell-style-properties/@fo:padding-top"/></xsl:call-template></xsl:attribute>
|
||||
</w:top>
|
||||
</xsl:if>
|
||||
<xsl:if test="$cell-style-properties/@fo:padding-bottom">
|
||||
<w:bottom w:type="dxa">
|
||||
<xsl:attribute name="w:w"><xsl:call-template name="convert2twip"><xsl:with-param name="value" select="$cell-style-properties/@fo:padding-bottom"/></xsl:call-template></xsl:attribute>
|
||||
</w:bottom>
|
||||
</xsl:if>
|
||||
<xsl:if test="$cell-style-properties/@fo:padding-left">
|
||||
<w:left w:type="dxa">
|
||||
<xsl:attribute name="w:w"><xsl:call-template name="convert2twip"><xsl:with-param name="value" select="$cell-style-properties/@fo:padding-left"/></xsl:call-template></xsl:attribute>
|
||||
</w:left>
|
||||
</xsl:if>
|
||||
<xsl:if test="$cell-style-properties/@fo:padding-right">
|
||||
<w:right w:type="dxa">
|
||||
<xsl:attribute name="w:w"><xsl:call-template name="convert2twip"><xsl:with-param name="value" select="$cell-style-properties/@fo:padding-right"/></xsl:call-template></xsl:attribute>
|
||||
</w:right>
|
||||
</xsl:if>
|
||||
</w:tcMar>
|
||||
<!-- the following code is to get the cell borders if they exist -->
|
||||
<xsl:variable name="border-top" select="$cell-style-properties/@fo:border-top | $cell-style-properties/@fo:border"/>
|
||||
<xsl:variable name="border-bottom" select="$cell-style-properties/@fo:border-bottom | $cell-style-properties/@fo:border"/>
|
||||
<xsl:variable name="border-left" select="$cell-style-properties/@fo:border-left | $cell-style-properties/@fo:border"/>
|
||||
<xsl:variable name="border-right" select="$cell-style-properties/@fo:border-right | $cell-style-properties/@fo:border"/>
|
||||
<xsl:variable name="border-line-width-top" select="$cell-style-properties/@style:border-line-width-top | $cell-style-properties/@style:border-line-width "/>
|
||||
<xsl:variable name="border-line-width-bottom" select="$cell-style-properties/@style:border-line-width-bottom | $cell-style-properties/@style:border-line-width"/>
|
||||
<xsl:variable name="border-line-width-left" select="$cell-style-properties/@style:border-line-width-left | $cell-style-properties/@style:border-line-width"/>
|
||||
<xsl:variable name="border-line-width-right" select="$cell-style-properties/@style:border-line-width-right | $cell-style-properties/@style:border-line-width"/>
|
||||
<xsl:element name="w:tcBorders">
|
||||
<xsl:if test="$border-top">
|
||||
<xsl:element name="w:top">
|
||||
<xsl:call-template name="get-border">
|
||||
<xsl:with-param name="so-border" select="$border-top"/>
|
||||
<xsl:with-param name="so-border-line-width" select="$border-line-width-top"/>
|
||||
<xsl:with-param name="so-border-position" select=" 'top' "/>
|
||||
</xsl:call-template>
|
||||
</xsl:element>
|
||||
</xsl:if>
|
||||
<xsl:if test="$border-bottom">
|
||||
<xsl:element name="w:bottom">
|
||||
<xsl:call-template name="get-border">
|
||||
<xsl:with-param name="so-border" select="$border-bottom"/>
|
||||
<xsl:with-param name="so-border-line-width" select="$border-line-width-bottom"/>
|
||||
<xsl:with-param name="so-border-position" select=" 'bottom' "/>
|
||||
</xsl:call-template>
|
||||
</xsl:element>
|
||||
</xsl:if>
|
||||
<xsl:if test="$border-left">
|
||||
<xsl:element name="w:left">
|
||||
<xsl:call-template name="get-border">
|
||||
<xsl:with-param name="so-border" select="$border-left"/>
|
||||
<xsl:with-param name="so-border-line-width" select="$border-line-width-left"/>
|
||||
<xsl:with-param name="so-border-position" select=" 'left' "/>
|
||||
</xsl:call-template>
|
||||
</xsl:element>
|
||||
</xsl:if>
|
||||
<xsl:if test="$border-right">
|
||||
<xsl:element name="w:right">
|
||||
<xsl:call-template name="get-border">
|
||||
<xsl:with-param name="so-border" select="$border-right"/>
|
||||
<xsl:with-param name="so-border-line-width" select="$border-line-width-right"/>
|
||||
<xsl:with-param name="so-border-position" select=" 'right' "/>
|
||||
</xsl:call-template>
|
||||
</xsl:element>
|
||||
</xsl:if>
|
||||
</xsl:element>
|
||||
</xsl:element>
|
||||
<xsl:if test="not (*) ">
|
||||
<w:p/>
|
||||
</xsl:if>
|
||||
<xsl:apply-templates select=" text:p | table:table | text:h | office:annotation"/>
|
||||
</xsl:element>
|
||||
</xsl:template>
|
||||
<xsl:template name="calculate-table-cell-width">
|
||||
<xsl:param name="table-cell-position"/>
|
||||
<xsl:param name="table-column"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$table-column/@table:number-columns-repeated">
|
||||
<xsl:choose>
|
||||
<xsl:when test="($table-cell-position - $table-column/@table:number-columns-repeated) <= 0">
|
||||
<xsl:variable name="table-cell-width" select="key('table-column-style', $table-column/@table:style-name)/style:table-column-properties/@style:column-width"/>
|
||||
<xsl:variable name="table-cell-width-in-twip">
|
||||
<xsl:call-template name="convert2twip">
|
||||
<xsl:with-param name="value" select="$table-cell-width"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:value-of select="$table-cell-width-in-twip"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:call-template name="calculate-table-cell-width">
|
||||
<xsl:with-param name="table-cell-position" select="$table-cell-position - $table-column/@table:number-columns-repeated"/>
|
||||
<xsl:with-param name="table-column" select="$table-column/following-sibling::table:table-column[1]"/>
|
||||
</xsl:call-template>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<!-- if the $table-column doesn't contain the table:number-columns-repeated attribute -->
|
||||
<xsl:choose>
|
||||
<xsl:when test="($table-cell-position - 1) = 0">
|
||||
<xsl:variable name="table-cell-width" select="key('table-column-style', $table-column/@table:style-name)/style:table-column-properties/@style:column-width"/>
|
||||
<xsl:variable name="table-cell-width-in-twip">
|
||||
<xsl:call-template name="convert2twip">
|
||||
<xsl:with-param name="value" select="$table-cell-width"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:value-of select="$table-cell-width-in-twip"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="($table-cell-position - 1) > 0">
|
||||
<xsl:call-template name="calculate-table-cell-width">
|
||||
<xsl:with-param name="table-cell-position" select=" $table-cell-position - 1 "/>
|
||||
<xsl:with-param name="table-column" select="$table-column/following-sibling::table:table-column[1]"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:message>
|
||||
<xsl:value-of select=" 'calculate table cell width wrong ' "/>
|
||||
</xsl:message>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,511 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
* This file is part of the LibreOffice project.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* This file incorporates work covered by the following license notice:
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed
|
||||
* with this work for additional information regarding copyright
|
||||
* ownership. The ASF licenses this file to you under the Apache
|
||||
* License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
||||
-->
|
||||
<!--
|
||||
For further documentation and updates visit http://xml.openoffice.org/odf2xhtml
|
||||
-->
|
||||
<xsl:stylesheet version="1.0"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
|
||||
xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0"
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:dom="http://www.w3.org/2001/xml-events"
|
||||
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"
|
||||
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
|
||||
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
|
||||
xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"
|
||||
xmlns:math="http://www.w3.org/1998/Math/MathML"
|
||||
xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0"
|
||||
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
|
||||
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
|
||||
xmlns:ooo="http://openoffice.org/2004/office"
|
||||
xmlns:oooc="http://openoffice.org/2004/calc"
|
||||
xmlns:ooow="http://openoffice.org/2004/writer"
|
||||
xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"
|
||||
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
|
||||
xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
|
||||
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
|
||||
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
|
||||
xmlns:xforms="http://www.w3.org/2002/xforms"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
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 xforms xsd xsi"
|
||||
xmlns="http://www.w3.org/1999/xhtml">
|
||||
|
||||
<!-- ************** -->
|
||||
<!-- *** header *** -->
|
||||
<!-- ************** -->
|
||||
|
||||
<xsl:template name="create-header">
|
||||
<xsl:param name="globalData" />
|
||||
|
||||
<xsl:text>
</xsl:text>
|
||||
<xsl:element name="head">
|
||||
<xsl:attribute name="profile">http://dublincore.org/documents/dcmi-terms/</xsl:attribute>
|
||||
<xsl:if test="$debugEnabled"><xsl:message>CSS helper variable will be created...</xsl:message></xsl:if>
|
||||
<xsl:call-template name='xhtml-header-properties'>
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
</xsl:call-template>
|
||||
<xsl:text>
</xsl:text>
|
||||
|
||||
<xsl:if test="$debugEnabled"><xsl:message>CSS variable ready, header will be created...</xsl:message></xsl:if>
|
||||
<!-- constructing the css header simulating inheritance of style-families by style order -->
|
||||
<xsl:call-template name='create-css-styleheader'>
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
</xsl:call-template>
|
||||
<xsl:if test="$debugEnabled"><xsl:message>CSS header creation finished!</xsl:message></xsl:if>
|
||||
<xsl:text>
</xsl:text>
|
||||
</xsl:element>
|
||||
|
||||
</xsl:template>
|
||||
|
||||
<!-- Creating a CSS style header from the collected styles of the 'globalData' parameter -->
|
||||
<xsl:template name='create-css-styleheader'>
|
||||
<xsl:param name="globalData" />
|
||||
|
||||
<xsl:element name="style">
|
||||
<!-- https://validator.w3.org/unicorn:
|
||||
The “type” attribute for the “style” element is not needed and should be omitted.
|
||||
<xsl:attribute name="type">text/css</xsl:attribute> -->
|
||||
<xsl:text>
|
||||
</xsl:text>
|
||||
<xsl:call-template name='create-page-layout'>
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
</xsl:call-template>
|
||||
<xsl:text>table { border-collapse:collapse; border-spacing:0; empty-cells:show }
|
||||
</xsl:text>
|
||||
<xsl:choose>
|
||||
<xsl:when test="/*/office:body/office:spreadsheet"><xsl:text>td, th { vertical-align:top; font-size:10pt;}
|
||||
</xsl:text></xsl:when>
|
||||
<xsl:otherwise><xsl:text>td, th { vertical-align:top; font-size:12pt;}
|
||||
</xsl:text></xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:text>h1, h2, h3, h4, h5, h6 { clear:both;}
|
||||
</xsl:text>
|
||||
<xsl:choose>
|
||||
<xsl:when test="/*/office:body/office:spreadsheet">
|
||||
<xsl:text>p { white-space: nowrap; }
|
||||
</xsl:text>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
<xsl:text>ol, ul { margin:0; padding:0;}
|
||||
</xsl:text>
|
||||
<xsl:text>li { list-style: none; margin:0; padding:0;}
|
||||
</xsl:text>
|
||||
<xsl:text>span.footnodeNumber { padding-right:1em; }
|
||||
</xsl:text>
|
||||
<xsl:text>span.annotation_style_by_filter { font-size:95%; font-family:Arial; background-color:#fff000; margin:0; border:0; padding:0; }
|
||||
</xsl:text>
|
||||
<!-- Simulate tabs. They are around 0.64cm in LO, we convert that to 0.8rem. -->
|
||||
<xsl:text>span.heading_numbering { margin-right: 0.8rem; }</xsl:text>
|
||||
<xsl:text>* { margin:0;}
|
||||
</xsl:text>
|
||||
<xsl:call-template name="write-mapped-CSS-styles">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
</xsl:call-template>
|
||||
</xsl:element>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="write-mapped-CSS-styles">
|
||||
<xsl:param name="globalData" />
|
||||
<xsl:param name="emptyStyles"/>
|
||||
|
||||
<xsl:for-each select="$globalData/all-styles/style">
|
||||
<xsl:if test="final-properties != ''">
|
||||
<!-- NOTE: easy process, as only the style family in conjunction with the style name, makes the style unambiguous -->
|
||||
<xsl:text>.</xsl:text><!--<xsl:value-of select="@style:family" /><xsl:text>:</xsl:text>--><xsl:value-of select="translate(@style:name, '.,;: %()[]/\+', '_____________')"/><xsl:text> { </xsl:text> <xsl:value-of select="final-properties" /><xsl:text>}
|
||||
</xsl:text>
|
||||
</xsl:if>
|
||||
|
||||
</xsl:for-each>
|
||||
<!-- Otherwise all styles have been processed and the empty styles have to be given out -->
|
||||
<xsl:text>/* ODF styles with no properties representable as CSS:
|
||||
</xsl:text><xsl:for-each select="$globalData/all-styles/style[final-properties = '']"><xsl:value-of select="concat('.', @style:name, ' ')"/></xsl:for-each><xsl:text> { } */
|
||||
</xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<!-- Creating CSS page layout based on first office master style -->
|
||||
<xsl:template name='create-page-layout'>
|
||||
<xsl:param name="globalData" />
|
||||
|
||||
<!-- approximation to find the correct master page style (with page dimensions) -->
|
||||
<xsl:variable name="masterPageNames">
|
||||
<!-- set context to styles.xml -->
|
||||
<xsl:for-each select="$globalData/all-doc-styles/style">
|
||||
<!-- Loop over every style:style containing a @style:master-page-name attribute -->
|
||||
<xsl:for-each select="key('masterPage','count')">
|
||||
<!-- set context to styles.xml -->
|
||||
<xsl:for-each select="/*/office:body">
|
||||
<!-- Check if this style is being used in the body -->
|
||||
<xsl:if test="key('elementUsingStyle', ../@style:name)">
|
||||
<!-- Check every master-page-name if it is not empty and return as ';' separated list -->
|
||||
<xsl:if test="string-length(../@style:master-page-name) > 0"><xsl:value-of select="../@style:master-page-name"/>;</xsl:if>
|
||||
</xsl:if>
|
||||
</xsl:for-each>
|
||||
</xsl:for-each>
|
||||
</xsl:for-each>
|
||||
</xsl:variable>
|
||||
<!-- Take the first of the masterpage list and get the according style:master-page element and find the @style:page-layout-name -->
|
||||
<xsl:variable name="pageLayoutName" select="key('masterPageElements', substring-before($masterPageNames,';'))/@style:page-layout-name"/>
|
||||
<!-- Find the according style:page-layout and store the properties in a variable -->
|
||||
<xsl:variable name="pageProperties" select="key('pageLayoutElements', $pageLayoutName)/style:page-layout-properties"/>
|
||||
|
||||
<xsl:variable name="pageSize">
|
||||
<xsl:call-template name="page-size">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="pageProperties" select="$pageProperties" />
|
||||
</xsl:call-template>
|
||||
<xsl:call-template name="page-margin">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="pageProperties" select="$pageProperties" />
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:if test="$pageSize and $pageSize!=''">
|
||||
<xsl:text>@page { </xsl:text>
|
||||
<xsl:value-of select="$pageSize"/>
|
||||
<xsl:text> }
|
||||
</xsl:text>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template name="page-size">
|
||||
<xsl:param name="globalData" />
|
||||
<xsl:param name="pageProperties" />
|
||||
|
||||
<xsl:variable name="printOrientation" select="$pageProperties/@style:print-orientation" />
|
||||
<xsl:variable name="pageWidth" select="$pageProperties/@fo:page-width" />
|
||||
<xsl:variable name="pageHeight" select="$pageProperties/@fo:page-height" />
|
||||
<xsl:choose>
|
||||
<xsl:when test="$pageWidth and $pageHeight">
|
||||
<xsl:text>size: </xsl:text>
|
||||
<xsl:value-of select="$pageWidth" />
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:value-of select="$pageHeight" />
|
||||
<xsl:text>; </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="$printOrientation">
|
||||
<xsl:text>size: </xsl:text>
|
||||
<xsl:value-of select="$printOrientation" />
|
||||
<xsl:text>; </xsl:text>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="page-margin">
|
||||
<xsl:param name="globalData" />
|
||||
<xsl:param name="pageProperties" />
|
||||
|
||||
<xsl:variable name="marginTop" select="$pageProperties/@fo:margin-top" />
|
||||
<xsl:if test="$marginTop">
|
||||
<xsl:text>margin-top: </xsl:text>
|
||||
<xsl:value-of select="$marginTop" />
|
||||
<xsl:text>; </xsl:text>
|
||||
</xsl:if>
|
||||
<xsl:variable name="marginBottom" select="$pageProperties/@fo:margin-bottom" />
|
||||
<xsl:if test="$marginBottom">
|
||||
<xsl:text>margin-bottom: </xsl:text>
|
||||
<xsl:value-of select="$marginBottom" />
|
||||
<xsl:text>; </xsl:text>
|
||||
</xsl:if>
|
||||
<xsl:variable name="marginLeft" select="$pageProperties/@fo:margin-left" />
|
||||
<xsl:if test="$marginLeft">
|
||||
<xsl:text>margin-left: </xsl:text>
|
||||
<xsl:value-of select="$marginLeft" />
|
||||
<xsl:text>; </xsl:text>
|
||||
</xsl:if>
|
||||
<xsl:variable name="marginRight" select="$pageProperties/@fo:margin-right" />
|
||||
<xsl:if test="$marginRight">
|
||||
<xsl:text>margin-right: </xsl:text>
|
||||
<xsl:value-of select="$marginRight" />
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<!-- *************************** -->
|
||||
<!-- *** Common XHTML header *** -->
|
||||
<!-- *************************** -->
|
||||
|
||||
<xsl:template name='xhtml-header-properties'>
|
||||
<xsl:param name="globalData" />
|
||||
|
||||
<xsl:variable name="netloc">
|
||||
<xsl:for-each select="$globalData/meta-file/*/office:meta/meta:user-defined">
|
||||
<xsl:if test="./@meta:name='ODF.base'">
|
||||
<xsl:value-of select="." />
|
||||
<xsl:text>
</xsl:text>
|
||||
</xsl:if>
|
||||
</xsl:for-each>
|
||||
<xsl:for-each select="$globalData/meta-file/*/office:meta/meta:user-defined">
|
||||
<xsl:if test="./@meta:name='ODF.filename'">
|
||||
<xsl:value-of select="." />
|
||||
<xsl:text>
</xsl:text>
|
||||
</xsl:if>
|
||||
</xsl:for-each>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:variable name="lang">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$globalData/meta-file/*/office:meta/dc:language">
|
||||
<xsl:value-of select="$globalData/meta-file/*/office:meta/dc:language" />
|
||||
</xsl:when>
|
||||
<xsl:otherwise>en-US</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:text>
</xsl:text>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:variable name="prov">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$globalData/meta-file/*/office:meta/meta:printed-by">
|
||||
<xsl:value-of select="concat('Printed by "',$globalData/meta-file/*/office:meta/meta:printed-by,'"[dc:publisher] on "',$globalData/meta-file/*/office:meta/meta:print-date,'"[dc:date] in "',$lang,'"[dc:language]')" />
|
||||
</xsl:when>
|
||||
<xsl:otherwise />
|
||||
</xsl:choose>
|
||||
<xsl:text>
</xsl:text>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:variable name="keywords">
|
||||
<xsl:for-each select="$globalData/meta-file/*/office:meta/meta:keyword">
|
||||
<xsl:value-of select="." />
|
||||
<xsl:if test="position() != last()">
|
||||
<xsl:text>, </xsl:text>
|
||||
</xsl:if>
|
||||
</xsl:for-each>
|
||||
<xsl:text>
</xsl:text>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:text>
</xsl:text>
|
||||
<!-- explicit output content-type for low-tech browser (e.g. IE6) -->
|
||||
<xsl:element name="meta">
|
||||
<xsl:attribute name="http-equiv">Content-Type</xsl:attribute>
|
||||
<xsl:attribute name="content">application/xhtml+xml; charset=utf-8</xsl:attribute>
|
||||
</xsl:element>
|
||||
<xsl:text>
</xsl:text>
|
||||
|
||||
<!-- title of document for browser frame title -->
|
||||
<xsl:element name="title">
|
||||
<xsl:attribute name="xml:lang">
|
||||
<xsl:value-of select="$lang" />
|
||||
</xsl:attribute>
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="$globalData/meta-file/*/office:meta/dc:title">
|
||||
<xsl:value-of select="$globalData/meta-file/*/office:meta/dc:title" />
|
||||
</xsl:when>
|
||||
<!-- providing the mandatory title is a workaround for an IE bug-->
|
||||
<xsl:otherwise>
|
||||
<xsl:text>- no title specified</xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:element>
|
||||
<xsl:text>
</xsl:text>
|
||||
|
||||
<!-- title, in DC syntax -->
|
||||
<xsl:element name="meta">
|
||||
<xsl:attribute name="name">DCTERMS.title</xsl:attribute>
|
||||
<xsl:attribute name="content">
|
||||
<xsl:value-of select="$globalData/meta-file/*/office:meta/dc:title" />
|
||||
</xsl:attribute>
|
||||
<xsl:attribute name="xml:lang">
|
||||
<xsl:value-of select="$lang" />
|
||||
</xsl:attribute>
|
||||
</xsl:element>
|
||||
<xsl:text>
</xsl:text>
|
||||
|
||||
<!-- the identifier for source (identifier) -->
|
||||
<xsl:call-template name="add-meta-tag">
|
||||
<xsl:with-param name="meta-name" select="'DCTERMS.identifier'" />
|
||||
<xsl:with-param name="meta-data" select="translate($netloc, ' ','')" />
|
||||
<xsl:with-param name="meta-enc" select="'DCTERMS.URI'" />
|
||||
</xsl:call-template>
|
||||
<xsl:text>
</xsl:text>
|
||||
|
||||
<!-- the language for source (language) -->
|
||||
<xsl:call-template name="add-meta-tag">
|
||||
<xsl:with-param name="meta-name" select="'DCTERMS.language'" />
|
||||
<xsl:with-param name="meta-data" select="$lang" />
|
||||
<xsl:with-param name="meta-enc" select="'DCTERMS.RFC4646'" />
|
||||
</xsl:call-template>
|
||||
<xsl:text>
</xsl:text>
|
||||
|
||||
<!-- a bit commercial (generator) -->
|
||||
<xsl:element name="meta">
|
||||
<xsl:attribute name="name">DCTERMS.source</xsl:attribute>
|
||||
<xsl:attribute name="content">http://xml.openoffice.org/odf2xhtml</xsl:attribute>
|
||||
</xsl:element>
|
||||
<xsl:text>
</xsl:text>
|
||||
|
||||
<!-- the author of the input source (author) -->
|
||||
<xsl:call-template name="add-meta-tag">
|
||||
<xsl:with-param name="meta-name" select="'DCTERMS.creator'" />
|
||||
<xsl:with-param name="meta-data" select="$globalData/meta-file/*/office:meta/meta:initial-creator" />
|
||||
</xsl:call-template>
|
||||
<xsl:text>
</xsl:text>
|
||||
|
||||
<!-- creation-date of the input source (issued) -->
|
||||
<xsl:call-template name="add-meta-tag">
|
||||
<xsl:with-param name="meta-name" select="'DCTERMS.issued'" />
|
||||
<xsl:with-param name="meta-data" select="$globalData/meta-file/*/office:meta/meta:creation-date" />
|
||||
<xsl:with-param name="meta-enc" select="'DCTERMS.W3CDTF'" />
|
||||
</xsl:call-template>
|
||||
<xsl:text>
</xsl:text>
|
||||
|
||||
<!-- name of last changing person of the input source (changedby) -->
|
||||
<xsl:call-template name="add-meta-tag">
|
||||
<xsl:with-param name="meta-name" select="'DCTERMS.contributor'" />
|
||||
<xsl:with-param name="meta-data" select="$globalData/meta-file/*/office:meta/dc:creator" />
|
||||
</xsl:call-template>
|
||||
<xsl:text>
</xsl:text>
|
||||
|
||||
<!-- last changing date of the input source (changed) -->
|
||||
<xsl:call-template name="add-meta-tag">
|
||||
<xsl:with-param name="meta-name" select="'DCTERMS.modified'" />
|
||||
<xsl:with-param name="meta-data" select="$globalData/meta-file/*/office:meta/dc:date" />
|
||||
<xsl:with-param name="meta-enc" select="'DCTERMS.W3CDTF'" />
|
||||
</xsl:call-template>
|
||||
<xsl:text>
</xsl:text>
|
||||
|
||||
<!-- Last print, as provenance -->
|
||||
<xsl:if test="$prov">
|
||||
<xsl:call-template name="add-meta-tag">
|
||||
<xsl:with-param name="meta-name" select="'DCTERMS.provenance'" />
|
||||
<xsl:with-param name="meta-data" select="$prov" />
|
||||
<xsl:with-param name="meta-lang" select="$lang" />
|
||||
</xsl:call-template>
|
||||
<xsl:text>
</xsl:text>
|
||||
</xsl:if>
|
||||
|
||||
<!-- keywords about the input source (keywords) -->
|
||||
<xsl:if test="($globalData/meta-file/*/office:meta/dc:subject != '') or ($keywords != '')">
|
||||
<xsl:choose>
|
||||
<xsl:when test="($globalData/meta-file/*/office:meta/dc:subject != '') and ($keywords != '')">
|
||||
<xsl:call-template name="add-meta-tag">
|
||||
<xsl:with-param name="meta-name" select="'DCTERMS.subject'" />
|
||||
<xsl:with-param name="meta-data" select="normalize-space(concat($globalData/meta-file/*/office:meta/dc:subject,', ',$keywords))" />
|
||||
<xsl:with-param name="meta-lang" select="$lang" />
|
||||
</xsl:call-template>
|
||||
<xsl:text>
</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="($globalData/meta-file/*/office:meta/dc:subject != '')">
|
||||
<xsl:call-template name="add-meta-tag">
|
||||
<xsl:with-param name="meta-name" select="'DCTERMS.subject'" />
|
||||
<xsl:with-param name="meta-data" select="normalize-space($globalData/meta-file/*/office:meta/dc:subject)" />
|
||||
<xsl:with-param name="meta-lang" select="$lang" />
|
||||
</xsl:call-template>
|
||||
<xsl:text>
</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:call-template name="add-meta-tag">
|
||||
<xsl:with-param name="meta-name" select="'DCTERMS.subject'" />
|
||||
<xsl:with-param name="meta-data" select="normalize-space($keywords)" />
|
||||
<xsl:with-param name="meta-lang" select="$lang" />
|
||||
</xsl:call-template>
|
||||
<xsl:text>
</xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:if>
|
||||
|
||||
<!-- detailed description about the input source (description) -->
|
||||
<xsl:call-template name="add-meta-tag">
|
||||
<xsl:with-param name="meta-name" select="'DCTERMS.description'" />
|
||||
<xsl:with-param name="meta-data" select="$globalData/meta-file/*/office:meta/dc:description" />
|
||||
<xsl:with-param name="meta-lang" select="$lang" />
|
||||
</xsl:call-template>
|
||||
<xsl:text>
</xsl:text>
|
||||
|
||||
|
||||
<!-- user defined use of DCTERM tags -->
|
||||
<xsl:for-each select="$globalData/meta-file/*/office:meta/meta:user-defined[starts-with(@meta:name,'DCTERMS.')][not(.='')]">
|
||||
<xsl:call-template name="add-meta-tag">
|
||||
<xsl:with-param name="meta-name" select="@meta:name" />
|
||||
<xsl:with-param name="meta-data" select="." />
|
||||
<!-- <xsl:with-param name="meta-lang" select="$lang" /> -->
|
||||
</xsl:call-template>
|
||||
<xsl:text>
</xsl:text>
|
||||
</xsl:for-each>
|
||||
<!-- user defined use of DC tags (legacy) -->
|
||||
<xsl:for-each select="$globalData/meta-file/*/office:meta/meta:user-defined[starts-with(@meta:name,'DC.')][not(.='')]">
|
||||
<xsl:call-template name="add-meta-tag">
|
||||
<xsl:with-param name="meta-name" select="@meta:name" />
|
||||
<xsl:with-param name="meta-data" select="." />
|
||||
<!-- <xsl:with-param name="meta-lang" select="$lang" /> -->
|
||||
</xsl:call-template>
|
||||
<xsl:text>
</xsl:text>
|
||||
</xsl:for-each>
|
||||
<xsl:call-template name="add-meta-tag">
|
||||
<xsl:with-param name="meta-name" select="'xsl:vendor'" />
|
||||
<xsl:with-param name="meta-data" select="system-property('xsl:vendor')" />
|
||||
</xsl:call-template>
|
||||
<xsl:text>
</xsl:text>
|
||||
|
||||
<link rel="schema.DC" href="http://purl.org/dc/elements/1.1/" hreflang="en" />
|
||||
<xsl:text>
</xsl:text>
|
||||
<link rel="schema.DCTERMS" href="http://purl.org/dc/terms/" hreflang="en" />
|
||||
<xsl:text>
</xsl:text>
|
||||
<link rel="schema.DCTYPE" href="http://purl.org/dc/dcmitype/" hreflang="en" />
|
||||
<xsl:text>
</xsl:text>
|
||||
<link rel="schema.DCAM" href="http://purl.org/dc/dcam/" hreflang="en" />
|
||||
<xsl:text>
</xsl:text>
|
||||
<!-- W3C GRDDL Profile -->
|
||||
<!--
|
||||
<link rel="transformation" href="http://xml.openoffice.org/odf2xhtml/rdf-extract.xsl" />
|
||||
-->
|
||||
|
||||
<!-- base URL of document for resolving relative links
|
||||
NOTE: CHROME has a problem, with relative references as from content table, referencing to root directory instead of document
|
||||
<xsl:element name="base">
|
||||
<xsl:attribute name="href">-->
|
||||
<!-- earlier 'targetURL' was used for an absolute reference of base provided by the Office (file URL)
|
||||
<xsl:value-of select="$targetURL" />
|
||||
now '.' let relative links work, even if document has been moved -->
|
||||
<!--<xsl:text>.</xsl:text>
|
||||
</xsl:attribute>
|
||||
</xsl:element>-->
|
||||
</xsl:template>
|
||||
|
||||
<!-- generic template for adding common meta tags -->
|
||||
<xsl:template name="add-meta-tag">
|
||||
<xsl:param name="meta-name" />
|
||||
<xsl:param name="meta-data" />
|
||||
<xsl:param name="meta-enc" />
|
||||
<xsl:param name="meta-lang" />
|
||||
|
||||
<xsl:if test="$meta-data and $meta-data != ''">
|
||||
<xsl:element name="meta">
|
||||
<xsl:attribute name="name">
|
||||
<xsl:value-of select="$meta-name" />
|
||||
</xsl:attribute>
|
||||
<xsl:attribute name="content">
|
||||
<xsl:value-of select="$meta-data" />
|
||||
</xsl:attribute>
|
||||
<xsl:if test="$meta-enc">
|
||||
<xsl:attribute name="scheme">
|
||||
<xsl:value-of select="$meta-enc" />
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
<xsl:if test="$meta-lang">
|
||||
<xsl:attribute name="xml:lang">
|
||||
<xsl:value-of select="$meta-lang" />
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
</xsl:element>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
||||
@@ -0,0 +1,192 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
* This file is part of the LibreOffice project.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* This file incorporates work covered by the following license notice:
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed
|
||||
* with this work for additional information regarding copyright
|
||||
* ownership. The ASF licenses this file to you under the Apache
|
||||
* License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
||||
-->
|
||||
<!--
|
||||
For further documentation and updates visit http://xml.openoffice.org/odf2xhtml
|
||||
-->
|
||||
<xsl:stylesheet version="1.0"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
|
||||
xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0"
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:dom="http://www.w3.org/2001/xml-events"
|
||||
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"
|
||||
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
|
||||
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
|
||||
xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"
|
||||
xmlns:math="http://www.w3.org/1998/Math/MathML"
|
||||
xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0"
|
||||
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
|
||||
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
|
||||
xmlns:ooo="http://openoffice.org/2004/office"
|
||||
xmlns:oooc="http://openoffice.org/2004/calc"
|
||||
xmlns:ooow="http://openoffice.org/2004/writer"
|
||||
xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"
|
||||
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
|
||||
xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
|
||||
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
|
||||
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
|
||||
xmlns:xforms="http://www.w3.org/2002/xforms"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
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 xforms xsd xsi"
|
||||
xmlns="http://www.w3.org/1999/xhtml">
|
||||
|
||||
|
||||
<!--+++++ INCLUDED XSL MODULES +++++-->
|
||||
|
||||
<!-- inheritance of office style properties is resolved into absolute styles. Office properties gathered as elements -->
|
||||
<xsl:include href="../common/styles/style_collector.xsl" />
|
||||
|
||||
<!-- mapping rules of office style properties to CSS/HTML properties -->
|
||||
<xsl:include href="../common/styles/style_mapping_css.xsl" />
|
||||
|
||||
<!-- office header element handling especially for XHTML -->
|
||||
<xsl:include href="header.xsl" />
|
||||
|
||||
<!-- office body element handling especially for XHTML -->
|
||||
<xsl:include href="body.xsl" />
|
||||
|
||||
|
||||
<xsl:output method = "xml"
|
||||
encoding = "UTF-8"
|
||||
media-type = "application/xhtml+xml"
|
||||
indent = "no"
|
||||
omit-xml-declaration = "no"
|
||||
doctype-public = "-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN"
|
||||
doctype-system = "http://www.w3.org/Math/DTD/mathml2/xhtml-math11-f.dtd" />
|
||||
|
||||
|
||||
|
||||
<xsl:variable name="namespace" select="'http://www.w3.org/1999/xhtml'" />
|
||||
|
||||
<!--+++++ PARAMETER SECTION +++++-->
|
||||
|
||||
<!-- OPTIONAL: if the document content is provided in a directory structure. Opposite to a single flat XML stream -->
|
||||
<xsl:param name="isPackageFormat" />
|
||||
|
||||
<!-- OPTIONAL: (MANDATORY: for all input document with relative external links): parameter is an absolute file URL to the target directory.
|
||||
Relative links from the office document (e.g. to external graphics) will get this parameter as a prefix -->
|
||||
<xsl:param name="targetBaseURL" select="'./'" />
|
||||
|
||||
<!-- OPTIONAL: (MANDATORY: for all input document with content table) : parameter is an absolute file URL to the target document.
|
||||
Relative links to this office document (e.g. to internal anchor) will get this parameter as a prefix -->
|
||||
<xsl:param name="targetURL" select="'./'" />
|
||||
|
||||
<!-- OPTIONAL: (MANDATORY: for input document with relative internal links)
|
||||
To access contents of an office file (content like the meta.xml, styles.xml file or graphics) a URL could be chosen.
|
||||
This could be even a JAR URL. The sourceBase of the content URL "jar:file:/C:/temp/Test.sxw!/content.xml" would be
|
||||
"jar:file:/C:/temp/Test.sxw!/" for example.
|
||||
When working with OpenOffice API a Package-URL encoded over HTTP can be used to access the jared contents of the jared document. -->
|
||||
<xsl:param name="sourceBaseURL" select="'./'" />
|
||||
|
||||
<!-- OPTIONAL: (MANDATORY: for session management by URL rewriting)
|
||||
Useful for WebApplications: if a HTTP session is not cookie based, URL rewriting is being used (the session is appended to the URL).
|
||||
This URL session is used for example when links to graphics are created by XSLT. Otherwise the user have to log again in for every graphic he likes to see. -->
|
||||
<xsl:param name="optionalURLSuffix" />
|
||||
|
||||
<!-- OPTIONAL: URL to office meta file (flat xml use the URL to the input file) -->
|
||||
<xsl:param name="metaFileURL" />
|
||||
|
||||
<!-- OPTIONAL: URL to office meta file (flat xml use the URL to the input file) -->
|
||||
<xsl:param name="stylesFileURL" />
|
||||
|
||||
<!-- OPTIONAL: DPI (dots per inch) the standard resolution of given pictures (necessary for the conversion of 'cm' into 'pixel')-->
|
||||
<!-- Although many pictures have a 96 dpi resolution, a higher resolution give better results for common browsers -->
|
||||
<!-- Cp. measure_conversion.xsl:
|
||||
<xsl:param name="dpi" select="111" /> -->
|
||||
|
||||
|
||||
<!-- OPTIONAL: in case of using a different processor than a JAVA XSLT, you can unable the Java functionality
|
||||
(e.g. encoding chapter names for the content-table as href and anchors ) -->
|
||||
<xsl:param name="java" select="true()" />
|
||||
<xsl:param name="javaEnabled" select="boolean($java)" />
|
||||
|
||||
<!-- OPTIONAL: for activating the debug mode set the variable here to 'true()' or give any value from outside -->
|
||||
<xsl:param name="debug" select="false()" />
|
||||
<xsl:param name="debugEnabled" select="boolean($debug)" />
|
||||
<xsl:param name="onlyStyleOutput" select="false()" />
|
||||
<xsl:param name="onlyStyleOutputEnabled" select="boolean($onlyStyleOutput)" />
|
||||
|
||||
<!-- *************************************** -->
|
||||
<!-- *** build the appropriate HTML file *** -->
|
||||
<!-- *************************************** -->
|
||||
<xsl:template match="/">
|
||||
<!-- debug output of parameter value set -->
|
||||
<xsl:if test="$debugEnabled">
|
||||
<xsl:call-template name="debug-check-parameter" />
|
||||
</xsl:if>
|
||||
<xsl:message>XSL Vendor: '<xsl:value-of select="system-property('xsl:vendor')"/>'</xsl:message>
|
||||
<!-- gathers style properties and
|
||||
returns them as globalData parameter to the 'start-main' template -->
|
||||
<xsl:call-template name="collect-global-odf-properties" />
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<!-- *************************** -->
|
||||
<!-- *** Built up XHTML file *** -->
|
||||
<!-- *************************** -->
|
||||
<xsl:template name="start-main">
|
||||
<xsl:param name="globalData" />
|
||||
|
||||
<xsl:variable name="lang">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$globalData/meta-file/*/office:meta/dc:language">
|
||||
<xsl:value-of select="$globalData/meta-file/*/office:meta/dc:language" />
|
||||
</xsl:when>
|
||||
<xsl:otherwise>en-US</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:text>
</xsl:text>
|
||||
<xsl:element name="html">
|
||||
|
||||
<xsl:attribute name="lang"><xsl:value-of select="$lang"/></xsl:attribute>
|
||||
<xsl:text>
</xsl:text>
|
||||
<xsl:comment>This file was converted to xhtml by LibreOffice - see https://cgit.freedesktop.org/libreoffice/core/tree/filter/source/xslt for the code.</xsl:comment>
|
||||
<xsl:text>
</xsl:text>
|
||||
<xsl:call-template name='create-header'>
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
</xsl:call-template>
|
||||
|
||||
<xsl:text>
</xsl:text>
|
||||
<xsl:call-template name='create-body'>
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
</xsl:call-template>
|
||||
<xsl:text>
</xsl:text>
|
||||
</xsl:element>
|
||||
<xsl:text>
</xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<!-- debug purpose only:
|
||||
verbose checking of the parameters of this template-->
|
||||
<xsl:template name="debug-check-parameter">
|
||||
<xsl:message>Parameter dpi: <xsl:value-of select="$dpi" /></xsl:message>
|
||||
<xsl:message>Parameter metaFileURL: <xsl:value-of select="$metaFileURL" /></xsl:message>
|
||||
<xsl:message>Parameter stylesFileURL: <xsl:value-of select="$stylesFileURL" /></xsl:message>
|
||||
<xsl:message>Parameter sourceBaseURL: <xsl:value-of select="$sourceBaseURL" /></xsl:message>
|
||||
<xsl:message>Parameter targetBaseURL: <xsl:value-of select="$targetBaseURL" /></xsl:message>
|
||||
<xsl:message>Parameter onlyStyleOutputEnabled: <xsl:value-of select="$onlyStyleOutputEnabled" /></xsl:message>
|
||||
<xsl:message>Parameter debugEnabled: <xsl:value-of select="$debugEnabled" /></xsl:message>
|
||||
<xsl:message>Parameter java: <xsl:value-of select="$java" /></xsl:message>
|
||||
<xsl:message>Parameter javaEnabled: <xsl:value-of select="$javaEnabled" /></xsl:message>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
||||
@@ -0,0 +1,213 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
* This file is part of the LibreOffice project.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* This file incorporates work covered by the following license notice:
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed
|
||||
* with this work for additional information regarding copyright
|
||||
* ownership. The ASF licenses this file to you under the Apache
|
||||
* License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
||||
-->
|
||||
<!--
|
||||
For further documentation and updates visit http://xml.openoffice.org/odf2xhtml
|
||||
-->
|
||||
<xsl:stylesheet version="1.0"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
|
||||
xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0"
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:dom="http://www.w3.org/2001/xml-events"
|
||||
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"
|
||||
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
|
||||
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
|
||||
xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"
|
||||
xmlns:math="http://www.w3.org/1998/Math/MathML"
|
||||
xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0"
|
||||
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
|
||||
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
|
||||
xmlns:ooo="http://openoffice.org/2004/office"
|
||||
xmlns:oooc="http://openoffice.org/2004/calc"
|
||||
xmlns:ooow="http://openoffice.org/2004/writer"
|
||||
xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"
|
||||
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
|
||||
xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
|
||||
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
|
||||
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
|
||||
xmlns:xforms="http://www.w3.org/2002/xforms"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
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"
|
||||
xmlns="http://www.w3.org/1999/xhtml">
|
||||
|
||||
|
||||
|
||||
<!-- current node is a table:table -->
|
||||
<xsl:template name="create-table-children">
|
||||
<xsl:param name="globalData" />
|
||||
<xsl:param name="allVisibleTableRows" />
|
||||
<xsl:param name="allTableColumns" />
|
||||
|
||||
<xsl:element name="colgroup">
|
||||
<xsl:for-each select="$allTableColumns/table:table-column">
|
||||
<xsl:if test="not(@table:visibility = 'collapse' or @table:visibility = 'filter')">
|
||||
<xsl:element name="col">
|
||||
<xsl:variable name="value" select="$globalData/all-doc-styles/style[@style:name = current()/@table:style-name]/*/@style:column-width" />
|
||||
<xsl:if test="$value">
|
||||
<xsl:attribute name="width">
|
||||
<!-- using the absolute width, problems with the relative in browser (in OOo style:rel-column-width) -->
|
||||
<xsl:call-template name="convert2px">
|
||||
<xsl:with-param name="value" select="$globalData/all-doc-styles/style[@style:name = current()/@table:style-name]/*/@style:column-width" />
|
||||
</xsl:call-template>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
</xsl:element>
|
||||
<!-- *** the column-style ***
|
||||
<xsl:attribute name="width">
|
||||
<xsl:variable name="currentColumnStyleName" select="$allTableColumns/table:table-column[position() = $columnPosition]/@table:style-name" />
|
||||
<xsl:value-of select="$globalData/all-doc-styles/style[@style:name = $currentColumnStyleName]/*/@style:column-width" />
|
||||
</xsl:attribute>-->
|
||||
</xsl:if>
|
||||
</xsl:for-each>
|
||||
</xsl:element>
|
||||
|
||||
<xsl:call-template name="create-table-rows">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="allVisibleTableRows" select="$allVisibleTableRows" />
|
||||
<xsl:with-param name="allTableColumns" select="$allTableColumns" />
|
||||
</xsl:call-template>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
|
||||
<!-- Creating the content of a table content using CSS styles -->
|
||||
<xsl:template name="create-table-cell-content">
|
||||
<xsl:param name="tableDataType" />
|
||||
<xsl:param name="globalData" />
|
||||
<xsl:param name="allTableColumns" />
|
||||
<xsl:param name="columnPosition" />
|
||||
<xsl:param name="currentTableColumn" />
|
||||
|
||||
<xsl:element name="{$tableDataType}">
|
||||
|
||||
<!-- if parser reads DTD the default is set to '1' -->
|
||||
<xsl:if test="@table:number-columns-spanned and @table:number-columns-spanned > 1">
|
||||
<xsl:attribute name="colspan">
|
||||
<xsl:value-of select="@table:number-columns-spanned" />
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
<!-- if parser reads DTD the default is set to '1' -->
|
||||
<xsl:if test="@table:number-rows-spanned and @table:number-rows-spanned > 1">
|
||||
<xsl:attribute name="rowspan">
|
||||
<xsl:value-of select="@table:number-rows-spanned" />
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
|
||||
|
||||
<!-- *** the cell-style *** -->
|
||||
<!-- The cell style has no conclusion with the column style, so we switch the order/priorities due to browser issues
|
||||
|
||||
The cell-style depends on two attributes:
|
||||
|
||||
1) table:style-name - the style properties of cell. When they exist, a default alignment (cp. below) will be added for the
|
||||
case of no alignment in the style exist.
|
||||
|
||||
2) office:value-type - the value type of the table-cell giving the default alignments.
|
||||
By default a string value is left aligned, all other are aligned:right.
|
||||
-->
|
||||
<xsl:choose>
|
||||
<xsl:when test="@table:style-name">
|
||||
<xsl:call-template name="set-styles">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="styleName" select="@table:style-name" />
|
||||
<xsl:with-param name="currentTableColumn" select="$currentTableColumn" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<!-- Cells without a style use the 'table:default-cell-style-name'
|
||||
when there is no default cell style specified for the current column. -->
|
||||
<xsl:variable name="defaultCellStyleName" select="$currentTableColumn/@table:default-cell-style-name" />
|
||||
<xsl:choose>
|
||||
<xsl:when test="$defaultCellStyleName">
|
||||
<xsl:call-template name="set-styles">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
<xsl:with-param name="styleName" select="$defaultCellStyleName" />
|
||||
<xsl:with-param name="currentTableColumn" select="$currentTableColumn" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<!-- No cell style exists, nor a default table cell style for the column -->
|
||||
<xsl:attribute name="style">
|
||||
<!-- sets cell alignment dependent of cell value type -->
|
||||
<xsl:call-template name="set-cell-alignment" />
|
||||
</xsl:attribute>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
|
||||
<xsl:if test="$debugEnabled">
|
||||
<xsl:message>A table cell '<xsl:value-of select="$tableDataType" />' element has been added!</xsl:message>
|
||||
</xsl:if>
|
||||
|
||||
<!-- empty cell tags produce problems with width CSS style on itself other table cells as well
|
||||
therefore a non breakable space ( / ) have been inserted.-->
|
||||
<xsl:choose>
|
||||
<xsl:when test="node()">
|
||||
<xsl:call-template name="apply-styles-and-content">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:call-template name="apply-styles-and-content">
|
||||
<xsl:with-param name="globalData" select="$globalData" />
|
||||
</xsl:call-template>
|
||||
<xsl:text> </xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
|
||||
</xsl:element>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<!-- Sets the cell alignment by the 'office:value-type' of the 'table:table-cell'.
|
||||
Strings have a left alignment, other values right -->
|
||||
<xsl:template name="set-cell-alignment">
|
||||
<xsl:choose>
|
||||
<xsl:when test="@office:value-type and not(@office:value-type = 'string')">text-align:right; </xsl:when>
|
||||
<xsl:otherwise>text-align:left;</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
|
||||
<!-- Sets styles of a cell -->
|
||||
<xsl:template name="set-styles">
|
||||
<xsl:param name="globalData" />
|
||||
<xsl:param name="styleName" />
|
||||
<xsl:param name="currentTableColumn" />
|
||||
|
||||
<xsl:attribute name="style">
|
||||
<!-- sets cell alignment dependent of cell value type -->
|
||||
<xsl:call-template name="set-cell-alignment" />
|
||||
|
||||
<!-- set column style (disjunct of cell style) -->
|
||||
<xsl:value-of select="$globalData/all-styles/style[@style:name = $currentTableColumn/@table:style-name]/final-properties" />
|
||||
|
||||
</xsl:attribute>
|
||||
|
||||
<!-- cell style header -->
|
||||
<xsl:attribute name="class">
|
||||
<xsl:value-of select="translate($styleName, '.,;: %()[]/\+', '_____________')"/>
|
||||
</xsl:attribute>
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>
|
||||
|
||||
Reference in New Issue
Block a user