* 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):
|
||||||
|
|
||||||
image = ImgManip.ImgManip(name)
|
try:
|
||||||
(x,y) = image.size()
|
image = ImgManip.ImgManip(name)
|
||||||
|
(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):
|
||||||
|
|
||||||
image = ImgManip.ImgManip(name)
|
try:
|
||||||
|
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):
|
||||||
|
|
||||||
im = ImgManip.ImgManip(name)
|
try:
|
||||||
|
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"""
|
||||||
|
|
||||||
|
try:
|
||||||
|
pic = ImgManip.ImgManip(name)
|
||||||
|
except:
|
||||||
|
return
|
||||||
|
|
||||||
self.imagenum = self.imagenum + 1
|
self.imagenum = self.imagenum + 1
|
||||||
pic = ImgManip.ImgManip(name)
|
|
||||||
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):
|
||||||
image = ImgManip.ImgManip(name)
|
|
||||||
(x,y) = image.size()
|
# try to open the image. If the open fails, it probably wasn't
|
||||||
ratio = float(x_cm)*float(y)/(float(y_cm)*float(x))
|
# 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:
|
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):
|
||||||
img = ImgManip.ImgManip(name)
|
try:
|
||||||
|
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):
|
||||||
im = ImgManip.ImgManip(name)
|
try:
|
||||||
|
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,9 +329,10 @@ 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]:
|
||||||
spouse.append ((self.doc.add_photo,
|
if photo.getMimeType()[0:5] == "image":
|
||||||
[photo.ref.getPath (),
|
spouse.append ((self.doc.add_photo,
|
||||||
'right', 2, 2]))
|
[photo.ref.getPath (),
|
||||||
|
'right', 2, 2]))
|
||||||
|
|
||||||
if suppress_children and len (already_described):
|
if suppress_children and len (already_described):
|
||||||
style = "AR-Child"
|
style = "AR-Child"
|
||||||
@ -359,8 +360,9 @@ 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]:
|
||||||
ret.append ((self.doc.add_photo,
|
if photo.getMimeType()[0:5] == "image":
|
||||||
[photo.ref.getPath (), 'left', 2, 2]))
|
ret.append ((self.doc.add_photo,
|
||||||
|
[photo.ref.getPath (), 'left', 2, 2]))
|
||||||
ret.append ((self.doc.end_cell, []))
|
ret.append ((self.doc.end_cell, []))
|
||||||
|
|
||||||
ret.append ((self.doc.start_cell, ["AR-Entry"]))
|
ret.append ((self.doc.start_cell, ["AR-Entry"]))
|
||||||
|
@ -564,15 +564,17 @@ class DetAncestorReport(Report.Report):
|
|||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
def insert_images(self, person, tag):
|
def insert_images(self, person, tag):
|
||||||
|
|
||||||
photos= person.getPhotoList()
|
photos= person.getPhotoList()
|
||||||
for photo in photos :
|
for photo in photos :
|
||||||
attribs= photo.getAttributeList()
|
if photo.getMimeType()[0:5] != "image":
|
||||||
for attrib in attribs :
|
continue
|
||||||
if attrib.getType() == tag:
|
attribs= photo.getAttributeList()
|
||||||
vlist= string.split(attrib.getValue())
|
for attrib in attribs :
|
||||||
if vlist[0] == 'left' or vlist[0] == 'right':
|
if attrib.getType() == tag:
|
||||||
self.doc.add_photo(photo.ref.getPath(), vlist[0], \
|
vlist= string.split(attrib.getValue())
|
||||||
float(vlist[1]), float(vlist[2]))
|
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()
|
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