Fix ksvg not respecting fit request

This resolves Bug 1018
pull/1/head
Timothy Pearson 11 years ago
parent af3e4faad3
commit 6792dcd1ea

@ -575,7 +575,9 @@ void KSVGCanvas::update(float zoomFactor)
setRenderBufferSize(newWidth, newHeight); setRenderBufferSize(newWidth, newHeight);
} }
else else
{
fill(); fill();
}
// reset clip paths // reset clip paths
TQDictIterator<CanvasClipPath> itr(m_clipPaths); TQDictIterator<CanvasClipPath> itr(m_clipPaths);

@ -231,36 +231,42 @@ bool InputHandler::startElement(const TQString &namespaceURI, const TQString &,
// Need this before we can find our ownerSVGElement (AP) // Need this before we can find our ownerSVGElement (AP)
if(m_currentNode != 0) if(m_currentNode != 0)
{
m_currentNode->appendChild(*svg); m_currentNode->appendChild(*svg);
}
else else
// TODO: Those set/get attribute callls have NO effect anymore
// Convert to the new system, Rob? (Niko)
{ {
if(Helper::self()->fit()) if(Helper::self()->fit())
{ // handle fitting of svg into small drawing area(thumb) { // handle fitting of svg into small drawing area(thumb)
// TODO : aspectratio? and what about svgs that dont provide width and height? // TODO : aspectratio? and what about svgs that dont provide width and height?
if(svg->getAttribute("viewBox").string().isEmpty()) if(attrs.value("viewBox").isEmpty())
{ {
SVGLengthImpl *width = SVGSVGElementImpl::createSVGLength(); SVGLengthImpl *width = SVGSVGElementImpl::createSVGLength();
SVGLengthImpl *height = SVGSVGElementImpl::createSVGLength(); SVGLengthImpl *height = SVGSVGElementImpl::createSVGLength();
width->setValueAsString(svg->getAttribute("width").string()); width->setValueAsString(attrs.value("width"));
height->setValueAsString(svg->getAttribute("height").string()); height->setValueAsString(attrs.value("height"));
TQString viewbox = TQString("0 0 %1 %2").arg(width->value()).arg(height->value()); TQString viewbox = TQString("0 0 %1 %2").arg(width->value()).arg(height->value());
//kdDebug(26001) << "VIEWBOX : " << viewbox.latin1() << endl; //kdDebug(26001) << "VIEWBOX : " << viewbox.latin1() << endl;
svg->setAttribute("viewBox", viewbox); // HACK
// Does the existing attribute need to be deleted before appending the new attribute?
const_cast<TQXmlAttributes&>(attrs).append("viewBox", TQString::null, "viewBox", viewbox);
width->deref(); width->deref();
height->deref(); height->deref();
} }
svg->setAttribute("width", TQString::number(Helper::self()->canvas()->width())); // HACK
svg->setAttribute("height", TQString::number(Helper::self()->canvas()->height())); // Does the existing attribute need to be deleted before appending the new attribute?
const_cast<TQXmlAttributes&>(attrs).append("width", TQString::null, "width", TQString::number(Helper::self()->canvas()->width()));
const_cast<TQXmlAttributes&>(attrs).append("height", TQString::null, "height", TQString::number(Helper::self()->canvas()->height()));
} }
if(!Helper::self()->SVGFragmentId().isEmpty()) if(!Helper::self()->SVGFragmentId().isEmpty())
{ {
if(svg->currentView()->parseViewSpec(Helper::self()->SVGFragmentId())) if(svg->currentView()->parseViewSpec(Helper::self()->SVGFragmentId()))
{
svg->setUseCurrentView(true); svg->setUseCurrentView(true);
} }
} }
}
if(m_rootNode == 0) if(m_rootNode == 0)
{ {
@ -397,7 +403,7 @@ bool InputHandler::endElement(const TQString &, const TQString &, const TQString
m_noRendering = false; m_noRendering = false;
bool ok = tests ? tests->ok() : true; bool ok = tests ? tests->ok() : true;
if(haveCanvas && element && style && ok && style->getDisplay() && style->getVisible() && qName == "pattern" || (shape && shape->directRender())) if((haveCanvas && element && style && ok && style->getDisplay() && style->getVisible() && (qName == "pattern")) || (shape && shape->directRender()))
element->createItem(); element->createItem();
} }

@ -67,8 +67,9 @@ bool SVGCreator::create(const TQString &path, int width, int height, TQImage &im
m_finished = false; m_finished = false;
while(!m_finished) while(!m_finished) {
kapp->processOneEvent(); kapp->processOneEvent();
}
doc->deref(); doc->deref();

Loading…
Cancel
Save