Skip to content

Commit

Permalink
Fixed problem with percentage widths on table columns
Browse files Browse the repository at this point in the history
  • Loading branch information
philipru committed Sep 28, 2020
1 parent 22971bd commit e1c2210
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 36 deletions.
2 changes: 1 addition & 1 deletion pso-pdf-ant/test/export/expected/fo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@
<fo:block font-weight="bold" font-size="14pt" space-before.optimum="12pt" space-after.optimum="4pt" color="#1f4f76" keep-with-next="always">Horizontal and vertical header (no caption)</fo:block>
<fo:block space-before.optimum="12pt" space-after.optimum="12pt"><fo:table border-collapse="collapse" table-layout="fixed" inline-progression-dimension.optimum="100%"><fo:table-column column-width="proportional-column-width(1)"/><fo:table-column column-width="proportional-column-width(1)"/><fo:table-column column-width="proportional-column-width(1)"/><fo:table-column column-width="proportional-column-width(1)"/><fo:table-header><fo:table-row><fo:table-cell space-before.optimum="5pt" space-after.optimum="5pt" background-color="#1f4f76"><fo:block margin-left="0.08cm" space-before="0.08cm" margin-right="0.08cm" font-weight="bold" color="white" font-size="10pt" hyphenate="false" language="en" hyphenation-remain-character-count="5">Header</fo:block></fo:table-cell><fo:table-cell space-before.optimum="5pt" space-after.optimum="5pt" background-color="#1f4f76"><fo:block margin-left="0.08cm" space-before="0.08cm" margin-right="0.08cm" font-weight="bold" color="white" font-size="10pt" hyphenate="false" language="en" hyphenation-remain-character-count="5">Horizontal1</fo:block></fo:table-cell><fo:table-cell space-before.optimum="5pt" space-after.optimum="5pt" background-color="#1f4f76"><fo:block margin-left="0.08cm" space-before="0.08cm" margin-right="0.08cm" font-weight="bold" color="white" font-size="10pt" hyphenate="false" language="en" hyphenation-remain-character-count="5">Horizontal3</fo:block></fo:table-cell><fo:table-cell space-before.optimum="5pt" space-after.optimum="5pt" background-color="#1f4f76"><fo:block margin-left="0.08cm" space-before="0.08cm" margin-right="0.08cm" font-weight="bold" color="white" font-size="10pt" hyphenate="false" language="en" hyphenation-remain-character-count="5">Horizontal3</fo:block></fo:table-cell></fo:table-row></fo:table-header><fo:table-body><fo:table-row><fo:table-cell space-before.optimum="5pt" space-after.optimum="5pt" background-color="#1f4f76"><fo:block margin-left="0.08cm" space-before="0.08cm" margin-right="0.08cm" font-weight="bold" color="white" font-size="10pt" hyphenate="false" language="en" hyphenation-remain-character-count="5">vertical</fo:block></fo:table-cell><fo:table-cell space-before.optimum="5pt" space-after.optimum="5pt" background-color="#e7f1ff"><fo:block margin-left="0.08cm" space-before="0.08cm" margin-right="0.08cm" font-weight="normal" color="#1f4f76" font-size="10pt" hyphenate="false" language="en" hyphenation-remain-character-count="5">Cell4</fo:block></fo:table-cell><fo:table-cell space-before.optimum="5pt" space-after.optimum="5pt" background-color="#e7f1ff"><fo:block margin-left="0.08cm" space-before="0.08cm" margin-right="0.08cm" font-weight="normal" color="#1f4f76" font-size="10pt" hyphenate="false" language="en" hyphenation-remain-character-count="5">Cell5</fo:block></fo:table-cell><fo:table-cell space-before.optimum="5pt" space-after.optimum="5pt" background-color="#e7f1ff"><fo:block margin-left="0.08cm" space-before="0.08cm" margin-right="0.08cm" font-weight="normal" color="#1f4f76" font-size="10pt" hyphenate="false" language="en" hyphenation-remain-character-count="5">Cell6</fo:block></fo:table-cell></fo:table-row></fo:table-body></fo:table></fo:block>
<fo:block font-weight="bold" font-size="14pt" space-before.optimum="12pt" space-after.optimum="4pt" color="#1f4f76" keep-with-next="always">Complex table 1</fo:block>
<fo:block space-before.optimum="12pt" space-after.optimum="12pt"><fo:table border-collapse="collapse" table-layout="fixed" inline-progression-dimension.optimum="100%" width="100%"><fo:table-column column-width="proportional-column-width(21)"/><fo:table-column column-width="proportional-column-width(38)"/><fo:table-column column-width="proportional-column-width(40)"/><fo:table-header><fo:table-row><fo:table-cell space-before.optimum="5pt" space-after.optimum="5pt" background-color="#1f4f76"><fo:block margin-left="0.08cm" space-before="0.08cm" margin-right="0.08cm" font-weight="bold" color="white" font-size="10pt" hyphenate="false" language="en" hyphenation-remain-character-count="5"><fo:inline font-weight="bold">Medicinal products by therapeutic areas</fo:inline></fo:block></fo:table-cell><fo:table-cell space-before.optimum="5pt" space-after.optimum="5pt" background-color="#1f4f76"><fo:block margin-left="0.08cm" space-before="0.08cm" margin-right="0.08cm" font-weight="bold" color="white" font-size="10pt" hyphenate="false" language="en" hyphenation-remain-character-count="5"><fo:inline font-weight="bold">Interaction</fo:inline></fo:block></fo:table-cell><fo:table-cell space-before.optimum="5pt" space-after.optimum="5pt" background-color="#1f4f76"><fo:block margin-left="0.08cm" space-before="0.08cm" margin-right="0.08cm" font-weight="bold" color="white" font-size="10pt" hyphenate="false" language="en" hyphenation-remain-character-count="5"><fo:inline font-weight="bold">Recommendations concerning</fo:inline> <fo:inline font-weight="bold">co-administration</fo:inline></fo:block></fo:table-cell></fo:table-row><fo:table-row><fo:table-cell space-before.optimum="5pt" space-after.optimum="5pt" background-color="#1f4f76" number-columns-spanned="3"><fo:block margin-left="0.08cm" space-before="0.08cm" margin-right="0.08cm" font-weight="bold" color="white" font-size="10pt" hyphenate="false" language="en" hyphenation-remain-character-count="5"><fo:inline font-weight="bold">ANTI-INFECTIVES</fo:inline></fo:block></fo:table-cell></fo:table-row><fo:table-row><fo:table-cell space-before.optimum="5pt" space-after.optimum="5pt" background-color="#1f4f76" number-columns-spanned="3"><fo:block margin-left="0.08cm" space-before="0.08cm" margin-right="0.08cm" font-weight="bold" color="white" font-size="10pt" hyphenate="false" language="en" hyphenation-remain-character-count="5"><fo:inline font-weight="bold">Antiretrovirals</fo:inline></fo:block></fo:table-cell></fo:table-row></fo:table-header><fo:table-body><fo:table-row><fo:table-cell space-before.optimum="5pt" space-after.optimum="5pt" background-color="#e7f1ff" number-columns-spanned="3"><fo:block margin-left="0.08cm" space-before="0.08cm" margin-right="0.08cm" font-weight="normal" color="#1f4f76" font-size="10pt" hyphenate="false" language="en" hyphenation-remain-character-count="5">
<fo:block space-before.optimum="12pt" space-after.optimum="12pt"><fo:table border-collapse="collapse" table-layout="fixed" inline-progression-dimension.optimum="100%" width="100%"><fo:table-column column-width="20.123%"/><fo:table-column column-width="400px"/><fo:table-column column-width="40%"/><fo:table-header><fo:table-row><fo:table-cell space-before.optimum="5pt" space-after.optimum="5pt" background-color="#1f4f76"><fo:block margin-left="0.08cm" space-before="0.08cm" margin-right="0.08cm" font-weight="bold" color="white" font-size="10pt" hyphenate="false" language="en" hyphenation-remain-character-count="5"><fo:inline font-weight="bold">Medicinal products by therapeutic areas</fo:inline></fo:block></fo:table-cell><fo:table-cell space-before.optimum="5pt" space-after.optimum="5pt" background-color="#1f4f76"><fo:block margin-left="0.08cm" space-before="0.08cm" margin-right="0.08cm" font-weight="bold" color="white" font-size="10pt" hyphenate="false" language="en" hyphenation-remain-character-count="5"><fo:inline font-weight="bold">Interaction</fo:inline></fo:block></fo:table-cell><fo:table-cell space-before.optimum="5pt" space-after.optimum="5pt" background-color="#1f4f76"><fo:block margin-left="0.08cm" space-before="0.08cm" margin-right="0.08cm" font-weight="bold" color="white" font-size="10pt" hyphenate="false" language="en" hyphenation-remain-character-count="5"><fo:inline font-weight="bold">Recommendations concerning</fo:inline> <fo:inline font-weight="bold">co-administration</fo:inline></fo:block></fo:table-cell></fo:table-row><fo:table-row><fo:table-cell space-before.optimum="5pt" space-after.optimum="5pt" background-color="#1f4f76" number-columns-spanned="3"><fo:block margin-left="0.08cm" space-before="0.08cm" margin-right="0.08cm" font-weight="bold" color="white" font-size="10pt" hyphenate="false" language="en" hyphenation-remain-character-count="5"><fo:inline font-weight="bold">ANTI-INFECTIVES</fo:inline></fo:block></fo:table-cell></fo:table-row><fo:table-row><fo:table-cell space-before.optimum="5pt" space-after.optimum="5pt" background-color="#1f4f76" number-columns-spanned="3"><fo:block margin-left="0.08cm" space-before="0.08cm" margin-right="0.08cm" font-weight="bold" color="white" font-size="10pt" hyphenate="false" language="en" hyphenation-remain-character-count="5"><fo:inline font-weight="bold">Antiretrovirals</fo:inline></fo:block></fo:table-cell></fo:table-row></fo:table-header><fo:table-body><fo:table-row><fo:table-cell space-before.optimum="5pt" space-after.optimum="5pt" background-color="#e7f1ff" number-columns-spanned="3"><fo:block margin-left="0.08cm" space-before="0.08cm" margin-right="0.08cm" font-weight="normal" color="#1f4f76" font-size="10pt" hyphenate="false" language="en" hyphenation-remain-character-count="5">
<fo:block space-before.optimum="4pt" space-after.optimum="8pt" text-align="justify" hyphenate="false"><fo:inline font-weight="bold"><fo:inline font-style="italic">Nucleoside reverse transcriptase inhibitors (NRTIs)</fo:inline></fo:inline></fo:block>
</fo:block></fo:table-cell></fo:table-row><fo:table-row><fo:table-cell space-before.optimum="5pt" space-after.optimum="5pt" background-color="#e7f1ff"><fo:block margin-left="0.08cm" space-before="0.08cm" margin-right="0.08cm" font-weight="normal" color="#1f4f76" font-size="10pt" hyphenate="false" language="en" hyphenation-remain-character-count="5">
<fo:block space-before.optimum="4pt" space-after.optimum="8pt" text-align="justify" hyphenate="false">Didanosine
Expand Down
2 changes: 1 addition & 1 deletion pso-pdf-ant/test/export/input/lorem_ipsum.psml
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@
</row>
</table>
<heading level="2">Complex table 1</heading>
<table width="100%"><col width="21%"/><col width="38%"/><col width="40%"/>
<table width="100%"><col width="20.123%"/><col width="400px"/><col width="40%"/>
<row part="header">
<hcell><bold>Medicinal products by therapeutic areas</bold></hcell>
<hcell><bold>Interaction</bold></hcell>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
<!--
This stylesheet defines the rules to turn PS standard XML into FO XML format.
TODO: check bookmark rules at the bottom of this stylesheet.
@author Jean-Baptiste Reure
@author Philip Rutherford
@author Willy Ekasalim
@version 3 May 2012
Copyright (C) 2012 Weborganic Systems Pty. Ltd.
-->
<xsl:stylesheet version="2.0"

<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ps="http://www.pageseeder.com/editing/2.0"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
Expand Down Expand Up @@ -68,7 +68,7 @@
<xsl:sequence select="psf:style-properties-overwrite($crole-props, $col-props)"/>
<xsl:choose>
<!-- % or px, if nothing then default to px -->
<xsl:when test="ends-with(@width, '%')"><xsl:attribute name="column-width" select="concat('proportional-column-width(',replace(@width, '\D', ''),')')" /></xsl:when>
<xsl:when test="ends-with(@width, '%')"><xsl:attribute name="column-width" select="@width" /></xsl:when>
<xsl:when test="ends-with(@width, 'px')"><xsl:attribute name="column-width" select="@width" /></xsl:when>
<xsl:when test="@width"><xsl:attribute name="column-width" select="concat(replace(@width, '\D', ''), 'px')"/></xsl:when>
<xsl:otherwise><xsl:attribute name="column-width">proportional-column-width(1)</xsl:attribute></xsl:otherwise>
Expand Down Expand Up @@ -136,7 +136,7 @@
</xsl:template>

<xsl:template match="caption" />

<!-- Template for PageSeeder Row element
.. admonition:: xpath:row
Expand All @@ -149,7 +149,7 @@
| </fo:table-cell>
| </fo:table-row>
-->
-->
<xsl:template match="row">
<fo:table-row>
<xsl:variable name="part" select="@part"/>
Expand Down Expand Up @@ -210,7 +210,7 @@
</xsl:for-each>
</fo:table-row>
</xsl:template>

