Commit 6af0257c authored by Ivan Tyagov's avatar Ivan Tyagov

Any OOoDocument can make use of 'display', 'quality', 'resolution' arguments...

Any OOoDocument can make use of 'display', 'quality', 'resolution' arguments in default download like an Image (i.e. converted to an image respectively if image format passed).

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@37074 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 350150df
...@@ -48,6 +48,7 @@ from Products.ERP5.Document.File import File ...@@ -48,6 +48,7 @@ from Products.ERP5.Document.File import File
from Products.ERP5.Document.Document import Document, PermanentURLMixIn,\ from Products.ERP5.Document.Document import Document, PermanentURLMixIn,\
VALID_IMAGE_FORMAT_LIST, ConversionError, NotConvertedError VALID_IMAGE_FORMAT_LIST, ConversionError, NotConvertedError
from AccessControl.SecurityManagement import setSecurityManager from AccessControl.SecurityManagement import setSecurityManager
from Products.ERP5Type.Utils import fill_args_from_request
from zLOG import LOG, ERROR from zLOG import LOG, ERROR
# Mixin Import # Mixin Import
...@@ -154,6 +155,12 @@ class OOoDocument(PermanentURLMixIn, BaseConvertableFileMixin, File, ...@@ -154,6 +155,12 @@ class OOoDocument(PermanentURLMixIn, BaseConvertableFileMixin, File,
rx_strip = re.compile('<[^>]*?>', re.DOTALL|re.MULTILINE) rx_strip = re.compile('<[^>]*?>', re.DOTALL|re.MULTILINE)
rx_compr = re.compile('\s+') rx_compr = re.compile('\s+')
security.declareProtected('View', 'index_html')
@fill_args_from_request('display', 'quality', 'resolution')
def index_html(self, REQUEST, *args, **kw):
"""Return the document data."""
return Document.index_html(self, REQUEST, *args, **kw)
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'isSupportBaseDataConversion') 'isSupportBaseDataConversion')
def isSupportBaseDataConversion(self): def isSupportBaseDataConversion(self):
...@@ -372,13 +379,14 @@ class OOoDocument(PermanentURLMixIn, BaseConvertableFileMixin, File, ...@@ -372,13 +379,14 @@ class OOoDocument(PermanentURLMixIn, BaseConvertableFileMixin, File,
and not requires_pdf_first: and not requires_pdf_first:
self.setConversion(data, mime, format=original_format) self.setConversion(data, mime, format=original_format)
else: else:
# create temporary image and use it to resize accordingly
temp_image = self.portal_contributions.newContent( temp_image = self.portal_contributions.newContent(
portal_type='Image', portal_type='Image',
file=cStringIO.StringIO(), file=cStringIO.StringIO(),
file_name=self.getId(), file_name=self.getId(),
temp_object=1) temp_object=1)
temp_image._setData(data) temp_image._setData(data)
mime, data = temp_image.convert(original_format, display=display) mime, data = temp_image.convert(original_format, display=display, **kw)
if requires_pdf_first: if requires_pdf_first:
if display is None: if display is None:
self.setConversion(data, mime, format=original_format) self.setConversion(data, mime, format=original_format)
......
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