From 75f32e5f1fba08551837af618adec9e6122c69bf Mon Sep 17 00:00:00 2001
From: Fabien Morin <fabien@nexedi.com>
Date: Wed, 30 Jan 2008 13:46:40 +0000
Subject: [PATCH] - add a code part to replace caracters from scribus file
 (.sla) wich are not   xml valid and make xml parser failed to parse it. They
 appear for example   when you have more than one line in a text frame or if
 you have tabulation   caracter.   This hack is temporary, because the problem
 comes with scribus and perhaps   will be corrected in the next scribus
 version.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@18924 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5Form/ScribusUtils.py | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/product/ERP5Form/ScribusUtils.py b/product/ERP5Form/ScribusUtils.py
index b6aa11769f..dfc3a2636f 100644
--- a/product/ERP5Form/ScribusUtils.py
+++ b/product/ERP5Form/ScribusUtils.py
@@ -1235,10 +1235,9 @@ class ScribusParser:
     This function is used to get attributes'values in an object_dict and 
     to be sure a compatible value is returned (for that use default value)
     """
-    #return object_dict.get(check_key, None) or default_value
     if object_dict.has_key(check_key):
       # 'check_key' exists
-      if len(object_dict[check_key]) != 0:
+      if len(object_dict[check_key]):
         # check_key corresponding value is not null
         # returning this value
         return object_dict[check_key]
@@ -1261,6 +1260,15 @@ class ScribusParser:
     containing a dict of all the relative attributes
     """
 
+    # XXX this is a hack to correct a scribus problem
+    # actualy scribus (version 1.3.3.12svn) use some invali xml caracters
+    # like the '&#x5;' caracter wich is a carriage return caratere, used for
+    # example in a text frame with many lines
+    # this problem is well knowed by scribus community and perhaps will be
+    # correct in futur scribus version
+    xml_string = xml_string.replace('&#x5;', '\n')
+    xml_string = xml_string.replace('&#x4;', '\t')
+
     # Create DOM tree from the xml string
     print " > create DOM tree"
     dom_tree = minidom.parseString(xml_string)
@@ -1351,7 +1359,7 @@ class ScribusParser:
         # end parsing document version 1.2.*
 
       else:
-        print " found Scribus Doucment format 1.3"
+        print " found Scribus Doucment format 1.3 or higher"
         # assuming version is compliant with 1.3.* specifications
 
         keep_page = 1
-- 
2.30.9