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