fix from Hardik Joshi

bzr revid: ced-fa8542024b8da57330ea0524f373c75ea1ddcd29
This commit is contained in:
ced 2007-10-04 05:59:04 +00:00
parent 22cc537a7a
commit 58f6e71768
2 changed files with 19 additions and 8 deletions

View File

@ -37,6 +37,15 @@ import tools
class report_xml(osv.osv):
_inherit = 'ir.actions.report.xml'
def sxwtorml(self,cr, uid, file_sxw):
'''
The use of this function is to get rml file from sxw file.
'''
sxwval = StringIO(base64.decodestring(file_sxw))
fp = tools.file_open('normalized_oo2rml.xsl',
subdir='addons/base_report_designer/wizard/tiny_sxw2rml')
return {'report_rml_content': str(sxw2rml(sxwval, xsl=fp.read()))}
def upload_report(self, cr, uid, report_id, file_sxw, context):
'''
Untested function

View File

@ -132,7 +132,7 @@ class DomApiGeneral:
if type(string) == unicode:
return string.encode("utf-8")
tempstring = unicode(string,"cp1252").encode("utf-8")
return tempstring
return tempstring
class DomApi(DomApiGeneral):
"""This class provides a DOM-API for XML-Files from an SXW-Archive."""
@ -143,15 +143,15 @@ class DomApi(DomApiGeneral):
body = self.content_dom.getElementsByTagName("office:body")
self.body = body and body[0]
# TODO:
# TODO:
self.style_dict = {}
self.style_properties_dict = {}
# ******** always use the following order:
self.buildStyleDict()
self.buildStylePropertiesDict()
self.page_master = self.styles_dom.getElementsByTagName("style:page-master")[0]
if self.styles_dom.getElementsByTagName("style:page-master").__len__()<>0:
self.page_master = self.styles_dom.getElementsByTagName("style:page-master")[0]
self.document = self.content_dom.getElementsByTagName("office:document-content")[0]
def buildStylePropertiesDict(self):
@ -224,7 +224,7 @@ class DomApi(DomApiGeneral):
def normalizeLength(self):
"""Normalize all lengthes to floats (i.e: 1 inch = 72).
Always use this after "normalizeContent" and "transferStyles"!"""
Always use this after "normalizeContent" and "transferStyles"!"""
# TODO: The complex attributes of table cell styles are not transferred yet.
#all_styles = self.content_dom.getElementsByTagName("style:properties")
#all_styles += self.content_dom.getElementsByTagName("draw:image")
@ -335,9 +335,11 @@ def sxw2rml(sxw_file, xsl, output='.', save_pict=False):
node.setProp('name', img)
node.setContent( base64.encodestring(tool.images[img]))
images.addChild(node)
root.addNextSibling(images)
xml = style.saveResultToString(result)
root.addNextSibling(images)
try:
xml = style.saveResultToString(result)
except:
pass
return result
if __name__ == "__main__":