xref: /aoo41x/main/sc/source/ui/drawfunc/fudraw.cxx (revision 0deba7fb)
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 
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 
73cdf0e10cSrcweir FuDraw::~FuDraw()
74cdf0e10cSrcweir {
75cdf0e10cSrcweir }
76cdf0e10cSrcweir 
77cdf0e10cSrcweir /*************************************************************************
78cdf0e10cSrcweir |*
79cdf0e10cSrcweir |* Modifier-Tasten auswerten
80cdf0e10cSrcweir |*
81cdf0e10cSrcweir \************************************************************************/
82cdf0e10cSrcweir 
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 
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 
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 
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 
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 
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 
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 //IAccessibility2 Implementation 2009-----
358*0deba7fbSSteve Yin 						//If there is only one object, don't do the UnmarkAlllObj() & MarkNextObj().
359*0deba7fbSSteve Yin 						if ( pView->GetMarkableObjCount() > 1 && pView->HasMarkableObj() )
360*0deba7fbSSteve Yin 						{
361*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009
362cdf0e10cSrcweir 						// #97016# No next object: go over open end and
363cdf0e10cSrcweir 						// get first from the other side
364cdf0e10cSrcweir 						pView->UnmarkAllObj();
365cdf0e10cSrcweir 						pView->MarkNextObj(!aCode.IsShift());
366*0deba7fbSSteve Yin 						}
367cdf0e10cSrcweir 					}
368cdf0e10cSrcweir 
369cdf0e10cSrcweir 					// #97016# II
370cdf0e10cSrcweir 					if(pView->AreObjectsMarked())
371cdf0e10cSrcweir 						pView->MakeVisible(pView->GetAllMarkedRect(), *pWindow);
372cdf0e10cSrcweir 
373cdf0e10cSrcweir 					bReturn = sal_True;
374cdf0e10cSrcweir 				}
375cdf0e10cSrcweir 
376cdf0e10cSrcweir 				// #98994# handle Mod1 and Mod2 to get travelling running on different systems
377cdf0e10cSrcweir 				if(rKEvt.GetKeyCode().IsMod1() || rKEvt.GetKeyCode().IsMod2())
378cdf0e10cSrcweir 				{
379cdf0e10cSrcweir 					// #97016# II do something with a selected handle?
380cdf0e10cSrcweir 					const SdrHdlList& rHdlList = pView->GetHdlList();
381cdf0e10cSrcweir 					sal_Bool bForward(!rKEvt.GetKeyCode().IsShift());
382cdf0e10cSrcweir 
383cdf0e10cSrcweir 					((SdrHdlList&)rHdlList).TravelFocusHdl(bForward);
384cdf0e10cSrcweir 
385cdf0e10cSrcweir 					// guarantee visibility of focused handle
386cdf0e10cSrcweir 					SdrHdl* pHdl = rHdlList.GetFocusHdl();
387cdf0e10cSrcweir 
388cdf0e10cSrcweir 					if(pHdl)
389cdf0e10cSrcweir 					{
390cdf0e10cSrcweir 						Point aHdlPosition(pHdl->GetPos());
391cdf0e10cSrcweir 						Rectangle aVisRect(aHdlPosition - Point(100, 100), Size(200, 200));
392cdf0e10cSrcweir 						pView->MakeVisible(aVisRect, *pWindow);
393cdf0e10cSrcweir 					}
394cdf0e10cSrcweir 
395cdf0e10cSrcweir 					// consumed
396cdf0e10cSrcweir 					bReturn = sal_True;
397cdf0e10cSrcweir 				}
398cdf0e10cSrcweir 			}
399cdf0e10cSrcweir 		}
400cdf0e10cSrcweir 		break;
401cdf0e10cSrcweir 
402cdf0e10cSrcweir 		// #97016#
403cdf0e10cSrcweir 		case KEY_END:
404cdf0e10cSrcweir 		{
405cdf0e10cSrcweir 			// in calc do NOT select the last draw object when
406cdf0e10cSrcweir 			// there is not yet a object selected
407cdf0e10cSrcweir 			if(pView->AreObjectsMarked())
408cdf0e10cSrcweir 			{
409cdf0e10cSrcweir 				KeyCode aCode = rKEvt.GetKeyCode();
410cdf0e10cSrcweir 
411cdf0e10cSrcweir 				if ( aCode.IsMod1() )
412cdf0e10cSrcweir 				{
413cdf0e10cSrcweir 					// #97016# mark last object
414cdf0e10cSrcweir 					pView->UnmarkAllObj();
415cdf0e10cSrcweir 					pView->MarkNextObj(sal_False);
416cdf0e10cSrcweir 
417cdf0e10cSrcweir 					// #97016# II
418cdf0e10cSrcweir 					if(pView->AreObjectsMarked())
419cdf0e10cSrcweir 						pView->MakeVisible(pView->GetAllMarkedRect(), *pWindow);
420cdf0e10cSrcweir 
421cdf0e10cSrcweir 					bReturn = sal_True;
422cdf0e10cSrcweir 				}
423cdf0e10cSrcweir 			}
424cdf0e10cSrcweir 		}
425cdf0e10cSrcweir 		break;
426cdf0e10cSrcweir 
427cdf0e10cSrcweir 		// #97016#
428cdf0e10cSrcweir 		case KEY_HOME:
429cdf0e10cSrcweir 		{
430cdf0e10cSrcweir 			// in calc do NOT select the first draw object when
431cdf0e10cSrcweir 			// there is not yet a object selected
432cdf0e10cSrcweir 			if(pView->AreObjectsMarked())
433cdf0e10cSrcweir 			{
434cdf0e10cSrcweir 				KeyCode aCode = rKEvt.GetKeyCode();
435cdf0e10cSrcweir 
436cdf0e10cSrcweir 				if ( aCode.IsMod1() )
437cdf0e10cSrcweir 				{
438cdf0e10cSrcweir 					// #97016# mark first object
439cdf0e10cSrcweir 					pView->UnmarkAllObj();
440cdf0e10cSrcweir 					pView->MarkNextObj(sal_True);
441cdf0e10cSrcweir 
442cdf0e10cSrcweir 					// #97016# II
443cdf0e10cSrcweir 					if(pView->AreObjectsMarked())
444cdf0e10cSrcweir 						pView->MakeVisible(pView->GetAllMarkedRect(), *pWindow);
445cdf0e10cSrcweir 
446cdf0e10cSrcweir 					bReturn = sal_True;
447cdf0e10cSrcweir 				}
448cdf0e10cSrcweir 			}
449cdf0e10cSrcweir 		}
450cdf0e10cSrcweir 		break;
451cdf0e10cSrcweir 
452cdf0e10cSrcweir 		// #97016#
453cdf0e10cSrcweir 		case KEY_UP:
454cdf0e10cSrcweir 		case KEY_DOWN:
455cdf0e10cSrcweir 		case KEY_LEFT:
456cdf0e10cSrcweir 		case KEY_RIGHT:
457cdf0e10cSrcweir 		{
458cdf0e10cSrcweir 			// in calc do cursor travelling of draw objects only when
459cdf0e10cSrcweir 			// there is a object selected yet
460cdf0e10cSrcweir 			if(pView->AreObjectsMarked())
461cdf0e10cSrcweir 			{
462cdf0e10cSrcweir 
463cdf0e10cSrcweir 				const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
464cdf0e10cSrcweir 				if(rMarkList.GetMarkCount() == 1)
465cdf0e10cSrcweir 				{
466cdf0e10cSrcweir                     // disable cursor travelling on note objects as the tail connector position
467cdf0e10cSrcweir                     // must not move.
468cdf0e10cSrcweir 				    SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
469cdf0e10cSrcweir                     if( ScDrawLayer::IsNoteCaption( pObj ) )
470cdf0e10cSrcweir                         break;
471cdf0e10cSrcweir 				}
472cdf0e10cSrcweir 
473cdf0e10cSrcweir 				long nX = 0;
474cdf0e10cSrcweir 				long nY = 0;
475cdf0e10cSrcweir 				sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode();
476cdf0e10cSrcweir 
477cdf0e10cSrcweir 				if (nCode == KEY_UP)
478cdf0e10cSrcweir 				{
479cdf0e10cSrcweir 					// Scroll nach oben
480cdf0e10cSrcweir 					nX = 0;
481cdf0e10cSrcweir 					nY =-1;
482cdf0e10cSrcweir 				}
483cdf0e10cSrcweir 				else if (nCode == KEY_DOWN)
484cdf0e10cSrcweir 				{
485cdf0e10cSrcweir 					// Scroll nach unten
486cdf0e10cSrcweir 					nX = 0;
487cdf0e10cSrcweir 					nY = 1;
488cdf0e10cSrcweir 				}
489cdf0e10cSrcweir 				else if (nCode == KEY_LEFT)
490cdf0e10cSrcweir 				{
491cdf0e10cSrcweir 					// Scroll nach links
492cdf0e10cSrcweir 					nX =-1;
493cdf0e10cSrcweir 					nY = 0;
494cdf0e10cSrcweir 				}
495cdf0e10cSrcweir 				else if (nCode == KEY_RIGHT)
496cdf0e10cSrcweir 				{
497cdf0e10cSrcweir 					// Scroll nach rechts
498cdf0e10cSrcweir 					nX = 1;
499cdf0e10cSrcweir 					nY = 0;
500cdf0e10cSrcweir 				}
501cdf0e10cSrcweir 
502cdf0e10cSrcweir 				sal_Bool bReadOnly = rViewData.GetDocShell()->IsReadOnly();
503cdf0e10cSrcweir 
504cdf0e10cSrcweir 				if(!rKEvt.GetKeyCode().IsMod1() && !bReadOnly)
505cdf0e10cSrcweir 				{
506cdf0e10cSrcweir 					if(rKEvt.GetKeyCode().IsMod2())
507cdf0e10cSrcweir 					{
508cdf0e10cSrcweir 						// #97016# move in 1 pixel distance
509cdf0e10cSrcweir 						Size aLogicSizeOnePixel = (pWindow) ? pWindow->PixelToLogic(Size(1,1)) : Size(100, 100);
510cdf0e10cSrcweir 						nX *= aLogicSizeOnePixel.Width();
511cdf0e10cSrcweir 						nY *= aLogicSizeOnePixel.Height();
512cdf0e10cSrcweir 					}
51393641701SArmin Le Grand 					else if(rKEvt.GetKeyCode().IsShift()) // #121236# Support for shift key in calc
51493641701SArmin Le Grand 					{
51593641701SArmin Le Grand 						nX *= 1000;
51693641701SArmin Le Grand 						nY *= 1000;
51793641701SArmin Le Grand 					}
518cdf0e10cSrcweir 					else
519cdf0e10cSrcweir 					{
520cdf0e10cSrcweir 						// old, fixed move distance
521cdf0e10cSrcweir 						nX *= 100;
522cdf0e10cSrcweir 						nY *= 100;
523cdf0e10cSrcweir 					}
524cdf0e10cSrcweir 
525cdf0e10cSrcweir 					// is there a movement to do?
526cdf0e10cSrcweir 					if(0 != nX || 0 != nY)
527cdf0e10cSrcweir 					{
528cdf0e10cSrcweir 						// #97016# II
529cdf0e10cSrcweir 						const SdrHdlList& rHdlList = pView->GetHdlList();
530cdf0e10cSrcweir 						SdrHdl* pHdl = rHdlList.GetFocusHdl();
531cdf0e10cSrcweir 
532cdf0e10cSrcweir 						if(0L == pHdl)
533cdf0e10cSrcweir 						{
534cdf0e10cSrcweir 							// #107086# only take action when move is allowed
535cdf0e10cSrcweir 							if(pView->IsMoveAllowed())
536cdf0e10cSrcweir 							{
537cdf0e10cSrcweir 								// #90129# restrict movement to WorkArea
538cdf0e10cSrcweir 								const Rectangle& rWorkArea = pView->GetWorkArea();
539cdf0e10cSrcweir 
540cdf0e10cSrcweir 								if(!rWorkArea.IsEmpty())
541cdf0e10cSrcweir 								{
542cdf0e10cSrcweir 									Rectangle aMarkRect(pView->GetMarkedObjRect());
543cdf0e10cSrcweir 									aMarkRect.Move(nX, nY);
544cdf0e10cSrcweir 
545cdf0e10cSrcweir 									if(!aMarkRect.IsInside(rWorkArea))
546cdf0e10cSrcweir 									{
547cdf0e10cSrcweir 										if(aMarkRect.Left() < rWorkArea.Left())
548cdf0e10cSrcweir 										{
549cdf0e10cSrcweir 											nX += rWorkArea.Left() - aMarkRect.Left();
550cdf0e10cSrcweir 										}
551cdf0e10cSrcweir 
552cdf0e10cSrcweir 										if(aMarkRect.Right() > rWorkArea.Right())
553cdf0e10cSrcweir 										{
554cdf0e10cSrcweir 											nX -= aMarkRect.Right() - rWorkArea.Right();
555cdf0e10cSrcweir 										}
556cdf0e10cSrcweir 
557cdf0e10cSrcweir 										if(aMarkRect.Top() < rWorkArea.Top())
558cdf0e10cSrcweir 										{
559cdf0e10cSrcweir 											nY += rWorkArea.Top() - aMarkRect.Top();
560cdf0e10cSrcweir 										}
561cdf0e10cSrcweir 
562cdf0e10cSrcweir 										if(aMarkRect.Bottom() > rWorkArea.Bottom())
563cdf0e10cSrcweir 										{
564cdf0e10cSrcweir 											nY -= aMarkRect.Bottom() - rWorkArea.Bottom();
565cdf0e10cSrcweir 										}
566cdf0e10cSrcweir 									}
567cdf0e10cSrcweir 								}
568cdf0e10cSrcweir 
569cdf0e10cSrcweir 								// now move the selected draw objects
570cdf0e10cSrcweir 								pView->MoveAllMarked(Size(nX, nY));
571cdf0e10cSrcweir 
572cdf0e10cSrcweir 								// #97016# II
573cdf0e10cSrcweir 								pView->MakeVisible(pView->GetAllMarkedRect(), *pWindow);
574cdf0e10cSrcweir 
575cdf0e10cSrcweir 								bReturn = sal_True;
576cdf0e10cSrcweir 							}
577cdf0e10cSrcweir 						}
578cdf0e10cSrcweir 						else
579cdf0e10cSrcweir 						{
580cdf0e10cSrcweir 							// move handle with index nHandleIndex
581cdf0e10cSrcweir 							if(pHdl && (nX || nY))
582cdf0e10cSrcweir 							{
583cdf0e10cSrcweir 								// now move the Handle (nX, nY)
584cdf0e10cSrcweir 								Point aStartPoint(pHdl->GetPos());
585cdf0e10cSrcweir 								Point aEndPoint(pHdl->GetPos() + Point(nX, nY));
586cdf0e10cSrcweir 								const SdrDragStat& rDragStat = pView->GetDragStat();
587cdf0e10cSrcweir 
588cdf0e10cSrcweir 								// start dragging
589cdf0e10cSrcweir 								pView->BegDragObj(aStartPoint, 0, pHdl, 0);
590cdf0e10cSrcweir 
591cdf0e10cSrcweir 								if(pView->IsDragObj())
592cdf0e10cSrcweir 								{
593cdf0e10cSrcweir 									FASTBOOL bWasNoSnap = rDragStat.IsNoSnap();
594cdf0e10cSrcweir 									sal_Bool bWasSnapEnabled = pView->IsSnapEnabled();
595cdf0e10cSrcweir 
596cdf0e10cSrcweir 									// switch snapping off
597cdf0e10cSrcweir 									if(!bWasNoSnap)
598cdf0e10cSrcweir 										((SdrDragStat&)rDragStat).SetNoSnap(sal_True);
599cdf0e10cSrcweir 									if(bWasSnapEnabled)
600cdf0e10cSrcweir 										pView->SetSnapEnabled(sal_False);
601cdf0e10cSrcweir 
602cdf0e10cSrcweir 									pView->MovAction(aEndPoint);
603cdf0e10cSrcweir 									pView->EndDragObj();
604cdf0e10cSrcweir 
605cdf0e10cSrcweir 									// restore snap
606cdf0e10cSrcweir 									if(!bWasNoSnap)
607cdf0e10cSrcweir 										((SdrDragStat&)rDragStat).SetNoSnap(bWasNoSnap);
608cdf0e10cSrcweir 									if(bWasSnapEnabled)
609cdf0e10cSrcweir 										pView->SetSnapEnabled(bWasSnapEnabled);
610cdf0e10cSrcweir 								}
611cdf0e10cSrcweir 
612cdf0e10cSrcweir 								// make moved handle visible
613cdf0e10cSrcweir 								Rectangle aVisRect(aEndPoint - Point(100, 100), Size(200, 200));
614cdf0e10cSrcweir 								pView->MakeVisible(aVisRect, *pWindow);
615cdf0e10cSrcweir 
616cdf0e10cSrcweir 								bReturn = sal_True;
617cdf0e10cSrcweir 							}
618cdf0e10cSrcweir 						}
619cdf0e10cSrcweir 					}
620cdf0e10cSrcweir 				}
621cdf0e10cSrcweir 			}
622cdf0e10cSrcweir 		}
623cdf0e10cSrcweir 		break;
624cdf0e10cSrcweir 
625cdf0e10cSrcweir 		// #97016#
626cdf0e10cSrcweir 		case KEY_SPACE:
627cdf0e10cSrcweir 		{
628cdf0e10cSrcweir 			// in calc do only something when draw objects are selected
629cdf0e10cSrcweir 			if(pView->AreObjectsMarked())
630cdf0e10cSrcweir 			{
631cdf0e10cSrcweir 				const SdrHdlList& rHdlList = pView->GetHdlList();
632cdf0e10cSrcweir 				SdrHdl* pHdl = rHdlList.GetFocusHdl();
633cdf0e10cSrcweir 
634cdf0e10cSrcweir 				if(pHdl)
635cdf0e10cSrcweir 				{
636cdf0e10cSrcweir 					if(pHdl->GetKind() == HDL_POLY)
637cdf0e10cSrcweir 					{
638cdf0e10cSrcweir 						// rescue ID of point with focus
639cdf0e10cSrcweir 						sal_uInt32 nPol(pHdl->GetPolyNum());
640cdf0e10cSrcweir 						sal_uInt32 nPnt(pHdl->GetPointNum());
641cdf0e10cSrcweir 
642cdf0e10cSrcweir 						if(pView->IsPointMarked(*pHdl))
643cdf0e10cSrcweir 						{
644cdf0e10cSrcweir 							if(rKEvt.GetKeyCode().IsShift())
645cdf0e10cSrcweir 							{
646cdf0e10cSrcweir 								pView->UnmarkPoint(*pHdl);
647cdf0e10cSrcweir 							}
648cdf0e10cSrcweir 						}
649cdf0e10cSrcweir 						else
650cdf0e10cSrcweir 						{
651cdf0e10cSrcweir 							if(!rKEvt.GetKeyCode().IsShift())
652cdf0e10cSrcweir 							{
653cdf0e10cSrcweir 								pView->UnmarkAllPoints();
654cdf0e10cSrcweir 							}
655cdf0e10cSrcweir 
656cdf0e10cSrcweir 							pView->MarkPoint(*pHdl);
657cdf0e10cSrcweir 						}
658cdf0e10cSrcweir 
659cdf0e10cSrcweir 						if(0L == rHdlList.GetFocusHdl())
660cdf0e10cSrcweir 						{
661cdf0e10cSrcweir 							// restore point with focus
662cdf0e10cSrcweir 							SdrHdl* pNewOne = 0L;
663cdf0e10cSrcweir 
664cdf0e10cSrcweir 							for(sal_uInt32 a(0); !pNewOne && a < rHdlList.GetHdlCount(); a++)
665cdf0e10cSrcweir 							{
666cdf0e10cSrcweir 								SdrHdl* pAct = rHdlList.GetHdl(a);
667cdf0e10cSrcweir 
668cdf0e10cSrcweir 								if(pAct
669cdf0e10cSrcweir 									&& pAct->GetKind() == HDL_POLY
670cdf0e10cSrcweir 									&& pAct->GetPolyNum() == nPol
671cdf0e10cSrcweir 									&& pAct->GetPointNum() == nPnt)
672cdf0e10cSrcweir 								{
673cdf0e10cSrcweir 									pNewOne = pAct;
674cdf0e10cSrcweir 								}
675cdf0e10cSrcweir 							}
676cdf0e10cSrcweir 
677cdf0e10cSrcweir 							if(pNewOne)
678cdf0e10cSrcweir 							{
679cdf0e10cSrcweir 								((SdrHdlList&)rHdlList).SetFocusHdl(pNewOne);
680cdf0e10cSrcweir 							}
681cdf0e10cSrcweir 						}
682cdf0e10cSrcweir 
683cdf0e10cSrcweir 						bReturn = sal_True;
684cdf0e10cSrcweir 					}
685cdf0e10cSrcweir 				}
686cdf0e10cSrcweir 			}
687cdf0e10cSrcweir 		}
688cdf0e10cSrcweir 		break;
689cdf0e10cSrcweir 	}
690cdf0e10cSrcweir 
691cdf0e10cSrcweir 	if (!bReturn)
692cdf0e10cSrcweir 	{
693cdf0e10cSrcweir 		bReturn = FuPoor::KeyInput(rKEvt);
694cdf0e10cSrcweir 	}
695cdf0e10cSrcweir 
696cdf0e10cSrcweir 	if (!bReturn)
697cdf0e10cSrcweir 	{
698cdf0e10cSrcweir 		// #98198# allow direct typing into a selected text object
699cdf0e10cSrcweir 
700cdf0e10cSrcweir 		const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
701cdf0e10cSrcweir 		if( !pView->IsTextEdit() && 1 == rMarkList.GetMarkCount() && EditEngine::IsSimpleCharInput(rKEvt) )
702cdf0e10cSrcweir 		{
703cdf0e10cSrcweir             SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
704cdf0e10cSrcweir 
705cdf0e10cSrcweir 			// start text edit for suitable object, pass key event to OutlinerView
706cdf0e10cSrcweir 			if ( lcl_KeyEditMode( pObj, pViewShell, &rKEvt ) )
707cdf0e10cSrcweir 				bReturn = sal_True;
708cdf0e10cSrcweir 		}
709cdf0e10cSrcweir 	}
710cdf0e10cSrcweir 
711cdf0e10cSrcweir 	return (bReturn);
712cdf0e10cSrcweir }
713cdf0e10cSrcweir 
714cdf0e10cSrcweir // #97016# II
715cdf0e10cSrcweir void FuDraw::SelectionHasChanged()
716cdf0e10cSrcweir {
717cdf0e10cSrcweir 	const SdrHdlList& rHdlList = pView->GetHdlList();
718cdf0e10cSrcweir 	((SdrHdlList&)rHdlList).ResetFocusHdl();
719cdf0e10cSrcweir }
720cdf0e10cSrcweir 
721cdf0e10cSrcweir /*************************************************************************
722cdf0e10cSrcweir |*
723cdf0e10cSrcweir |* Vor dem Scrollen Selektionsdarstellung ausblenden
724cdf0e10cSrcweir |*
725cdf0e10cSrcweir \************************************************************************/
726cdf0e10cSrcweir 
727cdf0e10cSrcweir void FuDraw::ScrollStart()
728cdf0e10cSrcweir {
729cdf0e10cSrcweir //		HideShownXor in Gridwin
730cdf0e10cSrcweir }
731cdf0e10cSrcweir 
732cdf0e10cSrcweir /*************************************************************************
733cdf0e10cSrcweir |*
734cdf0e10cSrcweir |* Nach dem Scrollen Selektionsdarstellung wieder anzeigen
735cdf0e10cSrcweir |*
736cdf0e10cSrcweir \************************************************************************/
737cdf0e10cSrcweir 
738cdf0e10cSrcweir void FuDraw::ScrollEnd()
739cdf0e10cSrcweir {
740cdf0e10cSrcweir //		ShowShownXor in Gridwin
741cdf0e10cSrcweir }
742cdf0e10cSrcweir 
743cdf0e10cSrcweir /*************************************************************************
744cdf0e10cSrcweir |*
745cdf0e10cSrcweir |* Function aktivieren
746cdf0e10cSrcweir |*
747cdf0e10cSrcweir \************************************************************************/
748cdf0e10cSrcweir 
749cdf0e10cSrcweir void FuDraw::Activate()
750cdf0e10cSrcweir {
751cdf0e10cSrcweir 	FuPoor::Activate();
752cdf0e10cSrcweir }
753cdf0e10cSrcweir 
754cdf0e10cSrcweir /*************************************************************************
755cdf0e10cSrcweir |*
756cdf0e10cSrcweir |* Function deaktivieren
757cdf0e10cSrcweir |*
758cdf0e10cSrcweir \************************************************************************/
759cdf0e10cSrcweir 
760cdf0e10cSrcweir void FuDraw::Deactivate()
761cdf0e10cSrcweir {
762cdf0e10cSrcweir 	FuPoor::Deactivate();
763cdf0e10cSrcweir }
764cdf0e10cSrcweir 
765cdf0e10cSrcweir /*************************************************************************
766cdf0e10cSrcweir |*
767cdf0e10cSrcweir |* Maus-Pointer umschalten
768cdf0e10cSrcweir |*
769cdf0e10cSrcweir \************************************************************************/
770cdf0e10cSrcweir 
771cdf0e10cSrcweir sal_Bool lcl_UrlHit( SdrView* pView, const Point& rPosPixel, Window* pWindow )
772cdf0e10cSrcweir {
773cdf0e10cSrcweir 	SdrViewEvent aVEvt;
774cdf0e10cSrcweir 	MouseEvent aMEvt( rPosPixel, 1, 0, MOUSE_LEFT );
775cdf0e10cSrcweir 	SdrHitKind eHit = pView->PickAnything( aMEvt, SDRMOUSEBUTTONDOWN, aVEvt );
776cdf0e10cSrcweir 
777cdf0e10cSrcweir 	if ( eHit != SDRHIT_NONE && aVEvt.pObj != NULL )
778cdf0e10cSrcweir 	{
779cdf0e10cSrcweir 		if ( ScDrawLayer::GetIMapInfo( aVEvt.pObj ) && ScDrawLayer::GetHitIMapObject(
780cdf0e10cSrcweir 								aVEvt.pObj, pWindow->PixelToLogic(rPosPixel), *pWindow ) )
781cdf0e10cSrcweir 			return sal_True;
782cdf0e10cSrcweir 
783cdf0e10cSrcweir 		if ( aVEvt.eEvent == SDREVENT_EXECUTEURL )
784cdf0e10cSrcweir 			return sal_True;
785cdf0e10cSrcweir 	}
786cdf0e10cSrcweir 
787cdf0e10cSrcweir 	return sal_False;
788cdf0e10cSrcweir }
789cdf0e10cSrcweir 
790cdf0e10cSrcweir void FuDraw::ForcePointer(const MouseEvent* pMEvt)
791cdf0e10cSrcweir {
792cdf0e10cSrcweir 	if ( !pView->IsAction() )
793cdf0e10cSrcweir 	{
794cdf0e10cSrcweir 		Point aPosPixel = pWindow->GetPointerPosPixel();
795cdf0e10cSrcweir 		sal_Bool bAlt		= pMEvt && pMEvt->IsMod2();
796cdf0e10cSrcweir 		Point aPnt		= pWindow->PixelToLogic( aPosPixel );
797cdf0e10cSrcweir 		SdrHdl* pHdl	= pView->PickHandle(aPnt);
798cdf0e10cSrcweir 		SdrObject* pObj;
799cdf0e10cSrcweir 		SdrPageView* pPV;
800cdf0e10cSrcweir 
801cdf0e10cSrcweir         ScMacroInfo* pInfo = 0;
802cdf0e10cSrcweir         if ( pView->PickObj(aPnt, pView->getHitTolLog(), pObj, pPV, SDRSEARCH_ALSOONMASTER) )
803cdf0e10cSrcweir         {
804cdf0e10cSrcweir             if ( pObj->IsGroupObject() )
805cdf0e10cSrcweir             {
806cdf0e10cSrcweir                 SdrObject* pHit = 0;
807cdf0e10cSrcweir                 if ( pView->PickObj(aMDPos, pView->getHitTolLog(), pHit, pPV, SDRSEARCH_DEEP ) )
808cdf0e10cSrcweir                     pObj = pHit;
809cdf0e10cSrcweir             }
810cdf0e10cSrcweir             pInfo = ScDrawLayer::GetMacroInfo( pObj );
811cdf0e10cSrcweir         }
812cdf0e10cSrcweir 
813cdf0e10cSrcweir 		if ( pView->IsTextEdit() )
814cdf0e10cSrcweir 		{
815cdf0e10cSrcweir 			pViewShell->SetActivePointer(Pointer(POINTER_TEXT));		// kann nicht sein ?
816cdf0e10cSrcweir 		}
817cdf0e10cSrcweir 		else if ( pHdl )
818cdf0e10cSrcweir 		{
819cdf0e10cSrcweir 			pViewShell->SetActivePointer(
820cdf0e10cSrcweir 				pView->GetPreferedPointer( aPnt, pWindow ) );
821cdf0e10cSrcweir 		}
822cdf0e10cSrcweir 		else if ( pView->IsMarkedHit(aPnt) )
823cdf0e10cSrcweir 		{
824cdf0e10cSrcweir 			pViewShell->SetActivePointer( Pointer(POINTER_MOVE) );
825cdf0e10cSrcweir 		}
826cdf0e10cSrcweir 		else if ( !bAlt && ( !pMEvt || !pMEvt->GetButtons() )
827cdf0e10cSrcweir 						&& lcl_UrlHit( pView, aPosPixel, pWindow ) )
828cdf0e10cSrcweir 		{
829cdf0e10cSrcweir 			//	kann mit ALT unterdrueckt werden
830cdf0e10cSrcweir 			pWindow->SetPointer( Pointer( POINTER_REFHAND ) );			// Text-URL / ImageMap
831cdf0e10cSrcweir 		}
832cdf0e10cSrcweir 		else if ( !bAlt && pView->PickObj(aPnt, pView->getHitTolLog(), pObj, pPV, SDRSEARCH_PICKMACRO) )
833cdf0e10cSrcweir 		{
834cdf0e10cSrcweir 			//	kann mit ALT unterdrueckt werden
835cdf0e10cSrcweir 			SdrObjMacroHitRec aHitRec;	//! muss da noch irgendwas gesetzt werden ????
836cdf0e10cSrcweir 			pViewShell->SetActivePointer( pObj->GetMacroPointer(aHitRec) );
837cdf0e10cSrcweir 		}
838cdf0e10cSrcweir #ifdef ISSUE66550_HLINK_FOR_SHAPES
839cdf0e10cSrcweir         else if ( !bAlt && pInfo && ((pInfo->GetMacro().getLength() > 0) || (pInfo->GetHlink().getLength() > 0)) )
840cdf0e10cSrcweir #else
841cdf0e10cSrcweir         else if ( !bAlt && pInfo && (pInfo->GetMacro().getLength() > 0) )
842cdf0e10cSrcweir #endif
843cdf0e10cSrcweir 			pWindow->SetPointer( Pointer( POINTER_REFHAND ) );
844cdf0e10cSrcweir 		else if ( IsDetectiveHit( aPnt ) )
845cdf0e10cSrcweir 			pViewShell->SetActivePointer( Pointer( POINTER_DETECTIVE ) );
846cdf0e10cSrcweir 		else
847cdf0e10cSrcweir 			pViewShell->SetActivePointer( aNewPointer );			//! in Gridwin?
848cdf0e10cSrcweir 	}
849cdf0e10cSrcweir }
850cdf0e10cSrcweir 
851cdf0e10cSrcweir sal_Bool FuDraw::IsSizingOrMovingNote( const MouseEvent& rMEvt ) const
852cdf0e10cSrcweir {
853cdf0e10cSrcweir     sal_Bool bIsSizingOrMoving = sal_False;
854cdf0e10cSrcweir     if ( rMEvt.IsLeft() )
855cdf0e10cSrcweir     {
856cdf0e10cSrcweir         const SdrMarkList& rNoteMarkList = pView->GetMarkedObjectList();
857cdf0e10cSrcweir         if(rNoteMarkList.GetMarkCount() == 1)
858cdf0e10cSrcweir         {
859cdf0e10cSrcweir             SdrObject* pObj = rNoteMarkList.GetMark( 0 )->GetMarkedSdrObj();
860cdf0e10cSrcweir             if ( ScDrawLayer::IsNoteCaption( pObj ) )
861cdf0e10cSrcweir             {
862cdf0e10cSrcweir                 Point aMPos = pWindow->PixelToLogic( rMEvt.GetPosPixel() );
863cdf0e10cSrcweir                 bIsSizingOrMoving =
864cdf0e10cSrcweir                     pView->PickHandle( aMPos ) ||      // handles to resize the note
865cdf0e10cSrcweir                     pView->IsTextEditFrameHit( aMPos );         // frame for moving the note
866cdf0e10cSrcweir             }
867cdf0e10cSrcweir         }
868cdf0e10cSrcweir     }
869cdf0e10cSrcweir     return bIsSizingOrMoving;
870cdf0e10cSrcweir }
871