tdf#123090 Handle removed column with gridSpan.
Change-Id: If477845972ce4c8e7bf09ea8718c58851a5b9740 Signed-off-by: Gülşah Köse <gulsah.kose@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/68102 Tested-by: Jenkins Reviewed-by: Andras Timar <andras.timar@collabora.com>
This commit is contained in:
committed by
Andras Timar
parent
ffc59a0c4f
commit
48ef20f203
@@ -282,21 +282,63 @@ void TableProperties::pushToPropSet( const ::oox::core::XmlFilterBase& rFilterBa
|
|||||||
std::unique_ptr<TableStyle> xTableStyleToDelete;
|
std::unique_ptr<TableStyle> xTableStyleToDelete;
|
||||||
const TableStyle& rTableStyle( getUsedTableStyle( rFilterBase, xTableStyleToDelete ) );
|
const TableStyle& rTableStyle( getUsedTableStyle( rFilterBase, xTableStyleToDelete ) );
|
||||||
sal_Int32 nRow = 0;
|
sal_Int32 nRow = 0;
|
||||||
|
|
||||||
for (auto & tableRow : mvTableRows)
|
for (auto & tableRow : mvTableRows)
|
||||||
{
|
{
|
||||||
sal_Int32 nColumn = 0;
|
sal_Int32 nColumn = 0;
|
||||||
for (auto & tableCell : tableRow.getTableCells())
|
sal_Int32 nColumnSize = tableRow.getTableCells().size();
|
||||||
|
sal_Int32 nRemovedColumn = 0; //
|
||||||
|
|
||||||
|
for (sal_Int32 nColIndex = 0; nColIndex < nColumnSize; nColIndex++)
|
||||||
{
|
{
|
||||||
TableCell& rTableCell(tableCell);
|
TableCell& rTableCell(tableRow.getTableCells().at(nColIndex));
|
||||||
|
|
||||||
if ( !rTableCell.getvMerge() && !rTableCell.gethMerge() )
|
if ( !rTableCell.getvMerge() && !rTableCell.gethMerge() )
|
||||||
{
|
{
|
||||||
uno::Reference< XTable > xTable( xColumnRowRange, uno::UNO_QUERY_THROW );
|
uno::Reference< XTable > xTable( xColumnRowRange, uno::UNO_QUERY_THROW );
|
||||||
|
bool bMerged = false;
|
||||||
|
|
||||||
if ( ( rTableCell.getRowSpan() > 1 ) || ( rTableCell.getGridSpan() > 1 ) )
|
if ( ( rTableCell.getRowSpan() > 1 ) || ( rTableCell.getGridSpan() > 1 ) )
|
||||||
|
{
|
||||||
MergeCells( xTable, nColumn, nRow, rTableCell.getGridSpan(), rTableCell.getRowSpan() );
|
MergeCells( xTable, nColumn, nRow, rTableCell.getGridSpan(), rTableCell.getRowSpan() );
|
||||||
|
|
||||||
|
if(rTableCell.getGridSpan() > 1)
|
||||||
|
{
|
||||||
|
nRemovedColumn = (rTableCell.getGridSpan() - 1);
|
||||||
|
// MergeCells removes columns. So our loop don't know that removed column and we are skip the handlingthat removed column(s).
|
||||||
|
nColIndex += nRemovedColumn;
|
||||||
|
bMerged = true; // it will adjust new column number after push current column's props with pushToXCell.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Reference< XCellRange > xCellRange( xTable, UNO_QUERY_THROW );
|
Reference< XCellRange > xCellRange( xTable, UNO_QUERY_THROW );
|
||||||
rTableCell.pushToXCell( rFilterBase, pMasterTextListStyle, xCellRange->getCellByPosition( nColumn, nRow ), *this, rTableStyle,
|
Reference < XCell > xCell;
|
||||||
nColumn, tableRow.getTableCells().size()-1, nRow, mvTableRows.size()-1 );
|
|
||||||
|
if(nRemovedColumn)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
xCell = xCellRange->getCellByPosition( nColumn, nRow );
|
||||||
|
}
|
||||||
|
catch(Exception&) //Exception can come from TableModel::getCellByPosition when an column removed while merging columns. So adjust again here.
|
||||||
|
{
|
||||||
|
xCell = xCellRange->getCellByPosition( nColumn-nRemovedColumn, nRow );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
xCell = xCellRange->getCellByPosition( nColumn, nRow );
|
||||||
|
|
||||||
|
rTableCell.pushToXCell( rFilterBase,
|
||||||
|
pMasterTextListStyle,
|
||||||
|
xCell,
|
||||||
|
*this,
|
||||||
|
rTableStyle,
|
||||||
|
nColumn,
|
||||||
|
tableRow.getTableCells().size()-1,
|
||||||
|
nRow,
|
||||||
|
mvTableRows.size()-1 );
|
||||||
|
if (bMerged)
|
||||||
|
nColumn += nRemovedColumn;
|
||||||
}
|
}
|
||||||
++nColumn;
|
++nColumn;
|
||||||
}
|
}
|
||||||
|
@@ -2518,7 +2518,7 @@ void SdImportTest::testTdf119015()
|
|||||||
uno::Reference<table::XTable> xTable(pTableObj->getTable());
|
uno::Reference<table::XTable> xTable(pTableObj->getTable());
|
||||||
|
|
||||||
// Test that we actually have three cells: this threw css.lang.IndexOutOfBoundsException
|
// Test that we actually have three cells: this threw css.lang.IndexOutOfBoundsException
|
||||||
uno::Reference<text::XTextRange> xTextRange(xTable->getCellByPosition(2, 0),
|
uno::Reference<text::XTextRange> xTextRange(xTable->getCellByPosition(1, 0),
|
||||||
uno::UNO_QUERY_THROW);
|
uno::UNO_QUERY_THROW);
|
||||||
CPPUNIT_ASSERT_EQUAL(OUString("A3"), xTextRange->getString());
|
CPPUNIT_ASSERT_EQUAL(OUString("A3"), xTextRange->getString());
|
||||||
|
|
||||||
|
@@ -251,6 +251,7 @@ void SAL_CALL CellCursor::merge( )
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
mxTable->merge( aStart.mnCol, aStart.mnRow, aEnd.mnCol - aStart.mnCol + 1, aEnd.mnRow - aStart.mnRow + 1 );
|
mxTable->merge( aStart.mnCol, aStart.mnRow, aEnd.mnCol - aStart.mnCol + 1, aEnd.mnRow - aStart.mnRow + 1 );
|
||||||
|
mxTable->optimize();
|
||||||
mxTable->setModified(true);
|
mxTable->setModified(true);
|
||||||
}
|
}
|
||||||
catch( Exception& )
|
catch( Exception& )
|
||||||
|
@@ -1839,7 +1839,6 @@ void SvxTableController::MergeRange( sal_Int32 nFirstCol, sal_Int32 nFirstRow, s
|
|||||||
}
|
}
|
||||||
|
|
||||||
xRange->merge();
|
xRange->merge();
|
||||||
mxTable->optimize();
|
|
||||||
mbHasJustMerged = true;
|
mbHasJustMerged = true;
|
||||||
setSelectedCells( maCursorFirstPos, maCursorFirstPos );
|
setSelectedCells( maCursorFirstPos, maCursorFirstPos );
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user