Commit 771b276d authored by Nicolas Delaby's avatar Nicolas Delaby

Do not change the format provide by the user to store the conversion in cache

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@27929 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 7165bf85
# -*- coding: utf-8 -*-
############################################################################## ##############################################################################
# #
# Copyright (c) 2002-2006 Nexedi SARL and Contributors. All Rights Reserved. # Copyright (c) 2002-2006 Nexedi SARL and Contributors. All Rights Reserved.
...@@ -405,9 +406,9 @@ class OOoDocument(PermanentURLMixIn, File, ConversionCacheMixin): ...@@ -405,9 +406,9 @@ class OOoDocument(PermanentURLMixIn, File, ConversionCacheMixin):
else: else:
has_format = self.hasConversion(format=original_format, display=display) has_format = self.hasConversion(format=original_format, display=display)
elif display is None or original_format not in STANDARD_IMAGE_FORMAT_LIST: elif display is None or original_format not in STANDARD_IMAGE_FORMAT_LIST:
has_format = self.hasConversion(format=format) has_format = self.hasConversion(format=original_format)
else: else:
has_format = self.hasConversion(format=format, display=display) has_format = self.hasConversion(format=original_format, display=display)
if not has_format: if not has_format:
# Do real conversion # Do real conversion
mime, data = self._convert(format) mime, data = self._convert(format)
...@@ -432,7 +433,7 @@ class OOoDocument(PermanentURLMixIn, File, ConversionCacheMixin): ...@@ -432,7 +433,7 @@ class OOoDocument(PermanentURLMixIn, File, ConversionCacheMixin):
cs.close() cs.close()
if (display is None or original_format not in STANDARD_IMAGE_FORMAT_LIST) \ if (display is None or original_format not in STANDARD_IMAGE_FORMAT_LIST) \
and not requires_pdf_first: and not requires_pdf_first:
self.setConversion(data, mime, format=format) self.setConversion(data, mime, format=original_format)
else: else:
temp_image = self.portal_contributions.newContent( temp_image = self.portal_contributions.newContent(
portal_type='Image', portal_type='Image',
...@@ -446,15 +447,15 @@ class OOoDocument(PermanentURLMixIn, File, ConversionCacheMixin): ...@@ -446,15 +447,15 @@ class OOoDocument(PermanentURLMixIn, File, ConversionCacheMixin):
self.setConversion(data, mime, format=original_format, display=display) self.setConversion(data, mime, format=original_format, display=display)
else: else:
if display is None: if display is None:
self.setConversion(data, mime, format=format) self.setConversion(data, mime, format=original_format)
else: else:
self.setConversion(data, mime, format=format, display=display) self.setConversion(data, mime, format=original_format, display=display)
if requires_pdf_first: if requires_pdf_first:
format = original_format format = original_format
if display is None or original_format not in STANDARD_IMAGE_FORMAT_LIST: if display is None or original_format not in STANDARD_IMAGE_FORMAT_LIST:
return self.getConversion(format=format) return self.getConversion(format=original_format)
else: else:
return self.getConversion(format=format, display=display) return self.getConversion(format=original_format, display=display)
security.declareProtected(Permissions.View, 'asTextContent') security.declareProtected(Permissions.View, 'asTextContent')
def asTextContent(self): def asTextContent(self):
...@@ -494,7 +495,7 @@ class OOoDocument(PermanentURLMixIn, File, ConversionCacheMixin): ...@@ -494,7 +495,7 @@ class OOoDocument(PermanentURLMixIn, File, ConversionCacheMixin):
else: else:
mime = guess_content_type(file_name)[0] mime = guess_content_type(file_name)[0]
data = Pdata(zip_file.read(file_name)) data = Pdata(zip_file.read(file_name))
self.setConversion(data, mime, format='_embedded', file_name=file_name) self.setConversion(data, mime=mime, format='_embedded', file_name=file_name)
if must_close: if must_close:
zip_file.close() zip_file.close()
archive_file.close() archive_file.close()
......
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