diff options
-rw-r--r-- | sc/source/ui/inc/undocell.hxx | 4 | ||||
-rw-r--r-- | sc/source/ui/undo/undocell.cxx | 19 |
2 files changed, 18 insertions, 5 deletions
diff --git a/sc/source/ui/inc/undocell.hxx b/sc/source/ui/inc/undocell.hxx index 2ab9ab1a9cfa..3ff3127bba39 100644 --- a/sc/source/ui/inc/undocell.hxx +++ b/sc/source/ui/inc/undocell.hxx @@ -352,8 +352,9 @@ class ScUndoRangeNames: public ScSimpleUndo { public: TYPEINFO(); + //use nTab = -1 for global range names ScUndoRangeNames( ScDocShell* pNewDocShell, - ScRangeName* pOld, ScRangeName* pNew ); + ScRangeName* pOld, ScRangeName* pNew , SCTAB nTab = -1); virtual ~ScUndoRangeNames(); virtual void Undo(); @@ -366,6 +367,7 @@ public: private: ScRangeName* pOldRanges; ScRangeName* pNewRanges; + SCTAB mnTab; void DoChange( sal_Bool bUndo ); }; diff --git a/sc/source/ui/undo/undocell.cxx b/sc/source/ui/undo/undocell.cxx index fa98ed441a7d..a4c6c6dc529f 100644 --- a/sc/source/ui/undo/undocell.cxx +++ b/sc/source/ui/undo/undocell.cxx @@ -1084,10 +1084,11 @@ sal_Bool ScUndoDetective::CanRepeat(SfxRepeatTarget& /* rTarget */) const // ScUndoRangeNames::ScUndoRangeNames( ScDocShell* pNewDocShell, - ScRangeName* pOld, ScRangeName* pNew ) : + ScRangeName* pOld, ScRangeName* pNew, SCTAB nTab ) : ScSimpleUndo( pNewDocShell ), pOldRanges ( pOld ), - pNewRanges ( pNew ) + pNewRanges ( pNew ), + mnTab ( nTab ) { } @@ -1108,9 +1109,19 @@ void ScUndoRangeNames::DoChange( sal_Bool bUndo ) pDoc->CompileNameFormula( sal_True ); // CreateFormulaString if ( bUndo ) - pDoc->SetRangeName( new ScRangeName( *pOldRanges ) ); + { + if (mnTab >= 0) + pDoc->SetRangeName( mnTab, new ScRangeName( *pOldRanges ) ); + else + pDoc->SetRangeName( new ScRangeName( *pOldRanges ) ); + } else - pDoc->SetRangeName( new ScRangeName( *pNewRanges ) ); + { + if (mnTab >= 0) + pDoc->SetRangeName( mnTab, new ScRangeName( *pNewRanges ) ); + else + pDoc->SetRangeName( new ScRangeName( *pNewRanges ) ); + } pDoc->CompileNameFormula( false ); // CompileFormulaString |