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 {
26 }
27 
29  : SwBaseShell( _rView )
30 {
31  SetName("Navigation");
32 }
33 
35 {
36  SwWrtShell *pSh = &GetShell();
37  SdrView* pSdrView = pSh->GetDrawView();
38  const SfxItemSet *pArgs = rReq.GetArgs();
39  const sal_uInt16 nSlotId = rReq.GetSlot();
40  bool bChanged = pSdrView->GetModel()->IsChanged();
41  pSdrView->GetModel()->SetChanged(false);
42  SwNavigationMgr& aSwNavigationMgr = pSh->GetNavigationMgr();
43  const SfxPoolItem* pItem;
44  if(pArgs)
45  pArgs->GetItemState(nSlotId, false, &pItem);
46  switch (nSlotId)
47  {
48  case FN_NAVIGATION_BACK:
49  aSwNavigationMgr.goBack();
50  break;
51 
53  aSwNavigationMgr.goForward();
54  break;
55  default:
56  break;
57  }
58  if (pSdrView->GetModel()->IsChanged())
60  else if (bChanged)
61  pSdrView->GetModel()->SetChanged();
62 }
63 
64 // determine if the buttons should be enabled/disabled
65 
67 {
68  SwWrtShell *pSh = &GetShell();
69  SfxWhichIter aIter( rSet );
70  sal_uInt16 nWhich = aIter.FirstWhich();
71  SwNavigationMgr& aNavigationMgr = pSh->GetNavigationMgr();
72  while( nWhich )
73  {
74  switch( nWhich )
75  {
76  case FN_NAVIGATION_BACK:
77  if (!aNavigationMgr.backEnabled())
78  {
80  }
81  break;
83  if (!aNavigationMgr.forwardEnabled())
84  {
86  }
87  break;
88  default:
89  break;
90  }
91  nWhich = aIter.NextWhich();
92  }
93 }
94 
95 /* 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:66
bool forwardEnabled()
Definition: navmgr.cxx:92
SwWrtShell & GetShell()
Definition: basesh.cxx:2680
void Execute(SfxRequest const &)
Definition: navsh.cxx:34
#define FN_NAVIGATION_FORWARD
Definition: cmdid.h:613
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:612
SwNavigationShell(SwView &rView)
Definition: navsh.cxx:28
SdrModel * GetModel() const
Definition: view.hxx:144