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 
45  if (pSdrView->IsTextEdit())
46  pSh->EndTextEdit();
47  if (pSh->GetView().IsDrawMode())
48  pSh->GetView().LeaveDrawCreate();
49  pSh->EnterStdMode();
50 
51  switch (nSlotId)
52  {
53  case FN_NAVIGATION_BACK:
54  aSwNavigationMgr.goBack();
55  break;
56 
58  aSwNavigationMgr.goForward();
59  break;
60  default:
61  break;
62  }
63  if (pSdrView->GetModel()->IsChanged())
65  else if (bChanged)
66  pSdrView->GetModel()->SetChanged();
67 }
68 
69 // determine if the buttons should be enabled/disabled
70 
72 {
73  SwWrtShell* pSh = &GetShell();
74  SfxWhichIter aIter(rSet);
75  sal_uInt16 nWhich = aIter.FirstWhich();
76  SwNavigationMgr& aNavigationMgr = pSh->GetNavigationMgr();
77  while (nWhich)
78  {
79  switch (nWhich)
80  {
81  case FN_NAVIGATION_BACK:
82  if (!aNavigationMgr.backEnabled())
83  {
85  }
86  break;
88  if (!aNavigationMgr.forwardEnabled())
89  {
91  }
92  break;
93  default:
94  break;
95  }
96  nWhich = aIter.NextWhich();
97  }
98 }
99 
100 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool IsDrawMode() const
Definition: view.hxx:539
#define SFX_IMPL_INTERFACE(Class, SuperClass)
SdrView * GetDrawView()
Definition: vnew.cxx:376
void GetState(SfxItemSet &)
Definition: navsh.cxx:71
bool forwardEnabled()
Definition: navmgr.cxx:93
SwWrtShell & GetShell()
Definition: basesh.cxx:2760
void Execute(SfxRequest const &)
Definition: navsh.cxx:32
#define FN_NAVIGATION_FORWARD
Definition: cmdid.h:614
sal_uInt16 FirstWhich()
void EnterStdMode()
Definition: select.cxx:551
void SetModified()
Definition: edws.cxx:70
const SfxItemSet * GetArgs() const
sal_uInt16 NextWhich()
SwNavigationMgr & GetNavigationMgr()
Definition: wrtsh.hxx:473
Used by the UI to modify the document model.
Definition: wrtsh.hxx:93
void goBack()
Definition: navmgr.cxx:101
const SwView & GetView() const
Definition: wrtsh.hxx:431
virtual void SetChanged(bool bFlg=true)
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
void goForward()
Definition: navmgr.cxx:147
bool backEnabled()
Definition: navmgr.cxx:83
void SetName(const OUString &rName)
void LeaveDrawCreate()
Definition: view.hxx:538
bool IsChanged() const
sal_uInt16 GetSlot() const
void DisableItem(sal_uInt16 nWhich)
virtual bool IsTextEdit() const final override
#define FN_NAVIGATION_BACK
Definition: cmdid.h:613
SwNavigationShell(SwView &rView)
Definition: navsh.cxx:26
void EndTextEdit()
Deletes object if required.
Definition: feshview.cxx:1308
SdrModel * GetModel() const
Definition: view.hxx:144