#8 An OO road to nested tables

Unstable (example)
open
nobody
None
5
2005-07-11
2005-07-11
Anonymous
No

---> I can't really post any patches cuz the the whole
code need to be rewritten. Or not everything but just a
part of it.

Ok: Here's what you have to do to fix your tables:

First of all - you have to take heed of the fact that when
you have a nested table, it will "break" the parent table
into two parts - the portion that was before and the other
portion that comes after the nested table ends.

So... We need a way to save every bit of information
about every table...

And here's the way I used to make it work for me:

I made a new class -> TABLE

which included:
<everything that the html2pdf code uses to create
tables>
+ pointer-links:
NEXT - linked to nested table
LAST -- linked to parent.

So....

Now as we encounter the tag <table>:

1) We'll call New Table
like this:
$this->table->next=new TABLE
and well also set the new table's link to it's parent:
$this->table->next->last = $this->table
and now' we'll activate the new table:
$this->table = $this->table->next;

From now on the program will deal with the nested
table...

But... We still have another problem to solve: The
write_table function is not used to handle multiple tables
in this manner so it will write every one of these tables
into a position 0,0.

So. We have to link a specific cell of some table to a
nested table.

For that - We'll use table cell textbuffer and add a
specialcontent TABLE into it.... and in printbuffer - under
the new SWITCH call We'll add something like this:

CASE 'TABLE':
$this->table=$table->next;

... and then we call the write table function again :)

and after the call:

$this->table=$this->table->last; (back to parsing the
parent table)

And that's the whole concept... We have to go OO guy's!

Also - to restore the setting changes after you finished
to read a nestedtable you'll have to make a new class
again... named settings... :) and put it under
HTML2FPDF and TABLE classes...

The rest of it is easy...

And also: because a parent table can have a multiple
nested tables, you might have to use the $this->next ...
as an array and mark the nested table array-id into the
textbuffer specialcontent for a right call :)

PS. You have to replace every occurrence of $this-
>whetevertablesetting to $this->table-
>whatevertablesetting in the code for this kind of change
to work... :P But trust me :) It's worth it.

Allan Paiste (allan.paiste@laomaailm.ee)

Discussion


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks