~valavanisalex/ubuntu/precise/inkscape/fix-943984

« back to all changes in this revision

Viewing changes to inkscape-0.47pre1/share/extensions/xaml2svg/brushes.xsl

  • Committer: Bazaar Package Importer
  • Author(s): Bryce Harrington
  • Date: 2009-07-02 17:09:45 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20090702170945-nn6d6zswovbwju1t
Tags: 0.47~pre1-0ubuntu1
* New upstream release.
  - Don't constrain maximization on small resolution devices (pre0)
    (LP: #348842)
  - Fixes segfault on startup (pre0)
    (LP: #391149)

Show diffs side-by-side

added added

removed removed

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