framework/source/uielement/langselectionstatusbarcontroller.cxx |    2 
 sc/source/ui/docshell/docsh4.cxx                                |   30 
+++++++++-
 2 files changed, 30 insertions(+), 2 deletions(-)

New commits:
commit fbbad70b9437aa2e96f004c530f2d552715cf810
Author:     Henry Castro <hcas...@collabora.com>
AuthorDate: Wed Dec 27 11:12:16 2023 -0400
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Fri Jan 5 18:14:26 2024 +0100

    tdf#127856: fix cell selection language
    
    Clicking the language in the popup Calc's status bar,
    it will change the cell range selection language property.
    
    Signed-off-by: Henry Castro <hcas...@collabora.com>
    Change-Id: I1cc218da44eff0a4d3acee7b089e54aaad474379
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161371
    Tested-by: Jenkins
    Tested-by: Caolán McNamara <caolan.mcnam...@collabora.com>
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/framework/source/uielement/langselectionstatusbarcontroller.cxx 
b/framework/source/uielement/langselectionstatusbarcontroller.cxx
index f913688526db..169583a76fcd 100644
--- a/framework/source/uielement/langselectionstatusbarcontroller.cxx
+++ b/framework/source/uielement/langselectionstatusbarcontroller.cxx
@@ -212,7 +212,7 @@ void LangSelectionStatusbarController::LangMenu(
 
     if (MID_LANG_SEL_1 <= nId && nId <= MID_LANG_SEL_9)
     {
-        if (bWriter)
+        if (bWriter || bCalc)
             aBuff.append( ".uno:LanguageStatus?Language:string=Current_" );
         else
             aBuff.append( ".uno:LanguageStatus?Language:string=Default_" );
diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx
index 08a37c9e1b62..3e316ce9420f 100644
--- a/sc/source/ui/docshell/docsh4.cxx
+++ b/sc/source/ui/docshell/docsh4.cxx
@@ -1290,7 +1290,35 @@ void ScDocShell::Execute( SfxRequest& rReq )
                     aLangText = aLangText.replaceAt( nPos, 
aParagraphLangPrefix.getLength(), u"" );
                 }
 
-                if (bSelection || bParagraph)
+                if (bSelection)
+                {
+                    ScTabViewShell* pViewShell = GetBestViewShell();
+                    const LanguageType nLangType = 
SvtLanguageTable::GetLanguageType(aLangText);
+                    const SvtScriptType nScriptType = 
SvtLanguageOptions::GetScriptTypeOfLanguage(nLangType);
+
+                    if (pViewShell)
+                    {
+                        const ScPatternAttr* pSelAttrs = 
pViewShell->GetSelectionPattern();
+                        if (pSelAttrs)
+                        {
+                            const SfxItemSet& rOldSet = 
pSelAttrs->GetItemSet();
+                            auto pNewSet = 
std::make_shared<SfxItemSet>(rOldSet);
+
+                            if (nScriptType == SvtScriptType::LATIN)
+                                pNewSet->Put(SvxLanguageItem(nLangType,
+                                                             
rOldSet.GetPool()->GetWhich(SID_ATTR_CHAR_LANGUAGE)));
+                            if (nScriptType == SvtScriptType::COMPLEX)
+                                pNewSet->Put(SvxLanguageItem(nLangType,
+                                                             
rOldSet.GetPool()->GetWhich(SID_ATTR_CHAR_CJK_LANGUAGE)));
+                            if (nScriptType == SvtScriptType::ASIAN)
+                                pNewSet->Put(SvxLanguageItem(nLangType,
+                                                             
rOldSet.GetPool()->GetWhich(SID_ATTR_CHAR_CTL_LANGUAGE)));
+
+                            pViewShell->ApplyAttributes(*pNewSet, rOldSet);
+                        }
+                    }
+                }
+                else if (bParagraph)
                 {
                     ScViewData* pViewData = GetViewData();
                     if (!pViewData)

Reply via email to