Issue 118783 - svg export produces invalid file
Summary: svg export produces invalid file
Alias: None
Product: Draw
Classification: Application
Component: save-export (show other issues)
Version: recent-trunk
Hardware: PC Windows XP
: P5 (lowest) Normal (vote)
Target Milestone: ---
Assignee: Armin Le Grand
QA Contact:
Depends on:
Reported: 2012-01-14 16:15 UTC by Regina Henschel
Modified: 2017-05-20 10:31 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---

Source for the svg file. (7.73 KB, application/
2012-01-14 16:15 UTC, Regina Henschel
no flags Details
result of export to svg (969 bytes, image/svg+xml)
2012-01-14 16:16 UTC, Regina Henschel
no flags Details

Note You need to log in before you can comment on or make changes to this issue.
Description Regina Henschel 2012-01-14 16:15:16 UTC
Created attachment 77131 [details]
Source for the svg file.

Open the attached document and export the combined rectangles to svg. I get the attached result.

It is not valid, because
(1) an id value must be unique, but is assigned twice.
(2) an id value must not contain the characters ( or ) .
Comment 1 Regina Henschel 2012-01-14 16:16:17 UTC
Created attachment 77132 [details]
result of export to svg
Comment 2 Armin Le Grand 2012-01-14 18:09:17 UTC
ALG: Taking alook...
Comment 3 Regina Henschel 2012-01-14 19:23:35 UTC
There is no need for the second path element for the inner stroke, because svg handles elements with more then one closed subpath as AOO handles polypolygons. So on export it is sufficient to export the polypolygon itself. And with the new svg import those paths are shown correct too. So I suggest to drop the additional path element as solution for problem (1).
Comment 4 Armin Le Grand 2012-01-16 10:45:44 UTC
ALG: Doing what is explained does not export the original Svg file, but uses the built-in existing Svg exporter, so the exported Svg will not be equal to the original one. To export the original one, use 'Save as Picture...' in the context menu of the graphic object.

ALG: Looking at the existing Svg export...
Comment 5 Armin Le Grand 2012-01-16 12:07:38 UTC
ALG: (2) Seems to be correct, checked ( I think about replacing '(' and ')' by just '_'.

(1) Is more complicated: The 1st path is already the PolyPolygon suggested (see the 'Z' statements in svg:d or delete 2nd path in an editor). The question is more why the 2nd path is written at all, describing the inner polygon of a PolyPolygon. Investigating...
Comment 6 Armin Le Grand 2012-01-16 12:37:25 UTC
ALG: (1) is tricky; The current Svg exporter works using Metafiles, not primitives. In Metafiles the stroke actions (even the SvtGraphicStroke helper in the comment action) use no PolyPolygon, but single polygons. Thus, the resulting Metafile has thee basic polygon actions:
- the filled PolyPolygon
- the outer stroke polygon
- the inner stroke polygon
what is correct so far. The Svg exporter tries to combine the 1st SvtGraphicFill with the 2nd SvtGraphicStroke WITHOUT comparing the paths on equality, thus the 1st and 2nd action get combined to one path statement in the export. The 3rd starts a new path segment, this time only stroked.

The error happens in the Svg exporter; it cannot combine PolyPolygon fill with Polygon stroke actions (also to mark: basing the Svg exporter to primitives would also solve this). Thus, in the case of stroked PolyPolygons it will either be possible to more intelligently combine those or not.

Checking if this is possible; it's not planned to be done, this can be read from looking at the code...
Comment 7 Armin Le Grand 2012-01-16 14:24:28 UTC
ALG: Solved (1) by forcing write of fill data when stroke data is not equal, also need to add a 2nd number to the ID since ID is not only object number but multiple svg elements could be written per shape. Solved (2) by using '_' instead of '(' and ')'. Also made 'Z' svg:d creation dependent of closed state of the tool spolygon (1st and last point are equal), not only on fill and/or line. Also had to be very careful for polygon comarison; operator== does not do what YOu expect, there is a method IsEqual() instead. Argh! Old classes...
Comment 8 Armin Le Grand 2012-01-16 14:31:08 UTC
ALG: Comitted, done.