diff options
Diffstat (limited to 'sc/source/ui/docshell')
-rw-r--r-- | sc/source/ui/docshell/docsh4.cxx | 94 |
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: { } |