diff options
Diffstat (limited to 'sc/source/ui/undo')
-rw-r--r-- | sc/source/ui/undo/undodat.cxx | 129 | ||||
-rw-r--r-- | sc/source/ui/undo/undotab.cxx | 26 |
2 files changed, 109 insertions, 46 deletions
diff --git a/sc/source/ui/undo/undodat.cxx b/sc/source/ui/undo/undodat.cxx index 498060839a..f34ebba87d 100644 --- a/sc/source/ui/undo/undodat.cxx +++ b/sc/source/ui/undo/undodat.cxx @@ -77,10 +77,13 @@ OUString ScUndoDoOutline::GetComment() const void ScUndoDoOutline::Undo() { + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (!pViewShell) + return; + BeginUndo(); ScDocument& rDoc = pDocShell->GetDocument(); - ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); // sheet has to be switched over (#46952#)! @@ -114,9 +117,11 @@ void ScUndoDoOutline::Undo() void ScUndoDoOutline::Redo() { - BeginRedo(); - ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (!pViewShell) + return; + + BeginRedo(); // sheet has to be switched over (#46952#)! @@ -168,10 +173,13 @@ OUString ScUndoMakeOutline::GetComment() const void ScUndoMakeOutline::Undo() { + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (!pViewShell) + return; + BeginUndo(); ScDocument& rDoc = pDocShell->GetDocument(); - ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); SCTAB nTab = aBlockStart.Tab(); ScUndoUtil::MarkSimpleBlock( pDocShell, aBlockStart, aBlockEnd ); @@ -196,10 +204,13 @@ void ScUndoMakeOutline::Undo() void ScUndoMakeOutline::Redo() { + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (!pViewShell) + return; + BeginRedo(); ScDocument& rDoc = pDocShell->GetDocument(); - ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); ScUndoUtil::MarkSimpleBlock( pDocShell, aBlockStart, aBlockEnd ); @@ -253,10 +264,13 @@ OUString ScUndoOutlineLevel::GetComment() const void ScUndoOutlineLevel::Undo() { + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (!pViewShell) + return; + BeginUndo(); ScDocument& rDoc = pDocShell->GetDocument(); - ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); // Original Outline table @@ -288,9 +302,11 @@ void ScUndoOutlineLevel::Undo() void ScUndoOutlineLevel::Redo() { - BeginRedo(); - ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (!pViewShell) + return; + + BeginRedo(); // sheet has to be switched on or off before this (#46952#) !!! @@ -337,10 +353,13 @@ OUString ScUndoOutlineBlock::GetComment() const void ScUndoOutlineBlock::Undo() { + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (!pViewShell) + return; + BeginUndo(); ScDocument& rDoc = pDocShell->GetDocument(); - ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); SCTAB nTab = aBlockStart.Tab(); // Original Outline table @@ -387,9 +406,11 @@ void ScUndoOutlineBlock::Undo() void ScUndoOutlineBlock::Redo() { - BeginRedo(); - ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (!pViewShell) + return; + + BeginRedo(); ScUndoUtil::MarkSimpleBlock( pDocShell, aBlockStart, aBlockEnd ); if (bShow) @@ -437,10 +458,13 @@ OUString ScUndoRemoveAllOutlines::GetComment() const void ScUndoRemoveAllOutlines::Undo() { + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (!pViewShell) + return; + BeginUndo(); ScDocument& rDoc = pDocShell->GetDocument(); - ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); SCTAB nTab = aBlockStart.Tab(); // Original Outline table @@ -477,9 +501,11 @@ void ScUndoRemoveAllOutlines::Undo() void ScUndoRemoveAllOutlines::Redo() { - BeginRedo(); - ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (!pViewShell) + return; + + BeginRedo(); // sheet has to be switched over (#46952#)! @@ -523,10 +549,13 @@ OUString ScUndoAutoOutline::GetComment() const void ScUndoAutoOutline::Undo() { + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (!pViewShell) + return; + BeginUndo(); ScDocument& rDoc = pDocShell->GetDocument(); - ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); SCTAB nTab = aBlockStart.Tab(); // Original outline table @@ -561,19 +590,18 @@ void ScUndoAutoOutline::Undo() void ScUndoAutoOutline::Redo() { - BeginRedo(); - ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (!pViewShell) + return; + + BeginRedo(); SCTAB nTab = aBlockStart.Tab(); - if (pViewShell) - { - // sheet has to be switched on or off before this (#46952#) !!! + // sheet has to be switched on or off before this (#46952#) !!! - SCTAB nVisTab = pViewShell->GetViewData().GetTabNo(); - if ( nVisTab != nTab ) - pViewShell->SetTabNo( nTab ); - } + SCTAB nVisTab = pViewShell->GetViewData().GetTabNo(); + if ( nVisTab != nTab ) + pViewShell->SetTabNo( nTab ); ScRange aRange( aBlockStart.Col(), aBlockStart.Row(), nTab, aBlockEnd.Col(), aBlockEnd.Row(), nTab ); @@ -584,8 +612,7 @@ void ScUndoAutoOutline::Redo() // If it was called with a multi selection, // then this is now the enclosing range... - if (pViewShell) - pViewShell->MarkRange( aRange ); + pViewShell->MarkRange( aRange ); EndRedo(); } @@ -624,10 +651,13 @@ OUString ScUndoSubTotals::GetComment() const void ScUndoSubTotals::Undo() { + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (!pViewShell) + return; + BeginUndo(); ScDocument& rDoc = pDocShell->GetDocument(); - ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); if (nNewEndRow > aParam.nRow2) { @@ -691,9 +721,11 @@ void ScUndoSubTotals::Undo() void ScUndoSubTotals::Redo() { - BeginRedo(); - ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (!pViewShell) + return; + + BeginRedo(); SCTAB nVisTab = pViewShell->GetViewData().GetTabNo(); if ( nVisTab != nTab ) @@ -755,6 +787,9 @@ OUString ScUndoQuery::GetComment() const void ScUndoQuery::Undo() { ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (!pViewShell) + return; + if (ScTabViewShell::isAnyEditViewInRange(pViewShell, /*bColumns*/ false, aQueryParam.nRow1, aQueryParam.nRow2)) return; @@ -870,9 +905,11 @@ void ScUndoQuery::Undo() void ScUndoQuery::Redo() { - BeginRedo(); - ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (!pViewShell) + return; + + BeginRedo(); SCTAB nVisTab = pViewShell->GetViewData().GetTabNo(); if ( nVisTab != nTab ) @@ -1065,10 +1102,13 @@ OUString ScUndoImportData::GetComment() const void ScUndoImportData::Undo() { + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (!pViewShell) + return; + BeginUndo(); ScDocument& rDoc = pDocShell->GetDocument(); - ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); ScUndoUtil::MarkSimpleBlock( pDocShell, aImportParam.nCol1,aImportParam.nRow1,nTab, nEndCol,nEndRow,nTab ); @@ -1150,10 +1190,13 @@ void ScUndoImportData::Undo() void ScUndoImportData::Redo() { + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (!pViewShell) + return; + BeginRedo(); ScDocument& rDoc = pDocShell->GetDocument(); - ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); ScUndoUtil::MarkSimpleBlock( pDocShell, aImportParam.nCol1,aImportParam.nRow1,nTab, nEndCol,nEndRow,nTab ); @@ -1274,10 +1317,13 @@ OUString ScUndoRepeatDB::GetComment() const void ScUndoRepeatDB::Undo() { + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (!pViewShell) + return; + BeginUndo(); ScDocument& rDoc = pDocShell->GetDocument(); - ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); SCTAB nTab = aBlockStart.Tab(); if (bQuerySize) @@ -1375,9 +1421,12 @@ void ScUndoRepeatDB::Undo() void ScUndoRepeatDB::Redo() { + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (!pViewShell) + return; + BeginRedo(); - ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); SCTAB nTab = aBlockStart.Tab(); SCTAB nVisTab = pViewShell->GetViewData().GetTabNo(); @@ -1493,12 +1542,6 @@ void ScUndoDataPilot::Undo() pDocShell->PostPaint(aOldRange, PaintPartFlags::Grid, SC_PF_LINES); pDocShell->PostDataChanged(); - ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); - if (pViewShell) - { - //! set current sheet - } - if (xNewDPObject) { // notify API objects @@ -1887,7 +1930,7 @@ void ScUndoDataForm::DoChange( const bool bUndo ) aDrawRange.aEnd.SetCol(rDoc.MaxCol()); aDrawRange.aEnd.SetRow(rDoc.MaxRow()); nPaint |= PaintPartFlags::Top | PaintPartFlags::Left; -/*A*/ if (pViewShell) + if (pViewShell) pViewShell->AdjustBlockHeight(false); } else @@ -1902,7 +1945,7 @@ void ScUndoDataForm::DoChange( const bool bUndo ) nPaint |= PaintPartFlags::Left; aDrawRange.aEnd.SetRow(rDoc.MaxRow()); } -/*A*/ if (pViewShell && pViewShell->AdjustBlockHeight(false)) + if (pViewShell && pViewShell->AdjustBlockHeight(false)) { aDrawRange.aStart.SetCol(0); aDrawRange.aStart.SetRow(0); diff --git a/sc/source/ui/undo/undotab.cxx b/sc/source/ui/undo/undotab.cxx index 4237aab463..0eacb70d1c 100644 --- a/sc/source/ui/undo/undotab.cxx +++ b/sc/source/ui/undo/undotab.cxx @@ -105,6 +105,9 @@ void ScUndoInsertTab::SetChangeTrack() void ScUndoInsertTab::Undo() { ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (!pViewShell) + return; + pViewShell->SetTabNo(nTab); pDocShell->SetInUndo( true ); //! BeginUndo @@ -126,6 +129,8 @@ void ScUndoInsertTab::Undo() void ScUndoInsertTab::Redo() { ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (!pViewShell) + return; RedoSdrUndoAction( pDrawUndo.get() ); // Draw Redo first @@ -202,6 +207,9 @@ void ScUndoInsertTables::SetChangeTrack() void ScUndoInsertTables::Undo() { ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (!pViewShell) + return; + pViewShell->SetTabNo(nTab); pDocShell->SetInUndo( true ); //! BeginUndo @@ -225,6 +233,8 @@ void ScUndoInsertTables::Undo() void ScUndoInsertTables::Redo() { ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (!pViewShell) + return; RedoSdrUndoAction( pDrawUndo.get() ); // Draw Redo first @@ -493,9 +503,11 @@ OUString ScUndoMoveTab::GetComment() const void ScUndoMoveTab::DoChange( bool bUndo ) const { - ScDocument& rDoc = pDocShell->GetDocument(); ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (!pViewShell) + return; + ScDocument& rDoc = pDocShell->GetDocument(); if (bUndo) // UnDo { size_t i = mpNewTabs->size(); @@ -645,8 +657,11 @@ void ScUndoCopyTab::Undo() void ScUndoCopyTab::Redo() { - ScDocument& rDoc = pDocShell->GetDocument(); ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (!pViewShell) + return; + + ScDocument& rDoc = pDocShell->GetDocument(); SCTAB nDestTab = 0; for (size_t i = 0, n = mpNewTabs->size(); i < n; ++i) @@ -883,6 +898,9 @@ OUString ScUndoImportTab::GetComment() const void ScUndoImportTab::DoChange() const { ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (!pViewShell) + return; + ScDocument& rDoc = pDocShell->GetDocument(); SCTAB nTabCount = rDoc.GetTableCount(); if (pViewShell) @@ -1105,9 +1123,11 @@ ScUndoShowHideTab::~ScUndoShowHideTab() void ScUndoShowHideTab::DoChange( bool bShowP ) const { - ScDocument& rDoc = pDocShell->GetDocument(); ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (!pViewShell) + return; + ScDocument& rDoc = pDocShell->GetDocument(); for(const SCTAB& nTab : undoTabs) { rDoc.SetVisible( nTab, bShowP ); |