1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
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>
35 FuNavigation::FuNavigation (
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
);
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
65 static_cast<DrawViewShell
*>(mpViewShell
)->SwitchPage(0);
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
76 mpView
->SdrEndTextEdit();
79 SdPage
* pPage
= static_cast<DrawViewShell
*>(mpViewShell
)->GetActualPage();
80 sal_uInt16 nSdPage
= (pPage
->GetPageNum() - 1) / 2;
84 // Switch the page and send events regarding
85 // deactivation the old page and activating the new
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 ();
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();
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
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 ();
128 case SID_GO_TO_LAST_PAGE
:
130 if (!mpView
->IsTextEdit()
131 && dynamic_cast< const DrawViewShell
*>( mpViewShell
) != nullptr
136 static_cast<DrawViewShell
*>(mpViewShell
)->GetActualPage();
137 static_cast<DrawViewShell
*>(mpViewShell
)
138 ->SwitchPage(mpDoc
->GetSdPageCount(
139 pPage
->GetPageKind()) - 1);
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: */