Version: 1.4.2 (using KDE KDE 3.4.2) Installed from: Debian testing/unstable Packages OS: Linux The "paris.svg" file from the gnome-games package (contains the images of cards) opens garbled.
Created attachment 14058 [details] This is the file that fails to load
Hello, Thanks for the bug report. I can confirm the problem(s). From looking at the SVG code I can see at least one thing that we don't support yet: <use transform="translate(576.5,430.5)" xlink:href="#sl"/> The only use items we support yet are x, y and xlink:href The transform item and other items like stroke are not yet supported. They will be soon though
Wow this is a huge file. While doing some tests while trying to correctly open this file: Just creating and transforming all those objects with Karbon takes a long time :( From my little debug window: Finished parsing in 22204 milliseconds And that's just creating and moving the objects around. If I don't create the objects and only parse the svg data, I get: Finished parsing in 1029 milliseconds Conclusion: Creating objects in Karbon is extremely expensive at the moment :(
SVN commit 492906 by beaulen: Improved the svg import filter a little bit. The use tag now understands the format attribute too, which means translating, scaling and rotating. I also improved handling of the gradients (which was needed after updating the handling of the use tag). I tried tens of svg files, from normal ones to very complex files. I couldn't get any of those files to make Karbon crash. One made it hang though and several still don't open 100% correctly. The file attached in bug report 119150 ( http://bugs.kde.org/show_bug.cgi?id=119150 ) Opens a little bit better too now, still not correctly though. CCBUG:119150 M +376 -250 svgimport.cc M +7 -3 svgimport.h
SVN commit 493039 by beaulen: Don't try and reinvent the wheel. VPath can perfectly parse the transform attribute. This will load paris.svg from the bugreport http://bugs.kde.org/show_bug.cgi?id=119150 almost perfectly. There does seem to be a problem with some paths though, especially the numbers on the cards. This commit will break use cases where the style is in the use tag. I'll fix that next. M +17 -56 svgimport.cc --- trunk/koffice/filters/karbon/svg/svgimport.cc #493038:493039 @@ -945,6 +945,9 @@ if( !id.isEmpty() ) { + addGraphicContext(); + setupTransform( e ); + QString key = id.mid( 1 ); if( !e.attribute( "x" ).isEmpty() && !e.attribute( "y" ).isEmpty() ) @@ -952,73 +955,31 @@ double tx = e.attribute( "x" ).toDouble(); double ty = e.attribute( "y" ).toDouble(); - m_gc.current()->matrix.reset(); m_gc.current()->matrix.translate(tx,ty); } - else if( !e.attribute( "transform" ).isEmpty() ) - { - QString xfrmStr = e.attribute( "transform" ); - - int t = xfrmStr.find("translate"); - int s = xfrmStr.find("scale"); - int r = xfrmStr.find("rotate"); - m_gc.current()->matrix.reset(); - - if(t > -1) - { - int tbegin = xfrmStr.find("(",t); - int tend = xfrmStr.find(",",tbegin); - double tx = xfrmStr.mid(tbegin+1,tend-tbegin-1).toDouble(); - tbegin = tend+1; - tend = xfrmStr.find(")",tbegin); - double ty = xfrmStr.mid(tbegin,tend-tbegin).toDouble(); - - m_gc.current()->matrix.translate(tx,ty); - } - - if(s > -1) - { - int sbegin = xfrmStr.find("(",s); - int send = xfrmStr.find(")",sbegin); - double sx = xfrmStr.mid(sbegin+1,send-sbegin-1).toDouble(); - - m_gc.current()->matrix.scale(sx,-sx); - } - - if(r > -1) - { - int rbegin = xfrmStr.find("(",r); - int rend = xfrmStr.find(")",rbegin); - double rx = xfrmStr.mid(rbegin+1,rend-rbegin-1).toDouble(); - - m_gc.current()->matrix.rotate(rx); - } - - } - if(m_defs.contains(key)) { QDomElement a = m_defs[key]; if(a.tagName() == "g" || a.tagName() == "a") parseGroup( grp, a); else + { createObject( grp, a ); - } - else - return; + // Names are not unique, so findObject(objectname) will not always give the correct results. + // Since we just created our object, it's the last one so get the last one. + /*VObject *obj = 0L; + if(grp) + obj = grp->objects().getLast(); //findObject(key, grp); + else + obj = m_document.activeLayer()->objects().getLast(); - // Names are not unique, so findObject(objectname) will not always give the correct results. - // Since we just created our object, it's the last one so get the last one. - VObject *obj = 0L; - if(grp) - obj = grp->objects().getLast(); //findObject(key, grp); - else - obj = m_document.activeLayer()->objects().getLast(); - - // Parse stroke and fill etc... - if(obj) - parseStyle( obj, e ); + // Parse stroke and fill etc... + /*if(obj) + parseStyle( obj, e );*/ + } + } + delete( m_gc.pop() ); } }
SVN commit 909716 by langkamp: fixed parsing of x and y attribute of the use tag CCBUG:119150 M +2 -2 svgimport.cc WebSVN link: http://websvn.kde.org/?view=rev&revision=909716
Fixed in svn.