Bug 105588 - SVG exported from Impress or Draw cannot be correctly inserted as an image into another document
Summary: SVG exported from Impress or Draw cannot be correctly inserted as an image in...
Status: RESOLVED WORKSFORME
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: filters and storage (show other bugs)
Version:
(earliest affected)
5.2.4.2 release
Hardware: x86-64 (AMD64) All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: bibisectNotNeeded, regression
Depends on:
Blocks: SVG-Save
  Show dependency treegraph
 
Reported: 2017-01-28 22:34 UTC by peter.sebregondi
Modified: 2022-03-05 03:38 UTC (History)
8 users (show)

See Also:
Crash report or crash signature:


Attachments
example shapes to export as selection (11.36 KB, application/vnd.oasis.opendocument.presentation)
2021-06-26 07:29 UTC, Stéphane Guillou (stragu)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description peter.sebregondi 2017-01-28 22:34:47 UTC
Description:
I have opened a pptx in Impress. Then I have exported a drawing group as a selection in SVG format. 
This SVG (created by Impress) can be opened in the Windows Edge browser and looks good. 
However, when I try to insert this SVG in a docx or odt in Writer, only a little anchor and a little green square are shown. The anchor and the square disappear when I click into the text.

A test with an Inkscape SVG showed that it can be inserted in both a docx and an odt in Writer.
Disabling OpenGL did not help. 
So, inserting an Inkscape SVG in Writer works, but inserting an Impress SVG works not. 

Steps to Reproduce:
1.Steps are described in the description.
2.I went through the same steps 4x
3.

Actual Results:  
See description

Expected Results:
Writer should have successfully inserted the Impress-SVG both in docx and odt.


Reproducible: Always

User Profile Reset: No

Additional Info:


User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.76 Safari/537.36
Comment 1 V Stuart Foote 2017-01-29 01:12:57 UTC
On Windows 10 Pro 64-bit en-US with
Version: 5.3.0.3 (x64)
Build ID: 7074905676c47b82bbcfbea1aeefc84afe1c50e1
CPU Threads: 8; OS Version: Windows 6.19; UI Render: GL; Layout Engine: new; 
Locale: en-US (en_US); Calc: group

Confirmed. But it is not limited to opening a PPTX document into Impress and selecting draw objects.

Rather you can simply create a new blank slide, adding Draw objects with text annotation, and Text boxes--selection of a group of objects and Exporting as SVG results in an .SVG image that does not cleanly render back to a Draw or Writer document canvas.

