diff options
author | Caolán McNamara <caolanm@redhat.com> | 2011-10-17 15:18:44 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2011-10-17 15:21:53 +0100 |
commit | ecf8ed8eed580cfbfa6b32a51dbdbed6cf556659 (patch) | |
tree | de983e0bb51b09f9e5c3c8abc5b366b8f75678a1 | |
parent | d7aae30d6bd53eb66f6e300d024f597f70fc01fb (diff) |
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.
-rw-r--r-- | cui/source/dialogs/SpellDialog.cxx | 48 | ||||
-rw-r--r-- | cui/source/inc/SpellDialog.hxx | 2 |
2 files changed, 31 insertions, 19 deletions
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<XDictionaryEntry> 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<XDictionaryEntry> 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<sal_Unicode>('.')); + 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, |