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

Henry Castro hcastro at collabora.com
Sat Oct 14 11:39:27 UTC 2017


 editeng/source/editeng/impedit5.cxx          |   10 +++++
 sd/qa/unit/tiledrendering/tiledrendering.cxx |   21 +++++++++++
 sd/source/ui/docshell/docshel3.cxx           |   17 +++++++--
 sd/source/ui/docshell/docshell.cxx           |   49 +++++++++++++++++++++++++--
 4 files changed, 91 insertions(+), 6 deletions(-)

New commits:
commit 59e9d163345e7a9eb68c1bae273593cd70c61153
Author: Henry Castro <hcastro at collabora.com>
Date:   Fri Oct 13 20:47:29 2017 -0400

    sd lok: fix spell checking languages in Impress
    
    Change-Id: I133c9b91521fa7f2b5f7e3a47396f7efa31e1a86
    Reviewed-on: https://gerrit.libreoffice.org/43382
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Henry Castro <hcastro at collabora.com>

diff --git a/editeng/source/editeng/impedit5.cxx b/editeng/source/editeng/impedit5.cxx
index 5ba3549c9360..170bccec2676 100644
--- a/editeng/source/editeng/impedit5.cxx
+++ b/editeng/source/editeng/impedit5.cxx
@@ -684,6 +684,7 @@ void ImpEditEngine::RemoveCharAttribs( sal_Int32 nPara, sal_uInt16 nWhich, bool
 
 void ImpEditEngine::SetParaAttribs( sal_Int32 nPara, const SfxItemSet& rSet )
 {
+    bool bCheckLanguage = false;
     ContentNode* pNode = aEditDoc.GetObject( nPara );
 
     if ( !pNode )
@@ -704,7 +705,16 @@ void ImpEditEngine::SetParaAttribs( sal_Int32 nPara, const SfxItemSet& rSet )
                 InsertUndo(new EditUndoSetParaAttribs(pEditEngine, nPara, pNode->GetContentAttribs().GetItems(), rSet));
             }
         }
+
+        bCheckLanguage = ( rSet.GetItemState( EE_CHAR_LANGUAGE ) == SfxItemState::SET ) ||
+                         ( rSet.GetItemState( EE_CHAR_LANGUAGE_CJK ) == SfxItemState::SET ) ||
+                         ( rSet.GetItemState( EE_CHAR_LANGUAGE_CTL ) == SfxItemState::SET );
+
         pNode->GetContentAttribs().GetItems().Set( rSet );
+
+        if ( bCheckLanguage && pNode->GetWrongList() )
+            pNode->GetWrongList()->ResetInvalidRange(0, pNode->Len());
+
         if ( aStatus.UseCharAttribs() )
             pNode->CreateDefFont();
 
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index c72b42a5ac5b..1e3d54e7e6d1 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -30,6 +30,7 @@
 #include <sfx2/dispatch.hxx>
 #include <sfx2/viewfrm.hxx>
 #include <svl/srchitem.hxx>
+#include <svl/slstitm.hxx>
 #include <comphelper/lok.hxx>
 #include <svx/svdotable.hxx>
 #include <svx/svdoutl.hxx>
@@ -102,6 +103,7 @@ public:
     void testCommentCallbacks();
     void testMultiViewInsertDeletePage();
     void testDisableUndoRepair();
+    void testLanguageStatus();
 
     CPPUNIT_TEST_SUITE(SdTiledRenderingTest);
     CPPUNIT_TEST(testRegisterCallback);
@@ -139,6 +141,7 @@ public:
     CPPUNIT_TEST(testCommentCallbacks);
     CPPUNIT_TEST(testMultiViewInsertDeletePage);
     CPPUNIT_TEST(testDisableUndoRepair);
+    CPPUNIT_TEST(testLanguageStatus);
 
     CPPUNIT_TEST_SUITE_END();
 
@@ -1827,6 +1830,24 @@ void SdTiledRenderingTest::testDisableUndoRepair()
     }
 }
 
+void SdTiledRenderingTest::testLanguageStatus()
+{
+    // Load the document.
+    comphelper::LibreOfficeKit::setActive();
+    createDoc("dummy.odp");
+    SfxViewShell* pView1 = SfxViewShell::Current();
+    SfxLokHelper::createView();
+    SfxViewShell* pView2 = SfxViewShell::Current();
+    {
+        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 SfxStringListItem* >(pItem1.get()));
+        CPPUNIT_ASSERT(dynamic_cast< const SfxStringListItem* >(pItem2.get()));
+    }
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SdTiledRenderingTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sd/source/ui/docshell/docshel3.cxx b/sd/source/ui/docshell/docshel3.cxx
index db099f07ce45..463c2273ee00 100644
--- a/sd/source/ui/docshell/docshel3.cxx
+++ b/sd/source/ui/docshell/docshel3.cxx
@@ -120,7 +120,8 @@ static void lcl_setLanguage( const SdDrawDocument *pDoc, const OUString &rLangua
         for( size_t nObj = 0; nObj < nObjCount; ++nObj )
         {
             SdrObject *pObj = pPage->GetObj( nObj );
-            lcl_setLanguageForObj( pObj, nLang, bLanguageNone );
+            if (pObj->GetObjIdentifier() != OBJ_PAGE)
+                lcl_setLanguageForObj( pObj, nLang, bLanguageNone );
         }
     }
 }
