From ff89cf3166fd36111e205a994efa57feb99c1e2e Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Thu, 18 Nov 2010 12:16:57 +0100 Subject: [PATCH] undoapi: don't do view updates when paints are locked --- sc/source/ui/inc/docsh.hxx | 2 ++ sc/source/ui/inc/undobase.hxx | 5 +++++ sc/source/ui/undo/undobase.cxx | 16 ++++++++++++++++ sc/source/ui/undo/undoblk.cxx | 5 ++--- sc/source/ui/undo/undoblk2.cxx | 20 ++++++-------------- sc/source/ui/undo/undoblk3.cxx | 29 +++++++++++------------------ sc/source/ui/undo/undotab.cxx | 5 ++--- sc/source/ui/undo/undoutil.cxx | 5 ++++- 8 files changed, 48 insertions(+), 39 deletions(-) diff --git a/sc/source/ui/inc/docsh.hxx b/sc/source/ui/inc/docsh.hxx index 86d20eb0132a..ba79cd8270ea 100644 --- a/sc/source/ui/inc/docsh.hxx +++ b/sc/source/ui/inc/docsh.hxx @@ -334,6 +334,8 @@ public: void PostPaintGridAll(); void PostPaintExtras(); + bool IsPaintLocked() const { return pPaintLockData != NULL; } + void PostDataChanged(); void UpdatePaintExt( USHORT& rExtFlags, SCCOL nStartCol, SCROW nStartRow, SCTAB nStartTab, diff --git a/sc/source/ui/inc/undobase.hxx b/sc/source/ui/inc/undobase.hxx index 6f2bb3572832..ea7885b2859b 100644 --- a/sc/source/ui/inc/undobase.hxx +++ b/sc/source/ui/inc/undobase.hxx @@ -31,6 +31,7 @@ #include #include "global.hxx" #include "address.hxx" +#include "docsh.hxx" class ScDocument; class ScDocShell; @@ -53,6 +54,10 @@ protected: ScDocShell* pDocShell; SfxUndoAction* pDetectiveUndo; + bool IsPaintLocked() const { return pDocShell->IsPaintLocked(); } + + bool SetViewMarkData( const ScMarkData& rMarkData ); + void BeginUndo(); void EndUndo(); void BeginRedo(); diff --git a/sc/source/ui/undo/undobase.cxx b/sc/source/ui/undo/undobase.cxx index fffb76ebd061..793b416fbee4 100644 --- a/sc/source/ui/undo/undobase.cxx +++ b/sc/source/ui/undo/undobase.cxx @@ -66,6 +66,19 @@ __EXPORT ScSimpleUndo::~ScSimpleUndo() delete pDetectiveUndo; } +bool ScSimpleUndo::SetViewMarkData( const ScMarkData& rMarkData ) +{ + if ( IsPaintLocked() ) + return false; + + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if ( !pViewShell ) + return false; + + pViewShell->SetMarkData( rMarkData ); + return true; +} + BOOL __EXPORT ScSimpleUndo::Merge( SfxUndoAction *pNextAction ) { // Zu jeder Undo-Action kann eine SdrUndoGroup fuer das Aktualisieren @@ -253,6 +266,9 @@ BOOL ScBlockUndo::AdjustHeight() void ScBlockUndo::ShowBlock() { + if ( IsPaintLocked() ) + return; + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); if (pViewShell) { diff --git a/sc/source/ui/undo/undoblk.cxx b/sc/source/ui/undo/undoblk.cxx index 3fb2c74a9954..556cd3c82d93 100644 --- a/sc/source/ui/undo/undoblk.cxx +++ b/sc/source/ui/undo/undoblk.cxx @@ -1600,10 +1600,8 @@ String __EXPORT ScUndoSelectionStyle::GetComment() const void ScUndoSelectionStyle::DoChange( const BOOL bUndo ) { ScDocument* pDoc = pDocShell->GetDocument(); - ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); - if (pViewShell) - pViewShell->SetMarkData( aMarkData ); + SetViewMarkData( aMarkData ); ScRange aWorkRange( aRange ); if ( pDoc->HasAttrib( aWorkRange, HASATTR_MERGED ) ) // zusammengefasste Zellen? @@ -1635,6 +1633,7 @@ void ScUndoSelectionStyle::DoChange( const BOOL bUndo ) pDocShell->UpdatePaintExt( nExtFlags, aWorkRange ); + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); if ( !( (pViewShell) && pViewShell->AdjustBlockHeight() ) ) /*A*/ pDocShell->PostPaint( aWorkRange, PAINT_GRID | PAINT_EXTRAS, nExtFlags ); diff --git a/sc/source/ui/undo/undoblk2.cxx b/sc/source/ui/undo/undoblk2.cxx index 2ab03eb71923..a7ddfaf6f23f 100644 --- a/sc/source/ui/undo/undoblk2.cxx +++ b/sc/source/ui/undo/undoblk2.cxx @@ -113,18 +113,13 @@ void __EXPORT ScUndoWidthOrHeight::Undo() BeginUndo(); ScDocument* pDoc = pDocShell->GetDocument(); - ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); SCCOLROW nPaintStart = nStart > 0 ? nStart-1 : static_cast(0); if (eMode==SC_SIZE_OPTIMAL) { - if (pViewShell) - { - pViewShell->SetMarkData( aMarkData ); - + if ( SetViewMarkData( aMarkData ) ) nPaintStart = 0; // paint all, because of changed selection - } } //! outlines from all tables? @@ -155,6 +150,7 @@ void __EXPORT ScUndoWidthOrHeight::Undo() DoSdrUndoAction( pDrawUndo, pDoc ); + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); if (pViewShell) { pViewShell->UpdateScrollBars(); @@ -171,19 +167,14 @@ void __EXPORT ScUndoWidthOrHeight::Redo() { BeginRedo(); - ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); - BOOL bPaintAll = FALSE; if (eMode==SC_SIZE_OPTIMAL) { - if (pViewShell) - { - pViewShell->SetMarkData( aMarkData ); - + if ( SetViewMarkData( aMarkData ) ) bPaintAll = TRUE; // paint all, because of changed selection - } } + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); if (pViewShell) { SCTAB nTab = pViewShell->GetViewData()->GetTabNo(); @@ -192,7 +183,8 @@ void __EXPORT ScUndoWidthOrHeight::Redo() } // SetWidthOrHeight aendert aktuelle Tabelle ! - pViewShell->SetWidthOrHeight( bWidth, nRangeCnt, pRanges, eMode, nNewSize, FALSE, TRUE, &aMarkData ); + if ( pViewShell ) + pViewShell->SetWidthOrHeight( bWidth, nRangeCnt, pRanges, eMode, nNewSize, FALSE, TRUE, &aMarkData ); // paint grid if selection was changed directly at the MarkData if (bPaintAll) diff --git a/sc/source/ui/undo/undoblk3.cxx b/sc/source/ui/undo/undoblk3.cxx index 506afeac138e..6a9c7e12af23 100644 --- a/sc/source/ui/undo/undoblk3.cxx +++ b/sc/source/ui/undo/undoblk3.cxx @@ -147,10 +147,8 @@ void ScUndoDeleteContents::SetChangeTrack() void ScUndoDeleteContents::DoChange( const BOOL bUndo ) { ScDocument* pDoc = pDocShell->GetDocument(); - ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); - if (pViewShell) - pViewShell->SetMarkData( aMarkData ); + SetViewMarkData( aMarkData ); USHORT nExtFlags = 0; @@ -195,6 +193,7 @@ void ScUndoDeleteContents::DoChange( const BOOL bUndo ) SetChangeTrack(); } + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); if ( !( (pViewShell) && pViewShell->AdjustRowHeight( aRange.aStart.Row(), aRange.aEnd.Row() ) ) ) /*A*/ pDocShell->PostPaint( aRange, PAINT_GRID | PAINT_EXTRAS, nExtFlags ); @@ -341,10 +340,8 @@ void ScUndoFillTable::SetChangeTrack() void ScUndoFillTable::DoChange( const BOOL bUndo ) { ScDocument* pDoc = pDocShell->GetDocument(); - ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); - if (pViewShell) - pViewShell->SetMarkData( aMarkData ); + SetViewMarkData( aMarkData ); if (bUndo) // nur Undo { @@ -379,6 +376,7 @@ void ScUndoFillTable::DoChange( const BOOL bUndo ) // CellContentChanged kommt mit der Markierung + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); if (pViewShell) { SCTAB nTab = pViewShell->GetViewData()->GetTabNo(); @@ -485,10 +483,8 @@ String __EXPORT ScUndoSelectionAttr::GetComment() const void ScUndoSelectionAttr::DoChange( const BOOL bUndo ) { ScDocument* pDoc = pDocShell->GetDocument(); - ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); - if (pViewShell) - pViewShell->SetMarkData( aMarkData ); + SetViewMarkData( aMarkData ); ScRange aEffRange( aRange ); if ( pDoc->HasAttrib( aEffRange, HASATTR_MERGED ) ) // zusammengefasste Zellen? @@ -515,6 +511,7 @@ void ScUndoSelectionAttr::DoChange( const BOOL bUndo ) pDoc->ApplySelectionFrame( aMarkData, pLineOuter, pLineInner ); } + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); if ( !( (pViewShell) && pViewShell->AdjustBlockHeight() ) ) /*A*/ pDocShell->PostPaint( aEffRange, PAINT_GRID | PAINT_EXTRAS, nExtFlags ); @@ -1165,8 +1162,7 @@ void __EXPORT ScUndoReplace::Undo() DBG_ASSERT(pSearchItem->GetCommand() == SVX_SEARCHCMD_REPLACE_ALL, "ScUndoReplace:: Falscher Modus"); - if (pViewShell) - pViewShell->SetMarkData( aMarkData ); + SetViewMarkData( aMarkData ); //! markierte Tabellen //! Bereich merken ? @@ -1243,7 +1239,7 @@ void __EXPORT ScUndoReplace::Redo() { if (pViewShell) { - pViewShell->SetMarkData( aMarkData ); + SetViewMarkData( aMarkData ); pViewShell->SearchAndReplace( pSearchItem, FALSE, TRUE ); } @@ -1466,9 +1462,7 @@ void ScUndoConversion::DoChange( ScDocument* pRefDoc, const ScAddress& rCursorPo ScDocument* pDoc = pDocShell->GetDocument(); ShowTable( rCursorPos.Tab() ); - ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); - if (pViewShell) - pViewShell->SetMarkData( aMarkData ); + SetViewMarkData( aMarkData ); SCTAB nTabCount = pDoc->GetTableCount(); // Undo/Redo-doc has only selected tables @@ -1575,9 +1569,7 @@ void ScUndoRefConversion::DoChange( ScDocument* pRefDoc) ShowTable(aRange); - ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); - if (pViewShell) - pViewShell->SetMarkData( aMarkData ); + SetViewMarkData( aMarkData ); ScRange aCopyRange = aRange; SCTAB nTabCount = pDoc->GetTableCount(); @@ -1586,6 +1578,7 @@ void ScUndoRefConversion::DoChange( ScDocument* pRefDoc) pRefDoc->CopyToDocument( aCopyRange, nFlags, bMulti, pDoc, &aMarkData ); pDocShell->PostPaint( aRange, PAINT_GRID); pDocShell->PostDataChanged(); + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); if (pViewShell) pViewShell->CellContentChanged(); } diff --git a/sc/source/ui/undo/undotab.cxx b/sc/source/ui/undo/undotab.cxx index 70845f6c0bc9..f7520c235e56 100644 --- a/sc/source/ui/undo/undotab.cxx +++ b/sc/source/ui/undo/undotab.cxx @@ -901,9 +901,7 @@ void ScUndoMakeScenario::Undo() void ScUndoMakeScenario::Redo() { - ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); - if (pViewShell) - pViewShell->SetMarkData( aMarkData ); + SetViewMarkData( aMarkData ); RedoSdrUndoAction( pDrawUndo ); // Draw Redo first @@ -915,6 +913,7 @@ void ScUndoMakeScenario::Redo() bDrawIsInUndo = FALSE; pDocShell->SetInUndo( FALSE ); + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); if (pViewShell) pViewShell->SetTabNo( nDestTab, TRUE ); diff --git a/sc/source/ui/undo/undoutil.cxx b/sc/source/ui/undo/undoutil.cxx index 168975cdda3a..9cd32381c8a5 100644 --- a/sc/source/ui/undo/undoutil.cxx +++ b/sc/source/ui/undo/undoutil.cxx @@ -43,10 +43,13 @@ #include "globstr.hrc" #include "global.hxx" -void ScUndoUtil::MarkSimpleBlock( ScDocShell* /* pDocShell */, +void ScUndoUtil::MarkSimpleBlock( ScDocShell* pDocShell, SCCOL nStartX, SCROW nStartY, SCTAB nStartZ, SCCOL nEndX, SCROW nEndY, SCTAB nEndZ ) { + if ( pDocShell->IsPaintLocked() ) + return; + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); if (pViewShell) {