diff options
author | Tamás Zolnai <tamas.zolnai@collabora.com> | 2020-03-16 16:24:48 +0100 |
---|---|---|
committer | Tamás Zolnai <tamas.zolnai@collabora.com> | 2020-03-17 11:12:47 +0100 |
commit | 6167264dace8e10fe66537bcf64eaa5904232786 (patch) | |
tree | 3f715bb06a7ef5c3b1c73734f7e38f99bffdb989 /sd/source/ui/docshell | |
parent | d7fa4fc8b64769f0d25b87ff33b8d1b8e96572d9 (diff) |
sd lok: Implement execution of SID_LANGUAGE_STATUS...
Also for selection and paragraph which is used by the
spellchecking context menu.
Change-Id: Ie242175605185b3083aa529b54acc183aee1d47b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90596
Tested-by: Tamás Zolnai <tamas.zolnai@collabora.com>
Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com>
Diffstat (limited to 'sd/source/ui/docshell')
-rw-r--r-- | sd/source/ui/docshell/docshel3.cxx | 64 |
1 files changed, 56 insertions, 8 deletions
diff --git a/sd/source/ui/docshell/docshel3.cxx b/sd/source/ui/docshell/docshel3.cxx index e9d67b7a6976..8f1c597328a2 100644 --- a/sd/source/ui/docshell/docshel3.cxx +++ b/sd/source/ui/docshell/docshel3.cxx @@ -38,6 +38,8 @@ #include <editeng/editobj.hxx> #include <com/sun/star/i18n/TextConversionOption.hpp> #include <sfx2/notebookbar/SfxNotebookBar.hxx> +#include <drawview.hxx> +#include <editeng/editeng.hxx> #include <sdmod.hxx> #include <drawdoc.hxx> @@ -265,6 +267,7 @@ void DrawDocShell::Execute( SfxRequest& rReq ) const SfxStringItem* pItem = rReq.GetArg<SfxStringItem>(SID_LANGUAGE_STATUS); if (pItem) aNewLangTxt = pItem->GetValue(); + if (aNewLangTxt == "*" ) { // open the dialog "Tools/Options/Language Settings - Language" @@ -282,25 +285,70 @@ void DrawDocShell::Execute( SfxRequest& rReq ) // setting the new language... if (!aNewLangTxt.isEmpty()) { + const OUString aSelectionLangPrefix("Current_"); + const OUString aParagraphLangPrefix("Paragraph_"); const OUString aDocumentLangPrefix("Default_"); const OUString aStrNone("LANGUAGE_NONE"); const OUString aStrResetLangs("RESET_LANGUAGES"); + + bool bSelection = false; + bool bParagraph = false; + SdDrawDocument* pDoc = mpViewShell->GetDoc(); sal_Int32 nPos = -1; if (-1 != (nPos = aNewLangTxt.indexOf( aDocumentLangPrefix ))) { aNewLangTxt = aNewLangTxt.replaceAt( nPos, aDocumentLangPrefix.getLength(), "" ); + + if (aNewLangTxt == aStrNone) + lcl_setLanguage( pDoc, OUString(), true ); + else if (aNewLangTxt == aStrResetLangs) + lcl_setLanguage( pDoc, OUString() ); + else + lcl_setLanguage( pDoc, aNewLangTxt ); } - else + else if (-1 != (nPos = aNewLangTxt.indexOf( aSelectionLangPrefix ))) + { + bSelection = true; + aNewLangTxt = aNewLangTxt.replaceAt( nPos, aSelectionLangPrefix.getLength(), "" ); + } + else if (-1 != (nPos = aNewLangTxt.indexOf( aParagraphLangPrefix ))) + { + bParagraph = true; + aNewLangTxt = aNewLangTxt.replaceAt( nPos, aParagraphLangPrefix.getLength(), "" ); + } + + if (bSelection || bParagraph) { - break; + SdrView* pSdrView = mpViewShell->GetDrawView(); + if (!pSdrView) + return; + + EditView& rEditView = pSdrView->GetTextEditOutlinerView()->GetEditView(); + const LanguageType nLangToUse = SvtLanguageTable::GetLanguageType( aNewLangTxt ); + SvtScriptType nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage( nLangToUse ); + + SfxItemSet aAttrs = rEditView.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 = rEditView.GetSelection(); + aOldSel = aSel; + aSel.nStartPos = 0; + aSel.nEndPos = EE_TEXTPOS_ALL; + rEditView.SetSelection( aSel ); + } + + rEditView.SetAttribs( aAttrs ); + if (bParagraph) + rEditView.SetSelection( aOldSel ); } - if (aNewLangTxt == aStrNone) - lcl_setLanguage( pDoc, OUString(), true ); - else if (aNewLangTxt == aStrResetLangs) - lcl_setLanguage( pDoc, OUString() ); - else - lcl_setLanguage( pDoc, aNewLangTxt ); if ( pDoc->GetOnlineSpell() ) { |