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/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 <globals.hrc>
23 #include <navsh.hxx>
24 #define ShellClass_SwNavigationShell
25 #include <swslots.hxx>
26 #include <unomid.h>
27 #include <navmgr.hxx>
28 
30 
31 void SwNavigationShell::InitInterface_Impl()
32 {
33 }
34 
36  : SwBaseShell( _rView )
37 {
38  SetName("Navigation");
39 }
40 
42 {
43  SwWrtShell *pSh = &GetShell();
44  SdrView* pSdrView = pSh->GetDrawView();
45  const SfxItemSet *pArgs = rReq.GetArgs();
46  const sal_uInt16 nSlotId = rReq.GetSlot();
47  bool bChanged = pSdrView->GetModel()->IsChanged();
48  pSdrView->GetModel()->SetChanged(false);
49  SwNavigationMgr& aSwNavigationMgr = pSh->GetNavigationMgr();
50  const SfxPoolItem* pItem;
51  if(pArgs)
52  pArgs->GetItemState(nSlotId, false, &pItem);
53  switch (nSlotId)
54  {
55  case FN_NAVIGATION_BACK:
56  aSwNavigationMgr.goBack();
57  break;
58 
60  aSwNavigationMgr.goForward();
61  break;
62  default:
63  break;
64  }
65  if (pSdrView->GetModel()->IsChanged())
67  else if (bChanged)
68  pSdrView->GetModel()->SetChanged();
69 }
70 
71 // determine if the buttons should be enabled/disabled
72 
74 {
75  SwWrtShell *pSh = &GetShell();
76  SfxWhichIter aIter( rSet );
77  sal_uInt16 nWhich = aIter.FirstWhich();
78  SwNavigationMgr& aNavigationMgr = pSh->GetNavigationMgr();
79  while( nWhich )
80  {
81  switch( nWhich )
82  {
83  case FN_NAVIGATION_BACK:
84  if (!aNavigationMgr.backEnabled())
85  {
87  }
88  break;
90  if (!aNavigationMgr.forwardEnabled())
91  {
93  }
94  break;
95  default:
96  break;
97  }
98  nWhich = aIter.NextWhich();
99  }
100 }
101 
102 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define SFX_IMPL_INTERFACE(Class, SuperClass)
SdrView * GetDrawView()
Definition: vnew.cxx:376
void GetState(SfxItemSet &)
Definition: navsh.cxx:73
bool forwardEnabled()
Definition: navmgr.cxx:92
SwWrtShell & GetShell()
Definition: basesh.cxx:2622
void Execute(SfxRequest const &)
Definition: navsh.cxx:41
#define FN_NAVIGATION_FORWARD
Definition: cmdid.h:594
sal_uInt16 FirstWhich()
void SetModified()
Definition: edws.cxx:69
const SfxItemSet * GetArgs() const
sal_uInt16 NextWhich()
SwNavigationMgr & GetNavigationMgr()
Definition: wrtsh.hxx:468
Used by the UI to modify the document model.
Definition: wrtsh.hxx:88
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:593
SwNavigationShell(SwView &rView)
Definition: navsh.cxx:35
SdrModel * GetModel() const
Definition: view.hxx:146