Code

updated spanish.nsh and inkscape.nsi to reflect latest file-changes
[inkscape.git] / trunk / share / extensions / xaml2svg / brushes.xsl
1 <?xml version="1.0" encoding="UTF-8"?>\r
2 \r
3 <!--\r
4 Copyright (c) 2005-2007 Toine de Greef (a.degreef@chello.nl)\r
5 \r
6 Permission is hereby granted, free of charge, to any person obtaining a copy\r
7 of this software and associated documentation files (the "Software"), to deal\r
8 in the Software without restriction, including without limitation the rights\r
9 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r
10 copies of the Software, and to permit persons to whom the Software is\r
11 furnished to do so, subject to the following conditions:\r
12 \r
13 The above copyright notice and this permission notice shall be included in\r
14 all copies or substantial portions of the Software.\r
15 \r
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
19 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
21 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
22 THE SOFTWARE.\r
23 -->\r
24 \r
25 <xsl:stylesheet version="1.0"\r
26 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"\r
27 xmlns:xlink="http://www.w3.org/1999/xlink"\r
28 xmlns:svg="http://www.w3.org/2000/svg"\r
29 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"\r
30 exclude-result-prefixes="x">\r
31 <xsl:strip-space elements="*" />\r
32 <xsl:output method="xml" encoding="ISO-8859-1"/>\r
33 \r
34 <xsl:template mode="forward" match="*[name(.) = 'LinearGradientBrush']">\r
35   <linearGradient>\r
36     <xsl:attribute name="id">\r
37       <xsl:choose>\r
38         <xsl:when test="@x:Key"><xsl:value-of select="@x:Key" /></xsl:when>\r
39         <xsl:otherwise><xsl:value-of select="concat('id_', generate-id(..))" /></xsl:otherwise>\r
40       </xsl:choose>\r
41     </xsl:attribute>\r
42     <xsl:attribute name="gradientUnits">\r
43       <xsl:choose>\r
44         <xsl:when test="@MappingMode = 'RelativeToBoundingBox' or not(@StartPoint and @EndPoint)"><xsl:value-of select="'boundingBox'" /></xsl:when>\r
45         <xsl:otherwise><xsl:value-of select="'userSpaceOnUse'" /></xsl:otherwise>\r
46       </xsl:choose>\r
47     </xsl:attribute>\r
48     <xsl:if test="@SpreadMethod">\r
49       <xsl:attribute name="spreadMethod">\r
50         <xsl:value-of select="translate(@SpreadMethod, 'PR', 'pr')" />\r
51       </xsl:attribute>\r
52     </xsl:if>\r
53     <xsl:choose>\r
54       <xsl:when test="@MappingMode = 'Absolute' and @StartPoint and @EndPoint">\r
55         <xsl:attribute name="x1"><xsl:value-of select="substring-before(@StartPoint,',')" /></xsl:attribute>\r
56         <xsl:attribute name="x1"><xsl:value-of select="substring-before(@StartPoint,',')" /></xsl:attribute>\r
57         <xsl:attribute name="y1"><xsl:value-of select="substring-after(@StartPoint,',')" /></xsl:attribute>\r
58         <xsl:attribute name="x2"><xsl:value-of select="substring-before(@EndPoint,',')" /></xsl:attribute>\r
59         <xsl:attribute name="y2"><xsl:value-of select="substring-after(@EndPoint,',')" /></xsl:attribute>\r
60       </xsl:when>\r
61       <xsl:when test="@StartPoint and @EndPoint">\r
62         <xsl:attribute name="x1"><xsl:value-of select="concat(100 * number(substring-before(@StartPoint,',')), '%')" /></xsl:attribute>\r
63         <xsl:attribute name="y1"><xsl:value-of select="concat(100 * number(substring-after(@StartPoint,',')), '%')" /></xsl:attribute>\r
64         <xsl:attribute name="x2"><xsl:value-of select="concat(100 * number(substring-before(@EndPoint,',')), '%')" /></xsl:attribute>\r
65         <xsl:attribute name="y2"><xsl:value-of select="concat(100 * number(substring-after(@EndPoint,',')), '%')" /></xsl:attribute>\r
66       </xsl:when>\r
67       <xsl:otherwise>\r
68         <xsl:attribute name="x1"><xsl:value-of select="0" /></xsl:attribute>\r
69         <xsl:attribute name="y1"><xsl:value-of select="0" /></xsl:attribute>\r
70         <xsl:attribute name="x2"><xsl:value-of select="'100%'" /></xsl:attribute>\r
71         <xsl:attribute name="y2"><xsl:value-of select="'100%'" /></xsl:attribute>\r
72       </xsl:otherwise>\r
73     </xsl:choose>\r
74     <xsl:call-template name="template_gradienttransform" />\r
75     <xsl:apply-templates select="*[name(.) != 'Brush.Transform' and name(.) != concat(name(..), '.Transform') and name(.) != 'Brush.RelativeTransform' and name(.) != concat(name(..), '.RelativeTransform')]" />\r
76   </linearGradient>\r
77 </xsl:template>\r
78 \r
79 <xsl:template mode="forward" match="*[name(.) = 'RadialGradientBrush']">\r
80   <radialGradient>\r
81     <xsl:attribute name="id">\r
82       <xsl:choose>\r
83         <xsl:when test="@x:Key"><xsl:value-of select="@x:Key" /></xsl:when>\r
84         <xsl:otherwise><xsl:value-of select="concat('id_', generate-id(..))" /></xsl:otherwise>\r
85       </xsl:choose>\r
86     </xsl:attribute>\r
87     <xsl:attribute name="gradientUnits">\r
88       <xsl:choose>\r
89         <xsl:when test="@MappingMode = 'RelativeToBoundingBox' or not(@StartPoint and @EndPoint)"><xsl:value-of select="'boundingBox'" /></xsl:when>\r
90         <xsl:otherwise><xsl:value-of select="'userSpaceOnUse'" /></xsl:otherwise>\r
91       </xsl:choose>\r
92     </xsl:attribute>\r
93     <xsl:if test="@SpreadMethod">\r
94       <xsl:attribute name="spreadMethod">\r
95         <xsl:value-of select="translate(@SpreadMethod, 'PR', 'pr')" />\r
96       </xsl:attribute>\r
97     </xsl:if>\r
98     <xsl:if test="@Center">\r
99       <xsl:attribute name="cx"><xsl:value-of select="substring-before(@Center, ',')" /></xsl:attribute>\r
100     <xsl:attribute name="cy"><xsl:value-of select="substring-after(@Center, ',')" /></xsl:attribute>\r
101     </xsl:if>\r
102     <xsl:if test="@GradientOrigin">\r
103       <xsl:attribute name="fx"><xsl:value-of select="substring-before(@GradientOrigin, ',')" /></xsl:attribute>\r
104       <xsl:attribute name="fy"><xsl:value-of select="substring-after(@GradientOrigin, ',')" /></xsl:attribute>\r
105     </xsl:if>\r
106     <!-- Xamlon uses Focus -->\r
107     <xsl:if test="@Focus">\r
108       <xsl:attribute name="fx"><xsl:value-of select="substring-before(@Focus, ',')" /></xsl:attribute>\r
109       <xsl:attribute name="fy"><xsl:value-of select="substring-after(@Focus, ',')" /></xsl:attribute>\r
110     </xsl:if>\r
111     <xsl:attribute name="r"><xsl:value-of select="@RadiusX" /></xsl:attribute>\r
112     <xsl:call-template name="template_gradienttransform" />\r
113     <xsl:apply-templates select="*[name(.) != 'Brush.Transform' and name(.) != concat(name(..), '.Transform') and name(.) != 'Brush.RelativeTransform' and name(.) != concat(name(..), '.RelativeTransform')]" />\r
114   </radialGradient>\r
115 </xsl:template>\r
116 \r
117 <xsl:template match="*[name(.) = 'GradientStopCollection' or name(.) = 'GradientBrush.GradientStops' or name(.) = concat(name(..), '.GradientStops')]">\r
118   <xsl:apply-templates />\r
119 </xsl:template>\r
120 \r
121 <xsl:template match="*[name(.) = 'GradientStop']">\r
122   <stop>\r
123     <xsl:if test="@Offset"><xsl:attribute name="offset"><xsl:value-of select="@Offset" /></xsl:attribute></xsl:if>\r
124     <xsl:if test="@Color">\r
125       <xsl:attribute name="stop-color"><xsl:call-template name="template_color"><xsl:with-param name="colorspec" select="@Color" /></xsl:call-template></xsl:attribute>\r
126       <xsl:variable name="test_opacity"><xsl:call-template name="template_opacity"><xsl:with-param name="colorspec" select="@Color" /></xsl:call-template></xsl:variable>\r
127       <xsl:if test="string-length($test_opacity) &gt; 0"><xsl:attribute name="stop-opacity"><xsl:value-of select="$test_opacity" /></xsl:attribute></xsl:if>\r
128     </xsl:if>\r
129   </stop>\r
130 </xsl:template>\r
131 \r
132 <xsl:template match="*[name(.) = 'SolidColorBrush']">\r
133   <xsl:call-template name="template_properties" />\r
134   <xsl:apply-templates />\r
135 </xsl:template>\r
136 \r
137 <xsl:template match="*[name(.) = 'ImageBrush']">\r
138   <defs>\r
139     <pattern>\r
140       <xsl:choose>\r
141         <xsl:when test="@TileMode != 'none' and @Viewport and @ViewportUnits = 'Absolute'">\r
142           <xsl:attribute name="patternUnits">userSpaceOnUse</xsl:attribute>\r
143           <xsl:attribute name="x"><xsl:value-of select="substring-before(@Viewport, ',')" /></xsl:attribute>\r
144           <xsl:attribute name="y"><xsl:value-of select="substring-before(substring-after(@Viewport, ','), ',')" /></xsl:attribute>\r
145           <xsl:attribute name="width"><xsl:value-of select="substring-before(substring-after(substring-after(@Viewport, ','), ','), ',')" /></xsl:attribute>\r
146           <xsl:attribute name="height"><xsl:value-of select="substring-after(substring-after(substring-after(@Viewport, ','), ','), ',')" /></xsl:attribute>\r
147         </xsl:when>\r
148         <xsl:when test="@TileMode != 'none' and @Viewport">\r
149           <xsl:attribute name="patternUnits">boundingBox</xsl:attribute>\r
150           <xsl:attribute name="x"><xsl:value-of select="concat(100 * number(substring-before(@Viewport, ',')), '%')" /></xsl:attribute>\r
151           <xsl:attribute name="y"><xsl:value-of select="concat(100 * number(substring-before(substring-after(@Viewport, ','), ',')), '%')" /></xsl:attribute>\r
152           <xsl:attribute name="width"><xsl:value-of select="concat(100 * number(substring-before(substring-after(substring-after(@Viewport, ','), ','), ',')), '%')" /></xsl:attribute>\r
153           <xsl:attribute name="height"><xsl:value-of select="concat(100 * number(substring-after(substring-after(substring-after(@Viewport, ','), ','), ',')), '%')" /></xsl:attribute>\r
154         </xsl:when>\r
155         <xsl:when test="@Viewport and ../../@Width and ../../@Height">\r
156           <xsl:attribute name="patternUnits">userSpaceOnUse</xsl:attribute>\r
157           <xsl:attribute name="x">0</xsl:attribute>\r
158           <xsl:attribute name="y">0</xsl:attribute>\r
159           <xsl:attribute name="width"><xsl:value-of select="../../@Width" /></xsl:attribute>\r
160           <xsl:attribute name="height"><xsl:value-of select="../../@Height" /></xsl:attribute>\r
161         </xsl:when>\r
162         <xsl:otherwise>\r
163           <xsl:attribute name="patternUnits">boundingBox </xsl:attribute>\r
164           <xsl:attribute name="x">0</xsl:attribute>\r
165           <xsl:attribute name="y">0</xsl:attribute>\r
166           <xsl:attribute name="width">100%</xsl:attribute>\r
167           <xsl:attribute name="height">100%</xsl:attribute>\r
168         </xsl:otherwise>\r
169       </xsl:choose>\r
170       <xsl:attribute name="id"><xsl:value-of select="concat('id_', generate-id(..))" /></xsl:attribute>\r
171       <image>\r
172         <xsl:attribute name="xlink:href"><xsl:value-of select="@ImageSource" /></xsl:attribute>\r
173         <xsl:choose>\r
174           <xsl:when test="@Viewport and @ViewportUnits = 'Absolute'">\r
175             <xsl:attribute name="patternUnits">userSpaceOnUse</xsl:attribute>\r
176             <xsl:attribute name="x"><xsl:value-of select="0" /></xsl:attribute>\r
177             <xsl:attribute name="y"><xsl:value-of select="0" /></xsl:attribute>\r
178             <xsl:attribute name="width"><xsl:value-of select="substring-before(substring-after(substring-after(@Viewport, ','), ','), ',')" /></xsl:attribute>\r
179             <xsl:attribute name="height"><xsl:value-of select="substring-after(substring-after(substring-after(@Viewport, ','), ','), ',')" /></xsl:attribute>\r
180           </xsl:when>\r
181           <xsl:when test="@Viewport">\r
182             <xsl:attribute name="patternUnits">boundingBox</xsl:attribute>\r
183             <xsl:attribute name="x"><xsl:value-of select="0" /></xsl:attribute>\r
184             <xsl:attribute name="y"><xsl:value-of select="0" /></xsl:attribute>\r
185             <xsl:attribute name="width"><xsl:value-of select="concat(100 * number(substring-before(substring-after(substring-after(@Viewport, ','), ','), ',')), '%')" /></xsl:attribute>\r
186             <xsl:attribute name="height"><xsl:value-of select="concat(100 * number(substring-after(substring-after(substring-after(@Viewport, ','), ','), ',')), '%')" /></xsl:attribute>\r
187           </xsl:when>\r
188           <xsl:otherwise>\r
189             <xsl:attribute name="patternUnits">boundingBox</xsl:attribute>\r
190             <xsl:attribute name="x">0</xsl:attribute>\r
191             <xsl:attribute name="y">0</xsl:attribute>\r
192             <xsl:attribute name="width">100%</xsl:attribute>\r
193             <xsl:attribute name="height">100%</xsl:attribute>\r
194           </xsl:otherwise>\r
195         </xsl:choose>\r
196         <xsl:attribute name="style">opacity:1</xsl:attribute>\r
197         <xsl:attribute name="image-rendering">optimizeSpeed</xsl:attribute>\r
198       </image>\r
199     </pattern>\r
200   </defs>\r
201 </xsl:template>\r
202 \r
203 <xsl:template match="*[name(.) = 'DrawingBrush']">\r
204     <pattern>\r
205       <xsl:choose>\r
206         <xsl:when test="@TileMode != 'none' and @Viewport and @ViewportUnits = 'Absolute'">\r
207           <xsl:attribute name="patternUnits">userSpaceOnUse</xsl:attribute>\r
208           <xsl:attribute name="x"><xsl:value-of select="substring-before(@Viewport, ',')" /></xsl:attribute>\r
209           <xsl:attribute name="y"><xsl:value-of select="substring-before(substring-after(@Viewport, ','), ',')" /></xsl:attribute>\r
210           <xsl:attribute name="width"><xsl:value-of select="substring-before(substring-after(substring-after(@Viewport, ','), ','), ',')" /></xsl:attribute>\r
211           <xsl:attribute name="height"><xsl:value-of select="substring-after(substring-after(substring-after(@Viewport, ','), ','), ',')" /></xsl:attribute>\r
212         </xsl:when>\r
213         <xsl:when test="@TileMode != 'none' and @Viewport">\r
214           <xsl:attribute name="patternUnits">boundingBox</xsl:attribute>\r
215           <xsl:attribute name="x"><xsl:value-of select="concat(100 * number(substring-before(@Viewport, ',')), '%')" /></xsl:attribute>\r
216           <xsl:attribute name="y"><xsl:value-of select="concat(100 * number(substring-before(substring-after(@Viewport, ','), ',')), '%')" /></xsl:attribute>\r
217           <xsl:attribute name="width"><xsl:value-of select="concat(100 * number(substring-before(substring-after(substring-after(@Viewport, ','), ','), ',')), '%')" /></xsl:attribute>\r
218           <xsl:attribute name="height"><xsl:value-of select="concat(100 * number(substring-after(substring-after(substring-after(@Viewport, ','), ','), ',')), '%')" /></xsl:attribute>\r
219         </xsl:when>\r
220         <xsl:when test="@Viewport and ../../@Width and ../../@Height">\r
221           <xsl:attribute name="patternUnits">userSpaceOnUse</xsl:attribute>\r
222           <xsl:attribute name="x">0</xsl:attribute>\r
223           <xsl:attribute name="y">0</xsl:attribute>\r
224           <xsl:attribute name="width"><xsl:value-of select="../../@Width" /></xsl:attribute>\r
225           <xsl:attribute name="height"><xsl:value-of select="../../@Height" /></xsl:attribute>\r
226         </xsl:when>\r
227         <xsl:otherwise>\r
228           <xsl:attribute name="patternUnits">boundingBox</xsl:attribute>\r
229           <xsl:attribute name="x">0</xsl:attribute>\r
230           <xsl:attribute name="y">0</xsl:attribute>\r
231           <xsl:attribute name="width">100%</xsl:attribute>\r
232           <xsl:attribute name="height">100%</xsl:attribute>\r
233         </xsl:otherwise>\r
234       </xsl:choose>\r
235       <xsl:attribute name="id"><xsl:value-of select="concat('id_', generate-id(..))" /></xsl:attribute>\r
236       <xsl:apply-templates mode="forward" />\r
237     </pattern>\r
238 </xsl:template>\r
239 \r
240 <xsl:template match="*[name(.) = 'DrawingBrush.Drawing']">\r
241   <xsl:apply-templates mode="forward" />\r
242 </xsl:template>\r
243 \r
244 </xsl:stylesheet>\r