sc/sdi/docsh.sdi | 14 +++++++------- sc/sdi/prevwsh.sdi | 3 +++ sc/source/ui/app/scmod.cxx | 31 +++++++++++++------------------ sc/source/ui/docshell/docsh4.cxx | 13 +++++++++---- sc/source/ui/inc/prevwsh.hxx | 3 +++ sc/source/ui/view/prevwsh.cxx | 34 +++++++++++++++++++++++++++++++++- vcl/inc/vcl/syswin.hxx | 3 +++ vcl/source/window/syswin.cxx | 11 +++++++++++ vcl/source/window/winproc.cxx | 32 ++++++++++++++++++++++---------- 9 files changed, 104 insertions(+), 40 deletions(-)
New commits: commit c379b5b82e1ce693b5dc158dcea0f8b0a508ea46 Author: Kohei Yoshida <kohei.yosh...@gmail.com> Date: Tue Jun 5 12:10:45 2012 -0400 Slightly cleaner way to get to the system window instance. Change-Id: Ia75a70ff8cdb00db2c5b21825774fd5922992573 diff --git a/sc/source/ui/view/prevwsh.cxx b/sc/source/ui/view/prevwsh.cxx index eb65065..1e556f0 100644 --- a/sc/source/ui/view/prevwsh.cxx +++ b/sc/source/ui/view/prevwsh.cxx @@ -114,7 +114,7 @@ void ScPreviewShell::Construct( Window* pParent ) // Find the top-most window, and set the close window handler to intercept // the window close event. Window* pWin = pParent; - while (true) + while (!pWin->IsSystemWindow()) { if (pWin->GetParent()) pWin = pWin->GetParent(); @@ -122,7 +122,6 @@ void ScPreviewShell::Construct( Window* pParent ) break; } - pWin = pWin->GetWindow(WINDOW_CLIENT); mpFrameWindow = dynamic_cast<SystemWindow*>(pWin); if (mpFrameWindow) mpFrameWindow->SetCloseHdl(LINK(this, ScPreviewShell, CloseHdl)); commit 80fb93fe6c08f25a404ff2afa989fca246ac9efd Author: Kohei Yoshida <kohei.yosh...@gmail.com> Date: Tue Jun 5 00:22:16 2012 -0400 Intercept the window close event and end the preview when clicking 'x'. This is to prevent the preview window from closing the whole document when pressing the window frame's 'x' button. Instead, pressing the 'x' will end the preview mode and bring it back to the normal Calc window. Change-Id: If4d42928784e3e05bc6357d811a1954efb221f01 diff --git a/sc/source/ui/inc/prevwsh.hxx b/sc/source/ui/inc/prevwsh.hxx index 0664c1e..0f89fc7 100644 --- a/sc/source/ui/inc/prevwsh.hxx +++ b/sc/source/ui/inc/prevwsh.hxx @@ -53,6 +53,7 @@ class ScPreviewShell: public SfxViewShell friend class ScPreview; // allow access to AdjustPosSizePixel ScDocShell* pDocShell; + SystemWindow* mpFrameWindow; ScPreview* pPreview; // Ausgabe-Fenster ScrollBar* pHorScroll; ScrollBar* pVerScroll; @@ -69,7 +70,9 @@ friend class ScPreview; // allow access to AdjustPosSizePixel private: void Construct( Window* pParent ); DECL_LINK(ScrollHandler, ScrollBar* ); + DECL_LINK(CloseHdl, SystemWindow*); void DoScroll( sal_uInt16 nMode ); + void ExitPreview(); protected: virtual void Activate(sal_Bool bMDI); diff --git a/sc/source/ui/view/prevwsh.cxx b/sc/source/ui/view/prevwsh.cxx index c23c2f4..eb65065 100644 --- a/sc/source/ui/view/prevwsh.cxx +++ b/sc/source/ui/view/prevwsh.cxx @@ -111,6 +111,22 @@ SFX_IMPL_NAMED_VIEWFACTORY( ScPreviewShell, "PrintPreview" ) void ScPreviewShell::Construct( Window* pParent ) { + // Find the top-most window, and set the close window handler to intercept + // the window close event. + Window* pWin = pParent; + while (true) + { + if (pWin->GetParent()) + pWin = pWin->GetParent(); + else + break; + } + + pWin = pWin->GetWindow(WINDOW_CLIENT); + mpFrameWindow = dynamic_cast<SystemWindow*>(pWin); + if (mpFrameWindow) + mpFrameWindow->SetCloseHdl(LINK(this, ScPreviewShell, CloseHdl)); + eZoom = SVX_ZOOM_WHOLEPAGE; pCorner = new ScrollBarBox( pParent, WB_SIZEABLE ); @@ -145,6 +161,7 @@ ScPreviewShell::ScPreviewShell( SfxViewFrame* pViewFrame, SfxViewShell* pOldSh ) : SfxViewShell( pViewFrame, SFX_VIEW_CAN_PRINT | SFX_VIEW_HAS_PRINTOPTIONS ), pDocShell( (ScDocShell*)pViewFrame->GetObjectShell() ), + mpFrameWindow(NULL), nSourceDesignMode( SC_FORCEMODE_NONE ), pAccessibilityBroadcaster( NULL ) { @@ -174,6 +191,9 @@ ScPreviewShell::ScPreviewShell( SfxViewFrame* pViewFrame, ScPreviewShell::~ScPreviewShell() { + if (mpFrameWindow) + mpFrameWindow->SetCloseHdl(Link()); // Remove close handler. + // #108333#; notify Accessibility that Shell is dying and before destroy all BroadcastAccessibility( SfxSimpleHint( SFX_HINT_DYING ) ); DELETEZ(pAccessibilityBroadcaster); @@ -502,6 +522,12 @@ IMPL_LINK (ScPreviewShell,ScrollHandler, ScrollBar* ,pScroll ) return 0; } +IMPL_LINK (ScPreviewShell, CloseHdl, SystemWindow*, EMPTYARG) +{ + ExitPreview(); + return 0; +} + sal_Bool ScPreviewShell::ScrollCommand( const CommandEvent& rCEvt ) { sal_Bool bDone = false; @@ -769,7 +795,7 @@ void ScPreviewShell::Execute( SfxRequest& rReq ) // -> always switch this frame back to normal view // (ScTabViewShell ctor reads stored view data) - GetViewFrame()->GetDispatcher()->Execute( SID_VIEWSHELL0, SFX_CALLMODE_ASYNCHRON ); + ExitPreview(); break; case SID_CURSORPAGEUP: case SID_CURSORPAGEDOWN: @@ -1167,6 +1193,11 @@ void ScPreviewShell::DoScroll( sal_uInt16 nMode ) } +void ScPreviewShell::ExitPreview() +{ + GetViewFrame()->GetDispatcher()->Execute(SID_VIEWSHELL0, SFX_CALLMODE_ASYNCHRON); +} + void ScPreviewShell::AddAccessibilityObject( SfxListener& rObject ) { if (!pAccessibilityBroadcaster) diff --git a/vcl/inc/vcl/syswin.hxx b/vcl/inc/vcl/syswin.hxx index 7370280..4ca02c4 100644 --- a/vcl/inc/vcl/syswin.hxx +++ b/vcl/inc/vcl/syswin.hxx @@ -271,6 +271,9 @@ public: void SetScreenNumber( unsigned int nNewScreen ); void SetApplicationID( const rtl::OUString &rApplicationID ); + + void SetCloseHdl(const Link& rLink); + const Link& GetCloseHdl() const; }; #endif // _SV_SYSWIN_HXX diff --git a/vcl/source/window/syswin.cxx b/vcl/source/window/syswin.cxx index d439943..a7a8ce0 100644 --- a/vcl/source/window/syswin.cxx +++ b/vcl/source/window/syswin.cxx @@ -57,6 +57,7 @@ public: TaskPaneList* mpTaskPaneList; Size maMaxOutSize; rtl::OUString maRepresentedURL; + Link maCloseHdl; }; SystemWindow::ImplData::ImplData() @@ -1034,4 +1035,14 @@ void SystemWindow::SetApplicationID(const rtl::OUString &rApplicationID) mpWindowImpl->mpFrame->SetApplicationID( rApplicationID ); } +void SystemWindow::SetCloseHdl(const Link& rLink) +{ + mpImplData->maCloseHdl = rLink; +} + +const Link& SystemWindow::GetCloseHdl() const +{ + return mpImplData->maCloseHdl; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/window/winproc.cxx b/vcl/source/window/winproc.cxx index 076657f..b5096ab 100644 --- a/vcl/source/window/winproc.cxx +++ b/vcl/source/window/winproc.cxx @@ -1953,20 +1953,32 @@ void ImplHandleClose( Window* pWindow ) if ( pSVData->maWinData.mpTrackWin ) pSVData->maWinData.mpTrackWin->EndTracking( ENDTRACK_CANCEL | ENDTRACK_KEY ); - if( ! bWasPopup ) + if (bWasPopup) + return; + + Window *pWin = pWindow->ImplGetWindow(); + SystemWindow* pSysWin = dynamic_cast<SystemWindow*>(pWin); + if (pSysWin) { - Window *pWin = pWindow->ImplGetWindow(); - // check whether close is allowed - if ( !pWin->IsEnabled() || !pWin->IsInputEnabled() || pWin->IsInModalMode() ) - Sound::Beep( SOUND_DISABLE, pWin ); - else + // See if the custom close handler is set. + const Link& rLink = pSysWin->GetCloseHdl(); + if (rLink.IsSet()) { - DelayedCloseEvent* pEv = new DelayedCloseEvent; - pEv->pWindow = pWin; - pWin->ImplAddDel( &pEv->aDelData ); - Application::PostUserEvent( Link( pEv, DelayedCloseEventLink ) ); + rLink.Call(pSysWin); + return; } } + + // check whether close is allowed + if ( !pWin->IsEnabled() || !pWin->IsInputEnabled() || pWin->IsInModalMode() ) + Sound::Beep( SOUND_DISABLE, pWin ); + else + { + DelayedCloseEvent* pEv = new DelayedCloseEvent; + pEv->pWindow = pWin; + pWin->ImplAddDel( &pEv->aDelData ); + Application::PostUserEvent( Link( pEv, DelayedCloseEventLink ) ); + } } // ----------------------------------------------------------------------- commit 1227601d74ecddb06dcbe69e260aa32835900ed3 Author: Kohei Yoshida <kohei.yosh...@gmail.com> Date: Mon Jun 4 14:20:35 2012 -0400 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 diff --git a/sc/sdi/docsh.sdi b/sc/sdi/docsh.sdi index 5891c10..cd3cf5c 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 2af8e07..2117128 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 c2eb404..845e551 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 9524e6b..d751bca 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 adc5208..c23c2f4 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: _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits