* 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
b0f5bf62fa
commit
84b555b087
@ -173,8 +173,12 @@ class AbiWordDoc(BaseDoc.BaseDoc):
|
|||||||
|
|
||||||
def add_photo(self,name,pos,x_cm,y_cm):
|
def add_photo(self,name,pos,x_cm,y_cm):
|
||||||
|
|
||||||
|
try:
|
||||||
image = ImgManip.ImgManip(name)
|
image = ImgManip.ImgManip(name)
|
||||||
(x,y) = image.size()
|
(x,y) = image.size()
|
||||||
|
except:
|
||||||
|
return
|
||||||
|
|
||||||
aspect_ratio = float(x)/float(y)
|
aspect_ratio = float(x)/float(y)
|
||||||
|
|
||||||
if aspect_ratio > x_cm/y_cm:
|
if aspect_ratio > x_cm/y_cm:
|
||||||
|
@ -119,7 +119,10 @@ class AbiWordDoc(BaseDoc.BaseDoc):
|
|||||||
|
|
||||||
def add_photo(self,name,pos,x_cm,y_cm):
|
def add_photo(self,name,pos,x_cm,y_cm):
|
||||||
|
|
||||||
|
try:
|
||||||
image = ImgManip.ImgManip(name)
|
image = ImgManip.ImgManip(name)
|
||||||
|
except:
|
||||||
|
return
|
||||||
(x,y) = image.size()
|
(x,y) = image.size()
|
||||||
aspect_ratio = float(x)/float(y)
|
aspect_ratio = float(x)/float(y)
|
||||||
|
|
||||||
|
@ -409,7 +409,11 @@ class KwordDoc(BaseDoc.BaseDoc):
|
|||||||
|
|
||||||
def add_photo(self,name,pos,x_cm,y_cm):
|
def add_photo(self,name,pos,x_cm,y_cm):
|
||||||
|
|
||||||
|
try:
|
||||||
im = ImgManip.ImgManip(name)
|
im = ImgManip.ImgManip(name)
|
||||||
|
except:
|
||||||
|
return
|
||||||
|
|
||||||
(x,y)= im.size()
|
(x,y)= im.size()
|
||||||
ratio = float(x_cm)*float(y)/(float(y_cm)*float(x))
|
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):
|
def add_photo(self,name,pos,x,y):
|
||||||
"""Add photo to report"""
|
"""Add photo to report"""
|
||||||
self.imagenum = self.imagenum + 1
|
|
||||||
|
try:
|
||||||
pic = ImgManip.ImgManip(name)
|
pic = ImgManip.ImgManip(name)
|
||||||
|
except:
|
||||||
|
return
|
||||||
|
|
||||||
|
self.imagenum = self.imagenum + 1
|
||||||
picf = self.filename[:-4] + '_img' + str(self.imagenum) + '.eps'
|
picf = self.filename[:-4] + '_img' + str(self.imagenum) + '.eps'
|
||||||
pic.eps_convert(picf)
|
pic.eps_convert(picf)
|
||||||
|
|
||||||
|
@ -358,9 +358,15 @@ class OpenOfficeDoc(BaseDoc.BaseDoc):
|
|||||||
os.system ('/usr/bin/oowriter "$FILE" &')
|
os.system ('/usr/bin/oowriter "$FILE" &')
|
||||||
|
|
||||||
def add_photo(self,name,pos,x_cm,y_cm):
|
def add_photo(self,name,pos,x_cm,y_cm):
|
||||||
|
|
||||||
|
# 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)
|
image = ImgManip.ImgManip(name)
|
||||||
(x,y) = image.size()
|
(x,y) = image.size()
|
||||||
ratio = float(x_cm)*float(y)/(float(y_cm)*float(x))
|
ratio = float(x_cm)*float(y)/(float(y_cm)*float(x))
|
||||||
|
except:
|
||||||
|
return
|
||||||
|
|
||||||
if ratio < 1:
|
if ratio < 1:
|
||||||
act_width = x_cm
|
act_width = x_cm
|
||||||
|
@ -286,7 +286,11 @@ class PdfDoc(BaseDoc.BaseDoc):
|
|||||||
self.col = self.col + self.span
|
self.col = self.col + self.span
|
||||||
|
|
||||||
def add_photo(self,name,pos,x_cm,y_cm):
|
def add_photo(self,name,pos,x_cm,y_cm):
|
||||||
|
try:
|
||||||
img = ImgManip.ImgManip(name)
|
img = ImgManip.ImgManip(name)
|
||||||
|
except:
|
||||||
|
return
|
||||||
|
|
||||||
x,y = img.size()
|
x,y = img.size()
|
||||||
|
|
||||||
ratio = float(x_cm)*float(y)/(float(y_cm)*float(x))
|
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):
|
def add_photo(self,name,pos,x_cm,y_cm):
|
||||||
|
try:
|
||||||
im = ImgManip.ImgManip(name)
|
im = ImgManip.ImgManip(name)
|
||||||
|
except:
|
||||||
|
return
|
||||||
|
|
||||||
nx,ny = im.size()
|
nx,ny = im.size()
|
||||||
|
|
||||||
ratio = float(x_cm)*float(ny)/(float(y_cm)*float(nx))
|
ratio = float(x_cm)*float(ny)/(float(y_cm)*float(nx))
|
||||||
|
@ -329,6 +329,7 @@ class ComprehensiveAncestorsReport (Report.Report):
|
|||||||
(partner != from_family_father and
|
(partner != from_family_father and
|
||||||
partner != from_family_mother)):
|
partner != from_family_mother)):
|
||||||
for photo in partner.getPhotoList ()[:1]:
|
for photo in partner.getPhotoList ()[:1]:
|
||||||
|
if photo.getMimeType()[0:5] == "image":
|
||||||
spouse.append ((self.doc.add_photo,
|
spouse.append ((self.doc.add_photo,
|
||||||
[photo.ref.getPath (),
|
[photo.ref.getPath (),
|
||||||
'right', 2, 2]))
|
'right', 2, 2]))
|
||||||
@ -359,6 +360,7 @@ class ComprehensiveAncestorsReport (Report.Report):
|
|||||||
else:
|
else:
|
||||||
ret.append ((self.doc.start_cell, ["AR-Photo"]))
|
ret.append ((self.doc.start_cell, ["AR-Photo"]))
|
||||||
for photo in photos[:1]:
|
for photo in photos[:1]:
|
||||||
|
if photo.getMimeType()[0:5] == "image":
|
||||||
ret.append ((self.doc.add_photo,
|
ret.append ((self.doc.add_photo,
|
||||||
[photo.ref.getPath (), 'left', 2, 2]))
|
[photo.ref.getPath (), 'left', 2, 2]))
|
||||||
ret.append ((self.doc.end_cell, []))
|
ret.append ((self.doc.end_cell, []))
|
||||||
|
@ -566,6 +566,8 @@ class DetAncestorReport(Report.Report):
|
|||||||
|
|
||||||
photos= person.getPhotoList()
|
photos= person.getPhotoList()
|
||||||
for photo in photos :
|
for photo in photos :
|
||||||
|
if photo.getMimeType()[0:5] != "image":
|
||||||
|
continue
|
||||||
attribs= photo.getAttributeList()
|
attribs= photo.getAttributeList()
|
||||||
for attrib in attribs :
|
for attrib in attribs :
|
||||||
if attrib.getType() == tag:
|
if attrib.getType() == tag:
|
||||||
@ -584,6 +586,8 @@ class DetAncestorReport(Report.Report):
|
|||||||
photos= person.getPhotoList()
|
photos= person.getPhotoList()
|
||||||
numPhotos= 0 # Number of photos
|
numPhotos= 0 # Number of photos
|
||||||
for photo in photos :
|
for photo in photos :
|
||||||
|
if photo.getMimeType()[0:5] != "image":
|
||||||
|
continue
|
||||||
attribs= photo.getAttributeList()
|
attribs= photo.getAttributeList()
|
||||||
for attrib in attribs :
|
for attrib in attribs :
|
||||||
if attrib.getType() == tag:
|
if attrib.getType() == tag:
|
||||||
|
@ -559,6 +559,8 @@ class DetDescendantReport(Report.Report):
|
|||||||
|
|
||||||
photos= person.getPhotoList()
|
photos= person.getPhotoList()
|
||||||
for photo in photos :
|
for photo in photos :
|
||||||
|
if photo.getMimeType()[0:5] != "image":
|
||||||
|
continue
|
||||||
attribs= photo.getAttributeList()
|
attribs= photo.getAttributeList()
|
||||||
for attrib in attribs :
|
for attrib in attribs :
|
||||||
if attrib.getType() == tag:
|
if attrib.getType() == tag:
|
||||||
@ -577,6 +579,8 @@ class DetDescendantReport(Report.Report):
|
|||||||
photos= person.getPhotoList()
|
photos= person.getPhotoList()
|
||||||
numPhotos= 0 # Number of photos
|
numPhotos= 0 # Number of photos
|
||||||
for photo in photos :
|
for photo in photos :
|
||||||
|
if photo.getMimeType()[0:5] != "image":
|
||||||
|
continue
|
||||||
attribs= photo.getAttributeList()
|
attribs= photo.getAttributeList()
|
||||||
for attrib in attribs :
|
for attrib in attribs :
|
||||||
if attrib.getType() == tag:
|
if attrib.getType() == tag:
|
||||||
|
Loading…
Reference in New Issue
Block a user