xref: /aoo41x/main/sc/source/ui/view/auditsh.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sc.hxx"
30 
31 
32 
33 //------------------------------------------------------------------
34 
35 #include "scitems.hxx"
36 #include <svl/srchitem.hxx>
37 #include <sfx2/bindings.hxx>
38 #include <sfx2/objface.hxx>
39 #include <sfx2/objsh.hxx>
40 #include <sfx2/request.hxx>
41 
42 #include "auditsh.hxx"
43 #include "tabvwsh.hxx"
44 #include "scresid.hxx"
45 #include "sc.hrc"
46 #include "document.hxx"
47 
48 //------------------------------------------------------------------------
49 
50 #define ScAuditingShell
51 #include "scslots.hxx"
52 
53 //------------------------------------------------------------------------
54 
55 TYPEINIT1( ScAuditingShell, SfxShell );
56 
57 SFX_IMPL_INTERFACE(ScAuditingShell, SfxShell, ScResId(SCSTR_AUDITSHELL))
58 {
59 	SFX_POPUPMENU_REGISTRATION( ScResId(RID_POPUP_AUDIT) );
60 }
61 
62 
63 //------------------------------------------------------------------------
64 
65 ScAuditingShell::ScAuditingShell(ScViewData* pData) :
66 	SfxShell(pData->GetViewShell()),
67 	pViewData( pData ),
68 	nFunction( SID_FILL_ADD_PRED )
69 {
70 	SetPool( &pViewData->GetViewShell()->GetPool() );
71     ::svl::IUndoManager* pMgr = pViewData->GetSfxDocShell()->GetUndoManager();
72     SetUndoManager( pMgr );
73     if ( !pViewData->GetDocument()->IsUndoEnabled() )
74     {
75         pMgr->SetMaxUndoActionCount( 0 );
76     }
77 	SetHelpId( HID_SCSHELL_AUDIT );
78 	SetName(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("Auditing")));
79 }
80 
81 //------------------------------------------------------------------------
82 
83 ScAuditingShell::~ScAuditingShell()
84 {
85 }
86 
87 //------------------------------------------------------------------------
88 
89 void ScAuditingShell::Execute( SfxRequest& rReq )
90 {
91 	SfxBindings& rBindings = pViewData->GetBindings();
92 	sal_uInt16 nSlot = rReq.GetSlot();
93 	switch ( nSlot )
94 	{
95 		case SID_FILL_ADD_PRED:
96 		case SID_FILL_DEL_PRED:
97 		case SID_FILL_ADD_SUCC:
98 		case SID_FILL_DEL_SUCC:
99 			nFunction = nSlot;
100 			rBindings.Invalidate( SID_FILL_ADD_PRED );
101 			rBindings.Invalidate( SID_FILL_DEL_PRED );
102 			rBindings.Invalidate( SID_FILL_ADD_SUCC );
103 			rBindings.Invalidate( SID_FILL_DEL_SUCC );
104 			break;
105 		case SID_CANCEL:		// Escape
106 		case SID_FILL_NONE:
107 			pViewData->GetViewShell()->SetAuditShell( sal_False );
108 			break;
109 
110 		case SID_FILL_SELECT:
111 			{
112 				const SfxItemSet* pReqArgs = rReq.GetArgs();
113 				if ( pReqArgs )
114 				{
115 					const SfxPoolItem* pXItem;
116 					const SfxPoolItem* pYItem;
117 					if ( pReqArgs->GetItemState( SID_RANGE_COL, sal_True, &pXItem ) == SFX_ITEM_SET
118 					  && pReqArgs->GetItemState( SID_RANGE_ROW, sal_True, &pYItem ) == SFX_ITEM_SET )
119 					{
120 						DBG_ASSERT( pXItem->ISA(SfxInt16Item) && pYItem->ISA(SfxInt32Item),
121 										"falsche Items" );
122 						SCsCOL nCol = static_cast<SCsCOL>(((const SfxInt16Item*) pXItem)->GetValue());
123 						SCsROW nRow = static_cast<SCsROW>(((const SfxInt32Item*) pYItem)->GetValue());
124 						ScViewFunc* pView = pViewData->GetView();
125 						pView->MoveCursorAbs( nCol, nRow, SC_FOLLOW_LINE, sal_False, sal_False );
126 						switch ( nFunction )
127 						{
128 							case SID_FILL_ADD_PRED:
129 								pView->DetectiveAddPred();
130 								break;
131 							case SID_FILL_DEL_PRED:
132 								pView->DetectiveDelPred();
133 								break;
134 							case SID_FILL_ADD_SUCC:
135 								pView->DetectiveAddSucc();
136 								break;
137 							case SID_FILL_DEL_SUCC:
138 								pView->DetectiveDelSucc();
139 								break;
140 						}
141 					}
142 				}
143 			}
144 			break;
145 	}
146 }
147 
148 //------------------------------------------------------------------------
149 
150 void ScAuditingShell::GetState( SfxItemSet& rSet )
151 {
152 	rSet.Put( SfxBoolItem( nFunction, sal_True ) );			// aktive Funktion markieren
153 }
154 
155 
156