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