Bug 95717 - DRAW: Manage layers in SVG export
Summary: DRAW: Manage layers in SVG export
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Draw (show other bugs)
Version:
(earliest affected)
5.0.3.2 release
Hardware: All All
: medium enhancement
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: filter:svg
: 144848 (view as bug list)
Depends on:
Blocks: Layers
  Show dependency treegraph
 
Reported: 2015-11-10 07:51 UTC by Stephane Santon
Modified: 2023-12-07 08:48 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
Draw file with 4 objects, and 1 custom layer (9.54 KB, application/vnd.oasis.opendocument.graphics)
2015-11-12 09:09 UTC, Stephane Santon
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Stephane Santon 2015-11-10 07:51:10 UTC
More and more users create SVG pictures to be used in HTML5 animations, or to replace classic linear presentation applications (like PREZI, but on SOZI with HTML5 compliance).
We have to create multilayer SVG pictures to manage animation.

But even if we create different layers in Draw, there are no more layers when it is exported to SVG format.
(We still have to use Inkscape which provides real multilayers SVG pictures)
Comment 1 Regina Henschel 2015-11-10 22:33:37 UTC
Which w3.org standard svg elements provides "layers"?

In ODF, "The animation elements are based upon §3.5 and §12.5 of [SMIL20], and section §19.2 of [SVG]."
with [SMIL20]=http://www.w3.org/TR/2005/REC-SMIL2-20050107/
[SVG]=http://www.w3.org/TR/2003/REC-SVG11-20030114/
For details see section "15 SMIL Animations" in http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html

Can you please provide a standard conform svg document using "layers"? Inkscape "svg" <> standard svg.

Draw does not have animation and Impress has no layers. It is not clear, what do you mean.
Comment 2 Stephane Santon 2015-11-11 21:25:43 UTC
Standard SVG does not implement specific "layers" but groups with <g>, and layers can be seen as groups.

I don't want to integrate animation in the SVG file, but to distinguish layers (groups) in order to animate then with a HTML5 page. 

Inkscape can find his layers while opening his SVG files by :
 <g
     id="layer2"
     inkscape:groupmode="layer"
     inkscape:label="..."

DRAW could do the same :
 <g
     id="layer2"
     draw:groupmode="layer"

or
 <g
     class="layer"
     id="layer2"

Then, an application could detect these layers an create some animations by hiding, showing, moving groups, like SOZI does :
http://sozi.baierouge.fr/images/tutorial-layers/sozi-layers-tutorial-full.svg
Comment 3 Regina Henschel 2015-11-11 23:02:01 UTC
To me it looks like your request is not about "layers" but about groups.

I think, introducing an own namespace should not be done; svg is rich enough to do all needed things in standard svg. Namespace "draw" would be a bad choice anyway, because it can be confused with ODF.

Currently neither a page nor a group gets an identifier but only the individual shapes. I would support a request, that svg export should make the name of a group to an id-attribute of the <g>-element in svg. Such could be used in Impress too, where no user layers exists.

It would be possible to put the layer into a class attribute, but it does not work well, because a group in Draw can contain shapes from different layers. Therefore the layer-information would only be meaningful for a single shape, but not for a group.

