lib/isodoc/itu/itu.implementers-guide.xsl in metanorma-itu-2.4.6 vs lib/isodoc/itu/itu.implementers-guide.xsl in metanorma-itu-2.4.7

- old
+ new

@@ -9029,23 +9029,60 @@ <xsl:call-template name="termsource"/> </xsl:template> <xsl:template match="*[local-name() = 'image']"> + <xsl:param name="indent">0</xsl:param> <xsl:variable name="isAdded" select="../@added"/> <xsl:variable name="isDeleted" select="../@deleted"/> <xsl:choose> - <xsl:when test="ancestor::*[local-name() = 'title'] or not(parent::*[local-name() = 'figure']) or parent::*[local-name() = 'p']"> + <xsl:when test="ancestor::*[local-name() = 'title'] or not(parent::*[local-name() = 'figure']) or parent::*[local-name() = 'p']"> <!-- inline image ( 'image:path' in adoc, with one colon after image) --> <fo:inline padding-left="1mm" padding-right="1mm"> <xsl:if test="not(parent::*[local-name() = 'figure']) or parent::*[local-name() = 'p']"> <xsl:attribute name="padding-left">0mm</xsl:attribute> <xsl:attribute name="padding-right">0mm</xsl:attribute> </xsl:if> <xsl:variable name="src"> <xsl:call-template name="image_src"/> </xsl:variable> - <fo:external-graphic src="{$src}" fox:alt-text="Image {@alt}" vertical-align="middle"/> + + <xsl:variable name="scale"> + <xsl:call-template name="getImageScale"> + <xsl:with-param name="indent" select="$indent"/> + </xsl:call-template> + </xsl:variable> + + <!-- debug scale='<xsl:value-of select="$scale"/>', indent='<xsl:value-of select="$indent"/>' --> + + <!-- <fo:external-graphic src="{$src}" fox:alt-text="Image {@alt}" vertical-align="middle"/> --> + <fo:external-graphic src="{$src}" fox:alt-text="Image {@alt}" vertical-align="middle"> + + <xsl:variable name="width"> + <xsl:call-template name="setImageWidth"/> + </xsl:variable> + <xsl:if test="$width != ''"> + <xsl:attribute name="width"><xsl:value-of select="$width"/></xsl:attribute> + </xsl:if> + <xsl:variable name="height"> + <xsl:call-template name="setImageHeight"/> + </xsl:variable> + <xsl:if test="$height != ''"> + <xsl:attribute name="height"><xsl:value-of select="$height"/></xsl:attribute> + </xsl:if> + + <xsl:if test="$width = '' and $height = ''"> + <xsl:if test="number($scale) &lt; 100"> + <xsl:attribute name="content-width"><xsl:value-of select="number($scale)"/>%</xsl:attribute> + <!-- <xsl:attribute name="content-width">scale-to-fit</xsl:attribute> + <xsl:attribute name="content-height">100%</xsl:attribute> + <xsl:attribute name="width">100%</xsl:attribute> + <xsl:attribute name="scaling">uniform</xsl:attribute> --> + </xsl:if> + </xsl:if> + + </fo:external-graphic> + </fo:inline> </xsl:when> <xsl:otherwise> <fo:block xsl:use-attribute-sets="image-style"> @@ -9062,54 +9099,46 @@ <xsl:attribute name="width">100%</xsl:attribute> <xsl:attribute name="content-height">100%</xsl:attribute> <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute> <xsl:attribute name="scaling">uniform</xsl:attribute> - <xsl:apply-templates select="." mode="cross_image"/> + <xsl:apply-templates select="." mode="cross_image"/> </fo:instream-foreign-object> </xsl:when> <xsl:otherwise> + <!-- <fo:block>debug block image: + <xsl:variable name="scale"> + <xsl:call-template name="getImageScale"> + <xsl:with-param name="indent" select="$indent"/> + </xsl:call-template> + </xsl:variable> + <xsl:value-of select="concat('scale=', $scale,', indent=', $indent)"/> + </fo:block> --> <fo:external-graphic src="{$src}" fox:alt-text="Image {@alt}" xsl:use-attribute-sets="image-graphic-style"> <xsl:if test="not(@mimetype = 'image/svg+xml') and (../*[local-name() = 'name'] or parent::*[local-name() = 'figure'][@unnumbered = 'true']) and not(ancestor::*[local-name() = 'table'])"> - <xsl:if test="@width != '' and @width != 'auto' and @width != 'text-width' and @width != 'full-page-width' and @width != 'narrow'"> - <xsl:attribute name="width"> - <xsl:value-of select="@width"/> - </xsl:attribute> - </xsl:if> + <xsl:call-template name="setImageWidthHeight"/> - <xsl:if test="@height != '' and @height != 'auto'"> - <xsl:attribute name="height"> - <xsl:value-of select="@height"/> - </xsl:attribute> - </xsl:if> - <xsl:choose> <xsl:when test="@width != '' and @width != 'auto' and @height != '' and @height != 'auto'"> <xsl:attribute name="scaling">non-uniform</xsl:attribute> </xsl:when> <xsl:otherwise> - <xsl:variable name="img_src"> - <xsl:choose> - <xsl:when test="not(starts-with(@src, 'data:'))"><xsl:value-of select="concat($basepath, @src)"/></xsl:when> - <xsl:otherwise><xsl:value-of select="@src"/></xsl:otherwise> - </xsl:choose> + <xsl:variable name="scale"> + <xsl:call-template name="getImageScale"> + <xsl:with-param name="indent" select="$indent"/> + </xsl:call-template> </xsl:variable> - <xsl:variable name="image_width_effective"> - - <xsl:value-of select="$width_effective"/> - + <xsl:variable name="scaleRatio"> + 1 </xsl:variable> - <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $image_width_effective, $height_effective)"/> <xsl:if test="number($scale) &lt; 100"> - - <xsl:attribute name="content-width"><xsl:value-of select="$scale"/>%</xsl:attribute> - + <xsl:attribute name="content-width"><xsl:value-of select="number($scale) * number($scaleRatio)"/>%</xsl:attribute> </xsl:if> </xsl:otherwise> </xsl:choose> </xsl:if> @@ -9121,10 +9150,66 @@ </fo:block> </xsl:otherwise> </xsl:choose> </xsl:template> + <xsl:template name="setImageWidth"> + <xsl:if test="@width != '' and @width != 'auto' and @width != 'text-width' and @width != 'full-page-width' and @width != 'narrow'"> + <xsl:value-of select="@width"/> + </xsl:if> + </xsl:template> + <xsl:template name="setImageHeight"> + <xsl:if test="@height != '' and @height != 'auto'"> + <xsl:value-of select="@height"/> + </xsl:if> + </xsl:template> + <xsl:template name="setImageWidthHeight"> + <xsl:variable name="width"> + <xsl:call-template name="setImageWidth"/> + </xsl:variable> + <xsl:if test="$width != ''"> + <xsl:attribute name="width"> + <xsl:value-of select="$width"/> + </xsl:attribute> + </xsl:if> + <xsl:variable name="height"> + <xsl:call-template name="setImageHeight"/> + </xsl:variable> + <xsl:if test="$height != ''"> + <xsl:attribute name="height"> + <xsl:value-of select="$height"/> + </xsl:attribute> + </xsl:if> + </xsl:template> + + <xsl:template name="getImageScale"> + <xsl:param name="indent"/> + <xsl:variable name="indent_left"> + <xsl:choose> + <xsl:when test="$indent != ''"><xsl:value-of select="$indent"/></xsl:when> + <xsl:otherwise>0</xsl:otherwise> + </xsl:choose> + </xsl:variable> + <xsl:variable name="img_src"> + <xsl:choose> + <xsl:when test="not(starts-with(@src, 'data:'))"><xsl:value-of select="concat($basepath, @src)"/></xsl:when> + <xsl:otherwise><xsl:value-of select="@src"/></xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:variable name="image_width_effective"> + + <xsl:value-of select="$width_effective - number($indent_left)"/> + + </xsl:variable> + <!-- <xsl:message>width_effective=<xsl:value-of select="$width_effective"/></xsl:message> + <xsl:message>indent_left=<xsl:value-of select="$indent_left"/></xsl:message> + <xsl:message>image_width_effective=<xsl:value-of select="$image_width_effective"/> for <xsl:value-of select="ancestor::ogc:p[1]/@id"/></xsl:message> --> + <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $image_width_effective, $height_effective)"/> + <xsl:value-of select="$scale"/> + </xsl:template> + <xsl:template name="image_src"> <xsl:choose> <xsl:when test="@mimetype = 'image/svg+xml' and $images/images/image[@id = current()/@id]"> <xsl:value-of select="$images/images/image[@id = current()/@id]/@src"/> </xsl:when> @@ -11806,10 +11891,11 @@ </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template match="*[local-name() = 'ul'] | *[local-name() = 'ol']"> + <xsl:param name="indent">0</xsl:param> <xsl:choose> <xsl:when test="parent::*[local-name() = 'note'] or parent::*[local-name() = 'termnote']"> <fo:block-container role="SKIP"> <xsl:attribute name="margin-left"> <xsl:choose> @@ -11820,19 +11906,23 @@ <xsl:call-template name="refine_list_container_style"/> <fo:block-container margin-left="0mm" role="SKIP"> <fo:block> - <xsl:apply-templates select="." mode="list"/> + <xsl:apply-templates select="." mode="list"> + <xsl:with-param name="indent" select="$indent"/> + </xsl:apply-templates> </fo:block> </fo:block-container> </fo:block-container> </xsl:when> <xsl:otherwise> <fo:block role="SKIP"> - <xsl:apply-templates select="." mode="list"/> + <xsl:apply-templates select="." mode="list"> + <xsl:with-param name="indent" select="$indent"/> + </xsl:apply-templates> </fo:block> </xsl:otherwise> </xsl:choose> </xsl:template> @@ -11913,10 +12003,17 @@ </fo:block> </xsl:if> </xsl:template> <xsl:template match="*[local-name()='li']"> + <xsl:param name="indent">0</xsl:param> + <!-- <fo:list-item xsl:use-attribute-sets="list-item-style"> + <fo:list-item-label end-indent="label-end()"><fo:block>x</fo:block></fo:list-item-label> + <fo:list-item-body start-indent="body-start()" xsl:use-attribute-sets="list-item-body-style"> + <fo:block>debug li indent=<xsl:value-of select="$indent"/></fo:block> + </fo:list-item-body> + </fo:list-item> --> <fo:list-item xsl:use-attribute-sets="list-item-style"> <xsl:copy-of select="@id"/> <xsl:call-template name="refine_list-item-style"/> @@ -11937,10 +12034,12 @@ <fo:list-item-body start-indent="body-start()" xsl:use-attribute-sets="list-item-body-style"> <fo:block role="SKIP"> <xsl:call-template name="refine_list-item-body-style"/> - <xsl:apply-templates/> + <xsl:apply-templates> + <xsl:with-param name="indent" select="$indent"/> + </xsl:apply-templates> <!-- <xsl:apply-templates select="node()[not(local-name() = 'note')]" /> <xsl:for-each select="./bsi:note"> <xsl:call-template name="note"/> \ No newline at end of file