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/srchitem.hxx>
13 #include <svl/eitem.hxx>
14 #include <svl/whiter.hxx>
15 #include <svx/svdopath.hxx>
16 #include <sfx2/request.hxx>
17 #include <sfx2/dispatch.hxx>
18 #include <sfx2/objface.hxx>
23 #include "globals.hrc"
27 #define SwNavigationShell
28 #include "swslots.hxx"
33 SFX_IMPL_INTERFACE(SwNavigationShell
, SwBaseShell
, SW_RES(STR_SHELLNAME_NAVIGATION
))
37 SwNavigationShell::SwNavigationShell(SwView
&_rView
):
41 SetName(OUString("Navigation"));
42 SetHelpId(SW_NAVIGATIONSHELL
);
45 void SwNavigationShell::Execute(SfxRequest
&rReq
)
47 SwWrtShell
*pSh
= &GetShell();
48 SdrView
* pSdrView
= pSh
->GetDrawView();
49 const SfxItemSet
*pArgs
= rReq
.GetArgs();
50 sal_uInt16 nSlotId
= rReq
.GetSlot();
51 sal_Bool bChanged
= pSdrView
->GetModel()->IsChanged();
52 pSdrView
->GetModel()->SetChanged(sal_False
);
53 SwNavigationMgr
& aSwNavigationMgr
= pSh
->GetNavigationMgr();
54 const SfxPoolItem
* pItem
;
56 pArgs
->GetItemState(nSlotId
, sal_False
, &pItem
);
59 case FN_NAVIGATION_BACK
:
60 aSwNavigationMgr
.goBack();
63 case FN_NAVIGATION_FORWARD
:
64 aSwNavigationMgr
.goForward();
69 if (pSdrView
->GetModel()->IsChanged())
70 GetShell().SetModified();
72 pSdrView
->GetModel()->SetChanged(sal_True
);
75 // determine if the buttons should be enabled/disabled
77 void SwNavigationShell::GetState(SfxItemSet
&rSet
)
79 SwWrtShell
*pSh
= &GetShell();
80 SfxWhichIter
aIter( rSet
);
81 sal_uInt16 nWhich
= aIter
.FirstWhich();
82 SwNavigationMgr
& aNavigationMgr
= pSh
->GetNavigationMgr();
87 case FN_NAVIGATION_BACK
:
89 if (!aNavigationMgr
.backEnabled()) {
90 rSet
.DisableItem(FN_NAVIGATION_BACK
);
94 case FN_NAVIGATION_FORWARD
:
96 if (!aNavigationMgr
.forwardEnabled())
97 rSet
.DisableItem(FN_NAVIGATION_FORWARD
);
103 nWhich
= aIter
.NextWhich();
107 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */