Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync LO core xhtml filter as of 2023-05 #46

Merged
merged 7 commits into from
May 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
<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="replace($listIndent, ',', '.')"/>cm</xsl:attribute>
<xsl:attribute name="style">margin-left:<xsl:value-of select="translate($listIndent, ',', '.')"/>cm</xsl:attribute>
</xsl:element>
</xsl:if>
</xsl:template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>


Expand Down Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,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

Expand Down
49 changes: 42 additions & 7 deletions src/test/resources/odf1.4/tools/odf2html/export/xhtml/body.xsl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?> <!-- -*- fill-column: 130; nxml-child-indent: 4; tab-width: 4; indent-tabs-mode: nil -*- -->
<!--
* This file is part of the LibreOffice project.
*
Expand Down Expand Up @@ -50,9 +50,11 @@
<xsl:key name="writingModeStyles" match="/*/office:styles/style:style/style:paragraph-properties/@style:writing-mode | /*/office:automatic-styles/style:style/style:paragraph-properties/@style:writing-mode" use="'test'"/>
<xsl:template name="create-body">
<xsl:param name="globalData"/>
<xsl:text>&#xa;</xsl:text>
<xsl:call-template name="create-body.collect-page-properties">
<xsl:with-param name="globalData" select="$globalData"/>
</xsl:call-template>
<xsl:text>&#xa;</xsl:text>
</xsl:template>

<xsl:template name="create-body.collect-page-properties">
Expand Down Expand Up @@ -178,6 +180,7 @@
</xsl:if>
</xsl:attribute>
</xsl:if>
<xsl:text>&#xa;</xsl:text>
<!-- processing the content of the OpenDocument content file -->
<xsl:apply-templates select="/*/office:body/*">
<xsl:with-param name="globalData" select="$globalData"/>
Expand Down Expand Up @@ -240,6 +243,7 @@
<xsl:with-param name="globalData" select="$globalData"/>
</xsl:apply-templates>
</xsl:element>
<xsl:text>&#xa;</xsl:text>
</xsl:template>


Expand All @@ -251,7 +255,9 @@
<xsl:template match="draw:text-box">
<xsl:param name="globalData"/>

<xsl:text>&#xa;</xsl:text>
<xsl:comment>Next 'div' was a 'draw:text-box'.</xsl:comment>
<xsl:text>&#xa;</xsl:text>
<xsl:element name="div">
<xsl:variable name="dimension">
<xsl:apply-templates select="@fo:min-width"/>
Expand Down Expand Up @@ -375,10 +381,14 @@
<!-- The paragraph is written as DIV as there might be nested paragraphs (see above choose block) -->
<xsl:choose>
<xsl:when test="name() = 'text:p'">
<xsl:text>&#xa;</xsl:text>
<xsl:comment>Next 'div' was a 'text:p'.</xsl:comment>
<xsl:text>&#xa;</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>&#xa;</xsl:text>
<xsl:comment>Next 'div' was a 'draw:page'.</xsl:comment>
<xsl:text>&#xa;</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:element name="div">
Expand Down Expand Up @@ -479,10 +489,12 @@
</xsl:if>
</xsl:when>
<xsl:otherwise>
<xsl:text>&#xa;</xsl:text>
<xsl:call-template name="create-paragraph">
<xsl:with-param name="globalData" select="$globalData" />
<xsl:with-param name="footnotePrefix" select="$footnotePrefix" />
</xsl:call-template>
<xsl:text>&#xa;</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
Expand Down Expand Up @@ -554,6 +566,7 @@
<xsl:with-param name="globalData" select="$globalData"/>
</xsl:apply-templates>
</xsl:element>
<xsl:text>&#xa;</xsl:text>
<xsl:apply-templates select="following-sibling::node()[1]" mode="tabHandling">
<xsl:with-param name="globalData" select="$globalData"/>
<xsl:with-param name="tabStops" select="$tabStops"/>
Expand All @@ -565,13 +578,15 @@
<xsl:when test="name() = 'text:line-break'">
<!-- A line-break resets the tabCount to '0' -->
<br/>
<xsl:text>&#xa;</xsl:text>
<xsl:apply-templates select="following-sibling::node()[1]" mode="tabHandling">
<xsl:with-param name="globalData" select="$globalData"/>
<xsl:with-param name="tabStops" select="$tabStops"/>
<xsl:with-param name="tabCount" select="0"/>
<xsl:with-param name="parentMarginLeft" select="$parentMarginLeft"/>
<xsl:with-param name="pageMarginLeft" select="$pageMarginLeft"/>
</xsl:apply-templates>
<xsl:text>&#xa;</xsl:text>
</xsl:when>
<xsl:otherwise>
<!-- only before the first tab all content is written out -->
Expand All @@ -587,6 +602,7 @@
<xsl:with-param name="parentMarginLeft" select="$parentMarginLeft"/>
<xsl:with-param name="pageMarginLeft" select="$pageMarginLeft"/>
</xsl:apply-templates>
<xsl:text>&#xa;</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
Expand Down Expand Up @@ -805,6 +821,7 @@
<xsl:param name="leftPosition" select="0" />
<xsl:param name="parentMarginLeft" />
<xsl:param name="stopAtFirstFrame" select="false()" />
<xsl:param name="tdf146264hack" select="false()" />

