Issue 124143 - glue points on svg graphics are not read, when order in file format is first svg second png
Summary: glue points on svg graphics are not read, when order in file format is first ...
Status: CLOSED FIXED
Alias: None
Product: Draw
Classification: Application
Component: open-import (show other issues)
Version: 4.1.0-dev
Hardware: All All
: P3 Normal (vote)
Target Milestone: 4.1.0
Assignee: Armin Le Grand
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-01-29 14:04 UTC by Regina Henschel
Modified: 2017-05-20 10:35 UTC (History)
2 users (show)

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


Attachments
Additional glue points on svg graphic, produced by LibreOffice. (14.47 KB, application/vnd.oasis.opendocument.graphics)
2014-01-29 14:04 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 2014-01-29 14:04:55 UTC
Created attachment 82430 [details]
Additional glue points on svg graphic, produced by LibreOffice.

If the order of image is first svg, second png, then additional glue points are not read. Such files are generated be LO, see the attached document. When the order is first png, second svg (as written by AOO), then the glue points are correctly read.
Comment 1 Armin Le Grand 2014-01-31 21:45:16 UTC
There is a reason to first write PNG: All used older office versions before the change will *not* be able to load files where the SVG is first, so I strongly recommend to keep that order, also strongly recommend that order to any other ODF writing application.
I can have a look at it, though. I guess ODF allows both, so it at least is a valid ODF file.
Comment 2 Armin Le Grand 2014-02-03 20:22:43 UTC
Taking a look, strage, the GluePoints are outside the graphics as it should be...
Comment 3 Armin Le Grand 2014-02-04 00:41:10 UTC
Regina, indeed a strange handling is involved here. Problem is the import structure the xml importer is using. When e.g. a rectangle is used, the GluePoints are part of the draw:rect element. Example (a):

        <draw:rect draw:style-name="gr2" draw:text-style-name="P1" draw:layer="layout" svg:width="8.4cm" svg:height="6.6cm" svg:x="5.4cm" svg:y="20.5cm">
          <draw:glue-point draw:id="4" svg:x="-2.142cm" svg:y="-1.666cm"/>
          <draw:glue-point draw:id="5" svg:x="-1.547cm" svg:y="0.454cm"/>
          <draw:glue-point draw:id="6" svg:x="0.714cm" svg:y="-0.606cm"/>
          <draw:glue-point draw:id="7" svg:x="2.857cm" svg:y="2.727cm"/>
          <text:p/>
        </draw:rect>

For GraphicObject, a draw:frame is used, which has as members a number of draw:image which all represent the same image in various possible resolutions, and the draw:glue-point also. Example (b):

        <draw:frame draw:style-name="gr1" draw:text-style-name="P1" draw:layer="layout" svg:width="14.138cm" svg:height="14.138cm" svg:x="3.3cm" svg:y="2.462cm">
          <draw:image xlink:href="Pictures/100002010000021600000216274DD2E6.png" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
          <draw:image xlink:href="Pictures/10000FF90000373B0000373BA044D74E.svg" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad">
            <text:p/>
          </draw:image>
          <draw:glue-point draw:id="4" svg:x="-1.18cm" svg:y="-1.295cm"/>
          <draw:glue-point draw:id="5" svg:x="-1.039cm" svg:y="-0.163cm"/>
          <draw:glue-point draw:id="6" svg:x="-0.048cm" svg:y="-0.234cm"/>
          <draw:glue-point draw:id="7" svg:x="0.729cm" svg:y="0.756cm"/>
          <draw:glue-point draw:id="8" svg:x="1.719cm" svg:y="0.26cm"/>
        </draw:frame>

The importer starts creating the needed xShape (the model object) in case (a) with reading draw:rect, the draw:glue-point are then added to the current xShape (which is the rectangle). This workls.

In case (b) the xShape gets not created with the start of draw:frame, but with the start of draw:image, so in the example two xShapes are created and later the most valuable is kept and the others are thrown away again. Problem is that here also the draw:glue-point will be added to the 'current' xShape, thus always in the example to the 2nd one. If the 2nd one is thrown away, the GluePoints are gone.
Theoretically (not tried) this also means that when the draw:glue-point would be added to the draw:frame before the draw:image these will be lost or added to the xShape imported before since it would be the 'current' xShape.

To really do this in a clean way would mean to rewrite the importer for the draw:frame case what is too expensive for now. I will try to move the read GluePoints to the correct target shape at decision time (when the images with less quality get thrown away)...
Comment 4 Armin Le Grand 2014-02-04 17:39:39 UTC
Added methods to rescue already added GluePoints from a source shape and context to a destination one by copying. This will produce the same data as if the GluePoints were directly added to the destination. The critical point is to get back the original mapping ID read at GluePoint import time (in the ODF thats the draw:id from a draw:glue-point), but got that working.
Cheked with provided sample, but also with hand-made tests (by exchanging the draw:image entries), works as intended. Preparing commit...
Comment 5 SVN Robot 2014-02-04 17:42:06 UTC
"alg" committed SVN revision 1564400 into trunk:
i124143 for draw:frame containing multiple draw:image and draw:glue-point it ...
Comment 6 Armin Le Grand 2014-02-04 17:42:35 UTC
Okay, done.
Comment 7 Regina Henschel 2014-08-01 15:41:35 UTC
Verified on AOO411m4(Build:9774)  -  Rev. 1614049 (=RC1)