From 3c03d7f8a6b1f7341d0268664f43d99d4acd7f5a Mon Sep 17 00:00:00 2001 From: Tatuya Kamada <tatuya@nexedi.com> Date: Wed, 15 Apr 2009 02:37:29 +0000 Subject: [PATCH] * Modify make ImageField-mapping-image-size-management better when image size is smaller than ODF frame size TODO: write a test git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@26419 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5OOo/FormPrintout.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/product/ERP5OOo/FormPrintout.py b/product/ERP5OOo/FormPrintout.py index 32b522f73e..f0688cfb26 100644 --- a/product/ERP5OOo/FormPrintout.py +++ b/product/ERP5OOo/FormPrintout.py @@ -178,7 +178,7 @@ class FormPrintout(Implicit, Persistent, RoleManager, Item): report_method=report_method, form=form, here=obj) - # set property to aquisition + # set property to do aquisition content_type = printout_template.content_type self.strategy = self._createStrategy(content_type) printout = self.strategy.render(extra_context=extra_context) @@ -475,6 +475,8 @@ class ODFStrategy(Implicit): if len(image_list) is 0: return element_tree path = image_field.get_value('default') + if path is not None: + path = path.encode() picture = self.getPortalObject().restrictedTraverse(path) picture_data = getattr(aq_base(picture), 'data', None) picture_type = picture.getContentType() @@ -526,7 +528,12 @@ class ODFStrategy(Implicit): height = float(picture.height()) if height: aspect_ratio = Decimal(picture.width()) / height - w = h * aspect_ratio + resize_w = h * aspect_ratio + resize_h = w / aspect_ratio + if resize_w < w: + w = resize_w + elif resize_h < h: + h = resize_h return (str(w) + unit, str(h) + unit) -- 2.30.9