[Libreoffice-commits] core.git: include/svl sc/qa sc/sdi sc/source sc/uiconfig sfx2/source

Henry Castro hcastro at collabora.com
Sun Oct 22 15:18:38 UTC 2017


 include/svl/hint.hxx                         |    1 
 sc/qa/unit/tiledrendering/tiledrendering.cxx |   51 +++++++++++++++
 sc/sdi/docsh.sdi                             |    1 
 sc/source/ui/docshell/docsh4.cxx             |   89 +++++++++++++++++++++++++++
 sc/source/ui/view/gridwin4.cxx               |    1 
 sc/source/ui/view/tabvwsh5.cxx               |    8 ++
 sc/uiconfig/scalc/menubar/menubar.xml        |    2 
 sc/uiconfig/scalc/statusbar/statusbar.xml    |    1 
 sfx2/source/control/unoctitm.cxx             |   13 +++
 9 files changed, 165 insertions(+), 2 deletions(-)

New commits:
commit 2fa424f40a185eb43d862a29abce07345695fcf3
Author: Henry Castro <hcastro at collabora.com>
Date:   Thu Oct 19 22:47:17 2017 -0400

    sc lok: fix spell checking languages in Calc
    
    Change-Id: Iadcc3b55a30ce2a2c785366fb3807ff6e4bda1fe
    Reviewed-on: https://gerrit.libreoffice.org/43581
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Henry Castro <hcastro at collabora.com>

diff --git a/include/svl/hint.hxx b/include/svl/hint.hxx
index 2a0e981802b3..b987e9091476 100644
--- a/include/svl/hint.hxx
+++ b/include/svl/hint.hxx
@@ -33,6 +33,7 @@ enum class SfxHintId {
     Deinitializing,
     ModeChanged,
     ColorsChanged,
+    LanguageChanged,
 
 // VCL text hints
     TextParaInserted,
diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index 1f56bba58179..bc477a044e64 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -85,6 +85,7 @@ public:
     void testInsertGraphicInvalidations();
     void testDocumentSizeWithTwoViews();
     void testDisableUndoRepair();
+    void testLanguageStatus();
 
     CPPUNIT_TEST_SUITE(ScTiledRenderingTest);
     CPPUNIT_TEST(testRowColumnSelections);
@@ -112,6 +113,7 @@ public:
     CPPUNIT_TEST(testInsertGraphicInvalidations);
     CPPUNIT_TEST(testDocumentSizeWithTwoViews);
     CPPUNIT_TEST(testDisableUndoRepair);
+    CPPUNIT_TEST(testLanguageStatus);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -1412,6 +1414,55 @@ void ScTiledRenderingTest::testDisableUndoRepair()
         CPPUNIT_ASSERT_EQUAL(SfxItemState::SET, aSet2.GetItemState(SID_UNDO));
         CPPUNIT_ASSERT(dynamic_cast< const SfxStringItem* >(aSet2.GetItem(SID_UNDO)));
     }
+
+    comphelper::LibreOfficeKit::setActive(false);
+}
+
+void ScTiledRenderingTest::testLanguageStatus()
+{
+    comphelper::LibreOfficeKit::setActive();
+    ScModelObj* pModelObj = createDoc("small.ods");
+    CPPUNIT_ASSERT(pModelObj);
+    ScDocShell* pDocSh = dynamic_cast< ScDocShell* >( pModelObj->GetEmbeddedObject() );
+    CPPUNIT_ASSERT(pDocSh);
+
+    // view #1
+    SfxViewShell* pView1 = SfxViewShell::Current();
+
+    // view #2
+    SfxLokHelper::createView();
+    SfxViewShell* pView2 = SfxViewShell::Current();
+    CPPUNIT_ASSERT(pView1 != pView2);
+    const OUString aLangBolivia("Spanish (Bolivia)");
+    {
+        std::unique_ptr<SfxPoolItem> pItem1;
+        std::unique_ptr<SfxPoolItem> pItem2;
+        pView1->GetViewFrame()->GetBindings().QueryState(SID_LANGUAGE_STATUS, pItem1);
+        pView2->GetViewFrame()->GetBindings().QueryState(SID_LANGUAGE_STATUS, pItem2);
+        CPPUNIT_ASSERT(dynamic_cast< const SfxStringItem* >(pItem1.get()));
+        CPPUNIT_ASSERT(dynamic_cast< const SfxStringItem* >(pItem2.get()));
+        CPPUNIT_ASSERT(!dynamic_cast< const SfxStringItem* >(pItem1.get())->GetValue().isEmpty());
+        CPPUNIT_ASSERT(!dynamic_cast< const SfxStringItem* >(pItem1.get())->GetValue().isEmpty());
+    }
+
+    {
+        SfxStringItem aLangString(SID_LANGUAGE_STATUS, "Default_Spanish (Bolivia)");
+        pView1->GetViewFrame()->GetDispatcher()->ExecuteList(SID_LANGUAGE_STATUS,
+            SfxCallMode::SYNCHRON, { &aLangString });
+    }
+
+    {
+        std::unique_ptr<SfxPoolItem> pItem1;
+        std::unique_ptr<SfxPoolItem> pItem2;
+        pView1->GetViewFrame()->GetBindings().QueryState(SID_LANGUAGE_STATUS, pItem1);
+        pView2->GetViewFrame()->GetBindings().QueryState(SID_LANGUAGE_STATUS, pItem2);
+        CPPUNIT_ASSERT(dynamic_cast< const SfxStringItem* >(pItem1.get()));
+        CPPUNIT_ASSERT(dynamic_cast< const SfxStringItem* >(pItem2.get()));
+        CPPUNIT_ASSERT_EQUAL(aLangBolivia, dynamic_cast< const SfxStringItem* >(pItem1.get())->GetValue());
+        CPPUNIT_ASSERT_EQUAL(aLangBolivia, dynamic_cast< const SfxStringItem* >(pItem1.get())->GetValue());
+    }
+
+    comphelper::LibreOfficeKit::setActive(false);
 }
 
 }
diff --git a/sc/sdi/docsh.sdi b/sc/sdi/docsh.sdi
index 3160e88a4795..fdb22acf3e0c 100644
--- a/sc/sdi/docsh.sdi
+++ b/sc/sdi/docsh.sdi
@@ -74,6 +74,7 @@ interface TableDocument
     SID_ATTR_CHAR_FONTLIST  [ StateMethod = GetState; ]
     SID_SHARE_DOC           [ ExecMethod = Execute; StateMethod = GetState; ]
     SID_NOTEBOOKBAR         [ ExecMethod = Execute; StateMethod = GetState; ]
+    SID_LANGUAGE_STATUS     [ ExecMethod = Execute; StateMethod = GetState; ]
 }
 
 
diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx
index 2067d04761e7..8cfb5fc81a2a 100644
--- a/sc/source/ui/docshell/docsh4.cxx
+++ b/sc/source/ui/docshell/docsh4.cxx
@@ -30,11 +30,13 @@ using namespace ::com::sun::star;
 
 #include "scitems.hxx"
 #include <editeng/flstitem.hxx>
+#include <editeng/langitem.hxx>
 #include <sfx2/fcontnr.hxx>
 #include <sfx2/linkmgr.hxx>
 #include <sfx2/objface.hxx>
 #include <sfx2/docfile.hxx>
 #include <svtools/ehdl.hxx>
+#include <svtools/langtab.hxx>
 #include <basic/sbxcore.hxx>
 #include <basic/sberrors.hxx>
 #include <svtools/sfxecode.hxx>
@@ -52,6 +54,7 @@ using namespace ::com::sun::star;
 #include <svl/PasswordHelper.hxx>
 #include <svl/documentlockfile.hxx>
 #include <svl/sharecontrolfile.hxx>
+#include <svl/slstitm.hxx>
 #include <unotools/securityoptions.hxx>
 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
 
@@ -1120,6 +1123,83 @@ void ScDocShell::Execute( SfxRequest& rReq )
                 sfx2::SfxNotebookBar::CloseMethod(*pBindings);
         }
         break;