@@ -296,6 +297,7 @@ void DrawDocShell::Execute( SfxRequest& rReq )
                         const OUString aDocumentLangPrefix("Default_");
                         const OUString aStrNone("LANGUAGE_NONE");
                         const OUString aStrResetLangs("RESET_LANGUAGES");
+                        SdDrawDocument* pDoc = mpViewShell->GetDoc();
                         sal_Int32 nPos = -1;
                         if (-1 != (nPos = aNewLangTxt.indexOf( aDocumentLangPrefix )))
                         {
@@ -306,11 +308,18 @@ void DrawDocShell::Execute( SfxRequest& rReq )
                             break;
                         }
                         if (aNewLangTxt == aStrNone)
-                            lcl_setLanguage( mpViewShell->GetDoc(), OUString() );
+                            lcl_setLanguage( pDoc, OUString(), true );
                         else if (aNewLangTxt == aStrResetLangs)
-                            lcl_setLanguage( mpViewShell->GetDoc(), OUString(), true );
+                            lcl_setLanguage( pDoc, OUString() );
                         else
-                            lcl_setLanguage( mpViewShell->GetDoc(), aNewLangTxt );
+                            lcl_setLanguage( pDoc, aNewLangTxt );
+
+                        mpViewShell->GetFrame()->GetBindings().Invalidate( SID_LANGUAGE_STATUS );
+
+                        if ( pDoc->GetOnlineSpell() )
+                        {
+                            pDoc->StartOnlineSpelling();
+                        }
                     }
                 }
             }
diff --git a/sd/source/ui/docshell/docshell.cxx b/sd/source/ui/docshell/docshell.cxx
index 3528f3dd4756..e7ae2542c9f1 100644
--- a/sd/source/ui/docshell/docshell.cxx
+++ b/sd/source/ui/docshell/docshell.cxx
@@ -31,9 +31,13 @@
 #include <svx/svxids.hrc>
 #include <svl/srchitem.hxx>
 #include <svx/srchdlg.hxx>
+#include <svx/svdoutl.hxx>
+#include <svx/svditer.hxx>
 #include <editeng/flstitem.hxx>
+#include <editeng/eeitem.hxx>
 #include <svl/eitem.hxx>
 #include <svl/intitem.hxx>
+#include <svl/slstitm.hxx>
 #include <sfx2/printer.hxx>
 #include <sfx2/docfile.hxx>
 #include <svx/drawitem.hxx>
@@ -41,8 +45,10 @@
 #include <svl/whiter.hxx>
 #include <svl/itempool.hxx>
 #include <svtools/ctrltool.hxx>
+#include <svtools/langtab.hxx>
 #include <vcl/graphicfilter.hxx>
 #include <comphelper/classids.hxx>
+#include <comphelper/lok.hxx>
 #include <svl/cjkoptions.hxx>
 #include <svl/visitem.hxx>
 
@@ -270,8 +276,47 @@ void DrawDocShell::GetState(SfxItemSet &rSet)
             break;
             case SID_LANGUAGE_STATUS:
             {
-                // Keeping this enabled for the time being
-                rSet.Put(SfxVisibilityItem(nWhich, true));
+                if ( comphelper::LibreOfficeKit::isActive() )
+                {
+                    SdrObject* pObj = nullptr;
+                    bool bLanguageFound = false;
+                    OutlinerParaObject* pParaObj = nullptr;
+                    LanguageType eLanguage( LANGUAGE_DONTKNOW );
+                    sal_uInt16 nCount = mpDoc->GetPageCount();
+                    for ( sal_uInt16 itPage = 0; itPage < nCount && !bLanguageFound; itPage++ )
+                    {
+                        SdrObjListIter aListIter(*mpDoc->GetPage(itPage), SdrIterMode::DeepWithGroups);
+                        while ( aListIter.IsMore() && !bLanguageFound )
+                        {
+                            pObj = aListIter.Next();
+                            if ( pObj )
+                            {
+                                pParaObj = pObj->GetOutlinerParaObject();
+                                if ( pParaObj )
+                                {
+                                    SdrOutliner aOutliner(&mpDoc->GetPool(), OutlinerMode::TextObject);
+                                    aOutliner.SetText(*pParaObj);
+                                    eLanguage = aOutliner.GetLanguage(0, 0);
+                                    bLanguageFound = eLanguage != LANGUAGE_DONTKNOW;
+                                }
+                            }
+                        }
+                    }
+
+                    if ( eLanguage == LANGUAGE_DONTKNOW )
+                    {
+                        eLanguage = mpDoc->GetLanguage( EE_CHAR_LANGUAGE );
+                    }
+
+                    css::uno::Sequence< OUString > aSeq( 1 );
+                    aSeq[0] = SvtLanguageTable::GetLanguageString(eLanguage);
+                    SfxStringListItem aItem( SID_LANGUAGE_STATUS );
+                    aItem.SetStringList( aSeq );
+                    rSet.Put(aItem);
+                }
+                else
+                    // Keeping this enabled for the time being
+                    rSet.Put(SfxVisibilityItem(nWhich, true));
             }
             break;
 


More information about the Libreoffice-commits mailing list