diff options
author | László Németh <nemeth@numbertext.org> | 2013-07-18 14:51:17 +0200 |
---|---|---|
committer | Andras Timar <atimar@suse.com> | 2013-07-18 15:16:20 +0000 |
commit | 703b0fc230ca1fe271f6eca981ce3121ede5bf7d (patch) | |
tree | c43eabe89f01f90caff5b9c93ef5de60dd9b7bde /librelogo | |
parent | 48d7af8ad317b1919e83e7925c5809e8a96d5303 (diff) |
librelogo: fix LibO SVG export for W3C Validator/Wikipedia
Change-Id: I19b01b08ab08540cc8e9f7255d13663ba7ce1d02
Reviewed-on: https://gerrit.libreoffice.org/4969
Reviewed-by: Andras Timar <atimar@suse.com>
Tested-by: Andras Timar <atimar@suse.com>
Diffstat (limited to 'librelogo')
-rw-r--r-- | librelogo/source/LibreLogo/LibreLogo.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/librelogo/source/LibreLogo/LibreLogo.py b/librelogo/source/LibreLogo/LibreLogo.py index 49983d349b4a..b4e5936046c9 100644 --- a/librelogo/source/LibreLogo/LibreLogo.py +++ b/librelogo/source/LibreLogo/LibreLogo.py @@ -1205,6 +1205,15 @@ def __groupstart__(name = ""): __group__ = uno.getComponentContext().ServiceManager.createInstance('com.sun.star.drawing.ShapeCollection') __grouplefthang__ = 0 +def create_valid_svg_file(filename): + with open(filename, "r") as f: + s = f.read() + s = re.sub('(?s)(<g\\sid="[^"]*)\(([^"]*)\)', '\\1\\2', s) # bad "(", ")" in xml:id + s = re.sub('(?s)<g\\sooo:[^>]*>', '', s) # remove non standard attributes + s = re.sub('(?s)<svg\\s+version="1.2"', '<svg version="1.1"', s) # for W3C Validator + with open(filename, 'w') as f: + f.write(s) + def __groupend__(name = ""): global __group__, __grouplefthang__, __groupstack__ g = 0 @@ -1243,7 +1252,8 @@ def __groupend__(name = ""): name = os.path.expanduser('~') + os.path.sep + name __dispatcher__(".uno:ExportTo", (__getprop__("URL", unohelper.systemPathToFileUrl(name)), __getprop__("FilterName", "draw_svg_Export")), draw) __time__.sleep(1) - draw.dispose() + create_valid_svg_file(name) + draw.close(True) __group__ = __groupstack__.pop() if __group__ and g: |