+        case SID_LANGUAGE_STATUS:
+        {
+            sal_Int32 nPos = 0;
+            OUString aLangText;
+            const SfxStringItem* pItem = rReq.GetArg<SfxStringItem>(nSlot);
+            if ( pItem )
+                aLangText = pItem->GetValue();
+
+            if ( !aLangText.isEmpty() )
+            {
+                LanguageType eLang, eLatin, eCjk, eCtl;
+                const OUString aDocLangPrefix("Default_");
+                const OUString aNoLang("LANGUAGE_NONE");
+                const OUString aResetLang("RESET_LANGUAGES");
+
+                ScDocument& rDoc = GetDocument();
+                rDoc.GetLanguage( eLatin, eCjk, eCtl );
+
+                if ( aLangText == "*" )
+                {
+                    SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
+                    if (pFact)
+                    {
+                        ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateVclDialog(GetActiveDialogParent(), SID_LANGUAGE_OPTIONS));
+                        pDlg->Execute();
+                    }
+
+                    rDoc.GetLanguage( eLang, eCjk, eCtl );
+                }
+                else if ( (nPos = aLangText.indexOf(aDocLangPrefix)) != -1 )
+                {
+                    aLangText = aLangText.replaceAt(nPos, aDocLangPrefix.getLength(), "");
+
+                    if ( aLangText == aNoLang )
+                    {
+                        eLang = LANGUAGE_NONE;
+                        rDoc.SetLanguage( eLang, eCjk, eCtl );
+                    }
+                    else if ( aLangText == aResetLang )
+                    {
+                        bool bAutoSpell;
+
+                        ScModule::GetSpellSettings(eLang, eCjk, eCtl, bAutoSpell);
+                        rDoc.SetLanguage(eLang, eCjk, eCtl);
+                    }
+                    else
+                    {
+                        eLang = SvtLanguageTable::GetLanguageType( aLangText );
+                        if ( eLang != LANGUAGE_DONTKNOW  && SvtLanguageOptions::GetScriptTypeOfLanguage(eLang) == SvtScriptType::LATIN )
+                        {
+                            rDoc.SetLanguage( eLang, eCjk, eCtl );
+                        }
+                        else
+                        {
+                            eLang = eLatin;
+                        }
+                    }
+                }
+
+                if ( eLang != eLatin )
+                {
+                    if ( ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell() )
+                    {
+                        ScInputHandler* pInputHandler = SC_MOD()->GetInputHdl(pViewSh);
+                        if ( pInputHandler )
+                            pInputHandler->UpdateSpellSettings();
+
+                        pViewSh->UpdateDrawTextOutliner();
+                    }
+
+                    SetDocumentModified();
+                    Broadcast(SfxHint(SfxHintId::LanguageChanged));
+                    PostPaintGridAll();
+                }
+            }
+        }
+        break;
         default:
         {
             // small (?) hack -> forwarding of the slots to TabViewShell
@@ -1881,6 +1961,15 @@ void ScDocShell::GetState( SfxItemSet &rSet )
                 }
                 break;
 
+            case SID_LANGUAGE_STATUS:
+                {
+                    LanguageType eLatin, eCjk, eCtl;
+
+                    GetDocument().GetLanguage( eLatin, eCjk, eCtl );
+                    rSet.Put(SfxStringItem(nWhich, SvtLanguageTable::GetLanguageString(eLatin)));
+                }
+                break;
+
             default:
                 {
                 }
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index e631bbaed818..297008b3140f 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -1197,6 +1197,7 @@ void ScGridWindow::PaintTile( VirtualDevice& rDevice,
         mpLOKDrawView.reset(new FmFormView(pModel, &rDevice));
         mpLOKDrawView->ShowSdrPage(mpLOKDrawView->GetModel()->GetPage(nTab));
         aOutputData.SetDrawView(mpLOKDrawView.get());
+        aOutputData.SetSpellCheckContext(mpSpellCheckCxt.get());
     }
 
     // draw the content
diff --git a/sc/source/ui/view/tabvwsh5.cxx b/sc/source/ui/view/tabvwsh5.cxx
index fd69cc802ed3..928d804c2c8c 100644
--- a/sc/source/ui/view/tabvwsh5.cxx
+++ b/sc/source/ui/view/tabvwsh5.cxx
@@ -298,6 +298,14 @@ void ScTabViewShell::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
                 SetTabNo( GetViewData().GetTabNo(), true );
                 break;
 
+            case SfxHintId::LanguageChanged:
+            {
+                GetViewFrame()->GetBindings().Invalidate(SID_LANGUAGE_STATUS);
+                if ( ScGridWindow* pWin = GetViewData().GetActiveWin() )
+                    pWin->ResetAutoSpell();
+            }
+                break;
+
             default:
                 break;
         }
diff --git a/sc/uiconfig/scalc/menubar/menubar.xml b/sc/uiconfig/scalc/menubar/menubar.xml
index 6033b178d3b3..812903a8de48 100644
--- a/sc/uiconfig/scalc/menubar/menubar.xml
+++ b/sc/uiconfig/scalc/menubar/menubar.xml
@@ -680,6 +680,8 @@
             <menu:menuitem menu:id=".uno:ThesaurusDialog"/>
             <menu:menu menu:id=".uno:LanguageMenu">
                 <menu:menupopup>
+                    <menu:menuitem menu:id=".uno:SetLanguageAllTextMenu"/>
+                    <menu:menuseparator/>
                     <menu:menuitem menu:id=".uno:Hyphenate"/>
                     <menu:menuitem menu:id=".uno:ChineseConversion"/>
                     <menu:menuitem menu:id=".uno:HangulHanjaConversion"/>
diff --git a/sc/uiconfig/scalc/statusbar/statusbar.xml b/sc/uiconfig/scalc/statusbar/statusbar.xml
index 79a746fa2e99..49f69c751cb3 100644
--- a/sc/uiconfig/scalc/statusbar/statusbar.xml
+++ b/sc/uiconfig/scalc/statusbar/statusbar.xml
@@ -21,6 +21,7 @@
  <statusbar:statusbaritem xlink:href=".uno:StatusDocPos" statusbar:align="left" statusbar:autosize="true" statusbar:width="58"/>
  <statusbar:statusbaritem xlink:href=".uno:RowColSelCount" statusbar:align="left" statusbar:autosize="true" statusbar:width="58"/>
  <statusbar:statusbaritem xlink:href=".uno:StatusPageStyle" statusbar:align="left" statusbar:autosize="true" statusbar:width="83"/>
+ <statusbar:statusbaritem xlink:href=".uno:LanguageStatus" statusbar:align="center" statusbar:autosize="true" statusbar:width="100"/>
  <statusbar:statusbaritem xlink:href=".uno:InsertMode" statusbar:align="center" statusbar:width="55"/>
  <statusbar:statusbaritem xlink:href=".uno:StatusSelectionMode" statusbar:align="center" statusbar:ownerdraw="true" statusbar:width="16"/>
  <statusbar:statusbaritem xlink:href=".uno:ModifiedStatus" statusbar:align="center" statusbar:ownerdraw="true" statusbar:width="16"/>
diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx
index c609bf21bbd5..1636be332a55 100644
--- a/sfx2/source/control/unoctitm.cxx
+++ b/sfx2/source/control/unoctitm.cxx
@@ -1161,10 +1161,19 @@ static void InterceptLOKStateChangeEvent(const SfxViewFrame* pViewFrame, const c
     }
     else if (aEvent.FeatureURL.Path == "LanguageStatus")
     {
+        OUString sValue;
         css::uno::Sequence< OUString > aSeq;
-        if (aEvent.IsEnabled && (aEvent.State >>= aSeq))
+
+        if (aEvent.IsEnabled)
         {
-            aBuffer.append(aSeq[0]);
+            if (aEvent.State >>= sValue)
+            {
+                aBuffer.append(sValue);
+            }
+            else if (aEvent.State >>= aSeq)
+            {
+                aBuffer.append(aSeq[0]);
+            }
         }
     }
     else


More information about the Libreoffice-commits mailing list