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>
32 #include <svx/svxids.hrc>
33 #include <svx/dialog/gotodlg.hxx>
34 #include <strings.hrc>
35 #include <sdresid.hxx>
40 FuNavigation::FuNavigation (
46 : FuPoor(pViewSh
, pWin
, pView
, pDoc
, rReq
)
50 rtl::Reference
<FuPoor
> FuNavigation::Create( ViewShell
* pViewSh
, ::sd::Window
* pWin
, ::sd::View
* pView
, SdDrawDocument
* pDoc
, SfxRequest
& rReq
)
52 rtl::Reference
<FuPoor
> xFunc( new FuNavigation( pViewSh
, pWin
, pView
, pDoc
, rReq
) );
53 xFunc
->DoExecute(rReq
);
57 void FuNavigation::DoExecute( SfxRequest
& rReq
)
60 bool bSlideShow
= SlideShow::IsRunning( mpViewShell
->GetViewShellBase() )
61 && !SlideShow::IsInteractiveSlideshow( &mpViewShell
->GetViewShellBase() ); // IASS
63 switch ( rReq
.GetSlot() )
65 case SID_GO_TO_FIRST_PAGE
:
67 if (!mpView
->IsTextEdit()
68 && dynamic_cast< const DrawViewShell
*>( mpViewShell
) != nullptr
72 static_cast<DrawViewShell
*>(mpViewShell
)->SwitchPage(0);
77 case SID_GO_TO_PREVIOUS_PAGE
:
80 if( auto pDrawViewShell
= dynamic_cast<DrawViewShell
*>( mpViewShell
) )
82 // With no modifier pressed we move to the previous
84 mpView
->SdrEndTextEdit();
87 SdPage
* pPage
= pDrawViewShell
->GetActualPage();
88 sal_uInt16 nSdPage
= (pPage
->GetPageNum() - 1) / 2;
92 // Switch the page and send events regarding
93 // deactivation the old page and activating the new
95 TabControl
& rPageTabControl
=
96 static_cast<DrawViewShell
*>(mpViewShell
)
97 ->GetPageTabControl();
98 if (rPageTabControl
.IsReallyShown())
99 rPageTabControl
.SendDeactivatePageEvent ();
100 static_cast<DrawViewShell
*>(mpViewShell
)->SwitchPage(nSdPage
- 1);
101 if (rPageTabControl
.IsReallyShown())
102 rPageTabControl
.SendActivatePageEvent ();
108 case SID_GO_TO_NEXT_PAGE
:
111 if( auto pDrawViewShell
= dynamic_cast<DrawViewShell
*>( mpViewShell
))
113 // With no modifier pressed we move to the next slide.
114 mpView
->SdrEndTextEdit();
117 SdPage
* pPage
= pDrawViewShell
->GetActualPage();
118 sal_uInt16 nSdPage
= (pPage
->GetPageNum() - 1) / 2;
120 if (nSdPage
< mpDoc
->GetSdPageCount(pPage
->GetPageKind()) - 1)
122 // Switch the page and send events regarding
123 // deactivation the old page and activating the new
125 TabControl
& rPageTabControl
=
126 static_cast<DrawViewShell
*>(mpViewShell
)->GetPageTabControl();
127 if (rPageTabControl
.IsReallyShown())
128 rPageTabControl
.SendDeactivatePageEvent ();
129 static_cast<DrawViewShell
*>(mpViewShell
)->SwitchPage(nSdPage
+ 1);
130 if (rPageTabControl
.IsReallyShown())
131 rPageTabControl
.SendActivatePageEvent ();
137 case SID_GO_TO_LAST_PAGE
:
139 if (!mpView
->IsTextEdit() && !bSlideShow
)
140 if (auto pDrawViewShell
= dynamic_cast<DrawViewShell
*>( mpViewShell
))
143 SdPage
* pPage
= pDrawViewShell
->GetActualPage();
144 pDrawViewShell
->SwitchPage(mpDoc
->GetSdPageCount(
145 pPage
->GetPageKind()) - 1);
153 if(auto pDrawViewShell
= dynamic_cast<DrawViewShell
*>( mpViewShell
))
155 OUString sTitle
= SdResId(STR_GOTO_PAGE_DLG_TITLE
);
156 OUString sLabel
= SdResId(STR_PAGE_NAME
) + ":";
158 if (mpDoc
->GetDocumentType() == DocumentType::Impress
)
160 sTitle
= SdResId(STR_GOTO_SLIDE_DLG_TITLE
);
161 sLabel
= SdResId(STR_SLIDE_NAME
) + ":";
163 svx::GotoPageDlg
aDlg(pDrawViewShell
->GetFrameWeld(), sTitle
, sLabel
,
164 pDrawViewShell
->GetCurPagePos() + 1,
165 mpDoc
->GetSdPageCount(PageKind::Standard
));
166 if (aDlg
.run() == RET_OK
)
167 pDrawViewShell
->SwitchPage(aDlg
.GetPageSelection() - 1);
172 // Refresh toolbar icons
173 SfxBindings
& rBindings
= mpViewShell
->GetViewFrame()->GetBindings();
174 rBindings
.Invalidate(SID_GO_TO_FIRST_PAGE
);
175 rBindings
.Invalidate(SID_GO_TO_PREVIOUS_PAGE
);
176 rBindings
.Invalidate(SID_GO_TO_NEXT_PAGE
);
177 rBindings
.Invalidate(SID_GO_TO_LAST_PAGE
);
181 } // end of namespace sd
183 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */