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

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


 sd/source/ui/docshell/docshel3.cxx |   64 ++++++++++++++++++++++++++++++++-----
 1 file changed, 56 insertions(+), 8 deletions(-)

New commits:
commit 6167264dace8e10fe66537bcf64eaa5904232786
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Mon Mar 16 16:24:48 2020 +0100
Commit:     Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Tue Mar 17 11:12:47 2020 +0100

    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 at collabora.com>
    Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>

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() )
                         {


More information about the Libreoffice-commits mailing list