xref: /aoo4110/main/sc/source/ui/drawfunc/fumark.cxx (revision b1cdbd2c)
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 #include <sfx2/dispatch.hxx>
28 #include <sfx2/viewfrm.hxx>
29 
30 #include "fumark.hxx"
31 #include "sc.hrc"
32 #include "tabvwsh.hxx"
33 #include "scmod.hxx"
34 #include "reffact.hxx"
35 #include "document.hxx"
36 #include "scresid.hxx"
37 #include "drawview.hxx"
38 
39 //------------------------------------------------------------------
40 
41 /*************************************************************************
42 |*
43 |* Funktion zum Aufziehen eines Rechtecks
44 |*
45 \************************************************************************/
46 
FuMarkRect(ScTabViewShell * pViewSh,Window * pWin,ScDrawView * pViewP,SdrModel * pDoc,SfxRequest & rReq)47 FuMarkRect::FuMarkRect(ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pViewP,
48 			   SdrModel* pDoc, SfxRequest& rReq) :
49     FuPoor(pViewSh, pWin, pViewP, pDoc, rReq),
50 	bVisible(sal_False),
51 	bStartDrag(sal_False)
52 {
53 }
54 
55 /*************************************************************************
56 |*
57 |* Destruktor
58 |*
59 \************************************************************************/
60 
~FuMarkRect()61 FuMarkRect::~FuMarkRect()
62 {
63 }
64 
65 /*************************************************************************
66 |*
67 |* MouseButtonDown-event
68 |*
69 \************************************************************************/
70 
MouseButtonDown(const MouseEvent & rMEvt)71 sal_Bool FuMarkRect::MouseButtonDown(const MouseEvent& rMEvt)
72 {
73 	// #95491# remember button state for creation of own MouseEvents
74 	SetMouseButtonCode(rMEvt.GetButtons());
75 
76 	pWindow->CaptureMouse();
77 	pView->UnmarkAll();			// der Einheitlichkeit halber und wegen #50558#
78 	bStartDrag = sal_True;
79 
80 	aBeginPos = pWindow->PixelToLogic( rMEvt.GetPosPixel() );
81 	aZoomRect = Rectangle( aBeginPos, Size() );
82 	return sal_True;
83 }
84 
85 /*************************************************************************
86 |*
87 |* MouseMove-event
88 |*
89 \************************************************************************/
90 
MouseMove(const MouseEvent & rMEvt)91 sal_Bool FuMarkRect::MouseMove(const MouseEvent& rMEvt)
92 {
93 	if ( bStartDrag )
94 	{
95 		if ( bVisible )
96 			pViewShell->DrawMarkRect(aZoomRect);
97 		Point aPixPos= rMEvt.GetPosPixel();
98 		ForceScroll(aPixPos);
99 
100 		Point aEndPos = pWindow->PixelToLogic(aPixPos);
101 		Rectangle aRect(aBeginPos, aEndPos);
102 		aZoomRect = aRect;
103 		aZoomRect.Justify();
104 		pViewShell->DrawMarkRect(aZoomRect);
105 		bVisible = sal_True;
106 	}
107 
108 	ForcePointer(&rMEvt);
109 
110 	return bStartDrag;
111 }
112 
113 /*************************************************************************
114 |*
115 |* MouseButtonUp-event
116 |*
117 \************************************************************************/
118 
MouseButtonUp(const MouseEvent & rMEvt)119 sal_Bool FuMarkRect::MouseButtonUp(const MouseEvent& rMEvt)
120 {
121 	// #95491# remember button state for creation of own MouseEvents
122 	SetMouseButtonCode(rMEvt.GetButtons());
123 
124 	if ( bVisible )
125 	{
126 		// Hide ZoomRect
127 		pViewShell->DrawMarkRect(aZoomRect);
128 		bVisible = sal_False;
129 	}
130 
131 	Size aZoomSizePixel = pWindow->LogicToPixel(aZoomRect).GetSize();
132 
133 	sal_uInt16 nMinMove = pView->GetMinMoveDistancePixel();
134 	if ( aZoomSizePixel.Width() < nMinMove || aZoomSizePixel.Height() < nMinMove )
135 	{
136 		// Klick auf der Stelle
137 
138 		aZoomRect.SetSize(Size());		// dann ganz leer
139 	}
140 
141 	bStartDrag = sal_False;
142 	pWindow->ReleaseMouse();
143 
144 	pViewShell->GetViewData()->GetDispatcher().
145 		Execute(aSfxRequest.GetSlot(), SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD);
146 
147 		//	Daten an der View merken
148 
149 	pViewShell->SetChartArea( aSourceRange, aZoomRect );
150 
151 		//	Chart-Dialog starten:
152 
153 //	sal_uInt16 nId  = ScChartDlgWrapper::GetChildWindowId();
154 //	SfxChildWindow* pWnd = pViewShell->GetViewFrame()->GetChildWindow( nId );
155 //	SC_MOD()->SetRefDialog( nId, pWnd ? sal_False : sal_True );
156 
157 	return sal_True;
158 }
159 
160 /*************************************************************************
161 |*
162 |* Command-event
163 |*
164 \************************************************************************/
165 
Command(const CommandEvent & rCEvt)166 sal_uInt8 FuMarkRect::Command(const CommandEvent& rCEvt)
167 {
168 	if ( COMMAND_STARTDRAG == rCEvt.GetCommand() )
169 	{
170 		//	#29877# nicht anfangen, auf der Tabelle rumzudraggen,
171 		//	aber Maus-Status nicht zuruecksetzen
172 		return SC_CMD_IGNORE;
173 	}
174 	else
175 		return FuPoor::Command(rCEvt);
176 }
177 
178 /*************************************************************************
179 |*
180 |* Tastaturereignisse bearbeiten
181 |*
182 |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert sal_True, andernfalls
183 |* FALSE.
184 |*
185 \************************************************************************/
186 
KeyInput(const KeyEvent & rKEvt)187 sal_Bool FuMarkRect::KeyInput(const KeyEvent& rKEvt)
188 {
189 	sal_Bool bReturn = sal_False;
190 
191 	switch ( rKEvt.GetKeyCode().GetCode() )
192 	{
193 		case KEY_ESCAPE:
194 			//	beenden
195 			pViewShell->GetViewData()->GetDispatcher().
196 				Execute(aSfxRequest.GetSlot(), SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
197 			bReturn = sal_True;
198 			break;
199 	}
200 
201 	if (!bReturn)
202 	{
203 		bReturn = FuPoor::KeyInput(rKEvt);
204 	}
205 
206 	return (bReturn);
207 }
208 
209 /*************************************************************************
210 |*
211 |* Vor dem Scrollen Selektionsdarstellung ausblenden
212 |*
213 \************************************************************************/
214 
ScrollStart()215 void FuMarkRect::ScrollStart()
216 {
217 }
218 
219 /*************************************************************************
220 |*
221 |* Nach dem Scrollen Selektionsdarstellung wieder anzeigen
222 |*
223 \************************************************************************/
224 
ScrollEnd()225 void FuMarkRect::ScrollEnd()
226 {
227 }
228 
229 /*************************************************************************
230 |*
231 |* Function aktivieren
232 |*
233 \************************************************************************/
234 
Activate()235 void FuMarkRect::Activate()
236 {
237 	FuPoor::Activate();
238 
239 		//	Markierung merken, bevor evtl. Tabelle umgeschaltet wird
240 
241 	ScViewData* pViewData = pViewShell->GetViewData();
242 	ScMarkData& rMark = pViewData->GetMarkData();
243 
244 	if ( !rMark.IsMultiMarked() && !rMark.IsMarked() )
245 		pViewShell->MarkDataArea( sal_True );
246 
247 	pViewData->GetMultiArea( aSourceRange );		// Mehrfachselektion erlaubt
248 
249 //	pViewShell->Unmark();
250 
251 	ForcePointer(NULL);
252 }
253 
254 /*************************************************************************
255 |*
256 |* Function deaktivieren
257 |*
258 \************************************************************************/
259 
Deactivate()260 void FuMarkRect::Deactivate()
261 {
262 	FuPoor::Deactivate();
263 
264 	if (bVisible)
265 	{
266 		// Hide ZoomRect
267 		pViewShell->DrawMarkRect(aZoomRect);
268 		bVisible = sal_False;
269 		bStartDrag = sal_False;
270 	}
271 }
272 
273 /*************************************************************************
274 |*
275 |* Maus-Pointer umschalten
276 |*
277 \************************************************************************/
278 
ForcePointer(const MouseEvent *)279 void FuMarkRect::ForcePointer(const MouseEvent* /* pMEvt */)
280 {
281 	pViewShell->SetActivePointer( Pointer( POINTER_CHART ) );
282 }
283 
284 
285 
286 
287