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: fusel.cxx,v $
10 * $Revision: 1.55.74.1 $
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"
36 #include <vos/process.hxx>
37 #include <basic/sbstar.hxx>
38 #include <svx/svdpagv.hxx>
39 #include <svx/svdogrp.hxx>
40 #include <svx/polysc3d.hxx>
41 #include "drawview.hxx"
42 #include <svtools/imapobj.hxx>
43 #include <svtools/urihelper.hxx>
44 #include <unotools/localfilehelper.hxx>
45 #include <svx/svxids.hrc>
46 #include <svx/xfillit0.hxx>
47 #include <sfx2/app.hxx>
48 #include <sfx2/viewfrm.hxx>
49 #include <svtools/aeitem.hxx>
50 #include <svtools/stritem.hxx>
51 #include <svtools/intitem.hxx>
52 #include <sfx2/dispatch.hxx>
53 #include <tools/urlobj.hxx>
54 #include <sfx2/docfile.hxx>
55 #include <tools/debug.hxx>
56 #include <svx/eeitem.hxx>
57 #include <svx/flditem.hxx>
59 #include <svx/svdotable.hxx>
62 #include "strings.hrc"
63 #include "res_bmp.hrc"
64 #include "GraphicDocShell.hxx"
66 #include "DrawDocShell.hxx"
67 #include "stlpool.hxx"
69 #include "anminfo.hxx"
71 #include "ViewShell.hxx"
72 #include "ViewShellBase.hxx"
73 #ifndef SD_FRAMW_VIEW_HXX
74 #include "FrameView.hxx"
77 #ifndef SD_WINDOW_SHELL_HXX
80 #include "drawdoc.hxx"
82 #include "DrawViewShell.hxx"
83 #include "ToolBarManager.hxx"
85 #include <svx/globl3d.hxx>
88 #include "slideshow.hxx"
91 #include <svx/svdundo.hxx>
92 #include <avmedia/mediawindow.hxx>
94 #include <svx/sdrhittesthelper.hxx>
96 using namespace ::com::sun::star
;
100 TYPEINIT1( FuSelection
, FuDraw
);
102 /*************************************************************************
106 \************************************************************************/
108 FuSelection::FuSelection (
112 SdDrawDocument
* pDoc
,
114 : FuDraw(pViewSh
, pWin
, pView
, pDoc
, rReq
),
115 bTempRotation(FALSE
),
116 bSelectionChanged(FALSE
),
117 bHideAndAnimate(FALSE
),
119 bSuppressChangesOfSelection(FALSE
),
121 nEditMode(SID_BEZIER_MOVE
),
122 pWaterCanCandidate(NULL
)
126 FunctionReference
FuSelection::Create( ViewShell
* pViewSh
, ::sd::Window
* pWin
, ::sd::View
* pView
, SdDrawDocument
* pDoc
, SfxRequest
& rReq
)
128 FunctionReference
xFunc( new FuSelection( pViewSh
, pWin
, pView
, pDoc
, rReq
) );
129 xFunc
->DoExecute(rReq
);
133 void FuSelection::DoExecute( SfxRequest
& rReq
)
135 FuDraw::DoExecute( rReq
);
137 // Objektbar auswaehlen
138 SelectionHasChanged();
141 /*************************************************************************
145 \************************************************************************/
147 FuSelection::~FuSelection()
149 mpView
->UnmarkAllPoints();
150 mpView
->ResetCreationActive();
152 if ( mpView
->GetDragMode() != SDRDRAG_MOVE
)
154 mpView
->SetDragMode(SDRDRAG_MOVE
);
158 /*************************************************************************
160 |* MouseButtonDown-event
162 \************************************************************************/
164 BOOL
FuSelection::MouseButtonDown(const MouseEvent
& rMEvt
)
167 bHideAndAnimate
= FALSE
;
170 BOOL bReturn
= FuDraw::MouseButtonDown(rMEvt
);
171 BOOL bWaterCan
= SD_MOD()->GetWaterCan();
172 const bool bReadOnly
= mpDocSh
->IsReadOnly();
173 // When the right mouse button is pressed then only select objects
174 // (and deselect others) as a preparation for showing the context
176 const bool bSelectionOnly
= rMEvt
.IsRight();
179 bSelectionChanged
= FALSE
;
181 if ( mpView
->IsAction() )
183 if ( rMEvt
.IsRight() )
188 USHORT nDrgLog
= USHORT ( mpWindow
->PixelToLogic(Size(DRGPIX
,0)).Width() );
189 USHORT nHitLog
= USHORT ( mpWindow
->PixelToLogic(Size(HITPIX
,0)).Width() );
191 // The following code is executed for right clicks as well as for left
192 // clicks in order to modify the selection for the right button as a
193 // preparation for the context menu. The functions BegMarkObject() and
194 // BegDragObject(), however, are not called for right clicks because a)
195 // it makes no sense and b) to have IsAction() return FALSE when called
196 // from Command() which is a prerequisite for the context menu.
197 if ((rMEvt
.IsLeft() || rMEvt
.IsRight())
198 && !mpView
->IsAction()
199 && (mpView
->IsFrameDragSingles() || !mpView
->HasMarkablePoints()))
201 /******************************************************************
203 ******************************************************************/
204 mpWindow
->CaptureMouse();
205 pHdl
= mpView
->PickHandle(aMDPos
);
209 long nAngle0
= GetAngle(aMDPos
- mpView
->GetRef1());
211 nAngle0
= NormAngle360(nAngle0
);
212 bMirrorSide0
= BOOL (nAngle0
< 18000L);
214 if (!pHdl
&& mpView
->Is3DRotationCreationActive())
216 /******************************************************************
217 * Wenn 3D-Rotationskoerper erstellt werden sollen, jetzt
218 * die Erstellung beenden
219 ******************************************************************/
220 bSuppressChangesOfSelection
= TRUE
;
222 mpWindow
->EnterWait();
223 mpView
->End3DCreation();
224 bSuppressChangesOfSelection
= FALSE
;
225 mpView
->ResetCreationActive();
227 mpWindow
->LeaveWait();
230 BOOL bTextEdit
= FALSE
;
232 SdrHitKind eHit
= mpView
->PickAnything(rMEvt
, SDRMOUSEBUTTONDOWN
, aVEvt
);
234 if ( eHit
== SDRHIT_TEXTEDITOBJ
&& ( mpViewShell
->GetFrameView()->IsQuickEdit() || dynamic_cast< sdr::table::SdrTableObj
* >( aVEvt
.pObj
) != NULL
) )
240 && !mpDocSh
->IsReadOnly()
241 && ((mpView
->IsMarkedHit(aMDPos
, nHitLog
) && !rMEvt
.IsShift() && !rMEvt
.IsMod2()) || pHdl
!= NULL
)
242 && (rMEvt
.GetClicks() != 2)
245 if (!pHdl
&& mpView
->Is3DRotationCreationActive())
247 // Wechsel Rotationskoerper -> Selektion
248 mpView
->ResetCreationActive();
252 // Remember the selected object for proper handling in
254 pWaterCanCandidate
= pickObject (aMDPos
);
258 // Handle oder markiertes Objekt getroffen
259 bFirstMouseMove
= TRUE
;
263 if ( ! rMEvt
.IsRight())
264 mpView
->BegDragObj(aMDPos
, (OutputDevice
*) NULL
, pHdl
, nDrgLog
);
269 if (!rMEvt
.IsMod2() && mpView
->PickObj(aMDPos
, mpView
->getHitTolLog(), pObj
, pPV
, SDRSEARCH_PICKMACRO
))
271 mpView
->BegMacroObj(aMDPos
, nHitLog
, pObj
, pPV
, mpWindow
);
274 else if ( bTextEdit
)
276 UINT16 nSdrObjKind
= aVEvt
.pObj
->GetObjIdentifier();
278 if (aVEvt
.pObj
->GetObjInventor() == SdrInventor
&&
279 (nSdrObjKind
== OBJ_TEXT
||
280 nSdrObjKind
== OBJ_TITLETEXT
||
281 nSdrObjKind
== OBJ_OUTLINETEXT
||
282 !aVEvt
.pObj
->IsEmptyPresObj()))
284 // Seamless Editing: Verzweigen zur Texteingabe
285 if (!rMEvt
.IsShift())
288 SfxUInt16Item
aItem(SID_TEXTEDIT
, 1);
289 mpViewShell
->GetViewFrame()->GetDispatcher()->
290 Execute(SID_TEXTEDIT
, SFX_CALLMODE_SYNCHRON
|
291 SFX_CALLMODE_RECORD
, &aItem
, 0L);
292 return bReturn
; // VORSICHT, durch den synchronen Slot ist das objekt jetzt geloescht
295 else if ( !rMEvt
.IsMod2() && rMEvt
.GetClicks() == 1 &&
296 aVEvt
.eEvent
== SDREVENT_EXECUTEURL
)
298 mpWindow
->ReleaseMouse();
299 SfxStringItem
aStrItem(SID_FILE_NAME
, aVEvt
.pURLField
->GetURL());
300 SfxStringItem
aReferer(SID_REFERER
, mpDocSh
->GetMedium()->GetName());
301 SfxBoolItem
aBrowseItem( SID_BROWSE
, TRUE
);
302 SfxViewFrame
* pFrame
= mpViewShell
->GetViewFrame();
303 mpWindow
->ReleaseMouse();
307 // Im neuen Frame oeffnen
308 pFrame
->GetDispatcher()->Execute(SID_OPENDOC
, SFX_CALLMODE_ASYNCHRON
| SFX_CALLMODE_RECORD
,
309 &aStrItem
, &aBrowseItem
, &aReferer
, 0L);
313 // Im aktuellen Frame oeffnen
314 SfxFrameItem
aFrameItem(SID_DOCFRAME
, pFrame
);
315 pFrame
->GetDispatcher()->Execute(SID_OPENDOC
, SFX_CALLMODE_ASYNCHRON
| SFX_CALLMODE_RECORD
,
316 &aStrItem
, &aFrameItem
, &aBrowseItem
, &aReferer
, 0L);
321 else if(!rMEvt
.IsMod2()
322 && mpViewShell
->ISA(DrawViewShell
)
325 if(mpView
->PickObj(aMDPos
, mpView
->getHitTolLog(), pObj
, pPV
, SDRSEARCH_ALSOONMASTER
))
327 // Animate object when not just selecting.
328 if ( ! bSelectionOnly
)
329 bReturn
= AnimateObj(pObj
, aMDPos
);
331 if (!bReturn
&& (pObj
->ISA(SdrObjGroup
) || pObj
->ISA(E3dPolyScene
)))
333 if(rMEvt
.GetClicks() == 1)
335 // In die Gruppe hineinschauen
336 if (mpView
->PickObj(aMDPos
, mpView
->getHitTolLog(), pObj
, pPV
, SDRSEARCH_ALSOONMASTER
| SDRSEARCH_DEEP
))
337 bReturn
= AnimateObj(pObj
, aMDPos
);
339 else if( !bReadOnly
&& rMEvt
.GetClicks() == 2)
341 // Neu: Doppelklick auf selektiertes Gruppenobjekt
343 if ( ! bSelectionOnly
345 && pObj
->GetPage() == pPV
->GetPage())
346 bReturn
= pPV
->EnterGroup(pObj
);
351 // #i71727# replaced else here with two possibilities, once the original else (!pObj)
352 // and also ignoring the found object when it's on a masterpage
353 if(!pObj
|| (pObj
->GetPage() && pObj
->GetPage()->IsMasterPage()))
355 if(mpView
->IsGroupEntered() && 2 == rMEvt
.GetClicks())
357 // New: double click on empty space/on obj on MasterPage, leave group
358 mpView
->LeaveOneGroup();
368 if ( ! (rMEvt
.IsShift() || rMEvt
.IsMod2()))
370 // Find the object under the current mouse position
371 // and store it for the MouseButtonUp() method to
373 pWaterCanCandidate
= pickObject (aMDPos
);
379 BOOL bDeactivateOLE
= FALSE
;
381 if ( !rMEvt
.IsShift() && !rMEvt
.IsMod2() )
383 OSL_ASSERT (mpViewShell
->GetViewShell()!=NULL
);
384 Client
* pIPClient
= static_cast<Client
*>(
385 mpViewShell
->GetViewShell()->GetIPClient());
387 if (pIPClient
&& pIPClient
->IsObjectInPlaceActive())
389 // OLE-Objekt wird im nachfolgenden UnmarkAll() deaktiviert
390 bDeactivateOLE
= TRUE
;
396 BOOL bMarked
= FALSE
;
398 if ( !rMEvt
.IsMod1() && !bDeactivateOLE
)
400 if ( rMEvt
.IsMod2() )
402 bMarked
= mpView
->MarkNextObj(aMDPos
, nHitLog
, rMEvt
.IsShift() );
406 BOOL bToggle
= FALSE
;
408 if (rMEvt
.IsShift() && mpView
->GetMarkedObjectList().GetMarkCount() > 1)
410 // Bei Einfachselektion kein Toggle
414 bMarked
= mpView
->MarkObj(aMDPos
, nHitLog
, bToggle
, FALSE
);
418 if( !bDeactivateOLE
)
422 (!rMEvt
.IsShift() || mpView
->IsMarkedHit(aMDPos
, nHitLog
)))
424 /**********************************************************
426 **********************************************************/
429 pHdl
=mpView
->PickHandle(aMDPos
);
430 if ( ! rMEvt
.IsRight())
431 mpView
->BegDragObj(aMDPos
, (OutputDevice
*) NULL
, pHdl
, nDrgLog
);
435 /**********************************************************
437 **********************************************************/
438 if ( ! rMEvt
.IsRight())
439 mpView
->BegMarkObj(aMDPos
);
447 && (rMEvt
.IsLeft() || rMEvt
.IsRight())
448 && !mpView
->IsAction())
450 /**********************************************************************
452 **********************************************************************/
453 mpWindow
->CaptureMouse();
455 SdrHitKind eHit
= mpView
->PickAnything(rMEvt
, SDRMOUSEBUTTONDOWN
, aVEvt
);
457 if (eHit
== SDRHIT_HANDLE
&& aVEvt
.pHdl
->GetKind() == HDL_BWGT
)
459 /******************************************************************
461 ******************************************************************/
462 if ( ! rMEvt
.IsRight())
463 mpView
->BegDragObj(aMDPos
, (OutputDevice
*) NULL
, aVEvt
.pHdl
, nDrgLog
);
465 else if (eHit
== SDRHIT_MARKEDOBJECT
&& nEditMode
== SID_BEZIER_INSERT
)
467 /******************************************************************
468 * Klebepunkt einfuegen
469 ******************************************************************/
470 mpView
->BegInsObjPoint(aMDPos
, rMEvt
.IsMod1());
472 else if (eHit
== SDRHIT_MARKEDOBJECT
&& rMEvt
.IsMod1())
474 /******************************************************************
475 * Klebepunkt selektieren
476 ******************************************************************/
477 if (!rMEvt
.IsShift())
478 mpView
->UnmarkAllPoints();
480 if ( ! rMEvt
.IsRight())
481 mpView
->BegMarkPoints(aMDPos
);
483 else if (eHit
== SDRHIT_MARKEDOBJECT
&& !rMEvt
.IsShift() && !rMEvt
.IsMod2())
485 /******************************************************************
487 ******************************************************************/
488 if ( ! rMEvt
.IsRight())
489 mpView
->BegDragObj(aMDPos
, (OutputDevice
*) NULL
, NULL
, nDrgLog
);
491 else if (eHit
== SDRHIT_HANDLE
)
493 /******************************************************************
494 * Klebepunkt selektieren
495 ******************************************************************/
496 if (!mpView
->IsPointMarked(*aVEvt
.pHdl
) || rMEvt
.IsShift())
498 if (!rMEvt
.IsShift())
500 mpView
->UnmarkAllPoints();
501 pHdl
= mpView
->PickHandle(aMDPos
);
505 if (mpView
->IsPointMarked(*aVEvt
.pHdl
))
507 mpView
->UnmarkPoint(*aVEvt
.pHdl
);
512 pHdl
= mpView
->PickHandle(aMDPos
);
518 mpView
->MarkPoint(*pHdl
);
519 if ( ! rMEvt
.IsRight())
520 mpView
->BegDragObj(aMDPos
, (OutputDevice
*) NULL
, pHdl
, nDrgLog
);
525 // #90239# point IS marked and NO shift is pressed. Start
526 // dragging of selected point(s)
527 pHdl
= mpView
->PickHandle(aMDPos
);
529 if ( ! rMEvt
.IsRight())
530 mpView
->BegDragObj(aMDPos
, (OutputDevice
*)NULL
, pHdl
, nDrgLog
);
535 /******************************************************************
536 * Objekt selektieren oder draggen
537 ******************************************************************/
538 if (!rMEvt
.IsShift() && !rMEvt
.IsMod2() && eHit
== SDRHIT_UNMARKEDOBJECT
)
540 mpView
->UnmarkAllObj();
543 BOOL bMarked
= FALSE
;
549 bMarked
= mpView
->MarkNextObj(aMDPos
, nHitLog
, rMEvt
.IsShift());
553 bMarked
= mpView
->MarkObj(aMDPos
, nHitLog
, rMEvt
.IsShift(), FALSE
);
558 (!rMEvt
.IsShift() || eHit
== SDRHIT_MARKEDOBJECT
))
560 // Objekt verschieben
561 if ( ! rMEvt
.IsRight())
562 mpView
->BegDragObj(aMDPos
, (OutputDevice
*) NULL
, aVEvt
.pHdl
, nDrgLog
);
564 else if (mpView
->AreObjectsMarked())
566 /**************************************************************
567 * Klebepunkt selektieren
568 **************************************************************/
569 if (!rMEvt
.IsShift())
570 mpView
->UnmarkAllPoints();
572 if ( ! rMEvt
.IsRight())
573 mpView
->BegMarkPoints(aMDPos
);
577 /**************************************************************
579 **************************************************************/
580 if ( ! rMEvt
.IsRight())
581 mpView
->BegMarkObj(aMDPos
);
584 ForcePointer(&rMEvt
);
590 ForcePointer(&rMEvt
);
596 /*************************************************************************
600 \************************************************************************/
602 BOOL
FuSelection::MouseMove(const MouseEvent
& rMEvt
)
604 BOOL bReturn
= FuDraw::MouseMove(rMEvt
);
606 if (aDragTimer
.IsActive())
610 bFirstMouseMove
= FALSE
;
618 if (mpView
->IsAction())
620 Point
aPix(rMEvt
.GetPosPixel());
621 Point
aPnt(mpWindow
->PixelToLogic(aPix
));
625 if (mpView
->IsInsObjPoint())
627 mpView
->MovInsObjPoint(aPnt
);
631 mpView
->MovAction(aPnt
);
635 ForcePointer(&rMEvt
);
640 /*************************************************************************
642 |* MouseButtonUp-event
644 \************************************************************************/
646 BOOL
FuSelection::MouseButtonUp(const MouseEvent
& rMEvt
)
648 BOOL bReturn
= FALSE
;
649 // When the right mouse button is pressed then only select objects
650 // (and deselect others) as a preparation for showing the context
652 const bool bSelectionOnly
= rMEvt
.IsRight();
656 // Animation laeuft noch -> sofort returnieren
657 bHideAndAnimate
= FALSE
;
659 mpWindow
->ReleaseMouse();
663 if (aDragTimer
.IsActive() )
666 bIsInDragMode
= FALSE
;
672 Point
aPnt( mpWindow
->PixelToLogic( rMEvt
.GetPosPixel() ) );
673 USHORT nHitLog
= USHORT ( mpWindow
->PixelToLogic(Size(HITPIX
,0)).Width() );
674 USHORT nDrgLog
= USHORT ( mpWindow
->PixelToLogic(Size(DRGPIX
,0)).Width() );
676 if (mpView
->IsFrameDragSingles() || !mpView
->HasMarkablePoints())
678 /**********************************************************************
680 **********************************************************************/
681 if ( mpView
->IsDragObj() )
683 /******************************************************************
684 * Objekt wurde verschoben
685 ******************************************************************/
686 FrameView
* pFrameView
= mpViewShell
->GetFrameView();
687 BOOL bDragWithCopy
= (rMEvt
.IsMod1() && pFrameView
->IsDragWithCopy());
691 bDragWithCopy
= !mpView
->IsPresObjSelected(FALSE
, TRUE
);
694 mpView
->SetDragWithCopy(bDragWithCopy
);
695 mpView
->EndDragObj( mpView
->IsDragWithCopy() );
697 mpView
->ForceMarkedToAnotherPage();
699 if (!rMEvt
.IsShift() && !rMEvt
.IsMod1() && !rMEvt
.IsMod2() &&
700 !bSelectionChanged
&&
701 Abs(aPnt
.X() - aMDPos
.X()) < nDrgLog
&&
702 Abs(aPnt
.Y() - aMDPos
.Y()) < nDrgLog
)
704 /**************************************************************
705 * Toggle zw. Selektion und Rotation
706 **************************************************************/
707 SdrObject
* pSingleObj
= NULL
;
708 ULONG nMarkCount
= mpView
->GetMarkedObjectList().GetMarkCount();
712 pSingleObj
= mpView
->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj();
715 if (nSlotId
== SID_OBJECT_SELECT
716 && mpView
->IsRotateAllowed()
717 && (mpViewShell
->GetFrameView()->IsClickChangeRotation()
719 && pSingleObj
->GetObjInventor()==E3dInventor
))
723 bTempRotation
= TRUE
;
724 nSlotId
= SID_OBJECT_ROTATE
;
727 else if (nSlotId
== SID_OBJECT_ROTATE
)
729 nSlotId
= SID_OBJECT_SELECT
;
733 else if (nSlotId
== SID_CONVERT_TO_3D_LATHE
)
737 bSuppressChangesOfSelection
= TRUE
;
738 mpView
->Start3DCreation();
739 bSuppressChangesOfSelection
= FALSE
;
741 else if (pHdl
->GetKind() != HDL_MIRX
&&
742 pHdl
->GetKind() != HDL_REF1
&&
743 pHdl
->GetKind() != HDL_REF2
&& mpView
->Is3DRotationCreationActive())
745 /*********************************************************
746 * Wenn 3D-Rotationskoerper erstellt werden sollen, jetzt
747 * die Erstellung beenden
748 **********************************************************/
749 long nAngle1
= GetAngle(aPnt
- mpView
->GetRef1());
751 nAngle1
= NormAngle360(nAngle1
);
752 BOOL bMirrorSide1
= BOOL (nAngle1
< 18000L);
754 if (bMirrorSide0
!= bMirrorSide1
)
756 bSuppressChangesOfSelection
= TRUE
;
758 mpWindow
->EnterWait();
759 mpView
->End3DCreation();
760 bSuppressChangesOfSelection
= FALSE
;
761 nSlotId
= SID_OBJECT_SELECT
;
763 mpWindow
->LeaveWait();
769 else if (rMEvt
.IsMod1()
771 && Abs(aPnt
.X() - aMDPos
.X()) < nDrgLog
772 && Abs(aPnt
.Y() - aMDPos
.Y()) < nDrgLog
)
775 mpView
->MarkObj(aPnt
, nHitLog
, rMEvt
.IsShift(), rMEvt
.IsMod1());
778 if (mpView
->IsAction() )
783 if( SD_MOD()->GetWaterCan() )
785 if( rMEvt
.IsRight() )
787 // Bei rechter Maustaste wird im Giesskannenmodus ein Undo ausgefuehrt
788 mpViewShell
->GetViewFrame()->GetDispatcher()->Execute( SID_UNDO
, SFX_CALLMODE_ASYNCHRON
);
790 else if (pWaterCanCandidate
!= NULL
)
792 // Is the candiate object still under the mouse?
793 if (pickObject (aPnt
) == pWaterCanCandidate
)
795 SdStyleSheetPool
* pPool
= static_cast<SdStyleSheetPool
*>(
796 mpDocSh
->GetStyleSheetPool());
799 SfxStyleSheet
* pStyleSheet
= static_cast<SfxStyleSheet
*>(
800 pPool
->GetActualStyleSheet());
801 if (pStyleSheet
!= NULL
&& mpView
->IsUndoEnabled() )
804 // Added UNDOs for the WaterCan mode. This was never done in
805 // the past, thus it was missing all the time.
806 SdrUndoAction
* pUndoAttr
= mpDoc
->GetSdrUndoFactory().CreateUndoAttrObject(*pWaterCanCandidate
, sal_True
, sal_True
);
807 mpView
->BegUndo(pUndoAttr
->GetComment());
808 mpView
->AddUndo(mpDoc
->GetSdrUndoFactory().CreateUndoGeoObject(*pWaterCanCandidate
));
809 mpView
->AddUndo(pUndoAttr
);
811 pWaterCanCandidate
->SetStyleSheet (pStyleSheet
, FALSE
);
819 // else when there has been no object under the mouse when the
820 // button was pressed then nothing happens even when there is
824 USHORT nClicks
= rMEvt
.GetClicks();
826 if (nClicks
== 2 && rMEvt
.IsLeft() && bMBDown
&&
827 !rMEvt
.IsMod1() && !rMEvt
.IsShift() )
834 ForcePointer(&rMEvt
);
836 mpWindow
->ReleaseMouse();
837 SdrObject
* pSingleObj
= NULL
;
838 ULONG nMarkCount
= mpView
->GetMarkedObjectList().GetMarkCount();
842 pSingleObj
= mpView
->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj();
845 if ( (nSlotId
!= SID_OBJECT_SELECT
&& nMarkCount
==0) ||
846 ( mpView
->GetDragMode() == SDRDRAG_CROOK
&&
847 !mpView
->IsCrookAllowed( mpView
->IsCrookNoContortion() ) ) ||
848 ( mpView
->GetDragMode() == SDRDRAG_SHEAR
&&
849 !mpView
->IsShearAllowed() && !mpView
->IsDistortAllowed() ) ||
850 ( nSlotId
==SID_CONVERT_TO_3D_LATHE
&& pSingleObj
&&
851 (pSingleObj
->GetObjInventor() != SdrInventor
||
852 pSingleObj
->GetObjIdentifier() == OBJ_MEASURE
) ) )
855 ForcePointer(&rMEvt
);
857 mpWindow
->ReleaseMouse();
858 FuDraw::MouseButtonUp(rMEvt
);
859 mpViewShell
->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT
, SFX_CALLMODE_SYNCHRON
);
860 return bReturn
; // VORSICHT, durch den synchronen Slot ist das objekt jetzt geloescht
863 FuDraw::MouseButtonUp(rMEvt
);
867 /**********************************************************************
869 **********************************************************************/
870 if ( mpView
->IsAction() )
872 if ( mpView
->IsInsObjPoint() )
874 mpView
->EndInsObjPoint(SDRCREATE_FORCEEND
);
876 else if ( mpView
->IsDragObj() )
878 FrameView
* pFrameView
= mpViewShell
->GetFrameView();
879 BOOL bDragWithCopy
= (rMEvt
.IsMod1() && pFrameView
->IsDragWithCopy());
883 bDragWithCopy
= !mpView
->IsPresObjSelected(FALSE
, TRUE
);
886 mpView
->SetDragWithCopy(bDragWithCopy
);
887 mpView
->EndDragObj( mpView
->IsDragWithCopy() );
893 USHORT nDrgLog2
= USHORT ( mpWindow
->PixelToLogic(Size(DRGPIX
,0)).Width() );
894 Point aPos
= mpWindow
->PixelToLogic( rMEvt
.GetPosPixel() );
896 if (Abs(aMDPos
.X() - aPos
.X()) < nDrgLog2
&&
897 Abs(aMDPos
.Y() - aPos
.Y()) < nDrgLog2
&&
898 !rMEvt
.IsShift() && !rMEvt
.IsMod2())
901 SdrHitKind eHit
= mpView
->PickAnything(rMEvt
, SDRMOUSEBUTTONDOWN
, aVEvt
);
903 if (eHit
== SDRHIT_NONE
)
905 // Klick auf der Stelle: deselektieren
906 mpView
->UnmarkAllObj();
911 else if (!rMEvt
.IsShift() && rMEvt
.IsMod1() && !rMEvt
.IsMod2() &&
912 Abs(aPnt
.X() - aMDPos
.X()) < nDrgLog
&&
913 Abs(aPnt
.Y() - aMDPos
.Y()) < nDrgLog
)
916 mpView
->MarkObj(aPnt
, nHitLog
, FALSE
, rMEvt
.IsMod1());
920 ForcePointer(&rMEvt
);
922 mpWindow
->ReleaseMouse();
924 FuDraw::MouseButtonUp(rMEvt
);
930 /*************************************************************************
932 |* Tastaturereignisse bearbeiten
934 |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert TRUE, andernfalls
937 \************************************************************************/
939 BOOL
FuSelection::KeyInput(const KeyEvent
& rKEvt
)
941 BOOL bReturn
= FALSE
;
943 switch (rKEvt
.GetKeyCode().GetCode())
947 bReturn
= FuSelection::cancel();
954 bReturn
= FuDraw::KeyInput(rKEvt
);
956 if(mpView
->GetMarkedObjectList().GetMarkCount() == 0)
958 mpView
->ResetCreationActive();
960 mpViewShell
->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT
, SFX_CALLMODE_ASYNCHRON
| SFX_CALLMODE_RECORD
);
969 /*************************************************************************
971 |* Function aktivieren
973 \************************************************************************/
975 void FuSelection::Activate()
978 mpView
->ResetCreationActive();
979 mpView
->SetEditMode(SDREDITMODE_EDIT
);
983 case SID_OBJECT_ROTATE
:
985 // (gemapter) Slot wird explizit auf Rotate gesetzt #31052#
986 if( mpViewShell
->ISA(DrawViewShell
) )
989 static_cast<DrawViewShell
*>(mpViewShell
)->GetSlotArray();
990 pSlotArray
[ 1 ] = SID_OBJECT_ROTATE
;
993 eMode
= SDRDRAG_ROTATE
;
995 if ( mpView
->GetDragMode() != eMode
)
996 mpView
->SetDragMode(eMode
);
1000 case SID_OBJECT_MIRROR
:
1002 eMode
= SDRDRAG_MIRROR
;
1004 if ( mpView
->GetDragMode() != eMode
)
1005 mpView
->SetDragMode(eMode
);
1009 case SID_OBJECT_CROP
:
1011 eMode
= SDRDRAG_CROP
;
1013 if ( mpView
->GetDragMode() != eMode
)
1014 mpView
->SetDragMode(eMode
);
1018 case SID_OBJECT_TRANSPARENCE
:
1020 eMode
= SDRDRAG_TRANSPARENCE
;
1022 if ( mpView
->GetDragMode() != eMode
)
1023 mpView
->SetDragMode(eMode
);
1027 case SID_OBJECT_GRADIENT
:
1029 eMode
= SDRDRAG_GRADIENT
;
1031 if ( mpView
->GetDragMode() != eMode
)
1032 mpView
->SetDragMode(eMode
);
1036 case SID_OBJECT_SHEAR
:
1038 eMode
= SDRDRAG_SHEAR
;
1040 if ( mpView
->GetDragMode() != eMode
)
1041 mpView
->SetDragMode(eMode
);
1045 case SID_OBJECT_CROOK_ROTATE
:
1047 eMode
= SDRDRAG_CROOK
;
1049 if ( mpView
->GetDragMode() != eMode
)
1051 mpView
->SetDragMode(eMode
);
1052 mpView
->SetCrookMode(SDRCROOK_ROTATE
);
1057 case SID_OBJECT_CROOK_SLANT
:
1059 eMode
= SDRDRAG_CROOK
;
1061 if ( mpView
->GetDragMode() != eMode
)
1063 mpView
->SetDragMode(eMode
);
1064 mpView
->SetCrookMode(SDRCROOK_SLANT
);
1069 case SID_OBJECT_CROOK_STRETCH
:
1071 eMode
= SDRDRAG_CROOK
;
1073 if ( mpView
->GetDragMode() != eMode
)
1075 mpView
->SetDragMode(eMode
);
1076 mpView
->SetCrookMode(SDRCROOK_STRETCH
);
1081 case SID_CONVERT_TO_3D_LATHE
:
1083 eMode
= SDRDRAG_MIRROR
;
1084 bSuppressChangesOfSelection
= TRUE
;
1086 if ( mpView
->GetDragMode() != eMode
)
1087 mpView
->SetDragMode(eMode
);
1089 if (!mpView
->Is3DRotationCreationActive())
1090 mpView
->Start3DCreation();
1092 bSuppressChangesOfSelection
= FALSE
;
1098 eMode
= SDRDRAG_MOVE
;
1100 if ( mpView
->GetDragMode() != eMode
)
1101 mpView
->SetDragMode(eMode
);
1106 if (nSlotId
!= SID_OBJECT_ROTATE
)
1108 bTempRotation
= FALSE
;
1116 /*************************************************************************
1118 |* Function deaktivieren
1120 \************************************************************************/
1122 void FuSelection::Deactivate()
1124 FuDraw::Deactivate();
1128 /*************************************************************************
1130 |* Selektion hat sich geaendert
1132 \************************************************************************/
1134 void FuSelection::SelectionHasChanged()
1136 bSelectionChanged
= TRUE
;
1138 FuDraw::SelectionHasChanged();
1140 if ((mpView
->Is3DRotationCreationActive() && !bSuppressChangesOfSelection
))
1142 // Wechsel Rotationskoerper -> Selektion
1143 mpView
->ResetCreationActive();
1144 nSlotId
= SID_OBJECT_SELECT
;
1148 // Activate the right tool bar for the current context of the view.
1149 mpViewShell
->GetViewShellBase().GetToolBarManager()->SelectionHasChanged(*mpViewShell
, *mpView
);
1153 /*************************************************************************
1155 |* Aktuellen Bezier-Editmodus setzen
1157 \************************************************************************/
1159 void FuSelection::SetEditMode(USHORT nMode
)
1163 if (nEditMode
== SID_BEZIER_INSERT
)
1165 mpView
->SetInsObjPointMode(TRUE
);
1169 mpView
->SetInsObjPointMode(FALSE
);
1174 SfxBindings
& rBindings
= mpViewShell
->GetViewFrame()->GetBindings();
1175 rBindings
.Invalidate(SID_BEZIER_MOVE
);
1176 rBindings
.Invalidate(SID_BEZIER_INSERT
);
1179 /*************************************************************************
1181 |* Animation oder Interaktion ausfuehren
1183 \************************************************************************/
1185 BOOL
FuSelection::AnimateObj(SdrObject
* pObj
, const Point
& rPos
)
1187 BOOL bAnimated
= FALSE
;
1188 BOOL bClosed
= pObj
->IsClosedObj();
1189 BOOL bFilled
= FALSE
;
1193 SfxItemSet
aSet(mpDoc
->GetPool());
1195 aSet
.Put(pObj
->GetMergedItemSet());
1197 const XFillStyleItem
& rFillStyle
= (const XFillStyleItem
&) aSet
.Get(XATTR_FILLSTYLE
);
1198 bFilled
= rFillStyle
.GetValue() != XFILL_NONE
;
1201 const SetOfByte
* pVisiLayer
= &mpView
->GetSdrPageView()->GetVisibleLayers();
1202 USHORT nHitLog
= USHORT ( mpWindow
->PixelToLogic(Size(HITPIX
,0)).Width() );
1203 const long n2HitLog
= nHitLog
* 2;
1204 Point
aHitPosR(rPos
);
1205 Point
aHitPosL(rPos
);
1206 Point
aHitPosT(rPos
);
1207 Point
aHitPosB(rPos
);
1209 aHitPosR
.X() += n2HitLog
;
1210 aHitPosL
.X() -= n2HitLog
;
1211 aHitPosT
.Y() += n2HitLog
;
1212 aHitPosB
.Y() -= n2HitLog
;
1216 (SdrObjectPrimitiveHit(*pObj
, aHitPosR
, nHitLog
, *mpView
->GetSdrPageView(), pVisiLayer
, false) &&
1217 SdrObjectPrimitiveHit(*pObj
, aHitPosL
, nHitLog
, *mpView
->GetSdrPageView(), pVisiLayer
, false) &&
1218 SdrObjectPrimitiveHit(*pObj
, aHitPosT
, nHitLog
, *mpView
->GetSdrPageView(), pVisiLayer
, false) &&
1219 SdrObjectPrimitiveHit(*pObj
, aHitPosB
, nHitLog
, *mpView
->GetSdrPageView(), pVisiLayer
, false) ) )
1221 if ( mpDoc
->GetIMapInfo( pObj
) )
1223 const IMapObject
* pIMapObj
= mpDoc
->GetHitIMapObject( pObj
, rPos
, *mpWindow
);
1225 if ( pIMapObj
&& pIMapObj
->GetURL().Len() )
1227 // Sprung zu Dokument
1228 mpWindow
->ReleaseMouse();
1229 SfxStringItem
aStrItem(SID_FILE_NAME
, pIMapObj
->GetURL());
1230 SfxStringItem
aReferer(SID_REFERER
, mpDocSh
->GetMedium()->GetName());
1231 SfxViewFrame
* pFrame
= mpViewShell
->GetViewFrame();
1232 SfxFrameItem
aFrameItem(SID_DOCFRAME
, pFrame
);
1233 SfxBoolItem
aBrowseItem( SID_BROWSE
, TRUE
);
1234 mpWindow
->ReleaseMouse();
1235 pFrame
->GetDispatcher()->
1236 Execute(SID_OPENDOC
, SFX_CALLMODE_ASYNCHRON
| SFX_CALLMODE_RECORD
,
1237 &aStrItem
, &aFrameItem
, &aBrowseItem
, &aReferer
, 0L);
1242 else if (!mpDocSh
->ISA(GraphicDocShell
) &&
1243 mpView
->ISA(DrawView
) &&
1244 mpDoc
->GetAnimationInfo(pObj
))
1246 /**********************************************************
1247 * Animations-Objekt in der Mitte getroffen -> Interaktion
1248 **********************************************************/
1249 SdAnimationInfo
* pInfo
= mpDoc
->GetAnimationInfo(pObj
);
1250 DrawViewShell
* pDrViewSh
= static_cast<DrawViewShell
*>(mpViewShell
);
1251 mpWindow
->ReleaseMouse();
1253 switch (pInfo
->meClickAction
)
1255 case presentation::ClickAction_BOOKMARK
:
1257 // Sprung zu Bookmark (Seite oder Objekt)
1258 SfxStringItem
aItem(SID_NAVIGATOR_OBJECT
, pInfo
->GetBookmark());
1259 mpViewShell
->GetViewFrame()->GetDispatcher()->
1260 Execute(SID_NAVIGATOR_OBJECT
, SFX_CALLMODE_SLOT
| SFX_CALLMODE_RECORD
, &aItem
, 0L);
1265 case presentation::ClickAction_DOCUMENT
:
1267 String
sBookmark( pInfo
->GetBookmark() );
1268 // Sprung zu Dokument
1269 if (sBookmark
.Len())
1271 SfxStringItem
aReferer(SID_REFERER
, mpDocSh
->GetMedium()->GetName());
1272 SfxStringItem
aStrItem(SID_FILE_NAME
, sBookmark
);
1273 SfxViewFrame
* pFrame
= mpViewShell
->GetViewFrame();
1274 SfxFrameItem
aFrameItem(SID_DOCFRAME
, pFrame
);
1275 SfxBoolItem
aBrowseItem( SID_BROWSE
, TRUE
);
1276 pFrame
->GetDispatcher()->
1277 Execute(SID_OPENDOC
, SFX_CALLMODE_ASYNCHRON
| SFX_CALLMODE_RECORD
,
1278 &aStrItem
, &aFrameItem
, &aBrowseItem
, &aReferer
, 0L);
1285 case presentation::ClickAction_PREVPAGE
:
1287 // Sprung zur vorherigen Seite
1288 SfxUInt16Item
aItem(SID_NAVIGATOR_PAGE
, PAGE_PREVIOUS
);
1289 mpViewShell
->GetViewFrame()->GetDispatcher()->
1290 Execute(SID_NAVIGATOR_PAGE
, SFX_CALLMODE_SLOT
| SFX_CALLMODE_RECORD
,
1296 case presentation::ClickAction_NEXTPAGE
:
1298 // Sprung zur naechsten Seite
1299 SfxUInt16Item
aItem(SID_NAVIGATOR_PAGE
, PAGE_NEXT
);
1300 mpViewShell
->GetViewFrame()->GetDispatcher()->
1301 Execute(SID_NAVIGATOR_PAGE
, SFX_CALLMODE_SLOT
| SFX_CALLMODE_RECORD
,
1307 case presentation::ClickAction_FIRSTPAGE
:
1309 // Sprung zu erster Seite
1310 SfxUInt16Item
aItem(SID_NAVIGATOR_PAGE
, PAGE_FIRST
);
1311 mpViewShell
->GetViewFrame()->GetDispatcher()->
1312 Execute(SID_NAVIGATOR_PAGE
, SFX_CALLMODE_SLOT
| SFX_CALLMODE_RECORD
,
1318 case presentation::ClickAction_LASTPAGE
:
1320 // Sprung zu letzter Seite
1321 SfxUInt16Item
aItem(SID_NAVIGATOR_PAGE
, PAGE_LAST
);
1322 mpViewShell
->GetViewFrame()->GetDispatcher()->
1323 Execute(SID_NAVIGATOR_PAGE
, SFX_CALLMODE_SLOT
| SFX_CALLMODE_RECORD
,
1329 case presentation::ClickAction_SOUND
:
1333 mxPlayer
.set( avmedia::MediaWindow::createPlayer( pInfo
->GetBookmark()), uno::UNO_QUERY_THROW
);
1336 catch( uno::Exception
& e
)
1344 case presentation::ClickAction_VERB
:
1347 mpView
->UnmarkAll();
1348 mpView
->MarkObj(pObj
, mpView
->GetSdrPageView(), FALSE
, FALSE
);
1349 pDrViewSh
->DoVerb((sal_Int16
)pInfo
->mnVerb
);
1354 case presentation::ClickAction_PROGRAM
:
1356 String aBaseURL
= GetDocSh()->GetMedium()->GetBaseURL();
1357 INetURLObject
aURL( ::URIHelper::SmartRel2Abs( INetURLObject(aBaseURL
), pInfo
->GetBookmark(),
1358 URIHelper::GetMaybeFileHdl(), true, false,
1359 INetURLObject::WAS_ENCODED
, INetURLObject::DECODE_UNAMBIGUOUS
) );
1361 if( INET_PROT_FILE
== aURL
.GetProtocol() )
1363 SfxStringItem
aUrl( SID_FILE_NAME
, aURL
.GetMainURL( INetURLObject::NO_DECODE
) );
1364 SfxBoolItem
aBrowsing( SID_BROWSE
, TRUE
);
1366 SfxViewFrame
* pViewFrm
= SfxViewFrame::Current();
1368 pViewFrm
->GetDispatcher()->Execute( SID_OPENDOC
,
1369 SFX_CALLMODE_ASYNCHRON
| SFX_CALLMODE_RECORD
,
1379 case presentation::ClickAction_MACRO
:
1382 String aMacro
= pInfo
->GetBookmark();
1384 if ( SfxApplication::IsXScriptURL( aMacro
) )
1387 uno::Sequence
< sal_Int16
> aOutArgsIndex
;
1388 uno::Sequence
< uno::Any
> aOutArgs
;
1389 uno::Sequence
< uno::Any
>* pInArgs
=
1390 new uno::Sequence
< uno::Any
>(0);
1392 ErrCode eErr
= mpDocSh
->CallXScript( aMacro
,
1393 *pInArgs
, aRet
, aOutArgsIndex
, aOutArgs
);
1395 // Check the return value from the script
1396 BOOL bTmp
= sal_False
;
1397 if ( eErr
== ERRCODE_NONE
&&
1398 aRet
.getValueType() == getCppuBooleanType() &&
1399 sal_True
== ( aRet
>>= bTmp
) &&
1411 // aMacro has got following format:
1412 // "Macroname.Modulname.Libname.Documentname" or
1413 // "Macroname.Modulname.Libname.Applicationsname"
1415 aMacro
.GetToken(0, sal_Unicode('.'));
1417 aMacro
.GetToken(1, sal_Unicode('.'));
1419 aMacro
.GetToken(2, sal_Unicode('.'));
1421 aMacro
.GetToken(3, sal_Unicode('.'));
1423 // In this moment the Call-method only
1424 // resolves modulename+macroname
1425 String
aExecMacro(aModulName
);
1426 aExecMacro
.Append( sal_Unicode('.') );
1427 aExecMacro
.Append( aMacroName
);
1428 bAnimated
= mpDocSh
->GetBasic()->Call(aExecMacro
);
1442 mpView
->ISA(DrawView
) &&
1443 !mpDocSh
->ISA(GraphicDocShell
) &&
1444 SlideShow::IsRunning( mpViewShell
->GetViewShellBase() ) &&
1445 mpDoc
->GetAnimationInfo(pObj
))
1447 /**********************************************************
1448 * Effekt-Objekt in der Mitte getroffen -> Effekt abspielen
1449 **********************************************************/
1450 SdAnimationInfo
* pInfo
= mpDoc
->GetAnimationInfo(pObj
);
1452 switch (pInfo
->meClickAction
)
1454 case presentation::ClickAction_VANISH
:
1455 case presentation::ClickAction_INVISIBLE
:
1470 /** is called when the currenct function should be aborted. <p>
1471 This is used when a function gets a KEY_ESCAPE but can also
1474 @returns true if a active function was aborted
1476 bool FuSelection::cancel()
1478 if (mpView
->Is3DRotationCreationActive())
1480 mpView
->ResetCreationActive();
1481 mpViewShell
->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT
, SFX_CALLMODE_ASYNCHRON
| SFX_CALLMODE_RECORD
);
1493 SdrObject
* FuSelection::pickObject (const Point
& rTestPoint
)
1495 SdrObject
* pObject
= NULL
;
1496 SdrPageView
* pPageView
;
1497 USHORT nHitLog
= USHORT (mpWindow
->PixelToLogic(Size(HITPIX
,0)).Width());
1498 mpView
->PickObj (rTestPoint
, nHitLog
, pObject
, pPageView
, SDRSEARCH_PICKMARKABLE
);
1501 } // end of namespace sd