Issue 118728

Summary: linked svg graphic looses link
Product: Writer Reporter: Regina Henschel <rb.henschel>
Component: open-importAssignee: Armin Le Grand <Armin.Le.Grand>
Status: CLOSED FIXED QA Contact:
Severity: Normal    
Priority: P5 (lowest) CC: bjdujing, issues, rbircher
Version: 3.4.0 Beta (OOo)   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Issue Type: DEFECT Latest Confirmation in: ---
Developer Difficulty: ---
Attachments:
Description Flags
svg graphic for testing none

Description Regina Henschel 2012-01-05 16:18:34 UTC
Created attachment 77102 [details]
svg graphic for testing

Save the attached svg-graphic to your PC.
Open a new Writer document.
Insert the svg-graphic as linked graphic.
Save the document and close it.
Reopen the document.

Notice the read error. The link is still listed in Edit > Links..., but the graphic is not loaded.
Comment 1 Raphael Bircher 2012-01-07 08:46:07 UTC
Please put confirmed issues directly to NEW

Changed Status: NEW
Comment 2 Armin Le Grand 2012-01-10 15:36:01 UTC
ALG: Happens as desrcibed. The 'Read error' also comes up initially with e.g. a gif, but Writer will then load and show it. Checking where the difference is between a gif Writer graphic object and a Svg one...
Comment 3 Armin Le Grand 2012-01-10 16:17:04 UTC
ALG: Seems as if the Svg provided does not have a DOCTYPE identifier which I used for Svg identification in ImpPeekGraphicFormat (svtools). Checking Svg spec if this is allowed to not have it...
Comment 4 Regina Henschel 2012-01-10 16:33:30 UTC
Hi Armin, it is recommended not to have it, see http://www.w3.org/TR/SVG/intro.html#MIMEType, last sentence.
Comment 5 Regina Henschel 2012-01-10 17:40:29 UTC
now the correct one http://www.w3.org/TR/SVG/intro.html#NamespaceAndDTDIdentifiers
Comment 6 Armin Le Grand 2012-01-11 09:36:31 UTC
ALG->Regina: Thanks for the hint, very useful. I already looked at that definitions. I formally used the following checks (for the first 256 bytes):

- 'DOCTYPE' is part of it
- 'svg' is part of it

I now modified to use:

- '<?xml' -> identify as Xml at all
- 'version' -> also Xml, but also Svg
- 'www.w3.org' -> has to do with w3, part of Svg namespace definition
- '<svg' -> contains (at least) one Svg node

Comments?
Comment 7 Armin Le Grand 2012-01-11 11:44:34 UTC
ALG: Comitted, waiting for comments, but done so far.
Comment 8 Regina Henschel 2012-01-11 20:39:17 UTC
If the document has a Doctype declaration, it is possible, that '<svg' is not inside the first 256 bytes. This happens, because it is allowed that a Doctype contains an internal DTD subset. Such an example is given in chapter "3.2.  SVG as the Host Language" in http://www.w3.org/TR/XHTMLplusMathMLplusSVG/.

Therefore the simple test '<svg' might fail.
Perhaps a combining test with '<svg' || ('DOCTYPE' && 'svg') is safer.
Comment 9 Armin Le Grand 2012-01-12 13:08:30 UTC
ALG: You are correct, I stubled already over files with lot of comment text where '<svg' was outside the 1st 256 bytes. I have now changed to do the following:

(1) if(check('<?xml', 256) && check('version', 256)))
(2)   if(check('DOCTYPE', 256) && check('svg', 256))
(3)   else if(check('<svg', 256))
(4)   else if(check('<svg', fullsize))
(5)     is_svg;

Seems okay and handles all cases I stumbled upon. If 1-3 fails, evtl. the full file is checked, but should happen very rarely.
Comment 10 Armin Le Grand 2012-01-16 14:40:04 UTC
ALG: Woks as expected, checked in, done.
Comment 11 Du Jing 2012-09-21 03:19:21 UTC
verified on the build AOO3.5_r1387482