summaryrefslogtreecommitdiff
path: root/swext
diff options
context:
space:
mode:
authorRobert Antoni Buj Gelonch <robert.buj@gmail.com>2015-04-27 00:21:38 +0200
committerAdolfo Jayme Barrientos <fitojb@ubuntu.com>2015-04-27 13:25:54 +0000
commitc4a8c792c7246939be04cff9a57dcc35f6418566 (patch)
tree1852b3277b34d90bfd93bf87fbfcf2f6cccb1955 /swext
parent4f351515bc4efb72343941f9d97d43572788512a (diff)
odt2mediawiki.xsl: vertical & horizontal align of a image
Change-Id: I45cdffe132a796ccf06023f4465a2633df1926f3 Reviewed-on: https://gerrit.libreoffice.org/15544 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com>
Diffstat (limited to 'swext')
-rw-r--r--swext/mediawiki/src/filter/odt2mediawiki.xsl169
1 files changed, 126 insertions, 43 deletions
diff --git a/swext/mediawiki/src/filter/odt2mediawiki.xsl b/swext/mediawiki/src/filter/odt2mediawiki.xsl
index dab745b22a88..b0bc0500eb0e 100644
--- a/swext/mediawiki/src/filter/odt2mediawiki.xsl
+++ b/swext/mediawiki/src/filter/odt2mediawiki.xsl
@@ -977,53 +977,38 @@
<apply-templates/>
</variable>
- <text>[[</text>
- <call-template name="mk-image-name">
- <with-param name="image" select="$image"/>
+ <variable name="picture">
+ <text>[[</text>
+ <call-template name="mk-image-name">
+ <with-param name="image" select="$image"/>
+ </call-template>
+ <text>|thumb</text>
+ </variable>
+
+ <!-- Picture markup + Horizontal & Vertical align -->
+ <call-template name="mk-image-align">
+ <with-param name="picture" select="$picture"/>
</call-template>
- <text>|thumb|</text>
- <!-- Image alt -->
- <if test="name(following-sibling::*)='svg:title'">
- <text>alt="</text>
- <value-of select="following-sibling::*/text()"/>
- <text>"|</text>
- </if>
+
+ <!-- Image caption -->
+ <text>|</text>
<value-of select="normalize-space($image-description)"/>
- <text>]]</text>
+
+ <text>]]</text>
</template>
<template match="draw:image[not(boolean(ancestor::draw:text-box))]">
- <text>[[</text>
- <call-template name="mk-image-name">
- <with-param name="image" select="."/>
- </call-template>
+ <variable name="picture">
+ <text>[[</text>
+ <call-template name="mk-image-name">
+ <with-param name="image" select="."/>
+ </call-template>
+ </variable>
- <!-- Horizontal align -->
- <if test="name(..)='draw:frame' and boolean(../@draw:style-name)">
- <variable name="style-element" select="key('style-ref', ../@draw:style-name)"/>
- <if test="boolean($style-element/style:graphic-properties/@style:wrap)">
- <choose>
- <!-- No wrap -->
- <when test="$style-element/style:graphic-properties/@style:wrap='none'">
- <choose>
- <when test="boolean($style-element/style:graphic-properties/@style:horizontal-pos)">
- <choose>
- <when test="$style-element/style:graphic-properties/@style:horizontal-pos='center'">
- <text>|center</text>
- </when>
- <otherwise>
- <text>|none</text>
- </otherwise>
- </choose>
- </when>
- <otherwise>
- <text>|none</text>
- </otherwise>
- </choose>
- </when>
- </choose>
- </if>
- </if>
+ <!-- Picture markup + Horizontal & Vertical align -->
+ <call-template name="mk-image-align">
+ <with-param name="picture" select="$picture"/>
+ </call-template>
<!-- Image alt -->
<if test="name(following-sibling::*)='svg:title'">
@@ -1031,8 +1016,106 @@
<value-of select="following-sibling::*/text()"/>
<text>"</text>
</if>
- <text>]]</text>
- </template>
+
+ <text>]]</text>
+ </template>
+
+ <template name="mk-image-align">
+ <param name="picture"/>
+
+ <choose>
+ <when test="name(..)='draw:frame' and boolean(../@draw:style-name)">
+ <variable name="style-element" select="key('style-ref', ../@draw:style-name)"/>
+ <choose>
+ <when test="boolean($style-element/style:graphic-properties/@style:wrap)">
+ <choose>
+ <!-- wrap=none -->
+ <when test="$style-element/style:graphic-properties/@style:wrap='none'">
+ <text>{{clear}}</text>
+ <value-of select="$NL"/>
+ <value-of select="$picture"/>
+ <choose>
+ <when test="boolean($style-element/style:graphic-properties/@style:horizontal-pos)">
+ <choose>
+ <when test="$style-element/style:graphic-properties/@style:horizontal-pos='center'">
+ <text>|center</text>
+ </when>
+ <otherwise>
+ <text>|none</text>
+ </otherwise>
+ </choose>
+ </when>
+ <otherwise>
+ <text>|none</text>
+ </otherwise>
+ </choose>
+ </when>
+ <!-- wrap != none -->
+ <otherwise>
+ <value-of select="$picture"/>
+ <!-- Horizontal align -->
+ <call-template name="mk-image-horizontal-align">
+ <with-param name="style-element" select="$style-element"/>
+ </call-template>
+ <!-- Vertical align -->
+ <call-template name="mk-image-vertical-align">
+ <with-param name="style-element" select="$style-element"/>
+ </call-template>
+ </otherwise>
+ </choose>
+ </when>
+ <!-- without wrap -->
+ <otherwise>
+ <value-of select="$picture"/>
+ <!-- Horizontal align -->
+ <call-template name="mk-image-horizontal-align">
+ <with-param name="style-element" select="$style-element"/>
+ </call-template>
+ <!-- Vertical align -->
+ <call-template name="mk-image-vertical-align">
+ <with-param name="style-element" select="$style-element"/>
+ </call-template>
+ </otherwise>
+ </choose>
+ </when>
+ <otherwise>
+ <value-of select="$picture"/>
+ </otherwise>
+ </choose>
+ </template>
+
+ <template name="mk-image-horizontal-align">
+ <param name="style-element"/>
+
+ <if test="boolean($style-element/style:graphic-properties/@style:horizontal-pos)">
+ <choose>
+ <when test="$style-element/style:graphic-properties/@style:horizontal-pos='right'">
+ <text>|right</text>
+ </when>
+ <when test="$style-element/style:graphic-properties/@style:horizontal-pos='left'">
+ <text>|left</text>
+ </when>
+ </choose>
+ </if>
+ </template>
+
+ <template name="mk-image-vertical-align">
+ <param name="style-element"/>
+
+ <if test="boolean($style-element/style:graphic-properties/@style:vertical-pos)">
+ <choose>
+ <when test="$style-element/style:graphic-properties/@style:vertical-pos='top'">
+ <text>|top</text>
+ </when>
+ <when test="$style-element/style:graphic-properties/@style:vertical-pos='middle'">
+ <text>|middle</text>
+ </when>
+ <when test="$style-element/style:graphic-properties/@style:vertical-pos='below'">
+ <text>|below</text>
+ </when>
+ </choose>
+ </if>
+ </template>
<template name="mk-image-name">
<param name="image"/>