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 #include <osl/diagnose.h>
26 
27 #include <auditsh.hxx>
28 #include <tabvwsh.hxx>
29 #include <sc.hrc>
30 #include <document.hxx>
31 
32 #define ShellClass_ScAuditingShell
33 #include <scslots.hxx>
34 
35 
37 
38 void ScAuditingShell::InitInterface_Impl()
39 {
40  GetStaticInterface()->RegisterPopupMenu("audit");
41 }
42 
44  SfxShell(rData.GetViewShell()),
45  rViewData( rData ),
46  nFunction( SID_FILL_ADD_PRED )
47 {
50  SetUndoManager( pMgr );
52  {
53  pMgr->SetMaxUndoActionCount( 0 );
54  }
55  SetName("Auditing");
57 }
58 
60 {
61 }
62 
64 {
65  SfxBindings& rBindings = rViewData.GetBindings();
66  sal_uInt16 nSlot = rReq.GetSlot();
67  switch ( nSlot )
68  {
69  case SID_FILL_ADD_PRED:
70  case SID_FILL_DEL_PRED:
71  case SID_FILL_ADD_SUCC:
72  case SID_FILL_DEL_SUCC:
73  nFunction = nSlot;
74  rBindings.Invalidate( SID_FILL_ADD_PRED );
75  rBindings.Invalidate( SID_FILL_DEL_PRED );
76  rBindings.Invalidate( SID_FILL_ADD_SUCC );
77  rBindings.Invalidate( SID_FILL_DEL_SUCC );
78  break;
79  case SID_CANCEL: // Escape
80  case SID_FILL_NONE:
82  break;
83 
84  case SID_FILL_SELECT:
85  {
86  const SfxItemSet* pReqArgs = rReq.GetArgs();
87  if ( pReqArgs )
88  {
89  const SfxPoolItem* pXItem;
90  const SfxPoolItem* pYItem;
91  if ( pReqArgs->GetItemState( SID_RANGE_COL, true, &pXItem ) == SfxItemState::SET
92  && pReqArgs->GetItemState( SID_RANGE_ROW, true, &pYItem ) == SfxItemState::SET )
93  {
94  assert( dynamic_cast<const SfxInt16Item*>( pXItem) && dynamic_cast<const SfxInt32Item*>( pYItem) &&
95  "wrong items" );
96  SCCOL nCol = static_cast<SCCOL>(static_cast<const SfxInt16Item*>(pXItem)->GetValue());
97  SCROW nRow = static_cast<SCROW>(static_cast<const SfxInt32Item*>(pYItem)->GetValue());
98  ScViewFunc* pView = rViewData.GetView();
99  pView->MoveCursorAbs( nCol, nRow, SC_FOLLOW_LINE, false, false );
100  switch ( nFunction )
101  {
102  case SID_FILL_ADD_PRED:
103  pView->DetectiveAddPred();
104  break;
105  case SID_FILL_DEL_PRED:
106  pView->DetectiveDelPred();
107  break;
108  case SID_FILL_ADD_SUCC:
109  pView->DetectiveAddSucc();
110  break;
111  case SID_FILL_DEL_SUCC:
112  pView->DetectiveDelSucc();
113  break;
114  }
115  }
116  }
117  }
118  break;
119  }
120 }
121 
123 {
124  rSet.Put( SfxBoolItem( nFunction, true ) ); // mark active functions
125 }
126 
127 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define SFX_IMPL_INTERFACE(Class, SuperClass)
std::string GetValue
void GetState(SfxItemSet &rSet)
Definition: auditsh.cxx:122
void SetAuditShell(bool bActive)
Definition: tabvwsh4.cxx:693
ScDocument & GetDocument() const
Definition: viewdata.hxx:379
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:1190
void Execute(const SfxRequest &rReq)
Definition: auditsh.cxx:63
void DetectiveDelSucc()
Definition: viewfun6.cxx:91
void SetUndoManager(SfxUndoManager *pNewUndoMgr)
SfxItemPool & GetPool() const
ScTabViewShell * GetViewShell() const
Definition: viewdata.hxx:356
ScAuditingShell(ScViewData &rData)
Definition: auditsh.cxx:43
void DetectiveAddPred()
Definition: viewfun6.cxx:70
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
SfxBindings & GetBindings()
Definition: viewdata.cxx:3096
sal_Int16 SCCOL
Definition: types.hxx:21
void DetectiveAddSucc()
Definition: viewfun6.cxx:84
void SetPool(SfxItemPool *pNewPool)
void SetName(const OUString &rName)
void DetectiveDelPred()
Definition: viewfun6.cxx:77
ScDBFunc * GetView() const
Definition: viewdata.cxx:861
sal_uInt16 nFunction
Definition: auditsh.hxx:32
ScViewData & rViewData
Definition: auditsh.hxx:31
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
sal_Int32 SCROW
Definition: types.hxx:17
sal_uInt16 GetSlot() const
static const OUString & GetContextName(const Context eContext)
virtual ~ScAuditingShell() override
Definition: auditsh.cxx:59
SfxObjectShell * GetSfxDocShell() const
Definition: viewdata.hxx:357
bool IsUndoEnabled() const
Definition: document.hxx:1535
void SetContextName(const OUString &rsContextName)
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo