KSVG: Support for default document size.

When width and height parameters passed to KSVGIconEngine::load(...)
are 0, SVG document defaults will be used.

Signed-off-by: Mavridis Philippe <mavridisf@gmail.com>
feat/tdehtml+svg
Mavridis Philippe 2 years ago
parent 452ca94c96
commit dbd8fb94cc
Signed by: blu.256
GPG Key ID: F8D2D7E2F989A494

@ -596,17 +596,31 @@ bool KSVGIconEngine::load(int width, int height, const TQString &path)
// Detect width and height
TQDomElement rootElement = rootNode.toElement();
// Create icon painter
d->painter = new KSVGIconPainter(width, height);
d->width = width; // this sets default for no width -> 100% case
if(rootElement.hasAttribute("width"))
{
d->width = d->helper->toPixel(rootElement.attribute("width"), true);
if(!width) // no width set, use default
{
width = d->width;
}
}
d->height = height; // this sets default for no height -> 100% case
if(rootElement.hasAttribute("height"))
{
d->height = d->helper->toPixel(rootElement.attribute("height"), false);
if(!height) // no height set, use default
{
height = d->height;
}
}
// Create icon painter
d->painter = new KSVGIconPainter(width, height);
// Create icon painter
d->painter->setDrawWidth(static_cast<int>(d->width));
d->painter->setDrawHeight(static_cast<int>(d->height));

Loading…
Cancel
Save