From 3cfdbb1694c3711689af111d4b8c4d5758742445 Mon Sep 17 00:00:00 2001 From: Nicolas Delaby <nicolas@nexedi.com> Date: Fri, 8 Apr 2011 15:32:53 +0000 Subject: [PATCH] workaround a Bug in LibreOffice HTML import filter. https://bugs.freedesktop.org/show_bug.cgi?id=36080 git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@45265 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5OOo/transforms/html_to_odt.py | 4 ++++ product/ERP5OOo/transforms/oood_commandtransform.py | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/product/ERP5OOo/transforms/html_to_odt.py b/product/ERP5OOo/transforms/html_to_odt.py index 1c2881a8e7..582e677a7a 100644 --- a/product/ERP5OOo/transforms/html_to_odt.py +++ b/product/ERP5OOo/transforms/html_to_odt.py @@ -44,6 +44,10 @@ class HTMLToOdt: 'content': 'text/html; charset=utf-8'}) orig = html.tostring(html_node, encoding='utf-8', method='xml') + # workaround a Bug in LibreOffice HTML import filter. + # https://bugs.freedesktop.org/show_bug.cgi?id=36080 + orig = orig.replace('<title/>', '<title></title>') + import pdb;pdb.set_trace() doc = OOOdCommandTransform(context, filename, orig, self.inputs[0]) odt = doc.convertTo('odt') if cache is not None: diff --git a/product/ERP5OOo/transforms/oood_commandtransform.py b/product/ERP5OOo/transforms/oood_commandtransform.py index 821272b119..e70d3d4b0f 100644 --- a/product/ERP5OOo/transforms/oood_commandtransform.py +++ b/product/ERP5OOo/transforms/oood_commandtransform.py @@ -12,6 +12,7 @@ from zLOG import LOG from Products.ERP5OOo.OOoUtils import OOoBuilder import re from lxml import etree +from lxml import html from lxml.etree import ParseError, Element from urllib import unquote @@ -193,8 +194,9 @@ class OOOdCommandTransform(commandtransform): parent_node.append(style_node) style_node.attrib.update({'type': 'text/css'}) parent_node.remove(css_link_tag) - return etree.tostring(xml_doc, encoding='utf-8', - xml_declaration=False, pretty_print=False, ) + xml_output = html.tostring(xml_doc, encoding='utf-8', method='xml') + xml_output = xml_output.replace('<title/>', '<title></title>') + return xml_output def convertTo(self, format): server_proxy = OOoServerProxy(self.context) -- 2.30.9