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