xref: /aoo41x/main/sc/source/ui/drawfunc/fudraw.cxx (revision 4d7c9de0)
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 #include <editeng/editeng.hxx>	// EditEngine::IsSimpleCharInput
30cdf0e10cSrcweir #include <editeng/outlobj.hxx>
31cdf0e10cSrcweir #include <svx/svdobj.hxx>
32cdf0e10cSrcweir #include <svx/svdoole2.hxx>
33cdf0e10cSrcweir #include <svx/svdouno.hxx>
34cdf0e10cSrcweir #include <svx/svdocapt.hxx>
35cdf0e10cSrcweir #include <svx/svdpage.hxx>
36cdf0e10cSrcweir #include <svx/svditer.hxx>
37cdf0e10cSrcweir #include <svx/svdundo.hxx>
38cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
39cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
40cdf0e10cSrcweir 
41cdf0e10cSrcweir #include "sc.hrc"
42cdf0e10cSrcweir #include "fudraw.hxx"
43cdf0e10cSrcweir #include "futext.hxx"
44cdf0e10cSrcweir #include "tabvwsh.hxx"
45cdf0e10cSrcweir #include "drwlayer.hxx"
46cdf0e10cSrcweir #include "scresid.hxx"
47cdf0e10cSrcweir #include "userdat.hxx"
48cdf0e10cSrcweir #include "docsh.hxx"
49cdf0e10cSrcweir #include "postit.hxx"
50cdf0e10cSrcweir #include "globstr.hrc"
51cdf0e10cSrcweir #include "drawview.hxx"
52cdf0e10cSrcweir 
53cdf0e10cSrcweir /*************************************************************************
54cdf0e10cSrcweir |*
55cdf0e10cSrcweir |* Basisklasse fuer alle Drawmodul-spezifischen Funktionen
56cdf0e10cSrcweir |*
57cdf0e10cSrcweir \************************************************************************/
58cdf0e10cSrcweir 
FuDraw(ScTabViewShell * pViewSh,Window * pWin,ScDrawView * pViewP,SdrModel * pDoc,SfxRequest & rReq)59cdf0e10cSrcweir FuDraw::FuDraw(ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pViewP,
60cdf0e10cSrcweir 			   SdrModel* pDoc, SfxRequest& rReq) :
61cdf0e10cSrcweir     FuPoor      (pViewSh, pWin, pViewP, pDoc, rReq),
62cdf0e10cSrcweir 	aNewPointer ( POINTER_ARROW ),
63cdf0e10cSrcweir 	aOldPointer ( POINTER_ARROW )
64cdf0e10cSrcweir {
65cdf0e10cSrcweir }
66cdf0e10cSrcweir 
67cdf0e10cSrcweir /*************************************************************************
68cdf0e10cSrcweir |*
69cdf0e10cSrcweir |* Destruktor
70cdf0e10cSrcweir |*
71cdf0e10cSrcweir \************************************************************************/
72cdf0e10cSrcweir 
~FuDraw()73cdf0e10cSrcweir FuDraw::~FuDraw()
74cdf0e10cSrcweir {
75cdf0e10cSrcweir }
76cdf0e10cSrcweir 
77cdf0e10cSrcweir /*************************************************************************
78cdf0e10cSrcweir |*
79cdf0e10cSrcweir |* Modifier-Tasten auswerten
80cdf0e10cSrcweir |*
81cdf0e10cSrcweir \************************************************************************/
82cdf0e10cSrcweir 
DoModifiers(const MouseEvent & rMEvt)83cdf0e10cSrcweir void FuDraw::DoModifiers(const MouseEvent& rMEvt)
84cdf0e10cSrcweir {
85cdf0e10cSrcweir 	//	Shift	= Ortho und AngleSnap
86cdf0e10cSrcweir 	//	Control	= Snap (Toggle)
87cdf0e10cSrcweir 	//	Alt		= zentrisch
88cdf0e10cSrcweir 
89cdf0e10cSrcweir 	sal_Bool bShift	= rMEvt.IsShift();
90cdf0e10cSrcweir //    sal_Bool bCtrl  = rMEvt.IsMod1();
91cdf0e10cSrcweir 	sal_Bool bAlt	= rMEvt.IsMod2();
92cdf0e10cSrcweir 
93cdf0e10cSrcweir //    ScViewData* pViewData = pViewShell->GetViewData();
94cdf0e10cSrcweir //    const ScViewOptions& rOpt = pViewData->GetOptions();
95cdf0e10cSrcweir //    const ScGridOptions& rGrid = rOpt.GetGridOptions();
96cdf0e10cSrcweir //    sal_Bool bGridOpt = rGrid.GetUseGridSnap();
97cdf0e10cSrcweir 
98cdf0e10cSrcweir 	sal_Bool bOrtho		= bShift;
99cdf0e10cSrcweir 	sal_Bool bAngleSnap	= bShift;
100cdf0e10cSrcweir //    sal_Bool bGridSnap  = ( bGridOpt != bCtrl );        // andere Snap's nicht unterstuetzt
101cdf0e10cSrcweir 	sal_Bool bCenter	= bAlt;
102cdf0e10cSrcweir 
103cdf0e10cSrcweir 	// #i33136#
104cdf0e10cSrcweir 	if(doConstructOrthogonal())
105cdf0e10cSrcweir 	{
106cdf0e10cSrcweir 		bOrtho = !bShift;
107cdf0e10cSrcweir 	}
108cdf0e10cSrcweir 
109cdf0e10cSrcweir 	if (pView->IsOrtho() != bOrtho)
110cdf0e10cSrcweir 		pView->SetOrtho(bOrtho);
111cdf0e10cSrcweir 	if (pView->IsAngleSnapEnabled() != bAngleSnap)
112cdf0e10cSrcweir 		pView->SetAngleSnapEnabled(bAngleSnap);
113cdf0e10cSrcweir 
114cdf0e10cSrcweir /*	Control fuer Snap beisst sich beim Verschieben mit "kopieren" !!!
115cdf0e10cSrcweir 
116cdf0e10cSrcweir 	if (pView->IsGridSnap() != bGridSnap)
117cdf0e10cSrcweir 		pView->SetGridSnap(bGridSnap);
118cdf0e10cSrcweir 	if (pView->IsSnapEnabled() != bGridSnap)
119cdf0e10cSrcweir 		pView->SetSnapEnabled(bGridSnap);
120cdf0e10cSrcweir */
121cdf0e10cSrcweir 	if (pView->IsCreate1stPointAsCenter() != bCenter)
122cdf0e10cSrcweir 		pView->SetCreate1stPointAsCenter(bCenter);
123cdf0e10cSrcweir 	if (pView->IsResizeAtCenter() != bCenter)
124cdf0e10cSrcweir 		pView->SetResizeAtCenter(bCenter);
125cdf0e10cSrcweir 
126cdf0e10cSrcweir }
127cdf0e10cSrcweir 
ResetModifiers()128cdf0e10cSrcweir void FuDraw::ResetModifiers()
129cdf0e10cSrcweir {
130cdf0e10cSrcweir 	ScViewData* pViewData = pViewShell->GetViewData();
131cdf0e10cSrcweir 	const ScViewOptions& rOpt = pViewData->GetOptions();
132cdf0e10cSrcweir 	const ScGridOptions& rGrid = rOpt.GetGridOptions();
133cdf0e10cSrcweir 	sal_Bool bGridOpt = rGrid.GetUseGridSnap();
134cdf0e10cSrcweir 
135cdf0e10cSrcweir 	if (pView->IsOrtho())
136cdf0e10cSrcweir 		pView->SetOrtho(sal_False);
137cdf0e10cSrcweir 	if (pView->IsAngleSnapEnabled())
138cdf0e10cSrcweir 		pView->SetAngleSnapEnabled(sal_False);
139cdf0e10cSrcweir 
140cdf0e10cSrcweir 	if (pView->IsGridSnap() != bGridOpt)
141cdf0e10cSrcweir 		pView->SetGridSnap(bGridOpt);
142cdf0e10cSrcweir 	if (pView->IsSnapEnabled() != bGridOpt)
143cdf0e10cSrcweir 		pView->SetSnapEnabled(bGridOpt);
144cdf0e10cSrcweir 
145cdf0e10cSrcweir 	if (pView->IsCreate1stPointAsCenter())
146cdf0e10cSrcweir 		pView->SetCreate1stPointAsCenter(sal_False);
147cdf0e10cSrcweir 	if (pView->IsResizeAtCenter())
148cdf0e10cSrcweir 		pView->SetResizeAtCenter(sal_False);
149cdf0e10cSrcweir }
150cdf0e10cSrcweir 
151cdf0e10cSrcweir /*************************************************************************
152cdf0e10cSrcweir |*
153cdf0e10cSrcweir |* MouseButtonDown-event
154cdf0e10cSrcweir |*
155cdf0e10cSrcweir \************************************************************************/
156cdf0e10cSrcweir 
MouseButtonDown(const MouseEvent & rMEvt)157cdf0e10cSrcweir sal_Bool __EXPORT FuDraw::MouseButtonDown(const MouseEvent& rMEvt)
158cdf0e10cSrcweir {
159cdf0e10cSrcweir 	// #95491# remember button state for creation of own MouseEvents
160cdf0e10cSrcweir 	SetMouseButtonCode(rMEvt.GetButtons());
161cdf0e10cSrcweir 
162cdf0e10cSrcweir 	DoModifiers( rMEvt );
163cdf0e10cSrcweir 	return sal_False;
164cdf0e10cSrcweir }
165cdf0e10cSrcweir 
166cdf0e10cSrcweir /*************************************************************************
167cdf0e10cSrcweir |*
168cdf0e10cSrcweir |* MouseMove-event
169cdf0e10cSrcweir |*
170cdf0e10cSrcweir \************************************************************************/
171cdf0e10cSrcweir 
MouseMove(const MouseEvent & rMEvt)172cdf0e10cSrcweir sal_Bool __EXPORT FuDraw::MouseMove(const MouseEvent& rMEvt)
173cdf0e10cSrcweir {
174cdf0e10cSrcweir 	//	#106438# evaluate modifiers only if in a drawing layer action
175cdf0e10cSrcweir 	//	(don't interfere with keyboard shortcut handling)
176cdf0e10cSrcweir 	if (pView->IsAction())
177cdf0e10cSrcweir 		DoModifiers( rMEvt );
178cdf0e10cSrcweir 
179cdf0e10cSrcweir 	return sal_False;
180cdf0e10cSrcweir }
181cdf0e10cSrcweir 
182cdf0e10cSrcweir /*************************************************************************
183cdf0e10cSrcweir |*
184cdf0e10cSrcweir |* MouseButtonUp-event
185cdf0e10cSrcweir |*
186cdf0e10cSrcweir \************************************************************************/
187cdf0e10cSrcweir 
MouseButtonUp(const MouseEvent & rMEvt)188cdf0e10cSrcweir sal_Bool __EXPORT FuDraw::MouseButtonUp(const MouseEvent& rMEvt)
189cdf0e10cSrcweir {
190cdf0e10cSrcweir 	// #95491# remember button state for creation of own MouseEvents
191cdf0e10cSrcweir 	SetMouseButtonCode(rMEvt.GetButtons());
192cdf0e10cSrcweir 
193cdf0e10cSrcweir 	ResetModifiers();
194cdf0e10cSrcweir 	return sal_False;
195cdf0e10cSrcweir }
196cdf0e10cSrcweir 
197cdf0e10cSrcweir /*************************************************************************
198cdf0e10cSrcweir |*
199cdf0e10cSrcweir |* Tastaturereignisse bearbeiten
200cdf0e10cSrcweir |*
201cdf0e10cSrcweir |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert sal_True, andernfalls
202cdf0e10cSrcweir |* FALSE.
203cdf0e10cSrcweir |*
204cdf0e10cSrcweir \************************************************************************/
205cdf0e10cSrcweir 
lcl_KeyEditMode(SdrObject * pObj,ScTabViewShell * pViewShell,const KeyEvent * pInitialKey)206cdf0e10cSrcweir sal_Bool lcl_KeyEditMode( SdrObject* pObj, ScTabViewShell* pViewShell, const KeyEvent* pInitialKey )
207cdf0e10cSrcweir {
208cdf0e10cSrcweir 	sal_Bool bReturn = sal_False;
209cdf0e10cSrcweir 	if ( pObj && pObj->ISA(SdrTextObj) && !pObj->ISA(SdrUnoObj) )
210cdf0e10cSrcweir 	{
211cdf0e10cSrcweir 		// start text edit - like FuSelection::MouseButtonUp,
212cdf0e10cSrcweir 		// but with bCursorToEnd instead of mouse position
213cdf0e10cSrcweir 
214cdf0e10cSrcweir 		OutlinerParaObject* pOPO = pObj->GetOutlinerParaObject();
215cdf0e10cSrcweir 		sal_Bool bVertical = ( pOPO && pOPO->IsVertical() );
216cdf0e10cSrcweir 		sal_uInt16 nTextSlotId = bVertical ? SID_DRAW_TEXT_VERTICAL : SID_DRAW_TEXT;
217cdf0e10cSrcweir 
218cdf0e10cSrcweir 		// don't switch shells if text shell is already active
219cdf0e10cSrcweir 		FuPoor* pPoor = pViewShell->GetViewData()->GetView()->GetDrawFuncPtr();
220cdf0e10cSrcweir 		if ( !pPoor || pPoor->GetSlotID() != nTextSlotId )
221cdf0e10cSrcweir 		{
222cdf0e10cSrcweir 			pViewShell->GetViewData()->GetDispatcher().
223cdf0e10cSrcweir 				Execute(nTextSlotId, SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD);
224cdf0e10cSrcweir 		}
225cdf0e10cSrcweir 
226cdf0e10cSrcweir 		// get the resulting FuText and set in edit mode
227cdf0e10cSrcweir 		pPoor = pViewShell->GetViewData()->GetView()->GetDrawFuncPtr();
228cdf0e10cSrcweir 		if ( pPoor && pPoor->GetSlotID() == nTextSlotId )	 //	no RTTI
229cdf0e10cSrcweir 		{
230cdf0e10cSrcweir 			FuText* pText = (FuText*)pPoor;
231cdf0e10cSrcweir 			pText->SetInEditMode( pObj, NULL, sal_True, pInitialKey );
232cdf0e10cSrcweir 			//! set cursor to end of text
233cdf0e10cSrcweir 		}
234cdf0e10cSrcweir 		bReturn = sal_True;
235cdf0e10cSrcweir 	}
236cdf0e10cSrcweir 	return bReturn;
237cdf0e10cSrcweir }
238cdf0e10cSrcweir 
KeyInput(const KeyEvent & rKEvt)239cdf0e10cSrcweir sal_Bool __EXPORT FuDraw::KeyInput(const KeyEvent& rKEvt)
240cdf0e10cSrcweir {
241cdf0e10cSrcweir 	sal_Bool bReturn = sal_False;
242cdf0e10cSrcweir     ScViewData& rViewData = *pViewShell->GetViewData();
243cdf0e10cSrcweir 
244cdf0e10cSrcweir 	switch ( rKEvt.GetKeyCode().GetCode() )
245cdf0e10cSrcweir 	{
246cdf0e10cSrcweir 		case KEY_ESCAPE:
247cdf0e10cSrcweir 
248cdf0e10cSrcweir 	/* 18.12.95: TextShell beibehalten nicht mehr gewuenscht...
249cdf0e10cSrcweir 	 *
250cdf0e10cSrcweir 	 *			if ( pView->IsAction() )
251cdf0e10cSrcweir 	 *			{
252cdf0e10cSrcweir 	 *				pView->BrkAction();
253cdf0e10cSrcweir 	 *				pWindow->ReleaseMouse();
254cdf0e10cSrcweir 	 *				bReturn = sal_True;
255cdf0e10cSrcweir 	 *			}
256cdf0e10cSrcweir 	 *			else if ( pView->IsTextEdit() )
257cdf0e10cSrcweir 	 *			{
258cdf0e10cSrcweir 	 *				pView->EndTextEdit();
259cdf0e10cSrcweir 	 *				pView->SetCreateMode();
260cdf0e10cSrcweir 	 *				pViewShell->GetScDrawView()->InvalidateDrawTextAttrs();
261cdf0e10cSrcweir 	 *				bReturn = sal_True;
262cdf0e10cSrcweir 	 *			}
263cdf0e10cSrcweir 	 *			else
264cdf0e10cSrcweir 	 */
265cdf0e10cSrcweir 
266cdf0e10cSrcweir 			if ( pViewShell->IsDrawTextShell() || aSfxRequest.GetSlot() == SID_DRAW_NOTEEDIT )
267cdf0e10cSrcweir 			{
268cdf0e10cSrcweir 				// in normale Draw-Shell, wenn Objekt selektiert, sonst Zeichnen aus
269cdf0e10cSrcweir 				rViewData.GetDispatcher().Execute(aSfxRequest.GetSlot(), SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
270cdf0e10cSrcweir 				bReturn = sal_True;
271cdf0e10cSrcweir 			}
272cdf0e10cSrcweir 			else if ( pViewShell->IsDrawSelMode() )
273cdf0e10cSrcweir 			{
274cdf0e10cSrcweir 				pView->UnmarkAll();
275cdf0e10cSrcweir 				rViewData.GetDispatcher().Execute(SID_OBJECT_SELECT, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
276cdf0e10cSrcweir 				bReturn = sal_True;
277cdf0e10cSrcweir 			}
278cdf0e10cSrcweir 			else if ( pView->AreObjectsMarked() )
279cdf0e10cSrcweir 			{
280cdf0e10cSrcweir 				// #97016# III
281cdf0e10cSrcweir 				SdrHdlList& rHdlList = const_cast< SdrHdlList& >( pView->GetHdlList() );
282cdf0e10cSrcweir                 if( rHdlList.GetFocusHdl() )
283cdf0e10cSrcweir 					rHdlList.ResetFocusHdl();
284cdf0e10cSrcweir 				else
285cdf0e10cSrcweir 					pView->UnmarkAll();
286cdf0e10cSrcweir 
287cdf0e10cSrcweir 				//	Beim Bezier-Editieren ist jetzt wieder das Objekt selektiert
288cdf0e10cSrcweir 				if (!pView->AreObjectsMarked())
289cdf0e10cSrcweir 					pViewShell->SetDrawShell( sal_False );
290cdf0e10cSrcweir 
291cdf0e10cSrcweir 				bReturn = sal_True;
292cdf0e10cSrcweir 			}
293cdf0e10cSrcweir 			break;
294cdf0e10cSrcweir 
295cdf0e10cSrcweir         case KEY_DELETE:					//! ueber Accelerator
296cdf0e10cSrcweir             pView->DeleteMarked();
297cdf0e10cSrcweir             bReturn = sal_True;
298cdf0e10cSrcweir         break;
299cdf0e10cSrcweir 
300cdf0e10cSrcweir 		case KEY_RETURN:
301cdf0e10cSrcweir 		{
302cdf0e10cSrcweir 			if( rKEvt.GetKeyCode().GetModifier() == 0 )
303cdf0e10cSrcweir 			{
304cdf0e10cSrcweir 	            // #98256# activate OLE object on RETURN for selected object
305cdf0e10cSrcweir 				// #98198# put selected text object in edit mode
306cdf0e10cSrcweir 				const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
307cdf0e10cSrcweir 				if( !pView->IsTextEdit() && 1 == rMarkList.GetMarkCount() )
308cdf0e10cSrcweir 				{
309cdf0e10cSrcweir                     sal_Bool bOle = pViewShell->GetViewFrame()->GetFrame().IsInPlace();
310cdf0e10cSrcweir 	                SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
311cdf0e10cSrcweir 	    			if( pObj && pObj->ISA( SdrOle2Obj ) && !bOle )
312cdf0e10cSrcweir 			        {
313cdf0e10cSrcweir 	                    //HMHpView->HideMarkHdl();
314cdf0e10cSrcweir 	                    pViewShell->ActivateObject( static_cast< SdrOle2Obj* >( pObj ), 0 );
315cdf0e10cSrcweir 
316cdf0e10cSrcweir 						// consumed
317cdf0e10cSrcweir 						bReturn = sal_True;
318cdf0e10cSrcweir 			        }
319cdf0e10cSrcweir 					else if ( lcl_KeyEditMode( pObj, pViewShell, NULL ) )		// start text edit for suitable object
320cdf0e10cSrcweir 						bReturn = sal_True;
321cdf0e10cSrcweir 				}
322cdf0e10cSrcweir 			}
323cdf0e10cSrcweir 		}
324cdf0e10cSrcweir 		break;
325cdf0e10cSrcweir 
326cdf0e10cSrcweir 		case KEY_F2:
327cdf0e10cSrcweir 		{
328cdf0e10cSrcweir 			if( rKEvt.GetKeyCode().GetModifier() == 0 )
329cdf0e10cSrcweir 			{
330cdf0e10cSrcweir 				// #98198# put selected text object in edit mode
331cdf0e10cSrcweir 				// (this is not SID_SETINPUTMODE, but F2 hardcoded, like in Writer)
332cdf0e10cSrcweir 				const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
333cdf0e10cSrcweir 				if( !pView->IsTextEdit() && 1 == rMarkList.GetMarkCount() )
334cdf0e10cSrcweir 				{
335cdf0e10cSrcweir 	                SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
336cdf0e10cSrcweir 					if ( lcl_KeyEditMode( pObj, pViewShell, NULL ) )			// start text edit for suitable object
337cdf0e10cSrcweir 						bReturn = sal_True;
338cdf0e10cSrcweir 				}
339cdf0e10cSrcweir 			}
340cdf0e10cSrcweir 		}
341cdf0e10cSrcweir 		break;
342cdf0e10cSrcweir 
343cdf0e10cSrcweir 		// #97016#
344cdf0e10cSrcweir 		case KEY_TAB:
345cdf0e10cSrcweir 		{
346cdf0e10cSrcweir 			// in calc do NOT start draw object selection using TAB/SHIFT-TAB when
347cdf0e10cSrcweir 			// there is not yet a object selected
348cdf0e10cSrcweir 			if(pView->AreObjectsMarked())
349cdf0e10cSrcweir 			{
350cdf0e10cSrcweir 				KeyCode aCode = rKEvt.GetKeyCode();
351cdf0e10cSrcweir 
352cdf0e10cSrcweir 				if ( !aCode.IsMod1() && !aCode.IsMod2() )
353cdf0e10cSrcweir 				{
354cdf0e10cSrcweir 					// changeover to the next object
355cdf0e10cSrcweir 					if(!pView->MarkNextObj( !aCode.IsShift() ))
356cdf0e10cSrcweir 					{
357*0deba7fbSSteve Yin 						//If there is only one object, don't do the UnmarkAlllObj() & MarkNextObj().
358*0deba7fbSSteve Yin 						if ( pView->GetMarkableObjCount() > 1 && pView->HasMarkableObj() )
359*0deba7fbSSteve Yin 						{
360cdf0e10cSrcweir 						// #97016# No next object: go over open end and
361cdf0e10cSrcweir 						// get first from the other side
362cdf0e10cSrcweir 						pView->UnmarkAllObj();
363cdf0e10cSrcweir 						pView->MarkNextObj(!aCode.IsShift());
364*0deba7fbSSteve Yin 						}
365cdf0e10cSrcweir 					}
366cdf0e10cSrcweir 
367cdf0e10cSrcweir 					// #97016# II
368cdf0e10cSrcweir 					if(pView->AreObjectsMarked())
369cdf0e10cSrcweir 						pView->MakeVisible(pView->GetAllMarkedRect(), *pWindow);
370cdf0e10cSrcweir 
371cdf0e10cSrcweir 					bReturn = sal_True;
372cdf0e10cSrcweir 				}
373cdf0e10cSrcweir 
374cdf0e10cSrcweir 				// #98994# handle Mod1 and Mod2 to get travelling running on different systems
375cdf0e10cSrcweir 				if(rKEvt.GetKeyCode().IsMod1() || rKEvt.GetKeyCode().IsMod2())
376cdf0e10cSrcweir 				{
377cdf0e10cSrcweir 					// #97016# II do something with a selected handle?
378cdf0e10cSrcweir 					const SdrHdlList& rHdlList = pView->GetHdlList();
379cdf0e10cSrcweir 					sal_Bool bForward(!rKEvt.GetKeyCode().IsShift());
380cdf0e10cSrcweir 
381cdf0e10cSrcweir 					((SdrHdlList&)rHdlList).TravelFocusHdl(bForward);
382cdf0e10cSrcweir 
383cdf0e10cSrcweir 					// guarantee visibility of focused handle
384cdf0e10cSrcweir 					SdrHdl* pHdl = rHdlList.GetFocusHdl();
385cdf0e10cSrcweir 
386cdf0e10cSrcweir 					if(pHdl)
387cdf0e10cSrcweir 					{
388cdf0e10cSrcweir 						Point aHdlPosition(pHdl->GetPos());
389cdf0e10cSrcweir 						Rectangle aVisRect(aHdlPosition - Point(100, 100), Size(200, 200));
390cdf0e10cSrcweir 						pView->MakeVisible(aVisRect, *pWindow);
391cdf0e10cSrcweir 					}
392cdf0e10cSrcweir 
393cdf0e10cSrcweir 					// consumed
394cdf0e10cSrcweir 					bReturn = sal_True;
395cdf0e10cSrcweir 				}
396cdf0e10cSrcweir 			}
397cdf0e10cSrcweir 		}
398cdf0e10cSrcweir 		break;
399cdf0e10cSrcweir 
400cdf0e10cSrcweir 		// #97016#
401cdf0e10cSrcweir 		case KEY_END:
402cdf0e10cSrcweir 		{
403cdf0e10cSrcweir 			// in calc do NOT select the last draw object when
404cdf0e10cSrcweir 			// there is not yet a object selected
405cdf0e10cSrcweir 			if(pView->AreObjectsMarked())
406cdf0e10cSrcweir 			{
407cdf0e10cSrcweir 				KeyCode aCode = rKEvt.GetKeyCode();
408cdf0e10cSrcweir 
409cdf0e10cSrcweir 				if ( aCode.IsMod1() )
410cdf0e10cSrcweir 				{
411cdf0e10cSrcweir 					// #97016# mark last object
412cdf0e10cSrcweir 					pView->UnmarkAllObj();
413cdf0e10cSrcweir 					pView->MarkNextObj(sal_False);
414cdf0e10cSrcweir 
415cdf0e10cSrcweir 					// #97016# II
416cdf0e10cSrcweir 					if(pView->AreObjectsMarked())
417cdf0e10cSrcweir 						pView->MakeVisible(pView->GetAllMarkedRect(), *pWindow);
418cdf0e10cSrcweir 
419cdf0e10cSrcweir 					bReturn = sal_True;
420cdf0e10cSrcweir 				}
421cdf0e10cSrcweir 			}
422cdf0e10cSrcweir 		}
423cdf0e10cSrcweir 		break;
424cdf0e10cSrcweir 
425cdf0e10cSrcweir 		// #97016#
426cdf0e10cSrcweir 		case KEY_HOME:
427cdf0e10cSrcweir 		{
428cdf0e10cSrcweir 			// in calc do NOT select the first draw object when
429cdf0e10cSrcweir 			// there is not yet a object selected
430cdf0e10cSrcweir 			if(pView->AreObjectsMarked())
431cdf0e10cSrcweir 			{
432cdf0e10cSrcweir 				KeyCode aCode = rKEvt.GetKeyCode();
433cdf0e10cSrcweir 
434cdf0e10cSrcweir 				if ( aCode.IsMod1() )
435cdf0e10cSrcweir 				{
436cdf0e10cSrcweir 					// #97016# mark first object
437cdf0e10cSrcweir 					pView->UnmarkAllObj();
438cdf0e10cSrcweir 					pView->MarkNextObj(sal_True);
439cdf0e10cSrcweir 
440cdf0e10cSrcweir 					// #97016# II
441cdf0e10cSrcweir 					if(pView->AreObjectsMarked())
442cdf0e10cSrcweir 						pView->MakeVisible(pView->GetAllMarkedRect(), *pWindow);
443cdf0e10cSrcweir 
444cdf0e10cSrcweir 					bReturn = sal_True;
445cdf0e10cSrcweir 				}
446cdf0e10cSrcweir 			}
447cdf0e10cSrcweir 		}
448cdf0e10cSrcweir 		break;
449cdf0e10cSrcweir 
450cdf0e10cSrcweir 		// #97016#
451cdf0e10cSrcweir 		case KEY_UP:
452cdf0e10cSrcweir 		case KEY_DOWN:
453cdf0e10cSrcweir 		case KEY_LEFT:
454cdf0e10cSrcweir 		case KEY_RIGHT:
455cdf0e10cSrcweir 		{
456cdf0e10cSrcweir 			// in calc do cursor travelling of draw objects only when
457cdf0e10cSrcweir 			// there is a object selected yet
458cdf0e10cSrcweir 			if(pView->AreObjectsMarked())
459cdf0e10cSrcweir 			{
460cdf0e10cSrcweir 
461cdf0e10cSrcweir 				const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
462cdf0e10cSrcweir 				if(rMarkList.GetMarkCount() == 1)
463cdf0e10cSrcweir 				{
464cdf0e10cSrcweir                     // disable cursor travelling on note objects as the tail connector position
465cdf0e10cSrcweir                     // must not move.
466cdf0e10cSrcweir 				    SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
467cdf0e10cSrcweir                     if( ScDrawLayer::IsNoteCaption( pObj ) )
468cdf0e10cSrcweir                         break;
469cdf0e10cSrcweir 				}
470cdf0e10cSrcweir 
471cdf0e10cSrcweir 				long nX = 0;
472cdf0e10cSrcweir 				long nY = 0;
473cdf0e10cSrcweir 				sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode();
474cdf0e10cSrcweir 
475cdf0e10cSrcweir 				if (nCode == KEY_UP)
476cdf0e10cSrcweir 				{
477cdf0e10cSrcweir 					// Scroll nach oben
478cdf0e10cSrcweir 					nX = 0;
479cdf0e10cSrcweir 					nY =-1;
480cdf0e10cSrcweir 				}
481cdf0e10cSrcweir 				else if (nCode == KEY_DOWN)
482cdf0e10cSrcweir 				{
483cdf0e10cSrcweir 					// Scroll nach unten
484cdf0e10cSrcweir 					nX = 0;
485cdf0e10cSrcweir 					nY = 1;
486cdf0e10cSrcweir 				}
487cdf0e10cSrcweir 				else if (nCode == KEY_LEFT)
488cdf0e10cSrcweir 				{
489cdf0e10cSrcweir 					// Scroll nach links
490cdf0e10cSrcweir 					nX =-1;
491cdf0e10cSrcweir 					nY = 0;
492cdf0e10cSrcweir 				}
493cdf0e10cSrcweir 				else if (nCode == KEY_RIGHT)
494cdf0e10cSrcweir 				{
495cdf0e10cSrcweir 					// Scroll nach rechts
496cdf0e10cSrcweir 					nX = 1;
497cdf0e10cSrcweir 					nY = 0;
498cdf0e10cSrcweir 				}
499cdf0e10cSrcweir 
500cdf0e10cSrcweir 				sal_Bool bReadOnly = rViewData.GetDocShell()->IsReadOnly();
501cdf0e10cSrcweir 
502cdf0e10cSrcweir 				if(!rKEvt.GetKeyCode().IsMod1() && !bReadOnly)
503cdf0e10cSrcweir 				{
504cdf0e10cSrcweir 					if(rKEvt.GetKeyCode().IsMod2())
505cdf0e10cSrcweir 					{
506cdf0e10cSrcweir 						// #97016# move in 1 pixel distance
507cdf0e10cSrcweir 						Size aLogicSizeOnePixel = (pWindow) ? pWindow->PixelToLogic(Size(1,1)) : Size(100, 100);
508cdf0e10cSrcweir 						nX *= aLogicSizeOnePixel.Width();
509cdf0e10cSrcweir 						nY *= aLogicSizeOnePixel.Height();
510cdf0e10cSrcweir 					}
51193641701SArmin Le Grand 					else if(rKEvt.GetKeyCode().IsShift()) // #121236# Support for shift key in calc
51293641701SArmin Le Grand 					{
51393641701SArmin Le Grand 						nX *= 1000;
51493641701SArmin Le Grand 						nY *= 1000;
51593641701SArmin Le Grand 					}
516cdf0e10cSrcweir 					else
517cdf0e10cSrcweir 					{
518cdf0e10cSrcweir 						// old, fixed move distance
519cdf0e10cSrcweir 						nX *= 100;
520cdf0e10cSrcweir 						nY *= 100;
521cdf0e10cSrcweir 					}
522cdf0e10cSrcweir 
523cdf0e10cSrcweir 					// is there a movement to do?
524cdf0e10cSrcweir 					if(0 != nX || 0 != nY)
525cdf0e10cSrcweir 					{
526cdf0e10cSrcweir 						// #97016# II
527cdf0e10cSrcweir 						const SdrHdlList& rHdlList = pView->GetHdlList();
528cdf0e10cSrcweir 						SdrHdl* pHdl = rHdlList.GetFocusHdl();
529cdf0e10cSrcweir 
530cdf0e10cSrcweir 						if(0L == pHdl)
531cdf0e10cSrcweir 						{
532cdf0e10cSrcweir 							// #107086# only take action when move is allowed
533cdf0e10cSrcweir 							if(pView->IsMoveAllowed())
534cdf0e10cSrcweir 							{
535cdf0e10cSrcweir 								// #90129# restrict movement to WorkArea
536cdf0e10cSrcweir 								const Rectangle& rWorkArea = pView->GetWorkArea();
537cdf0e10cSrcweir 
538cdf0e10cSrcweir 								if(!rWorkArea.IsEmpty())
539cdf0e10cSrcweir 								{
540cdf0e10cSrcweir 									Rectangle aMarkRect(pView->GetMarkedObjRect());
541cdf0e10cSrcweir 									aMarkRect.Move(nX, nY);
542cdf0e10cSrcweir 
543cdf0e10cSrcweir 									if(!aMarkRect.IsInside(rWorkArea))
544cdf0e10cSrcweir 									{
545cdf0e10cSrcweir 										if(aMarkRect.Left() < rWorkArea.Left())
546cdf0e10cSrcweir 										{
547cdf0e10cSrcweir 											nX += rWorkArea.Left() - aMarkRect.Left();
548cdf0e10cSrcweir 										}
549cdf0e10cSrcweir 
550cdf0e10cSrcweir 										if(aMarkRect.Right() > rWorkArea.Right())
551cdf0e10cSrcweir 										{
552cdf0e10cSrcweir 											nX -= aMarkRect.Right() - rWorkArea.Right();
553cdf0e10cSrcweir 										}
554cdf0e10cSrcweir 
555cdf0e10cSrcweir 										if(aMarkRect.Top() < rWorkArea.Top())
556cdf0e10cSrcweir 										{
557cdf0e10cSrcweir 											nY += rWorkArea.Top() - aMarkRect.Top();
558cdf0e10cSrcweir 										}
559cdf0e10cSrcweir 
560cdf0e10cSrcweir 										if(aMarkRect.Bottom() > rWorkArea.Bottom())
561cdf0e10cSrcweir 										{
562cdf0e10cSrcweir 											nY -= aMarkRect.Bottom() - rWorkArea.Bottom();
563cdf0e10cSrcweir 										}
564cdf0e10cSrcweir 									}
565cdf0e10cSrcweir 								}
566cdf0e10cSrcweir 
567cdf0e10cSrcweir 								// now move the selected draw objects
568cdf0e10cSrcweir 								pView->MoveAllMarked(Size(nX, nY));
569cdf0e10cSrcweir 
570cdf0e10cSrcweir 								// #97016# II
571cdf0e10cSrcweir 								pView->MakeVisible(pView->GetAllMarkedRect(), *pWindow);
572cdf0e10cSrcweir 
573cdf0e10cSrcweir 								bReturn = sal_True;
574cdf0e10cSrcweir 							}
575cdf0e10cSrcweir 						}
576cdf0e10cSrcweir 						else
577cdf0e10cSrcweir 						{
578cdf0e10cSrcweir 							// move handle with index nHandleIndex
579cdf0e10cSrcweir 							if(pHdl && (nX || nY))
580cdf0e10cSrcweir 							{
581cdf0e10cSrcweir 								// now move the Handle (nX, nY)
582cdf0e10cSrcweir 								Point aStartPoint(pHdl->GetPos());
583cdf0e10cSrcweir 								Point aEndPoint(pHdl->GetPos() + Point(nX, nY));
584cdf0e10cSrcweir 								const SdrDragStat& rDragStat = pView->GetDragStat();
585cdf0e10cSrcweir 
586cdf0e10cSrcweir 								// start dragging
587cdf0e10cSrcweir 								pView->BegDragObj(aStartPoint, 0, pHdl, 0);
588cdf0e10cSrcweir 
589cdf0e10cSrcweir 								if(pView->IsDragObj())
590cdf0e10cSrcweir 								{
591cdf0e10cSrcweir 									FASTBOOL bWasNoSnap = rDragStat.IsNoSnap();
592cdf0e10cSrcweir 									sal_Bool bWasSnapEnabled = pView->IsSnapEnabled();
593cdf0e10cSrcweir 
594cdf0e10cSrcweir 									// switch snapping off
595cdf0e10cSrcweir 									if(!bWasNoSnap)
596cdf0e10cSrcweir 										((SdrDragStat&)rDragStat).SetNoSnap(sal_True);
597cdf0e10cSrcweir 									if(bWasSnapEnabled)
598cdf0e10cSrcweir 										pView->SetSnapEnabled(sal_False);
599cdf0e10cSrcweir 
600cdf0e10cSrcweir 									pView->MovAction(aEndPoint);
601cdf0e10cSrcweir 									pView->EndDragObj();
602cdf0e10cSrcweir 
603cdf0e10cSrcweir 									// restore snap
604cdf0e10cSrcweir 									if(!bWasNoSnap)
605cdf0e10cSrcweir 										((SdrDragStat&)rDragStat).SetNoSnap(bWasNoSnap);
606cdf0e10cSrcweir 									if(bWasSnapEnabled)
607cdf0e10cSrcweir 										pView->SetSnapEnabled(bWasSnapEnabled);
608cdf0e10cSrcweir 								}
609cdf0e10cSrcweir 
610cdf0e10cSrcweir 								// make moved handle visible
611cdf0e10cSrcweir 								Rectangle aVisRect(aEndPoint - Point(100, 100), Size(200, 200));
612cdf0e10cSrcweir 								pView->MakeVisible(aVisRect, *pWindow);
613cdf0e10cSrcweir 
614cdf0e10cSrcweir 								bReturn = sal_True;
615cdf0e10cSrcweir 							}
616cdf0e10cSrcweir 						}
617cdf0e10cSrcweir 					}
618cdf0e10cSrcweir 				}
619cdf0e10cSrcweir 			}
620cdf0e10cSrcweir 		}
621cdf0e10cSrcweir 		break;
622cdf0e10cSrcweir 
623cdf0e10cSrcweir 		// #97016#
624cdf0e10cSrcweir 		case KEY_SPACE:
625cdf0e10cSrcweir 		{
626cdf0e10cSrcweir 			// in calc do only something when draw objects are selected
627cdf0e10cSrcweir 			if(pView->AreObjectsMarked())
628cdf0e10cSrcweir 			{
629cdf0e10cSrcweir 				const SdrHdlList& rHdlList = pView->GetHdlList();
630cdf0e10cSrcweir 				SdrHdl* pHdl = rHdlList.GetFocusHdl();
631cdf0e10cSrcweir 
632cdf0e10cSrcweir 				if(pHdl)
633cdf0e10cSrcweir 				{
634cdf0e10cSrcweir 					if(pHdl->GetKind() == HDL_POLY)
635cdf0e10cSrcweir 					{
636cdf0e10cSrcweir 						// rescue ID of point with focus
637cdf0e10cSrcweir 						sal_uInt32 nPol(pHdl->GetPolyNum());
638cdf0e10cSrcweir 						sal_uInt32 nPnt(pHdl->GetPointNum());
639cdf0e10cSrcweir 
640cdf0e10cSrcweir 						if(pView->IsPointMarked(*pHdl))
641cdf0e10cSrcweir 						{
642cdf0e10cSrcweir 							if(rKEvt.GetKeyCode().IsShift())
643cdf0e10cSrcweir 							{
644cdf0e10cSrcweir 								pView->UnmarkPoint(*pHdl);
645cdf0e10cSrcweir 							}
646cdf0e10cSrcweir 						}
647cdf0e10cSrcweir 						else
648cdf0e10cSrcweir 						{
649cdf0e10cSrcweir 							if(!rKEvt.GetKeyCode().IsShift())
650cdf0e10cSrcweir 							{
651cdf0e10cSrcweir 								pView->UnmarkAllPoints();
652cdf0e10cSrcweir 							}
653cdf0e10cSrcweir 
654cdf0e10cSrcweir 							pView->MarkPoint(*pHdl);
655cdf0e10cSrcweir 						}
656cdf0e10cSrcweir 
657cdf0e10cSrcweir 						if(0L == rHdlList.GetFocusHdl())
658cdf0e10cSrcweir 						{
659cdf0e10cSrcweir 							// restore point with focus
660cdf0e10cSrcweir 							SdrHdl* pNewOne = 0L;
661cdf0e10cSrcweir 
662cdf0e10cSrcweir 							for(sal_uInt32 a(0); !pNewOne && a < rHdlList.GetHdlCount(); a++)
663cdf0e10cSrcweir 							{
664cdf0e10cSrcweir 								SdrHdl* pAct = rHdlList.GetHdl(a);
665cdf0e10cSrcweir 
666cdf0e10cSrcweir 								if(pAct
667cdf0e10cSrcweir 									&& pAct->GetKind() == HDL_POLY
668cdf0e10cSrcweir 									&& pAct->GetPolyNum() == nPol
669cdf0e10cSrcweir 									&& pAct->GetPointNum() == nPnt)
670cdf0e10cSrcweir 								{
671cdf0e10cSrcweir 									pNewOne = pAct;
672cdf0e10cSrcweir 								}
673cdf0e10cSrcweir 							}
674cdf0e10cSrcweir 
675cdf0e10cSrcweir 							if(pNewOne)
676cdf0e10cSrcweir 							{
677cdf0e10cSrcweir 								((SdrHdlList&)rHdlList).SetFocusHdl(pNewOne);
678cdf0e10cSrcweir 							}
679cdf0e10cSrcweir 						}
680cdf0e10cSrcweir 
681cdf0e10cSrcweir 						bReturn = sal_True;
682cdf0e10cSrcweir 					}
683cdf0e10cSrcweir 				}
684cdf0e10cSrcweir 			}
685cdf0e10cSrcweir 		}
686cdf0e10cSrcweir 		break;
687cdf0e10cSrcweir 	}
688cdf0e10cSrcweir 
689cdf0e10cSrcweir 	if (!bReturn)
690cdf0e10cSrcweir 	{
691cdf0e10cSrcweir 		bReturn = FuPoor::KeyInput(rKEvt);
692cdf0e10cSrcweir 	}
693cdf0e10cSrcweir 
694cdf0e10cSrcweir 	if (!bReturn)
695cdf0e10cSrcweir 	{
696cdf0e10cSrcweir 		// #98198# allow direct typing into a selected text object
697cdf0e10cSrcweir 
698cdf0e10cSrcweir 		const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
699cdf0e10cSrcweir 		if( !pView->IsTextEdit() && 1 == rMarkList.GetMarkCount() && EditEngine::IsSimpleCharInput(rKEvt) )
700cdf0e10cSrcweir 		{
701cdf0e10cSrcweir             SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
702cdf0e10cSrcweir 
703cdf0e10cSrcweir 			// start text edit for suitable object, pass key event to OutlinerView
704cdf0e10cSrcweir 			if ( lcl_KeyEditMode( pObj, pViewShell, &rKEvt ) )
705cdf0e10cSrcweir 				bReturn = sal_True;
706cdf0e10cSrcweir 		}
707cdf0e10cSrcweir 	}
708cdf0e10cSrcweir 
709cdf0e10cSrcweir 	return (bReturn);
710cdf0e10cSrcweir }
711cdf0e10cSrcweir 
712cdf0e10cSrcweir // #97016# II
SelectionHasChanged()713cdf0e10cSrcweir void FuDraw::SelectionHasChanged()
714cdf0e10cSrcweir {
715cdf0e10cSrcweir 	const SdrHdlList& rHdlList = pView->GetHdlList();
716cdf0e10cSrcweir 	((SdrHdlList&)rHdlList).ResetFocusHdl();
717cdf0e10cSrcweir }
718cdf0e10cSrcweir 
719cdf0e10cSrcweir /*************************************************************************
720cdf0e10cSrcweir |*
721cdf0e10cSrcweir |* Vor dem Scrollen Selektionsdarstellung ausblenden
722cdf0e10cSrcweir |*
723cdf0e10cSrcweir \************************************************************************/
724cdf0e10cSrcweir 
ScrollStart()725cdf0e10cSrcweir void FuDraw::ScrollStart()
726cdf0e10cSrcweir {
727cdf0e10cSrcweir //		HideShownXor in Gridwin
728cdf0e10cSrcweir }
729cdf0e10cSrcweir 
730cdf0e10cSrcweir /*************************************************************************
731cdf0e10cSrcweir |*
732cdf0e10cSrcweir |* Nach dem Scrollen Selektionsdarstellung wieder anzeigen
733cdf0e10cSrcweir |*
734cdf0e10cSrcweir \************************************************************************/
735cdf0e10cSrcweir 
ScrollEnd()736cdf0e10cSrcweir void FuDraw::ScrollEnd()
737cdf0e10cSrcweir {
738cdf0e10cSrcweir //		ShowShownXor in Gridwin
739cdf0e10cSrcweir }
740cdf0e10cSrcweir 
741cdf0e10cSrcweir /*************************************************************************
742cdf0e10cSrcweir |*
743cdf0e10cSrcweir |* Function aktivieren
744cdf0e10cSrcweir |*
745cdf0e10cSrcweir \************************************************************************/
746cdf0e10cSrcweir 
Activate()747cdf0e10cSrcweir void FuDraw::Activate()
748cdf0e10cSrcweir {
749cdf0e10cSrcweir 	FuPoor::Activate();
750cdf0e10cSrcweir }
751cdf0e10cSrcweir 
752cdf0e10cSrcweir /*************************************************************************
753cdf0e10cSrcweir |*
754cdf0e10cSrcweir |* Function deaktivieren
755cdf0e10cSrcweir |*
756cdf0e10cSrcweir \************************************************************************/
757cdf0e10cSrcweir 
Deactivate()758cdf0e10cSrcweir void FuDraw::Deactivate()
759cdf0e10cSrcweir {
760cdf0e10cSrcweir 	FuPoor::Deactivate();
761cdf0e10cSrcweir }
762cdf0e10cSrcweir 
763cdf0e10cSrcweir /*************************************************************************
764cdf0e10cSrcweir |*
765cdf0e10cSrcweir |* Maus-Pointer umschalten
766cdf0e10cSrcweir |*
767cdf0e10cSrcweir \************************************************************************/
768cdf0e10cSrcweir 
lcl_UrlHit(SdrView * pView,const Point & rPosPixel,Window * pWindow)769cdf0e10cSrcweir sal_Bool lcl_UrlHit( SdrView* pView, const Point& rPosPixel, Window* pWindow )
770cdf0e10cSrcweir {
771cdf0e10cSrcweir 	SdrViewEvent aVEvt;
772cdf0e10cSrcweir 	MouseEvent aMEvt( rPosPixel, 1, 0, MOUSE_LEFT );
773cdf0e10cSrcweir 	SdrHitKind eHit = pView->PickAnything( aMEvt, SDRMOUSEBUTTONDOWN, aVEvt );
774cdf0e10cSrcweir 
775cdf0e10cSrcweir 	if ( eHit != SDRHIT_NONE && aVEvt.pObj != NULL )
776cdf0e10cSrcweir 	{
777cdf0e10cSrcweir 		if ( ScDrawLayer::GetIMapInfo( aVEvt.pObj ) && ScDrawLayer::GetHitIMapObject(
778cdf0e10cSrcweir 								aVEvt.pObj, pWindow->PixelToLogic(rPosPixel), *pWindow ) )
779cdf0e10cSrcweir 			return sal_True;
780cdf0e10cSrcweir 
781cdf0e10cSrcweir 		if ( aVEvt.eEvent == SDREVENT_EXECUTEURL )
782cdf0e10cSrcweir 			return sal_True;
783cdf0e10cSrcweir 	}
784cdf0e10cSrcweir 
785cdf0e10cSrcweir 	return sal_False;
786cdf0e10cSrcweir }
787cdf0e10cSrcweir 
ForcePointer(const MouseEvent * pMEvt)788cdf0e10cSrcweir void FuDraw::ForcePointer(const MouseEvent* pMEvt)
789cdf0e10cSrcweir {
790cdf0e10cSrcweir 	if ( !pView->IsAction() )
791cdf0e10cSrcweir 	{
792cdf0e10cSrcweir 		Point aPosPixel = pWindow->GetPointerPosPixel();
793cdf0e10cSrcweir 		sal_Bool bAlt		= pMEvt && pMEvt->IsMod2();
794cdf0e10cSrcweir 		Point aPnt		= pWindow->PixelToLogic( aPosPixel );
795cdf0e10cSrcweir 		SdrHdl* pHdl	= pView->PickHandle(aPnt);
796cdf0e10cSrcweir 		SdrObject* pObj;
797cdf0e10cSrcweir 		SdrPageView* pPV;
798cdf0e10cSrcweir 
799cdf0e10cSrcweir         ScMacroInfo* pInfo = 0;
800cdf0e10cSrcweir         if ( pView->PickObj(aPnt, pView->getHitTolLog(), pObj, pPV, SDRSEARCH_ALSOONMASTER) )
801cdf0e10cSrcweir         {
802cdf0e10cSrcweir             if ( pObj->IsGroupObject() )
803cdf0e10cSrcweir             {
804cdf0e10cSrcweir                 SdrObject* pHit = 0;
805cdf0e10cSrcweir                 if ( pView->PickObj(aMDPos, pView->getHitTolLog(), pHit, pPV, SDRSEARCH_DEEP ) )
806cdf0e10cSrcweir                     pObj = pHit;
807cdf0e10cSrcweir             }
808cdf0e10cSrcweir             pInfo = ScDrawLayer::GetMacroInfo( pObj );
809cdf0e10cSrcweir         }
810cdf0e10cSrcweir 
811cdf0e10cSrcweir 		if ( pView->IsTextEdit() )
812cdf0e10cSrcweir 		{
813cdf0e10cSrcweir 			pViewShell->SetActivePointer(Pointer(POINTER_TEXT));		// kann nicht sein ?
814cdf0e10cSrcweir 		}
815cdf0e10cSrcweir 		else if ( pHdl )
816cdf0e10cSrcweir 		{
817cdf0e10cSrcweir 			pViewShell->SetActivePointer(
818cdf0e10cSrcweir 				pView->GetPreferedPointer( aPnt, pWindow ) );
819cdf0e10cSrcweir 		}
820cdf0e10cSrcweir 		else if ( pView->IsMarkedHit(aPnt) )
821cdf0e10cSrcweir 		{
822cdf0e10cSrcweir 			pViewShell->SetActivePointer( Pointer(POINTER_MOVE) );
823cdf0e10cSrcweir 		}
824cdf0e10cSrcweir 		else if ( !bAlt && ( !pMEvt || !pMEvt->GetButtons() )
825cdf0e10cSrcweir 						&& lcl_UrlHit( pView, aPosPixel, pWindow ) )
826cdf0e10cSrcweir 		{
827cdf0e10cSrcweir 			//	kann mit ALT unterdrueckt werden
828cdf0e10cSrcweir 			pWindow->SetPointer( Pointer( POINTER_REFHAND ) );			// Text-URL / ImageMap
829cdf0e10cSrcweir 		}
830cdf0e10cSrcweir 		else if ( !bAlt && pView->PickObj(aPnt, pView->getHitTolLog(), pObj, pPV, SDRSEARCH_PICKMACRO) )
831cdf0e10cSrcweir 		{
832cdf0e10cSrcweir 			//	kann mit ALT unterdrueckt werden
833cdf0e10cSrcweir 			SdrObjMacroHitRec aHitRec;	//! muss da noch irgendwas gesetzt werden ????
834cdf0e10cSrcweir 			pViewShell->SetActivePointer( pObj->GetMacroPointer(aHitRec) );
835cdf0e10cSrcweir 		}
836cdf0e10cSrcweir #ifdef ISSUE66550_HLINK_FOR_SHAPES
837cdf0e10cSrcweir         else if ( !bAlt && pInfo && ((pInfo->GetMacro().getLength() > 0) || (pInfo->GetHlink().getLength() > 0)) )
838cdf0e10cSrcweir #else
839cdf0e10cSrcweir         else if ( !bAlt && pInfo && (pInfo->GetMacro().getLength() > 0) )
840cdf0e10cSrcweir #endif
841cdf0e10cSrcweir 			pWindow->SetPointer( Pointer( POINTER_REFHAND ) );
842cdf0e10cSrcweir 		else if ( IsDetectiveHit( aPnt ) )
843cdf0e10cSrcweir 			pViewShell->SetActivePointer( Pointer( POINTER_DETECTIVE ) );
844cdf0e10cSrcweir 		else
845cdf0e10cSrcweir 			pViewShell->SetActivePointer( aNewPointer );			//! in Gridwin?
846cdf0e10cSrcweir 	}
847cdf0e10cSrcweir }
848cdf0e10cSrcweir 
IsSizingOrMovingNote(const MouseEvent & rMEvt) const849cdf0e10cSrcweir sal_Bool FuDraw::IsSizingOrMovingNote( const MouseEvent& rMEvt ) const
850cdf0e10cSrcweir {
851cdf0e10cSrcweir     sal_Bool bIsSizingOrMoving = sal_False;
852cdf0e10cSrcweir     if ( rMEvt.IsLeft() )
853cdf0e10cSrcweir     {
854cdf0e10cSrcweir         const SdrMarkList& rNoteMarkList = pView->GetMarkedObjectList();
855cdf0e10cSrcweir         if(rNoteMarkList.GetMarkCount() == 1)
856cdf0e10cSrcweir         {
857cdf0e10cSrcweir             SdrObject* pObj = rNoteMarkList.GetMark( 0 )->GetMarkedSdrObj();
858cdf0e10cSrcweir             if ( ScDrawLayer::IsNoteCaption( pObj ) )
859cdf0e10cSrcweir             {
860cdf0e10cSrcweir                 Point aMPos = pWindow->PixelToLogic( rMEvt.GetPosPixel() );
861cdf0e10cSrcweir                 bIsSizingOrMoving =
862cdf0e10cSrcweir                     pView->PickHandle( aMPos ) ||      // handles to resize the note
863cdf0e10cSrcweir                     pView->IsTextEditFrameHit( aMPos );         // frame for moving the note
864cdf0e10cSrcweir             }
865cdf0e10cSrcweir         }
866cdf0e10cSrcweir     }
867cdf0e10cSrcweir     return bIsSizingOrMoving;
868cdf0e10cSrcweir }
869