* src/docgen/PdfDoc.py: fix columns, error check images

* src/docgen/RTFDoc.py: error check images

svn: r6292
This commit is contained in:
Brian Matherly 2006-04-08 01:59:33 +00:00
parent a96333aa24
commit 0d8e481893
3 changed files with 26 additions and 8 deletions

View File

@ -1,3 +1,7 @@
2006-04-07 Brian Matherly <pez4brian@users.sourceforge.net>
* src/docgen/PdfDoc.py: fix columns, error check images
* src/docgen/RTFDoc.py: error check images
2006-04-07 Don Allingham <don@gramps-project.org>
* src/EditPerson.py: Fix call to EditName, pylint fixes

View File

@ -243,6 +243,13 @@ class PdfDoc(BaseDoc.BaseDoc):
self.text = ""
def end_table(self):
# Calculate optimal widths
self.cur_table_cols = []
width = float(self.cur_table.get_width()/100.0) * self.get_usable_width()
for val in range(self.cur_table.get_columns()):
percent = float(self.cur_table.get_column_width(val))/100.0
self.cur_table_cols.append(int(width * percent * cm))
ts = reportlab.platypus.tables.TableStyle(self.tblstyle)
tbl = reportlab.platypus.tables.Table(data=self.table_data,
colWidths=self.cur_table_cols,
@ -255,10 +262,6 @@ class PdfDoc(BaseDoc.BaseDoc):
self.col = 0
self.cur_row = []
self.cur_table_cols = []
width = float(self.cur_table.get_width()/100.0) * self.get_usable_width()
for val in range(self.cur_table.get_columns()):
percent = float(self.cur_table.get_column_width(val))/100.0
self.cur_table_cols.append(int(width * percent * cm))
def end_row(self):
self.table_data.append(self.cur_row)
@ -274,12 +277,9 @@ class PdfDoc(BaseDoc.BaseDoc):
else:
self.cur_row.append("")
the_width = self.cur_table_cols[self.col]
# Fill in cells that this cell spans over
for val in range(1,self.span):
self.cur_row.append("")
the_width += self.cur_table_cols[self.col+val]
self.cur_table_cols[self.col+val] = 0
self.cur_table_cols[self.col] = the_width
p = self.my_para
f = p.get_font()
@ -317,6 +317,14 @@ class PdfDoc(BaseDoc.BaseDoc):
self.tblstyle.append(('ALIGN', loc, loc, 'CENTER'))
self.tblstyle.append(('VALIGN', loc, loc, 'TOP'))
# The following lines will enable the span feature.
# This is nice, except when spanning, lines that would have overfilled
# their cells still increase the height of the cell to make room for the
# wrapped text (even though the text does not actually wrap because it
# is spanned)
#if self.span != 1:
# self.tblstyle.append(('SPAN', (self.col, self.row), (self.col + self.span - 1, self.row ) ))
self.col = self.col + self.span
self.text = ""
@ -328,6 +336,9 @@ class PdfDoc(BaseDoc.BaseDoc):
x,y = img.size()
if (x,y) == (0,0):
return
ratio = float(x_cm)*float(y)/(float(y_cm)*float(x))
if ratio < 1:

View File

@ -349,6 +349,9 @@ class RTFDoc(BaseDoc.BaseDoc):
nx,ny = im.size()
if (nx,ny) == (0,0):
return
ratio = float(x_cm)*float(ny)/(float(y_cm)*float(nx))
if ratio < 1: