sc/source/ui/view/gridwin.cxx  |   27 +++++++++++++++++++++------
 sc/source/ui/view/viewfunc.cxx |    4 ++++
 2 files changed, 25 insertions(+), 6 deletions(-)

New commits:
commit 5fa3a5cd075bfc6607c76b9be41310a24fec17f2
Author: Kohei Yoshida <kohei.yosh...@collabora.com>
Date:   Fri May 5 17:53:02 2017 -0400

    tdf#86001: Pass on the language info from the cell to the engine.
    
    So that it can be used to set the correct language to use to check
    spelling (or disable it altogether).
    
    Reviewed-on: https://gerrit.libreoffice.org/37307
    Tested-by: Jenkins <c...@libreoffice.org>
    Reviewed-by: Kohei Yoshida <libreoff...@kohei.us>
    (cherry picked from commit eb35ead64b1371ea27420b57387ff1db0cbbbcf6)
    
     Conflicts:
            sc/source/ui/view/gridwin.cxx
    
    Change-Id: I4fddd9a7e08ab55476566db98476794b2fc1eb13
    Reviewed-on: https://gerrit.libreoffice.org/37308
    Tested-by: Jenkins <c...@libreoffice.org>
    Reviewed-by: Eike Rathke <er...@redhat.com>

diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 317d1941c1f0..3122880ccf7c 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -30,6 +30,7 @@
 #include <editeng/unolingu.hxx>
 #include <editeng/langitem.hxx>
 #include <editeng/misspellrange.hxx>
+#include <editeng/langitem.hxx>
 #include <svx/svdetc.hxx>
 #include <editeng/editobj.hxx>
 #include <sfx2/dispatch.hxx>
@@ -53,6 +54,8 @@
 #include <svx/svdocapt.hxx>
 #include <svx/svdpagv.hxx>
 
+#include <o3tl/make_unique.hxx>
+
 #include <com/sun/star/sheet/DataPilotFieldFilter.hpp>
 #include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
 #include <com/sun/star/sheet/DataPilotTableHeaderData.hpp>
@@ -5568,6 +5571,22 @@ bool ScGridWindow::ContinueOnlineSpelling()
         {
             ++nTextCellCount;
 
+            // NB: For spell-checking, we currently only use the primary
+            // language; not CJK nor CTL.
+            const ScPatternAttr* pPattern = pDoc->GetPattern(nCol, nRow, nTab);
+            LanguageType nCellLang =
+                static_cast<const 
SvxLanguageItem&>(pPattern->GetItem(ATTR_FONT_LANGUAGE)).GetValue();
+
+            if (nCellLang == LANGUAGE_SYSTEM)
+                nCellLang = 
Application::GetSettings().GetLanguageTag().getLanguageType();   // never use 
SYSTEM for spelling
+
+            if (nCellLang == LANGUAGE_NONE)
+            {
+                // No need to spell check this cell.
+                pCell = aIter.GetNext(nCol, nRow);
+                continue;
+            }
+
             if (!pEngine)
             {
                 //  ScTabEditEngine is needed
@@ -5582,14 +5601,10 @@ bool ScGridWindow::ContinueOnlineSpelling()
 
                 uno::Reference<linguistic2::XSpellChecker1> 
xXSpellChecker1(LinguMgr::GetSpellChecker());
                 pEngine->SetSpeller(xXSpellChecker1);
+                
pEngine->SetDefaultLanguage(ScGlobal::GetEditDefaultLanguage());
             }
 
-            const ScPatternAttr* pPattern = pDoc->GetPattern(nCol, nRow, nTab);
-            sal_uInt16 nCellLang =
-                static_cast<const 
SvxLanguageItem&>(pPattern->GetItem(ATTR_FONT_LANGUAGE)).GetValue();
-            if (nCellLang == LANGUAGE_SYSTEM)
-                nCellLang = 
Application::GetSettings().GetLanguageTag().getLanguageType();   // never use 
SYSTEM for spelling
-            pEngine->SetDefaultLanguage(nCellLang);
+            pEngine->SetDefaultItem(SvxLanguageItem(nCellLang, 
EE_CHAR_LANGUAGE));
 
             if (eType == CELLTYPE_STRING)
                 pEngine->SetText(pCell->mpString->getString());
diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index 0228541fe286..1b5a9b210849 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -904,6 +904,10 @@ void ScViewFunc::ApplyAttributes( const SfxItemSet* 
pDialogSet,
         }
     }
 
+    if (pDialogSet->HasItem(ATTR_FONT_LANGUAGE))
+        // font language has changed.  Redo the online spelling.
+        ResetAutoSpell();
+
     const SvxBoxItem*     pOldOuter = static_cast<const SvxBoxItem*>     
(&pOldSet->Get( ATTR_BORDER ));
     const SvxBoxItem*     pNewOuter = static_cast<const SvxBoxItem*>     
(&pDialogSet->Get( ATTR_BORDER ));
     const SvxBoxInfoItem* pOldInner = static_cast<const SvxBoxInfoItem*> 
(&pOldSet->Get( ATTR_BORDER_INNER ));
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to