<xsl:choose>
<xsl:when test="name() = 'draw:frame' and not($stopAtFirstFrame)">
Expand All @@ -825,16 +842,23 @@
<!-- every following frame sibling till the next draw:frame
have to be encapsulated within a div with left indent.
To be moved altogether according the indent (usually right) -->
<xsl:text>&#xa;</xsl:text>
<xsl:comment>Next 'div' added for floating.</xsl:comment>
<xsl:text>&#xa;</xsl:text>
<xsl:element name="div">
<xsl:attribute name="style">
<xsl:text>display:inline; position:relative; left:</xsl:text>
<xsl:value-of select="$leftPosition"/>
<xsl:text>cm;</xsl:text>
</xsl:attribute>
<xsl:apply-templates select=".">
<xsl:with-param name="globalData" select="$globalData"/>
</xsl:apply-templates>
<!-- This xsl:if is the meat of the extremely ugly "fix" to tdf#146264. It probably has unintended
bad side-effects.
-->
<xsl:if test="not($tdf146264hack)">
<xsl:apply-templates select=".">
<xsl:with-param name="globalData" select="$globalData"/>
</xsl:apply-templates>
</xsl:if>
<!-- if it is a frame sibling it will be NOT encapsulated within the div (as already within one) -->
<xsl:if test="not($nextSiblingIsFrame)">
<xsl:apply-templates select="following-sibling::node()[1]" mode="frameFloating">
Expand Down Expand Up @@ -905,11 +929,13 @@
<xsl:param name="globalData"/>
<xsl:param name="previousFrameWidths" select="0"/>
<xsl:param name="previousFrameHeights" select="0" />
<xsl:param name="tdf146264hack" select="false()" />

<xsl:call-template name="createDrawFrame">
<xsl:with-param name="globalData" select="$globalData" />
<xsl:with-param name="previousFrameWidths" select="$previousFrameWidths"/>
<xsl:with-param name="previousFrameHeights" select="$previousFrameHeights"/>
<xsl:with-param name="tdf146264hack" select="$tdf146264hack"/>
</xsl:call-template>
<!-- after the last draw:frame sibling the CSS float is disabled -->
<xsl:if test="@text:anchor-type!='as-char'">
Expand Down Expand Up @@ -953,6 +979,7 @@
<xsl:param name="previousFrameHeights" select="0" />
<xsl:param name="parentMarginLeft"/>
<xsl:param name="stopAtFirstFrame" select="false()" />
<xsl:param name="tdf146264hack" select="false()" />

<xsl:variable name="parentMarginLeftNew">
<xsl:choose>
Expand Down Expand Up @@ -1008,7 +1035,9 @@
</xsl:variable>
<!-- if the frame is anchored on a paragraph -->
<xsl:if test="@text:anchor-type='paragraph'">
<xsl:text>&#xa;</xsl:text>
<xsl:comment>Next 'div' is emulating the top height of a draw:frame.</xsl:comment>
<xsl:text>&#xa;</xsl:text>
<!-- When the svg:y is set relative to the paragraph content, the best way to emulate a positive height,
is to add an invisible division inbetween with a height.
Often text will flow into this 'gap', which is handled separately!
Expand Down Expand Up @@ -1037,6 +1066,7 @@
<xsl:with-param name="parentMarginLeft" select="$parentMarginLeftNew"/>
<xsl:with-param name="leftPosition" select="$leftPosition"/>
<xsl:with-param name="stopAtFirstFrame" select="$stopAtFirstFrame" />
<xsl:with-param name="tdf146264hack" select="$tdf146264hack" />
</xsl:apply-templates>
</xsl:template>

Expand All @@ -1053,9 +1083,9 @@
<xsl:otherwise>div</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:comment>Next '
<xsl:value-of select="$elem-name"/>' is a draw:frame.
</xsl:comment>
<xsl:text>&#xa;</xsl:text>
<xsl:comment>Next '<xsl:value-of select="$elem-name"/>' is a draw:frame. </xsl:comment>
<xsl:text>&#xa;</xsl:text>
<xsl:element name="{$elem-name}">
<xsl:choose>
<xsl:when test="draw:object/math:math">
Expand Down Expand Up @@ -1190,6 +1220,7 @@
</xsl:apply-templates>
</xsl:element>

<xsl:text>&#xa;</xsl:text>
</xsl:template>

<xsl:template name="create-heading-anchor">
Expand Down Expand Up @@ -2558,6 +2589,7 @@
<xsl:apply-templates>
<xsl:with-param name="globalData" select="$globalData"/>
<xsl:with-param name="listIndent" select="$minLabelWidth"/>
<xsl:with-param name="tdf146264hack" select="true()"/>
</xsl:apply-templates>
<!-- this span disables the float necessary to bring two block elements on one line. It contains a space as IE6 bug workaround -->
<span class="odfLiEnd"></span>
Expand Down Expand Up @@ -2778,12 +2810,15 @@
<xsl:param name="globalData"/>

<xsl:if test="not(contains(@text:display, 'none'))">
<xsl:text>&#xa;</xsl:text>
<xsl:comment>Next 'div' was a 'text:section'.</xsl:comment>
<xsl:text>&#xa;</xsl:text>
<xsl:element name="div">
<xsl:call-template name="apply-styles-and-content">
<xsl:with-param name="globalData" select="$globalData"/>
</xsl:call-template>
</xsl:element>
<xsl:text>&#xa;</xsl:text>
</xsl:if>
</xsl:template>

Expand Down