Apache OpenOffice (AOO) Bugzilla – Issue 124608
SVG export of a selected area causes the whole canvas to be exported
Last modified: 2014-07-24 14:08:59 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.
Created attachment 83094 [details] Sample drawing
Created attachment 83095 [details] Export to SVG
Created attachment 83096 [details] Export to EPS
Created attachment 83097 [details] Export to PNG
Confirmed with AOO410m15(Build:9761) - Rev. 1583666 2014-04-01 13:50 - Linux x86_64 Debian
Confirmed, grepping
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...
The current page is taken into account (SVGFilter::filter), but the property 'SelectionOnly' is ignored (but set as it seems)...
This was already reported in Bug 56084
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...
Hi Ariel, thanks for finding it. I started with this one now, should we set the older one as double...?
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...
(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.
this issue: svg issue 56084: swf
"alg" committed SVN revision 1585498 into trunk: i124608 Added functionality to export only selected objects in SVG export
Okay, done.
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".
(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.
@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...?
Created attachment 83138 [details] Patch to implement last suggestion
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"?
(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.
@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?
Rechecked patch, works well, committed, done.
"alg" committed SVN revision 1586325 into trunk: i124608 when exporting selection, use selection boundrect as svg canvas
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.
Created attachment 83164 [details] Screenshot of Quick Look Preview
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...
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.
*** Issue 125277 has been marked as a duplicate of this issue. ***
@Armin: is it safe to integrate these changes in branch AOO410? (It looks like they took your fix somewhere else and already released it)
@Ariel: Yes, safe from my POV. It's not a crash, but let's ask the release manager (setting the flag).
grant showstopper flag, fix available
Integrated revision 1585498 (comment 15) and revision 1586325 (comment 25) to AOO410 branch, doing some more checks. Target already adapted.
Tested and looks good, preparing commit.
"alg" committed SVN revision 1612298 into branches/AOO410: i124608 Added functionality to export only selected objects in SVG export
Confirmed fixed in AOO411m3(Build:9773) - Rev. 1612804 under Windows XP Well done!