7288/7290: refactor fix from matthiasbasler

Cluster DPI-aware code together
More precise comment
This commit is contained in:
Vassilii Khachaturov 2013-12-12 17:28:59 +02:00
parent 08814624b6
commit 0d61bb01ab

View File

@ -1025,10 +1025,6 @@ class ODFDoc(BaseDoc, TextDoc, DrawDoc):
pos = pos.title() if pos in ['left', 'right', 'single'] else 'Row' pos = pos.title() if pos in ['left', 'right', 'single'] else 'Row'
if crop: if crop:
dpi = ImgManip.image_dpi(file_name)
if not dpi:
dpi = (96.0,96.0) #LibOO 3.6 assumes this if image contains no DPI info
# Gramps cropping coordinates are [0, 100], so we need to convert to pixels # Gramps cropping coordinates are [0, 100], so we need to convert to pixels
# No rounding here, would lead to unwanted effects. # No rounding here, would lead to unwanted effects.
start_x = crop[0]/100.0*x start_x = crop[0]/100.0*x
@ -1042,7 +1038,11 @@ class ODFDoc(BaseDoc, TextDoc, DrawDoc):
x_cm, y_cm, int(end_x-start_x), int(end_y-start_y) x_cm, y_cm, int(end_x-start_x), int(end_y-start_y)
) )
# ODF wants crop measurements in inch. dpi = ImgManip.image_dpi(file_name)
if not dpi:
dpi = (96.0,96.0) #LibOO 3.6 assumes this if image contains no DPI info
# ODF wants crop measurements in inch and as margins from each side
left = start_x/dpi[0] left = start_x/dpi[0]
right = (x - end_x)/dpi[0] right = (x - end_x)/dpi[0]
top = start_y/dpi[1] top = start_y/dpi[1]