Commit ce4ad5b7 authored by Nicolas Delaby's avatar Nicolas Delaby

Refactor oood_command_transform to avoid instanciation

of Temp OOoDocument, because implicit conversion to base format
does not returns expected format (base conversion of html is html, not odt).

This patch consist into calling conversion server directly without pass Through
convert API of OOoDocument.

This patch is already absoleted and will be replaced by portal_data_adapters
as soon as it is implemented.



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@44734 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 2d15ccdf
...@@ -22,6 +22,13 @@ try: ...@@ -22,6 +22,13 @@ try:
except ImportError: except ImportError:
from cgi import parse_qsl from cgi import parse_qsl
# XXX Must be replaced by portal_data_adapters soon
from Products.ERP5OOo.Document.OOoDocument import OOoServerProxy
from Products.ERP5OOo.Document.OOoDocument import enc
from Products.ERP5OOo.Document.OOoDocument import dec
CLEAN_RELATIVE_PATH = re.compile('^../') CLEAN_RELATIVE_PATH = re.compile('^../')
class OOoDocumentDataStream: class OOoDocumentDataStream:
...@@ -67,12 +74,7 @@ class OOOdCommandTransform(commandtransform): ...@@ -67,12 +74,7 @@ class OOOdCommandTransform(commandtransform):
self.context = context self.context = context
if self.mimetype == 'text/html': if self.mimetype == 'text/html':
data = self.includeExternalCssList(data) data = self.includeExternalCssList(data)
tmp_ooo = newTempOOoDocument(context, str(id(self))) self.data = data
tmp_ooo.edit( data=data,
filename=self.name(),
content_type=self.mimetype,)
tmp_ooo.convertToBaseFormat()
self.ooo = tmp_ooo
def name(self): def name(self):
return self.__name__ return self.__name__
...@@ -194,8 +196,18 @@ class OOOdCommandTransform(commandtransform): ...@@ -194,8 +196,18 @@ class OOOdCommandTransform(commandtransform):
xml_declaration=False, pretty_print=False, ) xml_declaration=False, pretty_print=False, )
def convertTo(self, format): def convertTo(self, format):
if self.ooo.isTargetFormatAllowed(format): server_proxy = OOoServerProxy(self.context)
mime, data = self.ooo.convert(format) response_code, response_dict, message = \
server_proxy.getAllowedTargetItemList(self.mimetype)
allowed_extension_list = response_dict['response_data']
if format in dict(allowed_extension_list):
response_code, response_dict, message = server_proxy.run_generate(
'',
enc(self.data),
None,
format,
self.mimetype)
data = dec(response_dict['data'])
if self.mimetype == 'text/html': if self.mimetype == 'text/html':
data = self.includeImageList(data) data = self.includeImageList(data)
return data return data
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment