Fixed handling of arcs in non conforming svg files.

This resolves issue TDE/tde#46.

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
(cherry picked from commit 35d3a3c504)
v3.5.13-sru
Michele Calgaro 4 years ago committed by Slávek Banko
parent c1883367c3
commit e374731ad5
No known key found for this signature in database
GPG Key ID: 608F5293A04BE668

@ -1743,17 +1743,34 @@ void KSVGIconPainter::drawPath(const TQString &data, bool filled)
double curx = 0.0, cury = 0.0, contrlx = 0.0, contrly = 0.0, xc, yc; double curx = 0.0, cury = 0.0, contrlx = 0.0, contrly = 0.0, xc, yc;
unsigned int lastCommand = 0; unsigned int lastCommand = 0;
TQString _d = value.replace(",", " "); TQCString _d = value.replace(",", " ").simplifyWhiteSpace().latin1();
_d = _d.simplifyWhiteSpace(); const char *ptr = _d.data();
const char *ptr = _d.latin1(); const char *end = _d.data() + _d.length();
const char *end = _d.latin1() + _d.length() + 1;
double tox, toy, x1, y1, x2, y2, rx, ry, angle; double tox, toy, x1, y1, x2, y2, rx, ry, angle;
bool largeArc, sweep; bool largeArc, sweep;
char command = *(ptr++); char command = *ptr;
while(ptr < end) while(ptr < end)
{ {
if(*ptr == '+' || *ptr == '-' || *ptr == '.' || (*ptr >= '0' && *ptr <= '9'))
{
// there are still coords in this command
if(command == 'M')
{
command = 'L';
}
else if(command == 'm')
{
command = 'l';
}
}
else
{
command = *(ptr++);
}
if(*ptr == ' ') if(*ptr == ' ')
ptr++; ptr++;
@ -2179,10 +2196,19 @@ void KSVGIconPainter::drawPath(const TQString &data, bool filled)
ptr = getCoord(ptr, rx); ptr = getCoord(ptr, rx);
ptr = getCoord(ptr, ry); ptr = getCoord(ptr, ry);
ptr = getCoord(ptr, angle); ptr = getCoord(ptr, angle);
ptr = getCoord(ptr, tox); // 'largeArc' and 'sweep' are single digit flags. Some non conforming svg files do not
largeArc = tox == 1; // separate those fields with separators, so we can't use getCoord() here.
ptr = getCoord(ptr, tox); // See TDE/tde issue #46 on TGW
sweep = tox == 1; largeArc = ((*ptr++) != '0');
while (*ptr == ' ')
{
ptr++;
}
sweep = ((*ptr++) != '0');
while (*ptr == ' ')
{
ptr++;
}
ptr = getCoord(ptr, tox); ptr = getCoord(ptr, tox);
ptr = getCoord(ptr, toy); ptr = getCoord(ptr, toy);
@ -2198,10 +2224,19 @@ void KSVGIconPainter::drawPath(const TQString &data, bool filled)
ptr = getCoord(ptr, rx); ptr = getCoord(ptr, rx);
ptr = getCoord(ptr, ry); ptr = getCoord(ptr, ry);
ptr = getCoord(ptr, angle); ptr = getCoord(ptr, angle);
ptr = getCoord(ptr, tox); // 'largeArc' and 'sweep' are single digit flags. Some non conforming svg files do not
largeArc = tox == 1; // separate those fields with separators, so we can't use getCoord() here.
ptr = getCoord(ptr, tox); // See TDE/tde issue #46 on TGW
sweep = tox == 1; largeArc = ((*ptr++) != '0');
while (*ptr == ' ')
{
ptr++;
}
sweep = ((*ptr++) != '0');
while (*ptr == ' ')
{
ptr++;
}
ptr = getCoord(ptr, tox); ptr = getCoord(ptr, tox);
ptr = getCoord(ptr, toy); ptr = getCoord(ptr, toy);
@ -2215,23 +2250,6 @@ void KSVGIconPainter::drawPath(const TQString &data, bool filled)
break; break;
} }
if(*ptr == '+' || *ptr == '-' || *ptr == '.' || (*ptr >= '0' && *ptr <= '9'))
{
// there are still coords in this command
if(command == 'M')
{
command = 'L';
}
else if(command == 'm')
{
command = 'l';
}
}
else
{
command = *(ptr++);
}
// Detect reflection points // Detect reflection points
if(lastCommand != 'C' && lastCommand != 'c' && if(lastCommand != 'C' && lastCommand != 'c' &&
lastCommand != 'S' && lastCommand != 's' && lastCommand != 'S' && lastCommand != 's' &&

Loading…
Cancel
Save