Version 6.1.0.2, tag libreoffice-6.1.0.2
[LibreOffice.git] / sd / source / ui / func / funavig.cxx
blobe481562f0c47f3f1cad71ad26f2faf6608c789dc
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <funavig.hxx>
21 #include <sfx2/viewfrm.hxx>
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>
32 namespace sd {
35 FuNavigation::FuNavigation (
36 ViewShell* pViewSh,
37 ::sd::Window* pWin,
38 ::sd::View* pView,
39 SdDrawDocument* pDoc,
40 SfxRequest& rReq)
41 : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
45 rtl::Reference<FuPoor> FuNavigation::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
47 rtl::Reference<FuPoor> xFunc( new FuNavigation( pViewSh, pWin, pView, pDoc, rReq ) );
48 xFunc->DoExecute(rReq);
49 return xFunc;
52 void FuNavigation::DoExecute( SfxRequest& rReq )
54 bool bSlideShow = SlideShow::IsRunning( mpViewShell->GetViewShellBase() );
56 switch ( rReq.GetSlot() )
58 case SID_GO_TO_FIRST_PAGE:
60 if (!mpView->IsTextEdit()
61 && dynamic_cast< const DrawViewShell *>( mpViewShell ) != nullptr
62 && !bSlideShow)
64 // jump to first page
65 static_cast<DrawViewShell*>(mpViewShell)->SwitchPage(0);
68 break;
70 case SID_GO_TO_PREVIOUS_PAGE:
72 if( dynamic_cast< const DrawViewShell *>( mpViewShell ) != nullptr && !bSlideShow)
74 // With no modifier pressed we move to the previous
75 // slide.
76 mpView->SdrEndTextEdit();
78 // Previous page.
79 SdPage* pPage = static_cast<DrawViewShell*>(mpViewShell)->GetActualPage();
80 sal_uInt16 nSdPage = (pPage->GetPageNum() - 1) / 2;
82 if (nSdPage > 0)
84 // Switch the page and send events regarding
85 // deactivation the old page and activating the new
86 // one.
87 TabControl& rPageTabControl =
88 static_cast<DrawViewShell*>(mpViewShell)
89 ->GetPageTabControl();
90 if (rPageTabControl.IsReallyShown())
91 rPageTabControl.SendDeactivatePageEvent ();
92 static_cast<DrawViewShell*>(mpViewShell)->SwitchPage(nSdPage - 1);
93 if (rPageTabControl.IsReallyShown())
94 rPageTabControl.SendActivatePageEvent ();
98 break;
100 case SID_GO_TO_NEXT_PAGE:
102 if( dynamic_cast< const DrawViewShell *>( mpViewShell ) != nullptr && !bSlideShow)
104 // With no modifier pressed we move to the next slide.
105 mpView->SdrEndTextEdit();
107 // Next page.
108 SdPage* pPage = static_cast<DrawViewShell*>(mpViewShell)->GetActualPage();
109 sal_uInt16 nSdPage = (pPage->GetPageNum() - 1) / 2;
111 if (nSdPage < mpDoc->GetSdPageCount(pPage->GetPageKind()) - 1)
113 // Switch the page and send events regarding
114 // deactivation the old page and activating the new
115 // one.
116 TabControl& rPageTabControl =
117 static_cast<DrawViewShell*>(mpViewShell)->GetPageTabControl();
118 if (rPageTabControl.IsReallyShown())
119 rPageTabControl.SendDeactivatePageEvent ();
120 static_cast<DrawViewShell*>(mpViewShell)->SwitchPage(nSdPage + 1);
121 if (rPageTabControl.IsReallyShown())
122 rPageTabControl.SendActivatePageEvent ();
126 break;
128 case SID_GO_TO_LAST_PAGE:
130 if (!mpView->IsTextEdit()
131 && dynamic_cast< const DrawViewShell *>( mpViewShell ) != nullptr
132 && !bSlideShow)
134 // jump to last page
135 SdPage* pPage =
136 static_cast<DrawViewShell*>(mpViewShell)->GetActualPage();
137 static_cast<DrawViewShell*>(mpViewShell)
138 ->SwitchPage(mpDoc->GetSdPageCount(
139 pPage->GetPageKind()) - 1);
142 break;
144 // Refresh toolbar icons
145 SfxBindings& rBindings = mpViewShell->GetViewFrame()->GetBindings();
146 rBindings.Invalidate(SID_GO_TO_FIRST_PAGE);
147 rBindings.Invalidate(SID_GO_TO_PREVIOUS_PAGE);
148 rBindings.Invalidate(SID_GO_TO_NEXT_PAGE);
149 rBindings.Invalidate(SID_GO_TO_LAST_PAGE);
153 } // end of namespace sd
155 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */