Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / sc / source / ui / view / auditsh.cxx
blobbba0b46db4994e5afb57e912c9b44b482454236d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "scitems.hxx"
21 #include <svl/srchitem.hxx>
22 #include <sfx2/bindings.hxx>
23 #include <sfx2/objface.hxx>
24 #include <sfx2/objsh.hxx>
25 #include <sfx2/request.hxx>
26 #include <sfx2/sidebar/EnumContext.hxx>
28 #include "auditsh.hxx"
29 #include "tabvwsh.hxx"
30 #include "scresid.hxx"
31 #include "sc.hrc"
32 #include "document.hxx"
34 #define ScAuditingShell
35 #include "scslots.hxx"
38 SFX_IMPL_INTERFACE(ScAuditingShell, SfxShell)
40 void ScAuditingShell::InitInterface_Impl()
42 GetStaticInterface()->RegisterPopupMenu("audit");
45 ScAuditingShell::ScAuditingShell(ScViewData* pData) :
46 SfxShell(pData->GetViewShell()),
47 pViewData( pData ),
48 nFunction( SID_FILL_ADD_PRED )
50 SetPool( &pViewData->GetViewShell()->GetPool() );
51 ::svl::IUndoManager* pMgr = pViewData->GetSfxDocShell()->GetUndoManager();
52 SetUndoManager( pMgr );
53 if ( !pViewData->GetDocument()->IsUndoEnabled() )
55 pMgr->SetMaxUndoActionCount( 0 );
57 SetHelpId( HID_SCSHELL_AUDIT );
58 SetName("Auditing");
59 SfxShell::SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_Auditing));
62 ScAuditingShell::~ScAuditingShell()
66 void ScAuditingShell::Execute( SfxRequest& rReq )
68 SfxBindings& rBindings = pViewData->GetBindings();
69 sal_uInt16 nSlot = rReq.GetSlot();
70 switch ( nSlot )
72 case SID_FILL_ADD_PRED:
73 case SID_FILL_DEL_PRED:
74 case SID_FILL_ADD_SUCC:
75 case SID_FILL_DEL_SUCC:
76 nFunction = nSlot;
77 rBindings.Invalidate( SID_FILL_ADD_PRED );
78 rBindings.Invalidate( SID_FILL_DEL_PRED );
79 rBindings.Invalidate( SID_FILL_ADD_SUCC );
80 rBindings.Invalidate( SID_FILL_DEL_SUCC );
81 break;
82 case SID_CANCEL: // Escape
83 case SID_FILL_NONE:
84 pViewData->GetViewShell()->SetAuditShell( false );
85 break;
87 case SID_FILL_SELECT:
89 const SfxItemSet* pReqArgs = rReq.GetArgs();
90 if ( pReqArgs )
92 const SfxPoolItem* pXItem;
93 const SfxPoolItem* pYItem;
94 if ( pReqArgs->GetItemState( SID_RANGE_COL, true, &pXItem ) == SfxItemState::SET
95 && pReqArgs->GetItemState( SID_RANGE_ROW, true, &pYItem ) == SfxItemState::SET )
97 OSL_ENSURE( dynamic_cast<const SfxInt16Item*>( pXItem) != nullptr && dynamic_cast<const SfxInt32Item*>( pYItem) != nullptr,
98 "wrong items" );
99 SCsCOL nCol = static_cast<SCsCOL>(static_cast<const SfxInt16Item*>(pXItem)->GetValue());
100 SCsROW nRow = static_cast<SCsROW>(static_cast<const SfxInt32Item*>(pYItem)->GetValue());
101 ScViewFunc* pView = pViewData->GetView();
102 pView->MoveCursorAbs( nCol, nRow, SC_FOLLOW_LINE, false, false );
103 switch ( nFunction )
105 case SID_FILL_ADD_PRED:
106 pView->DetectiveAddPred();
107 break;
108 case SID_FILL_DEL_PRED:
109 pView->DetectiveDelPred();
110 break;
111 case SID_FILL_ADD_SUCC:
112 pView->DetectiveAddSucc();
113 break;
114 case SID_FILL_DEL_SUCC:
115 pView->DetectiveDelSucc();
116 break;
121 break;
125 void ScAuditingShell::GetState( SfxItemSet& rSet )
127 rSet.Put( SfxBoolItem( nFunction, true ) ); // mark active functions
130 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */