Bug 160373 - Broken SVG import with fill=none and clippaths
Summary: Broken SVG import with fill=none and clippaths
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: filters and storage (show other bugs)
Version:
(earliest affected)
6.1 all versions
Hardware: All All
: medium normal
Assignee: Xisco Faulí
URL:
Whiteboard: target:24.8.0 target:24.2.3 target:7.6.7
Keywords: bibisected, bisected, filter:svg
Depends on:
Blocks: SVG-Import
  Show dependency treegraph
 
Reported: 2024-03-26 10:14 UTC by d_tassos
Modified: 2024-04-12 12:43 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
Image showing the same svg imported before and after fixing (145.76 KB, image/png)
2024-03-26 10:17 UTC, d_tassos
Details
Same svg plot opened in inkscape without the need to fix it first (117.74 KB, image/png)
2024-03-26 10:18 UTC, d_tassos
Details
svg file to test for importing in impress (6.43 KB, text/plain)
2024-03-26 10:19 UTC, d_tassos
Details
minimal example (554 bytes, image/svg+xml)
2024-03-26 11:45 UTC, Xisco Faulí
Details
Image showing the same odp opened in the 7.6.5.2 and the 24.2.4 impress. (445.61 KB, image/png)
2024-04-12 08:25 UTC, d_tassos
Details

Note You need to log in before you can comment on or make changes to this bug.
Description d_tassos 2024-03-26 10:14:00 UTC
Description:
Importing svg images/plots exported from R using ggsave/svglite is broken. Most of the components of the plots are not shown. Opening the same plot in Inkscape everything is displayed correctly so it is a valid svg file.

A fix I have found is to run the bellow on the SVG, then everything is displayed correctly.

sed 's/^.g\s[^<]*//g;s/<\/g>$//g' my_svg_file.svg > my_fixed_svg_file.svg

which will for example change the bellow:

<g clip-path='url(#cpMTA1LjA2fDM5OC42OXwxMDguMzh8Mzk0Ljg3)'>
<rect x='105.06' y='108.38' width='293.62' height='286.50' style='stroke-width: 1.36; stroke: #FFFFFF; fill: #FFFFFF;' />
</g>

to:

<rect x='105.06' y='108.38' width='293.62' height='286.50' style='stroke-width: 1.36; stroke: #FFFFFF; fill: #FFFFFF;' />

The above, after the fix will display correctly in Impress. Why can't Impress display the plot correctly when there is the <g> tag?


Steps to Reproduce:
Import an svg with using the g tag

Actual Results:
Most graphics will not display

Expected Results:
Everything from the svg should display like they do in Inkscape


Reproducible: Always


User Profile Reset: No

Additional Info:
[Information automatically included from LibreOffice]
Locale: en-US
Module: PresentationDocument
[Information guessed from browser]
OS: Linux (All)
OS is 64bit: yes
Comment 1 d_tassos 2024-03-26 10:17:15 UTC
Created attachment 193311 [details]
Image showing the same svg imported before and after fixing
Comment 2 d_tassos 2024-03-26 10:18:15 UTC
Created attachment 193312 [details]
Same svg plot opened in inkscape without the need to fix it first
Comment 3 d_tassos 2024-03-26 10:19:28 UTC
Created attachment 193313 [details]
svg file to test for importing in impress
Comment 4 Xisco Faulí 2024-03-26 10:59:45 UTC
Regression introduced by:

author	Xisco Fauli <xiscofauli@libreoffice.org>	2023-08-22 12:46:02 +0200
committer	Xisco Fauli <xiscofauli@libreoffice.org>	2023-08-22 20:06:24 +0200
commit b2247336409b7b3b0ae04356a167dcd204badb04 (patch)
tree ebe8292d5a928d771b31ba13bb54d90cc3b2f96f
parent 3cf3e0e21d2f7fa33abced5e2f7291de6e4441eb (diff)
tdf#129356: handle css combinator when the element name is combined...

Bisected with: bibisect-linux64-24.2
Comment 5 Stéphane Guillou (stragu) 2024-03-26 11:08:52 UTC
reproduced on Windows 11:

Version: 24.2.1.2 (X86_64) / LibreOffice Community
Build ID: db4def46b0453cc22e2d0305797cf981b68ef5ac
CPU threads: 4; OS: Windows 10.0 Build 22631; UI render: Skia/Raster; VCL: win
Locale: en-US (en_US); UI: en-US
Calc: threaded
Comment 6 Xisco Faulí 2024-03-26 11:45:58 UTC
Created attachment 193318 [details]
minimal example
Comment 7 Xisco Faulí 2024-03-26 11:48:17 UTC
With the minimal example, if the fill:none is replaced with something else, i.e. fill:black, then the blue rect is displayed. weird...
Comment 8 Xisco Faulí 2024-03-26 13:05:08 UTC
for the record, this is not a regression as my minimal example shows. b2247336409b7b3b0ae04356a167dcd204badb04 just exposed a previous issue and made it more visible
Comment 9 d_tassos 2024-03-26 14:02:05 UTC
Indeed, it's not needed to remove the whole g tags. It seems just removing the clip-path within the <g> tags is enough for svg import to work.

If doing for example the bellow sed on the provided test.svg file then the resulting test_fix_clip.svg file imports OK to impress.

sed "s/\sclip-path=.*'//g" test.svg > test_fix_clip.svg
Comment 10 Commit Notification 2024-03-26 17:39:56 UTC
Xisco Fauli committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/feb4e0890b883940ec6964375293727ac6229f1c

tdf#160373: Iterate over all parents to check whether it's a clipPath content

It will be available in 24.8.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 11 Commit Notification 2024-03-27 07:52:15 UTC
Xisco Fauli committed a patch related to this issue.
It has been pushed to "libreoffice-24-2":

https://git.libreoffice.org/core/commit/ea3d61886a2b420b985bed162c28b94698283c76

tdf#160373: Iterate over all parents to check whether it's a clipPath content

It will be available in 24.2.3.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 12 Commit Notification 2024-03-27 07:52:18 UTC
Xisco Fauli committed a patch related to this issue.
It has been pushed to "libreoffice-7-6":

https://git.libreoffice.org/core/commit/d6d502f41346b021d369c27c9ed969d75d680986

tdf#160373: Iterate over all parents to check whether it's a clipPath content

It will be available in 7.6.7.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 13 d_tassos 2024-04-12 08:22:44 UTC
Checked the daily build 24.2.4 and it now works importing SVGs. I opened the same odp document which contains the same SVG before and after fixing and now the SVG before applying the fix is correctly displayed.
Comment 14 d_tassos 2024-04-12 08:25:01 UTC
Created attachment 193642 [details]
Image showing the same odp opened in the 7.6.5.2 and the 24.2.4 impress.
Comment 15 Stéphane Guillou (stragu) 2024-04-12 12:43:09 UTC
(In reply to d_tassos from comment #13)
> Checked the daily build 24.2.4 and it now works importing SVGs.
Thanks for testing. Let's mark as "verified" then.