xref: /aoo41x/main/sc/source/ui/view/auditsh.cxx (revision f120fe41)
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 #include <sfx2/sidebar/EnumContext.hxx>
38 
39 #include "auditsh.hxx"
40 #include "tabvwsh.hxx"
41 #include "scresid.hxx"
42 #include "sc.hrc"
43 #include "document.hxx"
44 
45 //------------------------------------------------------------------------
46 
47 #define ScAuditingShell
48 #include "scslots.hxx"
49 
50 //------------------------------------------------------------------------
51 
52 TYPEINIT1( ScAuditingShell, SfxShell );
53 
SFX_IMPL_INTERFACE(ScAuditingShell,SfxShell,ScResId (SCSTR_AUDITSHELL))54 SFX_IMPL_INTERFACE(ScAuditingShell, SfxShell, ScResId(SCSTR_AUDITSHELL))
55 {
56 	SFX_POPUPMENU_REGISTRATION( ScResId(RID_POPUP_AUDIT) );
57 }
58 
59 
60 //------------------------------------------------------------------------
61 
ScAuditingShell(ScViewData * pData)62 ScAuditingShell::ScAuditingShell(ScViewData* pData) :
63 	SfxShell(pData->GetViewShell()),
64 	pViewData( pData ),
65 	nFunction( SID_FILL_ADD_PRED )
66 {
67 	SetPool( &pViewData->GetViewShell()->GetPool() );
68     ::svl::IUndoManager* pMgr = pViewData->GetSfxDocShell()->GetUndoManager();
69     SetUndoManager( pMgr );
70     if ( !pViewData->GetDocument()->IsUndoEnabled() )
71     {
72         pMgr->SetMaxUndoActionCount( 0 );
73     }
74 	SetHelpId( HID_SCSHELL_AUDIT );
75 	SetName(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("Auditing")));
76     SfxShell::SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_Auditing));
77 }
78 
79 //------------------------------------------------------------------------
80 
~ScAuditingShell()81 ScAuditingShell::~ScAuditingShell()
82 {
83 }
84 
85 //------------------------------------------------------------------------
86 
Execute(SfxRequest & rReq)87 void ScAuditingShell::Execute( SfxRequest& rReq )
88 {
89 	SfxBindings& rBindings = pViewData->GetBindings();
90 	sal_uInt16 nSlot = rReq.GetSlot();
91 	switch ( nSlot )
92 	{
93 		case SID_FILL_ADD_PRED:
94 		case SID_FILL_DEL_PRED:
95 		case SID_FILL_ADD_SUCC:
96 		case SID_FILL_DEL_SUCC:
97 			nFunction = nSlot;
98 			rBindings.Invalidate( SID_FILL_ADD_PRED );
99 			rBindings.Invalidate( SID_FILL_DEL_PRED );
100 			rBindings.Invalidate( SID_FILL_ADD_SUCC );
101 			rBindings.Invalidate( SID_FILL_DEL_SUCC );
102 			break;
103 		case SID_CANCEL:		// Escape
104 		case SID_FILL_NONE:
105 			pViewData->GetViewShell()->SetAuditShell( sal_False );
106 			break;
107 
108 		case SID_FILL_SELECT:
109 			{
110 				const SfxItemSet* pReqArgs = rReq.GetArgs();
111 				if ( pReqArgs )
112 				{
113 					const SfxPoolItem* pXItem;
114 					const SfxPoolItem* pYItem;
115 					if ( pReqArgs->GetItemState( SID_RANGE_COL, sal_True, &pXItem ) == SFX_ITEM_SET
116 					  && pReqArgs->GetItemState( SID_RANGE_ROW, sal_True, &pYItem ) == SFX_ITEM_SET )
117 					{
118 						DBG_ASSERT( pXItem->ISA(SfxInt16Item) && pYItem->ISA(SfxInt32Item),
119 										"falsche Items" );
120 						SCsCOL nCol = static_cast<SCsCOL>(((const SfxInt16Item*) pXItem)->GetValue());
121 						SCsROW nRow = static_cast<SCsROW>(((const SfxInt32Item*) pYItem)->GetValue());
122 						ScViewFunc* pView = pViewData->GetView();
123 						pView->MoveCursorAbs( nCol, nRow, SC_FOLLOW_LINE, sal_False, sal_False );
124 						switch ( nFunction )
125 						{
126 							case SID_FILL_ADD_PRED:
127 								pView->DetectiveAddPred();
128 								break;
129 							case SID_FILL_DEL_PRED:
130 								pView->DetectiveDelPred();
131 								break;
132 							case SID_FILL_ADD_SUCC:
133 								pView->DetectiveAddSucc();
134 								break;
135 							case SID_FILL_DEL_SUCC:
136 								pView->DetectiveDelSucc();
137 								break;
138 						}
139 					}
140 				}
141 			}
142 			break;
143 	}
144 }
145 
146 //------------------------------------------------------------------------
147 
GetState(SfxItemSet & rSet)148 void ScAuditingShell::GetState( SfxItemSet& rSet )
149 {
150 	rSet.Put( SfxBoolItem( nFunction, sal_True ) );			// aktive Funktion markieren
151 }
152