Re: Table workaround


Subject: Re: Table workaround
From: Martin Sevior (msevior@mccubbin.ph.unimelb.edu.au)
Date: Wed Dec 20 2000 - 00:49:11 CST


On Wed, 20 Dec 2000, Mike Nordell wrote:

> Assuming a Table has a fixed number of columns, but each column can
> have different width compared to its "sibling" cell above/below it,
> would the following be a starting point?
>
> // this class encapsulates the beahviour of a table at the data-level
> class Table
> {
> class Cell
> {
> text_holder (strux?)
> ...

We also have to think of attributes to define a run of text/objects in the
piece table so that they know they're in a table.

Maybe <section format="table", rows="n", columns="n">

<p row="n1" columns="n2">

Have you done tables before Mike?

> // since each cell can have different width from its
> // "sibling" above/below, we need the following data member.
> UT_uint32 m_width;
> };
> class Line
> {
> std::list<Cell> m_cells;
> };
> std::list<Line> m_lines;
> };
>
> // this class takes care of the layout of a table.
> class TableLayouter
> {
> TableLayouter(const Table& table)
> : m_table(table)
> { }
> void doLayout(whatever_data_type_it_is& blockLayout)
> {
> for line: lines in table
> {
> layout_line = new fp_Line(line);
> for cell: cells in line
> {
> pLine->add(cell)
> ...
> }
> layout_line->layout();
> blockLayout.addLine(layout_line);
> }
> blockLayout.layout();
> }
>
> const Table& m_table;
> };

This is one way of doing things. You have to make each line know where the
cell on the previous line starts and stops.

I hadn't actually thought of doing tables at the line level. I had
thought of doing them at the container level. (Like our present columns.)

I posted an idea along these lines a month ago but Eric shot me down with
the counter example of a cell spanning multiple rows.

We have to handle the cases of cells spanning multiple rows and multiple
columns but otherwise being aligned above and below. If we do it on the
line level, lines above and below have to know where the previous cell
starts and stops. This may not be so bad since it we can itterate through
getPrev() and getNext() and work out sizes and position that way.

However it is not obvious how to handle multi-row cells on the line level
since by definition a cell from above or below would have to intrude
into a current line.

Martin



This archive was generated by hypermail 2b25 : Wed Dec 20 2000 - 00:49:17 CST