merge the formfield patch from ooo-build
[ooovba.git] / applied_patches / 0399-svg-import-painturi-fix.diff
blobf69baf125d5687f42cc1e1f22f16a2193931f67e
1 --- filter/source/svg/svgreader.cxx.old 2008-10-20 10:54:11.000000000 +0200
2 +++ filter/source/svg/svgreader.cxx 2008-10-20 12:12:44.000000000 +0200
3 @@ -996,6 +996,9 @@
4 const ARGBColor& rInheritColor,
5 const Gradient& rInheritGradient )
7 + std::pair<const char*,const char*> aPaintUri(NULL,NULL);
8 + std::pair<ARGBColor,bool> aColor(maCurrState.maCurrentColor,
9 + false);
10 if( strcmp(sValue,"none") == 0 )
11 rType = NONE;
12 else if( strcmp(sValue,"currentColor") == 0 )
13 @@ -1009,19 +1012,33 @@
14 rColor = rInheritColor;
15 rGradient = rInheritGradient;
17 - else if( strncmp(sValue,"url(#",5) == 0 )
18 + else if( parsePaintUri(aPaintUri,aColor,sValue) )
20 - // assuming gradient. assumption does not hold generally
21 - if( rValue.getLength() > 5 )
22 + if( aPaintUri.first != aPaintUri.second )
24 - ElementRefMapType::iterator aRes;
25 - if( (aRes=maGradientIdMap.find(rValue.copy(5,
26 - rValue.getLength()-6))) != maGradientIdMap.end() )
27 + // assuming gradient. assumption does not hold generally
28 + const char* pClosingBracket;
29 + if( (pClosingBracket=strstr(sValue,")")) && rValue.getLength() > 5 )
31 - rGradient = maGradientVector[aRes->second];
32 - rType = GRADIENT;
33 + ElementRefMapType::iterator aRes;
34 + if( (aRes=maGradientIdMap.find(
35 + rValue.copy(aPaintUri.first-sValue,
36 + aPaintUri.second-aPaintUri.first))) != maGradientIdMap.end() )
37 + {
38 + rGradient = maGradientVector[aRes->second];
39 + rType = GRADIENT;
40 + }
43 + else if( aColor.second )
44 + {
45 + rType = SOLID;
46 + rColor = aColor.first;
47 + }
48 + else
49 + {
50 + rType = NONE;
51 + }
53 else
55 --- filter/source/svg/parserfragments.cxx.old 2008-10-20 10:53:31.000000000 +0200
56 +++ filter/source/svg/parserfragments.cxx 2008-10-20 12:04:27.000000000 +0200
57 @@ -117,52 +117,72 @@
58 return basegfx::unotools::affineMatrixFromHomMatrix(aRet,aRHS);
61 +namespace
63 + struct ColorGrammar : public ::boost::spirit::grammar< ColorGrammar >
64 + {
65 + public:
66 + ARGBColor& m_rColor;
67 + explicit ColorGrammar( ARGBColor& rColor ) : m_rColor(rColor) {}
68 + template< typename ScannerT >
69 + struct definition
70 + {
71 + ::boost::spirit::rule< ScannerT > colorExpression;
72 + definition( const ColorGrammar& self )
73 + {
74 + using namespace ::boost::spirit;
76 + int_parser<sal_uInt8,10,1,3> byte_p;
77 + colorExpression =
78 + (
79 + // the #rrggbb form
80 + ('#' >> (xdigit_p >> xdigit_p)[boost::bind(&setEightBitColor,
81 + boost::ref(self.m_rColor.r),_1,_2)]
82 + >> (xdigit_p >> xdigit_p)[boost::bind(&setEightBitColor,
83 + boost::ref(self.m_rColor.g),_1,_2)]
84 + >> (xdigit_p >> xdigit_p)[boost::bind(&setEightBitColor,
85 + boost::ref(self.m_rColor.b),_1,_2)])
86 + |
87 + // the #rgb form
88 + ('#' >> xdigit_p[boost::bind(&setFourBitColor,
89 + boost::ref(self.m_rColor.r),_1)]
90 + >> xdigit_p[boost::bind(&setFourBitColor,
91 + boost::ref(self.m_rColor.g),_1)]
92 + >> xdigit_p[boost::bind(&setFourBitColor,
93 + boost::ref(self.m_rColor.b),_1)])
94 + |
95 + // rgb() form
96 + (str_p("rgb")
97 + >> '(' >>
98 + (
99 + // rgb(int,int,int)
100 + (byte_p[boost::bind(&setIntColor,
101 + boost::ref(self.m_rColor.r),_1)] >> ',' >>
102 + byte_p[boost::bind(&setIntColor,
103 + boost::ref(self.m_rColor.g),_1)] >> ',' >>
104 + byte_p[boost::bind(&setIntColor,
105 + boost::ref(self.m_rColor.b),_1)])
106 + |
107 + // rgb(double,double,double)
108 + (real_p[assign_a(self.m_rColor.r)] >> ',' >>
109 + real_p[assign_a(self.m_rColor.g)] >> ',' >>
110 + real_p[assign_a(self.m_rColor.b)])
112 + >> ')')
113 + );
115 + ::boost::spirit::rule<ScannerT> const& start() const { return colorExpression; }
116 + };
117 + };
120 bool parseColor( const char* sColor, ARGBColor& rColor )
122 using namespace ::boost::spirit;
124 - int_parser<sal_uInt8,10,1,3> byte_p;
126 if( parse(sColor,
127 - // Begin grammar
129 - // the #rrggbb form
130 - ('#' >> (xdigit_p >> xdigit_p)[boost::bind(&setEightBitColor,
131 - boost::ref(rColor.r),_1,_2)]
132 - >> (xdigit_p >> xdigit_p)[boost::bind(&setEightBitColor,
133 - boost::ref(rColor.g),_1,_2)]
134 - >> (xdigit_p >> xdigit_p)[boost::bind(&setEightBitColor,
135 - boost::ref(rColor.b),_1,_2)])
137 - // the #rgb form
138 - ('#' >> xdigit_p[boost::bind(&setFourBitColor,
139 - boost::ref(rColor.r),_1)]
140 - >> xdigit_p[boost::bind(&setFourBitColor,
141 - boost::ref(rColor.g),_1)]
142 - >> xdigit_p[boost::bind(&setFourBitColor,
143 - boost::ref(rColor.b),_1)])
145 - // rgb() form
146 - (str_p("rgb")
147 - >> '(' >>
149 - // rgb(int,int,int)
150 - (byte_p[boost::bind(&setIntColor,
151 - boost::ref(rColor.r),_1)] >> ',' >>
152 - byte_p[boost::bind(&setIntColor,
153 - boost::ref(rColor.g),_1)] >> ',' >>
154 - byte_p[boost::bind(&setIntColor,
155 - boost::ref(rColor.b),_1)])
156 - |
157 - // rgb(double,double,double)
158 - (real_p[assign_a(rColor.r)] >> ',' >>
159 - real_p[assign_a(rColor.g)] >> ',' >>
160 - real_p[assign_a(rColor.b)])
162 - >> ')')
163 - ) >> end_p,
164 - // End grammar
165 - space_p).full )
166 + ColorGrammar(rColor) >> end_p,
167 + space_p).full )
169 // free-form color found & parsed
170 return true;
171 @@ -519,6 +539,32 @@
174 //////////////////////////////////////////////////////////////
176 +bool parsePaintUri( std::pair<const char*,const char*>& o_rPaintUri,
177 + std::pair<ARGBColor,bool>& io_rColor,
178 + const char* sPaintUri )
180 + using namespace ::boost::spirit;
182 + const bool bRes = parse(sPaintUri,
183 + // Begin grammar
185 + str_p("url(#") >>
186 + (+alnum_p)[assign_a(o_rPaintUri)] >>
187 + str_p(")") >>
188 + *( str_p("none")[assign_a(io_rColor.second,false)] |
189 + str_p("currentColor")[assign_a(io_rColor.second,true)] |
190 + ColorGrammar(io_rColor.first)
191 + // TODO(F1): named color
193 + ) >> end_p,
194 + // End grammar
195 + space_p).full;
197 + return bRes;
200 +//////////////////////////////////////////////////////////////
202 namespace
204 --- filter/source/svg/parserfragments.hxx.old 2008-10-20 10:53:13.000000000 +0200
205 +++ filter/source/svg/parserfragments.hxx 2008-10-20 12:12:58.000000000 +0200
206 @@ -18,6 +18,7 @@
208 #include <sal/config.h>
209 #include <vector>
210 +#include <utility>
211 #include <string>
213 namespace basegfx
214 @@ -42,6 +43,29 @@
215 /// Parse given string for a list of double values, comma-delimited
216 bool parseDashArray( const char* sDashArray, std::vector<double>& rOutputVector );
218 + /** Parse paint uri
220 + @param o_rPaintUri
221 + Start and end ptr for uri substring (within
222 + [sPaintUri,sPaintUri+strlen(sPaintUri)]
224 + @param io_rColor
225 + The optional paint color to use. if o_rPaintUri is empty,
226 + parser sets io_rColor.second to false for color="None", to
227 + true and keeps current io_rColor.first entry for
228 + "currentColor", and to true and sets io_rColor.first to parsed
229 + color otherwise.
231 + @param sPaintUri
232 + String to parse. Permitted to contain the optional paint
233 + stuff, like fallback color.
235 + @return true, if a paint uri was successfully parsed.
236 + */
237 + bool parsePaintUri( std::pair<const char*,const char*>& o_rPaintUri,
238 + std::pair<ARGBColor,bool>& io_rColor,
239 + const char* sPaintUri );
241 /// Parse given string for the xlink attribute
242 bool parseXlinkHref( const char* xlink, std::string& data );