Allow import of svg without overriding style

Migrated from: https://bugs.launchpad.net/inkscape/+bug/1794060

Steps to reproduce:

What happened?

The blue svg is imported as red since the original style property took priority.

Note that the imported style information is still there (good!)

What should have happened?

The blue svg should be imported as blue. All style tags should be changed as appropriate so they refer only to elements from the imported file. E.g. rect {} should be changed so no rectangles in the open document are changed. I do not think we should leave rect {} there even if there are no rectangles in the open document.

This is especially desired for clips and masks in style tags. Or for ids (which may change on import if there is a collision)

Having this as a preference/option would be ideal, since I'm sure there are use cases where overriding styles are desired (either fully, or only those that don't collide with existing styles).

Notes

  1. You can already import a linked svg file. This preserves the style tags however the imported file is not editable.

  2. I found inconsistent behaviour in 0.92.3/4 on import.

The original issue was that the appearance on import not being preserved on save. However, different iterations of the original files and the minimal files above gave differing results in 0.92.3/4 (e.g. which file is imported, and adding other style attributes to the minimal file). I guess it is irrelevant when focusing on 1.0alpha.

Inkscape Version and Operating System:

  • Inkscape 1.0alpha (2bfff77150, 2019-04-16) (69e4b63d9397337d17afb3751dd37c7924b6c3b2 from master + unrelated commit) Linux Mint 19.1

Files from original issue

These will not currently open in 1.0alpha due to inkscape#175 (closed)

May change later.

lubridate.svg
dplyr.svg

Edited by Nathan Lee