Commit 4fada4ec authored by Nicolas Delaby's avatar Nicolas Delaby

* Check if hasBaseData only once

* if no conversion is asked return original document


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@35251 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 659db7dc
...@@ -311,14 +311,18 @@ class OOoDocument(PermanentURLMixIn, BaseConvertableAndFileMixin, File, ...@@ -311,14 +311,18 @@ class OOoDocument(PermanentURLMixIn, BaseConvertableAndFileMixin, File,
#XXX but I don't know what is a appropriate mime-type.(Yusei) #XXX but I don't know what is a appropriate mime-type.(Yusei)
if self.get_size() == 0: if self.get_size() == 0:
return 'text/plain', '' return 'text/plain', ''
# if no conversion asked (format empty)
# return raw data
if not format:
return self.getContentType(), self.getData()
# Check if we have already a base conversion
if not self.hasBaseData():
raise NotConvertedError
# Make sure we can support html and pdf by default # Make sure we can support html and pdf by default
is_html = 0 is_html = 0
requires_pdf_first = 0 requires_pdf_first = 0
original_format = format original_format = format
if format == 'base-data': if format == 'base-data':
if not self.hasBaseData():
raise NotConvertedError
return self.getBaseContentType(), str(self.getBaseData()) return self.getBaseContentType(), str(self.getBaseData())
if format == 'pdf': if format == 'pdf':
format_list = [x for x in self.getTargetFormatList() format_list = [x for x in self.getTargetFormatList()
...@@ -356,9 +360,6 @@ class OOoDocument(PermanentURLMixIn, BaseConvertableAndFileMixin, File, ...@@ -356,9 +360,6 @@ class OOoDocument(PermanentURLMixIn, BaseConvertableAndFileMixin, File,
# Raise an error if the format is not supported # Raise an error if the format is not supported
if not self.isTargetFormatAllowed(format): if not self.isTargetFormatAllowed(format):
raise ConversionError("OOoDocument: target format %s is not supported" % format) raise ConversionError("OOoDocument: target format %s is not supported" % format)
# Check if we have already a base conversion
if not self.hasBaseData():
raise NotConvertedError
# Return converted file # Return converted file
if requires_pdf_first: if requires_pdf_first:
# We should use original_format whenever we wish to # We should use original_format whenever we wish to
......
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