xref: /trunk/main/sd/source/ui/func/fusel.cxx (revision a0d53b35b9c5a6bd9856ab272d521493ba628169)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sd.hxx"
26 
27 
28 #include "fusel.hxx"
29 #include <vos/process.hxx>
30 #include <basic/sbstar.hxx>
31 #include <svx/svdpagv.hxx>
32 #include <svx/svdogrp.hxx>
33 #include <svx/polysc3d.hxx>
34 #include "drawview.hxx"
35 #include <svtools/imapobj.hxx>
36 #include <svl/urihelper.hxx>
37 #include <unotools/localfilehelper.hxx>
38 #include <svx/svxids.hrc>
39 #include <svx/xfillit0.hxx>
40 #include <sfx2/app.hxx>
41 #include <sfx2/viewfrm.hxx>
42 #include <svl/aeitem.hxx>
43 #include <svl/stritem.hxx>
44 #include <svl/intitem.hxx>
45 #include <sfx2/dispatch.hxx>
46 #include <tools/urlobj.hxx>
47 #include <sfx2/docfile.hxx>
48 #include <tools/debug.hxx>
49 #include <editeng/eeitem.hxx>
50 #include <editeng/flditem.hxx>
51 
52 #include <svx/svdotable.hxx>
53 
54 #include "app.hrc"
55 #include "strings.hrc"
56 #include "res_bmp.hrc"
57 #include "GraphicDocShell.hxx"
58 #include "app.hxx"
59 #include "DrawDocShell.hxx"
60 #include "stlpool.hxx"
61 #include "anmdef.hxx"
62 #include "anminfo.hxx"
63 #include "fudraw.hxx"
64 #include "ViewShell.hxx"
65 #include "ViewShellBase.hxx"
66 #ifndef SD_FRAMW_VIEW_HXX
67 #include "FrameView.hxx"
68 #endif
69 #include "View.hxx"
70 #ifndef SD_WINDOW_SHELL_HXX
71 #include "Window.hxx"
72 #endif
73 #include "drawdoc.hxx"
74 #include "sdpage.hxx"
75 #include "DrawViewShell.hxx"
76 #include "ToolBarManager.hxx"
77 #include "pgjump.hxx"
78 #include <svx/globl3d.hxx>
79 #include "Client.hxx"
80 
81 #include "slideshow.hxx"
82 
83 // #108981#
84 #include <svx/svdundo.hxx>
85 #include <avmedia/mediawindow.hxx>
86 
87 #include <svx/sdrhittesthelper.hxx>
88 
89 using namespace ::com::sun::star;
90 
91 namespace sd {
92 
93 TYPEINIT1( FuSelection, FuDraw );
94 
95 /*************************************************************************
96 |*
97 |* Konstruktor
98 |*
99 \************************************************************************/
100 
101 FuSelection::FuSelection (
102     ViewShell* pViewSh,
103     ::sd::Window* pWin,
104     ::sd::View* pView,
105     SdDrawDocument* pDoc,
106     SfxRequest& rReq)
107     : FuDraw(pViewSh, pWin, pView, pDoc, rReq),
108       bTempRotation(sal_False),
109       bSelectionChanged(sal_False),
110       bHideAndAnimate(sal_False),
111       pHdl(NULL),
112       bSuppressChangesOfSelection(sal_False),
113       bMirrorSide0(sal_False),
114       nEditMode(SID_BEZIER_MOVE),
115       pWaterCanCandidate(NULL)
116 //IAccessibility2 Implementation 2009-----
117   //Solution: Add Shift+UP/DOWN/LEFT/RIGHT key to move the position of insert point,
118   //and SHIFT+ENTER key to decide the postion and draw the new insert point
119     ,bBeginInsertPoint(sal_False),
120     oldPoint(0,0)
121   ,bMovedToCenterPoint(sal_False)
122 //-----IAccessibility2 Implementation 2009
123 {
124 }
125 
126 FunctionReference FuSelection::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
127 {
128     FunctionReference xFunc( new FuSelection( pViewSh, pWin, pView, pDoc, rReq ) );
129     xFunc->DoExecute(rReq);
130     return xFunc;
131 }
132 
133 void FuSelection::DoExecute( SfxRequest& rReq )
134 {
135     FuDraw::DoExecute( rReq );
136 
137     // Objektbar auswaehlen
138     SelectionHasChanged();
139 }
140 
141 /*************************************************************************
142 |*
143 |* Destruktor
144 |*
145 \************************************************************************/
146 
147 FuSelection::~FuSelection()
148 {
149     mpView->UnmarkAllPoints();
150     mpView->ResetCreationActive();
151 
152     if ( mpView->GetDragMode() != SDRDRAG_MOVE )
153     {
154         mpView->SetDragMode(SDRDRAG_MOVE);
155     }
156 }
157 
158 /*************************************************************************
159 |*
160 |* MouseButtonDown-event
161 |*
162 \************************************************************************/
163 
164 sal_Bool FuSelection::MouseButtonDown(const MouseEvent& rMEvt)
165 {
166     // Hack fuer #?????#
167     bHideAndAnimate = sal_False;
168 
169     pHdl = NULL;
170     sal_Bool bReturn = FuDraw::MouseButtonDown(rMEvt);
171     sal_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
175     // menu.
176     const bool bSelectionOnly = rMEvt.IsRight();
177 
178     bMBDown = sal_True;
179     bSelectionChanged = sal_False;
180 
181     if ( mpView->IsAction() )
182     {
183         if ( rMEvt.IsRight() )
184             mpView->BckAction();
185         return sal_True;
186     }
187 
188     sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
189     sal_uInt16 nHitLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(HITPIX,0)).Width() );
190 
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 sal_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()))
200     {
201         /******************************************************************
202         * KEIN BEZIER_EDITOR
203         ******************************************************************/
204         mpWindow->CaptureMouse();
205         pHdl = mpView->PickHandle(aMDPos);
206         SdrObject* pObj;
207         SdrPageView* pPV;
208 
209         long nAngle0  = GetAngle(aMDPos - mpView->GetRef1());
210         nAngle0 -= 27000;
211         nAngle0 = NormAngle360(nAngle0);
212         bMirrorSide0 = sal_Bool (nAngle0 < 18000L);
213 
214         if (!pHdl && mpView->Is3DRotationCreationActive())
215         {
216             /******************************************************************
217             * Wenn 3D-Rotationskoerper erstellt werden sollen, jetzt
218             * die Erstellung beenden
219             ******************************************************************/
220             bSuppressChangesOfSelection = sal_True;
221             if(mpWindow)
222                 mpWindow->EnterWait();
223             mpView->End3DCreation();
224             bSuppressChangesOfSelection = sal_False;
225             mpView->ResetCreationActive();
226             if(mpWindow)
227                 mpWindow->LeaveWait();
228         }
229 
230         sal_Bool bTextEdit = sal_False;
231         SdrViewEvent aVEvt;
232         SdrHitKind eHit = mpView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
233 
234         if ( eHit == SDRHIT_TEXTEDITOBJ && ( mpViewShell->GetFrameView()->IsQuickEdit() || dynamic_cast< sdr::table::SdrTableObj* >( aVEvt.pObj ) != NULL ) )
235         {
236             bTextEdit = sal_True;
237         }
238 
239         if(!bTextEdit
240             && !mpDocSh->IsReadOnly()
241             && ((mpView->IsMarkedHit(aMDPos, nHitLog) && !rMEvt.IsShift() && !rMEvt.IsMod2()) || pHdl != NULL)
242             && (rMEvt.GetClicks() != 2)
243             )
244         {
245             if (!pHdl && mpView->Is3DRotationCreationActive())
246             {
247                 // Wechsel Rotationskoerper -> Selektion
248                 mpView->ResetCreationActive();
249             }
250             else if (bWaterCan)
251             {
252                 // Remember the selected object for proper handling in
253                 // MouseButtonUp().
254                 pWaterCanCandidate = pickObject (aMDPos);
255             }
256             else
257             {
258                 // Handle oder markiertes Objekt getroffen
259                 bFirstMouseMove = sal_True;
260                 aDragTimer.Start();
261             }
262 
263             if ( ! rMEvt.IsRight())
264                 mpView->BegDragObj(aMDPos, (OutputDevice*) NULL, pHdl, nDrgLog);
265             bReturn = sal_True;
266         }
267         else
268         {
269             if (!rMEvt.IsMod2() && mpView->PickObj(aMDPos, mpView->getHitTolLog(), pObj, pPV, SDRSEARCH_PICKMACRO))
270             {
271                 mpView->BegMacroObj(aMDPos, nHitLog, pObj, pPV, mpWindow);
272                 bReturn = sal_True;
273             }
274             else if ( bTextEdit )
275             {
276                 sal_uInt16 nSdrObjKind = aVEvt.pObj->GetObjIdentifier();
277 
278                 if (aVEvt.pObj->GetObjInventor() == SdrInventor &&
279                     (nSdrObjKind == OBJ_TEXT ||
280                      nSdrObjKind == OBJ_TITLETEXT ||
281                      nSdrObjKind == OBJ_OUTLINETEXT ||
282                      !aVEvt.pObj->IsEmptyPresObj()))
283                 {
284                     // Seamless Editing: Verzweigen zur Texteingabe
285                     if (!rMEvt.IsShift())
286                         mpView->UnmarkAll();
287 
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
293                 }
294             }
295             else if ( !rMEvt.IsMod2() && rMEvt.GetClicks() == 1 &&
296                       aVEvt.eEvent == SDREVENT_EXECUTEURL )
297             {
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, sal_True );
302                 SfxViewFrame* pFrame = mpViewShell->GetViewFrame();
303                 mpWindow->ReleaseMouse();
304 
305                 if (rMEvt.IsMod1())
306                 {
307                     // Im neuen Frame oeffnen
308                     pFrame->GetDispatcher()->Execute(SID_OPENDOC, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
309                                 &aStrItem, &aBrowseItem, &aReferer, 0L);
310                 }
311                 else
312                 {
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);
317                 }
318 
319                 bReturn = sal_True;
320             }
321             else if(!rMEvt.IsMod2()
322                 && mpViewShell->ISA(DrawViewShell)
323                 )
324             {
325                 if(mpView->PickObj(aMDPos, mpView->getHitTolLog(), pObj, pPV, SDRSEARCH_ALSOONMASTER))
326                 {
327                     // Animate object when not just selecting.
328                     if ( ! bSelectionOnly)
329                         bReturn = AnimateObj(pObj, aMDPos);
330 
331                     if (!bReturn && (pObj->ISA(SdrObjGroup) || pObj->ISA(E3dPolyScene)))
332                     {
333                         if(rMEvt.GetClicks() == 1)
334                         {
335                             // In die Gruppe hineinschauen
336                             if (mpView->PickObj(aMDPos, mpView->getHitTolLog(), pObj, pPV, SDRSEARCH_ALSOONMASTER | SDRSEARCH_DEEP))
337                                 bReturn = AnimateObj(pObj, aMDPos);
338                         }
339                         else if( !bReadOnly && rMEvt.GetClicks() == 2)
340                         {
341                             // Neu: Doppelklick auf selektiertes Gruppenobjekt
342                             // Gruppe betreten
343                             if ( ! bSelectionOnly
344                                 && pObj
345                                 && pObj->GetPage() == pPV->GetPage())
346                                 bReturn = pPV->EnterGroup(pObj);
347                         }
348                     }
349                 }
350 
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()))
354                 {
355                     if(mpView->IsGroupEntered() && 2 == rMEvt.GetClicks())
356                     {
357                         // New: double click on empty space/on obj on MasterPage, leave group
358                         mpView->LeaveOneGroup();
359                         bReturn = sal_True;
360                     }
361                 }
362             }
363 
364             if (!bReturn)
365             {
366                 if (bWaterCan)
367                 {
368                     if ( ! (rMEvt.IsShift() || rMEvt.IsMod2()))
369                     {
370                         // Find the object under the current mouse position
371                         // and store it for the MouseButtonUp() method to
372                         // evaluate.
373                         pWaterCanCandidate = pickObject (aMDPos);
374                     }
375                 }
376                 else
377                 {
378                     bReturn = sal_True;
379                     sal_Bool bDeactivateOLE = sal_False;
380 
381                     if ( !rMEvt.IsShift() && !rMEvt.IsMod2() )
382                     {
383                         OSL_ASSERT (mpViewShell->GetViewShell()!=NULL);
384                         Client* pIPClient = static_cast<Client*>(
385                             mpViewShell->GetViewShell()->GetIPClient());
386 
387                         if (pIPClient && pIPClient->IsObjectInPlaceActive())
388                         {
389                             // OLE-Objekt wird im nachfolgenden UnmarkAll() deaktiviert
390                             bDeactivateOLE = sal_True;
391                         }
392 
393                         mpView->UnmarkAll();
394                     }
395 
396                     sal_Bool bMarked = sal_False;
397 
398                     if ( !rMEvt.IsMod1() && !bDeactivateOLE)
399                     {
400                         if ( rMEvt.IsMod2() )
401                         {
402                             bMarked = mpView->MarkNextObj(aMDPos, nHitLog, rMEvt.IsShift() );
403                         }
404                         else
405                         {
406                             sal_Bool bToggle = sal_False;
407 
408                             if (rMEvt.IsShift() && mpView->GetMarkedObjectList().GetMarkCount() > 1)
409                             {
410                                 // Bei Einfachselektion kein Toggle
411                                 bToggle = sal_True;
412                             }
413 
414                             bMarked = mpView->MarkObj(aMDPos, nHitLog, bToggle, sal_False);
415                         }
416                     }
417 
418                     if( !bDeactivateOLE )
419                     {
420                         if ( !bReadOnly &&
421                              bMarked                                                   &&
422                              (!rMEvt.IsShift() || mpView->IsMarkedHit(aMDPos, nHitLog)))
423                         {
424                             /**********************************************************
425                              * Objekt verschieben
426                              **********************************************************/
427                             aDragTimer.Start();
428 
429                             pHdl=mpView->PickHandle(aMDPos);
430                             if ( ! rMEvt.IsRight())
431                                 mpView->BegDragObj(aMDPos, (OutputDevice*) NULL, pHdl, nDrgLog);
432                         }
433                         else
434                         {
435                             /**********************************************************
436                              * Objekt selektieren
437                              **********************************************************/
438                             if ( ! rMEvt.IsRight())
439                                 mpView->BegMarkObj(aMDPos);
440                         }
441                     }
442 
443                     if( bMarked && bTempRotation && (nSlotId == SID_OBJECT_ROTATE) && !rMEvt.IsShift() && (rMEvt.GetClicks() != 2) )
444                     {
445                         nSlotId = SID_OBJECT_SELECT;
446                         Activate();
447                     }
448                 }
449             }
450         }
451     }
452     else if ( !bReadOnly
453               && (rMEvt.IsLeft() || rMEvt.IsRight())
454               && !mpView->IsAction())
455     {
456         /**********************************************************************
457         * BEZIER-EDITOR
458         **********************************************************************/
459         mpWindow->CaptureMouse();
460         SdrViewEvent aVEvt;
461         SdrHitKind eHit = mpView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
462 
463         if (eHit == SDRHIT_HANDLE && aVEvt.pHdl->GetKind() == HDL_BWGT)
464         {
465             /******************************************************************
466             * Handle draggen
467             ******************************************************************/
468             if ( ! rMEvt.IsRight())
469                 mpView->BegDragObj(aMDPos, (OutputDevice*) NULL, aVEvt.pHdl, nDrgLog);
470         }
471         else if (eHit == SDRHIT_MARKEDOBJECT && nEditMode == SID_BEZIER_INSERT)
472         {
473             /******************************************************************
474             * Klebepunkt einfuegen
475             ******************************************************************/
476             mpView->BegInsObjPoint(aMDPos, rMEvt.IsMod1());
477         }
478         else if (eHit == SDRHIT_MARKEDOBJECT && rMEvt.IsMod1())
479         {
480             /******************************************************************
481             * Klebepunkt selektieren
482             ******************************************************************/
483             if (!rMEvt.IsShift())
484                 mpView->UnmarkAllPoints();
485 
486             if ( ! rMEvt.IsRight())
487                 mpView->BegMarkPoints(aMDPos);
488         }
489         else if (eHit == SDRHIT_MARKEDOBJECT && !rMEvt.IsShift() && !rMEvt.IsMod2())
490         {
491             /******************************************************************
492             * Objekt verschieben
493             ******************************************************************/
494             if ( ! rMEvt.IsRight())
495                 mpView->BegDragObj(aMDPos, (OutputDevice*) NULL, NULL, nDrgLog);
496         }
497         else if (eHit == SDRHIT_HANDLE)
498         {
499             /******************************************************************
500             * Klebepunkt selektieren
501             ******************************************************************/
502             if (!mpView->IsPointMarked(*aVEvt.pHdl) || rMEvt.IsShift())
503             {
504                 if (!rMEvt.IsShift())
505                 {
506                     mpView->UnmarkAllPoints();
507                     pHdl = mpView->PickHandle(aMDPos);
508                 }
509                 else
510                 {
511                     if (mpView->IsPointMarked(*aVEvt.pHdl))
512                     {
513                         mpView->UnmarkPoint(*aVEvt.pHdl);
514                         pHdl = NULL;
515                     }
516                     else
517                     {
518                         pHdl = mpView->PickHandle(aMDPos);
519                     }
520                 }
521 
522                 if (pHdl)
523                 {
524                     mpView->MarkPoint(*pHdl);
525                     if ( ! rMEvt.IsRight())
526                         mpView->BegDragObj(aMDPos, (OutputDevice*) NULL, pHdl, nDrgLog);
527                 }
528             }
529             else
530             {
531                 // #90239# point IS marked and NO shift is pressed. Start
532                 // dragging of selected point(s)
533                 pHdl = mpView->PickHandle(aMDPos);
534                 if(pHdl)
535                     if ( ! rMEvt.IsRight())
536                         mpView->BegDragObj(aMDPos, (OutputDevice*)NULL, pHdl, nDrgLog);
537             }
538         }
539         else
540         {
541             /******************************************************************
542             * Objekt selektieren oder draggen
543             ******************************************************************/
544             if (!rMEvt.IsShift() && !rMEvt.IsMod2() && eHit == SDRHIT_UNMARKEDOBJECT)
545             {
546                mpView->UnmarkAllObj();
547             }
548 
549             sal_Bool bMarked = sal_False;
550 
551             if (!rMEvt.IsMod1())
552             {
553                 if (rMEvt.IsMod2())
554                 {
555                     bMarked = mpView->MarkNextObj(aMDPos, nHitLog, rMEvt.IsShift());
556                 }
557                 else
558                 {
559                     bMarked = mpView->MarkObj(aMDPos, nHitLog, rMEvt.IsShift(), sal_False);
560                 }
561             }
562 
563             if (bMarked &&
564                 (!rMEvt.IsShift() || eHit == SDRHIT_MARKEDOBJECT))
565             {
566                 // Objekt verschieben
567                 if ( ! rMEvt.IsRight())
568                     mpView->BegDragObj(aMDPos, (OutputDevice*) NULL, aVEvt.pHdl, nDrgLog);
569             }
570             else if (mpView->AreObjectsMarked())
571             {
572                 /**************************************************************
573                 * Klebepunkt selektieren
574                 **************************************************************/
575                 if (!rMEvt.IsShift())
576                     mpView->UnmarkAllPoints();
577 
578                 if ( ! rMEvt.IsRight())
579                     mpView->BegMarkPoints(aMDPos);
580             }
581             else
582             {
583                 /**************************************************************
584                 * Objekt selektieren
585                 **************************************************************/
586                 if ( ! rMEvt.IsRight())
587                     mpView->BegMarkObj(aMDPos);
588             }
589 
590             ForcePointer(&rMEvt);
591         }
592     }
593 
594     if (!bIsInDragMode)
595     {
596         ForcePointer(&rMEvt);
597     }
598 
599     return bReturn;
600 }
601 
602 /*************************************************************************
603 |*
604 |* MouseMove-event
605 |*
606 \************************************************************************/
607 
608 sal_Bool FuSelection::MouseMove(const MouseEvent& rMEvt)
609 {
610     sal_Bool bReturn = FuDraw::MouseMove(rMEvt);
611 
612     if (aDragTimer.IsActive())
613     {
614         if(bFirstMouseMove)
615         {
616             bFirstMouseMove = sal_False;
617         }
618         else
619         {
620             aDragTimer.Stop();
621         }
622     }
623 
624     if (mpView->IsAction())
625     {
626         Point aPix(rMEvt.GetPosPixel());
627         Point aPnt(mpWindow->PixelToLogic(aPix));
628 
629         ForceScroll(aPix);
630 
631         if (mpView->IsInsObjPoint())
632         {
633             mpView->MovInsObjPoint(aPnt);
634         }
635         else
636         {
637             mpView->MovAction(aPnt);
638         }
639     }
640 
641     ForcePointer(&rMEvt);
642 
643     return (bReturn);
644 }
645 
646 /*************************************************************************
647 |*
648 |* MouseButtonUp-event
649 |*
650 \************************************************************************/
651 
652 sal_Bool FuSelection::MouseButtonUp(const MouseEvent& rMEvt)
653 {
654     sal_Bool bReturn = sal_False;
655     // When the right mouse button is pressed then only select objects
656     // (and deselect others) as a preparation for showing the context
657     // menu.
658     const bool bSelectionOnly = rMEvt.IsRight();
659 
660     if (bHideAndAnimate)
661     {
662         // Animation laeuft noch -> sofort returnieren
663         bHideAndAnimate = sal_False;
664         pHdl = NULL;
665         mpWindow->ReleaseMouse();
666         return(sal_True);
667     }
668 
669     if (aDragTimer.IsActive() )
670     {
671         aDragTimer.Stop();
672         bIsInDragMode = sal_False;
673     }
674 
675     if( !mpView )
676         return (sal_False);
677 
678     Point aPnt( mpWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
679     sal_uInt16 nHitLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(HITPIX,0)).Width() );
680     sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
681 
682     if (mpView->IsFrameDragSingles() || !mpView->HasMarkablePoints())
683     {
684         /**********************************************************************
685         * KEIN BEZIER_EDITOR
686         **********************************************************************/
687         if ( mpView->IsDragObj() )
688         {
689             /******************************************************************
690             * Objekt wurde verschoben
691             ******************************************************************/
692             FrameView* pFrameView = mpViewShell->GetFrameView();
693             sal_Bool bDragWithCopy = (rMEvt.IsMod1() && pFrameView->IsDragWithCopy());
694 
695             if (bDragWithCopy)
696             {
697                 bDragWithCopy = !mpView->IsPresObjSelected(sal_False, sal_True);
698             }
699 
700             mpView->SetDragWithCopy(bDragWithCopy);
701             mpView->EndDragObj( mpView->IsDragWithCopy() );
702 
703             mpView->ForceMarkedToAnotherPage();
704 
705             if (!rMEvt.IsShift() && !rMEvt.IsMod1() && !rMEvt.IsMod2() &&
706                 !bSelectionChanged                   &&
707                 Abs(aPnt.X() - aMDPos.X()) < nDrgLog &&
708                 Abs(aPnt.Y() - aMDPos.Y()) < nDrgLog)
709             {
710                 /**************************************************************
711                 * Toggle zw. Selektion und Rotation
712                 **************************************************************/
713                 SdrObject* pSingleObj = NULL;
714                 sal_uLong nMarkCount = mpView->GetMarkedObjectList().GetMarkCount();
715 
716                 if (nMarkCount==1)
717                 {
718                     pSingleObj = mpView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj();
719                 }
720 
721                 if (nSlotId == SID_OBJECT_SELECT
722                     && mpView->IsRotateAllowed()
723 
724                     && (rMEvt.GetClicks() != 2)
725                     && (mpViewShell->GetFrameView()->IsClickChangeRotation()
726                         || (pSingleObj
727                             && pSingleObj->GetObjInventor()==E3dInventor))
728                     && ! bSelectionOnly)
729 
730                 {
731                     bTempRotation = sal_True;
732                     nSlotId = SID_OBJECT_ROTATE;
733                     Activate();
734                 }
735                 else if (nSlotId == SID_OBJECT_ROTATE)
736                 {
737                     nSlotId = SID_OBJECT_SELECT;
738                     Activate();
739                 }
740             }
741             else if (nSlotId == SID_CONVERT_TO_3D_LATHE)
742             {
743                 if (!pHdl)
744                 {
745                     bSuppressChangesOfSelection = sal_True;
746                     mpView->Start3DCreation();
747                     bSuppressChangesOfSelection = sal_False;
748                 }
749                 else if (pHdl->GetKind() != HDL_MIRX &&
750                          pHdl->GetKind() != HDL_REF1 &&
751                          pHdl->GetKind() != HDL_REF2 && mpView->Is3DRotationCreationActive())
752                 {
753                     /*********************************************************
754                     * Wenn 3D-Rotationskoerper erstellt werden sollen, jetzt
755                     * die Erstellung beenden
756                     **********************************************************/
757                      long nAngle1  = GetAngle(aPnt - mpView->GetRef1());
758                      nAngle1 -= 27000;
759                      nAngle1 = NormAngle360(nAngle1);
760                      sal_Bool bMirrorSide1 = sal_Bool (nAngle1 < 18000L);
761 
762                      if (bMirrorSide0 != bMirrorSide1)
763                      {
764                          bSuppressChangesOfSelection = sal_True;
765                         if(mpWindow)
766                             mpWindow->EnterWait();
767                          mpView->End3DCreation();
768                          bSuppressChangesOfSelection = sal_False;
769                          nSlotId = SID_OBJECT_SELECT;
770                         if(mpWindow)
771                             mpWindow->LeaveWait();
772                          Activate();
773                     }
774                 }
775             }
776         }
777         else if (rMEvt.IsMod1()
778             && !rMEvt.IsMod2()
779             && Abs(aPnt.X() - aMDPos.X()) < nDrgLog
780             && Abs(aPnt.Y() - aMDPos.Y()) < nDrgLog)
781         {
782             // Gruppe betreten
783             mpView->MarkObj(aPnt, nHitLog, rMEvt.IsShift(), rMEvt.IsMod1());
784         }
785 
786         if (mpView->IsAction() )
787         {
788             mpView->EndAction();
789         }
790 
791         if( SD_MOD()->GetWaterCan() )
792         {
793             if( rMEvt.IsRight() )
794             {
795                 // Bei rechter Maustaste wird im Giesskannenmodus ein Undo ausgefuehrt
796                 mpViewShell->GetViewFrame()->GetDispatcher()->Execute( SID_UNDO, SFX_CALLMODE_ASYNCHRON );
797             }
798             else if (pWaterCanCandidate != NULL)
799             {
800                 // Is the candiate object still under the mouse?
801                 if (pickObject (aPnt) == pWaterCanCandidate)
802                 {
803                     SdStyleSheetPool* pPool = static_cast<SdStyleSheetPool*>(
804                         mpDocSh->GetStyleSheetPool());
805                     if (pPool != NULL)
806                     {
807                         SfxStyleSheet* pStyleSheet = static_cast<SfxStyleSheet*>(
808                             pPool->GetActualStyleSheet());
809                         if (pStyleSheet != NULL && mpView->IsUndoEnabled() )
810                         {
811                             // #108981#
812                             // Added UNDOs for the WaterCan mode. This was never done in
813                             // the past, thus it was missing all the time.
814                             SdrUndoAction* pUndoAttr = mpDoc->GetSdrUndoFactory().CreateUndoAttrObject(*pWaterCanCandidate, sal_True, sal_True);
815                             mpView->BegUndo(pUndoAttr->GetComment());
816                             mpView->AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoGeoObject(*pWaterCanCandidate));
817                             mpView->AddUndo(pUndoAttr);
818 
819                             pWaterCanCandidate->SetStyleSheet (pStyleSheet, sal_False);
820 
821                             // #108981#
822                             mpView->EndUndo();
823                         }
824                     }
825                 }
826             }
827             // else when there has been no object under the mouse when the
828             // button was pressed then nothing happens even when there is
829             // one now.
830         }
831 
832         sal_uInt16 nClicks = rMEvt.GetClicks();
833 
834         if (nClicks == 2 && rMEvt.IsLeft() && bMBDown &&
835             !rMEvt.IsMod1() && !rMEvt.IsShift() )
836         {
837             DoubleClick(rMEvt);
838         }
839 
840         bMBDown = sal_False;
841 
842         ForcePointer(&rMEvt);
843         pHdl = NULL;
844         mpWindow->ReleaseMouse();
845         SdrObject* pSingleObj = NULL;
846         sal_uLong nMarkCount = mpView->GetMarkedObjectList().GetMarkCount();
847 
848         if (nMarkCount==1)
849         {
850             pSingleObj = mpView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj();
851         }
852 
853         if ( (nSlotId != SID_OBJECT_SELECT && nMarkCount==0)                    ||
854              ( mpView->GetDragMode() == SDRDRAG_CROOK &&
855               !mpView->IsCrookAllowed( mpView->IsCrookNoContortion() ) ) ||
856              ( mpView->GetDragMode() == SDRDRAG_SHEAR &&
857               !mpView->IsShearAllowed() && !mpView->IsDistortAllowed() ) ||
858              ( nSlotId==SID_CONVERT_TO_3D_LATHE && pSingleObj &&
859               (pSingleObj->GetObjInventor() != SdrInventor         ||
860                pSingleObj->GetObjIdentifier() == OBJ_MEASURE) ) )
861         {
862             bReturn = sal_True;
863             ForcePointer(&rMEvt);
864             pHdl = NULL;
865             mpWindow->ReleaseMouse();
866             FuDraw::MouseButtonUp(rMEvt);
867             mpViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_SYNCHRON);
868             return bReturn; // VORSICHT, durch den synchronen Slot ist das objekt jetzt geloescht
869         }
870 
871         FuDraw::MouseButtonUp(rMEvt);
872     }
873     else
874     {
875         /**********************************************************************
876         * BEZIER_EDITOR
877         **********************************************************************/
878         if ( mpView->IsAction() )
879         {
880             if ( mpView->IsInsObjPoint() )
881             {
882                 mpView->EndInsObjPoint(SDRCREATE_FORCEEND);
883             }
884             else if ( mpView->IsDragObj() )
885             {
886                 FrameView* pFrameView = mpViewShell->GetFrameView();
887                 sal_Bool bDragWithCopy = (rMEvt.IsMod1() && pFrameView->IsDragWithCopy());
888 
889                 if (bDragWithCopy)
890                 {
891                     bDragWithCopy = !mpView->IsPresObjSelected(sal_False, sal_True);
892                 }
893 
894                 mpView->SetDragWithCopy(bDragWithCopy);
895                 mpView->EndDragObj( mpView->IsDragWithCopy() );
896             }
897             else
898             {
899                 mpView->EndAction();
900 
901                 sal_uInt16 nDrgLog2 = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
902                 Point aPos = mpWindow->PixelToLogic( rMEvt.GetPosPixel() );
903 
904                 if (Abs(aMDPos.X() - aPos.X()) < nDrgLog2 &&
905                     Abs(aMDPos.Y() - aPos.Y()) < nDrgLog2 &&
906                     !rMEvt.IsShift() && !rMEvt.IsMod2())
907                 {
908                     SdrViewEvent aVEvt;
909                     SdrHitKind eHit = mpView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
910 
911                     if (eHit == SDRHIT_NONE)
912                     {
913                         // Klick auf der Stelle: deselektieren
914                         mpView->UnmarkAllObj();
915                     }
916                 }
917             }
918         }
919         else if (!rMEvt.IsShift() && rMEvt.IsMod1() && !rMEvt.IsMod2() &&
920                  Abs(aPnt.X() - aMDPos.X()) < nDrgLog &&
921                  Abs(aPnt.Y() - aMDPos.Y()) < nDrgLog)
922         {
923             // Gruppe betreten
924             mpView->MarkObj(aPnt, nHitLog, sal_False, rMEvt.IsMod1());
925         }
926 
927 
928         ForcePointer(&rMEvt);
929         pHdl = NULL;
930         mpWindow->ReleaseMouse();
931 
932         FuDraw::MouseButtonUp(rMEvt);
933     }
934 
935     return (bReturn);
936 }
937 
938 /*************************************************************************
939 |*
940 |* Tastaturereignisse bearbeiten
941 |*
942 |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert sal_True, andernfalls
943 |* sal_False.
944 |*
945 \************************************************************************/
946 
947 sal_Bool FuSelection::KeyInput(const KeyEvent& rKEvt)
948 {
949     sal_Bool bReturn = sal_False;
950 
951     switch (rKEvt.GetKeyCode().GetCode())
952     {
953         case KEY_ESCAPE:
954         {
955             bReturn = FuSelection::cancel();
956         }
957         break;
958 //IAccessibility2 Implementation 2009-----
959   //Solution: add keyboard operation for insert points in drawing curve
960         case KEY_UP:
961         case KEY_DOWN:
962         case KEY_LEFT:
963         case KEY_RIGHT:
964         {
965             if(rKEvt.GetKeyCode().IsShift()&&(nEditMode == SID_BEZIER_INSERT)){
966                 long nX = 0;
967                 long nY = 0;
968                 sal_uInt16  nCode = rKEvt.GetKeyCode().GetCode();
969                 if (nCode == KEY_UP)
970                 {
971                     // Scroll nach oben
972                     nX = 0;
973                     nY =-1;
974     }
975                 else if (nCode == KEY_DOWN)
976                 {
977                     // Scroll nach unten
978                     nX = 0;
979                     nY = 1;
980                 }
981                 else if (nCode == KEY_LEFT)
982                 {
983                     // Scroll nach links
984                     nX =-1;
985                     nY = 0;
986                 }
987                 else if (nCode == KEY_RIGHT)
988                 {
989                     // Scroll nach rechts
990                     nX = 1;
991                     nY = 0;
992                 }
993 
994                 Point centerPoint;
995                 Rectangle rect = mpView->GetMarkedObjRect();
996                 centerPoint = mpWindow->LogicToPixel(rect.Center());
997                 Point aPoint = bMovedToCenterPoint? oldPoint:centerPoint;
998                 Point ePoint = aPoint + Point(nX,nY);
999                 mpWindow->SetPointerPosPixel(ePoint);
1000                 //simulate mouse move action
1001                 MouseEvent eMevt(ePoint,1,2, MOUSE_LEFT, 0);
1002                 MouseMove(eMevt);
1003                 oldPoint = ePoint;
1004                 bMovedToCenterPoint = sal_True;
1005                 bReturn = sal_True;
1006             }
1007         }
1008         break;
1009         case KEY_RETURN:
1010             if(rKEvt.GetKeyCode().IsShift()&&(nEditMode == SID_BEZIER_INSERT))
1011             {
1012                 if(!bBeginInsertPoint)
1013                 {
1014                     //simulate mouse button down action
1015                     MouseEvent aMevt(oldPoint,1,3, MOUSE_LEFT, KEY_SHIFT);
1016                     MouseButtonDown(aMevt);
1017                     mpWindow->CaptureMouse();
1018                     bBeginInsertPoint = sal_True;
1019                 }
1020                 else
1021                 {
1022                     //simulate mouse button up action
1023                     MouseEvent rMEvt(oldPoint,1,17, MOUSE_LEFT, KEY_SHIFT);
1024                     MouseButtonUp(rMEvt);
1025                     bBeginInsertPoint = sal_False;
1026                 }
1027                 bReturn= sal_True;
1028             }
1029             break;
1030     }
1031 //-----IAccessibility2 Implementation 2009
1032     if (!bReturn)
1033     {
1034         bReturn = FuDraw::KeyInput(rKEvt);
1035 
1036         if(mpView->GetMarkedObjectList().GetMarkCount() == 0)
1037         {
1038             mpView->ResetCreationActive();
1039 
1040             mpViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
1041         }
1042     }
1043 
1044     return(bReturn);
1045 
1046 }
1047 
1048 
1049 //IAccessibility2 Implementation 2009-----
1050 void FuSelection::ForcePointer(const MouseEvent* pMEvt)
1051 {
1052     if(bMovedToCenterPoint && !bBeginInsertPoint && pMEvt)
1053     {
1054         MouseEvent aMEvt(pMEvt->GetPosPixel(), pMEvt->GetClicks(),
1055             pMEvt->GetMode(), pMEvt->GetButtons(), pMEvt->GetModifier() & ~KEY_SHIFT);
1056         FuDraw::ForcePointer(&aMEvt);
1057     }
1058     else
1059     {
1060         FuDraw::ForcePointer(pMEvt);
1061     }
1062 }
1063 //-----IAccessibility2 Implementation 2009
1064 /*************************************************************************
1065 |*
1066 |* Function aktivieren
1067 |*
1068 \************************************************************************/
1069 
1070 void FuSelection::Activate()
1071 {
1072     SdrDragMode eMode;
1073     mpView->ResetCreationActive();
1074     mpView->SetEditMode(SDREDITMODE_EDIT);
1075 
1076     switch( nSlotId )
1077     {
1078         case SID_OBJECT_ROTATE:
1079         {
1080             // (gemapter) Slot wird explizit auf Rotate gesetzt #31052#
1081             if( mpViewShell->ISA(DrawViewShell) )
1082             {
1083                 sal_uInt16* pSlotArray =
1084                     static_cast<DrawViewShell*>(mpViewShell)->GetSlotArray();
1085                 pSlotArray[ 1 ] = SID_OBJECT_ROTATE;
1086             }
1087 
1088             eMode = SDRDRAG_ROTATE;
1089 
1090             if ( mpView->GetDragMode() != eMode )
1091                 mpView->SetDragMode(eMode);
1092         }
1093         break;
1094 
1095         case SID_OBJECT_MIRROR:
1096         {
1097             eMode = SDRDRAG_MIRROR;
1098 
1099             if ( mpView->GetDragMode() != eMode )
1100                 mpView->SetDragMode(eMode);
1101         }
1102         break;
1103 
1104         case SID_OBJECT_CROP:
1105         {
1106             eMode = SDRDRAG_CROP;
1107 
1108             if ( mpView->GetDragMode() != eMode )
1109                 mpView->SetDragMode(eMode);
1110         }
1111         break;
1112 
1113         case SID_OBJECT_TRANSPARENCE:
1114         {
1115             eMode = SDRDRAG_TRANSPARENCE;
1116 
1117             if ( mpView->GetDragMode() != eMode )
1118                 mpView->SetDragMode(eMode);
1119         }
1120         break;
1121 
1122         case SID_OBJECT_GRADIENT:
1123         {
1124             eMode = SDRDRAG_GRADIENT;
1125 
1126             if ( mpView->GetDragMode() != eMode )
1127                 mpView->SetDragMode(eMode);
1128         }
1129         break;
1130 
1131         case SID_OBJECT_SHEAR:
1132         {
1133             eMode = SDRDRAG_SHEAR;
1134 
1135             if ( mpView->GetDragMode() != eMode )
1136                 mpView->SetDragMode(eMode);
1137         }
1138         break;
1139 
1140         case SID_OBJECT_CROOK_ROTATE:
1141         {
1142             eMode = SDRDRAG_CROOK;
1143 
1144             if ( mpView->GetDragMode() != eMode )
1145             {
1146                 mpView->SetDragMode(eMode);
1147                 mpView->SetCrookMode(SDRCROOK_ROTATE);
1148             }
1149         }
1150         break;
1151 
1152         case SID_OBJECT_CROOK_SLANT:
1153         {
1154             eMode = SDRDRAG_CROOK;
1155 
1156             if ( mpView->GetDragMode() != eMode )
1157             {
1158                 mpView->SetDragMode(eMode);
1159                 mpView->SetCrookMode(SDRCROOK_SLANT);
1160             }
1161         }
1162         break;
1163 
1164         case SID_OBJECT_CROOK_STRETCH:
1165         {
1166             eMode = SDRDRAG_CROOK;
1167 
1168             if ( mpView->GetDragMode() != eMode )
1169             {
1170                 mpView->SetDragMode(eMode);
1171                 mpView->SetCrookMode(SDRCROOK_STRETCH);
1172             }
1173         }
1174         break;
1175 
1176         case SID_CONVERT_TO_3D_LATHE:
1177         {
1178             eMode = SDRDRAG_MIRROR;
1179             bSuppressChangesOfSelection = sal_True;
1180 
1181             if ( mpView->GetDragMode() != eMode )
1182                 mpView->SetDragMode(eMode);
1183 
1184             if (!mpView->Is3DRotationCreationActive())
1185                 mpView->Start3DCreation();
1186 
1187             bSuppressChangesOfSelection = sal_False;
1188         }
1189         break;
1190 
1191         default:
1192         {
1193             eMode = SDRDRAG_MOVE;
1194 
1195             if ( mpView->GetDragMode() != eMode )
1196                 mpView->SetDragMode(eMode);
1197         }
1198         break;
1199     }
1200 
1201     if (nSlotId != SID_OBJECT_ROTATE)
1202     {
1203         bTempRotation = sal_False;
1204     }
1205 
1206     FuDraw::Activate();
1207 }
1208 
1209 
1210 
1211 /*************************************************************************
1212 |*
1213 |* Function deaktivieren
1214 |*
1215 \************************************************************************/
1216 
1217 void FuSelection::Deactivate()
1218 {
1219     FuDraw::Deactivate();
1220 }
1221 
1222 
1223 /*************************************************************************
1224 |*
1225 |* Selektion hat sich geaendert
1226 |*
1227 \************************************************************************/
1228 
1229 void FuSelection::SelectionHasChanged()
1230 {
1231     bSelectionChanged = sal_True;
1232 
1233     FuDraw::SelectionHasChanged();
1234 
1235     if ((mpView->Is3DRotationCreationActive() && !bSuppressChangesOfSelection))
1236     {
1237         // Wechsel Rotationskoerper -> Selektion
1238         mpView->ResetCreationActive();
1239         nSlotId = SID_OBJECT_SELECT;
1240         Activate();
1241     }
1242 
1243     // Activate the right tool bar for the current context of the view.
1244     mpViewShell->GetViewShellBase().GetToolBarManager()->SelectionHasChanged(*mpViewShell, *mpView);
1245 }
1246 
1247 
1248 /*************************************************************************
1249 |*
1250 |* Aktuellen Bezier-Editmodus setzen
1251 |*
1252 \************************************************************************/
1253 
1254 void FuSelection::SetEditMode(sal_uInt16 nMode)
1255 {
1256     nEditMode = nMode;
1257 
1258     if (nEditMode == SID_BEZIER_INSERT)
1259     {
1260         mpView->SetInsObjPointMode(sal_True);
1261     }
1262     else
1263     {
1264         mpView->SetInsObjPointMode(sal_False);
1265     }
1266 
1267     ForcePointer();
1268 
1269     SfxBindings& rBindings = mpViewShell->GetViewFrame()->GetBindings();
1270     rBindings.Invalidate(SID_BEZIER_MOVE);
1271     rBindings.Invalidate(SID_BEZIER_INSERT);
1272 }
1273 
1274 /*************************************************************************
1275 |*
1276 |* Animation oder Interaktion ausfuehren
1277 |*
1278 \************************************************************************/
1279 
1280 sal_Bool FuSelection::AnimateObj(SdrObject* pObj, const Point& rPos)
1281 {
1282     sal_Bool bAnimated = sal_False;
1283     sal_Bool bClosed = pObj->IsClosedObj();
1284     sal_Bool bFilled = sal_False;
1285 
1286     if (bClosed)
1287     {
1288         SfxItemSet aSet(mpDoc->GetPool());
1289 
1290         aSet.Put(pObj->GetMergedItemSet());
1291 
1292         const XFillStyleItem& rFillStyle = (const XFillStyleItem&) aSet.Get(XATTR_FILLSTYLE);
1293         bFilled = rFillStyle.GetValue() != XFILL_NONE;
1294     }
1295 
1296     const SetOfByte* pVisiLayer = &mpView->GetSdrPageView()->GetVisibleLayers();
1297     sal_uInt16 nHitLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(HITPIX,0)).Width() );
1298     const long  n2HitLog = nHitLog * 2;
1299     Point aHitPosR(rPos);
1300     Point aHitPosL(rPos);
1301     Point aHitPosT(rPos);
1302     Point aHitPosB(rPos);
1303 
1304     aHitPosR.X() += n2HitLog;
1305     aHitPosL.X() -= n2HitLog;
1306     aHitPosT.Y() += n2HitLog;
1307     aHitPosB.Y() -= n2HitLog;
1308 
1309     if ( !bClosed                                      ||
1310          !bFilled                                      ||
1311          (SdrObjectPrimitiveHit(*pObj, aHitPosR, nHitLog, *mpView->GetSdrPageView(), pVisiLayer, false) &&
1312           SdrObjectPrimitiveHit(*pObj, aHitPosL, nHitLog, *mpView->GetSdrPageView(), pVisiLayer, false) &&
1313           SdrObjectPrimitiveHit(*pObj, aHitPosT, nHitLog, *mpView->GetSdrPageView(), pVisiLayer, false) &&
1314           SdrObjectPrimitiveHit(*pObj, aHitPosB, nHitLog, *mpView->GetSdrPageView(), pVisiLayer, false) ) )
1315     {
1316         if ( mpDoc->GetIMapInfo( pObj ) )
1317         {
1318             const IMapObject* pIMapObj = mpDoc->GetHitIMapObject( pObj, rPos, *mpWindow );
1319 
1320             if ( pIMapObj && pIMapObj->GetURL().Len() )
1321             {
1322                 // Sprung zu Dokument
1323                 mpWindow->ReleaseMouse();
1324                 SfxStringItem aStrItem(SID_FILE_NAME, pIMapObj->GetURL());
1325                 SfxStringItem aReferer(SID_REFERER, mpDocSh->GetMedium()->GetName());
1326                 SfxViewFrame* pFrame = mpViewShell->GetViewFrame();
1327                 SfxFrameItem aFrameItem(SID_DOCFRAME, pFrame);
1328                 SfxBoolItem aBrowseItem( SID_BROWSE, sal_True );
1329                 mpWindow->ReleaseMouse();
1330                 pFrame->GetDispatcher()->
1331                     Execute(SID_OPENDOC, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
1332                             &aStrItem, &aFrameItem, &aBrowseItem, &aReferer, 0L);
1333 
1334                 bAnimated = sal_True;
1335             }
1336         }
1337         else if (!mpDocSh->ISA(GraphicDocShell)        &&
1338                  mpView->ISA(DrawView)                 &&
1339                  mpDoc->GetAnimationInfo(pObj))
1340         {
1341             /**********************************************************
1342             * Animations-Objekt in der Mitte getroffen -> Interaktion
1343             **********************************************************/
1344             SdAnimationInfo* pInfo = mpDoc->GetAnimationInfo(pObj);
1345             DrawViewShell* pDrViewSh = static_cast<DrawViewShell*>(mpViewShell);
1346             mpWindow->ReleaseMouse();
1347 
1348             switch (pInfo->meClickAction)
1349             {
1350                 case presentation::ClickAction_BOOKMARK:
1351                 {
1352                     // Sprung zu Bookmark (Seite oder Objekt)
1353                     SfxStringItem aItem(SID_NAVIGATOR_OBJECT, pInfo->GetBookmark());
1354                     mpViewShell->GetViewFrame()->GetDispatcher()->
1355                     Execute(SID_NAVIGATOR_OBJECT, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD, &aItem, 0L);
1356                     bAnimated = sal_True;
1357                 }
1358                 break;
1359 
1360                 case presentation::ClickAction_DOCUMENT:
1361                 {
1362                     String sBookmark( pInfo->GetBookmark() );
1363                     // Sprung zu Dokument
1364                     if (sBookmark.Len())
1365                     {
1366                         SfxStringItem aReferer(SID_REFERER, mpDocSh->GetMedium()->GetName());
1367                         SfxStringItem aStrItem(SID_FILE_NAME, sBookmark);
1368                         SfxViewFrame* pFrame = mpViewShell->GetViewFrame();
1369                         SfxFrameItem aFrameItem(SID_DOCFRAME, pFrame);
1370                         SfxBoolItem aBrowseItem( SID_BROWSE, sal_True );
1371                         pFrame->GetDispatcher()->
1372                         Execute(SID_OPENDOC, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
1373                                 &aStrItem, &aFrameItem, &aBrowseItem, &aReferer, 0L);
1374                     }
1375 
1376                     bAnimated = sal_True;
1377                 }
1378                 break;
1379 
1380                 case presentation::ClickAction_PREVPAGE:
1381                 {
1382                     // Sprung zur vorherigen Seite
1383                     SfxUInt16Item aItem(SID_NAVIGATOR_PAGE, PAGE_PREVIOUS);
1384                     mpViewShell->GetViewFrame()->GetDispatcher()->
1385                     Execute(SID_NAVIGATOR_PAGE, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD,
1386                             &aItem, 0L);
1387                     bAnimated = sal_True;
1388                 }
1389                 break;
1390 
1391                 case presentation::ClickAction_NEXTPAGE:
1392                 {
1393                     // Sprung zur naechsten Seite
1394                     SfxUInt16Item aItem(SID_NAVIGATOR_PAGE, PAGE_NEXT);
1395                     mpViewShell->GetViewFrame()->GetDispatcher()->
1396                     Execute(SID_NAVIGATOR_PAGE, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD,
1397                             &aItem, 0L);
1398                     bAnimated = sal_True;
1399                 }
1400                 break;
1401 
1402                 case presentation::ClickAction_FIRSTPAGE:
1403                 {
1404                     // Sprung zu erster Seite
1405                     SfxUInt16Item aItem(SID_NAVIGATOR_PAGE, PAGE_FIRST);
1406                     mpViewShell->GetViewFrame()->GetDispatcher()->
1407                     Execute(SID_NAVIGATOR_PAGE, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD,
1408                             &aItem, 0L);
1409                     bAnimated = sal_True;
1410                 }
1411                 break;
1412 
1413                 case presentation::ClickAction_LASTPAGE:
1414                 {
1415                     // Sprung zu letzter Seite
1416                     SfxUInt16Item aItem(SID_NAVIGATOR_PAGE, PAGE_LAST);
1417                     mpViewShell->GetViewFrame()->GetDispatcher()->
1418                     Execute(SID_NAVIGATOR_PAGE, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD,
1419                             &aItem, 0L);
1420                     bAnimated = sal_True;
1421                 }
1422                 break;
1423 
1424                 case presentation::ClickAction_SOUND:
1425                 {
1426                         try
1427                         {
1428                             mxPlayer.set( avmedia::MediaWindow::createPlayer( pInfo->GetBookmark()), uno::UNO_QUERY_THROW );
1429                             mxPlayer->start();
1430                         }
1431                         catch( uno::Exception& e )
1432                         {
1433                             (void)e;
1434                         }
1435                     bAnimated = sal_True;
1436                 }
1437                 break;
1438 
1439                 case presentation::ClickAction_VERB:
1440                 {
1441                     // Verb zuweisen
1442                     mpView->UnmarkAll();
1443                     mpView->MarkObj(pObj, mpView->GetSdrPageView(), sal_False, sal_False);
1444                     pDrViewSh->DoVerb((sal_Int16)pInfo->mnVerb);
1445                     bAnimated = sal_True;
1446                 }
1447                 break;
1448 
1449                 case presentation::ClickAction_PROGRAM:
1450                 {
1451                    String aBaseURL = GetDocSh()->GetMedium()->GetBaseURL();
1452                    INetURLObject aURL( ::URIHelper::SmartRel2Abs( INetURLObject(aBaseURL), pInfo->GetBookmark(),
1453                                                 URIHelper::GetMaybeFileHdl(), true, false,
1454                                                 INetURLObject::WAS_ENCODED, INetURLObject::DECODE_UNAMBIGUOUS ) );
1455 
1456                    if( INET_PROT_FILE == aURL.GetProtocol() )
1457                    {
1458                         SfxStringItem aUrl( SID_FILE_NAME, aURL.GetMainURL( INetURLObject::NO_DECODE ) );
1459                         SfxBoolItem aBrowsing( SID_BROWSE, sal_True );
1460 
1461                         SfxViewFrame* pViewFrm = SfxViewFrame::Current();
1462                         if (pViewFrm)
1463                             pViewFrm->GetDispatcher()->Execute( SID_OPENDOC,
1464                                                         SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
1465                                                         &aUrl,
1466                                                         &aBrowsing,
1467                                                         0L );
1468                    }
1469 
1470                     bAnimated = sal_True;
1471                 }
1472                 break;
1473 
1474                 case presentation::ClickAction_MACRO:
1475                 {
1476                     // Execute makro
1477                     String aMacro = pInfo->GetBookmark();
1478 
1479                     if ( SfxApplication::IsXScriptURL( aMacro ) )
1480                     {
1481                         uno::Any aRet;
1482                         uno::Sequence< sal_Int16 > aOutArgsIndex;
1483                         uno::Sequence< uno::Any > aOutArgs;
1484                         uno::Sequence< uno::Any >* pInArgs =
1485                             new uno::Sequence< uno::Any >(0);
1486 
1487                         ErrCode eErr = mpDocSh->CallXScript( aMacro,
1488                             *pInArgs, aRet, aOutArgsIndex, aOutArgs);
1489 
1490                         // Check the return value from the script
1491                         sal_Bool bTmp = sal_False;
1492                         if ( eErr == ERRCODE_NONE &&
1493                              aRet.getValueType() == getCppuBooleanType() &&
1494                              sal_True == ( aRet >>= bTmp ) &&
1495                              bTmp == sal_True )
1496                         {
1497                             bAnimated = sal_True;
1498                         }
1499                         else
1500                         {
1501                             bAnimated = sal_False;
1502                         }
1503                     }
1504                     else
1505                     {
1506                         // aMacro has got following format:
1507                         // "Macroname.Modulname.Libname.Documentname" or
1508                         // "Macroname.Modulname.Libname.Applicationsname"
1509                         String aMacroName =
1510                             aMacro.GetToken(0, sal_Unicode('.'));
1511                         String aModulName =
1512                              aMacro.GetToken(1, sal_Unicode('.'));
1513                         String aLibName   =
1514                              aMacro.GetToken(2, sal_Unicode('.'));
1515                         String aDocName   =
1516                              aMacro.GetToken(3, sal_Unicode('.'));
1517 
1518                         // In this moment the Call-method only
1519                         // resolves modulename+macroname
1520                         String aExecMacro(aModulName);
1521                         aExecMacro.Append( sal_Unicode('.') );
1522                         aExecMacro.Append( aMacroName );
1523                         bAnimated = mpDocSh->GetBasic()->Call(aExecMacro);
1524                     }
1525                 }
1526                 break;
1527 
1528                 default:
1529                 {
1530                     bAnimated = sal_False;
1531                 }
1532                 break;
1533             }
1534         }
1535 
1536         if (!bAnimated                               &&
1537             mpView->ISA(DrawView)                 &&
1538             !mpDocSh->ISA(GraphicDocShell)        &&
1539             SlideShow::IsRunning( mpViewShell->GetViewShellBase() ) &&
1540             mpDoc->GetAnimationInfo(pObj))
1541         {
1542             /**********************************************************
1543             * Effekt-Objekt in der Mitte getroffen -> Effekt abspielen
1544             **********************************************************/
1545             SdAnimationInfo* pInfo = mpDoc->GetAnimationInfo(pObj);
1546 
1547             switch (pInfo->meClickAction)
1548             {
1549                 case presentation::ClickAction_VANISH:
1550                 case presentation::ClickAction_INVISIBLE:
1551                     break;
1552 
1553                 default:
1554                     bAnimated = sal_False;
1555                 break;
1556             }
1557         }
1558     }
1559 
1560     return bAnimated;
1561 }
1562 
1563 
1564 
1565 /** is called when the currenct function should be aborted. <p>
1566     This is used when a function gets a KEY_ESCAPE but can also
1567     be called directly.
1568 
1569     @returns true if a active function was aborted
1570 */
1571 bool FuSelection::cancel()
1572 {
1573     if (mpView->Is3DRotationCreationActive())
1574     {
1575         mpView->ResetCreationActive();
1576         mpViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
1577         return true;
1578     }
1579     else
1580     {
1581         return false;
1582     }
1583 }
1584 
1585 
1586 
1587 
1588 SdrObject* FuSelection::pickObject (const Point& rTestPoint)
1589 {
1590     SdrObject* pObject = NULL;
1591     SdrPageView* pPageView;
1592     sal_uInt16 nHitLog = sal_uInt16 (mpWindow->PixelToLogic(Size(HITPIX,0)).Width());
1593     mpView->PickObj (rTestPoint, nHitLog, pObject, pPageView, SDRSEARCH_PICKMARKABLE);
1594     return pObject;
1595 }
1596 } // end of namespace sd
1597