Bug 69271 - VIEWING: SVG - "class=" taking precendence over explicitely defined "style=" [Regression]
Summary: VIEWING: SVG - "class=" taking precendence over explicitely defined "style=" ...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: graphics stack (show other bugs)
Version:
(earliest affected)
4.1.0.4 release
Hardware: Other Linux (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: BSA target:4.2.0 target:4.1.6
Keywords: regression
Depends on:
Blocks:
 
Reported: 2013-09-12 13:14 UTC by Bojan Vitnik
Modified: 2014-02-14 21:24 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
Particular SVG picture showing the regression and screenshots (446.81 KB, application/zip)
2013-09-12 13:14 UTC, Bojan Vitnik
Details
Simple version of the SVG picture (5.19 KB, image/svg+xml)
2013-10-20 19:16 UTC, Bojan Vitnik
Details
example with class, only style attribute and both (1.08 KB, image/svg+xml)
2013-10-20 21:28 UTC, Regina Henschel
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Bojan Vitnik 2013-09-12 13:14:55 UTC
Created attachment 85719 [details]
Particular SVG picture showing the regression and screenshots

Problem description: 

As of version 4.1.1 (possibly earlier) SVG picture "Background - Gray.svg", found in attached zip archive, is not displayed correctly when inserted in LO Writer document.

Steps to reproduce:
1. Open the "Front_page.odt" document found in attached zip archive.

Current behavior:

In version 4.1.1 of LO Writer the picture is displayed in color instead of light gray. The light gray version of the picture was done by "coloring" colored version of the picture in light gray using Inkscape. As a result of that, light gray color was defined explicitly in "style=" but the original color was left defined in "class=". Here is an example from attached SVG:

<circle
   ...
   style="fill:#e8e8e8;fill-opacity:1"
   ....
   class="fil24"
/>

where class "fil24" is defined as:

.fil24 {fill:#2F6864}

In attached zip archive you will find screenshots of the document displayed in LO Writer version 4.0.5 and 4.1.1. It seems that "class=" is taking precedence over "style=" so picture is displayed colored instead of light gray.

The SVG picture is displayed correctly (light gray) in version 4.1.1 of LO Draw so only Writer is affected

Expected behavior:

Attached SVG picture should be displayed light gray.
Operating System: Ubuntu
Version: 4.1.1.2 release
Comment 1 Dominique Boutry 2013-10-19 15:30:20 UTC
Partially reproduced with LibO 4.1.2.3 on Win7. The following cases fail (i.e. the drawing is colored):
- drag&drop the "Background - Gray.svg" file into an opened Writer
- loading this file with "Insert > Image > From file" into Writer,
- loading this file with "Insert > Image > From file" into Calc,
- drag&drop that file into an opened Draw
- loading this file with "Insert > Image > From file" into Draw

Opening the "Front_page.odt" with Writer also fails.

Note that the Windows icon associated with the "Front_page.odt" is grey, not colored. I'm not sure if my computer drawn it or if I got it with your file in the ZIP container.
Comment 2 Regina Henschel 2013-10-19 21:15:59 UTC
The attached .svg file does not validate in http://validator.w3.org

If you do not use the special "inkscape svg" with all its special namespaces, but use normal standard svg, then the graphic is shown correctly.
Comment 3 Bojan Vitnik 2013-10-20 19:14:57 UTC
Dear Dominique, thanks for bug confirmation.

Dear Regina,

SVG being valid or not is not an issue here. SVG parser should ignore everything it does not understand (ie. Inskscape specific things). If you convert attached SVG to "standard svg" then it's displayed correctly but only because Inkscape removes CSS classes from SVG and leaves "style" attributes. Both "class" and "style" attributes are standard, not Inkscape specifc. Take a look at:

http://www.w3.org/TR/SVG/styling.html#StylingWithCSS

sections 6.11 and 6.12

Here, I'll attach a simple version of the SVG picture that is completely valid and does not have anything Inkscape specific but still causes the same bug - "class" attribute is taking precedence over "style" attribute.
Comment 4 Bojan Vitnik 2013-10-20 19:16:06 UTC
Created attachment 87887 [details]
Simple version of the SVG picture
Comment 5 Regina Henschel 2013-10-20 21:27:40 UTC
The style attribute has a higher specificity than the class selector. Therefore the rules of the style attribute has to be used.

Dear Bojan, examples files should not contain more than needed to understand the problem and reproduce the bug. Therefore I was annoyed to get a more than 2000 lines long file.
Comment 6 Regina Henschel 2013-10-20 21:28:53 UTC
Created attachment 87899 [details]
example with class, only style attribute and both
Comment 7 Bojan Vitnik 2013-10-20 21:52:38 UTC
Dear Regina,

Sorry for the large (and bad) example files but I was short on time and not too eager to dive into "misteries of SVG". I hope that it's clear now what the bug is all about :).
Comment 8 Michael Stahl (allotropia) 2014-02-05 21:22:10 UTC
so LO 4.0.6.2 preferred the style, whereas LO 4.1.x all prefer the class.

this was fixed in LO 4.2.0 by this commit:

commit 8b2fb0e153fa846a171105b7801c398ffbe3d595
Author:     Armin Le Grand <alg@apache.org>
AuthorDate: Wed Oct 30 11:22:20 2013 +0000

    Resolves: #i123510# changed priority in style preparation

... and introduced in 4.1.0 by this one:

commit f75ca1fdad1094fbea4bb6cb0e3cc9458700c470
Author:     Armin Le Grand <alg@apache.org>
AuthorDate: Wed Jul 25 08:28:44 2012 +0000

    Fix #120334# Added support for multiple CSS styles per graphic primitive

thanks Regina for getting this fixed :)
Comment 9 Commit Notification 2014-02-05 21:45:44 UTC
Armin Le Grand committed a patch related to this issue.
It has been pushed to "libreoffice-4-1":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=8335b5b2c930cd2336973d73506128e8ae5b3850&h=libreoffice-4-1

Resolves: fdo#69271 i#123510 changed priority in style preparation


It will be available in LibreOffice 4.1.6.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 10 Bojan Vitnik 2014-02-14 21:24:50 UTC
I can confirm it's fixed in LO 4.2.

Thank you all!