sw/source/uibase/app/docsh2.cxx           |    3 +++
 sw/source/uibase/docvw/AnnotationWin2.cxx |    6 ++----
 sw/source/uibase/docvw/PostItMgr.cxx      |    5 +++++
 sw/source/uibase/shells/langhelper.cxx    |   19 ++-----------------
 4 files changed, 12 insertions(+), 21 deletions(-)

New commits:
commit 5ca721c182251e94922a7d11c6756f8ba789a574
Author:     Maxim Monastirsky <momonas...@gmail.com>
AuthorDate: Mon Jun 19 15:45:06 2023 +0300
Commit:     Maxim Monastirsky <momonas...@gmail.com>
CommitDate: Fri Jun 23 08:30:27 2023 +0200

    tdf#103064 Refresh spellcheck marks on default lang change
    
    i.e. Tools > Language > For All Text, or Tools > Options... >
    Language Settings > Languages.
    
    The new language was already set as a pool default and picked by
    comments, just the spellcheck marks weren't refreshed.
    
    Another issue is that (unlike the Options dialog) menu items for
    specific languages (e.g. "English (USA)") also reset language
    settings in all paragraph/character styles, as implemented in
    tdf#35282, and this needs to be broadcasted as style modification.
    However as it turns out, the problem described in tdf#35282 was
    also reported in i#102191, for which the OOo devs provided a
    different fix (setting the new lang as DF), which was eventually
    merged as well as commit 8780cc5c294085fe7379a24eee58ac446cc40d0c
    ("cws tl84: #i102191# 'set language for all text' now uses
    hard language attribute"). So now we have two solutions for
    the same problem applied both. Given this, I prefer to instead
    revert the commit of tdf#35282, as it seems odd that a menu that
    claims to modify text actually modifies arbitrary styles (which
    might not even be used in the text).
    
    (fwiw there is also a third possible solution for i#102191/tdf#35282
    which wasn't even discussed: Just rename the menu title from
    "For All Text" to "Document", as the problem seems to be really
    that the menu title sets wrong expectations that it modifies the
    text attributes, and not just the document defaults.)
    
    An open question regarding the fix of i#102191 is whether
    comments and shapes should also get the default language as DF.
    This actually used to work for comments until recently, as we used
    to force the document body language on attached comments. But this
    is no longer the case, so a different solution would need to be
    developed if this is still wanted.
    
    Change-Id: Ib097765e30a7272270737fc61df6d10aa51565fb
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153477
    Tested-by: Jenkins
    Reviewed-by: Maxim Monastirsky <momonas...@gmail.com>

diff --git a/sw/source/uibase/app/docsh2.cxx b/sw/source/uibase/app/docsh2.cxx
index 4de0e8eae7ed..0a8e4e6c7900 100644
--- a/sw/source/uibase/app/docsh2.cxx
+++ b/sw/source/uibase/app/docsh2.cxx
@@ -875,8 +875,11 @@ void SwDocShell::Execute(SfxRequest& rReq)
             }
             break;
             case SID_SPELLCHECKER_CHANGED:
+            {
                 //! false, true, true is on the save side but a probably 
overdone
                 SwModule::CheckSpellChanges(false, true, true, false );
+                Broadcast(SfxHint(SfxHintId::LanguageChanged));
+            }
             break;
 
         case SID_MAIL_PREPAREEXPORT:
diff --git a/sw/source/uibase/docvw/AnnotationWin2.cxx 
b/sw/source/uibase/docvw/AnnotationWin2.cxx
index 86348469f853..834b03839835 100644
--- a/sw/source/uibase/docvw/AnnotationWin2.cxx
+++ b/sw/source/uibase/docvw/AnnotationWin2.cxx
@@ -1243,11 +1243,9 @@ void SwAnnotationWin::SetSpellChecking()
     {
         const SwViewOption* pVOpt = pWrtShell->GetViewOptions();
         EEControlBits nCntrl = mpOutliner->GetControlWord();
+        mpOutliner->SetControlWord(nCntrl & ~EEControlBits::ONLINESPELLING);
         if (pVOpt->IsOnlineSpell())
-            nCntrl |= EEControlBits::ONLINESPELLING;
-        else
-            nCntrl &= ~EEControlBits::ONLINESPELLING;
-        mpOutliner->SetControlWord(nCntrl);
+            mpOutliner->SetControlWord(nCntrl | EEControlBits::ONLINESPELLING);
 
         mpOutliner->CompleteOnlineSpelling();
         Invalidate();
diff --git a/sw/source/uibase/docvw/PostItMgr.cxx 
b/sw/source/uibase/docvw/PostItMgr.cxx
index 91dfcd2f2774..2d08a3941ac9 100644
--- a/sw/source/uibase/docvw/PostItMgr.cxx
+++ b/sw/source/uibase/docvw/PostItMgr.cxx
@@ -479,6 +479,11 @@ void SwPostItMgr::Notify( SfxBroadcaster& rBC, const 
SfxHint& rHint )
                 }
                 break;
             }
+            case SfxHintId::LanguageChanged:
+            {
+                SetSpellChecking();
+                break;
+            }
             case SfxHintId::SwSplitNodeOperation:
             {
                 // if we are in a SplitNode/Cut operation, do not delete note 
and then add again, as this will flicker
diff --git a/sw/source/uibase/shells/langhelper.cxx 
b/sw/source/uibase/shells/langhelper.cxx
index e4c2ba715a4f..219b02cbca70 100644
--- a/sw/source/uibase/shells/langhelper.cxx
+++ b/sw/source/uibase/shells/langhelper.cxx
@@ -247,23 +247,7 @@ namespace SwLangHelper
             }
             //Set the default document language
             rWrtSh.SetDefault( SvxLanguageItem( nLang, nLangWhichId ) );
-
-            //Resolves: fdo#35282 Clear the language from all Text Styles, and
-            //fallback to default document language
-            const SwTextFormatColls *pColls = 
rWrtSh.GetDoc()->GetTextFormatColls();
-            for(size_t i = 0, nCount = pColls->size(); i < nCount; ++i)
-            {
-                SwTextFormatColl &rTextColl = *(*pColls)[ i ];
-                rTextColl.ResetFormatAttr(nLangWhichId);
-            }
-            //Resolves: fdo#35282 Clear the language from all Character Styles,
-            //and fallback to default document language
-            const SwCharFormats *pCharFormats = 
rWrtSh.GetDoc()->GetCharFormats();
-            for(size_t i = 0, nCount = pCharFormats->size(); i < nCount; ++i)
-            {
-                SwCharFormat &rCharFormat = *(*pCharFormats)[ i ];
-                rCharFormat.ResetFormatAttr(nLangWhichId);
-            }
+            
rWrtSh.GetDoc()->GetDocShell()->Broadcast(SfxHint(SfxHintId::LanguageChanged));
 
             // #i102191: hard set respective language attribute in text 
document
             // (for all text in the document - which should be selected by 
now...)
@@ -324,6 +308,7 @@ namespace SwLangHelper
                 rWrtSh.SetDefault( SvxLanguageItem( LANGUAGE_NONE, i ) );
                 aAttribs.insert( i );
             }
+            
rWrtSh.GetDoc()->GetDocShell()->Broadcast(SfxHint(SfxHintId::LanguageChanged));
 
             // set all language attributes to default
             // (for all text in the document - which should be selected by 
now...)

Reply via email to