sw/source/uibase/shells/langhelper.cxx | 39 +++++++++++---------------------- 1 file changed, 13 insertions(+), 26 deletions(-)
New commits: commit 4d5508e27bdccb7d1465686773bb57a14310ed14 Author: Maxim Monastirsky <momonas...@gmail.com> AuthorDate: Sun Jun 18 02:59:55 2023 +0300 Commit: Maxim Monastirsky <momonas...@gmail.com> CommitDate: Mon Jun 19 13:12:16 2023 +0200 tdf#103064 Don't overwrite all formatting with DF on lang change i.e. right click on the language field in the statusbar, and choose a language from the popup menu. We now start with an empty itemset and only put there the modified items. This in turn makes the spelling restating hack unnecessary, so move it near its last consumer in ResetLanguages. Change-Id: Ie0f97a7fa41dc19b5785a41ee2ef4fb9c814f74a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153252 Tested-by: Jenkins Reviewed-by: Maxim Monastirsky <momonas...@gmail.com> diff --git a/sw/source/uibase/shells/langhelper.cxx b/sw/source/uibase/shells/langhelper.cxx index 23ea1abd6dfd..e4c2ba715a4f 100644 --- a/sw/source/uibase/shells/langhelper.cxx +++ b/sw/source/uibase/shells/langhelper.cxx @@ -93,10 +93,9 @@ namespace SwLangHelper bool SetLanguageStatus( OutlinerView* pOLV, SfxRequest &rReq, SwView const &rView, SwWrtShell &rSh ) { bool bRestoreSelection = false; - SfxItemSet aEditAttr(pOLV->GetAttribs()); ESelection aSelection = pOLV->GetSelection(); EditView & rEditView = pOLV->GetEditView(); - EditEngine * pEditEngine = rEditView.GetEditEngine(); + SfxItemSet aEditAttr(rEditView.GetEmptyItemSet()); // get the language OUString aNewLangText; @@ -173,30 +172,6 @@ namespace SwLangHelper else SwLangHelper::SetLanguage( rSh, pOLV, aSelection, aNewLangText, bForSelection, aEditAttr ); - // ugly hack, as it seems that EditView/EditEngine does not update their spellchecking marks - // when setting a new language attribute - if (bForSelection) - { - if (SwWrtShell* pWrtShell = rView.GetWrtShellPtr()) - { - const SwViewOption* pVOpt = pWrtShell->GetViewOptions(); - EEControlBits nCntrl = pEditEngine->GetControlWord(); - // turn off - nCntrl &= ~EEControlBits::ONLINESPELLING; - pEditEngine->SetControlWord(nCntrl); - - //turn back on - if (pVOpt->IsOnlineSpell()) - nCntrl |= EEControlBits::ONLINESPELLING; - else - nCntrl &= ~EEControlBits::ONLINESPELLING; - pEditEngine->SetControlWord(nCntrl); - - pEditEngine->CompleteOnlineSpelling(); - rEditView.Invalidate(); - } - } - if (!bForSelection) { // need to release view and restore selection... @@ -369,6 +344,18 @@ namespace SwLangHelper rEditView.RemoveAttribs( true, EE_CHAR_LANGUAGE ); rEditView.RemoveAttribs( true, EE_CHAR_LANGUAGE_CJK ); rEditView.RemoveAttribs( true, EE_CHAR_LANGUAGE_CTL ); + + // ugly hack, as it seems that EditView/EditEngine does not update their spellchecking marks + // when setting a new language attribute + EditEngine* pEditEngine = rEditView.GetEditEngine(); + EEControlBits nCntrl = pEditEngine->GetControlWord(); + // turn off + pEditEngine->SetControlWord(nCntrl & ~EEControlBits::ONLINESPELLING); + //turn back on + pEditEngine->SetControlWord(nCntrl); + pEditEngine->CompleteOnlineSpelling(); + + rEditView.Invalidate(); } else {