Add line-break for field with \n

This commit is contained in:
Cédric Krier committed 2008-05-07 19:57:35 +02:00
1 parent 483f838349
commit d946734759
1 file changed
+17 -2
+17 -2
View File
@@ -323,8 +323,23 @@ class Report(object):
if hasattr(res, '__str__'):
res = res.__str__()
if isinstance(res, basestring):
node.nodeValue = res.decode('utf-8')
node.parentNode.parentNode.replaceChild(node, node.parentNode)
if '\n' in res:
parent = node.parentNode.parentNode
for val in res.decode('utf-8').split('\n'):
newnode = node.cloneNode(1)
newnode.nodeValue = val
node.parentNode.parentNode.appendChild(newnode)
newnode = node.parentNode.cloneNode(1)
newnode.nodeType = newnode.ELEMENT_NODE
newnode.tagName = 'text:line-break'
newnode.firstChild.nodeValue = ''
newnode.removeAttribute('text:description')
node.parentNode.parentNode.appendChild(newnode)
parent.removeChild(parent.firstChild)
parent.removeChild(parent.lastChild)
else:
node.nodeValue = res.decode('utf-8')
node.parentNode.parentNode.replaceChild(node, node.parentNode)
return res
if 'language' in localcontext:
lang = localcontext['language']