diff options
author | Tamás Zolnai <tamas.zolnai@collabora.com> | 2019-11-26 16:34:20 +0100 |
---|---|---|
committer | Tamás Zolnai <tamas.zolnai@collabora.com> | 2019-11-26 20:07:59 +0100 |
commit | 11395405d08ecb44a555fd26d0e16993cb5e13f6 (patch) | |
tree | ad426812342b0b25d4e1069464364dbda95cd769 | |
parent | 6f62a5c4ee2c1b7654c7fcaa618fb495e0d32f0a (diff) |
SpellingPopup: Fix Ignore All execution.
Change-Id: I13520c1f14530cc1f04290d4d0b204cc45b124eb
Reviewed-on: https://gerrit.libreoffice.org/83786
Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com>
Tested-by: Tamás Zolnai <tamas.zolnai@collabora.com>
-rw-r--r-- | sw/source/uibase/shells/textsh1.cxx | 87 |
1 files changed, 42 insertions, 45 deletions
diff --git a/sw/source/uibase/shells/textsh1.cxx b/sw/source/uibase/shells/textsh1.cxx index 6cc1d1d7b0c8..1b048c9d16b7 100644 --- a/sw/source/uibase/shells/textsh1.cxx +++ b/sw/source/uibase/shells/textsh1.cxx @@ -1474,58 +1474,55 @@ void SwTextShell::Execute(SfxRequest &rReq) break; case SID_SPELLCHECK_IGNORE_ALL: { - if(!rWrtSh.HasSelection()) - { - OUString sApplyText; - const SfxStringItem* pItem2 = rReq.GetArg<SfxStringItem>(FN_PARAM_1); - if (pItem2) - sApplyText = pItem2->GetValue(); + OUString sApplyText; + const SfxStringItem* pItem2 = rReq.GetArg<SfxStringItem>(FN_PARAM_1); + if (pItem2) + sApplyText = pItem2->GetValue(); - const OUString sGrammarType("Grammar"); - const OUString sSpellingType("Spelling"); + const OUString sGrammarType("Grammar"); + const OUString sSpellingType("Spelling"); - if(sApplyText == sGrammarType) - { - linguistic2::ProofreadingResult aGrammarCheckRes; - sal_Int32 nErrorInResult = -1; - uno::Sequence< OUString > aSuggestions; - sal_Int32 nErrorPosInText = -1; - SwRect aToFill; - bool bCorrectionRes = rWrtSh.GetGrammarCorrection( aGrammarCheckRes, nErrorPosInText, nErrorInResult, aSuggestions, nullptr, aToFill ); - if(bCorrectionRes) - { - try { - uno::Reference< linguistic2::XDictionary > xDictionary = LinguMgr::GetIgnoreAllList(); - aGrammarCheckRes.xProofreader->ignoreRule( - aGrammarCheckRes.aErrors[ nErrorInResult ].aRuleIdentifier, - aGrammarCheckRes.aLocale ); - // refresh the layout of the actual paragraph (faster) - SwPaM *pPaM = rWrtSh.GetCursor(); - if (pPaM) - SwEditShell::IgnoreGrammarErrorAt( *pPaM ); - // refresh the layout of all paragraphs (workaround to launch a dictionary event) - xDictionary->setActive(false); - xDictionary->setActive(true); - } - catch( const uno::Exception& ) - { - } + if(sApplyText == sGrammarType) + { + linguistic2::ProofreadingResult aGrammarCheckRes; + sal_Int32 nErrorInResult = -1; + uno::Sequence< OUString > aSuggestions; + sal_Int32 nErrorPosInText = -1; + SwRect aToFill; + bool bCorrectionRes = rWrtSh.GetGrammarCorrection( aGrammarCheckRes, nErrorPosInText, nErrorInResult, aSuggestions, nullptr, aToFill ); + if(bCorrectionRes) + { + try { + uno::Reference< linguistic2::XDictionary > xDictionary = LinguMgr::GetIgnoreAllList(); + aGrammarCheckRes.xProofreader->ignoreRule( + aGrammarCheckRes.aErrors[ nErrorInResult ].aRuleIdentifier, + aGrammarCheckRes.aLocale ); + // refresh the layout of the actual paragraph (faster) + SwPaM *pPaM = rWrtSh.GetCursor(); + if (pPaM) + SwEditShell::IgnoreGrammarErrorAt( *pPaM ); + // refresh the layout of all paragraphs (workaround to launch a dictionary event) + xDictionary->setActive(false); + xDictionary->setActive(true); } - } - else if (sApplyText == sSpellingType) - { - SwRect aToFill; - uno::Reference< linguistic2::XSpellAlternatives > xSpellAlt( rWrtSh.GetCorrection(nullptr, aToFill) ); - uno::Reference< linguistic2::XDictionary > xDictionary = LinguMgr::GetIgnoreAllList(); - OUString sWord(xSpellAlt->getWord()); - linguistic::DictionaryError nAddRes = linguistic::AddEntryToDic( xDictionary, - sWord, false, OUString() ); - if (linguistic::DictionaryError::NONE != nAddRes && !xDictionary->getEntry(sWord).is()) + catch( const uno::Exception& ) { - SvxDicError(rWrtSh.GetView().GetFrameWeld(), nAddRes); } } } + else if (sApplyText == sSpellingType) + { + SwRect aToFill; + uno::Reference< linguistic2::XSpellAlternatives > xSpellAlt( rWrtSh.GetCorrection(nullptr, aToFill) ); + uno::Reference< linguistic2::XDictionary > xDictionary = LinguMgr::GetIgnoreAllList(); + OUString sWord(xSpellAlt->getWord()); + linguistic::DictionaryError nAddRes = linguistic::AddEntryToDic( xDictionary, + sWord, false, OUString() ); + if (linguistic::DictionaryError::NONE != nAddRes && !xDictionary->getEntry(sWord).is()) + { + SvxDicError(rWrtSh.GetView().GetFrameWeld(), nAddRes); + } + } } break; case SID_SPELLCHECK_APPLY_SUGGESTION: |