diff options
author | Tamás Zolnai <tamas.zolnai@collabora.com> | 2020-03-16 18:45:11 +0100 |
---|---|---|
committer | Tamás Zolnai <tamas.zolnai@collabora.com> | 2020-03-17 11:41:15 +0100 |
commit | ac83f2da9c21c3986fc50ee7203e43bc1f93cf31 (patch) | |
tree | 5b4b87d0d13118e6b050ab3ca58b230174167e73 /sc | |
parent | a00a3d681ec95841a5f6a879b05c6438d18161b4 (diff) |
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@collabora.com>
Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/ui/docshell/docsh4.cxx | 53 |
1 files changed, 52 insertions, 1 deletions
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() ) { |