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/.
11 #include <svx/svdview.hxx>
12 #include <svl/whiter.hxx>
13 #include <sfx2/request.hxx>
14 #include <sfx2/objface.hxx>
18 #define ShellClass_SwNavigationShell
19 #include <swslots.hxx>
22 SFX_IMPL_INTERFACE(SwNavigationShell
, SwBaseShell
)
24 void SwNavigationShell::InitInterface_Impl() {}
26 SwNavigationShell::SwNavigationShell(SwView
& _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
;
43 pArgs
->GetItemState(nSlotId
, false, &pItem
);
45 if (pSdrView
->IsTextEdit())
47 if (pSh
->GetView().IsDrawMode())
48 pSh
->GetView().LeaveDrawCreate();
53 case FN_NAVIGATION_BACK
:
54 aSwNavigationMgr
.goBack();
57 case FN_NAVIGATION_FORWARD
:
58 aSwNavigationMgr
.goForward();
63 if (pSdrView
->GetModel().IsChanged())
64 GetShell().SetModified();
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();
81 case FN_NAVIGATION_BACK
:
82 if (!aNavigationMgr
.backEnabled())
84 rSet
.DisableItem(FN_NAVIGATION_BACK
);
87 case FN_NAVIGATION_FORWARD
:
88 if (!aNavigationMgr
.forwardEnabled())
90 rSet
.DisableItem(FN_NAVIGATION_FORWARD
);
96 nWhich
= aIter
.NextWhich();
100 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */