[Libreoffice-commits] core.git: swext/mediawiki

Robert Antoni Buj Gelonch robert.buj at gmail.com
Mon Apr 27 06:26:14 PDT 2015


 swext/mediawiki/src/filter/odt2mediawiki.xsl |  169 ++++++++++++++++++++-------
 1 file changed, 126 insertions(+), 43 deletions(-)

New commits:
commit c4a8c792c7246939be04cff9a57dcc35f6418566
Author: Robert Antoni Buj Gelonch <robert.buj at gmail.com>
Date:   Mon Apr 27 00:21:38 2015 +0200

    odt2mediawiki.xsl: vertical & horizontal align of a image
    
    Change-Id: I45cdffe132a796ccf06023f4465a2633df1926f3
    Reviewed-on: https://gerrit.libreoffice.org/15544
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Adolfo Jayme Barrientos <fitojb at ubuntu.com>

diff --git a/swext/mediawiki/src/filter/odt2mediawiki.xsl b/swext/mediawiki/src/filter/odt2mediawiki.xsl
index dab745b..b0bc0500 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"/>


More information about the Libreoffice-commits mailing list