summaryrefslogtreecommitdiff
path: root/librelogo
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2013-07-18 14:51:17 +0200
committerLászló Németh <nemeth@numbertext.org>2013-07-18 14:51:17 +0200
commit90e3d0fef329917218ffb121179e06ab73ff01a5 (patch)
treea8394cfbeae60ff55076b4dc6045eab8cf3d3c99 /librelogo
parent4f4bed9b46eaaf9ab483d7c1b9ab31fb49838c99 (diff)
librelogo: fix LibO SVG export for W3C Validator/Wikipedia
Change-Id: I19b01b08ab08540cc8e9f7255d13663ba7ce1d02
Diffstat (limited to 'librelogo')
-rw-r--r--librelogo/source/LibreLogo/LibreLogo.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/librelogo/source/LibreLogo/LibreLogo.py b/librelogo/source/LibreLogo/LibreLogo.py
index e73a1736f7cd..e3213ecb5eea 100644
--- a/librelogo/source/LibreLogo/LibreLogo.py
+++ b/librelogo/source/LibreLogo/LibreLogo.py
@@ -1208,6 +1208,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
@@ -1246,7 +1255,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: