summaryrefslogtreecommitdiff
path: root/filter/source/xslt/odf2xhtml/export/common
diff options
context:
space:
mode:
Diffstat (limited to 'filter/source/xslt/odf2xhtml/export/common')
-rw-r--r--filter/source/xslt/odf2xhtml/export/common/body.xsl5
-rw-r--r--filter/source/xslt/odf2xhtml/export/common/styles/style_collector.xsl131
-rw-r--r--filter/source/xslt/odf2xhtml/export/common/styles/style_mapping_css.xsl30
-rw-r--r--filter/source/xslt/odf2xhtml/export/common/table/table.xsl4
-rw-r--r--filter/source/xslt/odf2xhtml/export/common/table/table_rows.xsl5
-rw-r--r--filter/source/xslt/odf2xhtml/export/common/table_of_content.xsl27
6 files changed, 148 insertions, 54 deletions
diff --git a/filter/source/xslt/odf2xhtml/export/common/body.xsl b/filter/source/xslt/odf2xhtml/export/common/body.xsl
index 9bc022e38d62..8dfb78222186 100644
--- a/filter/source/xslt/odf2xhtml/export/common/body.xsl
+++ b/filter/source/xslt/odf2xhtml/export/common/body.xsl
@@ -81,7 +81,7 @@
<!-- *************** -->
<!-- ID / NAME of text-box -->
- <xsl:template match="@draw:name">
+ <xsl:template match="@draw:name | @text:id | @xml:id">
<xsl:attribute name="id">
<xsl:choose>
<xsl:when test="number(substring(.,1,1))">
@@ -105,7 +105,8 @@
<!-- line breaks in lists need an indent similar to the list label -->
<xsl:if test="$listIndent">
<xsl:element namespace="{$namespace}" name="span">
- <xsl:attribute name="style">margin-left:<xsl:value-of select="$listIndent"/>cm</xsl:attribute>
+ <!-- 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>
diff --git a/filter/source/xslt/odf2xhtml/export/common/styles/style_collector.xsl b/filter/source/xslt/odf2xhtml/export/common/styles/style_collector.xsl
index d1c8f189be85..bdad6da4bf45 100644
--- a/filter/source/xslt/odf2xhtml/export/common/styles/style_collector.xsl
+++ b/filter/source/xslt/odf2xhtml/export/common/styles/style_collector.xsl
@@ -504,6 +504,8 @@
</xsl:template>
+ <!-- Context is <style:style> with all style properties elements containing attributes, accessed by */@prop
+ overwriting the ODF style properties that are being inherited from the 'inheritedStyleProperties' parameter! -->
<xsl:template name="create-inherited-style-properties">
<xsl:param name="inheritedStyleProperties" />
@@ -511,12 +513,70 @@
<!-- Writing all inherited style properties -->
<xsl:for-each select="$inheritedStyleProperties/@*">
<xsl:sort select="name()" />
- <xsl:copy-of select="." />
+
+ <!-- Normalization three ODF attributes to one ODF attribute fo:background color (only temporary not ODF conform but eases mapping to ODF)
+ There are two different background color:
+ 1) fo:background-color
+ 2) draw:fill-color
+ mapped to one in CSS.
+ In addition if there is the attribute @draw:fill="none" the background is 'transparent' -->
+ <xsl:choose>
+ <xsl:when test="name() = 'draw:fill-color' or name() = 'fo:background-color' or name() = 'draw:fill'">
+ <xsl:choose>
+ <xsl:when test="$inheritedStyleProperties/@draw:fill='none'">
+ <xsl:attribute name="fo:background-color">transparent</xsl:attribute>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:choose>
+ <xsl:when test="name()!='draw:fill'">
+ <xsl:attribute name="fo:background-color"><xsl:value-of select="."/></xsl:attribute>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:attribute name="fo:background-color">transparent</xsl:attribute>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:copy-of select="." />
+ </xsl:otherwise>
+ </xsl:choose>
</xsl:for-each>
+ <xsl:if test="*/@draw:fill-color or */@fo:background-color or */@draw:fill">
+ <xsl:choose>
+ <xsl:when test="*/@draw:fill='none'">
+ <xsl:attribute name="fo:background-color">transparent</xsl:attribute>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:choose>
+ <xsl:when test="*/@draw:fill-color">
+ <xsl:attribute name="fo:background-color"><xsl:value-of select="*/@draw:fill-color"/></xsl:attribute>
+ </xsl:when>
+ <xsl:when test="*/@fo:background-color">
+ <xsl:attribute name="fo:background-color"><xsl:value-of select="*/@fo:background-color"/></xsl:attribute>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:attribute name="fo:background-color">transparent</xsl:attribute>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:if>
+
+
+ <!-- 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']">
+ <xsl:for-each select="*/@*[name() != 'style:font-size-rel'][name() != 'fo:border'][name() != 'draw:fill-color']">
<xsl:copy-of select="." />
</xsl:for-each>
@@ -560,21 +620,20 @@
<xsl:template name="write-collected-styles">
<xsl:param name="globalData" />
- <xsl:message>&lt;all-doc-styles&gt;</xsl:message>
+ <xsl:message>all-doc-styles:start</xsl:message>
<xsl:for-each select="$globalData/all-doc-styles/style">
- <xsl:message>&lt;style</xsl:message>
- <xsl:message>style:family="<xsl:value-of select="current()/@style:family" />"&gt;</xsl:message>
- <xsl:message>style:name="<xsl:value-of select="current()/@style:name" />" </xsl:message>
- <xsl:message> &lt;*</xsl:message>
+ <xsl:message>***style:start</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> with properties:</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>/&gt;</xsl:message>
- <xsl:message>&lt;/style&gt;</xsl:message>
+ <xsl:message>***style:end</xsl:message>
</xsl:for-each>
- <xsl:message>&lt;/all-doc-styles&gt;</xsl:message>
+ <xsl:message>all-doc-styles:end</xsl:message>
</xsl:template>
<xsl:template name="map-odf-style-properties">
@@ -702,40 +761,28 @@
<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
- or ($style/*/@fo:border
- and
- not($style/*/@fo:border='none')
- )
+ or
+ $style/*/@fo:border-bottom
)
- and
- (
- not($style/*/@style:join-border)
- or $style/*/@style:join-border = 'true'
- )
- )
- or
- (
+ and
(
- $style/*/@fo:margin-top
- or $style/*/@fo:margin-bottom
- or $style/*/@fo:margin
- )
- and
- ( $style/*/@fo:background-color
- and
- not($style/*/@fo:background-color='transparent')
+ 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>
@@ -751,8 +798,7 @@
</xsl:element>
<xsl:element name="style" namespace="">
<xsl:copy-of select="$style/@style:family" />
- <xsl:copy-of select="$style/@style:name" />
- <xsl:attribute name="mergedBorders"><xsl:value-of select="true()" /></xsl:attribute>
+ <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" />
@@ -776,6 +822,17 @@
<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>
diff --git a/filter/source/xslt/odf2xhtml/export/common/styles/style_mapping_css.xsl b/filter/source/xslt/odf2xhtml/export/common/styles/style_mapping_css.xsl
index ec5b680df150..56b17331a0b9 100644
--- a/filter/source/xslt/odf2xhtml/export/common/styles/style_mapping_css.xsl
+++ b/filter/source/xslt/odf2xhtml/export/common/styles/style_mapping_css.xsl
@@ -22,11 +22,18 @@
<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>
+ <!-- *** Background color handling *** -->
+ <xsl:template match="@fo:background-color | @draw:fill-color | @draw:fill">
+ <xsl:choose>
+ <xsl:when test="@draw:fill='none'">
+ <xsl:text>background-color:transparent; </xsl:text>
+ </xsl:when>
+ <xsl:when test="name()!='draw:fill'">
+ <xsl:text>background-color:</xsl:text>
+ <xsl:value-of select="."/>
+ <xsl:text>; </xsl:text>
+ </xsl:when>
+ </xsl:choose>
</xsl:template>
<xsl:template match="@fo:border | @fo:border-top | @fo:border-bottom | @fo:border-left | @fo:border-right">
@@ -79,13 +86,21 @@
</xsl:template>
<!-- text-shadow is a CSS2 feature and yet not common used in user-agents -->
- <xsl:template match="@fo:color |@svg:font-family |@fo:font-size |@fo:font-style |@fo:font-weight |@fo:text-indent |@fo:text-shadow |@text:display">
+ <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%']"/>
@@ -208,9 +223,8 @@
<xsl:text>font-family:</xsl:text>
<xsl:variable name="content" select="."/>
- <xsl:variable name="quote">'</xsl:variable>
<xsl:variable name="fontName" select="$globalData/office:font-face-decls/style:font-face[@style:name=$content]/@svg:font-family" />
- <xsl:value-of select="translate($fontName, $quote, '')"/>
+ <xsl:value-of select="$fontName"/>
<xsl:text>; </xsl:text>
</xsl:template>
diff --git a/filter/source/xslt/odf2xhtml/export/common/table/table.xsl b/filter/source/xslt/odf2xhtml/export/common/table/table.xsl
index cfc1ebbc525b..1e9baa5703f2 100644
--- a/filter/source/xslt/odf2xhtml/export/common/table/table.xsl
+++ b/filter/source/xslt/odf2xhtml/export/common/table/table.xsl
@@ -65,12 +65,14 @@
<xsl:template match="table:table" name="table:table">
<xsl:param name="globalData" />
+ <xsl:text>&#xa;</xsl:text>
<!-- 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:text>&#xa;</xsl:text>
</xsl:template>
@@ -110,10 +112,12 @@
</xsl:element>
</xsl:when>
<xsl:otherwise>
+ <xsl:text>&#xa;</xsl:text>
<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:text>&#xa;</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
diff --git a/filter/source/xslt/odf2xhtml/export/common/table/table_rows.xsl b/filter/source/xslt/odf2xhtml/export/common/table/table_rows.xsl
index 2d6cd7285037..60b47be753ca 100644
--- a/filter/source/xslt/odf2xhtml/export/common/table/table_rows.xsl
+++ b/filter/source/xslt/odf2xhtml/export/common/table/table_rows.xsl
@@ -196,7 +196,10 @@
<xsl:param name="node-position" />
<xsl:attribute name="class">
- <xsl:value-of select="translate(@table:style-name, '. %()/\+', '')" />
+ <xsl:call-template name="create-unique-style-id">
+ <xsl:with-param name="styleName" select="@table:style-name"/>
+ <xsl:with-param name="styleFamily" select="'table-row'"/>
+ </xsl:call-template>
</xsl:attribute>
</xsl:template>
diff --git a/filter/source/xslt/odf2xhtml/export/common/table_of_content.xsl b/filter/source/xslt/odf2xhtml/export/common/table_of_content.xsl
index f26e2cc0a6c9..0f36b36486de 100644
--- a/filter/source/xslt/odf2xhtml/export/common/table_of_content.xsl
+++ b/filter/source/xslt/odf2xhtml/export/common/table_of_content.xsl
@@ -93,7 +93,10 @@
</xsl:attribute>
</xsl:if>
<xsl:attribute name="class">
- <xsl:value-of select="translate(parent::*/@text:style-name, '.,;: %()[]/\+', '_____________')"/>
+ <xsl:call-template name="create-unique-style-id">
+ <xsl:with-param name="styleName" select="parent::*/@text:style-name"/>
+ <xsl:with-param name="styleFamily" select="'table'"/>
+ </xsl:call-template>
</xsl:attribute>
</xsl:if>
@@ -291,7 +294,7 @@ Scenarios tabstops
-> 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 sceanrios 1 and 3
+ -> 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
@@ -317,7 +320,10 @@ Scenarios unmatched:
<xsl:element namespace="{$namespace}" name="p">
<xsl:if test="$position = 1">
<xsl:attribute name="class">
- <xsl:value-of select="translate(@text:style-name, '.,;: %()[]/\+', '_____________')"/>
+ <xsl:call-template name="create-unique-style-id">
+ <xsl:with-param name="styleName" select="@text:style-name"/>
+ <xsl:with-param name="styleFamily" select="'paragraph'"/>
+ </xsl:call-template>
</xsl:attribute>
</xsl:if>
<xsl:apply-templates mode="content-table">
@@ -341,7 +347,10 @@ Scenarios unmatched:
<xsl:element namespace="{$namespace}" name="p">
<xsl:if test="$position = 1">
<xsl:attribute name="class">
- <xsl:value-of select="translate(@text:style-name, '.,;: %()[]/\+', '_____________')"/>
+ <xsl:call-template name="create-unique-style-id">
+ <xsl:with-param name="styleName" select="@text:style-name"/>
+ <xsl:with-param name="styleFamily" select="'paragraph'"/>
+ </xsl:call-template>
</xsl:attribute>
</xsl:if>
<xsl:call-template name="grab-cell-content-before-tab-stop">
@@ -358,7 +367,10 @@ Scenarios unmatched:
<xsl:element namespace="{$namespace}" name="p">
<xsl:if test="$position = 1">
<xsl:attribute name="class">
- <xsl:value-of select="translate(@text:style-name, '.,;: %()[]/\+', '_____________')"/>
+ <xsl:call-template name="create-unique-style-id">
+ <xsl:with-param name="styleName" select="@text:style-name"/>
+ <xsl:with-param name="styleFamily" select="'paragraph'"/>
+ </xsl:call-template>
</xsl:attribute>
</xsl:if>
<xsl:call-template name="grab-cell-content-before-tab-stop">
@@ -382,7 +394,10 @@ Scenarios unmatched:
<xsl:element namespace="{$namespace}" name="p">
<xsl:if test="$position = 1">
<xsl:attribute name="class">
- <xsl:value-of select="translate(@text:style-name, '.,;: %()[]/\+', '_____________')"/>
+ <xsl:call-template name="create-unique-style-id">
+ <xsl:with-param name="styleName" select="@text:style-name"/>
+ <xsl:with-param name="styleFamily" select="'paragraph'"/>
+ </xsl:call-template>
</xsl:attribute>
</xsl:if>
<xsl:element namespace="{$namespace}" name="td">