1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <sot/object.hxx>
22 #include <editeng/eeitem.hxx>
23 #include <vcl/waitobj.hxx>
25 #include <editeng/flditem.hxx>
26 #include <svx/svdogrp.hxx>
27 #include <tools/urlobj.hxx>
28 #include <vcl/help.hxx>
29 #include <svx/bmpmask.hxx>
30 #include <svx/svdotext.hxx>
31 #include <sfx2/app.hxx>
32 #include <sfx2/dispatch.hxx>
33 #include <sfx2/bindings.hxx>
34 #include <svx/svdpagv.hxx>
35 #include <svtools/imapobj.hxx>
36 #include <svx/svxids.hrc>
37 #include <svx/obj3d.hxx>
38 #include <svx/polysc3d.hxx>
40 #include <sfx2/viewfrm.hxx>
42 #include "anminfo.hxx"
43 #include "imapinfo.hxx"
46 #include "strings.hrc"
47 #include "res_bmp.hrc"
50 #include "GraphicDocShell.hxx"
52 #include "ViewShell.hxx"
53 #include "FrameView.hxx"
56 #include "drawdoc.hxx"
57 #include "DrawDocShell.hxx"
59 #include "sdresid.hxx"
60 #include "drawview.hxx"
62 #include <svl/aeitem.hxx>
63 #include <vcl/msgbox.hxx>
64 #include "slideshow.hxx"
65 #include <svx/sdrhittesthelper.hxx>
67 using namespace ::com::sun::star
;
71 TYPEINIT1( FuDraw
, FuPoor
);
74 * Base-class for all drawmodul-specific functions
76 FuDraw::FuDraw(ViewShell
* pViewSh
, ::sd::Window
* pWin
, ::sd::View
* pView
,
77 SdDrawDocument
* pDoc
, SfxRequest
& rReq
) :
78 FuPoor(pViewSh
, pWin
, pView
, pDoc
, rReq
),
80 bDragHelpLine(sal_False
),
92 sal_Bool
FuDraw::MouseButtonDown(const MouseEvent
& rMEvt
)
94 // remember button state for creation of own MouseEvents
95 SetMouseButtonCode(rMEvt
.GetButtons());
97 sal_Bool bReturn
= sal_False
;
99 bDragHelpLine
= sal_False
;
101 aMDPos
= mpWindow
->PixelToLogic( rMEvt
.GetPosPixel() );
103 if ( rMEvt
.IsLeft() )
105 FrameView
* pFrameView
= mpViewShell
->GetFrameView();
107 bool bOrtho
= sal_False
;
109 sal_Bool bRestricted
= sal_True
;
111 if (mpView
->IsDragObj())
113 // object is dragged (move, resize,...)
114 const SdrHdl
* pHdl
= mpView
->GetDragStat().GetHdl();
116 if (!pHdl
|| (!pHdl
->IsCornerHdl() && !pHdl
->IsVertexHdl()))
119 bRestricted
= sal_False
;
124 if(bRestricted
&& doConstructOrthogonal())
126 // Restrict movement:
127 // rectangle->quadrat, ellipse->circle etc.
128 bOrtho
= !rMEvt
.IsShift();
132 bOrtho
= rMEvt
.IsShift() != pFrameView
->IsOrtho();
135 if (!mpView
->IsSnapEnabled())
136 mpView
->SetSnapEnabled(sal_True
);
137 sal_Bool bSnapModPressed
= rMEvt
.IsMod1();
139 sal_Bool bGridSnap
= pFrameView
->IsGridSnap();
140 bGridSnap
= (bSnapModPressed
!= bGridSnap
);
142 if (mpView
->IsGridSnap() != bGridSnap
)
143 mpView
->SetGridSnap(bGridSnap
);
145 sal_Bool bBordSnap
= pFrameView
->IsBordSnap();
146 bBordSnap
= (bSnapModPressed
!= bBordSnap
);
148 if (mpView
->IsBordSnap() != bBordSnap
)
149 mpView
->SetBordSnap(bBordSnap
);
151 sal_Bool bHlplSnap
= pFrameView
->IsHlplSnap();
152 bHlplSnap
= (bSnapModPressed
!= bHlplSnap
);
154 if (mpView
->IsHlplSnap() != bHlplSnap
)
155 mpView
->SetHlplSnap(bHlplSnap
);
157 sal_Bool bOFrmSnap
= pFrameView
->IsOFrmSnap();
158 bOFrmSnap
= (bSnapModPressed
!= bOFrmSnap
);
160 if (mpView
->IsOFrmSnap() != bOFrmSnap
)
161 mpView
->SetOFrmSnap(bOFrmSnap
);
163 sal_Bool bOPntSnap
= pFrameView
->IsOPntSnap();
164 bOPntSnap
= (bSnapModPressed
!= bOPntSnap
);
166 if (mpView
->IsOPntSnap() != bOPntSnap
)
167 mpView
->SetOPntSnap(bOPntSnap
);
169 sal_Bool bOConSnap
= pFrameView
->IsOConSnap();
170 bOConSnap
= (bSnapModPressed
!= bOConSnap
);
172 if (mpView
->IsOConSnap() != bOConSnap
)
173 mpView
->SetOConSnap(bOConSnap
);
175 sal_Bool bAngleSnap
= rMEvt
.IsShift() == !pFrameView
->IsAngleSnapEnabled();
177 if (mpView
->IsAngleSnapEnabled() != bAngleSnap
)
178 mpView
->SetAngleSnapEnabled(bAngleSnap
);
180 if (mpView
->IsOrtho() != bOrtho
)
181 mpView
->SetOrtho(bOrtho
);
183 sal_Bool bCenter
= rMEvt
.IsMod2();
185 if ( mpView
->IsCreate1stPointAsCenter() != bCenter
||
186 mpView
->IsResizeAtCenter() != bCenter
)
188 mpView
->SetCreate1stPointAsCenter(bCenter
);
189 mpView
->SetResizeAtCenter(bCenter
);
192 SdrPageView
* pPV
= 0;
193 sal_uInt16 nHitLog
= sal_uInt16 ( mpWindow
->PixelToLogic(Size(HITPIX
,0)).Width() );
195 // look only for HelpLines when they are visible (!)
196 sal_Bool
bHelpLine(sal_False
);
197 if(mpView
->IsHlplVisible())
198 bHelpLine
= mpView
->PickHelpLine(aMDPos
, nHitLog
, *mpWindow
, nHelpLine
, pPV
);
199 sal_Bool bHitHdl
= (mpView
->PickHandle(aMDPos
) != NULL
);
202 && !mpView
->IsCreateObj()
203 && ((mpView
->GetEditMode() == SDREDITMODE_EDIT
&& !bHitHdl
) || (rMEvt
.IsShift() && bSnapModPressed
)) )
205 mpWindow
->CaptureMouse();
206 mpView
->BegDragHelpLine(nHelpLine
, pPV
);
207 bDragHelpLine
= mpView
->IsDragHelpLine();
211 ForcePointer(&rMEvt
);
217 sal_Bool
FuDraw::MouseMove(const MouseEvent
& rMEvt
)
219 FrameView
* pFrameView
= mpViewShell
->GetFrameView();
220 Point aPos
= mpWindow
->PixelToLogic( rMEvt
.GetPosPixel() );
222 bool bOrtho
= sal_False
;
224 sal_Bool bRestricted
= sal_True
;
226 if (mpView
->IsDragObj())
228 // object is dragged (move, resize, ...)
229 const SdrHdl
* pHdl
= mpView
->GetDragStat().GetHdl();
231 if (!pHdl
|| (!pHdl
->IsCornerHdl() && !pHdl
->IsVertexHdl()))
234 bRestricted
= sal_False
;
238 if (mpView
->IsAction())
241 if(bRestricted
&& doConstructOrthogonal())
243 // Restrict movement:
244 // rectangle->quadrat, ellipse->circle etc.
245 bOrtho
= !rMEvt
.IsShift();
249 bOrtho
= rMEvt
.IsShift() != pFrameView
->IsOrtho();
252 sal_Bool bSnapModPressed
= rMEvt
.IsMod2();
253 mpView
->SetDragWithCopy(rMEvt
.IsMod1() && pFrameView
->IsDragWithCopy());
255 sal_Bool bGridSnap
= pFrameView
->IsGridSnap();
256 bGridSnap
= (bSnapModPressed
!= bGridSnap
);
258 if (mpView
->IsGridSnap() != bGridSnap
)
259 mpView
->SetGridSnap(bGridSnap
);
261 sal_Bool bBordSnap
= pFrameView
->IsBordSnap();
262 bBordSnap
= (bSnapModPressed
!= bBordSnap
);
264 if (mpView
->IsBordSnap() != bBordSnap
)
265 mpView
->SetBordSnap(bBordSnap
);
267 sal_Bool bHlplSnap
= pFrameView
->IsHlplSnap();
268 bHlplSnap
= (bSnapModPressed
!= bHlplSnap
);
270 if (mpView
->IsHlplSnap() != bHlplSnap
)
271 mpView
->SetHlplSnap(bHlplSnap
);
273 sal_Bool bOFrmSnap
= pFrameView
->IsOFrmSnap();
274 bOFrmSnap
= (bSnapModPressed
!= bOFrmSnap
);
276 if (mpView
->IsOFrmSnap() != bOFrmSnap
)
277 mpView
->SetOFrmSnap(bOFrmSnap
);
279 sal_Bool bOPntSnap
= pFrameView
->IsOPntSnap();
280 bOPntSnap
= (bSnapModPressed
!= bOPntSnap
);
282 if (mpView
->IsOPntSnap() != bOPntSnap
)
283 mpView
->SetOPntSnap(bOPntSnap
);
285 sal_Bool bOConSnap
= pFrameView
->IsOConSnap();
286 bOConSnap
= (bSnapModPressed
!= bOConSnap
);
288 if (mpView
->IsOConSnap() != bOConSnap
)
289 mpView
->SetOConSnap(bOConSnap
);
291 sal_Bool bAngleSnap
= rMEvt
.IsShift() == !pFrameView
->IsAngleSnapEnabled();
293 if (mpView
->IsAngleSnapEnabled() != bAngleSnap
)
294 mpView
->SetAngleSnapEnabled(bAngleSnap
);
296 if (mpView
->IsOrtho() != bOrtho
)
297 mpView
->SetOrtho(bOrtho
);
299 sal_Bool bCenter
= rMEvt
.IsMod2();
301 if ( mpView
->IsCreate1stPointAsCenter() != bCenter
||
302 mpView
->IsResizeAtCenter() != bCenter
)
304 mpView
->SetCreate1stPointAsCenter(bCenter
);
305 mpView
->SetResizeAtCenter(bCenter
);
308 if ( mpView
->IsDragHelpLine() )
309 mpView
->MovDragHelpLine(aPos
);
312 sal_Bool bReturn
= mpView
->MouseMove(rMEvt
, mpWindow
);
314 if (mpView
->IsAction())
316 // Because the flag set back if necessary in MouseMove
317 if (mpView
->IsOrtho() != bOrtho
)
318 mpView
->SetOrtho(bOrtho
);
321 ForcePointer(&rMEvt
);
327 sal_Bool
FuDraw::MouseButtonUp(const MouseEvent
& rMEvt
)
329 if ( mpView
->IsDragHelpLine() )
330 mpView
->EndDragHelpLine();
334 Rectangle
aOutputArea(Point(0,0), mpWindow
->GetOutputSizePixel());
336 if ( !aOutputArea
.IsInside(rMEvt
.GetPosPixel()) )
337 mpView
->GetSdrPageView()->DeleteHelpLine(nHelpLine
);
339 mpWindow
->ReleaseMouse();
342 FrameView
* pFrameView
= mpViewShell
->GetFrameView();
343 mpView
->SetOrtho( pFrameView
->IsOrtho() );
344 mpView
->SetAngleSnapEnabled( pFrameView
->IsAngleSnapEnabled() );
345 mpView
->SetSnapEnabled(sal_True
);
346 mpView
->SetCreate1stPointAsCenter(sal_False
);
347 mpView
->SetResizeAtCenter(sal_False
);
348 mpView
->SetDragWithCopy(pFrameView
->IsDragWithCopy());
349 mpView
->SetGridSnap(pFrameView
->IsGridSnap());
350 mpView
->SetBordSnap(pFrameView
->IsBordSnap());
351 mpView
->SetHlplSnap(pFrameView
->IsHlplSnap());
352 mpView
->SetOFrmSnap(pFrameView
->IsOFrmSnap());
353 mpView
->SetOPntSnap(pFrameView
->IsOPntSnap());
354 mpView
->SetOConSnap(pFrameView
->IsOConSnap());
356 bIsInDragMode
= sal_False
;
357 ForcePointer(&rMEvt
);
358 FuPoor::MouseButtonUp(rMEvt
);
364 * Process keyboard input
365 * @returns sal_True if a KeyEvent is being processed, sal_False otherwise
367 sal_Bool
FuDraw::KeyInput(const KeyEvent
& rKEvt
)
369 sal_Bool bReturn
= sal_False
;
371 switch ( rKEvt
.GetKeyCode().GetCode() )
375 bReturn
= FuDraw::cancel();
382 if (!mpDocSh
->IsReadOnly())
384 if ( mpView
&& mpView
->IsPresObjSelected(sal_False
, sal_True
, sal_False
, sal_True
) )
386 InfoBox(mpWindow
, String(SdResId(STR_ACTION_NOTPOSSIBLE
) ) ).Execute();
390 /* If IP-Client active, we reset the pointer to the OLE- and
391 to the old graphic object of SdClient. With this, we
392 avoid the restoration of an no more existing object in
393 ::SelectionHasChanged after deletion. All other OLE
394 objects are not affected. */
395 OSL_ASSERT (mpViewShell
->GetViewShell()!=NULL
);
396 Client
* pIPClient
= static_cast<Client
*>(
397 mpViewShell
->GetViewShell()->GetIPClient());
398 if (pIPClient
&& pIPClient
->IsObjectInPlaceActive())
399 pIPClient
->SetSdrGrafObj(NULL
);
401 // wait-mousepointer while deleting object
402 WaitObject
aWait( (Window
*)mpViewShell
->GetActiveWindow() );
404 mpView
->DeleteMarked();
413 KeyCode aCode
= rKEvt
.GetKeyCode();
415 if ( !aCode
.IsMod1() && !aCode
.IsMod2() )
417 // Moved next line which was a bugfix itself into
418 // the scope which really does the object selection travel
419 // and thus is allowed to call SelectionHasChanged().
421 // Switch to FuSelect.
422 mpViewShell
->GetViewFrame()->GetDispatcher()->Execute(
424 SFX_CALLMODE_ASYNCHRON
| SFX_CALLMODE_RECORD
);
426 // changeover to the next object
427 if(!mpView
->MarkNextObj( !aCode
.IsShift() ))
429 // No next object: go over open end and
430 // get first from the other side
431 mpView
->UnmarkAllObj();
432 mpView
->MarkNextObj(!aCode
.IsShift());
435 if(mpView
->AreObjectsMarked())
436 mpView
->MakeVisible(mpView
->GetAllMarkedRect(), *mpWindow
);
445 KeyCode aCode
= rKEvt
.GetKeyCode();
447 if ( aCode
.IsMod1() )
450 mpView
->UnmarkAllObj();
451 mpView
->MarkNextObj(sal_False
);
453 if(mpView
->AreObjectsMarked())
454 mpView
->MakeVisible(mpView
->GetAllMarkedRect(), *mpWindow
);
463 KeyCode aCode
= rKEvt
.GetKeyCode();
465 if ( aCode
.IsMod1() )
468 mpView
->UnmarkAllObj();
469 mpView
->MarkNextObj(sal_True
);
471 if(mpView
->AreObjectsMarked())
472 mpView
->MakeVisible(mpView
->GetAllMarkedRect(), *mpWindow
);
485 bReturn
= FuPoor::KeyInput(rKEvt
);
489 mpWindow
->ReleaseMouse();
496 void FuDraw::Activate()
503 void FuDraw::Deactivate()
505 FuPoor::Deactivate();
510 * Toggle mouse-pointer
512 void FuDraw::ForcePointer(const MouseEvent
* pMEvt
)
515 sal_uInt16 nModifier
= 0;
516 sal_Bool bLeftDown
= sal_False
;
517 sal_Bool bDefPointer
= sal_True
;
521 aPnt
= mpWindow
->PixelToLogic(pMEvt
->GetPosPixel());
522 nModifier
= pMEvt
->GetModifier();
523 bLeftDown
= pMEvt
->IsLeft();
527 aPnt
= mpWindow
->PixelToLogic(mpWindow
->GetPointerPosPixel());
530 if (mpView
->IsDragObj())
532 if (SD_MOD()->GetWaterCan() && !mpView
->PickHandle(aPnt
))
535 bDefPointer
= sal_False
;
536 mpWindow
->SetPointer(Pointer(POINTER_FILL
));
541 SdrHdl
* pHdl
= mpView
->PickHandle(aPnt
);
543 if (SD_MOD()->GetWaterCan() && !pHdl
)
546 bDefPointer
= sal_False
;
547 mpWindow
->SetPointer(Pointer(POINTER_FILL
));
550 mpViewShell
->GetViewFrame()->HasChildWindow(SvxBmpMaskChildWindow::GetChildWindowId()))
553 SvxBmpMask
* pMask
= (SvxBmpMask
*) mpViewShell
->GetViewFrame()->GetChildWindow(SvxBmpMaskChildWindow::GetChildWindowId())->GetWindow();
555 if (pMask
&& pMask
->IsEyedropping())
557 bDefPointer
= sal_False
;
558 mpWindow
->SetPointer(Pointer(POINTER_REFHAND
));
561 else if (!mpView
->IsAction())
563 SdrObject
* pObj
= NULL
;
564 SdrPageView
* pPV
= NULL
;
566 SdrHitKind eHit
= SDRHIT_NONE
;
567 SdrDragMode eDragMode
= mpView
->GetDragMode();
571 eHit
= mpView
->PickAnything(*pMEvt
, SDRMOUSEMOVE
, aVEvt
);
574 if ((eDragMode
== SDRDRAG_ROTATE
) && (eHit
== SDRHIT_MARKEDOBJECT
))
576 // The goal of this request is show always the rotation-arrow for 3D-objects at rotation-modus
577 // Independent of the settings at Extras->Optionen->Grafik "Objekte immer verschieben"
578 // 2D-objects acquit in an other way. Otherwise, the rotation of 3d-objects around any axises
579 // wouldn't be possible per default.
580 const SdrMarkList
& rMarkList
= mpView
->GetMarkedObjectList();
581 SdrObject
* pObject
= rMarkList
.GetMark(0)->GetMarkedSdrObj();
582 if ((pObject
->ISA(E3dObject
)) && (rMarkList
.GetMarkCount() == 1))
584 mpWindow
->SetPointer(Pointer(POINTER_ROTATE
));
585 bDefPointer
= sal_False
; // Otherwise it'll be calles Joes routine and the mousepointer will reconfigurate again
589 if (eHit
== SDRHIT_NONE
)
591 // found nothing -> look after at the masterpage
592 mpView
->PickObj(aPnt
, mpView
->getHitTolLog(), pObj
, pPV
, SDRSEARCH_ALSOONMASTER
);
594 else if (eHit
== SDRHIT_UNMARKEDOBJECT
)
598 else if (eHit
== SDRHIT_TEXTEDITOBJ
&& this->ISA(FuSelection
))
600 sal_uInt16 nSdrObjKind
= aVEvt
.pObj
->GetObjIdentifier();
602 if ( nSdrObjKind
!= OBJ_TEXT
&&
603 nSdrObjKind
!= OBJ_TITLETEXT
&&
604 nSdrObjKind
!= OBJ_OUTLINETEXT
&&
605 aVEvt
.pObj
->IsEmptyPresObj() )
608 bDefPointer
= sal_False
;
609 mpWindow
->SetPointer(Pointer(POINTER_ARROW
));
613 if (pObj
&& pMEvt
&& !pMEvt
->IsMod2() && this->ISA(FuSelection
))
615 // test for animation or ImageMap
616 bDefPointer
= !SetPointer(pObj
, aPnt
);
618 if (bDefPointer
&& (pObj
->ISA(SdrObjGroup
) || pObj
->ISA(E3dPolyScene
)))
620 // take a glance into the group
621 if (mpView
->PickObj(aPnt
, mpView
->getHitTolLog(), pObj
, pPV
, SDRSEARCH_ALSOONMASTER
| SDRSEARCH_DEEP
))
622 bDefPointer
= !SetPointer(pObj
, aPnt
);
630 mpWindow
->SetPointer(mpView
->GetPreferedPointer(
631 aPnt
, mpWindow
, nModifier
, bLeftDown
));
636 * Set cursor for animaton or imagemap
638 sal_Bool
FuDraw::SetPointer(SdrObject
* pObj
, const Point
& rPos
)
640 sal_Bool bSet
= sal_False
;
642 sal_Bool bAnimationInfo
= (!mpDocSh
->ISA(GraphicDocShell
) &&
643 mpDoc
->GetAnimationInfo(pObj
)) ? sal_True
:sal_False
;
645 sal_Bool bImageMapInfo
= sal_False
;
648 bImageMapInfo
= mpDoc
->GetIMapInfo(pObj
) ? sal_True
:sal_False
;
650 if (bAnimationInfo
|| bImageMapInfo
)
652 const SetOfByte
* pVisiLayer
= &mpView
->GetSdrPageView()->GetVisibleLayers();
653 sal_uInt16
nHitLog(sal_uInt16 (mpWindow
->PixelToLogic(Size(HITPIX
,0)).Width()));
654 long n2HitLog(nHitLog
* 2);
655 Point
aHitPosR(rPos
);
656 Point
aHitPosL(rPos
);
657 Point
aHitPosT(rPos
);
658 Point
aHitPosB(rPos
);
660 aHitPosR
.X() += n2HitLog
;
661 aHitPosL
.X() -= n2HitLog
;
662 aHitPosT
.Y() += n2HitLog
;
663 aHitPosB
.Y() -= n2HitLog
;
665 if ( !pObj
->IsClosedObj() ||
666 ( SdrObjectPrimitiveHit(*pObj
, aHitPosR
, nHitLog
, *mpView
->GetSdrPageView(), pVisiLayer
, false) &&
667 SdrObjectPrimitiveHit(*pObj
, aHitPosL
, nHitLog
, *mpView
->GetSdrPageView(), pVisiLayer
, false) &&
668 SdrObjectPrimitiveHit(*pObj
, aHitPosT
, nHitLog
, *mpView
->GetSdrPageView(), pVisiLayer
, false) &&
669 SdrObjectPrimitiveHit(*pObj
, aHitPosB
, nHitLog
, *mpView
->GetSdrPageView(), pVisiLayer
, false)))
671 /**********************************************************
672 * hit inside the object (without margin) or open object
673 ********************************************************/
677 /******************************************************
679 ******************************************************/
680 SdAnimationInfo
* pInfo
= mpDoc
->GetAnimationInfo(pObj
);
682 if ((mpView
->ISA(DrawView
) &&
683 (pInfo
->meClickAction
== presentation::ClickAction_BOOKMARK
||
684 pInfo
->meClickAction
== presentation::ClickAction_DOCUMENT
||
685 pInfo
->meClickAction
== presentation::ClickAction_PREVPAGE
||
686 pInfo
->meClickAction
== presentation::ClickAction_NEXTPAGE
||
687 pInfo
->meClickAction
== presentation::ClickAction_FIRSTPAGE
||
688 pInfo
->meClickAction
== presentation::ClickAction_LASTPAGE
||
689 pInfo
->meClickAction
== presentation::ClickAction_VERB
||
690 pInfo
->meClickAction
== presentation::ClickAction_PROGRAM
||
691 pInfo
->meClickAction
== presentation::ClickAction_MACRO
||
692 pInfo
->meClickAction
== presentation::ClickAction_SOUND
))
694 (mpView
->ISA(DrawView
) &&
695 SlideShow::IsRunning( mpViewShell
->GetViewShellBase() ) &&
696 (pInfo
->meClickAction
== presentation::ClickAction_VANISH
||
697 pInfo
->meClickAction
== presentation::ClickAction_INVISIBLE
||
698 pInfo
->meClickAction
== presentation::ClickAction_STOPPRESENTATION
||
700 ( pInfo
->meEffect
!= presentation::AnimationEffect_NONE
||
701 pInfo
->meTextEffect
!= presentation::AnimationEffect_NONE
)))))
705 mpWindow
->SetPointer(Pointer(POINTER_REFHAND
));
708 else if (bImageMapInfo
&&
709 mpDoc
->GetHitIMapObject(pObj
, rPos
, *mpWindow
))
711 /******************************************************
713 ******************************************************/
715 mpWindow
->SetPointer(Pointer(POINTER_REFHAND
));
726 * Response of doubleclick
728 void FuDraw::DoubleClick(const MouseEvent
& rMEvt
)
730 sal_uInt16 nHitLog
= sal_uInt16 ( mpWindow
->PixelToLogic(Size(HITPIX
,0)).Width() );
732 if ( mpView
->AreObjectsMarked() )
734 const SdrMarkList
& rMarkList
= mpView
->GetMarkedObjectList();
736 if (rMarkList
.GetMarkCount() == 1)
738 SdrMark
* pMark
= rMarkList
.GetMark(0);
739 SdrObject
* pObj
= pMark
->GetMarkedSdrObj();
741 sal_uInt32 nInv
= pObj
->GetObjInventor();
742 sal_uInt16 nSdrObjKind
= pObj
->GetObjIdentifier();
744 if (nInv
== SdrInventor
&& nSdrObjKind
== OBJ_OLE2
)
746 DrawDocShell
* pDocSh
= mpDoc
->GetDocSh();
748 if ( !pDocSh
->IsUIActive() )
750 /**********************************************************
751 * activate OLE-object
752 **********************************************************/
753 mpViewShell
->ActivateObject( (SdrOle2Obj
*) pObj
, 0);
756 else if (nInv
== SdrInventor
&& nSdrObjKind
== OBJ_GRAF
&& pObj
->IsEmptyPresObj() )
758 mpViewShell
->GetViewFrame()->
759 GetDispatcher()->Execute( SID_INSERT_GRAPHIC
,
760 SFX_CALLMODE_ASYNCHRON
| SFX_CALLMODE_RECORD
);
762 else if ( ( pObj
->ISA(SdrTextObj
) || pObj
->ISA(SdrObjGroup
) ) &&
763 !SD_MOD()->GetWaterCan() &&
764 mpViewShell
->GetFrameView()->IsDoubleClickTextEdit() &&
765 !mpDocSh
->IsReadOnly())
767 SfxUInt16Item
aItem(SID_TEXTEDIT
, 2);
768 mpViewShell
->GetViewFrame()->GetDispatcher()->
769 Execute(SID_TEXTEDIT
, SFX_CALLMODE_ASYNCHRON
|
770 SFX_CALLMODE_RECORD
, &aItem
, 0L);
772 else if (nInv
== SdrInventor
&& nSdrObjKind
== OBJ_GRUP
)
774 // hit group -> select subobject
776 mpView
->MarkObj(aMDPos
, nHitLog
, rMEvt
.IsShift(), sal_True
);
781 mpViewShell
->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT
, SFX_CALLMODE_ASYNCHRON
| SFX_CALLMODE_RECORD
);
785 sal_Bool
FuDraw::RequestHelp(const HelpEvent
& rHEvt
)
787 sal_Bool bReturn
= sal_False
;
789 if (Help::IsBalloonHelpEnabled() || Help::IsQuickHelpEnabled())
793 MouseEvent
aMEvt(mpWindow
->GetPointerPosPixel(), 1, 0, MOUSE_LEFT
);
795 SdrHitKind eHit
= mpView
->PickAnything(aMEvt
, SDRMOUSEBUTTONDOWN
, aVEvt
);
797 SdrObject
* pObj
= aVEvt
.pObj
;
799 if (eHit
!= SDRHIT_NONE
&& pObj
!= NULL
)
801 Point aPosPixel
= rHEvt
.GetMousePosPixel();
803 bReturn
= SetHelpText(pObj
, aPosPixel
, aVEvt
);
805 if (!bReturn
&& (pObj
->ISA(SdrObjGroup
) || pObj
->ISA(E3dPolyScene
)))
807 // take a glance into the group
808 SdrPageView
* pPV
= NULL
;
810 Point
aPos(mpWindow
->PixelToLogic(mpWindow
->ScreenToOutputPixel(aPosPixel
)));
812 if (mpView
->PickObj(aPos
, mpView
->getHitTolLog(), pObj
, pPV
, SDRSEARCH_ALSOONMASTER
| SDRSEARCH_DEEP
))
813 bReturn
= SetHelpText(pObj
, aPosPixel
, aVEvt
);
820 bReturn
= FuPoor::RequestHelp(rHEvt
);
828 sal_Bool
FuDraw::SetHelpText(SdrObject
* pObj
, const Point
& rPosPixel
, const SdrViewEvent
& rVEvt
)
830 sal_Bool bSet
= sal_False
;
832 Point
aPos(mpWindow
->PixelToLogic(mpWindow
->ScreenToOutputPixel(rPosPixel
)));
834 // URL for IMapObject underneath pointer is help text
835 if ( mpDoc
->GetIMapInfo(pObj
) )
837 IMapObject
* pIMapObj
= mpDoc
->GetHitIMapObject(pObj
, aPos
, *mpWindow
);
842 aHelpText
= pIMapObj
->GetAltText();
844 if (aHelpText
.Len() == 0)
846 // show url if no name is available
847 aHelpText
= INetURLObject::decode( pIMapObj
->GetURL(), '%', INetURLObject::DECODE_WITH_CHARSET
);
851 else if (!mpDocSh
->ISA(GraphicDocShell
) && mpDoc
->GetAnimationInfo(pObj
))
853 SdAnimationInfo
* pInfo
= mpDoc
->GetAnimationInfo(pObj
);
855 switch (pInfo
->meClickAction
)
857 case presentation::ClickAction_PREVPAGE
:
859 // jump to the prior page
860 aHelpText
= String(SdResId(STR_CLICK_ACTION_PREVPAGE
));
864 case presentation::ClickAction_NEXTPAGE
:
866 // jump to the next page
867 aHelpText
= String(SdResId(STR_CLICK_ACTION_NEXTPAGE
));
871 case presentation::ClickAction_FIRSTPAGE
:
873 // jump to the first page
874 aHelpText
= String(SdResId(STR_CLICK_ACTION_FIRSTPAGE
));
878 case presentation::ClickAction_LASTPAGE
:
880 // jump to the last page
881 aHelpText
= String(SdResId(STR_CLICK_ACTION_LASTPAGE
));
885 case presentation::ClickAction_BOOKMARK
:
887 // jump to object/page
888 aHelpText
= String(SdResId(STR_CLICK_ACTION_BOOKMARK
));
889 aHelpText
.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": " ) );
890 aHelpText
.Append( String(INetURLObject::decode( pInfo
->GetBookmark(), '%', INetURLObject::DECODE_WITH_CHARSET
) ));
894 case presentation::ClickAction_DOCUMENT
:
896 // jump to document (object/page)
897 aHelpText
= String(SdResId(STR_CLICK_ACTION_DOCUMENT
));
898 aHelpText
.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": " ) );
899 aHelpText
.Append( String(INetURLObject::decode( pInfo
->GetBookmark(), '%', INetURLObject::DECODE_WITH_CHARSET
) ));
903 case presentation::ClickAction_PROGRAM
:
906 aHelpText
= String(SdResId(STR_CLICK_ACTION_PROGRAM
));
907 aHelpText
.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": " ) );
908 aHelpText
.Append( String(INetURLObject::decode( pInfo
->GetBookmark(), '%', INetURLObject::DECODE_WITH_CHARSET
) ));
912 case presentation::ClickAction_MACRO
:
915 aHelpText
= String(SdResId(STR_CLICK_ACTION_MACRO
));
916 aHelpText
.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": " ) );
918 if ( SfxApplication::IsXScriptURL( pInfo
->GetBookmark() ) )
920 aHelpText
.Append( pInfo
->GetBookmark() );
924 String
sBookmark( pInfo
->GetBookmark() );
925 sal_Unicode cToken
= '.';
926 aHelpText
.Append( sBookmark
.GetToken( 2, cToken
) );
927 aHelpText
.Append( cToken
);
928 aHelpText
.Append( sBookmark
.GetToken( 1, cToken
) );
929 aHelpText
.Append( cToken
);
930 aHelpText
.Append( sBookmark
.GetToken( 0, cToken
) );
935 case presentation::ClickAction_SOUND
:
938 aHelpText
= String(SdResId(STR_CLICK_ACTION_SOUND
));
942 case presentation::ClickAction_VERB
:
945 aHelpText
= String(SdResId(STR_CLICK_ACTION_VERB
));
949 case presentation::ClickAction_STOPPRESENTATION
:
952 aHelpText
= String(SdResId(STR_CLICK_ACTION_STOPPRESENTATION
));
959 else if (rVEvt
.pURLField
)
961 /**************************************************************
963 **************************************************************/
964 aHelpText
= INetURLObject::decode( rVEvt
.pURLField
->GetURL(), '%', INetURLObject::DECODE_WITH_CHARSET
);
970 Rectangle aLogicPix
= mpWindow
->LogicToPixel(pObj
->GetLogicRect());
971 Rectangle
aScreenRect(mpWindow
->OutputToScreenPixel(aLogicPix
.TopLeft()),
972 mpWindow
->OutputToScreenPixel(aLogicPix
.BottomRight()));
974 if (Help::IsBalloonHelpEnabled())
975 Help::ShowBalloon( (Window
*)mpWindow
, rPosPixel
, aScreenRect
, aHelpText
);
976 else if (Help::IsQuickHelpEnabled())
977 Help::ShowQuickHelp( (Window
*)mpWindow
, aScreenRect
, aHelpText
);
984 /** is called when the currenct function should be aborted. <p>
985 This is used when a function gets a KEY_ESCAPE but can also
988 @returns true if a active function was aborted
990 bool FuDraw::cancel()
992 bool bReturn
= false;
994 if ( mpView
->IsAction() )
999 else if ( mpView
->IsTextEdit() )
1001 mpView
->SdrEndTextEdit();
1004 SfxBindings
& rBindings
= mpViewShell
->GetViewFrame()->GetBindings();
1005 rBindings
.Invalidate( SID_PARASPACE_INCREASE
);
1006 rBindings
.Invalidate( SID_PARASPACE_DECREASE
);
1008 else if ( mpView
->AreObjectsMarked() )
1010 const SdrHdlList
& rHdlList
= mpView
->GetHdlList();
1011 SdrHdl
* pHdl
= rHdlList
.GetFocusHdl();
1015 ((SdrHdlList
&)rHdlList
).ResetFocusHdl();
1019 mpView
->UnmarkAll();
1022 // Switch to FuSelect.
1023 mpViewShell
->GetViewFrame()->GetDispatcher()->Execute(
1025 SFX_CALLMODE_ASYNCHRON
| SFX_CALLMODE_RECORD
);
1033 } // end of namespace sd
1035 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */