diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-06-04 14:20:35 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-06-05 12:16:24 -0400 |
commit | 1227601d74ecddb06dcbe69e260aa32835900ed3 (patch) | |
tree | c1e10121461221780a4db173afa5b19c7d667ee0 | |
parent | f7ebee38a3c5c6cb58f40109a213d449138ea987 (diff) |
Disable file load and save and a whole bunch of other commands in preview.
We will probably need to go through more commands and disable them.
Change-Id: Ie3d547f18d799b76290f469d2790902c6883774c
-rw-r--r-- | sc/sdi/docsh.sdi | 14 | ||||
-rw-r--r-- | sc/sdi/prevwsh.sdi | 3 | ||||
-rw-r--r-- | sc/source/ui/app/scmod.cxx | 31 | ||||
-rw-r--r-- | sc/source/ui/docshell/docsh4.cxx | 13 | ||||
-rw-r--r-- | sc/source/ui/view/prevwsh.cxx | 2 |
5 files changed, 34 insertions, 29 deletions
diff --git a/sc/sdi/docsh.sdi b/sc/sdi/docsh.sdi index 5891c10e6100..cd3cf5cdd9c4 100644 --- a/sc/sdi/docsh.sdi +++ b/sc/sdi/docsh.sdi @@ -73,12 +73,12 @@ interface TableDocument uuid = "BA338A42-064E-11d0-89CB-008029E4B0B1" ; ] { - SID_OPEN_CALC [ ExecMethod = Execute; ] - SID_SBA_IMPORT [ ExecMethod = Execute; ] - SID_SC_CELLS [ ExecMethod = Execute; ] - SID_SC_CELLTEXT [ ExecMethod = Execute; ] - SID_SC_SETTEXT [ ExecMethod = Execute; ] - SID_SC_RANGE [ ExecMethod = Execute; ] + SID_OPEN_CALC [ ExecMethod = Execute; StateMethod = GetState; ] + SID_SBA_IMPORT [ ExecMethod = Execute; StateMethod = GetState; ] + SID_SC_CELLS [ ExecMethod = Execute; StateMethod = GetState; ] + SID_SC_CELLTEXT [ ExecMethod = Execute; StateMethod = GetState; ] + SID_SC_SETTEXT [ ExecMethod = Execute; StateMethod = GetState; ] + SID_SC_RANGE [ ExecMethod = Execute; StateMethod = GetState; ] SID_SC_SELECTION [ StateMethod = GetSbxState; ] SID_SC_ACTIVECELL [ StateMethod = GetSbxState; ] SID_SC_ACTIVETAB [ StateMethod = GetSbxState; ] @@ -96,7 +96,7 @@ interface TableDocument SID_CHART_ADDSOURCE [ ExecMethod = Execute; ] FID_AUTO_CALC [ ExecMethod = Execute; StateMethod = GetState; ] FID_RECALC [ ExecMethod = Execute; StateMethod = GetState; ] - FID_HARD_RECALC [ ExecMethod = Execute; ] + FID_HARD_RECALC [ ExecMethod = Execute; StateMethod = GetState; ] SID_UPDATETABLINKS [ ExecMethod = Execute; ] SID_REIMPORT_AFTER_LOAD [ ExecMethod = Execute; ] SID_AUTO_STYLE [ ExecMethod = Execute; ] diff --git a/sc/sdi/prevwsh.sdi b/sc/sdi/prevwsh.sdi index 2af8e07a117b..211712850bb5 100644 --- a/sc/sdi/prevwsh.sdi +++ b/sc/sdi/prevwsh.sdi @@ -159,6 +159,9 @@ interface TablePrintPreview SID_PRINTPREVIEW [ ExecMethod = Execute; StateMethod = GetState; Export = FALSE; ] // ole() api() SID_PREVIEW_CLOSE [ ExecMethod = Execute; StateMethod = GetState; Export = FALSE; ] SID_CANCEL [ ExecMethod = Execute; StateMethod = GetState; Export = FALSE; ] + + SID_SAVEDOC [ StateMethod = GetState; Export = FALSE; ] + SID_SAVEASDOC [ StateMethod = GetState; Export = FALSE; ] } diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx index c2eb40441e74..845e551ac7f1 100644 --- a/sc/source/ui/app/scmod.cxx +++ b/sc/source/ui/app/scmod.cxx @@ -586,10 +586,19 @@ void ScModule::Execute( SfxRequest& rReq ) void ScModule::GetState( SfxItemSet& rSet ) { + ScDocShell* pDocSh = PTR_CAST(ScDocShell, SfxObjectShell::Current()); + bool bTabView = pDocSh && (pDocSh->GetBestViewShell(true) != NULL); + SfxWhichIter aIter(rSet); - sal_uInt16 nWhich = aIter.FirstWhich(); - while ( nWhich ) + for (sal_uInt16 nWhich = aIter.FirstWhich(); nWhich; nWhich = aIter.NextWhich()) { + if (!bTabView) + { + // Not in the normal calc view shell (most likely in preview shell). Disable all actions. + rSet.DisableItem(nWhich); + continue; + } + switch ( nWhich ) { case FID_AUTOCOMPLETE: @@ -605,25 +614,13 @@ void ScModule::GetState( SfxItemSet& rSet ) rSet.Put( SfxUInt16Item( nWhich, sal::static_int_cast<sal_uInt16>(GetAppOptions().GetAppMetric()) ) ); break; case SID_AUTOSPELL_CHECK: - { - sal_Bool bAuto; - ScDocShell* pDocSh = PTR_CAST(ScDocShell, SfxObjectShell::Current()); - if ( pDocSh ) - bAuto = pDocSh->GetDocument()->GetDocOptions().IsAutoSpell(); - else - { - sal_uInt16 nDummyLang, nDummyCjk, nDummyCtl; - GetSpellSettings( nDummyLang, nDummyCjk, nDummyCtl, bAuto ); - } - rSet.Put( SfxBoolItem( nWhich, bAuto ) ); - } + rSet.Put( SfxBoolItem( nWhich, pDocSh->GetDocument()->GetDocOptions().IsAutoSpell()) ); break; case SID_ATTR_LANGUAGE: case ATTR_CJK_FONT_LANGUAGE: // WID for SID_ATTR_CHAR_CJK_LANGUAGE case ATTR_CTL_FONT_LANGUAGE: // WID for SID_ATTR_CHAR_CTL_LANGUAGE { - ScDocShell* pDocSh = PTR_CAST(ScDocShell, SfxObjectShell::Current()); - ScDocument* pDoc = pDocSh ? pDocSh->GetDocument() : NULL; + ScDocument* pDoc = pDocSh->GetDocument(); if ( pDoc ) { LanguageType eLatin, eCjk, eCtl; @@ -634,9 +631,7 @@ void ScModule::GetState( SfxItemSet& rSet ) } } break; - } - nWhich = aIter.NextWhich(); } } diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx index 9524e6ba4a74..d751bca810d2 100644 --- a/sc/source/ui/docshell/docsh4.cxx +++ b/sc/source/ui/docshell/docsh4.cxx @@ -1788,10 +1788,17 @@ void ScDocShell::GetStatePageStyle( SfxViewShell& /* rCaller */, void ScDocShell::GetState( SfxItemSet &rSet ) { + bool bTabView = GetBestViewShell(true) != NULL; + SfxWhichIter aIter(rSet); - sal_uInt16 nWhich = aIter.FirstWhich(); - while ( nWhich ) + for (sal_uInt16 nWhich = aIter.FirstWhich(); nWhich; nWhich = aIter.NextWhich()) { + if (!bTabView) + { + rSet.DisableItem(nWhich); + continue; + } + switch (nWhich) { case FID_AUTO_CALC: @@ -1856,8 +1863,6 @@ void ScDocShell::GetState( SfxItemSet &rSet ) } break; } - - nWhich = aIter.NextWhich(); } } diff --git a/sc/source/ui/view/prevwsh.cxx b/sc/source/ui/view/prevwsh.cxx index adc5208567a3..c23c2f43f7dc 100644 --- a/sc/source/ui/view/prevwsh.cxx +++ b/sc/source/ui/view/prevwsh.cxx @@ -814,6 +814,8 @@ void ScPreviewShell::GetState( SfxItemSet& rSet ) case SID_UNDO: case SID_REDO: case SID_REPEAT: + case SID_SAVEDOC: + case SID_SAVEASDOC: rSet.DisableItem(nWhich); break; case SID_PREVIEW_PREVIOUS: |