Issue 124608 - SVG export of a selected area causes the whole canvas to be exported
Summary: SVG export of a selected area causes the whole canvas to be exported
Status: CLOSED FIXED
Alias: None
Product: Draw
Classification: Application
Component: ui (show other issues)
Version: 4.1.0-dev
Hardware: All All
: P2 Normal (vote)
Target Milestone: 4.1.1
Assignee: Armin Le Grand
QA Contact:
URL:
Keywords:
: 125277 (view as issue list)
Depends on:
Blocks:
 
Reported: 2014-04-05 17:22 UTC by Thorsten Wagner
Modified: 2014-07-24 14:08 UTC (History)
5 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: 4.1.0-dev
Developer Difficulty: ---
jsc: 4.1.1_release_blocker+


Attachments
Sample drawing (10.00 KB, application/vnd.oasis.opendocument.graphics)
2014-04-05 17:23 UTC, Thorsten Wagner
no flags Details
Export to SVG (4.36 KB, image/svg+xml)
2014-04-05 17:23 UTC, Thorsten Wagner
no flags Details
Export to EPS (45.29 KB, application/postscript)
2014-04-05 17:24 UTC, Thorsten Wagner
no flags Details
Export to PNG (83.93 KB, image/png)
2014-04-05 17:24 UTC, Thorsten Wagner
no flags Details
Patch to implement last suggestion (6.99 KB, patch)
2014-04-08 15:41 UTC, Armin Le Grand
no flags Details | Diff
Screenshot of Quick Look Preview (77.09 KB, image/png)
2014-04-10 23:06 UTC, Thorsten Wagner
no flags Details

Note You need to log in before you can comment on or make changes to this issue.
Description Thorsten Wagner 2014-04-05 17:22:52 UTC
When selecting and exporting an area to SVG the selection is ignored and the whole canvas is exported instead.

Steps to reproduce:

(1) Load sample drawing (attached to the ticket)

(2) Select a subset of objects

(3) Export selection to SVG (see attached file "Sample.svg")

Exporting to some other formats, e.g. EPS or PNG is working correctly (see attached files "Sample.eps", "Sample.png"), only the selected objects are exported.

The problem appears on Mac OS X 10.9.2 with OpenOffice 4.1 revision 1572744 from trunk, but seems to exist in earlier revisions too.
Comment 1 Thorsten Wagner 2014-04-05 17:23:27 UTC
Created attachment 83094 [details]
Sample drawing
Comment 2 Thorsten Wagner 2014-04-05 17:23:51 UTC
Created attachment 83095 [details]
Export to SVG
Comment 3 Thorsten Wagner 2014-04-05 17:24:05 UTC
Created attachment 83096 [details]
Export to EPS
Comment 4 Thorsten Wagner 2014-04-05 17:24:26 UTC
Created attachment 83097 [details]
Export to PNG
Comment 5 Edwin Sharp 2014-04-06 06:45:55 UTC
Confirmed with
AOO410m15(Build:9761)  -  Rev. 1583666
2014-04-01 13:50 - Linux x86_64
Debian
Comment 6 Armin Le Grand 2014-04-07 08:45:13 UTC
Confirmed, grepping
Comment 7 Armin Le Grand 2014-04-07 09:57:57 UTC
The current SVG export is page-oriented by purpose and does not take the selection into account. It will also export all pages when triggered using the file/export path. Checking if and how this could be improved...
Comment 8 Armin Le Grand 2014-04-07 10:26:38 UTC
The current page is taken into account (SVGFilter::filter), but the property 'SelectionOnly' is ignored (but set as it seems)...
Comment 9 Ariel Constenla-Haile 2014-04-07 11:31:20 UTC
This was already reported in Bug 56084
Comment 10 Armin Le Grand 2014-04-07 12:40:43 UTC
Added code to svg exporter to work with the current selection if the selection flag is set in the export dialog. It will stop the export when the flag is set and no objects are selected. The exporter will use the single page export. If a selection is given it is used instead of the page content. This needed to be done in multiple places to have the correct export preparations and content handling. The MasterPage is not exported in the case of selection. If the SVG exporter gets an empty selection the fallback to export the whole page is used to be on the safe side when others have implemented using the SVG exporter as a service.
The SVG export size is still the PageSize. I thought about changing this to the BoundRect of the selection, but using the PageSize is also a kind of applied cropping in SVG in the sense of 'notheing exists outside the Page' which I think is better to keep.
Doing some more tests with MasterPage content and e.g. Font Embedding functionalities...
Comment 11 Armin Le Grand 2014-04-07 12:41:24 UTC
Hi Ariel, thanks for finding it. I started with this one now, should we set the older one as double...?
Comment 12 Armin Le Grand 2014-04-07 12:46:41 UTC
Cecked what happens in MasterPage view. Without selection the whole DrawPage is exported, including the MasterPage, this is the same as before my change. With selected objects on the MasterPage only these selected from the MasterPage get exported, as it should be. Doing some more checks...
Comment 13 Ariel Constenla-Haile 2014-04-07 12:51:44 UTC
(In reply to Armin Le Grand from comment #11)
> Hi Ariel, thanks for finding it. I started with this one now, should we set
> the older one as double...?

IMO it's not a duplicated, because the other one is about two filters, as said bug 56084 comment 9 it should depend on two separated bugs for each filter.
Comment 14 Edwin Sharp 2014-04-07 13:59:11 UTC
this issue: svg
issue 56084: swf
Comment 15 SVN Robot 2014-04-07 14:58:02 UTC
"alg" committed SVN revision 1585498 into trunk:
i124608 Added functionality to export only selected objects in SVG export
Comment 16 Armin Le Grand 2014-04-07 14:58:29 UTC
Okay, done.
Comment 17 Thorsten Wagner 2014-04-07 21:51:19 UTC
Exporting selections as SVG images works correctly now.

As mentioned by Armin the whole canvas (without the objects not selected) is exported. This is not the behaviour I would expect. Exporting to other images typs, e.g. PNG, JPEG, EPS causes only the canvas area covered by the selection to be exported.

I set the status of the ticket to "REOPENED".
Comment 18 Edwin Sharp 2014-04-08 06:26:38 UTC
(In reply to Thorsten Wagner from comment #17)
> I set the status of the ticket to "REOPENED".

You can do that only after checking revision 1585498.
Comment 19 Armin Le Grand 2014-04-08 09:57:17 UTC
@Edwin: I think Thorsten talks about the PageSize still used; I imply he has an own AOO build, got the needed revision, built and checked it.

@Thorsten: As argued in comment 10, I think keeping it that way is the best for SVG export for now. I see your point (was my first thought, too), but there are arguments for both. Here are some more:

- for SVG the FileSize will not increase by keeping page oriented (compared with bitmap graphics where this would be fatal)

- When using BoundRange, the objects have to be translated and will lose their original geometric definitions - if a user exports selections and wants to combine these later in some tooling he will have to deal with that - this will lead to feature requests to allow page-oriented exports (I would bet)

As a compromize I checked the following (full example exported): We may change the values for <svg ...> directly to

<svg width="180mm" height="130mm" viewBox="6000 2000 18000 13000">

compared to 

<svg width="280mm" height="210mm" viewBox="0 0 28000 21000">

That also works and may have the most benefits.
@Regina: I saw you on CC, what do you think...?
Comment 20 Armin Le Grand 2014-04-08 15:41:34 UTC
Created attachment 83138 [details]
Patch to implement last suggestion
Comment 21 Regina Henschel 2014-04-08 21:15:28 UTC
I think, that width and height in the svg-element should be the exact, real size of the selected drawing. An exported graphic should have the same size as can be seen on the selected objects in the status bar or position&size dialog inside Draw/Impress.
In SVG specification section "5.1.2 The ‘svg’ element", on the attribute width, "For outermost svg elements, the intrinsic width of the SVG document fragment."

I do not understand the left/top values in viewBox="6000 2000 18000 13000". Shouldn't it be viewBox="0 0 18000 13000"?
Comment 22 Thorsten Wagner 2014-04-08 21:47:08 UTC
(In reply to Regina Henschel from comment #21)

Regina, I agree completely. Canvas width and height should match the selection.

6000/2000 is the horizontal/vertical offset of the selection when selecting all objects of the sample drawing.
Comment 23 Armin Le Grand 2014-04-09 09:19:03 UTC
@Regina: TopLeft have to be adapted in the viewBox, else the top left unused part of the content will be visualized (by all SVG viewers I have checked).

@Thorsten: Have you applied my patch, rebuilt (filter module) and checked if this works as intended? I plan to apply that patch.

Both: What do you think about issue 56084? It's the same question ragarding staying page-oriented or not, but I think for swf as an animation format it makes less sense to 'zoom' on the selected objects, what do you think?
Comment 24 Armin Le Grand 2014-04-10 15:02:57 UTC
Rechecked patch, works well, committed, done.
Comment 25 SVN Robot 2014-04-10 15:06:28 UTC
"alg" committed SVN revision 1586325 into trunk:
i124608 when exporting selection, use selection boundrect as svg canvas
Comment 26 Thorsten Wagner 2014-04-10 23:05:34 UTC
Armin, thank you for your patch. It works, but the canvas size doesn't seem to be reduced (see screenshot). Although the selected content is aligned top left, the canvas size seems to be the original canvas size of the whole image. I would expect a reduced canvas size matching the size of the selection.

Concerning SWF I would expect a reduced canvas size too. The SWF format is not only an animation format, SWF is capable to show embedded images (vector graphics as well as raster graphics). I assume exports from Draw are SWF files with embedded vector graphics. From this point of view the handling should be similar to SVG.
Comment 27 Thorsten Wagner 2014-04-10 23:06:53 UTC
Created attachment 83164 [details]
Screenshot of Quick Look Preview
Comment 28 Armin Le Grand 2014-04-14 08:33:59 UTC
Hi Thorsten,

I re-checked and the canvas size is reduced as needed, open the SVG itself and check please. I do not know what your viewer does, but please use other viewers to proove (e.g. Inkscape or office itself) to see that it works as intended. Even your viewer is 'hiding' a littlte piece of the right side of the circle (again the LineWidth story) which shows that it knows about the reduced canvas size, but does not show it.
For swf: see comments in issue 56084, too dangerous for now with the current geometry usage...
Comment 29 Thorsten Wagner 2014-04-14 19:32:17 UTC
Armin, you are right. I rechecked and found the width and height of the Quick Look window equal independent from the SVG file shown. Sorry for the inconvenience.

Concerning SWF drawing tools like Impress or Draw are no mainstream tools for creating SWF files. Not fixing the SWF export now is probably no problem.
Comment 30 Ariel Constenla-Haile 2014-07-19 17:23:38 UTC
*** Issue 125277 has been marked as a duplicate of this issue. ***
Comment 31 Ariel Constenla-Haile 2014-07-19 17:30:45 UTC
@Armin: is it safe to integrate these changes in branch AOO410? (It looks like they took your fix somewhere else and already released it)
Comment 32 Armin Le Grand 2014-07-21 09:49:53 UTC
@Ariel: Yes, safe from my POV. It's not a crash, but let's ask the release manager (setting the flag).
Comment 33 jsc 2014-07-21 11:00:19 UTC
grant showstopper flag, fix available
Comment 34 Armin Le Grand 2014-07-21 14:19:41 UTC
Integrated revision 1585498 (comment 15) and revision 1586325 (comment 25) to AOO410 branch, doing some more checks. Target already adapted.
Comment 35 Armin Le Grand 2014-07-21 14:56:45 UTC
Tested and looks good, preparing commit.
Comment 36 SVN Robot 2014-07-21 14:57:52 UTC
"alg" committed SVN revision 1612298 into branches/AOO410:
i124608 Added functionality to export only selected objects in SVG export
Comment 37 Armin Le Grand 2014-07-21 14:58:08 UTC
Okay, done.
Comment 38 Pedro 2014-07-24 14:08:59 UTC
Confirmed fixed in AOO411m3(Build:9773) - Rev. 1612804 under Windows XP
Well done!