1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: fudraw.cxx,v $
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"
59 #include "imapinfo.hxx"
62 #include "strings.hrc"
63 #include "res_bmp.hrc"
66 #include "GraphicDocShell.hxx"
68 #include "ViewShell.hxx"
69 #include "FrameView.hxx"
71 #ifndef SD_WINDOW_SHELL_HXX
74 #include "drawdoc.hxx"
75 #include "DrawDocShell.hxx"
77 #include "sdresid.hxx"
78 #include "drawview.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
;
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
),
101 bDragHelpLine(FALSE
),
106 FunctionReference
FuDraw::Create( ViewShell
* pViewSh
, ::sd::Window
* pWin
, ::sd::View
* pView
, SdDrawDocument
* pDoc
, SfxRequest
& rReq
, bool bPermanent
)
109 FunctionReference
xFunc( pFunc
= new FuDraw( pViewSh
, pWin
, pView
, pDoc
, rReq
) );
110 pFunc
->SetPermanent(bPermanent
);
114 /*************************************************************************
118 \************************************************************************/
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();
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()))
165 if(bRestricted
&& doConstructOrthogonal())
167 // Restrict movement:
168 // rectangle->quadrat, ellipse->circle etc.
169 bOrtho
= !rMEvt
.IsShift();
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
);
243 && !mpView
->IsCreateObj()
244 && ((mpView
->GetEditMode() == SDREDITMODE_EDIT
&& !bHitHdl
) || (rMEvt
.IsShift() && bCntrl
)) )
246 mpWindow
->CaptureMouse();
247 mpView
->BegDragHelpLine(nHelpLine
, pPV
);
248 bDragHelpLine
= mpView
->IsDragHelpLine();
252 ForcePointer(&rMEvt
);
257 /*************************************************************************
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();
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()))
286 if (mpView
->IsAction())
289 if(bRestricted
&& doConstructOrthogonal())
291 // Restrict movement:
292 // rectangle->quadrat, ellipse->circle etc.
293 bOrtho
= !rMEvt
.IsShift();
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
);
374 /*************************************************************************
376 |* MouseButtonUp-event
378 \************************************************************************/
380 BOOL
FuDraw::MouseButtonUp(const MouseEvent
& rMEvt
)
382 if ( mpView
->IsDragHelpLine() )
383 mpView
->EndDragHelpLine();
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
);
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() )
432 bReturn
= FuDraw::cancel();
439 if (!mpDocSh
->IsReadOnly())
441 if ( mpView
&& mpView
->IsPresObjSelected(FALSE
, TRUE
, FALSE
, TRUE
) )
443 InfoBox(mpWindow
, String(SdResId(STR_ACTION_NOTPOSSIBLE
) ) ).Execute();
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() );
464 mpView
->DeleteMarked();
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(
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());
496 if(mpView
->AreObjectsMarked())
497 mpView
->MakeVisible(mpView
->GetAllMarkedRect(), *mpWindow
);
506 KeyCode aCode
= rKEvt
.GetKeyCode();
508 if ( aCode
.IsMod1() )
510 // #97016# mark last object
511 mpView
->UnmarkAllObj();
512 mpView
->MarkNextObj(FALSE
);
515 if(mpView
->AreObjectsMarked())
516 mpView
->MakeVisible(mpView
->GetAllMarkedRect(), *mpWindow
);
525 KeyCode aCode
= rKEvt
.GetKeyCode();
527 if ( aCode
.IsMod1() )
529 // #97016# mark first object
530 mpView
->UnmarkAllObj();
531 mpView
->MarkNextObj(TRUE
);
534 if(mpView
->AreObjectsMarked())
535 mpView
->MakeVisible(mpView
->GetAllMarkedRect(), *mpWindow
);
548 bReturn
= FuPoor::KeyInput(rKEvt
);
552 mpWindow
->ReleaseMouse();
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 /*************************************************************************
582 \************************************************************************/
584 void FuDraw::Activate()
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
)
611 USHORT nModifier
= 0;
612 BOOL bLeftDown
= FALSE
;
613 BOOL bDefPointer
= TRUE
;
617 aPnt
= mpWindow
->PixelToLogic(pMEvt
->GetPosPixel());
618 nModifier
= pMEvt
->GetModifier();
619 bLeftDown
= pMEvt
->IsLeft();
623 aPnt
= mpWindow
->PixelToLogic(mpWindow
->GetPointerPosPixel());
626 if (mpView
->IsDragObj())
628 if (SD_MOD()->GetWaterCan() && !mpView
->PickHandle(aPnt
))
630 /******************************************************************
632 ******************************************************************/
634 mpWindow
->SetPointer(Pointer(POINTER_FILL
));
639 SdrHdl
* pHdl
= mpView
->PickHandle(aPnt
);
641 if (SD_MOD()->GetWaterCan() && !pHdl
)
643 /******************************************************************
645 ******************************************************************/
647 mpWindow
->SetPointer(Pointer(POINTER_FILL
));
650 mpViewShell
->GetViewFrame()->HasChildWindow(SvxBmpMaskChildWindow::GetChildWindowId()))
652 /******************************************************************
654 ******************************************************************/
655 SvxBmpMask
* pMask
= (SvxBmpMask
*) mpViewShell
->GetViewFrame()->GetChildWindow(SvxBmpMaskChildWindow::GetChildWindowId())->GetWindow();
657 if (pMask
&& pMask
->IsEyedropping())
660 mpWindow
->SetPointer(Pointer(POINTER_REFHAND
));
663 else if (!mpView
->IsAction())
665 SdrObject
* pObj
= NULL
;
666 SdrPageView
* pPV
= NULL
;
668 SdrHitKind eHit
= SDRHIT_NONE
;
669 SdrDragMode eDragMode
= mpView
->GetDragMode();
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
)
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() )
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
);
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
)
747 BOOL bAnimationInfo
= (!mpDocSh
->ISA(GraphicDocShell
) &&
748 mpDoc
->GetAnimationInfo(pObj
)) ? TRUE
:FALSE
;
750 BOOL bImageMapInfo
= FALSE
;
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 ********************************************************/
782 /******************************************************
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
||
805 ( pInfo
->meEffect
!= presentation::AnimationEffect_NONE
||
806 pInfo
->meTextEffect
!= presentation::AnimationEffect_NONE
)))))
810 mpWindow
->SetPointer(Pointer(POINTER_REFHAND
));
813 else if (bImageMapInfo
&&
814 mpDoc
->GetHitIMapObject(pObj
, rPos
, *mpWindow
))
816 /******************************************************
818 ******************************************************/
820 mpWindow
->SetPointer(Pointer(POINTER_REFHAND
));
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
886 mpView
->MarkObj(aMDPos
, nHitLog
, rMEvt
.IsShift(), TRUE
);
891 mpViewShell
->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT
, SFX_CALLMODE_ASYNCHRON
| SFX_CALLMODE_RECORD
);
894 /*************************************************************************
898 \************************************************************************/
900 BOOL
FuDraw::RequestHelp(const HelpEvent
& rHEvt
)
902 BOOL bReturn
= FALSE
;
904 if (Help::IsBalloonHelpEnabled() || Help::IsQuickHelpEnabled())
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
);
935 bReturn
= FuPoor::RequestHelp(rHEvt
);
943 /*************************************************************************
947 \************************************************************************/
949 BOOL
FuDraw::SetHelpText(SdrObject
* pObj
, const Point
& rPosPixel
, const SdrViewEvent
& rVEvt
)
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
);
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
));
985 case presentation::ClickAction_NEXTPAGE
:
987 // jump to the next page
988 aHelpText
= String(SdResId(STR_CLICK_ACTION_NEXTPAGE
));
992 case presentation::ClickAction_FIRSTPAGE
:
994 // jump to the first page
995 aHelpText
= String(SdResId(STR_CLICK_ACTION_FIRSTPAGE
));
999 case presentation::ClickAction_LASTPAGE
:
1001 // jump to the last page
1002 aHelpText
= String(SdResId(STR_CLICK_ACTION_LASTPAGE
));
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
) ));
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
) ));
1024 case presentation::ClickAction_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
) ));
1033 case presentation::ClickAction_MACRO
:
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() );
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
) );
1056 case presentation::ClickAction_SOUND
:
1059 aHelpText
= String(SdResId(STR_CLICK_ACTION_SOUND
));
1063 case presentation::ClickAction_VERB
:
1066 aHelpText
= String(SdResId(STR_CLICK_ACTION_VERB
));
1070 case presentation::ClickAction_STOPPRESENTATION
:
1072 // quit presentation
1073 aHelpText
= String(SdResId(STR_CLICK_ACTION_STOPPRESENTATION
));
1080 else if (rVEvt
.pURLField
)
1082 /**************************************************************
1084 **************************************************************/
1085 aHelpText
= INetURLObject::decode( rVEvt
.pURLField
->GetURL(), '%', INetURLObject::DECODE_WITH_CHARSET
);
1088 if (aHelpText
.Len())
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
);
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
1109 @returns true if a active function was aborted
1111 bool FuDraw::cancel()
1113 bool bReturn
= false;
1115 if ( mpView
->IsAction() )
1117 mpView
->BrkAction();
1120 else if ( mpView
->IsTextEdit() )
1122 mpView
->SdrEndTextEdit();
1125 SfxBindings
& rBindings
= mpViewShell
->GetViewFrame()->GetBindings();
1126 rBindings
.Invalidate( SID_PARASPACE_INCREASE
);
1127 rBindings
.Invalidate( SID_PARASPACE_DECREASE
);
1129 else if ( mpView
->AreObjectsMarked() )
1132 const SdrHdlList
& rHdlList
= mpView
->GetHdlList();
1133 SdrHdl
* pHdl
= rHdlList
.GetFocusHdl();
1137 ((SdrHdlList
&)rHdlList
).ResetFocusHdl();
1141 mpView
->UnmarkAll();
1144 // Switch to FuSelect.
1145 mpViewShell
->GetViewFrame()->GetDispatcher()->Execute(
1147 SFX_CALLMODE_ASYNCHRON
| SFX_CALLMODE_RECORD
);
1155 } // end of namespace sd