https://bugs.documentfoundation.org/show_bug.cgi?id=101313
--- Comment #14 from Kevin Suo <[email protected]> --- I have doing some debugging and have found the following, but I don't think I can fix this, so could someone take a look: The code works for the Writer table like this: +---+----+----+ |a |b |c | +---+----+----+ |d |e | +--------+----+ But does not work for a Writer table like this: +-------+----+----+ |a |b |c | +---+---+----+----+ |d |e |f |g | +---+---+----+----+ The difference between the two tables is that: - In the first table, the 2nd row contains the merged cell. The right border for *each* of the cells ("d" and "e") has a corresponding aligned border in its top row (i.e. the right border of cells "b" aligns to the right border of cell "d", and the right border of cell "c" aligns to the right border of cell "e"). In such case, ScRTFParser::SeekTwips successfully finds the "nTwips" through the following code, for each of the "d" and "e" cells: ScRTFColTwips::const_iterator it = aColTwips.find( nTwips ); bool bFound = it != aColTwips.end(); sal_uInt16 nPos = it - aColTwips.begin(); *pCol = static_cast<SCCOL>(nPos); if ( bFound ) return true; -- In the second table, the 1st row contains the merged cell. The right border of "d" in the 2nd row does not have a corresponding aligned border in the 1st row (i.e. its top row), thus ScRTFParser::SeekTwips failes to find the "nTwips" through: ScRTFColTwips::const_iterator it = aColTwips.find( nTwips ); bool bFound = it != aColTwips.end(); sal_uInt16 nPos = it - aColTwips.begin(); *pCol = static_cast<SCCOL>(nPos); so it goes on to: SCCOL nCol = *pCol; // nCol is insertion position; the next one higher up is there (or not) if ( nCol < static_cast<SCCOL>(nCount) && ((aColTwips[nCol] - SC_RTFTWIPTOL) <= nTwips) ) return true; *Note* that aColTwips is always the list of right border twips of the cells in the first row, and is not updated upon the rows that followed. (i.e, for the 2nd table, aColTwips always has 3 elements which are the twips of the first row cels). At this moment *pCol is 3 because after the "find" the iterator is at the aColTwips.end(). the *pCol 3 is then passed to its caller "SeekTwips( pE->nTwips, &nCol )" in ScRTFParser::ColAdjust(), in which the column count grows to 6, and the pasted result in Calc becomes: +-------+----+----+ |a |b |c | +-------+---------+---+----+----+ |d |e |f |g | +-------+---------+---+----+----+ -- You are receiving this mail because: You are the assignee for the bug.
