android: Update app-specific/MIME type icons
[LibreOffice.git] / sd / source / ui / func / funavig.cxx
blobbd0cdb7c3336b63ebc8549e8da8339ea944c196c
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( !bSlideShow)
73 if( auto pDrawViewShell = dynamic_cast<DrawViewShell *>( mpViewShell ) )
75 // With no modifier pressed we move to the previous
76 // slide.
77 mpView->SdrEndTextEdit();
79 // Previous page.
80 SdPage* pPage = pDrawViewShell->GetActualPage();
81 sal_uInt16 nSdPage = (pPage->GetPageNum() - 1) / 2;
83 if (nSdPage > 0)
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 ();
99 break;
101 case SID_GO_TO_NEXT_PAGE:
103 if( !bSlideShow)
104 if( auto pDrawViewShell = dynamic_cast<DrawViewShell *>( mpViewShell ))
106 // With no modifier pressed we move to the next slide.
107 mpView->SdrEndTextEdit();
109 // Next page.
110 SdPage* pPage = pDrawViewShell->GetActualPage();
111 sal_uInt16 nSdPage = (pPage->GetPageNum() - 1) / 2;
113 if (nSdPage < mpDoc->GetSdPageCount(pPage->GetPageKind()) - 1)
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 ();
128 break;
130 case SID_GO_TO_LAST_PAGE:
132 if (!mpView->IsTextEdit() && !bSlideShow)
133 if (auto pDrawViewShell = dynamic_cast<DrawViewShell *>( mpViewShell ))
135 // jump to last page
136 SdPage* pPage = pDrawViewShell->GetActualPage();
137 pDrawViewShell->SwitchPage(mpDoc->GetSdPageCount(
138 pPage->GetPageKind()) - 1);
141 break;
143 // Refresh toolbar icons
144 SfxBindings& rBindings = mpViewShell->GetViewFrame()->GetBindings();
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);
152 } // end of namespace sd
154 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */