sc/source/core/data/table2.cxx | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
New commits: commit cf2963b07b85dbf789d2b55640214523cc38f963 Author: Eike Rathke <er...@redhat.com> AuthorDate: Fri Jun 10 00:01:23 2022 +0200 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Sun Jun 12 10:13:06 2022 +0200 Resolves: tdf#148072 Restore sheet-local names for Undo of Cut Undo of Cut uses CopyToTable() and not UndoToTab() as Copy does, so copy the sheet-local names also *from* Undo and not only *to* Undo. And mark for ScAreasChanged broadcast. Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135568 Reviewed-by: Eike Rathke <er...@redhat.com> Tested-by: Jenkins (cherry picked from commit b7eddf3e9c2db503dde632b35513844806be3c36) Conflicts: sc/source/core/data/table2.cxx Change-Id: Ib07f711a7d407dafdf548873291f1ccc81b85d47 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135587 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx index 0ab94dea70bc..7f3f0d48cee4 100644 --- a/sc/source/core/data/table2.cxx +++ b/sc/source/core/data/table2.cxx @@ -1308,13 +1308,21 @@ void ScTable::CopyToTable( if (!ValidColRow(nCol1, nRow1) || !ValidColRow(nCol2, nRow2)) return; - bool bIsUndoDoc = pDestTab->rDocument.IsUndo(); + const bool bToUndoDoc = pDestTab->rDocument.IsUndo(); + const bool bFromUndoDoc = rDocument.IsUndo(); - if (bIsUndoDoc && (nFlags & InsertDeleteFlags::CONTENTS)) + if ((bToUndoDoc || bFromUndoDoc) && (nFlags & InsertDeleteFlags::CONTENTS) && mpRangeName) { // Copying formulas may create sheet-local named expressions on the // destination sheet. Add existing to Undo first. + // During Undo restore the previous named expressions. pDestTab->SetRangeName( std::unique_ptr<ScRangeName>( new ScRangeName( *GetRangeName()))); + if (!pDestTab->rDocument.IsClipOrUndo()) + { + ScDocShell* pDocSh = static_cast<ScDocShell*>(pDestTab->rDocument.GetDocumentShell()); + if (pDocSh) + pDocSh->SetAreasChangedNeedBroadcast(); + } } if (nFlags != InsertDeleteFlags::NONE) @@ -1326,14 +1334,14 @@ void ScTable::CopyToTable( // quadratically expensive with large groups. So do the grouping just once at the end. sc::DelayFormulaGroupingSwitch delayGrouping( pDestTab->rDocument, true ); for (SCCOL i = nCol1; i <= ClampToAllocatedColumns(nCol2); i++) - aCol[i].CopyToColumn(rCxt, nRow1, nRow2, bIsUndoDoc ? nFlags : nTempFlags, bMarked, + aCol[i].CopyToColumn(rCxt, nRow1, nRow2, bToUndoDoc ? nFlags : nTempFlags, bMarked, pDestTab->CreateColumnIfNotExists(i), pMarkData, bAsLink, bGlobalNamesToLocal); } if (!bColRowFlags) // Column widths/Row heights/Flags return; - if(bIsUndoDoc && (nFlags & InsertDeleteFlags::ATTRIB)) + if (bToUndoDoc && (nFlags & InsertDeleteFlags::ATTRIB)) { pDestTab->mpCondFormatList.reset(new ScConditionalFormatList(pDestTab->rDocument, *mpCondFormatList)); } @@ -1441,7 +1449,7 @@ void ScTable::CopyToTable( if(nFlags & InsertDeleteFlags::OUTLINE) // also only when bColRowFlags pDestTab->SetOutlineTable( pOutlineTable.get() ); - if (!bIsUndoDoc && bCopyCaptions && (nFlags & (InsertDeleteFlags::NOTE | InsertDeleteFlags::ADDNOTES))) + if (!bToUndoDoc && bCopyCaptions && (nFlags & (InsertDeleteFlags::NOTE | InsertDeleteFlags::ADDNOTES))) { bool bCloneCaption = (nFlags & InsertDeleteFlags::NOCAPTIONS) == InsertDeleteFlags::NONE; CopyCaptionsToTable( nCol1, nRow1, nCol2, nRow2, pDestTab, bCloneCaption);