[Libreoffice-commits] core.git: sc/source

Tamás Zolnai (via logerrit) logerrit at kemper.freedesktop.org
Tue Mar 17 10:41:51 UTC 2020


 sc/source/ui/docshell/docsh4.cxx |   53 ++++++++++++++++++++++++++++++++++++++-
 1 file changed, 52 insertions(+), 1 deletion(-)

New commits:
commit ac83f2da9c21c3986fc50ee7203e43bc1f93cf31
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Mon Mar 16 18:45:11 2020 +0100
Commit:     Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Tue Mar 17 11:41:15 2020 +0100

    sc lok: Implement execution of SID_LANGUAGE_STATUS...
    
    Also for selection and paragraph which is used by the
    spellchecking context menu.
    
    Change-Id: I583caf48b9176ef4d6971cfe3b445080d01dc531
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90599
    Tested-by: Tamás Zolnai <tamas.zolnai at collabora.com>
    Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>

diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx
index e07000300000..b35ce4ddc964 100644
--- a/sc/source/ui/docshell/docsh4.cxx
+++ b/sc/source/ui/docshell/docsh4.cxx
@@ -105,6 +105,8 @@ using namespace ::com::sun::star;
 #include <memory>
 #include <sfx2/notebookbar/SfxNotebookBar.hxx>
 #include <helpids.h>
+#include <editeng/eeitem.hxx>
+#include <editeng/langitem.hxx>
 
 #include <svx/xdef.hxx>
 
@@ -1166,10 +1168,15 @@ void ScDocShell::Execute( SfxRequest& rReq )
             if ( !aLangText.isEmpty() )
             {
                 LanguageType eLang, eLatin, eCjk, eCtl;
+                const OUString aSelectionLangPrefix("Current_");
+                const OUString aParagraphLangPrefix("Paragraph_");
                 const OUString aDocLangPrefix("Default_");
                 const OUString aNoLang("LANGUAGE_NONE");
                 const OUString aResetLang("RESET_LANGUAGES");
 
+                bool bSelection = false;
+                bool bParagraph = false;
+
                 ScDocument& rDoc = GetDocument();
                 rDoc.GetLanguage( eLatin, eCjk, eCtl );
 
@@ -1211,8 +1218,52 @@ void ScDocShell::Execute( SfxRequest& rReq )
                         }
                     }
                 }
+                else if (-1 != (nPos = aLangText.indexOf( aSelectionLangPrefix )))
+                {
+                    bSelection = true;
+                    aLangText = aLangText.replaceAt( nPos, aSelectionLangPrefix.getLength(), "" );
+                }
+                else if (-1 != (nPos = aLangText.indexOf( aParagraphLangPrefix )))
+                {
+                    bParagraph = true;
+                    aLangText = aLangText.replaceAt( nPos, aParagraphLangPrefix.getLength(), "" );
+                }
 
-                if ( eLang != eLatin )
+                if (bSelection || bParagraph)
+                {
+                    ScViewData* pViewData = GetViewData();
+                    if (!pViewData)
+                        return;
+
+                    EditView* pEditView = pViewData->GetEditView(pViewData->GetActivePart());
+                    if (!pEditView)
+                        return;
+
+                    const LanguageType nLangToUse = SvtLanguageTable::GetLanguageType( aLangText );
+                    SvtScriptType nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage( nLangToUse );
+
+                    SfxItemSet aAttrs = pEditView->GetEditEngine()->GetEmptyItemSet();
+                    if (nScriptType == SvtScriptType::LATIN)
+                        aAttrs.Put( SvxLanguageItem( nLangToUse, EE_CHAR_LANGUAGE ) );
+                    if (nScriptType == SvtScriptType::COMPLEX)
+                        aAttrs.Put( SvxLanguageItem( nLangToUse, EE_CHAR_LANGUAGE_CTL ) );
+                    if (nScriptType == SvtScriptType::ASIAN)
+                        aAttrs.Put( SvxLanguageItem( nLangToUse, EE_CHAR_LANGUAGE_CJK ) );
+                    ESelection aOldSel;
+                    if (bParagraph)
+                    {
+                        ESelection aSel = pEditView->GetSelection();
+                        aOldSel = aSel;
+                        aSel.nStartPos = 0;
+                        aSel.nEndPos = EE_TEXTPOS_ALL;
+                        pEditView->SetSelection( aSel );
+                    }
+
+                    pEditView->SetAttribs( aAttrs );
+                    if (bParagraph)
+                        pEditView->SetSelection( aOldSel );
+                }
+                else if ( eLang != eLatin )
                 {
                     if ( ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell() )
                     {


More information about the Libreoffice-commits mailing list