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
24void 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 {
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 {
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: */
virtual void SetChanged(bool bFlg=true)
bool IsChanged() const
virtual bool IsTextEdit() const final override
SdrModel & GetModel() const
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
void DisableItem(sal_uInt16 nWhich)
sal_uInt16 GetSlot() const
const SfxItemSet * GetArgs() const
void SetName(const OUString &rName)
sal_uInt16 FirstWhich()
sal_uInt16 NextWhich()
SwWrtShell & GetShell()
Definition: basesh.cxx:3001
void SetModified()
Definition: edws.cxx:70
void EndTextEdit()
Deletes object if required.
Definition: feshview.cxx:1193
void goBack()
Definition: navmgr.cxx:98
bool backEnabled()
Definition: navmgr.cxx:80
bool forwardEnabled()
Definition: navmgr.cxx:90
void goForward()
Definition: navmgr.cxx:144
void GetState(SfxItemSet &)
Definition: navsh.cxx:71
void Execute(SfxRequest const &)
Definition: navsh.cxx:32
SwNavigationShell(SwView &rView)
Definition: navsh.cxx:26
SdrView * GetDrawView()
Definition: vnew.cxx:386
Definition: view.hxx:146
bool IsDrawMode() const
Definition: view.hxx:550
void LeaveDrawCreate()
Definition: view.hxx:549
Used by the UI to modify the document model.
Definition: wrtsh.hxx:97
void EnterStdMode()
Definition: select.cxx:560
SwNavigationMgr & GetNavigationMgr()
Definition: wrtsh.hxx:485
const SwView & GetView() const
Definition: wrtsh.hxx:443
#define FN_NAVIGATION_FORWARD
Definition: cmdid.h:650
#define FN_NAVIGATION_BACK
Definition: cmdid.h:649
static SfxItemSet & rSet
#define SFX_IMPL_INTERFACE(Class, SuperClass)