Commit 3c03d7f8 authored by Tatuya Kamada's avatar Tatuya Kamada

* 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
parent dddc54f0
...@@ -178,7 +178,7 @@ class FormPrintout(Implicit, Persistent, RoleManager, Item): ...@@ -178,7 +178,7 @@ class FormPrintout(Implicit, Persistent, RoleManager, Item):
report_method=report_method, report_method=report_method,
form=form, form=form,
here=obj) here=obj)
# set property to aquisition # set property to do aquisition
content_type = printout_template.content_type content_type = printout_template.content_type
self.strategy = self._createStrategy(content_type) self.strategy = self._createStrategy(content_type)
printout = self.strategy.render(extra_context=extra_context) printout = self.strategy.render(extra_context=extra_context)
...@@ -475,6 +475,8 @@ class ODFStrategy(Implicit): ...@@ -475,6 +475,8 @@ class ODFStrategy(Implicit):
if len(image_list) is 0: if len(image_list) is 0:
return element_tree return element_tree
path = image_field.get_value('default') path = image_field.get_value('default')
if path is not None:
path = path.encode()
picture = self.getPortalObject().restrictedTraverse(path) picture = self.getPortalObject().restrictedTraverse(path)
picture_data = getattr(aq_base(picture), 'data', None) picture_data = getattr(aq_base(picture), 'data', None)
picture_type = picture.getContentType() picture_type = picture.getContentType()
...@@ -526,7 +528,12 @@ class ODFStrategy(Implicit): ...@@ -526,7 +528,12 @@ class ODFStrategy(Implicit):
height = float(picture.height()) height = float(picture.height())
if height: if height:
aspect_ratio = Decimal(picture.width()) / 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) return (str(w) + unit, str(h) + unit)
......
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