From 76853accf76f045fa7cbfe72a4d8ee7c3833e2db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Wed, 15 Jun 2011 10:43:50 +0100 Subject: [PATCH] Resolves: fdo#33636 spell-checker dialog itself can munge the selection It can create/activate an editview, and GetSheetSelection will take an active editview as the current selection. So from GetSheetSelection's POV activating the spellchecker changes the selection, and the SpellChecker dialog detects a selection change as indicating that the spell-checking needs to be restarted on the new selection. --- sc/source/ui/inc/spelldialog.hxx | 5 ++++- sc/source/ui/view/spelldialog.cxx | 13 ++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/sc/source/ui/inc/spelldialog.hxx b/sc/source/ui/inc/spelldialog.hxx index 1024344..dc8f7ba 100644 --- a/sc/source/ui/inc/spelldialog.hxx +++ b/sc/source/ui/inc/spelldialog.hxx @@ -38,6 +38,7 @@ class ScConversionEngineBase; class ScSelectionState; class ScTabViewShell; class ScViewData; +class ScRangeList; class ScDocShell; class ScDocument; @@ -85,11 +86,13 @@ private: typedef ::std::auto_ptr< ScConversionEngineBase > ScConvEnginePtr; typedef ::std::auto_ptr< ScDocument > ScDocumentPtr; typedef ::std::auto_ptr< ScSelectionState > ScSelectionStatePtr; + typedef ::std::auto_ptr< ScRangeList > ScRangeListPtr; ScConvEnginePtr mxEngine; ScDocumentPtr mxUndoDoc; ScDocumentPtr mxRedoDoc; - ScSelectionStatePtr mxOldSel; /// Old selection state for comparison. + ScSelectionStatePtr mxOldSel; /// For cursor position in selection + ScRangeListPtr mxOldRangeList; /// Original selection range for comparison. ScTabViewShell* mpViewShell; ScViewData* mpViewData; ScDocShell* mpDocShell; diff --git a/sc/source/ui/view/spelldialog.cxx b/sc/source/ui/view/spelldialog.cxx index 586a751..04073c7 100644 --- a/sc/source/ui/view/spelldialog.cxx +++ b/sc/source/ui/view/spelldialog.cxx @@ -158,6 +158,7 @@ void ScSpellDialogChildWindow::Reset() mxUndoDoc.reset(); mxRedoDoc.reset(); mxOldSel.reset(); + mxOldRangeList.reset(); mpViewShell = 0; mpViewData = 0; mpDocShell = 0; @@ -190,6 +191,10 @@ void ScSpellDialogChildWindow::Init() SCTAB nTab = rCursor.Tab(); ScMarkData& rMarkData = mpViewData->GetMarkData(); + + mxOldRangeList.reset(new ScRangeList); + rMarkData.FillRangeListWithMarks(mxOldRangeList.get(), true); + rMarkData.MarkToMulti(); switch( mxOldSel->GetSelectionType() ) @@ -265,15 +270,17 @@ void ScSpellDialogChildWindow::Init() bool ScSpellDialogChildWindow::IsSelectionChanged() { - if( !mxOldSel.get() || !mpViewShell || (mpViewShell != PTR_CAST( ScTabViewShell, SfxViewShell::Current() )) ) + if( !mxOldRangeList.get() || !mpViewShell || (mpViewShell != PTR_CAST( ScTabViewShell, SfxViewShell::Current() )) ) return true; if( EditView* pEditView = mpViewData->GetSpellingView() ) if( pEditView->GetEditEngine() != mxEngine.get() ) return true; - ScSelectionState aNewSel( *mpViewData ); - return mxOldSel->GetSheetSelection() != aNewSel.GetSheetSelection(); + ScRangeList aCurrentRangeList; + mpViewData->GetMarkData().FillRangeListWithMarks(&aCurrentRangeList, true); + + return (*mxOldRangeList != aCurrentRangeList); } // ============================================================================ -- 1.7.5.2