Hi Robert,
find my comments inline...
Robert Vojta wrote:
[..]
I have Java extension, which should be able to import text tables.
Almost everything works for me. I'm trying to import complex text
table (merged, splitted cells) to my internal structure, which can
handle merged, splitted cells, etc.. My question is if my approach is
good enough or if there is easier way how to import text table
structure.
Horizontal cell merging
---------------------------------
Complex table doesn't have table column separators property set, but
each table row has table column separators property set. So, to
calculate relative width of all columns, merged cells, ... I use
following algorithm ...
- initialize mTCS array
- go through all rows table column separators properties
- add all separators to mTCS array (if they're not included in mTCS array)
- sort mTCS array
Now, mTCS array contains all table column separator positions from all
rows just once and is sorted. Number of all columns is mTCS.size() +
1. To calculate relative column width and merged cells, I use
following algorithm ...
- get row table column separators property
- go through all separators from a row and compare them to calculated
mTCS array
- I can calculate column width and row span from this comparison
Example ...
- mTCS array contains these numbers - 100, 200, 300, 400, 500
- row's table column separators contains these positions - 200, 300
... so, from these numbers, I'm able to say, that the first cell in a
row is over two cells (separators 100, 200, row span = 2), second cell
in a row is over one cell (separator 300, row span = 1) and the last
cell in a row is over all remaining cells (separators 400, 500, table
end, rowspan = 3).
This (horizontal) algorithm seems sensible, small correction: you get
the column span, not the row span.
Vertical cell merging
-----------------------------
I assume that if there are cells A1, A2, A3 and A5 (A4 is missing)
that the cell A3 is merged (A3:A4 in a simple table).
Even this may be right for A4 in your example, you shouldn't use the
cell names to decide which cells are merged.
E.g if you have a 3x3 table and you merge all cells of the second row.
You will have a table with cells B1, B3 and C1, C3 but no cells B2 and C2.
But this does not mean that B2 is merged with B1 or C2 is merged with C1.
You'd better ask for the "RowSpan" property of the cells.
Conclusion
----------------
There's an easy way how to obtain cell content, formatting, etc. if I
know cell name and I'm not interested in table structure. But, there's
no easy way how to reconstruct table structure. Or am I missed
something? Some property, method, ...? Is this good approach or should
I use another one?
For col span your algorithm should work, for row span you should ask the
cells for its "RowSpan" property.
Regards,
Robert
Regards
Andreas
--
Andreas Martens (ama) - OpenOffice.org Writer
OpenOffice.org Engineering at Sun: http://blogs.sun.com/GullFOSS
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]