Skip to content

Commit

Permalink
Added new parameter, tableWidthsProportional, which produces proporti…
Browse files Browse the repository at this point in the history
…onal table widths
  • Loading branch information
contrext committed Jun 6, 2016
1 parent fa6b8a9 commit 35b027f
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 12 deletions.
11 changes: 9 additions & 2 deletions xsl/docx2dita.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,13 @@ version="2.0">
<xsl:param name="topicExtension" select="'.dita'" as="xs:string"/><!-- Extension for generated topic files -->
<xsl:param name="fileNamePrefix" select="''" as="xs:string"/><!-- Prefix for genenerated file names -->
<xsl:param name="chartsAsTables" select="'false'" as="xs:string"/><!-- When true, capture Word charts as tables with the chart data -->
<xsl:variable name="chartsAsTablesBoolean" as="xs:boolean" select="$chartsAsTables = 'true'"/>
<xsl:variable name="chartsAsTablesBoolean" as="xs:boolean"
select="matches($chartsAsTables, 'true|yes|on|1', 'i')"/>

<xsl:param name="tableWidthsProportional" as="xs:string" select="'false'"/>
<xsl:variable name="tableWidthsProportionalBoolean" as="xs:boolean"
select="matches($tableWidthsProportional, 'true|yes|on|1', 'i')"
/>

<xsl:param name="rawPlatformString" select="'unknown'" as="xs:string"/>

Expand Down Expand Up @@ -381,7 +387,8 @@ version="2.0">
+ debug = "<xsl:sequence select="$debug"/>"
+ includeWordBackPointers= "<xsl:sequence select="$includeWordBackPointersBoolean"/>"
+ chartsAsTables = "<xsl:sequence select="$chartsAsTablesBoolean"/>"
+ saveIntermediateDocs = "<xsl:sequence select="$saveIntermediateDocs"/>"
+ saveIntermediateDocs = "<xsl:sequence select="$saveIntermediateDocs"/>"
+ tableWidthsProportional = "<xsl:sequence select="$tableWidthsProportional"/>" (<xsl:value-of select="$tableWidthsProportionalBoolean"/>)

Global Variables:

Expand Down
36 changes: 26 additions & 10 deletions xsl/simple2dita.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -746,10 +746,10 @@
<xsl:sequence select="@outputclass"/>
<xsl:choose>
<xsl:when test="number($width) &lt; 100">
<xsl:attribute name="pgwide">0</xsl:attribute>
<xsl:attribute name="pgwide" select="'0'"/>
</xsl:when>
<xsl:when test="string-length($width)">
<xsl:attribute name="pgwide">1</xsl:attribute>
<xsl:attribute name="pgwide" select="'1'"/>
</xsl:when>
</xsl:choose>
<xsl:if test="@langAttValue != ''">
Expand Down Expand Up @@ -902,14 +902,30 @@

<xsl:template name="create-colspec">
<xsl:param name="doDebug" as="xs:boolean" tunnel="yes" select="false()"/>
<xsl:for-each select="rsiwp:cols/rsiwp:col">
<colspec>
<xsl:attribute name="colname" select="local:constructColumnName(.)"/>
<xsl:sequence select="@align"/>
<xsl:sequence select="@colwidth"/>
</colspec>
</xsl:for-each>
</xsl:template>
<xsl:variable name="rawColwidths" as="xs:double*"
select="for $a in rsiwp:cols/rsiwp:col/@colwidth
return xs:double(substring-before($a, 'pt'))"
/>
<xsl:variable name="smallest" as="xs:double"
select="min($rawColwidths)"

/>

<xsl:for-each select="rsiwp:cols/rsiwp:col">
<!-- The @colwidth value is always points -->
<xsl:variable name="pos" as="xs:integer" select="position()"/>
<xsl:variable name="colwidth" as="xs:string"
select="if ($tableWidthsProportionalBoolean)
then concat(format-number(($rawColwidths[$pos] div $smallest), '#####.#'), '*')
else concat($rawColwidths[$pos], 'pt')"
/>
<colspec>
<xsl:attribute name="colname" select="local:constructColumnName(.)"/>
<xsl:sequence select="@align"/>
<xsl:attribute name="colwidth" select="$colwidth"/>
</colspec>
</xsl:for-each>
</xsl:template>


<!-- Determine which column the current entry sits in. Count the current entry,
Expand Down

0 comments on commit 35b027f

Please sign in to comment.