mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 14:16:07 -06:00
Painter: Another SVG fix
This commit is contained in:
parent
201f96bb61
commit
14bbbe92f8
4 changed files with 9119 additions and 42 deletions
|
|
@ -19,6 +19,7 @@ file
|
|||
svg\rg1024_Presentation_with_girl.svg,
|
||||
svg\symbol.svg,
|
||||
svg\idtest.svg,
|
||||
svg\wooden-easter-egg-holder.svg,
|
||||
svg\yinyang.svg;
|
||||
|
||||
mainconfig
|
||||
|
|
|
|||
9080
examples/SVGView/svg/wooden-easter-egg-holder.svg
Normal file
9080
examples/SVGView/svg/wooden-easter-egg-holder.svg
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 412 KiB |
|
|
@ -124,6 +124,7 @@ struct SvgParser {
|
|||
void Items(const XmlNode& n, int depth);
|
||||
void Element(const XmlNode& n, int depth, bool dosymbols = false);
|
||||
void ParseGradient(const XmlNode& n, bool radial);
|
||||
void ParseStyle(const XmlNode& n);
|
||||
void ResolveGradient(int i);
|
||||
void MapIds(const XmlNode& n);
|
||||
|
||||
|
|
|
|||
|
|
@ -238,6 +238,38 @@ void SvgParser::ParseGradient(const XmlNode& n, bool radial)
|
|||
s.offset = Nvl(StrDbl(m.Attr("offset")), offset);
|
||||
}
|
||||
}
|
||||
void SvgParser::ParseStyle(const XmlNode& n)
|
||||
{
|
||||
String text = n.GatherText();
|
||||
try {
|
||||
CParser p(text);
|
||||
while(!p.IsEof()) {
|
||||
if(p.Char('.') && p.IsId()) {
|
||||
Vector<String> ids;
|
||||
String id = p.ReadIdh();
|
||||
ids.Add(id);
|
||||
while(p.Char(',') && p.Char('.') && p.IsId()) {
|
||||
id = p.ReadIdh();
|
||||
ids.Add(id);
|
||||
}
|
||||
|
||||
if(p.Char('{')) {
|
||||
const char *b = p.GetPtr();
|
||||
while(!p.IsChar('}') && !p.IsEof())
|
||||
p.SkipTerm();
|
||||
|
||||
String style(b, p.GetPtr());
|
||||
for(const String& id : ids)
|
||||
classes.GetAdd(id) << style;
|
||||
}
|
||||
p.Char('}');
|
||||
}
|
||||
else
|
||||
p.SkipTerm();
|
||||
}
|
||||
}
|
||||
catch(CParser::Error) {}
|
||||
}
|
||||
|
||||
void SvgParser::Poly(const XmlNode& n, bool line)
|
||||
{
|
||||
|
|
@ -356,27 +388,9 @@ void SvgParser::Element(const XmlNode& n, int depth, bool dosymbols)
|
|||
else
|
||||
if(m.IsTag("radialGradient"))
|
||||
ParseGradient(m, true);
|
||||
else if(m.IsTag("style")) {
|
||||
String text = m.GatherText();
|
||||
try {
|
||||
CParser p(text);
|
||||
while(!p.IsEof()) {
|
||||
if(p.Char('.') && p.IsId()) {
|
||||
String id = p.ReadIdh();
|
||||
if(p.Char('{')) {
|
||||
const char *b = p.GetPtr();
|
||||
while(!p.IsChar('}') && !p.IsEof())
|
||||
p.SkipTerm();
|
||||
classes.Add(id, String(b, p.GetPtr()));
|
||||
}
|
||||
p.Char('}');
|
||||
}
|
||||
else
|
||||
p.SkipTerm();
|
||||
}
|
||||
}
|
||||
catch(CParser::Error) {}
|
||||
}
|
||||
else
|
||||
if(m.IsTag("style"))
|
||||
ParseStyle(m);
|
||||
}
|
||||
else
|
||||
if(n.IsTag("linearGradient"))
|
||||
|
|
@ -503,27 +517,8 @@ void SvgParser::Element(const XmlNode& n, int depth, bool dosymbols)
|
|||
}
|
||||
}
|
||||
else
|
||||
if(n.IsTag("style")) {
|
||||
String text = n.GatherText();
|
||||
try {
|
||||
CParser p(text);
|
||||
while(!p.IsEof()) {
|
||||
if(p.Char('.') && p.IsId()) {
|
||||
String id = p.ReadIdh();
|
||||
if(p.Char('{')) {
|
||||
const char *b = p.GetPtr();
|
||||
while(!p.IsChar('}') && !p.IsEof())
|
||||
p.SkipTerm();
|
||||
classes.Add(id, String(b, p.GetPtr()));
|
||||
}
|
||||
p.Char('}');
|
||||
}
|
||||
else
|
||||
p.SkipTerm();
|
||||
}
|
||||
}
|
||||
catch(CParser::Error) {}
|
||||
}
|
||||
if(n.IsTag("style"))
|
||||
ParseStyle(n);
|
||||
}
|
||||
|
||||
void SvgParser::Items(const XmlNode& n, int depth)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue