[Libreoffice-commits] core.git: Branch 'libreoffice-6-4' - svx/source
Mark Hung (via logerrit)
logerrit at kemper.freedesktop.org
Wed Feb 26 10:22:52 UTC 2020
svx/source/table/tablecontroller.cxx | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
New commits:
commit 183294472d4d40b5ca810ffc5eeb6a3c3dc86331
Author: Mark Hung <marklh9 at gmail.com>
AuthorDate: Sat Feb 15 01:11:47 2020 +0800
Commit: Xisco Faulí <xiscofauli at libreoffice.org>
CommitDate: Wed Feb 26 11:22:20 2020 +0100
tdf#130483 prevent pasting cell exceeds the border.
When pasting a table onto another selected table,
cells are cloned from source to target including their
column span and row span. In the test case the
target table can accomodate the first cell of the
merged cells, while the rest go over the table boundary,
hence causing some exception later.
Change-Id: Iae78a9e1689571d4ea2f1ac4853f68c1f7dccb9c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88737
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
(cherry picked from commit 5f90c8bc0270f692a38073b1e4aa9e3b6ba106ed)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89442
Reviewed-by: Xisco Faulí <xiscofauli at libreoffice.org>
diff --git a/svx/source/table/tablecontroller.cxx b/svx/source/table/tablecontroller.cxx
index ffd6ca9f1e90..a153c2b6db62 100644
--- a/svx/source/table/tablecontroller.cxx
+++ b/svx/source/table/tablecontroller.cxx
@@ -2789,14 +2789,24 @@ bool SvxTableController::PasteObject( SdrTableObj const * pPasteTableObj )
// copy cell contents
for( sal_Int32 nRow = 0; nRow < nPasteRows; ++nRow )
{
- for( sal_Int32 nCol = 0; nCol < nPasteColumns; ++nCol )
+ for( sal_Int32 nCol = 0, nTargetCol = aStart.mnCol; nCol < nPasteColumns; ++nCol )
{
- CellRef xTargetCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( aStart.mnCol + nCol, aStart.mnRow + nRow ).get() ) );
+ CellRef xTargetCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nTargetCol, aStart.mnRow + nRow ).get() ) );
if( xTargetCell.is() && !xTargetCell->isMerged() )
{
- xTargetCell->AddUndo();
- xTargetCell->cloneFrom( dynamic_cast< Cell* >( xPasteTable->getCellByPosition( nCol, nRow ).get() ) );
- nCol += xTargetCell->getColumnSpan() - 1;
+ CellRef xSourceCell(dynamic_cast<Cell*>(xPasteTable->getCellByPosition(nCol, nRow).get()));
+ if (xSourceCell.is())
+ {
+ xTargetCell->AddUndo();
+ // Prevent cell span exceeding the pasting range.
+ if (nColumns < nTargetCol + xSourceCell->getColumnSpan())
+ xTargetCell->replaceContentAndFormating(xSourceCell);
+ else
+ xTargetCell->cloneFrom(xSourceCell);
+
+ nCol += xSourceCell->getColumnSpan() - 1;
+ nTargetCol += xTargetCell->getColumnSpan();
+ }
}
}
}
More information about the Libreoffice-commits
mailing list