summaryrefslogtreecommitdiff
path: root/sc/source/ui/docshell/docsh4.cxx
diff options
context:
space:
mode:
authorHenry Castro <hcastro@collabora.com>2017-10-19 22:47:17 -0400
committerJan Holesovsky <kendy@collabora.com>2017-10-26 21:08:01 +0200
commit804038a4c05f5296fa34722650bc393ac01c02dd (patch)
tree95777fc9fdbd221a1e9bac23437a83e8375de6bb /sc/source/ui/docshell/docsh4.cxx
parent514c93d9741ce4bc12edf38eadb0e268aae80a90 (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>
Diffstat (limited to 'sc/source/ui/docshell/docsh4.cxx')
-rw-r--r--sc/source/ui/docshell/docsh4.cxx94
1 files changed, 94 insertions, 0 deletions
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:
{
}