tdf#130857 qt weld: Support mail merge "Server Auth" dialog
[LibreOffice.git] / sd / source / ui / func / funavig.cxx
blobca7565c8ba49ff76fba235504651d1d339650dbb
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 #include <svx/svxids.hrc>
33 #include <svx/dialog/gotodlg.hxx>
34 #include <strings.hrc>
35 #include <sdresid.hxx>
37 namespace sd {
40 FuNavigation::FuNavigation (
41 ViewShell* pViewSh,
42 ::sd::Window* pWin,
43 ::sd::View* pView,
44 SdDrawDocument* pDoc,
45 SfxRequest& rReq)
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);
54 return xFunc;
57 void FuNavigation::DoExecute( SfxRequest& rReq )
59 assert(mpViewShell);
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
69 && !bSlideShow)
71 // jump to first page
72 static_cast<DrawViewShell*>(mpViewShell)->SwitchPage(0);
75 break;
77 case SID_GO_TO_PREVIOUS_PAGE:
79 if( !bSlideShow)
80 if( auto pDrawViewShell = dynamic_cast<DrawViewShell *>( mpViewShell ) )
82 // With no modifier pressed we move to the previous
83 // slide.
84 mpView->SdrEndTextEdit();
86 // Previous page.
87 SdPage* pPage = pDrawViewShell->GetActualPage();
88 sal_uInt16 nSdPage = (pPage->GetPageNum() - 1) / 2;
90 if (nSdPage > 0)
92 // Switch the page and send events regarding
93 // deactivation the old page and activating the new
94 // one.
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 ();
106 break;
108 case SID_GO_TO_NEXT_PAGE:
110 if( !bSlideShow)
111 if( auto pDrawViewShell = dynamic_cast<DrawViewShell *>( mpViewShell ))
113 // With no modifier pressed we move to the next slide.
114 mpView->SdrEndTextEdit();
116 // Next page.
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
124 // one.
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 ();
135 break;
137 case SID_GO_TO_LAST_PAGE:
139 if (!mpView->IsTextEdit() && !bSlideShow)
140 if (auto pDrawViewShell = dynamic_cast<DrawViewShell *>( mpViewShell ))
142 // jump to last page
143 SdPage* pPage = pDrawViewShell->GetActualPage();
144 pDrawViewShell->SwitchPage(mpDoc->GetSdPageCount(
145 pPage->GetPageKind()) - 1);
148 break;
150 case SID_GO_TO_PAGE:
152 if( !bSlideShow)
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);
170 break;
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: */