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