diff options
author | Eike Rathke <erack@redhat.com> | 2020-03-14 22:08:52 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2020-03-15 11:08:34 +0100 |
commit | 5ce2125471ed3dafffbfd04e40ea5274cc548896 (patch) | |
tree | 7124c08c85961fd71b3bc73763193d1464593970 | |
parent | cf3fec9e7cadd0a6c4f42a4015df429d9e32b7e8 (diff) |
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 <erack@redhat.com>
Tested-by: Jenkins
-rw-r--r-- | sc/source/core/data/table2.cxx | 24 |
1 files changed, 24 insertions, 0 deletions
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 ) |