But issue also happens when exporting the entire slide--so not limited to export of selection ( http://opengrok.libreoffice.org/xref/core/filter/source/svg/svgfilter.cxx#228 ) rather it seems more like some import filter misformatting reading the extent of the SVG

Edge, Internet Explorer, Firefox have no issue with opening the SVG. Imagemagik's IMDisplay viewer renders it blank. Inkscape opens it but with large pixel counts, e.g. 22k x 30k size. 

Draw will open the SVG (either the selection or the full slide) but no text annotations.

Inserting the SVG in LO modules: it reads a diminutive extent on the document canvas for Writer as noted in OP, while insert into Draw or Impress shows nothing.

So not clear if the issue is the export filter, or the import filter or a combination of both.
Comment 2 Iain Waugh 2017-01-29 05:57:03 UTC
I am also seeing this bug.  It used to work in LibreOffice v5.1.3, but wasn't working in 5.2.1.

As a side note, a Draw SVG export from v5.1.3 uses 24kB; the same export from v5.2.1 uses 300kB.  Most of the extra size is taken up with Javascript.
Comment 3 Regina Henschel 2017-01-29 22:55:29 UTC
Search for attribute "visibility" in the svg file. It has the wrong value "hidden". Exchange for example
<g visibility="hidden">
with
<g visibility="visible">

Then the import should work.

Please report back, whether such repaired svg will import in your case too.
Comment 4 V Stuart Foote 2017-01-30 02:47:20 UTC
(In reply to Regina Henschel from comment #3)
> Search for attribute "visibility" in the svg file. It has the wrong value
> "hidden". Exchange for example
> <g visibility="hidden">
> with
> <g visibility="visible">
> 
> Then the import should work.
> 
> Please report back, whether such repaired svg will import in your case too.

Yes. If I edit the SVG in text editor (VI) and set the <g class="SlideGroup"> object's <g visibility="hidden"> to <g visibility="visible"> the SVG inserts into Draw/Impress and Writer cleanly.

Checked a 5.1.6.2 export to SVG, the <g visibility=""> is not set.
Comment 5 peter.sebregondi 2017-01-30 10:08:47 UTC
Exporting a selection of a pptx slide in Impress does not work anymore. 
A 366KB SVG is created, but both Microsoft Edge and Chrome bring the same error message: "An unexpected error occurred. The presentation engine will be stopped". 
However, exporting the whole slide still works, it creates a 367KB SVG.
Comment 6 peter.sebregondi 2017-01-30 11:07:07 UTC
On another PC, in Writer 5.1.0.3, the Impress5.2.4.2-selection-SVG was inserted in a docx, but only the text, no graphical elements such as shapes.
Comment 7 peter.sebregondi 2017-01-30 16:39:39 UTC
An Impress 5.2.5.1 selection SVG export (from a pptx drawing group) is shown correctly in Inkscape 0.92.
Chrome and Edge cannot handle this selection SVG, however.
Comment 8 peter.sebregondi 2017-01-30 19:45:21 UTC
Writer 5.2.5.1 does not insert any SVG that was exported from a pptx in Impress 5.2.5.1.
Comment 9 Regina Henschel 2017-01-31 14:25:19 UTC
There exist several problems in svg export. I have written the bugs 105636, 105639, 105641 and 105642 for some of them. So this bug should be for the false "hidden" value.

This false value is set in method SVGFilter::implExportDrawPages in file filter/source/svg/svgexport.cxx around line 1503.

Unfortunately setting the default to "visible" will show all slides together when the file is opened in a browser. So that would not fix the problem.

I expected, that the first slide - and in case of a selection of single objects the only one - is set to "visible" and only the other slides are set to "hidden".

I think, that there is a real bug, because the comment there,
 "// In case the exported slides are more than one the initial
  // visibility of each slide is set to 'hidden'. "
indicates, that the expected behavior was intended for a selection of objects. But it doesn't work.
Comment 10 QA Administrators 2018-02-01 03:44:38 UTC Comment hidden (obsolete)
Comment 11 ion_nsk_region 2020-06-03 07:18:39 UTC
The bug is still actual for LibreOffice Impress Version: 6.0.7.3
Selection of objects is exported as SVG with 
==================================
<g visibility="hidden">
==================================
Image is shown as blank white page in browsers (Firefox 76.0.1, Chromium 81.0.4044.138).
When image inserted back to Impress, it is not shown as all.
When image inserted into Writer, there are green squares for resizing (located almost one onto another) and anchor, but still, there is no image content.
If I set 
==================================
<g visibility="visible">
==================================
then image is properly shown in browsers. However, upon saving in Inkscape as Inkscape SVG, it become hidden again. Upon saving as optimized SVG, image content is visible and working fine for browsers, and for import to Impress.
Comment 12 Stéphane Guillou (stragu) 2021-06-26 07:27:33 UTC
Using the following steps:

1. In Impress, create two shapes
2. Select both with Shift + Click
3. Right click > Export...
4. Tick "Selection", export to SVG
5. Insert or drag-and-drop resulting file into Impress or Writer

With LO 7.0.6, 7.2 beta1, and 7.3 alpha1, I was able to insert the image in Writer or Impress and see it.
It was also visible in Firefox 89, Inkscape 0.92, gThumb, Sozi and GIMP.

No "visibility" setting found in the source.

However, exporting the whole slide (i.e. not ticking "selection" in the export dialogue) does export with <g visibility="hidden"> tags.
The resulting SVG can be seen fine when imported in Impress and Writer, and opened in Firefox and Inkscape, but requires switching the tags to <g visibility="visible"> to work in GIMP, Sozi and gThumb.

I think this bug should be a WORKSFORME and possibly a different bug should be opened about the "hidden" tags in whole-slide SVG exports.

Version: 7.3.0.0.alpha0+ / LibreOffice Community
Build ID: f446a203fa2897bab8ae7686c948a8bf060675c6
CPU threads: 8; OS: Linux 4.15; UI render: default; VCL: gtk3
Locale: en-AU (en_AU.UTF-8); UI: en-US
TinderBox: Linux-rpm_deb-x86_64@86-TDF, Branch:master, Time: 2021-06-24_15:16:38
Calc: threaded

Version: 7.2.0.0.beta1 / LibreOffice Community
Build ID: c6974f7afec4cd5195617ae48c6ef9aacfe85ddd
CPU threads: 8; OS: Linux 4.15; UI render: default; VCL: gtk3
Locale: en-AU (en_AU.UTF-8); UI: en-US
Calc: threaded

Version: 7.0.6.2
Build ID: 144abb84a525d8e30c9dbbefa69cbbf2d8d4ae3b
CPU threads: 8; OS: Linux 4.15; UI render: default; VCL: gtk3
Locale: en-AU (en_AU.UTF-8); UI: en-US
Calc: threaded
Comment 13 Stéphane Guillou (stragu) 2021-06-26 07:29:48 UTC
Created attachment 173218 [details]
example shapes to export as selection

For completeness sake, here is an example file I used.

Select both shapes > export _selection_ to SVG.
Comment 14 skierpage 2022-03-04 09:42:21 UTC
(In reply to stragu from comment #12)

> The resulting SVG can be seen fine when imported in Impress and Writer, and
> opened in Firefox and Inkscape, ...
When I export an Impress (version 7.3.1.3) slide as SVG and open in Inkscape (version Inkscape 1.1.2 (0a00cf5339, 2022-02-04)), I see the slide's contents, but not the text and background from its Master Slide. I filed Inkscape bug https://gitlab.com/inkscape/inbox/-/issues/6566 .

> but requires switching the tags to <g
> visibility="visible"> to work in GIMP, Sozi and gThumb.
I changed all the visibility="hidden" attributes in my SVG to visibility="visible", and I still didn't see stuff from the Master Slide in Inkscape.
Comment 15 skierpage 2022-03-05 03:38:28 UTC
(In reply to stragu from comment #12)
> I think this bug should be a WORKSFORME and possibly a different bug should be opened about the "hidden" tags in whole-slide SVG exports.
I filed bug 147776 "a slide exported as SVG from Impress should Just Work and not require JavaScript"

(In reply to skierpage from comment #14)
> (In reply to stragu from comment #12)
> 
> > The resulting SVG can be seen fine when imported in Impress and Writer, and
> > opened in Firefox and Inkscape, ...
> When I export an Impress (version 7.3.1.3) slide as SVG and open in Inkscape
> (version Inkscape 1.1.2 (0a00cf5339, 2022-02-04)), I see the slide's
> contents, but not the text and background from its Master Slide
[because the correct rendering requires Javascript]

> > but requires switching the tags to <g
> > visibility="visible"> to work in GIMP, Sozi and gThumb.
In addition to comment 4's change<g class="SlideGroup"> to visible to see the slide content: it seems the Master Slide's content is inside a <defs> tag and is not rendered. To see the Master Slide's content in the SVG, remove or comment out the outermost opening and closing <defs> tag.