Do you agree to take this bug report as request for an id-attribute for the <g>-element, which is generated for a group in Draw? If yes, the subject line should be changed accordingly.
Comment 4 Stephane Santon 2015-11-12 09:09:41 UTC
Created attachment 120492 [details]
Draw file with 4 objects, and 1 custom layer
Comment 5 Stephane Santon 2015-11-12 09:15:51 UTC
(In reply to Regina Henschel from comment #3)
> To me it looks like your request is not about "layers" but about groups.

Yes. The Draw layers have to be exported as groups.

> an own namespace should not be done

OK

> Currently neither a page nor a group gets an identifier but only the
> individual shapes. I would support a request, that svg export should make
> the name of a group to an id-attribute of the <g>-element in svg. Such could
> be used in Impress too, where no user layers exists.

Good !

> It would be possible to put the layer into a class attribute, but it does
> not work well, because a group in Draw can contain shapes from different
> layers. 

Oh ! I didn't know. OK.

> Do you agree to take this bug report as request for an id-attribute for the
> <g>-element, which is generated for a group in Draw? If yes, the subject
> line should be changed accordingly.

In a first step, yes. 

Is it enough to define "layers" ? Layers could be defined by :
- a SVG goup (OK)
- with an id (OK with the new request)
- and that is *a direct child of the root SVG element*.

----

In the current SVG export, you can find the first SVG Child group as :
<g>
  <g id="id2" class="Master_Slide">
   <g id="bg-id2" class="Background"/>
   <g id="bo-id2" class="BackgroundObjects"/>
  </g>
 </g>

What is it for ?

----

And then the next (and last) SVG child group with the SlideGroup class as :

 <g class="SlideGroup">
  <g>
   <g id="id1" class="Slide" clip-path="url(#presentation_clip_path)">
    <g class="Page">
     <g class="com.sun.star.drawing.CustomShape">
      <g id="id3">
        [...]
      </g>
     </g>
     <g class="com.sun.star.drawing.TextShape">
      <g id="id4">
        [...]
      </g>
     </g>
     <g class="Group">
      <g class="com.sun.star.drawing.CustomShape">
       <g id="id5">
        [...]
       </g>
      </g>
      <g class="com.sun.star.drawing.CustomShape">
       <g id="id6">
        [...]
       </g>
      </g>
     </g>
    </g>
   </g>
  </g>
 </g>

Is there always only ONE SlideGroup ?

Could the layers objects be separated in different SlideGroups with their own ID ?

Thanks
Comment 6 Stephane Santon 2015-11-12 18:15:40 UTC
You can have a look to an article about how Adobe Illustrator exports its layers :

http://www.adobe.com/inspire/2013/09/exporting-svg-illustrator.html

(At the bottom of the page)
Comment 7 Regina Henschel 2015-11-12 21:09:49 UTC
The description of the request is detailed enough now, therefore I set it to new. At least using the id attribute of the <g>-element in svg would be a useful enhancement.

I have no answer to your other questions.
Comment 8 Stephane Santon 2015-11-12 21:14:20 UTC
(In reply to Regina Henschel from comment #7)
> The description of the request is detailed enough now, therefore I set it to
> new. At least using the id attribute of the <g>-element in svg would be a
> useful enhancement.

Thanks :-)

> I have no answer to your other questions.

I hope ID-ed groups (= layers) will be direct children of SVG element.
Comment 9 Regina Henschel 2020-03-08 08:20:22 UTC
After working more on layers I think, my first idea to use the <g> element is not good. In Draw groups and layers are orthogonally to each others, because it is possible, that the elements in a group belong to different layers. You can group a shape together with a measure line, for example. Therefore I'll remove "group" from the subject.

But I have a different idea. The purpose of layers is only to have the properties "visible", "printable" and "locked". You can define css rules for each layer and use the class attributes on the elements.
Comment 10 Regina Henschel 2021-10-01 22:00:48 UTC
*** Bug 144848 has been marked as a duplicate of this bug. ***
Comment 11 Stéphane Guillou (stragu) 2023-12-07 08:48:03 UTC
(In reply to Regina Henschel from comment #9)
> After working more on layers I think, my first idea to use the <g> element
> is not good. In Draw groups and layers are orthogonally to each others,
> because it is possible, that the elements in a group belong to different
> layers. You can group a shape together with a measure line, for example.
> Therefore I'll remove "group" from the subject.
> 
> But I have a different idea. The purpose of layers is only to have the
> properties "visible", "printable" and "locked". You can define css rules for
> each layer and use the class attributes on the elements.

Thanks Regina. I tried to clarify the "group by layer" idea in bug 144869, which you made clear has to be either a destructive option on the existing layer, or an alternative filter.

I like the idea of supporting layer properties via CSS here.
Given that it would add a good amount of repeated tagging to the SVG code (CSS rules + class tags on each object), I think this should be made optional. 
Although focusing this report on supporting layer _properties_ makes this a duplicate of bug 53864. (Use of CSS and classes hasn't been mentioned there yet.)