Commit 8f74bb98 authored by Nicolas Delaby's avatar Nicolas Delaby

Extend support of embedded Image of html -> odf conversions

If Image is a Text, then conversion to image format is performed
parent 47ab412e
......@@ -1493,6 +1493,30 @@ class TestDocument(TestDocumentMixin):
self.assertEquals(builder.extract('Pictures/%s.jpeg' % image_count),
converted_image, failure_message)
# Let's continue with Presentation Document as embbeded image
document = self.portal.document_module.newContent(portal_type='Presentation')
upload_file = makeFileUpload('TEST-en-003.odp')
image_reference = 'IMAGE-odp'
document.edit(file=upload_file, reference=image_reference)
document.publish()
transaction.commit()
self.tic()
html_content = '<p><img src="%s?format=png&amp;display=%s&amp;quality=75"/></p>' % \
(image_reference, image_display)
web_page.edit(text_content=html_content)
mime_type, odt_archive = web_page.convert('odt')
builder = OOoBuilder(odt_archive)
image_count = builder._image_count
# compute resized image for comparison
mime, converted_image = document.convert(format='png',
display=image_display,
quality=75)
# fetch image from zipped archive content
# then compare with resized ERP5 Image
self.assertEquals(builder.extract('Pictures/%s.png' % image_count),
converted_image, failure_message)
def test_addContributorToDocument(self):
"""
Test if current authenticated user is added to contributor list of document
......
......@@ -137,10 +137,12 @@ class OOOdCommandTransform(commandtransform):
odt_content_modified = True
content_type = image.getContentType()
format = image_parameter_dict.pop('format', None)
if getattr(image, 'meta_type', None) == 'ERP5 Image':
#ERP5 API
# resize image according parameters
if getattr(image, 'convert', None) is not None:
# The document support conversion so perform conversion
# according given parameters
mime, image_data = image.convert(format, **image_parameter_dict)
# wrapp converted data into OFSImage in order to compute metadatas
# on converted result
image = OFSImage(image.getId(), image.getTitle(), image_data)
# image should be OFSImage
......
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