From ac83f2da9c21c3986fc50ee7203e43bc1f93cf31 Mon Sep 17 00:00:00 2001 From: Tamás Zolnai Date: Mon, 16 Mar 2020 18:45:11 +0100 Subject: sc lok: Implement execution of SID_LANGUAGE_STATUS... MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Tamás Zolnai --- sc/source/ui/docshell/docsh4.cxx | 53 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) 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 #include #include +#include +#include #include @@ -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() ) { -- cgit