sc/source/core/data/table2.cxx | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
New commits: commit 5ce2125471ed3dafffbfd04e40ea5274cc548896 Author: Eike Rathke <er...@redhat.com> AuthorDate: Sat Mar 14 22:08:52 2020 +0100 Commit: Eike Rathke <er...@redhat.com> CommitDate: Sun Mar 15 11:08:34 2020 +0100 Resolves: tdf#130371 Undo of sheet-local named expressions ... created during paste (and maybe other operations). Change-Id: I75d668f717b7336a1a65a9e02c75bf2aefe860b1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90497 Reviewed-by: Eike Rathke <er...@redhat.com> Tested-by: Jenkins diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx index 3828476810f2..80aa348ab3eb 100644 --- a/sc/source/core/data/table2.cxx +++ b/sc/source/core/data/table2.cxx @@ -52,6 +52,7 @@ #include <compressedarray.hxx> #include <brdcst.hxx> #include <refdata.hxx> +#include <docsh.hxx> #include <scitems.hxx> #include <editeng/boxitem.hxx> @@ -1167,6 +1168,14 @@ void ScTable::CopyToTable( return; bool bIsUndoDoc = pDestTab->pDocument->IsUndo(); + + if (bIsUndoDoc && (nFlags & InsertDeleteFlags::CONTENTS)) + { + // Copying formulas may create sheet-local named expressions on the + // destination sheet. Add existings to Undo first. + pDestTab->SetRangeName( std::unique_ptr<ScRangeName>( new ScRangeName( *GetRangeName()))); + } + if (nFlags != InsertDeleteFlags::NONE) { InsertDeleteFlags nTempFlags( nFlags & @@ -1321,6 +1330,21 @@ void ScTable::UndoToTable( bool bWidth = (nRow1==0 && nRow2==pDocument->MaxRow() && mpColWidth && pDestTab->mpColWidth); bool bHeight = (nCol1==0 && nCol2==pDocument->MaxCol() && mpRowHeights && pDestTab->mpRowHeights); + if ((nFlags & InsertDeleteFlags::CONTENTS) && mpRangeName) + { + // Undo sheet-local named expressions created during copying + // formulas. If mpRangeName is not set then the Undo wasn't even + // set to an empty ScRangeName map so don't "undo" that. + pDestTab->SetRangeName( std::unique_ptr<ScRangeName>( new ScRangeName( *GetRangeName()))); + if (!pDestTab->pDocument->IsClipOrUndo()) + { + ScDocShell* pDocSh = static_cast<ScDocShell*>(pDestTab->pDocument->GetDocumentShell()); + if (pDocSh) + pDocSh->SetAreasChangedNeedBroadcast(); + } + + } + for ( SCCOL i = 0; i < aCol.size(); i++) { if ( i >= nCol1 && i <= nCol2 ) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits