Hi,

zhaosheng wrote:
Hi:
In SW code, I found that there is a way to get the pointer to SWTableBox by using : SwTableBoxes& rBoxes = pLine->GetTabBoxes(); (pLine is pointer to an instance of SwTableLine ) pBox = rBoxes[ int]; this is ok. but when I merge all the cells in one column, I can't the right pointer to the instance of SwTableLine, so it will be a crash when the line is executed.
when cells have been merged, the structure of our (old) table model becomes recursive, see below.
Is there a way to get the SwTableBoxes other than SWTableLine? looking forward 
to getting your help
thanks very much.
This is not needed, you are still able to get all boxes via SwTableLines and SwTableCells, let me explain our (old) table model.

For an example we have a look at a simple 3x3 table.
The model is a SwTable object, let's call it aTable.
It contains a member aLines, which is an array of SwTableLine objects, in our example the array has the size 3:
aTable.aLine[0] is the first row, aTable.aLines[1] is the second row etc.
A SwTableLine contains a member aBoxes, which is an array of SwTableBox. In our example every SwTableLine contains three cells:
aTable.aLine[0].aBoxes[0] is the first cell of the first line etc.
A SwTableBox object has a member pSttNd, which points to the SwStartNode in the document model (nodes array).
So far, so good.
What happens to the table if you merge the three cells of the first column?
The size of aTable.aLines will be reduced to 1, your table will contain only one table row!
aTable.aLines[1] and aTable.aLines[2] does not exist any longer.
aTable.aLines[0].aBoxes becomes the size 2, aTable.aLines[0].aBoxes[2] disappears. aTable.aLines[0].aBoxes[0].pSttNd will point to the content of cell "A1", the big, merged cell. aTable.aLines[0].aBoxes[1].pSttNd will point to zero, because it's no longer a simple cell, it's a subtable. Have a look a the member aLines of the SwTableBox object. This is an array of SwTableLine. For simple table cell this array is empty and the pSttNd pointer is set to an existing SwStartNode, for complex table cells, the pSttNd pointer is empty and the aLines array has at least one entry. In our example, the aTable.aLines[0].aBoxes[1].aLines array will have the size three. Every entry is a SwTableLine object with two SwTableBox objects in its aBoxes array. The main thing is, a SwTableBox represent either a simple table cell (pSttNd is set, aLines is empty) or a "subtable" (pSttNd is empty, aLines has a size > 0). If you have a look at the stauts bar, you will notice the name of cells for the 3x3 table was "A1", "B1", "C1" etc. before the m erging, but afterwards you get names like "A1", "B1.1.1", "B1.2.1" etc. If you have a very complex table and a cell named e.g. "C3.2.1.4.5" you will be able to get the SwStartNode with
aTable.aLines[2].aBoxes[2].aLines[0].aBoxes[1].aLines[4].aBoxes[3]

Within our new table model (introduced with CWS swnewtable, integrated into src680m205) subtables are not used, every SwTableBox will contains a non.empty pSttNd and an empty aLines array. But that's another story, told another time. And be aware, we still support the old table model.


zhaosheng
2007-05-17
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]

Reply via email to