merge the formfield patch from ooo-build
[ooovba.git] / sd / source / ui / func / fudraw.cxx
blobd90d63699865f7462737575f6776494865a7fc60
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: fudraw.cxx,v $
10 * $Revision: 1.35 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
34 #include <sot/object.hxx>
35 #include <svx/eeitem.hxx>
36 #include <vcl/waitobj.hxx>
38 #include <svx/flditem.hxx>
39 #include <svx/svdogrp.hxx>
40 #include <tools/urlobj.hxx>
41 #include <vcl/help.hxx>
42 #include <svx/bmpmask.hxx>
43 #include <svx/svdotext.hxx>
44 #include <sfx2/app.hxx>
45 #include <sfx2/dispatch.hxx>
46 #include <sfx2/bindings.hxx>
47 #include <svx/svdpagv.hxx>
48 #include <svtools/imapobj.hxx>
49 #include <svx/svxids.hrc>
50 #include <svx/obj3d.hxx>
51 #include <svx/polysc3d.hxx>
52 #include <svx/svdpagv.hxx>
54 #include <sfx2/viewfrm.hxx>
55 #include <com/sun/star/embed/EmbedVerbs.hpp>
57 #include "anminfo.hxx"
58 #include "anmdef.hxx"
59 #include "imapinfo.hxx"
60 #include "app.hrc"
61 #include "glob.hrc"
62 #include "strings.hrc"
63 #include "res_bmp.hrc"
65 #include "app.hxx"
66 #include "GraphicDocShell.hxx"
67 #include "fudraw.hxx"
68 #include "ViewShell.hxx"
69 #include "FrameView.hxx"
70 #include "View.hxx"
71 #ifndef SD_WINDOW_SHELL_HXX
72 #include "Window.hxx"
73 #endif
74 #include "drawdoc.hxx"
75 #include "DrawDocShell.hxx"
76 #include "Client.hxx"
77 #include "sdresid.hxx"
78 #include "drawview.hxx"
79 #include "fusel.hxx"
80 #include <svtools/aeitem.hxx>
81 #include <vcl/msgbox.hxx>
82 #include "slideshow.hxx"
83 #include <svx/sdrhittesthelper.hxx>
85 using namespace ::com::sun::star;
87 namespace sd {
89 TYPEINIT1( FuDraw, FuPoor );
91 /*************************************************************************
93 |* Base-class for all drawmodul-specific functions
95 \************************************************************************/
97 FuDraw::FuDraw(ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView,
98 SdDrawDocument* pDoc, SfxRequest& rReq) :
99 FuPoor(pViewSh, pWin, pView, pDoc, rReq),
100 bMBDown(FALSE),
101 bDragHelpLine(FALSE),
102 bPermanent(FALSE)
106 FunctionReference FuDraw::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq, bool bPermanent )
108 FuDraw* pFunc;
109 FunctionReference xFunc( pFunc = new FuDraw( pViewSh, pWin, pView, pDoc, rReq ) );
110 pFunc->SetPermanent(bPermanent);
111 return xFunc;
114 /*************************************************************************
116 |* Destruktor
118 \************************************************************************/
120 FuDraw::~FuDraw()
122 mpView->BrkAction();
125 /*************************************************************************
127 |* MouseButtonDown-event
129 \************************************************************************/
131 BOOL FuDraw::MouseButtonDown(const MouseEvent& rMEvt)
133 // #95491# remember button state for creation of own MouseEvents
134 SetMouseButtonCode(rMEvt.GetButtons());
136 BOOL bReturn = FALSE;
138 bDragHelpLine = FALSE;
140 aMDPos = mpWindow->PixelToLogic( rMEvt.GetPosPixel() );
142 if ( rMEvt.IsLeft() )
144 FrameView* pFrameView = mpViewShell->GetFrameView();
146 // BOOL bOrtho = mpView->IsOrthoDesired() || pFrameView->IsOrtho();
147 // bOrtho = bOrtho != rMEvt.IsShift();
148 BOOL bOrtho = FALSE;
150 BOOL bRestricted = TRUE;
152 if (mpView->IsDragObj())
154 // object is dragged (move, resize,...)
155 const SdrHdl* pHdl = mpView->GetDragStat().GetHdl();
157 if (!pHdl || (!pHdl->IsCornerHdl() && !pHdl->IsVertexHdl()))
159 // Move
160 bRestricted = FALSE;
164 // #i33136#
165 if(bRestricted && doConstructOrthogonal())
167 // Restrict movement:
168 // rectangle->quadrat, ellipse->circle etc.
169 bOrtho = !rMEvt.IsShift();
171 else
173 bOrtho = rMEvt.IsShift() != pFrameView->IsOrtho();
176 if (!mpView->IsSnapEnabled())
177 mpView->SetSnapEnabled(TRUE);
178 BOOL bCntrl = rMEvt.IsMod1();
180 BOOL bGridSnap = pFrameView->IsGridSnap();
181 bGridSnap = (bCntrl != bGridSnap);
183 if (mpView->IsGridSnap() != bGridSnap)
184 mpView->SetGridSnap(bGridSnap);
186 BOOL bBordSnap = pFrameView->IsBordSnap();
187 bBordSnap = (bCntrl != bBordSnap);
189 if (mpView->IsBordSnap() != bBordSnap)
190 mpView->SetBordSnap(bBordSnap);
192 BOOL bHlplSnap = pFrameView->IsHlplSnap();
193 bHlplSnap = (bCntrl != bHlplSnap);
195 if (mpView->IsHlplSnap() != bHlplSnap)
196 mpView->SetHlplSnap(bHlplSnap);
198 BOOL bOFrmSnap = pFrameView->IsOFrmSnap();
199 bOFrmSnap = (bCntrl != bOFrmSnap);
201 if (mpView->IsOFrmSnap() != bOFrmSnap)
202 mpView->SetOFrmSnap(bOFrmSnap);
204 BOOL bOPntSnap = pFrameView->IsOPntSnap();
205 bOPntSnap = (bCntrl != bOPntSnap);
207 if (mpView->IsOPntSnap() != bOPntSnap)
208 mpView->SetOPntSnap(bOPntSnap);
210 BOOL bOConSnap = pFrameView->IsOConSnap();
211 bOConSnap = (bCntrl != bOConSnap);
213 if (mpView->IsOConSnap() != bOConSnap)
214 mpView->SetOConSnap(bOConSnap);
216 BOOL bAngleSnap = rMEvt.IsShift() == !pFrameView->IsAngleSnapEnabled();
218 if (mpView->IsAngleSnapEnabled() != bAngleSnap)
219 mpView->SetAngleSnapEnabled(bAngleSnap);
221 if (mpView->IsOrtho() != bOrtho)
222 mpView->SetOrtho(bOrtho);
224 BOOL bCenter = rMEvt.IsMod2();
226 if ( mpView->IsCreate1stPointAsCenter() != bCenter ||
227 mpView->IsResizeAtCenter() != bCenter )
229 mpView->SetCreate1stPointAsCenter(bCenter);
230 mpView->SetResizeAtCenter(bCenter);
233 SdrPageView* pPV = 0;
234 USHORT nHitLog = USHORT ( mpWindow->PixelToLogic(Size(HITPIX,0)).Width() );
236 // #76572# look only for HelpLines when they are visible (!)
237 BOOL bHelpLine(FALSE);
238 if(mpView->IsHlplVisible())
239 bHelpLine = mpView->PickHelpLine(aMDPos, nHitLog, *mpWindow, nHelpLine, pPV);
240 BOOL bHitHdl = (mpView->PickHandle(aMDPos) != NULL);
242 if ( bHelpLine
243 && !mpView->IsCreateObj()
244 && ((mpView->GetEditMode() == SDREDITMODE_EDIT && !bHitHdl) || (rMEvt.IsShift() && bCntrl)) )
246 mpWindow->CaptureMouse();
247 mpView->BegDragHelpLine(nHelpLine, pPV);
248 bDragHelpLine = mpView->IsDragHelpLine();
249 bReturn = TRUE;
252 ForcePointer(&rMEvt);
254 return bReturn;
257 /*************************************************************************
259 |* MouseMove-event
261 \************************************************************************/
263 BOOL FuDraw::MouseMove(const MouseEvent& rMEvt)
265 FrameView* pFrameView = mpViewShell->GetFrameView();
266 Point aPos = mpWindow->PixelToLogic( rMEvt.GetPosPixel() );
268 // BOOL bOrtho = mpView->IsOrthoDesired() || pFrameView->IsOrtho();
269 // bOrtho = bOrtho != rMEvt.IsShift();
270 BOOL bOrtho = FALSE;
272 BOOL bRestricted = TRUE;
274 if (mpView->IsDragObj())
276 // object is dragged (move, resize, ...)
277 const SdrHdl* pHdl = mpView->GetDragStat().GetHdl();
279 if (!pHdl || (!pHdl->IsCornerHdl() && !pHdl->IsVertexHdl()))
281 // Move
282 bRestricted = FALSE;
286 if (mpView->IsAction())
288 // #i33136#
289 if(bRestricted && doConstructOrthogonal())
291 // Restrict movement:
292 // rectangle->quadrat, ellipse->circle etc.
293 bOrtho = !rMEvt.IsShift();
295 else
297 bOrtho = rMEvt.IsShift() != pFrameView->IsOrtho();
300 BOOL bCntrl = rMEvt.IsMod1();
301 mpView->SetDragWithCopy(rMEvt.IsMod1() && pFrameView->IsDragWithCopy());
303 BOOL bGridSnap = pFrameView->IsGridSnap();
304 bGridSnap = (bCntrl != bGridSnap);
306 if (mpView->IsGridSnap() != bGridSnap)
307 mpView->SetGridSnap(bGridSnap);
309 BOOL bBordSnap = pFrameView->IsBordSnap();
310 bBordSnap = (bCntrl != bBordSnap);
312 if (mpView->IsBordSnap() != bBordSnap)
313 mpView->SetBordSnap(bBordSnap);
315 BOOL bHlplSnap = pFrameView->IsHlplSnap();
316 bHlplSnap = (bCntrl != bHlplSnap);
318 if (mpView->IsHlplSnap() != bHlplSnap)
319 mpView->SetHlplSnap(bHlplSnap);
321 BOOL bOFrmSnap = pFrameView->IsOFrmSnap();
322 bOFrmSnap = (bCntrl != bOFrmSnap);
324 if (mpView->IsOFrmSnap() != bOFrmSnap)
325 mpView->SetOFrmSnap(bOFrmSnap);
327 BOOL bOPntSnap = pFrameView->IsOPntSnap();
328 bOPntSnap = (bCntrl != bOPntSnap);
330 if (mpView->IsOPntSnap() != bOPntSnap)
331 mpView->SetOPntSnap(bOPntSnap);
333 BOOL bOConSnap = pFrameView->IsOConSnap();
334 bOConSnap = (bCntrl != bOConSnap);
336 if (mpView->IsOConSnap() != bOConSnap)
337 mpView->SetOConSnap(bOConSnap);
339 BOOL bAngleSnap = rMEvt.IsShift() == !pFrameView->IsAngleSnapEnabled();
341 if (mpView->IsAngleSnapEnabled() != bAngleSnap)
342 mpView->SetAngleSnapEnabled(bAngleSnap);
344 if (mpView->IsOrtho() != bOrtho)
345 mpView->SetOrtho(bOrtho);
347 BOOL bCenter = rMEvt.IsMod2();
349 if ( mpView->IsCreate1stPointAsCenter() != bCenter ||
350 mpView->IsResizeAtCenter() != bCenter )
352 mpView->SetCreate1stPointAsCenter(bCenter);
353 mpView->SetResizeAtCenter(bCenter);
356 if ( mpView->IsDragHelpLine() )
357 mpView->MovDragHelpLine(aPos);
360 BOOL bReturn = mpView->MouseMove(rMEvt, mpWindow);
362 if (mpView->IsAction())
364 // Because the flag set back if necessary in MouseMove
365 if (mpView->IsOrtho() != bOrtho)
366 mpView->SetOrtho(bOrtho);
369 ForcePointer(&rMEvt);
371 return bReturn;
374 /*************************************************************************
376 |* MouseButtonUp-event
378 \************************************************************************/
380 BOOL FuDraw::MouseButtonUp(const MouseEvent& rMEvt)
382 if ( mpView->IsDragHelpLine() )
383 mpView->EndDragHelpLine();
385 if ( bDragHelpLine )
387 Rectangle aOutputArea(Point(0,0), mpWindow->GetOutputSizePixel());
389 if ( !aOutputArea.IsInside(rMEvt.GetPosPixel()) )
390 mpView->GetSdrPageView()->DeleteHelpLine(nHelpLine);
392 mpWindow->ReleaseMouse();
395 FrameView* pFrameView = mpViewShell->GetFrameView();
396 mpView->SetOrtho( pFrameView->IsOrtho() );
397 mpView->SetAngleSnapEnabled( pFrameView->IsAngleSnapEnabled() );
398 mpView->SetSnapEnabled(TRUE);
399 mpView->SetCreate1stPointAsCenter(FALSE);
400 mpView->SetResizeAtCenter(FALSE);
401 mpView->SetDragWithCopy(pFrameView->IsDragWithCopy());
402 mpView->SetGridSnap(pFrameView->IsGridSnap());
403 mpView->SetBordSnap(pFrameView->IsBordSnap());
404 mpView->SetHlplSnap(pFrameView->IsHlplSnap());
405 mpView->SetOFrmSnap(pFrameView->IsOFrmSnap());
406 mpView->SetOPntSnap(pFrameView->IsOPntSnap());
407 mpView->SetOConSnap(pFrameView->IsOConSnap());
409 bIsInDragMode = FALSE;
410 ForcePointer(&rMEvt);
411 FuPoor::MouseButtonUp(rMEvt);
413 return FALSE;
416 /*************************************************************************
418 |* Process keyboard-events
420 |* When processing a KeyEvent the returnvalue is TRUE, otherwise FALSE.
422 \************************************************************************/
424 BOOL FuDraw::KeyInput(const KeyEvent& rKEvt)
426 BOOL bReturn = FALSE;
428 switch ( rKEvt.GetKeyCode().GetCode() )
430 case KEY_ESCAPE:
432 bReturn = FuDraw::cancel();
434 break;
436 case KEY_DELETE:
437 case KEY_BACKSPACE:
439 if (!mpDocSh->IsReadOnly())
441 if ( mpView && mpView->IsPresObjSelected(FALSE, TRUE, FALSE, TRUE) )
443 InfoBox(mpWindow, String(SdResId(STR_ACTION_NOTPOSSIBLE) ) ).Execute();
445 else
447 // Falls IP-Client aktiv, werden die Pointer
448 // auf das OLE- und das alte Graphic-Object
449 // am SdClient zurueckgesetzt, damit bei
450 // ::SelectionHasChanged nach dem Loeschen
451 // nicht mehr versucht wird, ein Grafik-Objekt
452 // zu restaurieren, das gar nicht mehr existiert.
453 // Alle anderen OLE-Objekte sind davon nicht
454 // betroffen (KA 06.10.95)
455 OSL_ASSERT (mpViewShell->GetViewShell()!=NULL);
456 Client* pIPClient = static_cast<Client*>(
457 mpViewShell->GetViewShell()->GetIPClient());
458 if (pIPClient && pIPClient->IsObjectInPlaceActive())
459 pIPClient->SetSdrGrafObj(NULL);
461 // wait-mousepointer while deleting object
462 WaitObject aWait( (Window*)mpViewShell->GetActiveWindow() );
463 // delete object
464 mpView->DeleteMarked();
467 bReturn = TRUE;
469 break;
471 case KEY_TAB:
473 KeyCode aCode = rKEvt.GetKeyCode();
475 if ( !aCode.IsMod1() && !aCode.IsMod2() )
477 // #105336# Moved next line which was a bugfix itself into
478 // the scope which really does the object selection travel
479 // and thus is allowed to call SelectionHasChanged().
481 // Switch to FuSelect.
482 mpViewShell->GetViewFrame()->GetDispatcher()->Execute(
483 SID_OBJECT_SELECT,
484 SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
486 // changeover to the next object
487 if(!mpView->MarkNextObj( !aCode.IsShift() ))
489 // #97016# No next object: go over open end and
490 // get first from the other side
491 mpView->UnmarkAllObj();
492 mpView->MarkNextObj(!aCode.IsShift());
495 // #97016# II
496 if(mpView->AreObjectsMarked())
497 mpView->MakeVisible(mpView->GetAllMarkedRect(), *mpWindow);
499 bReturn = TRUE;
502 break;
504 case KEY_END:
506 KeyCode aCode = rKEvt.GetKeyCode();
508 if ( aCode.IsMod1() )
510 // #97016# mark last object
511 mpView->UnmarkAllObj();
512 mpView->MarkNextObj(FALSE);
514 // #97016# II
515 if(mpView->AreObjectsMarked())
516 mpView->MakeVisible(mpView->GetAllMarkedRect(), *mpWindow);
518 bReturn = TRUE;
521 break;
523 case KEY_HOME:
525 KeyCode aCode = rKEvt.GetKeyCode();
527 if ( aCode.IsMod1() )
529 // #97016# mark first object
530 mpView->UnmarkAllObj();
531 mpView->MarkNextObj(TRUE);
533 // #97016# II
534 if(mpView->AreObjectsMarked())
535 mpView->MakeVisible(mpView->GetAllMarkedRect(), *mpWindow);
537 bReturn = TRUE;
540 break;
542 default:
543 break;
546 if (!bReturn)
548 bReturn = FuPoor::KeyInput(rKEvt);
550 else
552 mpWindow->ReleaseMouse();
555 return (bReturn);
558 /*************************************************************************
560 |* Fade out the selection-presentation before scrolling
562 \************************************************************************/
564 void FuDraw::ScrollStart()
568 /*************************************************************************
570 |* After scrolling show the selection-presentation again
572 \************************************************************************/
574 void FuDraw::ScrollEnd()
578 /*************************************************************************
580 |* Aktivate function
582 \************************************************************************/
584 void FuDraw::Activate()
586 FuPoor::Activate();
587 ForcePointer();
590 /*************************************************************************
592 |* Deaktivate function
594 \************************************************************************/
596 void FuDraw::Deactivate()
598 FuPoor::Deactivate();
602 /*************************************************************************
604 |* Toggle mouse-pointer
606 \************************************************************************/
608 void FuDraw::ForcePointer(const MouseEvent* pMEvt)
610 Point aPnt;
611 USHORT nModifier = 0;
612 BOOL bLeftDown = FALSE;
613 BOOL bDefPointer = TRUE;
615 if (pMEvt)
617 aPnt = mpWindow->PixelToLogic(pMEvt->GetPosPixel());
618 nModifier = pMEvt->GetModifier();
619 bLeftDown = pMEvt->IsLeft();
621 else
623 aPnt = mpWindow->PixelToLogic(mpWindow->GetPointerPosPixel());
626 if (mpView->IsDragObj())
628 if (SD_MOD()->GetWaterCan() && !mpView->PickHandle(aPnt))
630 /******************************************************************
631 * Giesskannenmodus
632 ******************************************************************/
633 bDefPointer = FALSE;
634 mpWindow->SetPointer(Pointer(POINTER_FILL));
637 else
639 SdrHdl* pHdl = mpView->PickHandle(aPnt);
641 if (SD_MOD()->GetWaterCan() && !pHdl)
643 /******************************************************************
644 * Giesskannenmodus
645 ******************************************************************/
646 bDefPointer = FALSE;
647 mpWindow->SetPointer(Pointer(POINTER_FILL));
649 else if (!pHdl &&
650 mpViewShell->GetViewFrame()->HasChildWindow(SvxBmpMaskChildWindow::GetChildWindowId()))
652 /******************************************************************
653 * Pipettenmodus
654 ******************************************************************/
655 SvxBmpMask* pMask = (SvxBmpMask*) mpViewShell->GetViewFrame()->GetChildWindow(SvxBmpMaskChildWindow::GetChildWindowId())->GetWindow();
657 if (pMask && pMask->IsEyedropping())
659 bDefPointer = FALSE;
660 mpWindow->SetPointer(Pointer(POINTER_REFHAND));
663 else if (!mpView->IsAction())
665 SdrObject* pObj = NULL;
666 SdrPageView* pPV = NULL;
667 SdrViewEvent aVEvt;
668 SdrHitKind eHit = SDRHIT_NONE;
669 SdrDragMode eDragMode = mpView->GetDragMode();
671 if (pMEvt)
673 eHit = mpView->PickAnything(*pMEvt, SDRMOUSEMOVE, aVEvt);
676 if ((eDragMode == SDRDRAG_ROTATE) && (eHit == SDRHIT_MARKEDOBJECT))
678 // The goal of this request is show always the rotation-arrow for 3D-objects at rotation-modus
679 // Independent of the settings at Extras->Optionen->Grafik "Objekte immer verschieben"
680 // 2D-objects acquit in an other way. Otherwise, the rotation of 3d-objects around any axises
681 // wouldn't be possible per default.
682 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
683 SdrObject* pObject = rMarkList.GetMark(0)->GetMarkedSdrObj();
684 if ((pObject->ISA(E3dObject)) && (rMarkList.GetMarkCount() == 1))
686 mpWindow->SetPointer(Pointer(POINTER_ROTATE));
687 bDefPointer = FALSE; // Otherwise it'll be calles Joes routine and the mousepointer will reconfigurate again
691 if (eHit == SDRHIT_NONE)
693 // found nothing -> look after at the masterpage
694 mpView->PickObj(aPnt, mpView->getHitTolLog(), pObj, pPV, SDRSEARCH_ALSOONMASTER);
696 else if (eHit == SDRHIT_UNMARKEDOBJECT)
698 pObj = aVEvt.pObj;
700 else if (eHit == SDRHIT_TEXTEDITOBJ && this->ISA(FuSelection))
702 UINT16 nSdrObjKind = aVEvt.pObj->GetObjIdentifier();
704 if ( nSdrObjKind != OBJ_TEXT &&
705 nSdrObjKind != OBJ_TITLETEXT &&
706 nSdrObjKind != OBJ_OUTLINETEXT &&
707 aVEvt.pObj->IsEmptyPresObj() )
709 pObj = NULL;
710 bDefPointer = FALSE;
711 mpWindow->SetPointer(Pointer(POINTER_ARROW));
715 if (pObj && pMEvt && !pMEvt->IsMod2() && this->ISA(FuSelection))
717 // Auf Animation oder ImageMap pruefen
718 bDefPointer = !SetPointer(pObj, aPnt);
720 if (bDefPointer && (pObj->ISA(SdrObjGroup) || pObj->ISA(E3dPolyScene)))
722 // In die Gruppe hineinschauen
723 if (mpView->PickObj(aPnt, mpView->getHitTolLog(), pObj, pPV, SDRSEARCH_ALSOONMASTER | SDRSEARCH_DEEP))
724 bDefPointer = !SetPointer(pObj, aPnt);
730 if (bDefPointer)
732 mpWindow->SetPointer(mpView->GetPreferedPointer(
733 aPnt, mpWindow, nModifier, bLeftDown));
737 /*************************************************************************
739 |* Set cursor for animaton or imagemap
741 \************************************************************************/
743 BOOL FuDraw::SetPointer(SdrObject* pObj, const Point& rPos)
745 BOOL bSet = FALSE;
747 BOOL bAnimationInfo = (!mpDocSh->ISA(GraphicDocShell) &&
748 mpDoc->GetAnimationInfo(pObj)) ? TRUE:FALSE;
750 BOOL bImageMapInfo = FALSE;
752 if (!bAnimationInfo)
753 bImageMapInfo = mpDoc->GetIMapInfo(pObj) ? TRUE:FALSE;
755 if (bAnimationInfo || bImageMapInfo)
757 const SetOfByte* pVisiLayer = &mpView->GetSdrPageView()->GetVisibleLayers();
758 USHORT nHitLog(USHORT (mpWindow->PixelToLogic(Size(HITPIX,0)).Width()));
759 long n2HitLog(nHitLog * 2);
760 Point aHitPosR(rPos);
761 Point aHitPosL(rPos);
762 Point aHitPosT(rPos);
763 Point aHitPosB(rPos);
765 aHitPosR.X() += n2HitLog;
766 aHitPosL.X() -= n2HitLog;
767 aHitPosT.Y() += n2HitLog;
768 aHitPosB.Y() -= n2HitLog;
770 if ( !pObj->IsClosedObj() ||
771 ( SdrObjectPrimitiveHit(*pObj, aHitPosR, nHitLog, *mpView->GetSdrPageView(), pVisiLayer, false) &&
772 SdrObjectPrimitiveHit(*pObj, aHitPosL, nHitLog, *mpView->GetSdrPageView(), pVisiLayer, false) &&
773 SdrObjectPrimitiveHit(*pObj, aHitPosT, nHitLog, *mpView->GetSdrPageView(), pVisiLayer, false) &&
774 SdrObjectPrimitiveHit(*pObj, aHitPosB, nHitLog, *mpView->GetSdrPageView(), pVisiLayer, false)))
776 /**********************************************************
777 * hit inside the object (without margin) or open object
778 ********************************************************/
780 if (bAnimationInfo)
782 /******************************************************
783 * Click-Action
784 ******************************************************/
785 SdAnimationInfo* pInfo = mpDoc->GetAnimationInfo(pObj);
787 if ((mpView->ISA(DrawView) &&
788 (pInfo->meClickAction == presentation::ClickAction_BOOKMARK ||
789 pInfo->meClickAction == presentation::ClickAction_DOCUMENT ||
790 pInfo->meClickAction == presentation::ClickAction_PREVPAGE ||
791 pInfo->meClickAction == presentation::ClickAction_NEXTPAGE ||
792 pInfo->meClickAction == presentation::ClickAction_FIRSTPAGE ||
793 pInfo->meClickAction == presentation::ClickAction_LASTPAGE ||
794 pInfo->meClickAction == presentation::ClickAction_VERB ||
795 pInfo->meClickAction == presentation::ClickAction_PROGRAM ||
796 pInfo->meClickAction == presentation::ClickAction_MACRO ||
797 pInfo->meClickAction == presentation::ClickAction_SOUND))
799 (mpView->ISA(DrawView) &&
800 SlideShow::IsRunning( mpViewShell->GetViewShellBase() ) &&
801 (pInfo->meClickAction == presentation::ClickAction_VANISH ||
802 pInfo->meClickAction == presentation::ClickAction_INVISIBLE ||
803 pInfo->meClickAction == presentation::ClickAction_STOPPRESENTATION ||
804 (pInfo->mbActive &&
805 ( pInfo->meEffect != presentation::AnimationEffect_NONE ||
806 pInfo->meTextEffect != presentation::AnimationEffect_NONE )))))
808 // Animations-Objekt
809 bSet = TRUE;
810 mpWindow->SetPointer(Pointer(POINTER_REFHAND));
813 else if (bImageMapInfo &&
814 mpDoc->GetHitIMapObject(pObj, rPos, *mpWindow))
816 /******************************************************
817 * ImageMap
818 ******************************************************/
819 bSet = TRUE;
820 mpWindow->SetPointer(Pointer(POINTER_REFHAND));
825 return bSet;
830 /*************************************************************************
832 |* Response of doubleclick
834 \************************************************************************/
836 void FuDraw::DoubleClick(const MouseEvent& rMEvt)
838 USHORT nHitLog = USHORT ( mpWindow->PixelToLogic(Size(HITPIX,0)).Width() );
840 if ( mpView->AreObjectsMarked() )
842 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
844 if (rMarkList.GetMarkCount() == 1)
846 SdrMark* pMark = rMarkList.GetMark(0);
847 SdrObject* pObj = pMark->GetMarkedSdrObj();
849 UINT32 nInv = pObj->GetObjInventor();
850 UINT16 nSdrObjKind = pObj->GetObjIdentifier();
852 if (nInv == SdrInventor && nSdrObjKind == OBJ_OLE2)
854 DrawDocShell* pDocSh = mpDoc->GetDocSh();
856 if ( !pDocSh->IsUIActive() )
858 /**********************************************************
859 * aktivate OLE-object
860 **********************************************************/
861 //HMHmpView->HideMarkHdl();
862 mpViewShell->ActivateObject( (SdrOle2Obj*) pObj,
863 embed::EmbedVerbs::MS_OLEVERB_PRIMARY );
866 else if (nInv == SdrInventor && nSdrObjKind == OBJ_GRAF && pObj->IsEmptyPresObj() )
868 mpViewShell->GetViewFrame()->
869 GetDispatcher()->Execute( SID_INSERT_GRAPHIC,
870 SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD );
872 else if ( ( pObj->ISA(SdrTextObj) || pObj->ISA(SdrObjGroup) ) &&
873 !SD_MOD()->GetWaterCan() &&
874 mpViewShell->GetFrameView()->IsDoubleClickTextEdit() &&
875 !mpDocSh->IsReadOnly())
877 SfxUInt16Item aItem(SID_TEXTEDIT, 2);
878 mpViewShell->GetViewFrame()->GetDispatcher()->
879 Execute(SID_TEXTEDIT, SFX_CALLMODE_ASYNCHRON |
880 SFX_CALLMODE_RECORD, &aItem, 0L);
882 else if (nInv == SdrInventor && nSdrObjKind == OBJ_GRUP)
884 // hit group -> select subobject
885 mpView->UnMarkAll();
886 mpView->MarkObj(aMDPos, nHitLog, rMEvt.IsShift(), TRUE);
890 else
891 mpViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
894 /*************************************************************************
896 |* Help-event
898 \************************************************************************/
900 BOOL FuDraw::RequestHelp(const HelpEvent& rHEvt)
902 BOOL bReturn = FALSE;
904 if (Help::IsBalloonHelpEnabled() || Help::IsQuickHelpEnabled())
906 SdrViewEvent aVEvt;
908 MouseEvent aMEvt(mpWindow->GetPointerPosPixel(), 1, 0, MOUSE_LEFT);
910 SdrHitKind eHit = mpView->PickAnything(aMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
912 SdrObject* pObj = aVEvt.pObj;
914 if (eHit != SDRHIT_NONE && pObj != NULL)
916 Point aPosPixel = rHEvt.GetMousePosPixel();
918 bReturn = SetHelpText(pObj, aPosPixel, aVEvt);
920 if (!bReturn && (pObj->ISA(SdrObjGroup) || pObj->ISA(E3dPolyScene)))
922 // In die Gruppe hineinschauen
923 SdrPageView* pPV = NULL;
925 Point aPos(mpWindow->PixelToLogic(mpWindow->ScreenToOutputPixel(aPosPixel)));
927 if (mpView->PickObj(aPos, mpView->getHitTolLog(), pObj, pPV, SDRSEARCH_ALSOONMASTER | SDRSEARCH_DEEP))
928 bReturn = SetHelpText(pObj, aPosPixel, aVEvt);
933 if (!bReturn)
935 bReturn = FuPoor::RequestHelp(rHEvt);
938 return(bReturn);
943 /*************************************************************************
945 |* Command-event
947 \************************************************************************/
949 BOOL FuDraw::SetHelpText(SdrObject* pObj, const Point& rPosPixel, const SdrViewEvent& rVEvt)
951 BOOL bSet = FALSE;
952 String aHelpText;
953 Point aPos(mpWindow->PixelToLogic(mpWindow->ScreenToOutputPixel(rPosPixel)));
955 // URL fuer IMapObject unter Pointer ist Hilfetext
956 if ( mpDoc->GetIMapInfo(pObj) )
958 IMapObject* pIMapObj = mpDoc->GetHitIMapObject(pObj, aPos, *mpWindow );
960 if ( pIMapObj )
962 // show name
963 aHelpText = pIMapObj->GetAltText();
965 if (aHelpText.Len() == 0)
967 // show url if no name is available
968 aHelpText = INetURLObject::decode( pIMapObj->GetURL(), '%', INetURLObject::DECODE_WITH_CHARSET );
972 else if (!mpDocSh->ISA(GraphicDocShell) && mpDoc->GetAnimationInfo(pObj))
974 SdAnimationInfo* pInfo = mpDoc->GetAnimationInfo(pObj);
976 switch (pInfo->meClickAction)
978 case presentation::ClickAction_PREVPAGE:
980 // jump to the prior page
981 aHelpText = String(SdResId(STR_CLICK_ACTION_PREVPAGE));
983 break;
985 case presentation::ClickAction_NEXTPAGE:
987 // jump to the next page
988 aHelpText = String(SdResId(STR_CLICK_ACTION_NEXTPAGE));
990 break;
992 case presentation::ClickAction_FIRSTPAGE:
994 // jump to the first page
995 aHelpText = String(SdResId(STR_CLICK_ACTION_FIRSTPAGE));
997 break;
999 case presentation::ClickAction_LASTPAGE:
1001 // jump to the last page
1002 aHelpText = String(SdResId(STR_CLICK_ACTION_LASTPAGE));
1004 break;
1006 case presentation::ClickAction_BOOKMARK:
1008 // jump to object/page
1009 aHelpText = String(SdResId(STR_CLICK_ACTION_BOOKMARK));
1010 aHelpText.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": " ) );
1011 aHelpText.Append( String(INetURLObject::decode( pInfo->GetBookmark(), '%', INetURLObject::DECODE_WITH_CHARSET ) ));
1013 break;
1015 case presentation::ClickAction_DOCUMENT:
1017 // jump to document (object/page)
1018 aHelpText = String(SdResId(STR_CLICK_ACTION_DOCUMENT));
1019 aHelpText.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": " ) );
1020 aHelpText.Append( String(INetURLObject::decode( pInfo->GetBookmark(), '%', INetURLObject::DECODE_WITH_CHARSET ) ));
1022 break;
1024 case presentation::ClickAction_PROGRAM:
1026 // execute program
1027 aHelpText = String(SdResId(STR_CLICK_ACTION_PROGRAM));
1028 aHelpText.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": " ) );
1029 aHelpText.Append( String(INetURLObject::decode( pInfo->GetBookmark(), '%', INetURLObject::DECODE_WITH_CHARSET ) ));
1031 break;
1033 case presentation::ClickAction_MACRO:
1035 // execute program
1036 aHelpText = String(SdResId(STR_CLICK_ACTION_MACRO));
1037 aHelpText.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": " ) );
1039 if ( SfxApplication::IsXScriptURL( pInfo->GetBookmark() ) )
1041 aHelpText.Append( pInfo->GetBookmark() );
1043 else
1045 String sBookmark( pInfo->GetBookmark() );
1046 sal_Unicode cToken = '.';
1047 aHelpText.Append( sBookmark.GetToken( 2, cToken ) );
1048 aHelpText.Append( cToken );
1049 aHelpText.Append( sBookmark.GetToken( 1, cToken ) );
1050 aHelpText.Append( cToken );
1051 aHelpText.Append( sBookmark.GetToken( 0, cToken ) );
1054 break;
1056 case presentation::ClickAction_SOUND:
1058 // play-back sound
1059 aHelpText = String(SdResId(STR_CLICK_ACTION_SOUND));
1061 break;
1063 case presentation::ClickAction_VERB:
1065 // execute OLE-verb
1066 aHelpText = String(SdResId(STR_CLICK_ACTION_VERB));
1068 break;
1070 case presentation::ClickAction_STOPPRESENTATION:
1072 // quit presentation
1073 aHelpText = String(SdResId(STR_CLICK_ACTION_STOPPRESENTATION));
1075 break;
1076 default:
1077 break;
1080 else if (rVEvt.pURLField)
1082 /**************************************************************
1083 * URL-Field
1084 **************************************************************/
1085 aHelpText = INetURLObject::decode( rVEvt.pURLField->GetURL(), '%', INetURLObject::DECODE_WITH_CHARSET );
1088 if (aHelpText.Len())
1090 bSet = TRUE;
1091 Rectangle aLogicPix = mpWindow->LogicToPixel(pObj->GetLogicRect());
1092 Rectangle aScreenRect(mpWindow->OutputToScreenPixel(aLogicPix.TopLeft()),
1093 mpWindow->OutputToScreenPixel(aLogicPix.BottomRight()));
1095 if (Help::IsBalloonHelpEnabled())
1096 Help::ShowBalloon( (Window*)mpWindow, rPosPixel, aScreenRect, aHelpText);
1097 else if (Help::IsQuickHelpEnabled())
1098 Help::ShowQuickHelp( (Window*)mpWindow, aScreenRect, aHelpText);
1101 return bSet;
1105 /** is called when the currenct function should be aborted. <p>
1106 This is used when a function gets a KEY_ESCAPE but can also
1107 be called directly.
1109 @returns true if a active function was aborted
1111 bool FuDraw::cancel()
1113 bool bReturn = false;
1115 if ( mpView->IsAction() )
1117 mpView->BrkAction();
1118 bReturn = true;
1120 else if ( mpView->IsTextEdit() )
1122 mpView->SdrEndTextEdit();
1123 bReturn = true;
1125 SfxBindings& rBindings = mpViewShell->GetViewFrame()->GetBindings();
1126 rBindings.Invalidate( SID_PARASPACE_INCREASE );
1127 rBindings.Invalidate( SID_PARASPACE_DECREASE );
1129 else if ( mpView->AreObjectsMarked() )
1131 // #97016# II
1132 const SdrHdlList& rHdlList = mpView->GetHdlList();
1133 SdrHdl* pHdl = rHdlList.GetFocusHdl();
1135 if(pHdl)
1137 ((SdrHdlList&)rHdlList).ResetFocusHdl();
1139 else
1141 mpView->UnmarkAll();
1144 // Switch to FuSelect.
1145 mpViewShell->GetViewFrame()->GetDispatcher()->Execute(
1146 SID_OBJECT_SELECT,
1147 SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
1149 bReturn = true;
1152 return bReturn;
1155 } // end of namespace sd