Hi!

Attached patch removes wrapping of groups with transform attribute,
and applies that transform to inner elements instead. It's very very
useful if you need to access elements from actionscript.

Will this sort of patch (may be not exacly this) be accepted for trunk?

Probably if I care of structure of movie more than positions, somebody
will care more about positions of movieclips (I feel that it can be not the
same as in svg). So may be this behavior can be turned on by some
attribute, e.g.:
<clip id="svgpiece" import="piece.svg" keep-structure="true" />

Any thoughts?
--
Paul
Index: src/xslt/simple-svg.xslt
===================================================================
--- src/xslt/simple-svg.xslt	(revision 240)
+++ src/xslt/simple-svg.xslt	(working copy)
@@ -26,7 +26,8 @@
 
 <!-- named template for redundant placing -->
 <xsl:template name="placeObject">
-	<!-- place the element, or the referenced element (if it's a reference). 
+	<xsl:param name="transform" />
+	<!-- place the element, or the referenced element (if it's a reference).
 -->
 	<xsl:variable name="id">
 		<xsl:choose>
@@ -41,7 +42,7 @@
 			</xsl:otherwise>
 		</xsl:choose>
 	</xsl:variable>
-	<!-- use inkscape label as an instance name instead of id, allowing 
+	<!-- use inkscape label as an instance name instead of id, allowing
 multiple instances with the same name. -->
 	<xsl:variable name="name">
 		<xsl:choose>
@@ -64,18 +65,23 @@
 		</xsl:choose>
 	</xsl:variable>
 	<!-- place the object. -->
-	<PlaceObject2 replace="0" depth="{swft:next-depth()}" name="{$name}" 
+	<PlaceObject2 replace="0" depth="{swft:next-depth()}" name="{$name}"
 objectID="{$id}">
-		<!-- svg:use elements add an instance transform, all others have it 
+		<!-- svg:use elements add an instance transform, all others have it
 included in their definition. -->
 		<xsl:choose>
 			<xsl:when test="name()='use'">
 				<xsl:call-template name="transform" />
 			</xsl:when>
-			<xsl:otherwise>
+			<xsl:when test="not($transform) or $transform=''">
 				<transform>
 					<Transform transX="0" transY="0"/>
 				</transform>
+			</xsl:when>
+			<xsl:otherwise>
+				<transform>
+					<xsl:copy-of select="swft:transform($transform)" />
+				</transform>
 			</xsl:otherwise>
 		</xsl:choose>
 	</PlaceObject2>
@@ -96,7 +102,7 @@
 	</xsl:variable>
 	<DefineSprite objectID="{$id}" frames="1">
 		<tags>
-			<PlaceObject2 replace="0" depth="{swft:next-depth()}" 
+			<PlaceObject2 replace="0" depth="{swft:next-depth()}"
 objectID="{$innerid}">
 				<xsl:call-template name="transform" />
 			</PlaceObject2>
@@ -131,7 +137,7 @@
 </xsl:template>
 
 
-<!-- entry point: starts 2 passes, one for queuing up the definitions, one 
+<!-- entry point: starts 2 passes, one for queuing up the definitions, one
 for placing the elements. -->
 <xsl:template match="svg:svg" mode="svg">
 	<xsl:param name="id"/>
@@ -162,7 +168,7 @@
 	<swft:push-gradient />
 </xsl:template>
 
-<xsl:template match="svg:g|svg:path|svg:rect|svg:circle|svg:ellipse|svg:line|svg:polyline|svg:polygon|svg:use|svg:text|svg:flowRoot" 
+<xsl:template match="svg:g|svg:path|svg:rect|svg:circle|svg:ellipse|svg:line|svg:polyline|svg:polygon|svg:use|svg:text|svg:flowRoot"
 mode="queue">
 	<xsl:param name="export"/>
 
@@ -191,7 +197,7 @@
 		</xsl:choose>
 	</xsl:variable>
 
-	<!-- first define the subparts, so that we get the innermost ones queued 
+	<!-- first define the subparts, so that we get the innermost ones queued
 first. -->
 	<xsl:apply-templates mode="queue">
 		<xsl:with-param name="export" select="$export"/>
@@ -209,11 +215,14 @@
 	</xsl:if>
 </xsl:template>
 
-<xsl:template match="svg:g|svg:path|svg:rect|svg:circle|svg:ellipse|svg:line|svg:polyline|svg:polygon|svg:use|svg:text|svg:flowRoot" 
+<xsl:template match="svg:g|svg:path|svg:rect|svg:circle|svg:ellipse|svg:line|svg:polyline|svg:polygon|svg:use|svg:text|svg:flowRoot"
 mode="placement">
+	<xsl:param name="transform" />
 	<xsl:if test="not(ancestor::svg:defs) or parent::svg:g">
 		<!-- no definition. just place this element. -->
-		<xsl:call-template name="placeObject" />
+		<xsl:call-template name="placeObject">
+			<xsl:with-param name="transform" select="$transform" />
+		</xsl:call-template>
 	</xsl:if>
 </xsl:template>
 
@@ -222,9 +231,9 @@
 	<xsl:param name="name"/>
 	<xsl:param name="export"/>
 
-	<!-- test if a wrapper is needed for a group transform -->
+	<!-- test if transform for inner elements is needed -->
 	<xsl:choose>
-		<xsl:when test="not(@transform) or @transform='' or 
+		<xsl:when test="not(@transform) or @transform='' or
 transform='translate(0,0)'">
 			<!-- no transform, define the group and place the subparts -->
 			<DefineSprite objectID="{$id}" frames="1">
@@ -236,19 +245,16 @@
 			</DefineSprite>
 		</xsl:when>
 		<xsl:otherwise>
-			<!-- define an inner group and wrap it with the group transform -->
-			<xsl:variable name="innerid"><xsl:value-of 
-select="swft:next-id()"/></xsl:variable>
-			<DefineSprite objectID="{$innerid}" frames="1">
+			<!-- apply transform for inner elements -->
+			<DefineSprite objectID="{$id}" frames="1">
 				<tags>
-					<xsl:apply-templates mode="placement" />
+					<xsl:apply-templates mode="placement">
+						<xsl:with-param name="transform" select="@transform" />
+					</xsl:apply-templates>
 					<ShowFrame/>
 					<End/>
 				</tags>
 			</DefineSprite>
-			<xsl:call-template name="wrapElement">
-				<xsl:with-param name="innerid" select="$innerid" />
-			</xsl:call-template>
 		</xsl:otherwise>
 	</xsl:choose>
 
@@ -262,7 +268,7 @@
 <xsl:template match="svg:rect|svg:circle|svg:ellipse|svg:line|svg:polyline|svg:polygon|svg:path" mode="definition">
 	<xsl:param name="id"/>
 	<xsl:param name="export"/>
-	<xsl:variable name="shapeid"><xsl:value-of 
+	<xsl:variable name="shapeid"><xsl:value-of
 select="swft:next-id()"/></xsl:variable>
 
 	<!-- define the path -->
@@ -281,22 +287,22 @@
 	<xsl:param name="id"/>
 	<xsl:param name="name"/>
 	<xsl:param name="export"/>
-	<xsl:variable name="shapeid"><xsl:value-of 
+	<xsl:variable name="shapeid"><xsl:value-of
 select="swft:next-id()"/></xsl:variable>
 
 	<!-- define the element -->
-	<DefineEditText objectID="{$shapeid}" wordWrap="1" multiLine="1" 
-password="0" readOnly="0" autoSize="0" hasLayout="1" notSelectable="0" 
-hasBorder="0" isHTML="0" useOutlines="0" fontRef="{swft:map-id('vera')}" 
-fontHeight="240" align="0" leftMargin="0" rightMargin="0" indent="0" 
+	<DefineEditText objectID="{$shapeid}" wordWrap="1" multiLine="1"
+password="0" readOnly="0" autoSize="0" hasLayout="1" notSelectable="0"
+hasBorder="0" isHTML="0" useOutlines="0" fontRef="{swft:map-id('vera')}"
+fontHeight="240" align="0" leftMargin="0" rightMargin="0" indent="0"
 leading="40" variableName="[EMAIL PROTECTED]">
 		<xsl:attribute name="initialText">
 			<xsl:apply-templates mode="svg-text"/>
 		</xsl:attribute>
 		<size>
-			<Rectangle left="{svg:flowRegion/svg:rect/@x * 20}" 
-right="{(svg:flowRegion/svg:rect/@x + svg:flowRegion/svg:rect/@width)* 20}" 
-top="{svg:flowRegion/svg:rect/@y * 20}" bottom="{(svg:flowRegion/svg:rect/@y 
+			<Rectangle left="{svg:flowRegion/svg:rect/@x * 20}"
+right="{(svg:flowRegion/svg:rect/@x + svg:flowRegion/svg:rect/@width)* 20}"
+top="{svg:flowRegion/svg:rect/@y * 20}" bottom="{(svg:flowRegion/svg:rect/@y
 + svg:flowRegion/svg:rect/@height)* 20}"/>
 		</size>
 		<color>
@@ -317,20 +323,20 @@
 	<xsl:param name="id"/>
 	<xsl:param name="name"/>
 	<xsl:param name="export"/>
-	<xsl:variable name="shapeid"><xsl:value-of 
+	<xsl:variable name="shapeid"><xsl:value-of
 select="swft:next-id()"/></xsl:variable>
 
 	<!-- define the element -->
-	<DefineEditText objectID="{$shapeid}" wordWrap="0" multiLine="1" 
-password="0" readOnly="1" autoSize="1" hasLayout="1" notSelectable="1" 
-hasBorder="0" isHTML="0" useOutlines="0" fontRef="{swft:map-id('vera')}" 
-fontHeight="240" align="0" leftMargin="0" rightMargin="0" indent="0" 
+	<DefineEditText objectID="{$shapeid}" wordWrap="0" multiLine="1"
+password="0" readOnly="1" autoSize="1" hasLayout="1" notSelectable="1"
+hasBorder="0" isHTML="0" useOutlines="0" fontRef="{swft:map-id('vera')}"
+fontHeight="240" align="0" leftMargin="0" rightMargin="0" indent="0"
 leading="40" variableName="[EMAIL PROTECTED]">
 	<xsl:attribute name="initialText">
 		<xsl:apply-templates mode="svg-text"/>
 	</xsl:attribute>
 	<size>
-		<Rectangle left="[EMAIL PROTECTED] * 20}" right="{(@x + 200) * 20}" top="[EMAIL PROTECTED] * 20 - 240}" bottom="[EMAIL PROTECTED] 
+		<Rectangle left="[EMAIL PROTECTED] * 20}" right="{(@x + 200) * 20}" top="[EMAIL PROTECTED] * 20 - 240}" bottom="[EMAIL PROTECTED]
 * 20}"/>
 	</size>
 	<color>
_______________________________________________
swfmill mailing list
[email protected]
http://osflash.org/mailman/listinfo/swfmill_osflash.org

Reply via email to