bump product version to 4.1.6.2
[LibreOffice.git] / sw / source / ui / shells / navsh.cxx
blob5d9ea9a30352e293496044b81c32a33795fa244a
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/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>
19 #include "wrtsh.hxx"
20 #include "view.hxx"
21 #include "edtwin.hxx"
22 #include "helpid.h"
23 #include "globals.hrc"
24 #include "navsh.hxx"
25 #include "popup.hrc"
26 #include "shells.hrc"
27 #define SwNavigationShell
28 #include "swslots.hxx"
29 #include <unomid.h>
30 #include "navmgr.hxx"
33 SFX_IMPL_INTERFACE(SwNavigationShell, SwBaseShell, SW_RES(STR_SHELLNAME_NAVIGATION))
37 SwNavigationShell::SwNavigationShell(SwView &_rView):
38 SwBaseShell( _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;
55 if(pArgs)
56 pArgs->GetItemState(nSlotId, sal_False, &pItem);
57 switch (nSlotId)
59 case FN_NAVIGATION_BACK:
60 aSwNavigationMgr.goBack();
61 break;
63 case FN_NAVIGATION_FORWARD:
64 aSwNavigationMgr.goForward();
65 break;
66 default:
67 break;
69 if (pSdrView->GetModel()->IsChanged())
70 GetShell().SetModified();
71 else if (bChanged)
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();
83 while( nWhich )
85 switch( nWhich )
87 case FN_NAVIGATION_BACK:
89 if (!aNavigationMgr.backEnabled()) {
90 rSet.DisableItem(FN_NAVIGATION_BACK);
93 break;
94 case FN_NAVIGATION_FORWARD:
96 if (!aNavigationMgr.forwardEnabled())
97 rSet.DisableItem(FN_NAVIGATION_FORWARD);
99 break;
100 default:
101 break;
103 nWhich = aIter.NextWhich();
107 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */