From ecf8ed8eed580cfbfa6b32a51dbdbed6cf556659 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 17 Oct 2011 15:18:44 +0100 Subject: Resolves: fdo#39347 changeall strips periods of sentences ending in error It's really dubious to do this, but we're doing it already for "Replace", just not for "Replace All". Might as well be equally wrong everywhere. --- cui/source/dialogs/SpellDialog.cxx | 48 +++++++++++++++++++++++--------------- cui/source/inc/SpellDialog.hxx | 2 ++ 2 files changed, 31 insertions(+), 19 deletions(-) (limited to 'cui') diff --git a/cui/source/dialogs/SpellDialog.cxx b/cui/source/dialogs/SpellDialog.cxx index 02be99c87cd6..8db9ef0da12b 100644 --- a/cui/source/dialogs/SpellDialog.cxx +++ b/cui/source/dialogs/SpellDialog.cxx @@ -591,6 +591,21 @@ void SpellDialog::StartSpellOptDlg_Impl() } +String SpellDialog::getReplacementString() const +{ + String aString = aSentenceED.GetErrorText(); + //dots are sometimes part of the spelled word but they are not necessarily part of the replacement + bool bDot = aString.Len() && aString.GetChar(aString.Len() - 1 ) == '.'; + if(aSuggestionLB.IsEnabled() && + aSuggestionLB.GetSelectEntryCount()>0 && + aNoSuggestionsST != aSuggestionLB.GetSelectEntry()) + aString = aSuggestionLB.GetSelectEntry(); + if(bDot && (!aString.Len() || aString.GetChar(aString.Len() - 1 ) != '.')) + aString += '.'; + + return aString; +} + // ----------------------------------------------------------------------- IMPL_LINK( SpellDialog, ChangeHdl, Button *, EMPTYARG ) @@ -602,16 +617,7 @@ IMPL_LINK( SpellDialog, ChangeHdl, Button *, EMPTYARG ) else { aSentenceED.UndoActionStart( SPELLUNDO_CHANGE_GROUP ); - String aString = aSentenceED.GetErrorText(); - //dots are sometimes part of the spelled word but they are not necessarily part of the replacement - bool bDot = aString.Len() && aString.GetChar(aString.Len() - 1 ) == '.'; - if(aSuggestionLB.IsEnabled() && - aSuggestionLB.GetSelectEntryCount()>0 && - aNoSuggestionsST != aSuggestionLB.GetSelectEntry()) - aString = aSuggestionLB.GetSelectEntry(); - if(bDot && (!aString.Len() || aString.GetChar(aString.Len() - 1 ) != '.')) - aString += '.'; - + String aString = getReplacementString(); aSentenceED.ChangeMarkedWord(aString, GetSelectedLang_Impl()); SpellContinue_Impl(); bModified = false; @@ -627,13 +633,7 @@ IMPL_LINK( SpellDialog, ChangeHdl, Button *, EMPTYARG ) IMPL_LINK( SpellDialog, ChangeAllHdl, Button *, EMPTYARG ) { aSentenceED.UndoActionStart( SPELLUNDO_CHANGE_GROUP ); - // change the current word first - String aString = aSentenceED.GetErrorText(); - if(aSuggestionLB.IsEnabled() && - aSuggestionLB.GetSelectEntryCount()>0 && - aNoSuggestionsST != aSuggestionLB.GetSelectEntry()) - aString = aSuggestionLB.GetSelectEntry(); - + String aString = getReplacementString(); LanguageType eLang = GetSelectedLang_Impl(); // add new word to ChangeAll list @@ -1238,10 +1238,20 @@ bool SpellDialog::ApplyChangeAllList_Impl(SpellPortions& rSentence, bool &bHasRe { if(aStart->xAlternatives.is()) { - Reference xEntry = xChangeAll->getEntry( aStart->sText ); + rtl::OUString &rString = aStart->sText; + + //dots are sometimes part of the spelled word but they are not necessarily part of the replacement + bool bDot = rString.getLength() && rString[rString.getLength() - 1] == '.'; + + Reference xEntry = xChangeAll->getEntry( rString ); + if(xEntry.is()) { - aStart->sText = xEntry->getReplacementText(); + rString = xEntry->getReplacementText(); + + if(bDot && (!rString.getLength() || rString[rString.getLength() - 1] != '.')) + rString = rString + rtl::OUString(static_cast('.')); + aStart->xAlternatives = 0; bHasReplaced = true; } diff --git a/cui/source/inc/SpellDialog.hxx b/cui/source/inc/SpellDialog.hxx index e9d39f679c0d..99d6af3d444b 100644 --- a/cui/source/inc/SpellDialog.hxx +++ b/cui/source/inc/SpellDialog.hxx @@ -245,6 +245,8 @@ protected: virtual void Paint( const Rectangle& rRect ); virtual long Notify( NotifyEvent& rNEvt ); + String getReplacementString() const; + public: SpellDialog( svx::SpellDialogChildWindow* pChildWindow, -- cgit v1.2.3