UNO Writer: Merging cells results in wrong column count from XTextTable

Michael Stahl mstahl at redhat.com
Thu Aug 28 11:56:26 PDT 2014


On 28/08/14 20:43, Grover Blue wrote:
> I have a Writer document with a table that has two rows and 5 columns.
> When XTextTable is first created, xTextTable.getColumns().getCount()
> returns the correct count of 5. When I merge 4 columns in the first row,
> xTextTable.getColumns().getCount() then returns a count of 2. But that's
> wrong, since row 2 has 5 columns.
> 
> 
> Is this a bug?  If not, how to properly get the number of columns/rows
> in a table?

must be this function:

> sal_Int32 SwXTableColumns::getCount(void) throw( uno::RuntimeException, std::exception )
> {
>    ...
>         SwTable* pTable = SwTable::FindTable( pFrmFmt );
>         if(!pTable->IsTblComplex())
>         {
>             SwTableLines& rLines = pTable->GetTabLines();
>             SwTableLine* pLine = rLines.front();
>             nRet = pLine->GetTabBoxes().size();
>         }
>     }
>     return nRet;
> }

as you see it just counts the cells in the first row of the table, and
calls that the number of columns...

whether that is correct or not is arguable: in core Writer tables, there
are actually no columns; there are just rows, and each rows contains
some number of cells, and there's no requirement that there must be the
same number of cells in each row; the columns in the API wrappers then
somehow badly try to emulate columns on top of the core rows-and-cells
data structure...


More information about the LibreOffice mailing list