* src/docgen/AbiWordDoc2.py: make sure that an object is
an image before attempting to include in in a report * src/docgen/AbiWordDoc.py: make sure that an object is an image before attempting to include in in a report * src/docgen/KwordDoc.py: make sure that an object is an image before attempting to include in in a report * src/docgen/LaTeXDoc.py: make sure that an object is an image before attempting to include in in a report * src/docgen/OpenOfficeDoc.py: make sure that an object is an image before attempting to include in in a report * src/docgen/PdfDoc.py: make sure that an object is an image before attempting to include in in a report * src/docgen/RTFDoc.py: make sure that an object is an image before attempting to include in in a report * src/plugins/Ancestors.py: make sure that an object is an image before attempting to include in in a report * src/plugins/DetAncestralReport.py: make sure that an object is an image before attempting to include in in a report * src/plugins/DetDescendantReport.py: make sure that an object is an image before attempting to include in in a report svn: r2287
This commit is contained in:
parent
a2b1e36b89
commit
94a50f3c26
@ -172,9 +172,13 @@ class AbiWordDoc(BaseDoc.BaseDoc):
|
||||
self.f.close()
|
||||
|
||||
def add_photo(self,name,pos,x_cm,y_cm):
|
||||
|
||||
try:
|
||||
image = ImgManip.ImgManip(name)
|
||||
(x,y) = image.size()
|
||||
except:
|
||||
return
|
||||
|
||||
image = ImgManip.ImgManip(name)
|
||||
(x,y) = image.size()
|
||||
aspect_ratio = float(x)/float(y)
|
||||
|
||||
if aspect_ratio > x_cm/y_cm:
|
||||
|
@ -118,8 +118,11 @@ class AbiWordDoc(BaseDoc.BaseDoc):
|
||||
self.f.close()
|
||||
|
||||
def add_photo(self,name,pos,x_cm,y_cm):
|
||||
|
||||
image = ImgManip.ImgManip(name)
|
||||
|
||||
try:
|
||||
image = ImgManip.ImgManip(name)
|
||||
except:
|
||||
return
|
||||
(x,y) = image.size()
|
||||
aspect_ratio = float(x)/float(y)
|
||||
|
||||
|
@ -409,7 +409,11 @@ class KwordDoc(BaseDoc.BaseDoc):
|
||||
|
||||
def add_photo(self,name,pos,x_cm,y_cm):
|
||||
|
||||
im = ImgManip.ImgManip(name)
|
||||
try:
|
||||
im = ImgManip.ImgManip(name)
|
||||
except:
|
||||
return
|
||||
|
||||
(x,y)= im.size()
|
||||
ratio = float(x_cm)*float(y)/(float(y_cm)*float(x))
|
||||
|
||||
|
@ -380,8 +380,13 @@ class LaTeXDoc(BaseDoc.BaseDoc):
|
||||
|
||||
def add_photo(self,name,pos,x,y):
|
||||
"""Add photo to report"""
|
||||
|
||||
try:
|
||||
pic = ImgManip.ImgManip(name)
|
||||
except:
|
||||
return
|
||||
|
||||
self.imagenum = self.imagenum + 1
|
||||
pic = ImgManip.ImgManip(name)
|
||||
picf = self.filename[:-4] + '_img' + str(self.imagenum) + '.eps'
|
||||
pic.eps_convert(picf)
|
||||
|
||||
|
@ -358,9 +358,15 @@ class OpenOfficeDoc(BaseDoc.BaseDoc):
|
||||
os.system ('/usr/bin/oowriter "$FILE" &')
|
||||
|
||||
def add_photo(self,name,pos,x_cm,y_cm):
|
||||
image = ImgManip.ImgManip(name)
|
||||
(x,y) = image.size()
|
||||
ratio = float(x_cm)*float(y)/(float(y_cm)*float(x))
|
||||
|
||||
# try to open the image. If the open fails, it probably wasn't
|
||||
# a valid image (could be a PDF, or a non-image)
|
||||
try:
|
||||
image = ImgManip.ImgManip(name)
|
||||
(x,y) = image.size()
|
||||
ratio = float(x_cm)*float(y)/(float(y_cm)*float(x))
|
||||
except:
|
||||
return
|
||||
|
||||
if ratio < 1:
|
||||
act_width = x_cm
|
||||
|
@ -286,7 +286,11 @@ class PdfDoc(BaseDoc.BaseDoc):
|
||||
self.col = self.col + self.span
|
||||
|
||||
def add_photo(self,name,pos,x_cm,y_cm):
|
||||
img = ImgManip.ImgManip(name)
|
||||
try:
|
||||
img = ImgManip.ImgManip(name)
|
||||
except:
|
||||
return
|
||||
|
||||
x,y = img.size()
|
||||
|
||||
ratio = float(x_cm)*float(y)/(float(y_cm)*float(x))
|
||||
|
@ -324,7 +324,11 @@ class RTFDoc(BaseDoc.BaseDoc):
|
||||
#
|
||||
#--------------------------------------------------------------------
|
||||
def add_photo(self,name,pos,x_cm,y_cm):
|
||||
im = ImgManip.ImgManip(name)
|
||||
try:
|
||||
im = ImgManip.ImgManip(name)
|
||||
except:
|
||||
return
|
||||
|
||||
nx,ny = im.size()
|
||||
|
||||
ratio = float(x_cm)*float(ny)/(float(y_cm)*float(nx))
|
||||
|
@ -329,9 +329,10 @@ class ComprehensiveAncestorsReport (Report.Report):
|
||||
(partner != from_family_father and
|
||||
partner != from_family_mother)):
|
||||
for photo in partner.getPhotoList ()[:1]:
|
||||
spouse.append ((self.doc.add_photo,
|
||||
[photo.ref.getPath (),
|
||||
'right', 2, 2]))
|
||||
if photo.getMimeType()[0:5] == "image":
|
||||
spouse.append ((self.doc.add_photo,
|
||||
[photo.ref.getPath (),
|
||||
'right', 2, 2]))
|
||||
|
||||
if suppress_children and len (already_described):
|
||||
style = "AR-Child"
|
||||
@ -359,8 +360,9 @@ class ComprehensiveAncestorsReport (Report.Report):
|
||||
else:
|
||||
ret.append ((self.doc.start_cell, ["AR-Photo"]))
|
||||
for photo in photos[:1]:
|
||||
ret.append ((self.doc.add_photo,
|
||||
[photo.ref.getPath (), 'left', 2, 2]))
|
||||
if photo.getMimeType()[0:5] == "image":
|
||||
ret.append ((self.doc.add_photo,
|
||||
[photo.ref.getPath (), 'left', 2, 2]))
|
||||
ret.append ((self.doc.end_cell, []))
|
||||
|
||||
ret.append ((self.doc.start_cell, ["AR-Entry"]))
|
||||
|
@ -564,15 +564,17 @@ class DetAncestorReport(Report.Report):
|
||||
#--------------------------------------------------------------------
|
||||
def insert_images(self, person, tag):
|
||||
|
||||
photos= person.getPhotoList()
|
||||
for photo in photos :
|
||||
attribs= photo.getAttributeList()
|
||||
for attrib in attribs :
|
||||
if attrib.getType() == tag:
|
||||
vlist= string.split(attrib.getValue())
|
||||
if vlist[0] == 'left' or vlist[0] == 'right':
|
||||
self.doc.add_photo(photo.ref.getPath(), vlist[0], \
|
||||
float(vlist[1]), float(vlist[2]))
|
||||
photos= person.getPhotoList()
|
||||
for photo in photos :
|
||||
if photo.getMimeType()[0:5] != "image":
|
||||
continue
|
||||
attribs= photo.getAttributeList()
|
||||
for attrib in attribs :
|
||||
if attrib.getType() == tag:
|
||||
vlist= string.split(attrib.getValue())
|
||||
if vlist[0] == 'left' or vlist[0] == 'right':
|
||||
self.doc.add_photo(photo.ref.getPath(), vlist[0], \
|
||||
float(vlist[1]), float(vlist[2]))
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
#
|
||||
@ -584,6 +586,8 @@ class DetAncestorReport(Report.Report):
|
||||
photos= person.getPhotoList()
|
||||
numPhotos= 0 # Number of photos
|
||||
for photo in photos :
|
||||
if photo.getMimeType()[0:5] != "image":
|
||||
continue
|
||||
attribs= photo.getAttributeList()
|
||||
for attrib in attribs :
|
||||
if attrib.getType() == tag:
|
||||
|
@ -559,6 +559,8 @@ class DetDescendantReport(Report.Report):
|
||||
|
||||
photos= person.getPhotoList()
|
||||
for photo in photos :
|
||||
if photo.getMimeType()[0:5] != "image":
|
||||
continue
|
||||
attribs= photo.getAttributeList()
|
||||
for attrib in attribs :
|
||||
if attrib.getType() == tag:
|
||||
@ -577,6 +579,8 @@ class DetDescendantReport(Report.Report):
|
||||
photos= person.getPhotoList()
|
||||
numPhotos= 0 # Number of photos
|
||||
for photo in photos :
|
||||
if photo.getMimeType()[0:5] != "image":
|
||||
continue
|
||||
attribs= photo.getAttributeList()
|
||||
for attrib in attribs :
|
||||
if attrib.getType() == tag:
|
||||
|
Loading…
Reference in New Issue
Block a user