Apache OpenOffice (AOO) Bugzilla – Issue 123042
[SVG] Crash: svg with image element fails to insert as linked graphic in Draw
Last modified: 2017-05-20 10:35:28 UTC
Created attachment 81335 [details] zip-Container with svg-graphic and picture, which is linked from the svg-graphic Open the attached zip container. It contains a svg graphic, which links to the confetti-picture. Launch Draw, Impress or Calc and insert the svg graphic via Insert > Picture with unchecked link (so embedded graphic). No problem. Launch Draw, Impress or Calc and insert the svg graphic via Insert > Picture as _linked_ graphic. Crash. Open the svg graphic via File > Open. No problem. Launch Writer and insert the svg graphic via Insert > Picture, linked or embedded. No Problem. @Oliver: The problem here can already be seen in r1471628. So it is independent from the crash in bug 122912 and its fix in bug 122600. The problem described here is the root cause for the crash with the test-suite file conform-viewers-03-f.svg, which i sent you.
CRASH is Reproducible with "AOO 4.0.0-Dev – German UI / German locale - [AAOO400m3(Build:9702) - Rev. 1513120 2013-08-13]" on German WIN7 Home Premium (64bit)", own separate user profile. Additional observations: a) no crash when I first do menu 'Insert -> Picture form File - Linked = UNCHECKED" and then insert as linked picture'. b) "Crash Protection" of (a) only works as long as unlinkec.SVG is in .DWG, CRASH reappears if unlinked.SVG has been deleted before I insert linked.SVG c) For me already crashes with 3.4.1 Revision 1372282
No crash with Impress Rev. 1503704 Win 7.
@Edwin: You have insert as _linked_ picture?
This is what I did: http://screencast.com/t/QRDwDT3p PS since comment 2 updated revision.
@Edwin: That is embedded. In the import dialog is a checkbox "Link" (bottom, center). You have to check it to get a linked graphic.
I get the crash now...
Created attachment 81338 [details] printf results I have made some printf. In the crash case there are three faulty calls to SvgDocHdl::startElement and SvgImageNode::decomposeSvgNode after the correct one. I'll attach the two source files with the printf, so that you can see where printf are; and the print result for inserting as embedded graphic, and the print result for inserting as linked graphic. Perhaps it helps a little bit.
Investigation reveals the following: - Intrinsic import of SVG graphic goes well. - Triggered via <sd::View::CheckPossibilities> another decomposition of the SVG graphic takes place which does not have the file path to the imported SVG graphic. When trying the resolve the path to the inner linked graphic using <rtl::Uri::convertRelToAbs( rPath, maUrl )> a <MalformedUriException> exception is thrown, because <rPath> is an empty string. The exception is not caught --> crash.
I am able to reproduce this bug by importing a SVG diagram into Writer (in 4.0.1). The diagram imports into the Writer document properly, and I'm even able to print a PDF, but soon after the Writer app is in the background it crashes with exception of type rtl::MalformedUriException. This is on MacOS 10.9.1 with OOo 4.0.1.
I will have a look...
The SVG interpreter needs a valid path when the SVG contains links itself, this is the base to resolve the links. This path is missing, mainly because the link reloader in ImpLoadLinkedGraphic (which is a local helper to SdrGrafObj) does not give it to the GraphicFilter::ImportGraphic call. It does not give it since it previously opens the file data itself using an SfxMedium instance and a DownLoad call, constructing an own local SvStream with the file data. This means that theoretically every GraphicFileFormat which contains links itself will fail and that the same sh<back><back> thing is done in the other applications somewhere.
Added code to the SVG interpreter to not crash but assert when the absolute link to itself (the file) is missing and a link is to be interpreted. Checking now if handing over the path in ImpLoadLinkedGraphic works...
Works like a charm; now I need to test if normal links still work (checked what GraphicFilter::ImportGraphic does with the given filename, is not used in the given configuration and thus should be okay). Also need to see what the other apps do in the same situation - or better where is the same problem in the other apps?
Writer imports okay, but looses linked image on reload (there was the crash before in SVG interpreter). Seems as if here the problem is in SvFileObject::GetGraphic_Impl. Checking...
Works as expected, all good after reload. Checking Calc...
Calc works well due to the changes in ImpLoadLinkedGraphic for SdrGrafObj. All apps allow insert and save/reload cycle with the changes applied. Doing some more tests with other linked graphics...
In all apps modified link, broke link, all with in-between save and reload, all work well. Used bitmap graphics linked and unlinked. Preparing commit...
"alg" committed SVN revision 1558977 into trunk: i123042 corrected reload of linked content to have access to it's own path
Okay, done. Interesting is if all the helpers in svdograf.cxx like SdrGraphicUpdater and SdrGraphicLink may be replaceable with SvFileObject as Writer uses it...
Verified on Ubuntu 10.04 (64bit) with build from branch AOO410 (rev. 1583666) Verified on Windows 7 with local build of branch AOO410, rev. 1582710 and with buildbot build, rev. 1582709