1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sd.hxx"
26
27 #include <sot/object.hxx>
28 #include <editeng/eeitem.hxx>
29 #include <vcl/waitobj.hxx>
30
31 #include <editeng/flditem.hxx>
32 #include <svx/svdogrp.hxx>
33 #include <tools/urlobj.hxx>
34 #include <vcl/help.hxx>
35 #include <svx/bmpmask.hxx>
36 #include <svx/svdotext.hxx>
37 #include <sfx2/app.hxx>
38 #include <sfx2/dispatch.hxx>
39 #include <sfx2/bindings.hxx>
40 #include <svx/svdpagv.hxx>
41 #include <svtools/imapobj.hxx>
42 #include <svx/svxids.hrc>
43 #include <svx/obj3d.hxx>
44 #include <svx/polysc3d.hxx>
45 #include <svx/svdpagv.hxx>
46
47 #include <sfx2/viewfrm.hxx>
48
49 #include "anminfo.hxx"
50 #include "anmdef.hxx"
51 #include "imapinfo.hxx"
52 #include "app.hrc"
53 #include "glob.hrc"
54 #include "strings.hrc"
55 #include "res_bmp.hrc"
56
57 #include "app.hxx"
58 #include "GraphicDocShell.hxx"
59 #include "fudraw.hxx"
60 #include "ViewShell.hxx"
61 #include "FrameView.hxx"
62 #include "View.hxx"
63 #ifndef SD_WINDOW_SHELL_HXX
64 #include "Window.hxx"
65 #endif
66 #include "drawdoc.hxx"
67 #include "DrawDocShell.hxx"
68 #include "Client.hxx"
69 #include "sdresid.hxx"
70 #include "drawview.hxx"
71 #include "fusel.hxx"
72 #include <svl/aeitem.hxx>
73 #include <vcl/msgbox.hxx>
74 #include "slideshow.hxx"
75 #include <svx/sdrhittesthelper.hxx>
76
77 using namespace ::com::sun::star;
78
79 namespace sd {
80
81 TYPEINIT1( FuDraw, FuPoor );
82
83 /*************************************************************************
84 |*
85 |* Base-class for all drawmodul-specific functions
86 |*
87 \************************************************************************/
88
FuDraw(ViewShell * pViewSh,::sd::Window * pWin,::sd::View * pView,SdDrawDocument * pDoc,SfxRequest & rReq)89 FuDraw::FuDraw(ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView,
90 SdDrawDocument* pDoc, SfxRequest& rReq) :
91 FuPoor(pViewSh, pWin, pView, pDoc, rReq),
92 bMBDown(sal_False),
93 bDragHelpLine(sal_False),
94 bPermanent(sal_False)
95 {
96 }
97
98 /*************************************************************************
99 |*
100 |* Destruktor
101 |*
102 \************************************************************************/
103
~FuDraw()104 FuDraw::~FuDraw()
105 {
106 mpView->BrkAction();
107 }
108
109 /*************************************************************************
110 |*
111 |* MouseButtonDown-event
112 |*
113 \************************************************************************/
114
MouseButtonDown(const MouseEvent & rMEvt)115 sal_Bool FuDraw::MouseButtonDown(const MouseEvent& rMEvt)
116 {
117 // #95491# remember button state for creation of own MouseEvents
118 SetMouseButtonCode(rMEvt.GetButtons());
119
120 sal_Bool bReturn = sal_False;
121
122 bDragHelpLine = sal_False;
123
124 aMDPos = mpWindow->PixelToLogic( rMEvt.GetPosPixel() );
125
126 if ( rMEvt.IsLeft() )
127 {
128 FrameView* pFrameView = mpViewShell->GetFrameView();
129
130 // sal_Bool bOrtho = mpView->IsOrthoDesired() || pFrameView->IsOrtho();
131 // bOrtho = bOrtho != rMEvt.IsShift();
132 sal_Bool bOrtho = sal_False;
133
134 sal_Bool bRestricted = sal_True;
135
136 if (mpView->IsDragObj())
137 {
138 // object is dragged (move, resize,...)
139 const SdrHdl* pHdl = mpView->GetDragStat().GetHdl();
140
141 if (!pHdl || (!pHdl->IsCornerHdl() && !pHdl->IsVertexHdl()))
142 {
143 // Move
144 bRestricted = sal_False;
145 }
146 }
147
148 // #i33136#
149 if(bRestricted && doConstructOrthogonal())
150 {
151 // Restrict movement:
152 // rectangle->quadrat, ellipse->circle etc.
153 bOrtho = !rMEvt.IsShift();
154 }
155 else
156 {
157 bOrtho = rMEvt.IsShift() != pFrameView->IsOrtho();
158 }
159
160 if (!mpView->IsSnapEnabled())
161 mpView->SetSnapEnabled(sal_True);
162 sal_Bool bSnapModPressed = rMEvt.IsMod1();
163
164 sal_Bool bGridSnap = pFrameView->IsGridSnap();
165 bGridSnap = (bSnapModPressed != bGridSnap);
166
167 if (mpView->IsGridSnap() != bGridSnap)
168 mpView->SetGridSnap(bGridSnap);
169
170 sal_Bool bBordSnap = pFrameView->IsBordSnap();
171 bBordSnap = (bSnapModPressed != bBordSnap);
172
173 if (mpView->IsBordSnap() != bBordSnap)
174 mpView->SetBordSnap(bBordSnap);
175
176 sal_Bool bHlplSnap = pFrameView->IsHlplSnap();
177 bHlplSnap = (bSnapModPressed != bHlplSnap);
178
179 if (mpView->IsHlplSnap() != bHlplSnap)
180 mpView->SetHlplSnap(bHlplSnap);
181
182 sal_Bool bOFrmSnap = pFrameView->IsOFrmSnap();
183 bOFrmSnap = (bSnapModPressed != bOFrmSnap);
184
185 if (mpView->IsOFrmSnap() != bOFrmSnap)
186 mpView->SetOFrmSnap(bOFrmSnap);
187
188 sal_Bool bOPntSnap = pFrameView->IsOPntSnap();
189 bOPntSnap = (bSnapModPressed != bOPntSnap);
190
191 if (mpView->IsOPntSnap() != bOPntSnap)
192 mpView->SetOPntSnap(bOPntSnap);
193
194 sal_Bool bOConSnap = pFrameView->IsOConSnap();
195 bOConSnap = (bSnapModPressed != bOConSnap);
196
197 if (mpView->IsOConSnap() != bOConSnap)
198 mpView->SetOConSnap(bOConSnap);
199
200 sal_Bool bAngleSnap = rMEvt.IsShift() == !pFrameView->IsAngleSnapEnabled();
201
202 if (mpView->IsAngleSnapEnabled() != bAngleSnap)
203 mpView->SetAngleSnapEnabled(bAngleSnap);
204
205 if (mpView->IsOrtho() != bOrtho)
206 mpView->SetOrtho(bOrtho);
207
208 sal_Bool bCenter = rMEvt.IsMod2();
209
210 if ( mpView->IsCreate1stPointAsCenter() != bCenter ||
211 mpView->IsResizeAtCenter() != bCenter )
212 {
213 mpView->SetCreate1stPointAsCenter(bCenter);
214 mpView->SetResizeAtCenter(bCenter);
215 }
216
217 SdrPageView* pPV = 0;
218 sal_uInt16 nHitLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(HITPIX,0)).Width() );
219
220 // #76572# look only for HelpLines when they are visible (!)
221 sal_Bool bHelpLine(sal_False);
222 if(mpView->IsHlplVisible())
223 bHelpLine = mpView->PickHelpLine(aMDPos, nHitLog, *mpWindow, nHelpLine, pPV);
224 sal_Bool bHitHdl = (mpView->PickHandle(aMDPos) != NULL);
225
226 if ( bHelpLine
227 && !mpView->IsCreateObj()
228 && ((mpView->GetEditMode() == SDREDITMODE_EDIT && !bHitHdl) || (rMEvt.IsShift() && bSnapModPressed)) )
229 {
230 mpWindow->CaptureMouse();
231 mpView->BegDragHelpLine(nHelpLine, pPV);
232 bDragHelpLine = mpView->IsDragHelpLine();
233 bReturn = sal_True;
234 }
235 }
236 ForcePointer(&rMEvt);
237
238 return bReturn;
239 }
240
241 /*************************************************************************
242 |*
243 |* MouseMove-event
244 |*
245 \************************************************************************/
246
MouseMove(const MouseEvent & rMEvt)247 sal_Bool FuDraw::MouseMove(const MouseEvent& rMEvt)
248 {
249 FrameView* pFrameView = mpViewShell->GetFrameView();
250 Point aPos = mpWindow->PixelToLogic( rMEvt.GetPosPixel() );
251
252 // sal_Bool bOrtho = mpView->IsOrthoDesired() || pFrameView->IsOrtho();
253 // bOrtho = bOrtho != rMEvt.IsShift();
254 sal_Bool bOrtho = sal_False;
255
256 sal_Bool bRestricted = sal_True;
257
258 if (mpView->IsDragObj())
259 {
260 // object is dragged (move, resize, ...)
261 const SdrHdl* pHdl = mpView->GetDragStat().GetHdl();
262
263 if (!pHdl || (!pHdl->IsCornerHdl() && !pHdl->IsVertexHdl()))
264 {
265 // Move
266 bRestricted = sal_False;
267 }
268 }
269
270 if (mpView->IsAction())
271 {
272 // #i33136#
273 if(bRestricted && doConstructOrthogonal())
274 {
275 // Restrict movement:
276 // rectangle->quadrat, ellipse->circle etc.
277 bOrtho = !rMEvt.IsShift();
278 }
279 else
280 {
281 bOrtho = rMEvt.IsShift() != pFrameView->IsOrtho();
282 }
283
284 sal_Bool bSnapModPressed = rMEvt.IsMod2();
285 mpView->SetDragWithCopy(rMEvt.IsMod1() && pFrameView->IsDragWithCopy());
286
287 sal_Bool bGridSnap = pFrameView->IsGridSnap();
288 bGridSnap = (bSnapModPressed != bGridSnap);
289
290 if (mpView->IsGridSnap() != bGridSnap)
291 mpView->SetGridSnap(bGridSnap);
292
293 sal_Bool bBordSnap = pFrameView->IsBordSnap();
294 bBordSnap = (bSnapModPressed != bBordSnap);
295
296 if (mpView->IsBordSnap() != bBordSnap)
297 mpView->SetBordSnap(bBordSnap);
298
299 sal_Bool bHlplSnap = pFrameView->IsHlplSnap();
300 bHlplSnap = (bSnapModPressed != bHlplSnap);
301
302 if (mpView->IsHlplSnap() != bHlplSnap)
303 mpView->SetHlplSnap(bHlplSnap);
304
305 sal_Bool bOFrmSnap = pFrameView->IsOFrmSnap();
306 bOFrmSnap = (bSnapModPressed != bOFrmSnap);
307
308 if (mpView->IsOFrmSnap() != bOFrmSnap)
309 mpView->SetOFrmSnap(bOFrmSnap);
310
311 sal_Bool bOPntSnap = pFrameView->IsOPntSnap();
312 bOPntSnap = (bSnapModPressed != bOPntSnap);
313
314 if (mpView->IsOPntSnap() != bOPntSnap)
315 mpView->SetOPntSnap(bOPntSnap);
316
317 sal_Bool bOConSnap = pFrameView->IsOConSnap();
318 bOConSnap = (bSnapModPressed != bOConSnap);
319
320 if (mpView->IsOConSnap() != bOConSnap)
321 mpView->SetOConSnap(bOConSnap);
322
323 sal_Bool bAngleSnap = rMEvt.IsShift() == !pFrameView->IsAngleSnapEnabled();
324
325 if (mpView->IsAngleSnapEnabled() != bAngleSnap)
326 mpView->SetAngleSnapEnabled(bAngleSnap);
327
328 if (mpView->IsOrtho() != bOrtho)
329 mpView->SetOrtho(bOrtho);
330
331 sal_Bool bCenter = rMEvt.IsMod2();
332
333 if ( mpView->IsCreate1stPointAsCenter() != bCenter ||
334 mpView->IsResizeAtCenter() != bCenter )
335 {
336 mpView->SetCreate1stPointAsCenter(bCenter);
337 mpView->SetResizeAtCenter(bCenter);
338 }
339
340 if ( mpView->IsDragHelpLine() )
341 mpView->MovDragHelpLine(aPos);
342 }
343
344 sal_Bool bReturn = mpView->MouseMove(rMEvt, mpWindow);
345
346 if (mpView->IsAction())
347 {
348 // Because the flag set back if necessary in MouseMove
349 if (mpView->IsOrtho() != bOrtho)
350 mpView->SetOrtho(bOrtho);
351 }
352
353 ForcePointer(&rMEvt);
354
355 return bReturn;
356 }
357
358 /*************************************************************************
359 |*
360 |* MouseButtonUp-event
361 |*
362 \************************************************************************/
363
MouseButtonUp(const MouseEvent & rMEvt)364 sal_Bool FuDraw::MouseButtonUp(const MouseEvent& rMEvt)
365 {
366 if ( mpView->IsDragHelpLine() )
367 mpView->EndDragHelpLine();
368
369 if ( bDragHelpLine )
370 {
371 Rectangle aOutputArea(Point(0,0), mpWindow->GetOutputSizePixel());
372
373 if ( !aOutputArea.IsInside(rMEvt.GetPosPixel()) )
374 mpView->GetSdrPageView()->DeleteHelpLine(nHelpLine);
375
376 mpWindow->ReleaseMouse();
377 }
378
379 FrameView* pFrameView = mpViewShell->GetFrameView();
380 mpView->SetOrtho( pFrameView->IsOrtho() );
381 mpView->SetAngleSnapEnabled( pFrameView->IsAngleSnapEnabled() );
382 mpView->SetSnapEnabled(sal_True);
383 mpView->SetCreate1stPointAsCenter(sal_False);
384 mpView->SetResizeAtCenter(sal_False);
385 mpView->SetDragWithCopy(pFrameView->IsDragWithCopy());
386 mpView->SetGridSnap(pFrameView->IsGridSnap());
387 mpView->SetBordSnap(pFrameView->IsBordSnap());
388 mpView->SetHlplSnap(pFrameView->IsHlplSnap());
389 mpView->SetOFrmSnap(pFrameView->IsOFrmSnap());
390 mpView->SetOPntSnap(pFrameView->IsOPntSnap());
391 mpView->SetOConSnap(pFrameView->IsOConSnap());
392
393 bIsInDragMode = sal_False;
394 ForcePointer(&rMEvt);
395 FuPoor::MouseButtonUp(rMEvt);
396
397 return sal_False;
398 }
399
400 /*************************************************************************
401 |*
402 |* Process keyboard-events
403 |*
404 |* When processing a KeyEvent the returnvalue is sal_True, otherwise sal_False.
405 |*
406 \************************************************************************/
407
KeyInput(const KeyEvent & rKEvt)408 sal_Bool FuDraw::KeyInput(const KeyEvent& rKEvt)
409 {
410 sal_Bool bReturn = sal_False;
411
412 switch ( rKEvt.GetKeyCode().GetCode() )
413 {
414 case KEY_ESCAPE:
415 {
416 bReturn = FuDraw::cancel();
417 }
418 break;
419
420 case KEY_DELETE:
421 case KEY_BACKSPACE:
422 {
423 if (!mpDocSh->IsReadOnly())
424 {
425 if ( mpView && mpView->IsPresObjSelected(sal_False, sal_True, sal_False, sal_True) )
426 {
427 InfoBox(mpWindow, String(SdResId(STR_ACTION_NOTPOSSIBLE) ) ).Execute();
428 }
429 else
430 {
431 // Falls IP-Client aktiv, werden die Pointer
432 // auf das OLE- und das alte Graphic-Object
433 // am SdClient zurueckgesetzt, damit bei
434 // ::SelectionHasChanged nach dem Loeschen
435 // nicht mehr versucht wird, ein Grafik-Objekt
436 // zu restaurieren, das gar nicht mehr existiert.
437 // Alle anderen OLE-Objekte sind davon nicht
438 // betroffen (KA 06.10.95)
439 OSL_ASSERT (mpViewShell->GetViewShell()!=NULL);
440 Client* pIPClient = static_cast<Client*>(
441 mpViewShell->GetViewShell()->GetIPClient());
442 if (pIPClient && pIPClient->IsObjectInPlaceActive())
443 pIPClient->SetSdrGrafObj(NULL);
444
445 // wait-mousepointer while deleting object
446 WaitObject aWait( (Window*)mpViewShell->GetActiveWindow() );
447 // delete object
448 mpView->DeleteMarked();
449 }
450 }
451 bReturn = sal_True;
452 }
453 break;
454
455 case KEY_TAB:
456 {
457 KeyCode aCode = rKEvt.GetKeyCode();
458
459 if ( !aCode.IsMod1() && !aCode.IsMod2() )
460 {
461 // #105336# Moved next line which was a bugfix itself into
462 // the scope which really does the object selection travel
463 // and thus is allowed to call SelectionHasChanged().
464
465 // Switch to FuSelect.
466 mpViewShell->GetViewFrame()->GetDispatcher()->Execute(
467 SID_OBJECT_SELECT,
468 SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
469
470 // changeover to the next object
471 if(!mpView->MarkNextObj( !aCode.IsShift() ))
472 {
473 //If there is only one object, don't do the UnmarkAlllObj() & MarkNextObj().
474 if ( mpView->GetMarkableObjCount() > 1 && mpView->AreObjectsMarked() )
475 {
476 // #97016# No next object: go over open end and
477 // get first from the other side
478 mpView->UnmarkAllObj();
479 mpView->MarkNextObj(!aCode.IsShift());
480 }
481 }
482
483 // #97016# II
484 if(mpView->AreObjectsMarked())
485 mpView->MakeVisible(mpView->GetAllMarkedRect(), *mpWindow);
486
487 bReturn = sal_True;
488 }
489 }
490 break;
491
492 case KEY_END:
493 {
494 KeyCode aCode = rKEvt.GetKeyCode();
495
496 if ( aCode.IsMod1() )
497 {
498 // #97016# mark last object
499 mpView->UnmarkAllObj();
500 mpView->MarkNextObj(sal_False);
501
502 // #97016# II
503 if(mpView->AreObjectsMarked())
504 mpView->MakeVisible(mpView->GetAllMarkedRect(), *mpWindow);
505
506 bReturn = sal_True;
507 }
508 }
509 break;
510
511 case KEY_HOME:
512 {
513 KeyCode aCode = rKEvt.GetKeyCode();
514
515 if ( aCode.IsMod1() )
516 {
517 // #97016# mark first object
518 mpView->UnmarkAllObj();
519 mpView->MarkNextObj(sal_True);
520
521 // #97016# II
522 if(mpView->AreObjectsMarked())
523 mpView->MakeVisible(mpView->GetAllMarkedRect(), *mpWindow);
524
525 bReturn = sal_True;
526 }
527 }
528 break;
529
530 default:
531 break;
532 }
533
534 if (!bReturn)
535 {
536 bReturn = FuPoor::KeyInput(rKEvt);
537 }
538 else
539 {
540 mpWindow->ReleaseMouse();
541 }
542
543 return (bReturn);
544 }
545
546 /*************************************************************************
547 |*
548 |* Fade out the selection-presentation before scrolling
549 |*
550 \************************************************************************/
551
ScrollStart()552 void FuDraw::ScrollStart()
553 {
554 }
555
556 /*************************************************************************
557 |*
558 |* After scrolling show the selection-presentation again
559 |*
560 \************************************************************************/
561
ScrollEnd()562 void FuDraw::ScrollEnd()
563 {
564 }
565
566 /*************************************************************************
567 |*
568 |* Aktivate function
569 |*
570 \************************************************************************/
571
Activate()572 void FuDraw::Activate()
573 {
574 FuPoor::Activate();
575 ForcePointer();
576 }
577
578 /*************************************************************************
579 |*
580 |* Deaktivate function
581 |*
582 \************************************************************************/
583
Deactivate()584 void FuDraw::Deactivate()
585 {
586 FuPoor::Deactivate();
587 }
588
589
590 /*************************************************************************
591 |*
592 |* Toggle mouse-pointer
593 |*
594 \************************************************************************/
595
ForcePointer(const MouseEvent * pMEvt)596 void FuDraw::ForcePointer(const MouseEvent* pMEvt)
597 {
598 Point aPnt;
599 sal_uInt16 nModifier = 0;
600 sal_Bool bLeftDown = sal_False;
601 sal_Bool bDefPointer = sal_True;
602
603 if (pMEvt)
604 {
605 aPnt = mpWindow->PixelToLogic(pMEvt->GetPosPixel());
606 nModifier = pMEvt->GetModifier();
607 bLeftDown = pMEvt->IsLeft();
608 }
609 else
610 {
611 aPnt = mpWindow->PixelToLogic(mpWindow->GetPointerPosPixel());
612 }
613
614 if (mpView->IsDragObj())
615 {
616 if (SD_MOD()->GetWaterCan() && !mpView->PickHandle(aPnt))
617 {
618 /******************************************************************
619 * Giesskannenmodus
620 ******************************************************************/
621 bDefPointer = sal_False;
622 mpWindow->SetPointer(Pointer(POINTER_FILL));
623 }
624 }
625 else
626 {
627 SdrHdl* pHdl = mpView->PickHandle(aPnt);
628
629 if (SD_MOD()->GetWaterCan() && !pHdl)
630 {
631 /******************************************************************
632 * Giesskannenmodus
633 ******************************************************************/
634 bDefPointer = sal_False;
635 mpWindow->SetPointer(Pointer(POINTER_FILL));
636 }
637 else if (!pHdl &&
638 mpViewShell->GetViewFrame()->HasChildWindow(SvxBmpMaskChildWindow::GetChildWindowId()))
639 {
640 /******************************************************************
641 * Pipettenmodus
642 ******************************************************************/
643 SvxBmpMask* pMask = (SvxBmpMask*) mpViewShell->GetViewFrame()->GetChildWindow(SvxBmpMaskChildWindow::GetChildWindowId())->GetWindow();
644
645 if (pMask && pMask->IsEyedropping())
646 {
647 bDefPointer = sal_False;
648 mpWindow->SetPointer(Pointer(POINTER_REFHAND));
649 }
650 }
651 else if (!mpView->IsAction())
652 {
653 SdrObject* pObj = NULL;
654 SdrPageView* pPV = NULL;
655 SdrViewEvent aVEvt;
656 SdrHitKind eHit = SDRHIT_NONE;
657 SdrDragMode eDragMode = mpView->GetDragMode();
658
659 if (pMEvt)
660 {
661 eHit = mpView->PickAnything(*pMEvt, SDRMOUSEMOVE, aVEvt);
662 }
663
664 if ((eDragMode == SDRDRAG_ROTATE) && (eHit == SDRHIT_MARKEDOBJECT))
665 {
666 // The goal of this request is show always the rotation-arrow for 3D-objects at rotation-modus
667 // Independent of the settings at Extras->Optionen->Grafik "Objekte immer verschieben"
668 // 2D-objects acquit in an other way. Otherwise, the rotation of 3d-objects around any axises
669 // wouldn't be possible per default.
670 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
671 SdrObject* pObject = rMarkList.GetMark(0)->GetMarkedSdrObj();
672 if ((pObject->ISA(E3dObject)) && (rMarkList.GetMarkCount() == 1))
673 {
674 mpWindow->SetPointer(Pointer(POINTER_ROTATE));
675 bDefPointer = sal_False; // Otherwise it'll be calles Joes routine and the mousepointer will reconfigurate again
676 }
677 }
678
679 if (eHit == SDRHIT_NONE)
680 {
681 // found nothing -> look after at the masterpage
682 mpView->PickObj(aPnt, mpView->getHitTolLog(), pObj, pPV, SDRSEARCH_ALSOONMASTER);
683 }
684 else if (eHit == SDRHIT_UNMARKEDOBJECT)
685 {
686 pObj = aVEvt.pObj;
687 }
688 else if (eHit == SDRHIT_TEXTEDITOBJ && this->ISA(FuSelection))
689 {
690 sal_uInt16 nSdrObjKind = aVEvt.pObj->GetObjIdentifier();
691
692 if ( nSdrObjKind != OBJ_TEXT &&
693 nSdrObjKind != OBJ_TITLETEXT &&
694 nSdrObjKind != OBJ_OUTLINETEXT &&
695 aVEvt.pObj->IsEmptyPresObj() )
696 {
697 pObj = NULL;
698 bDefPointer = sal_False;
699 mpWindow->SetPointer(Pointer(POINTER_ARROW));
700 }
701 }
702
703 if (pObj && pMEvt && !pMEvt->IsMod2() && this->ISA(FuSelection))
704 {
705 // Auf Animation oder ImageMap pruefen
706 bDefPointer = !SetPointer(pObj, aPnt);
707
708 if (bDefPointer && (pObj->ISA(SdrObjGroup) || pObj->ISA(E3dPolyScene)))
709 {
710 // In die Gruppe hineinschauen
711 if (mpView->PickObj(aPnt, mpView->getHitTolLog(), pObj, pPV, SDRSEARCH_ALSOONMASTER | SDRSEARCH_DEEP))
712 bDefPointer = !SetPointer(pObj, aPnt);
713 }
714 }
715 }
716 }
717
718 if (bDefPointer)
719 {
720 mpWindow->SetPointer(mpView->GetPreferedPointer(
721 aPnt, mpWindow, nModifier, bLeftDown));
722 }
723 }
724
725 /*************************************************************************
726 |*
727 |* Set cursor for animaton or imagemap
728 |*
729 \************************************************************************/
730
SetPointer(SdrObject * pObj,const Point & rPos)731 sal_Bool FuDraw::SetPointer(SdrObject* pObj, const Point& rPos)
732 {
733 sal_Bool bSet = sal_False;
734
735 sal_Bool bAnimationInfo = (!mpDocSh->ISA(GraphicDocShell) &&
736 mpDoc->GetAnimationInfo(pObj)) ? sal_True:sal_False;
737
738 sal_Bool bImageMapInfo = sal_False;
739
740 if (!bAnimationInfo)
741 bImageMapInfo = mpDoc->GetIMapInfo(pObj) ? sal_True:sal_False;
742
743 if (bAnimationInfo || bImageMapInfo)
744 {
745 const SetOfByte* pVisiLayer = &mpView->GetSdrPageView()->GetVisibleLayers();
746 sal_uInt16 nHitLog(sal_uInt16 (mpWindow->PixelToLogic(Size(HITPIX,0)).Width()));
747 long n2HitLog(nHitLog * 2);
748 Point aHitPosR(rPos);
749 Point aHitPosL(rPos);
750 Point aHitPosT(rPos);
751 Point aHitPosB(rPos);
752
753 aHitPosR.X() += n2HitLog;
754 aHitPosL.X() -= n2HitLog;
755 aHitPosT.Y() += n2HitLog;
756 aHitPosB.Y() -= n2HitLog;
757
758 if ( !pObj->IsClosedObj() ||
759 ( SdrObjectPrimitiveHit(*pObj, aHitPosR, nHitLog, *mpView->GetSdrPageView(), pVisiLayer, false) &&
760 SdrObjectPrimitiveHit(*pObj, aHitPosL, nHitLog, *mpView->GetSdrPageView(), pVisiLayer, false) &&
761 SdrObjectPrimitiveHit(*pObj, aHitPosT, nHitLog, *mpView->GetSdrPageView(), pVisiLayer, false) &&
762 SdrObjectPrimitiveHit(*pObj, aHitPosB, nHitLog, *mpView->GetSdrPageView(), pVisiLayer, false)))
763 {
764 /**********************************************************
765 * hit inside the object (without margin) or open object
766 ********************************************************/
767
768 if (bAnimationInfo)
769 {
770 /******************************************************
771 * Click-Action
772 ******************************************************/
773 SdAnimationInfo* pInfo = mpDoc->GetAnimationInfo(pObj);
774
775 if ((mpView->ISA(DrawView) &&
776 (pInfo->meClickAction == presentation::ClickAction_BOOKMARK ||
777 pInfo->meClickAction == presentation::ClickAction_DOCUMENT ||
778 pInfo->meClickAction == presentation::ClickAction_PREVPAGE ||
779 pInfo->meClickAction == presentation::ClickAction_NEXTPAGE ||
780 pInfo->meClickAction == presentation::ClickAction_FIRSTPAGE ||
781 pInfo->meClickAction == presentation::ClickAction_LASTPAGE ||
782 pInfo->meClickAction == presentation::ClickAction_VERB ||
783 pInfo->meClickAction == presentation::ClickAction_PROGRAM ||
784 pInfo->meClickAction == presentation::ClickAction_MACRO ||
785 pInfo->meClickAction == presentation::ClickAction_SOUND))
786 ||
787 (mpView->ISA(DrawView) &&
788 SlideShow::IsRunning( mpViewShell->GetViewShellBase() ) &&
789 (pInfo->meClickAction == presentation::ClickAction_VANISH ||
790 pInfo->meClickAction == presentation::ClickAction_INVISIBLE ||
791 pInfo->meClickAction == presentation::ClickAction_STOPPRESENTATION ||
792 (pInfo->mbActive &&
793 ( pInfo->meEffect != presentation::AnimationEffect_NONE ||
794 pInfo->meTextEffect != presentation::AnimationEffect_NONE )))))
795 {
796 // Animations-Objekt
797 bSet = sal_True;
798 mpWindow->SetPointer(Pointer(POINTER_REFHAND));
799 }
800 }
801 else if (bImageMapInfo &&
802 mpDoc->GetHitIMapObject(pObj, rPos, *mpWindow))
803 {
804 /******************************************************
805 * ImageMap
806 ******************************************************/
807 bSet = sal_True;
808 mpWindow->SetPointer(Pointer(POINTER_REFHAND));
809 }
810 }
811 }
812
813 return bSet;
814 }
815
816
817
818 /*************************************************************************
819 |*
820 |* Response of doubleclick
821 |*
822 \************************************************************************/
823
DoubleClick(const MouseEvent & rMEvt)824 void FuDraw::DoubleClick(const MouseEvent& rMEvt)
825 {
826 sal_uInt16 nHitLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(HITPIX,0)).Width() );
827
828 if ( mpView->AreObjectsMarked() )
829 {
830 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
831
832 if (rMarkList.GetMarkCount() == 1)
833 {
834 SdrMark* pMark = rMarkList.GetMark(0);
835 SdrObject* pObj = pMark->GetMarkedSdrObj();
836
837 sal_uInt32 nInv = pObj->GetObjInventor();
838 sal_uInt16 nSdrObjKind = pObj->GetObjIdentifier();
839
840 if (nInv == SdrInventor && nSdrObjKind == OBJ_OLE2)
841 {
842 DrawDocShell* pDocSh = mpDoc->GetDocSh();
843
844 if ( !pDocSh->IsUIActive() )
845 {
846 /**********************************************************
847 * aktivate OLE-object
848 **********************************************************/
849 //HMHmpView->HideMarkHdl();
850 mpViewShell->ActivateObject( (SdrOle2Obj*) pObj, 0);
851 }
852 }
853 else if (nInv == SdrInventor && nSdrObjKind == OBJ_GRAF && pObj->IsEmptyPresObj() )
854 {
855 mpViewShell->GetViewFrame()->
856 GetDispatcher()->Execute( SID_INSERT_GRAPHIC,
857 SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD );
858 }
859 else if ( ( pObj->ISA(SdrTextObj) || pObj->ISA(SdrObjGroup) ) &&
860 !SD_MOD()->GetWaterCan() &&
861 mpViewShell->GetFrameView()->IsDoubleClickTextEdit() &&
862 !mpDocSh->IsReadOnly())
863 {
864 SfxUInt16Item aItem(SID_TEXTEDIT, 2);
865 mpViewShell->GetViewFrame()->GetDispatcher()->
866 Execute(SID_TEXTEDIT, SFX_CALLMODE_ASYNCHRON |
867 SFX_CALLMODE_RECORD, &aItem, 0L);
868 }
869 else if (nInv == SdrInventor && nSdrObjKind == OBJ_GRUP)
870 {
871 // hit group -> select subobject
872 mpView->UnMarkAll();
873 mpView->MarkObj(aMDPos, nHitLog, rMEvt.IsShift(), sal_True);
874 }
875 }
876 }
877 else
878 mpViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
879 }
880
881 /*************************************************************************
882 |*
883 |* Help-event
884 |*
885 \************************************************************************/
886
RequestHelp(const HelpEvent & rHEvt)887 sal_Bool FuDraw::RequestHelp(const HelpEvent& rHEvt)
888 {
889 sal_Bool bReturn = sal_False;
890
891 if (Help::IsBalloonHelpEnabled() || Help::IsQuickHelpEnabled())
892 {
893 SdrViewEvent aVEvt;
894
895 MouseEvent aMEvt(mpWindow->GetPointerPosPixel(), 1, 0, MOUSE_LEFT);
896
897 SdrHitKind eHit = mpView->PickAnything(aMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
898
899 SdrObject* pObj = aVEvt.pObj;
900
901 if (eHit != SDRHIT_NONE && pObj != NULL)
902 {
903 Point aPosPixel = rHEvt.GetMousePosPixel();
904
905 bReturn = SetHelpText(pObj, aPosPixel, aVEvt);
906
907 if (!bReturn && (pObj->ISA(SdrObjGroup) || pObj->ISA(E3dPolyScene)))
908 {
909 // In die Gruppe hineinschauen
910 SdrPageView* pPV = NULL;
911
912 Point aPos(mpWindow->PixelToLogic(mpWindow->ScreenToOutputPixel(aPosPixel)));
913
914 if (mpView->PickObj(aPos, mpView->getHitTolLog(), pObj, pPV, SDRSEARCH_ALSOONMASTER | SDRSEARCH_DEEP))
915 bReturn = SetHelpText(pObj, aPosPixel, aVEvt);
916 }
917 }
918 }
919
920 if (!bReturn)
921 {
922 bReturn = FuPoor::RequestHelp(rHEvt);
923 }
924
925 return(bReturn);
926 }
927
928
929
930 /*************************************************************************
931 |*
932 |* Command-event
933 |*
934 \************************************************************************/
935
SetHelpText(SdrObject * pObj,const Point & rPosPixel,const SdrViewEvent & rVEvt)936 sal_Bool FuDraw::SetHelpText(SdrObject* pObj, const Point& rPosPixel, const SdrViewEvent& rVEvt)
937 {
938 sal_Bool bSet = sal_False;
939 String aHelpText;
940 Point aPos(mpWindow->PixelToLogic(mpWindow->ScreenToOutputPixel(rPosPixel)));
941
942 // URL fuer IMapObject unter Pointer ist Hilfetext
943 if ( mpDoc->GetIMapInfo(pObj) )
944 {
945 IMapObject* pIMapObj = mpDoc->GetHitIMapObject(pObj, aPos, *mpWindow );
946
947 if ( pIMapObj )
948 {
949 // show name
950 aHelpText = pIMapObj->GetAltText();
951
952 if (aHelpText.Len() == 0)
953 {
954 // show url if no name is available
955 aHelpText = INetURLObject::decode( pIMapObj->GetURL(), '%', INetURLObject::DECODE_WITH_CHARSET );
956 }
957 }
958 }
959 else if (!mpDocSh->ISA(GraphicDocShell) && mpDoc->GetAnimationInfo(pObj))
960 {
961 SdAnimationInfo* pInfo = mpDoc->GetAnimationInfo(pObj);
962
963 switch (pInfo->meClickAction)
964 {
965 case presentation::ClickAction_PREVPAGE:
966 {
967 // jump to the prior page
968 aHelpText = String(SdResId(STR_CLICK_ACTION_PREVPAGE));
969 }
970 break;
971
972 case presentation::ClickAction_NEXTPAGE:
973 {
974 // jump to the next page
975 aHelpText = String(SdResId(STR_CLICK_ACTION_NEXTPAGE));
976 }
977 break;
978
979 case presentation::ClickAction_FIRSTPAGE:
980 {
981 // jump to the first page
982 aHelpText = String(SdResId(STR_CLICK_ACTION_FIRSTPAGE));
983 }
984 break;
985
986 case presentation::ClickAction_LASTPAGE:
987 {
988 // jump to the last page
989 aHelpText = String(SdResId(STR_CLICK_ACTION_LASTPAGE));
990 }
991 break;
992
993 case presentation::ClickAction_BOOKMARK:
994 {
995 // jump to object/page
996 aHelpText = String(SdResId(STR_CLICK_ACTION_BOOKMARK));
997 aHelpText.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": " ) );
998 aHelpText.Append( String(INetURLObject::decode( pInfo->GetBookmark(), '%', INetURLObject::DECODE_WITH_CHARSET ) ));
999 }
1000 break;
1001
1002 case presentation::ClickAction_DOCUMENT:
1003 {
1004 // jump to document (object/page)
1005 aHelpText = String(SdResId(STR_CLICK_ACTION_DOCUMENT));
1006 aHelpText.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": " ) );
1007 aHelpText.Append( String(INetURLObject::decode( pInfo->GetBookmark(), '%', INetURLObject::DECODE_WITH_CHARSET ) ));
1008 }
1009 break;
1010
1011 case presentation::ClickAction_PROGRAM:
1012 {
1013 // execute program
1014 aHelpText = String(SdResId(STR_CLICK_ACTION_PROGRAM));
1015 aHelpText.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": " ) );
1016 aHelpText.Append( String(INetURLObject::decode( pInfo->GetBookmark(), '%', INetURLObject::DECODE_WITH_CHARSET ) ));
1017 }
1018 break;
1019
1020 case presentation::ClickAction_MACRO:
1021 {
1022 // execute program
1023 aHelpText = String(SdResId(STR_CLICK_ACTION_MACRO));
1024 aHelpText.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": " ) );
1025
1026 if ( SfxApplication::IsXScriptURL( pInfo->GetBookmark() ) )
1027 {
1028 aHelpText.Append( pInfo->GetBookmark() );
1029 }
1030 else
1031 {
1032 String sBookmark( pInfo->GetBookmark() );
1033 sal_Unicode cToken = '.';
1034 aHelpText.Append( sBookmark.GetToken( 2, cToken ) );
1035 aHelpText.Append( cToken );
1036 aHelpText.Append( sBookmark.GetToken( 1, cToken ) );
1037 aHelpText.Append( cToken );
1038 aHelpText.Append( sBookmark.GetToken( 0, cToken ) );
1039 }
1040 }
1041 break;
1042
1043 case presentation::ClickAction_SOUND:
1044 {
1045 // play-back sound
1046 aHelpText = String(SdResId(STR_CLICK_ACTION_SOUND));
1047 }
1048 break;
1049
1050 case presentation::ClickAction_VERB:
1051 {
1052 // execute OLE-verb
1053 aHelpText = String(SdResId(STR_CLICK_ACTION_VERB));
1054 }
1055 break;
1056
1057 case presentation::ClickAction_STOPPRESENTATION:
1058 {
1059 // quit presentation
1060 aHelpText = String(SdResId(STR_CLICK_ACTION_STOPPRESENTATION));
1061 }
1062 break;
1063 default:
1064 break;
1065 }
1066 }
1067 else if (rVEvt.pURLField)
1068 {
1069 /**************************************************************
1070 * URL-Field
1071 **************************************************************/
1072 aHelpText = INetURLObject::decode( rVEvt.pURLField->GetURL(), '%', INetURLObject::DECODE_WITH_CHARSET );
1073 }
1074
1075 if (aHelpText.Len())
1076 {
1077 bSet = sal_True;
1078 Rectangle aLogicPix = mpWindow->LogicToPixel(pObj->GetLogicRect());
1079 Rectangle aScreenRect(mpWindow->OutputToScreenPixel(aLogicPix.TopLeft()),
1080 mpWindow->OutputToScreenPixel(aLogicPix.BottomRight()));
1081
1082 if (Help::IsBalloonHelpEnabled())
1083 Help::ShowBalloon( (Window*)mpWindow, rPosPixel, aScreenRect, aHelpText);
1084 else if (Help::IsQuickHelpEnabled())
1085 Help::ShowQuickHelp( (Window*)mpWindow, aScreenRect, aHelpText);
1086 }
1087
1088 return bSet;
1089 }
1090
1091
1092 /** is called when the currenct function should be aborted. <p>
1093 This is used when a function gets a KEY_ESCAPE but can also
1094 be called directly.
1095
1096 @returns true if a active function was aborted
1097 */
cancel()1098 bool FuDraw::cancel()
1099 {
1100 bool bReturn = false;
1101
1102 if ( mpView->IsAction() )
1103 {
1104 mpView->BrkAction();
1105 bReturn = true;
1106 }
1107 else if ( mpView->IsTextEdit() )
1108 {
1109 mpView->SdrEndTextEdit();
1110 bReturn = true;
1111
1112 SfxBindings& rBindings = mpViewShell->GetViewFrame()->GetBindings();
1113 rBindings.Invalidate( SID_PARASPACE_INCREASE );
1114 rBindings.Invalidate( SID_PARASPACE_DECREASE );
1115 }
1116 else if ( mpView->AreObjectsMarked() )
1117 {
1118 // #97016# II
1119 const SdrHdlList& rHdlList = mpView->GetHdlList();
1120 SdrHdl* pHdl = rHdlList.GetFocusHdl();
1121
1122 if(pHdl)
1123 {
1124 ((SdrHdlList&)rHdlList).ResetFocusHdl();
1125 }
1126 else
1127 {
1128 mpView->UnmarkAll();
1129 }
1130
1131 // Switch to FuSelect.
1132 mpViewShell->GetViewFrame()->GetDispatcher()->Execute(
1133 SID_OBJECT_SELECT,
1134 SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
1135
1136 bReturn = true;
1137 }
1138
1139 return bReturn;
1140 }
1141
1142 } // end of namespace sd
1143