LibreOffice Module sd (master) 1
funavig.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <funavig.hxx>
21#include <sfx2/viewfrm.hxx>
22
23#include <app.hrc>
24#include <sdpage.hxx>
25#include <sfx2/bindings.hxx>
26#include <sfx2/request.hxx>
27#include <drawdoc.hxx>
28#include <DrawViewShell.hxx>
29#include <ViewShell.hxx>
30#include <slideshow.hxx>
31
32namespace sd {
33
34
36 ViewShell* pViewSh,
37 ::sd::Window* pWin,
38 ::sd::View* pView,
39 SdDrawDocument* pDoc,
40 SfxRequest& rReq)
41 : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
42{
43}
44
46{
47 rtl::Reference<FuPoor> xFunc( new FuNavigation( pViewSh, pWin, pView, pDoc, rReq ) );
48 xFunc->DoExecute(rReq);
49 return xFunc;
50}
51
53{
55
56 switch ( rReq.GetSlot() )
57 {
58 case SID_GO_TO_FIRST_PAGE:
59 {
60 if (!mpView->IsTextEdit()
61 && dynamic_cast< const DrawViewShell *>( mpViewShell ) != nullptr
62 && !bSlideShow)
63 {
64 // jump to first page
65 static_cast<DrawViewShell*>(mpViewShell)->SwitchPage(0);
66 }
67 }
68 break;
69
70 case SID_GO_TO_PREVIOUS_PAGE:
71 {
72 if( !bSlideShow)
73 if( auto pDrawViewShell = dynamic_cast<DrawViewShell *>( mpViewShell ) )
74 {
75 // With no modifier pressed we move to the previous
76 // slide.
78
79 // Previous page.
80 SdPage* pPage = pDrawViewShell->GetActualPage();
81 sal_uInt16 nSdPage = (pPage->GetPageNum() - 1) / 2;
82
83 if (nSdPage > 0)
84 {
85 // Switch the page and send events regarding
86 // deactivation the old page and activating the new
87 // one.
88 TabControl& rPageTabControl =
89 static_cast<DrawViewShell*>(mpViewShell)
90 ->GetPageTabControl();
91 if (rPageTabControl.IsReallyShown())
92 rPageTabControl.SendDeactivatePageEvent ();
93 static_cast<DrawViewShell*>(mpViewShell)->SwitchPage(nSdPage - 1);
94 if (rPageTabControl.IsReallyShown())
95 rPageTabControl.SendActivatePageEvent ();
96 }
97 }
98 }
99 break;
100
101 case SID_GO_TO_NEXT_PAGE:
102 {
103 if( !bSlideShow)
104 if( auto pDrawViewShell = dynamic_cast<DrawViewShell *>( mpViewShell ))
105 {
106 // With no modifier pressed we move to the next slide.
108
109 // Next page.
110 SdPage* pPage = pDrawViewShell->GetActualPage();
111 sal_uInt16 nSdPage = (pPage->GetPageNum() - 1) / 2;
112
113 if (nSdPage < mpDoc->GetSdPageCount(pPage->GetPageKind()) - 1)
114 {
115 // Switch the page and send events regarding
116 // deactivation the old page and activating the new
117 // one.
118 TabControl& rPageTabControl =
119 static_cast<DrawViewShell*>(mpViewShell)->GetPageTabControl();
120 if (rPageTabControl.IsReallyShown())
121 rPageTabControl.SendDeactivatePageEvent ();
122 static_cast<DrawViewShell*>(mpViewShell)->SwitchPage(nSdPage + 1);
123 if (rPageTabControl.IsReallyShown())
124 rPageTabControl.SendActivatePageEvent ();
125 }
126 }
127 }
128 break;
129
130 case SID_GO_TO_LAST_PAGE:
131 {
132 if (!mpView->IsTextEdit() && !bSlideShow)
133 if (auto pDrawViewShell = dynamic_cast<DrawViewShell *>( mpViewShell ))
134 {
135 // jump to last page
136 SdPage* pPage = pDrawViewShell->GetActualPage();
137 pDrawViewShell->SwitchPage(mpDoc->GetSdPageCount(
138 pPage->GetPageKind()) - 1);
139 }
140 }
141 break;
142 }
143 // Refresh toolbar icons
145 rBindings.Invalidate(SID_GO_TO_FIRST_PAGE);
146 rBindings.Invalidate(SID_GO_TO_PREVIOUS_PAGE);
147 rBindings.Invalidate(SID_GO_TO_NEXT_PAGE);
148 rBindings.Invalidate(SID_GO_TO_LAST_PAGE);
149}
150
151
152} // end of namespace sd
153
154/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt16 GetSdPageCount(PageKind ePgKind) const
Definition: drawdoc2.cxx:212
PageKind GetPageKind() const
Definition: sdpage.hxx:205
virtual bool IsTextEdit() const final override
sal_uInt16 GetPageNum() const
void Invalidate(sal_uInt16 nId)
sal_uInt16 GetSlot() const
SfxBindings & GetBindings()
Base class of the stacked shells that provide graphical views to Draw and Impress documents and editi...
virtual void DoExecute(SfxRequest &rReq) override
Definition: funavig.cxx:52
FuNavigation(ViewShell *pViewSh, ::sd::Window *pWin, ::sd::View *pView, SdDrawDocument *pDoc, SfxRequest &rReq)
Definition: funavig.cxx:35
static rtl::Reference< FuPoor > Create(ViewShell *pViewSh, ::sd::Window *pWin, ::sd::View *pView, SdDrawDocument *pDoc, SfxRequest &rReq)
Definition: funavig.cxx:45
Base class for all functions.
Definition: fupoor.hxx:48
SdDrawDocument * mpDoc
Definition: fupoor.hxx:148
ViewShell * mpViewShell
Definition: fupoor.hxx:145
::sd::View * mpView
Definition: fupoor.hxx:144
static bool IsRunning(ViewShellBase const &rBase)
returns true if there is a running presentation for the given ViewShellBase
Definition: slideshow.cxx:208
void SendDeactivatePageEvent()
Inform all listeners of this control that the current page has been deactivated.
Definition: tabcontr.cxx:350
void SendActivatePageEvent()
Inform all listeners of this control that the current page has been activated.
Definition: tabcontr.cxx:344
Base class of the stacked shell hierarchy.
Definition: ViewShell.hxx:92
SD_DLLPUBLIC ViewShellBase & GetViewShellBase() const
Definition: viewshel.cxx:1397
SD_DLLPUBLIC SfxViewFrame * GetViewFrame() const
Definition: viewshel.cxx:118
virtual SdrEndTextEditKind SdrEndTextEdit(bool bDontDeleteReally=false) override
ends current text editing
Definition: sdview.cxx:772
An SdWindow contains the actual working area of ViewShell.
Definition: Window.hxx:45