diff options
Diffstat (limited to 'sc')
-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 |
7 files changed, 158 insertions, 0 deletions
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"/> |