diff options
author | Henry Castro <hcastro@collabora.com> | 2017-10-19 22:47:17 -0400 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2017-10-26 21:08:01 +0200 |
commit | 804038a4c05f5296fa34722650bc393ac01c02dd (patch) | |
tree | 95777fc9fdbd221a1e9bac23437a83e8375de6bb | |
parent | 514c93d9741ce4bc12edf38eadb0e268aae80a90 (diff) |
sc lok: fix spell checking languages in Calc
Change-Id: Iadcc3b55a30ce2a2c785366fb3807ff6e4bda1fe
Reviewed-on: https://gerrit.libreoffice.org/43581
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Henry Castro <hcastro@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/43701
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
Tested-by: Jan Holesovsky <kendy@collabora.com>
-rw-r--r-- | include/svl/hint.hxx | 1 | ||||
-rw-r--r-- | sc/qa/unit/tiledrendering/tiledrendering.cxx | 51 | ||||
-rw-r--r-- | sc/sdi/docsh.sdi | 1 | ||||
-rw-r--r-- | sc/source/ui/docshell/docsh4.cxx | 94 | ||||
-rw-r--r-- | sc/source/ui/view/gridwin4.cxx | 1 | ||||
-rw-r--r-- | sc/source/ui/view/tabvwsh5.cxx | 8 | ||||
-rw-r--r-- | sc/uiconfig/scalc/menubar/menubar.xml | 2 | ||||
-rw-r--r-- | sc/uiconfig/scalc/statusbar/statusbar.xml | 1 | ||||
-rw-r--r-- | sfx2/source/control/unoctitm.cxx | 13 |
9 files changed, 170 insertions, 2 deletions
diff --git a/include/svl/hint.hxx b/include/svl/hint.hxx index 8de965d73af5..70f5fc74e8d6 100644 --- a/include/svl/hint.hxx +++ b/include/svl/hint.hxx @@ -30,6 +30,7 @@ #define SFX_HINT_UPDATEDONE 0x00000020 #define SFX_HINT_DEINITIALIZING 0x00000040 #define SFX_HINT_MODECHANGED 0x00000080 +#define SFX_HINT_LANGUAGECHANGED 0x00000100 // unused, formerly SFX_HINT_CANCELLABLE // unused, formerly SFX_HINT_DATAAVAILABLE // unused, formerly SFX_HINT_SAVECOMPLETED diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx index 8eaf06f7483d..32ccf698e872 100644 --- a/sc/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx @@ -77,6 +77,7 @@ public: void testInsertGraphicInvalidations(); void testDocumentSizeWithTwoViews(); void testDisableUndoRepair(); + void testLanguageStatus(); CPPUNIT_TEST_SUITE(ScTiledRenderingTest); CPPUNIT_TEST(testRowColumnSelections); @@ -104,6 +105,7 @@ public: CPPUNIT_TEST(testInsertGraphicInvalidations); CPPUNIT_TEST(testDocumentSizeWithTwoViews); CPPUNIT_TEST(testDisableUndoRepair); + CPPUNIT_TEST(testLanguageStatus); CPPUNIT_TEST_SUITE_END(); private: @@ -1414,6 +1416,55 @@ void ScTiledRenderingTest::testDisableUndoRepair() CPPUNIT_ASSERT(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 852af49223da..019465d8420c 100644 --- a/sc/sdi/docsh.sdi +++ b/sc/sdi/docsh.sdi @@ -88,6 +88,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 20f962546326..aaf28e094dea 100644 --- a/sc/source/ui/docshell/docsh4.cxx +++ b/sc/source/ui/docshell/docsh4.cxx @@ -31,11 +31,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 <svtools/sfxecode.hxx> #include <svx/ofaitem.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> @@ -63,6 +66,7 @@ using namespace ::com::sun::star; #include "docsh.hxx" #include "docshimp.hxx" #include "docfunc.hxx" +#include "docpool.hxx" #include "sc.hrc" #include "stlsheet.hxx" #include "stlpool.hxx" @@ -1117,6 +1121,87 @@ 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; + sal_uInt16 nLang, nCjkLang, nCtlLang; + + ScModule::GetSpellSettings( nLang, nCjkLang, nCtlLang, bAutoSpell ); + eLang = static_cast< LanguageType >(nLang); + 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(SFX_HINT_LANGUAGECHANGED)); + PostPaintGridAll(); + } + } + } + break; + default: { // kleiner (?) Hack -> forward der Slots an TabViewShell @@ -1882,6 +1967,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 b4b2a910d4a1..13b82122d6fd 100644 --- a/sc/source/ui/view/gridwin4.cxx +++ b/sc/source/ui/view/gridwin4.cxx @@ -1219,6 +1219,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 f46bbbfa9868..a934ad10d8e0 100644 --- a/sc/source/ui/view/tabvwsh5.cxx +++ b/sc/source/ui/view/tabvwsh5.cxx @@ -302,6 +302,14 @@ void ScTabViewShell::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) SetTabNo( GetViewData().GetTabNo(), true ); break; + case SFX_HINT_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 93110d624328..99b3b4736f24 100644 --- a/sc/uiconfig/scalc/menubar/menubar.xml +++ b/sc/uiconfig/scalc/menubar/menubar.xml @@ -646,6 +646,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 72edd1fabd15..394653cd582f 100644 --- a/sfx2/source/control/unoctitm.cxx +++ b/sfx2/source/control/unoctitm.cxx @@ -1157,10 +1157,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 |