Commit 0de89adf authored by Nicolas Delaby's avatar Nicolas Delaby

Cache text conversion for all OOoDocuments

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@28892 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 13937057
...@@ -388,7 +388,13 @@ class OOoDocument(PermanentURLMixIn, File, ConversionCacheMixin): ...@@ -388,7 +388,13 @@ class OOoDocument(PermanentURLMixIn, File, ConversionCacheMixin):
if 'enc.txt' in format_list: if 'enc.txt' in format_list:
format = 'enc.txt' format = 'enc.txt'
elif format not in format_list: elif format not in format_list:
return self.asTextContent() #Text conversion is not supported by oood, do it in other way
if not self.hasConversion(format=original_format):
#Do real conversion for text
mime, data = self._convert(format='text-content')
self.setConversion(data, mime, format=original_format)
return mime, data
return self.getConversion(format=original_format)
# 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)
...@@ -463,7 +469,11 @@ class OOoDocument(PermanentURLMixIn, File, ConversionCacheMixin): ...@@ -463,7 +469,11 @@ class OOoDocument(PermanentURLMixIn, File, ConversionCacheMixin):
This is the simplest way, the most universal and it is compatible This is the simplest way, the most universal and it is compatible
will all formats. will all formats.
""" """
return self._convert(format='text-content') if not self.hasConversion(format='txt'):
mime, data = self._convert(format='text-content')
self.setConversion(data, mime, format='txt')
return mime, data
return self.getConversion(format='txt')
security.declareProtected(Permissions.ModifyPortalContent, security.declareProtected(Permissions.ModifyPortalContent,
'_populateConversionCacheWithHTML') '_populateConversionCacheWithHTML')
......
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