<!-- ============================== fragment ================================== -->
<!-- Template for PageSeeder fragment
Expand Down Expand Up @@ -263,7 +263,7 @@
<xsl:copy-of select="node()" />
</fo:instream-foreign-object>
</xsl:template>

<!-- ============================== properties-fragment ================================== -->
<!-- Template for PageSeeder properties fragment
Expand Down Expand Up @@ -293,7 +293,7 @@
</fo:table>
</fo:block>
</xsl:template>

<!-- ============================== property ================================== -->
<!-- Template for PageSeeder property
Expand Down Expand Up @@ -347,7 +347,7 @@
| </fo:block>
| </fo:block>
-->
-->
<xsl:template match="toc">
<xsl:variable name="toc" select="." />
<!-- only first TOC is displayed -->
Expand Down Expand Up @@ -388,7 +388,7 @@
<xsl:value-of select="$level" />
</xsl:otherwise></xsl:choose>
</xsl:template>

<xsl:template name="indent">
<xsl:param name="title" />
<xsl:if test="contains($title, '.')">
Expand Down Expand Up @@ -651,14 +651,14 @@
-->
<xsl:template match="inline">
<xsl:variable name="name" select="concat('-', @label)"/>
<xsl:variable name="show" select="not(psf:load-style-properties(., 'inline')[@name = 'ps-hide']/@value = 'true') and
<xsl:variable name="show" select="not(psf:load-style-properties(., 'inline')[@name = 'ps-hide']/@value = 'true') and
not(psf:load-style-properties(., concat('inline',$name))[@name = 'ps-hide']/@value = 'true')"/>
<xsl:if test="$show">
<fo:inline>
<xsl:variable name="cust-props" select="psf:load-style-properties(., concat('inline', $name))" />
<xsl:variable name="def-props" select="psf:load-style-properties(., 'inline')" />
<xsl:sequence select="psf:style-properties-overwrite($cust-props, $def-props)"/>
<xsl:variable name="showName" select="not(psf:load-style-properties(., 'inlineName')[@name = 'ps-hide']/@value = 'true') and
<xsl:variable name="showName" select="not(psf:load-style-properties(., 'inlineName')[@name = 'ps-hide']/@value = 'true') and
not(psf:load-style-properties(., concat('inlineName',$name))[@name = 'ps-hide']/@value = 'true')"/>
<xsl:if test="$showName">
<fo:inline>
Expand All @@ -673,8 +673,8 @@
</xsl:if>
</xsl:template>

<!-- ============================== preformat ================================== -->
<!-- Template for PageSeeder preformat
<!-- ============================== preformat ================================== -->
<!-- Template for PageSeeder preformat
.. admonition:: xpath:preformat
Expand All @@ -693,8 +693,8 @@
</fo:block>
</xsl:template>

<!-- ============================== Code ================================== -->
<!-- Template for PageSeeder monospace
<!-- ============================== Code ================================== -->
<!-- Template for PageSeeder monospace
.. admonition:: xpath:monospace
Expand All @@ -709,7 +709,7 @@
<xsl:apply-templates select="* | text()" />
</fo:inline>
</xsl:template>

<!-- ============================== Subscript ================================== -->

<!-- Template for PageSeeder subscript (sub)
Expand All @@ -720,7 +720,7 @@
| ...
| </fo:inline>
-->
-->
<xsl:template match="sub">
<fo:inline>
<xsl:sequence select="psf:style-properties(., local-name(.))"/>
Expand All @@ -737,7 +737,7 @@
| ...
| </fo:inline>
-->
-->
<xsl:template match="sup">
<fo:inline>
<xsl:sequence select="psf:style-properties(., local-name(.))"/>
Expand All @@ -755,7 +755,7 @@
| <fo:base-link internal-destination=""> ... </fo:base-link>
| </fo:inline>
-->
-->
<xsl:template match="link[@href]">
<fo:inline>
<fo:basic-link>
Expand All @@ -768,7 +768,7 @@
<xsl:when test="starts-with(@href,'#')">
<xsl:attribute name="internal-destination">
<xsl:value-of select="if (string-length(@href) = 1) then concat('psf-', $current-uriid) else concat('psa-', substring-after(@href,'#'))"/>
</xsl:attribute>
</xsl:attribute>
</xsl:when>
<xsl:when test="@href=''">
<xsl:attribute name="internal-destination" select="concat('psf-', $current-uriid)" />
Expand Down Expand Up @@ -898,11 +898,11 @@
.. admonition:: xpath:title
| <fo:block>
| <fo:block>
| ...
| </fo:block>
-->
-->
<xsl:template match="title">
<xsl:if test="../*[not(self::title)]">
<fo:block space-before.optimum="15pt">
Expand All @@ -923,7 +923,7 @@
| ...
| </fo:inline>
-->
-->
<xsl:template match="bold">
<fo:inline>
<xsl:sequence select="psf:style-properties(., local-name(.))"/>
Expand All @@ -940,7 +940,7 @@
| ...
| </fo:inline>
-->
-->
<xsl:template match="italic">
<fo:inline>
<xsl:sequence select="psf:style-properties(., local-name(.))"/>
Expand All @@ -957,7 +957,7 @@
| ...
| </fo:inline>
-->
-->
<xsl:template match="underline">
<fo:inline>
<xsl:sequence select="psf:style-properties(., local-name(.))"/>
Expand Down Expand Up @@ -1017,7 +1017,7 @@
</xsl:otherwise>
</xsl:choose>
</xsl:template>

<!-- Template for PageSeeder xref or blockxref link -->
<xsl:template name="xref-link">
<xsl:choose>
Expand All @@ -1041,7 +1041,7 @@
| &#160;<fo:blocks/>
-->
-->
<xsl:template match="br">
&#160;<fo:block/>
</xsl:template>
Expand All @@ -1055,7 +1055,7 @@
| ...
| </fo:block>
-->
-->
<xsl:template match="image[parent::fragment]">
<fo:block>
<xsl:call-template name="inline-image"/>
Expand All @@ -1068,7 +1068,7 @@

<xsl:template name="inline-image" match="image">
<fo:inline>
<xsl:sequence select="psf:style-properties(., local-name(.))"/>
<xsl:sequence select="psf:style-properties(., local-name(.))"/>
<fo:external-graphic>
<xsl:attribute name="src">
<xsl:text>url(</xsl:text>
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.4.11-SNAPSHOT
0.4.11

0 comments on commit e1c2210

Please sign in to comment.