1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_sc.hxx" 26 27 28 29 //------------------------------------------------------------------ 30 31 #include "scitems.hxx" 32 #include <svl/srchitem.hxx> 33 #include <sfx2/bindings.hxx> 34 #include <sfx2/objface.hxx> 35 #include <sfx2/objsh.hxx> 36 #include <sfx2/request.hxx> 37 38 #include "auditsh.hxx" 39 #include "tabvwsh.hxx" 40 #include "scresid.hxx" 41 #include "sc.hrc" 42 #include "document.hxx" 43 44 //------------------------------------------------------------------------ 45 46 #define ScAuditingShell 47 #include "scslots.hxx" 48 49 //------------------------------------------------------------------------ 50 51 TYPEINIT1( ScAuditingShell, SfxShell ); 52 53 SFX_IMPL_INTERFACE(ScAuditingShell, SfxShell, ScResId(SCSTR_AUDITSHELL)) 54 { 55 SFX_POPUPMENU_REGISTRATION( ScResId(RID_POPUP_AUDIT) ); 56 } 57 58 59 //------------------------------------------------------------------------ 60 61 ScAuditingShell::ScAuditingShell(ScViewData* pData) : 62 SfxShell(pData->GetViewShell()), 63 pViewData( pData ), 64 nFunction( SID_FILL_ADD_PRED ) 65 { 66 SetPool( &pViewData->GetViewShell()->GetPool() ); 67 ::svl::IUndoManager* pMgr = pViewData->GetSfxDocShell()->GetUndoManager(); 68 SetUndoManager( pMgr ); 69 if ( !pViewData->GetDocument()->IsUndoEnabled() ) 70 { 71 pMgr->SetMaxUndoActionCount( 0 ); 72 } 73 SetHelpId( HID_SCSHELL_AUDIT ); 74 SetName(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("Auditing"))); 75 } 76 77 //------------------------------------------------------------------------ 78 79 ScAuditingShell::~ScAuditingShell() 80 { 81 } 82 83 //------------------------------------------------------------------------ 84 85 void ScAuditingShell::Execute( SfxRequest& rReq ) 86 { 87 SfxBindings& rBindings = pViewData->GetBindings(); 88 sal_uInt16 nSlot = rReq.GetSlot(); 89 switch ( nSlot ) 90 { 91 case SID_FILL_ADD_PRED: 92 case SID_FILL_DEL_PRED: 93 case SID_FILL_ADD_SUCC: 94 case SID_FILL_DEL_SUCC: 95 nFunction = nSlot; 96 rBindings.Invalidate( SID_FILL_ADD_PRED ); 97 rBindings.Invalidate( SID_FILL_DEL_PRED ); 98 rBindings.Invalidate( SID_FILL_ADD_SUCC ); 99 rBindings.Invalidate( SID_FILL_DEL_SUCC ); 100 break; 101 case SID_CANCEL: // Escape 102 case SID_FILL_NONE: 103 pViewData->GetViewShell()->SetAuditShell( sal_False ); 104 break; 105 106 case SID_FILL_SELECT: 107 { 108 const SfxItemSet* pReqArgs = rReq.GetArgs(); 109 if ( pReqArgs ) 110 { 111 const SfxPoolItem* pXItem; 112 const SfxPoolItem* pYItem; 113 if ( pReqArgs->GetItemState( SID_RANGE_COL, sal_True, &pXItem ) == SFX_ITEM_SET 114 && pReqArgs->GetItemState( SID_RANGE_ROW, sal_True, &pYItem ) == SFX_ITEM_SET ) 115 { 116 DBG_ASSERT( pXItem->ISA(SfxInt16Item) && pYItem->ISA(SfxInt32Item), 117 "falsche Items" ); 118 SCsCOL nCol = static_cast<SCsCOL>(((const SfxInt16Item*) pXItem)->GetValue()); 119 SCsROW nRow = static_cast<SCsROW>(((const SfxInt32Item*) pYItem)->GetValue()); 120 ScViewFunc* pView = pViewData->GetView(); 121 pView->MoveCursorAbs( nCol, nRow, SC_FOLLOW_LINE, sal_False, sal_False ); 122 switch ( nFunction ) 123 { 124 case SID_FILL_ADD_PRED: 125 pView->DetectiveAddPred(); 126 break; 127 case SID_FILL_DEL_PRED: 128 pView->DetectiveDelPred(); 129 break; 130 case SID_FILL_ADD_SUCC: 131 pView->DetectiveAddSucc(); 132 break; 133 case SID_FILL_DEL_SUCC: 134 pView->DetectiveDelSucc(); 135 break; 136 } 137 } 138 } 139 } 140 break; 141 } 142 } 143 144 //------------------------------------------------------------------------ 145 146 void ScAuditingShell::GetState( SfxItemSet& rSet ) 147 { 148 rSet.Put( SfxBoolItem( nFunction, sal_True ) ); // aktive Funktion markieren 149 } 150 151 152