Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sw / source / uibase / shells / navsh.cxx
blobc34bebdbc71e08e2b97b49f2b2dc3c9b4bb9bf17
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/.
8 */
10 #include <cmdid.h>
11 #include <svx/svdview.hxx>
12 #include <svl/whiter.hxx>
13 #include <sfx2/request.hxx>
14 #include <sfx2/objface.hxx>
15 #include <wrtsh.hxx>
16 #include <view.hxx>
17 #include <navsh.hxx>
18 #define ShellClass_SwNavigationShell
19 #include <swslots.hxx>
20 #include <navmgr.hxx>
22 SFX_IMPL_INTERFACE(SwNavigationShell, SwBaseShell)
24 void SwNavigationShell::InitInterface_Impl() {}
26 SwNavigationShell::SwNavigationShell(SwView& _rView)
27 : SwBaseShell(_rView)
29 SetName("Navigation");
32 void SwNavigationShell::Execute(SfxRequest const& rReq)
34 SwWrtShell* pSh = &GetShell();
35 SdrView* pSdrView = pSh->GetDrawView();
36 const SfxItemSet* pArgs = rReq.GetArgs();
37 const sal_uInt16 nSlotId = rReq.GetSlot();
38 bool bChanged = pSdrView->GetModel().IsChanged();
39 pSdrView->GetModel().SetChanged(false);
40 SwNavigationMgr& aSwNavigationMgr = pSh->GetNavigationMgr();
41 const SfxPoolItem* pItem;
42 if (pArgs)
43 pArgs->GetItemState(nSlotId, false, &pItem);
45 if (pSdrView->IsTextEdit())
46 pSh->EndTextEdit();
47 if (pSh->GetView().IsDrawMode())
48 pSh->GetView().LeaveDrawCreate();
49 pSh->EnterStdMode();
51 switch (nSlotId)
53 case FN_NAVIGATION_BACK:
54 aSwNavigationMgr.goBack();
55 break;
57 case FN_NAVIGATION_FORWARD:
58 aSwNavigationMgr.goForward();
59 break;
60 default:
61 break;
63 if (pSdrView->GetModel().IsChanged())
64 GetShell().SetModified();
65 else if (bChanged)
66 pSdrView->GetModel().SetChanged();
69 // determine if the buttons should be enabled/disabled
71 void SwNavigationShell::GetState(SfxItemSet& rSet)
73 SwWrtShell* pSh = &GetShell();
74 SfxWhichIter aIter(rSet);
75 sal_uInt16 nWhich = aIter.FirstWhich();
76 SwNavigationMgr& aNavigationMgr = pSh->GetNavigationMgr();
77 while (nWhich)
79 switch (nWhich)
81 case FN_NAVIGATION_BACK:
82 if (!aNavigationMgr.backEnabled())
84 rSet.DisableItem(FN_NAVIGATION_BACK);
86 break;
87 case FN_NAVIGATION_FORWARD:
88 if (!aNavigationMgr.forwardEnabled())
90 rSet.DisableItem(FN_NAVIGATION_FORWARD);
92 break;
93 default:
94 break;
96 nWhich = aIter.NextWhich();
100 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */