This commit is contained in:
Kovid Goyal 2007-07-30 05:34:46 +00:00
parent 5e2ed7fb4d
commit a79376875c
2 changed files with 14 additions and 9 deletions

View File

@ -1235,15 +1235,15 @@ class HTMLConverter(object):
def process_table(self, tag, tag_css): def process_table(self, tag, tag_css):
self.end_current_block() self.end_current_block()
colpad = 10 rowpad = 10
table = Table(self, tag, tag_css, rowpad=10, colpad=10) table = Table(self, tag, tag_css, rowpad=rowpad, colpad=10)
canvases = [] canvases = []
for block, xpos, ypos, delta in table.blocks(int(self.current_page.pageStyle.attrs['textwidth'])): for block, xpos, ypos, delta in table.blocks(int(self.current_page.pageStyle.attrs['textwidth'])):
if not block: if not block:
canvases.append(Canvas(int(self.current_page.pageStyle.attrs['textwidth']), ypos+colpad, canvases.append(Canvas(int(self.current_page.pageStyle.attrs['textwidth']), ypos+rowpad,
blockrule='block-fixed')) blockrule='block-fixed'))
else: else:
canvases[-1].put_object(block, xpos + int(delta/2.), 0) canvases[-1].put_object(block, xpos + int(delta/2.), ypos)
for canvas in canvases: for canvas in canvases:
self.current_page.append(canvas) self.current_page.append(canvas)

View File

@ -184,7 +184,11 @@ class Cell(object):
self.pts_to_pixels(attrs.get('linespace', ts['linespace'])) self.pts_to_pixels(attrs.get('linespace', ts['linespace']))
ws = self.pts_to_pixels(attrs.get('wordspace', ts['wordspace'])) ws = self.pts_to_pixels(attrs.get('wordspace', ts['wordspace']))
if isinstance(token, int): # Handle para and line breaks if isinstance(token, int): # Handle para and line breaks
if top != bottom: #Previous element not a line break
top = bottom top = bottom
else:
top += ls
bottom += ls
left = parindent if int == 1 else 0 left = parindent if int == 1 else 0
continue continue
if isinstance(token, Plot): if isinstance(token, Plot):
@ -310,7 +314,7 @@ class Table(object):
def get_widths(self, maxwidth): def get_widths(self, maxwidth):
''' '''
Return widths of columns + sefl.colpad Return widths of columns + self.colpad
''' '''
rows, cols = self.number_or_rows(), self.number_of_columns() rows, cols = self.number_or_rows(), self.number_of_columns()
widths = range(cols) widths = range(cols)
@ -376,12 +380,13 @@ class Table(object):
cell = cellmatrix[r][c] cell = cellmatrix[r][c]
if not cell: if not cell:
continue continue
width = sum(widths[c:c+cell.colspan]) width = sum(widths[c:c+cell.colspan])-self.colpad*cell.colspan
sypos = 0 sypos = 0
for tb in cell.text_blocks: for tb in cell.text_blocks:
tb.blockStyle = self.conv.book.create_block_style( tb.blockStyle = self.conv.book.create_block_style(
blockwidth=width, blockwidth=width,
blockheight=cell.text_block_size(tb, width)[1]) blockheight=cell.text_block_size(tb, width)[1],
blockrule='horz-fixed')
yield tb, xpos[c], sypos, delta yield tb, xpos[c], sypos, delta
sypos += tb.blockStyle.attrs['blockheight'] sypos += tb.blockStyle.attrs['blockheight']