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
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,
10 if( strcmp(sValue,"none") == 0 )
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];
33 + ElementRefMapType::iterator aRes;
34 + if( (aRes=maGradientIdMap.find(
35 + rValue.copy(aPaintUri.first-sValue,
36 + aPaintUri.second-aPaintUri.first))) != maGradientIdMap.end() )
38 + rGradient = maGradientVector[aRes->second];
43 + else if( aColor.second )
46 + rColor = aColor.first;
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
58 return basegfx::unotools::affineMatrixFromHomMatrix(aRet,aRHS);
63 + struct ColorGrammar : public ::boost::spirit::grammar< ColorGrammar >
66 + ARGBColor& m_rColor;
67 + explicit ColorGrammar( ARGBColor& rColor ) : m_rColor(rColor) {}
68 + template< typename ScannerT >
71 + ::boost::spirit::rule< ScannerT > colorExpression;
72 + definition( const ColorGrammar& self )
74 + using namespace ::boost::spirit;
76 + int_parser<sal_uInt8,10,1,3> byte_p;
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)])
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)])
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)])
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)])
115 + ::boost::spirit::rule<ScannerT> const& start() const { return colorExpression; }
120 bool parseColor( const char* sColor, ARGBColor& rColor )
122 using namespace ::boost::spirit;
124 - int_parser<sal_uInt8,10,1,3> byte_p;
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)])
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)])
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)])
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)])
166 + ColorGrammar(rColor) >> end_p,
169 // free-form color found & parsed
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,
186 + (+alnum_p)[assign_a(o_rPaintUri)] >>
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
200 +//////////////////////////////////////////////////////////////
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
208 #include <sal/config.h>
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
221 + Start and end ptr for uri substring (within
222 + [sPaintUri,sPaintUri+strlen(sPaintUri)]
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
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.
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 );