svghmi/inline_svg.ysl2
changeset 3625 bb1eff4091ab
parent 3393 a65bcbb6af20
child 3690 f41733be17a8
--- a/svghmi/inline_svg.ysl2	Thu Sep 22 09:42:38 2022 +0200
+++ b/svghmi/inline_svg.ysl2	Wed Sep 28 09:19:07 2022 +0200
@@ -42,6 +42,23 @@
     attrib "{name()}" > «substring(., 2)»
 }
 
+// remove "reference" and "frame" rectangles
+svgtmpl "svg:rect[@inkscape:label='reference' or @inkscape:label='frame']", mode="inline_svg" {
+    // nothing
+}
+
+svgtmpl "svg:g[svg:rect/@inkscape:label='frame']", mode="inline_svg" {
+    const "reference_rect","(../svg:rect | ../svg:g/svg:rect)[@inkscape:label='reference']";
+    const "frame_rect","svg:rect[@inkscape:label='frame']";
+    const "offset","func:offset($frame_rect, $reference_rect)";
+
+    xsl:copy {
+        attrib "svghmi_x_offset" value "$offset/vector/@x";
+        attrib "svghmi_y_offset" value "$offset/vector/@y";
+        apply "@* | node()", mode="inline_svg";
+    }
+}
+
 ////// Clone unlinking
 //
 // svg:use (inkscape's clones) inside a widgets are