summaryrefslogtreecommitdiff
path: root/sc/source/ui/view/prevwsh.cxx
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2012-06-05 00:22:16 -0400
committerKohei Yoshida <kohei.yoshida@gmail.com>2012-06-05 12:16:24 -0400
commit80fb93fe6c08f25a404ff2afa989fca246ac9efd (patch)
treeaad95dd4c2b914065fa9050ca98a1098ccce2344 /sc/source/ui/view/prevwsh.cxx
parent1227601d74ecddb06dcbe69e260aa32835900ed3 (diff)
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
Diffstat (limited to 'sc/source/ui/view/prevwsh.cxx')
-rw-r--r--sc/source/ui/view/prevwsh.cxx33
1 files changed, 32 insertions, 1 deletions
diff --git a/sc/source/ui/view/prevwsh.cxx b/sc/source/ui/view/prevwsh.cxx
index c23c2f43f7dc..eb650651b448 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)