LibreOffice Module sw (master)  1
navsh.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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  */
9 
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>
21 
23 
24 void SwNavigationShell::InitInterface_Impl() {}
25 
27  : SwBaseShell(_rView)
28 {
29  SetName("Navigation");
30 }
31 
33 {
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);
44  switch (nSlotId)
45  {
46  case FN_NAVIGATION_BACK:
47  aSwNavigationMgr.goBack();
48  break;
49 
51  aSwNavigationMgr.goForward();
52  break;
53  default:
54  break;
55  }
56  if (pSdrView->GetModel()->IsChanged())
58  else if (bChanged)
59  pSdrView->GetModel()->SetChanged();
60 }
61 
62 // determine if the buttons should be enabled/disabled
63 
65 {
66  SwWrtShell* pSh = &GetShell();
67  SfxWhichIter aIter(rSet);
68  sal_uInt16 nWhich = aIter.FirstWhich();
69  SwNavigationMgr& aNavigationMgr = pSh->GetNavigationMgr();
70  while (nWhich)
71  {
72  switch (nWhich)
73  {
74  case FN_NAVIGATION_BACK:
75  if (!aNavigationMgr.backEnabled())
76  {
78  }
79  break;
81  if (!aNavigationMgr.forwardEnabled())
82  {
84  }
85  break;
86  default:
87  break;
88  }
89  nWhich = aIter.NextWhich();
90  }
91 }
92 
93 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define SFX_IMPL_INTERFACE(Class, SuperClass)
SdrView * GetDrawView()
Definition: vnew.cxx:375
void GetState(SfxItemSet &)
Definition: navsh.cxx:64
bool forwardEnabled()
Definition: navmgr.cxx:92
SwWrtShell & GetShell()
Definition: basesh.cxx:2687
void Execute(SfxRequest const &)
Definition: navsh.cxx:32
#define FN_NAVIGATION_FORWARD
Definition: cmdid.h:614
sal_uInt16 FirstWhich()
void SetModified()
Definition: edws.cxx:70
const SfxItemSet * GetArgs() const
sal_uInt16 NextWhich()
SwNavigationMgr & GetNavigationMgr()
Definition: wrtsh.hxx:470
Used by the UI to modify the document model.
Definition: wrtsh.hxx:90
void goBack()
Definition: navmgr.cxx:100
virtual void SetChanged(bool bFlg=true)
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
void goForward()
Definition: navmgr.cxx:146
bool backEnabled()
Definition: navmgr.cxx:82
void SetName(const OUString &rName)
bool IsChanged() const
sal_uInt16 GetSlot() const
void DisableItem(sal_uInt16 nWhich)
#define FN_NAVIGATION_BACK
Definition: cmdid.h:613
SwNavigationShell(SwView &rView)
Definition: navsh.cxx:26
SdrModel * GetModel() const
Definition: view.hxx:144