LibreOffice Module sc (master)  1
auditsh.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  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <sfx2/bindings.hxx>
21 #include <sfx2/objface.hxx>
22 #include <sfx2/objsh.hxx>
23 #include <sfx2/request.hxx>
24 #include <vcl/EnumContext.hxx>
25 
26 #include <auditsh.hxx>
27 #include <tabvwsh.hxx>
28 #include <sc.hrc>
29 #include <document.hxx>
30 
31 #define ShellClass_ScAuditingShell
32 #include <scslots.hxx>
33 
34 
36 
37 void ScAuditingShell::InitInterface_Impl()
38 {
39  GetStaticInterface()->RegisterPopupMenu("audit");
40 }
41 
43  SfxShell(rData.GetViewShell()),
44  rViewData( rData ),
45  nFunction( SID_FILL_ADD_PRED )
46 {
49  SetUndoManager( pMgr );
51  {
52  pMgr->SetMaxUndoActionCount( 0 );
53  }
54  SetName("Auditing");
56 }
57 
59 {
60 }
61 
63 {
64  SfxBindings& rBindings = rViewData.GetBindings();
65  sal_uInt16 nSlot = rReq.GetSlot();
66  switch ( nSlot )
67  {
68  case SID_FILL_ADD_PRED:
69  case SID_FILL_DEL_PRED:
70  case SID_FILL_ADD_SUCC:
71  case SID_FILL_DEL_SUCC:
72  nFunction = nSlot;
73  rBindings.Invalidate( SID_FILL_ADD_PRED );
74  rBindings.Invalidate( SID_FILL_DEL_PRED );
75  rBindings.Invalidate( SID_FILL_ADD_SUCC );
76  rBindings.Invalidate( SID_FILL_DEL_SUCC );
77  break;
78  case SID_CANCEL: // Escape
79  case SID_FILL_NONE:
81  break;
82 
83  case SID_FILL_SELECT:
84  {
85  const SfxItemSet* pReqArgs = rReq.GetArgs();
86  if ( pReqArgs )
87  {
88  const SfxPoolItem* pXItem;
89  const SfxPoolItem* pYItem;
90  if ( pReqArgs->GetItemState( SID_RANGE_COL, true, &pXItem ) == SfxItemState::SET
91  && pReqArgs->GetItemState( SID_RANGE_ROW, true, &pYItem ) == SfxItemState::SET )
92  {
93  OSL_ENSURE( dynamic_cast<const SfxInt16Item*>( pXItem) != nullptr && dynamic_cast<const SfxInt32Item*>( pYItem) != nullptr,
94  "wrong items" );
95  SCCOL nCol = static_cast<SCCOL>(static_cast<const SfxInt16Item*>(pXItem)->GetValue());
96  SCROW nRow = static_cast<SCROW>(static_cast<const SfxInt32Item*>(pYItem)->GetValue());
97  ScViewFunc* pView = rViewData.GetView();
98  pView->MoveCursorAbs( nCol, nRow, SC_FOLLOW_LINE, false, false );
99  switch ( nFunction )
100  {
101  case SID_FILL_ADD_PRED:
102  pView->DetectiveAddPred();
103  break;
104  case SID_FILL_DEL_PRED:
105  pView->DetectiveDelPred();
106  break;
107  case SID_FILL_ADD_SUCC:
108  pView->DetectiveAddSucc();
109  break;
110  case SID_FILL_DEL_SUCC:
111  pView->DetectiveDelSucc();
112  break;
113  }
114  }
115  }
116  }
117  break;
118  }
119 }
120 
122 {
123  rSet.Put( SfxBoolItem( nFunction, true ) ); // mark active functions
124 }
125 
126 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define SFX_IMPL_INTERFACE(Class, SuperClass)
std::string GetValue
void GetState(SfxItemSet &rSet)
Definition: auditsh.cxx:121
void SetAuditShell(bool bActive)
Definition: tabvwsh4.cxx:678
ScDocument & GetDocument() const
Definition: viewdata.hxx:380
virtual SfxUndoManager * GetUndoManager()
const SfxItemSet * GetArgs() const
void Invalidate(sal_uInt16 nId)
SC_DLLPUBLIC void MoveCursorAbs(SCCOL nCurX, SCROW nCurY, ScFollowMode eMode, bool bShift, bool bControl, bool bKeepOld=false, bool bKeepSel=false)
Definition: tabview3.cxx:1185
void Execute(const SfxRequest &rReq)
Definition: auditsh.cxx:62
void DetectiveDelSucc()
Definition: viewfun6.cxx:90
void SetUndoManager(SfxUndoManager *pNewUndoMgr)
SfxItemPool & GetPool() const
ScTabViewShell * GetViewShell() const
Definition: viewdata.hxx:357
ScAuditingShell(ScViewData &rData)
Definition: auditsh.cxx:42
void DetectiveAddPred()
Definition: viewfun6.cxx:69
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
SfxBindings & GetBindings()
Definition: viewdata.cxx:3034
sal_Int16 SCCOL
Definition: types.hxx:22
void DetectiveAddSucc()
Definition: viewfun6.cxx:83
void SetPool(SfxItemPool *pNewPool)
void SetName(const OUString &rName)
void DetectiveDelPred()
Definition: viewfun6.cxx:76
ScDBFunc * GetView() const
Definition: viewdata.cxx:852
sal_uInt16 nFunction
Definition: auditsh.hxx:33
ScViewData & rViewData
Definition: auditsh.hxx:32
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
sal_Int32 SCROW
Definition: types.hxx:18
sal_uInt16 GetSlot() const
static const OUString & GetContextName(const Context eContext)
virtual ~ScAuditingShell() override
Definition: auditsh.cxx:58
SfxObjectShell * GetSfxDocShell() const
Definition: viewdata.hxx:358
bool IsUndoEnabled() const
Definition: document.hxx:1531
void SetContextName(const OUString &rsContextName)
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo