Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 :
21 : #include <sot/object.hxx>
22 : #include <editeng/eeitem.hxx>
23 : #include <vcl/waitobj.hxx>
24 :
25 : #include <editeng/flditem.hxx>
26 : #include <svx/svdogrp.hxx>
27 : #include <tools/urlobj.hxx>
28 : #include <vcl/help.hxx>
29 : #include <svx/bmpmask.hxx>
30 : #include <svx/svdotext.hxx>
31 : #include <sfx2/app.hxx>
32 : #include <sfx2/dispatch.hxx>
33 : #include <sfx2/bindings.hxx>
34 : #include <svx/svdpagv.hxx>
35 : #include <svtools/imapobj.hxx>
36 : #include <svx/svxids.hrc>
37 : #include <svx/obj3d.hxx>
38 : #include <svx/polysc3d.hxx>
39 :
40 : #include <sfx2/viewfrm.hxx>
41 :
42 : #include "anminfo.hxx"
43 : #include "imapinfo.hxx"
44 : #include "app.hrc"
45 : #include "glob.hrc"
46 : #include "strings.hrc"
47 : #include "res_bmp.hrc"
48 :
49 : #include "sdmod.hxx"
50 : #include "GraphicDocShell.hxx"
51 : #include "fudraw.hxx"
52 : #include "ViewShell.hxx"
53 : #include "FrameView.hxx"
54 : #include "View.hxx"
55 : #include "Window.hxx"
56 : #include "drawdoc.hxx"
57 : #include "DrawDocShell.hxx"
58 : #include "Client.hxx"
59 : #include "sdresid.hxx"
60 : #include "drawview.hxx"
61 : #include "fusel.hxx"
62 : #include <svl/aeitem.hxx>
63 : #include <vcl/msgbox.hxx>
64 : #include "slideshow.hxx"
65 : #include <svx/sdrhittesthelper.hxx>
66 :
67 : using namespace ::com::sun::star;
68 :
69 : namespace sd {
70 :
71 0 : TYPEINIT1( FuDraw, FuPoor );
72 :
73 : /**
74 : * Base-class for all drawmodul-specific functions
75 : */
76 0 : FuDraw::FuDraw(ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView,
77 : SdDrawDocument* pDoc, SfxRequest& rReq)
78 : : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
79 : , bMBDown(sal_False)
80 : , bDragHelpLine(sal_False)
81 : , nHelpLine(0)
82 0 : , bPermanent(sal_False)
83 : {
84 0 : }
85 :
86 0 : FuDraw::~FuDraw()
87 : {
88 0 : mpView->BrkAction();
89 0 : }
90 :
91 0 : sal_Bool FuDraw::MouseButtonDown(const MouseEvent& rMEvt)
92 : {
93 : // remember button state for creation of own MouseEvents
94 0 : SetMouseButtonCode(rMEvt.GetButtons());
95 :
96 0 : sal_Bool bReturn = sal_False;
97 :
98 0 : bDragHelpLine = sal_False;
99 :
100 0 : aMDPos = mpWindow->PixelToLogic( rMEvt.GetPosPixel() );
101 :
102 0 : if ( rMEvt.IsLeft() )
103 : {
104 0 : FrameView* pFrameView = mpViewShell->GetFrameView();
105 :
106 0 : bool bOrtho = false;
107 :
108 0 : sal_Bool bRestricted = sal_True;
109 :
110 0 : if (mpView->IsDragObj())
111 : {
112 : // object is dragged (move, resize,...)
113 0 : const SdrHdl* pHdl = mpView->GetDragStat().GetHdl();
114 :
115 0 : if (!pHdl || (!pHdl->IsCornerHdl() && !pHdl->IsVertexHdl()))
116 : {
117 : // Move
118 0 : bRestricted = sal_False;
119 : }
120 : }
121 :
122 : // #i33136#
123 0 : if(bRestricted && doConstructOrthogonal())
124 : {
125 : // Restrict movement:
126 : // rectangle->quadrat, ellipse->circle etc.
127 0 : bOrtho = !rMEvt.IsShift();
128 : }
129 : else
130 : {
131 0 : bOrtho = rMEvt.IsShift() != pFrameView->IsOrtho();
132 : }
133 :
134 0 : if (!mpView->IsSnapEnabled())
135 0 : mpView->SetSnapEnabled(true);
136 0 : bool bSnapModPressed = rMEvt.IsMod1();
137 :
138 0 : bool bGridSnap = pFrameView->IsGridSnap();
139 0 : bGridSnap = (bSnapModPressed != bGridSnap);
140 :
141 0 : if (mpView->IsGridSnap() != bGridSnap)
142 0 : mpView->SetGridSnap(bGridSnap);
143 :
144 0 : bool bBordSnap = pFrameView->IsBordSnap();
145 0 : bBordSnap = (bSnapModPressed != bBordSnap);
146 :
147 0 : if (mpView->IsBordSnap() != bBordSnap)
148 0 : mpView->SetBordSnap(bBordSnap);
149 :
150 0 : bool bHlplSnap = pFrameView->IsHlplSnap();
151 0 : bHlplSnap = (bSnapModPressed != bHlplSnap);
152 :
153 0 : if (mpView->IsHlplSnap() != bHlplSnap)
154 0 : mpView->SetHlplSnap(bHlplSnap);
155 :
156 0 : bool bOFrmSnap = pFrameView->IsOFrmSnap();
157 0 : bOFrmSnap = (bSnapModPressed != bOFrmSnap);
158 :
159 0 : if (mpView->IsOFrmSnap() != bOFrmSnap)
160 0 : mpView->SetOFrmSnap(bOFrmSnap);
161 :
162 0 : bool bOPntSnap = pFrameView->IsOPntSnap();
163 0 : bOPntSnap = (bSnapModPressed != bOPntSnap);
164 :
165 0 : if (mpView->IsOPntSnap() != bOPntSnap)
166 0 : mpView->SetOPntSnap(bOPntSnap);
167 :
168 0 : bool bOConSnap = pFrameView->IsOConSnap();
169 0 : bOConSnap = (bSnapModPressed != bOConSnap);
170 :
171 0 : if (mpView->IsOConSnap() != bOConSnap)
172 0 : mpView->SetOConSnap(bOConSnap);
173 :
174 0 : bool bAngleSnap = rMEvt.IsShift() == !pFrameView->IsAngleSnapEnabled();
175 :
176 0 : if (mpView->IsAngleSnapEnabled() != bAngleSnap)
177 0 : mpView->SetAngleSnapEnabled(bAngleSnap);
178 :
179 0 : if (mpView->IsOrtho() != bOrtho)
180 0 : mpView->SetOrtho(bOrtho);
181 :
182 0 : bool bCenter = rMEvt.IsMod2();
183 :
184 0 : if ( mpView->IsCreate1stPointAsCenter() != bCenter ||
185 0 : mpView->IsResizeAtCenter() != bCenter )
186 : {
187 0 : mpView->SetCreate1stPointAsCenter(bCenter);
188 0 : mpView->SetResizeAtCenter(bCenter);
189 : }
190 :
191 0 : SdrPageView* pPV = 0;
192 0 : sal_uInt16 nHitLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(HITPIX,0)).Width() );
193 :
194 : // look only for HelpLines when they are visible (!)
195 0 : sal_Bool bHelpLine(sal_False);
196 0 : if(mpView->IsHlplVisible())
197 0 : bHelpLine = mpView->PickHelpLine(aMDPos, nHitLog, *mpWindow, nHelpLine, pPV);
198 0 : sal_Bool bHitHdl = (mpView->PickHandle(aMDPos) != NULL);
199 :
200 0 : if ( bHelpLine
201 0 : && !mpView->IsCreateObj()
202 0 : && ((mpView->GetEditMode() == SDREDITMODE_EDIT && !bHitHdl) || (rMEvt.IsShift() && bSnapModPressed)) )
203 : {
204 0 : mpWindow->CaptureMouse();
205 0 : mpView->BegDragHelpLine(nHelpLine, pPV);
206 0 : bDragHelpLine = mpView->IsDragHelpLine();
207 0 : bReturn = sal_True;
208 : }
209 : }
210 0 : ForcePointer(&rMEvt);
211 :
212 0 : return bReturn;
213 : }
214 :
215 :
216 0 : sal_Bool FuDraw::MouseMove(const MouseEvent& rMEvt)
217 : {
218 0 : FrameView* pFrameView = mpViewShell->GetFrameView();
219 0 : Point aPos = mpWindow->PixelToLogic( rMEvt.GetPosPixel() );
220 :
221 0 : bool bOrtho = false;
222 :
223 0 : sal_Bool bRestricted = sal_True;
224 :
225 0 : if (mpView->IsDragObj())
226 : {
227 : // object is dragged (move, resize, ...)
228 0 : const SdrHdl* pHdl = mpView->GetDragStat().GetHdl();
229 :
230 0 : if (!pHdl || (!pHdl->IsCornerHdl() && !pHdl->IsVertexHdl()))
231 : {
232 : // Move
233 0 : bRestricted = sal_False;
234 : }
235 : }
236 :
237 0 : if (mpView->IsAction())
238 : {
239 : // #i33136#
240 0 : if(bRestricted && doConstructOrthogonal())
241 : {
242 : // Restrict movement:
243 : // rectangle->quadrat, ellipse->circle etc.
244 0 : bOrtho = !rMEvt.IsShift();
245 : }
246 : else
247 : {
248 0 : bOrtho = rMEvt.IsShift() != pFrameView->IsOrtho();
249 : }
250 :
251 0 : bool bSnapModPressed = rMEvt.IsMod2();
252 0 : mpView->SetDragWithCopy(rMEvt.IsMod1() && pFrameView->IsDragWithCopy());
253 :
254 0 : bool bGridSnap = pFrameView->IsGridSnap();
255 0 : bGridSnap = (bSnapModPressed != bGridSnap);
256 :
257 0 : if (mpView->IsGridSnap() != bGridSnap)
258 0 : mpView->SetGridSnap(bGridSnap);
259 :
260 0 : bool bBordSnap = pFrameView->IsBordSnap();
261 0 : bBordSnap = (bSnapModPressed != bBordSnap);
262 :
263 0 : if (mpView->IsBordSnap() != bBordSnap)
264 0 : mpView->SetBordSnap(bBordSnap);
265 :
266 0 : bool bHlplSnap = pFrameView->IsHlplSnap();
267 0 : bHlplSnap = (bSnapModPressed != bHlplSnap);
268 :
269 0 : if (mpView->IsHlplSnap() != bHlplSnap)
270 0 : mpView->SetHlplSnap(bHlplSnap);
271 :
272 0 : bool bOFrmSnap = pFrameView->IsOFrmSnap();
273 0 : bOFrmSnap = (bSnapModPressed != bOFrmSnap);
274 :
275 0 : if (mpView->IsOFrmSnap() != bOFrmSnap)
276 0 : mpView->SetOFrmSnap(bOFrmSnap);
277 :
278 0 : bool bOPntSnap = pFrameView->IsOPntSnap();
279 0 : bOPntSnap = (bSnapModPressed != bOPntSnap);
280 :
281 0 : if (mpView->IsOPntSnap() != bOPntSnap)
282 0 : mpView->SetOPntSnap(bOPntSnap);
283 :
284 0 : bool bOConSnap = pFrameView->IsOConSnap();
285 0 : bOConSnap = (bSnapModPressed != bOConSnap);
286 :
287 0 : if (mpView->IsOConSnap() != bOConSnap)
288 0 : mpView->SetOConSnap(bOConSnap);
289 :
290 0 : bool bAngleSnap = rMEvt.IsShift() == !pFrameView->IsAngleSnapEnabled();
291 :
292 0 : if (mpView->IsAngleSnapEnabled() != bAngleSnap)
293 0 : mpView->SetAngleSnapEnabled(bAngleSnap);
294 :
295 0 : if (mpView->IsOrtho() != bOrtho)
296 0 : mpView->SetOrtho(bOrtho);
297 :
298 0 : bool bCenter = rMEvt.IsMod2();
299 :
300 0 : if ( mpView->IsCreate1stPointAsCenter() != bCenter ||
301 0 : mpView->IsResizeAtCenter() != bCenter )
302 : {
303 0 : mpView->SetCreate1stPointAsCenter(bCenter);
304 0 : mpView->SetResizeAtCenter(bCenter);
305 : }
306 :
307 0 : if ( mpView->IsDragHelpLine() )
308 0 : mpView->MovDragHelpLine(aPos);
309 : }
310 :
311 0 : sal_Bool bReturn = mpView->MouseMove(rMEvt, mpWindow);
312 :
313 0 : if (mpView->IsAction())
314 : {
315 : // Because the flag set back if necessary in MouseMove
316 0 : if (mpView->IsOrtho() != bOrtho)
317 0 : mpView->SetOrtho(bOrtho);
318 : }
319 :
320 0 : ForcePointer(&rMEvt);
321 :
322 0 : return bReturn;
323 : }
324 :
325 :
326 0 : sal_Bool FuDraw::MouseButtonUp(const MouseEvent& rMEvt)
327 : {
328 0 : if ( mpView->IsDragHelpLine() )
329 0 : mpView->EndDragHelpLine();
330 :
331 0 : if ( bDragHelpLine )
332 : {
333 0 : Rectangle aOutputArea(Point(0,0), mpWindow->GetOutputSizePixel());
334 :
335 0 : if ( !aOutputArea.IsInside(rMEvt.GetPosPixel()) )
336 0 : mpView->GetSdrPageView()->DeleteHelpLine(nHelpLine);
337 :
338 0 : mpWindow->ReleaseMouse();
339 : }
340 :
341 0 : FrameView* pFrameView = mpViewShell->GetFrameView();
342 0 : mpView->SetOrtho( pFrameView->IsOrtho() );
343 0 : mpView->SetAngleSnapEnabled( pFrameView->IsAngleSnapEnabled() );
344 0 : mpView->SetSnapEnabled(true);
345 0 : mpView->SetCreate1stPointAsCenter(false);
346 0 : mpView->SetResizeAtCenter(false);
347 0 : mpView->SetDragWithCopy(pFrameView->IsDragWithCopy());
348 0 : mpView->SetGridSnap(pFrameView->IsGridSnap());
349 0 : mpView->SetBordSnap(pFrameView->IsBordSnap());
350 0 : mpView->SetHlplSnap(pFrameView->IsHlplSnap());
351 0 : mpView->SetOFrmSnap(pFrameView->IsOFrmSnap());
352 0 : mpView->SetOPntSnap(pFrameView->IsOPntSnap());
353 0 : mpView->SetOConSnap(pFrameView->IsOConSnap());
354 :
355 0 : bIsInDragMode = sal_False;
356 0 : ForcePointer(&rMEvt);
357 0 : FuPoor::MouseButtonUp(rMEvt);
358 :
359 0 : return sal_False;
360 : }
361 :
362 : /**
363 : * Process keyboard input
364 : * @returns sal_True if a KeyEvent is being processed, sal_False otherwise
365 : */
366 0 : sal_Bool FuDraw::KeyInput(const KeyEvent& rKEvt)
367 : {
368 0 : sal_Bool bReturn = sal_False;
369 :
370 0 : switch ( rKEvt.GetKeyCode().GetCode() )
371 : {
372 : case KEY_ESCAPE:
373 : {
374 0 : bReturn = FuDraw::cancel();
375 : }
376 0 : break;
377 :
378 : case KEY_DELETE:
379 : case KEY_BACKSPACE:
380 : {
381 0 : if (!mpDocSh->IsReadOnly())
382 : {
383 0 : if (mpView->IsPresObjSelected(sal_False, sal_True, sal_False, sal_True))
384 : {
385 0 : InfoBox(mpWindow, SD_RESSTR(STR_ACTION_NOTPOSSIBLE) ).Execute();
386 : }
387 : else
388 : {
389 : /* If IP-Client active, we reset the pointer to the OLE- and
390 : to the old graphic object of SdClient. With this, we
391 : avoid the restoration of an no more existing object in
392 : ::SelectionHasChanged after deletion. All other OLE
393 : objects are not affected. */
394 : OSL_ASSERT (mpViewShell->GetViewShell()!=NULL);
395 : Client* pIPClient = static_cast<Client*>(
396 0 : mpViewShell->GetViewShell()->GetIPClient());
397 0 : if (pIPClient && pIPClient->IsObjectInPlaceActive())
398 0 : pIPClient->SetSdrGrafObj(NULL);
399 :
400 : // wait-mousepointer while deleting object
401 0 : WaitObject aWait( (Window*)mpViewShell->GetActiveWindow() );
402 : // delete object
403 0 : mpView->DeleteMarked();
404 : }
405 : }
406 0 : bReturn = sal_True;
407 : }
408 0 : break;
409 :
410 : case KEY_TAB:
411 : {
412 0 : KeyCode aCode = rKEvt.GetKeyCode();
413 :
414 0 : if ( !aCode.IsMod1() && !aCode.IsMod2() )
415 : {
416 : // Moved next line which was a bugfix itself into
417 : // the scope which really does the object selection travel
418 : // and thus is allowed to call SelectionHasChanged().
419 :
420 : // Switch to FuSelect.
421 : mpViewShell->GetViewFrame()->GetDispatcher()->Execute(
422 : SID_OBJECT_SELECT,
423 0 : SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
424 :
425 : // changeover to the next object
426 0 : if(!mpView->MarkNextObj( !aCode.IsShift() ))
427 : {
428 : //If there is only one object, don't do the UnmarkAlllObj() & MarkNextObj().
429 0 : if ( mpView->GetMarkableObjCount() > 1 && mpView->AreObjectsMarked() )
430 : {
431 : // No next object: go over open end and get first from
432 : // the other side
433 0 : mpView->UnmarkAllObj();
434 0 : mpView->MarkNextObj(!aCode.IsShift());
435 : }
436 : }
437 :
438 0 : if(mpView->AreObjectsMarked())
439 0 : mpView->MakeVisible(mpView->GetAllMarkedRect(), *mpWindow);
440 :
441 0 : bReturn = sal_True;
442 : }
443 : }
444 0 : break;
445 :
446 : case KEY_END:
447 : {
448 0 : KeyCode aCode = rKEvt.GetKeyCode();
449 :
450 0 : if ( aCode.IsMod1() )
451 : {
452 : // mark last object
453 0 : mpView->UnmarkAllObj();
454 0 : mpView->MarkNextObj(false);
455 :
456 0 : if(mpView->AreObjectsMarked())
457 0 : mpView->MakeVisible(mpView->GetAllMarkedRect(), *mpWindow);
458 :
459 0 : bReturn = sal_True;
460 : }
461 : }
462 0 : break;
463 :
464 : case KEY_HOME:
465 : {
466 0 : KeyCode aCode = rKEvt.GetKeyCode();
467 :
468 0 : if ( aCode.IsMod1() )
469 : {
470 : // mark first object
471 0 : mpView->UnmarkAllObj();
472 0 : mpView->MarkNextObj(true);
473 :
474 0 : if(mpView->AreObjectsMarked())
475 0 : mpView->MakeVisible(mpView->GetAllMarkedRect(), *mpWindow);
476 :
477 0 : bReturn = sal_True;
478 : }
479 : }
480 0 : break;
481 :
482 : default:
483 0 : break;
484 : }
485 :
486 0 : if (!bReturn)
487 : {
488 0 : bReturn = FuPoor::KeyInput(rKEvt);
489 : }
490 : else
491 : {
492 0 : mpWindow->ReleaseMouse();
493 : }
494 :
495 0 : return (bReturn);
496 : }
497 :
498 :
499 0 : void FuDraw::Activate()
500 : {
501 0 : FuPoor::Activate();
502 0 : ForcePointer();
503 0 : }
504 :
505 :
506 0 : void FuDraw::Deactivate()
507 : {
508 0 : FuPoor::Deactivate();
509 0 : }
510 :
511 :
512 : /**
513 : * Toggle mouse-pointer
514 : */
515 0 : void FuDraw::ForcePointer(const MouseEvent* pMEvt)
516 : {
517 0 : Point aPnt;
518 0 : sal_uInt16 nModifier = 0;
519 0 : sal_Bool bLeftDown = sal_False;
520 0 : sal_Bool bDefPointer = sal_True;
521 :
522 0 : if (pMEvt)
523 : {
524 0 : aPnt = mpWindow->PixelToLogic(pMEvt->GetPosPixel());
525 0 : nModifier = pMEvt->GetModifier();
526 0 : bLeftDown = pMEvt->IsLeft();
527 : }
528 : else
529 : {
530 0 : aPnt = mpWindow->PixelToLogic(mpWindow->GetPointerPosPixel());
531 : }
532 :
533 0 : if (mpView->IsDragObj())
534 : {
535 0 : if (SD_MOD()->GetWaterCan() && !mpView->PickHandle(aPnt))
536 : {
537 : // water can mode
538 0 : bDefPointer = sal_False;
539 0 : mpWindow->SetPointer(Pointer(POINTER_FILL));
540 : }
541 : }
542 : else
543 : {
544 0 : SdrHdl* pHdl = mpView->PickHandle(aPnt);
545 :
546 0 : if (SD_MOD()->GetWaterCan() && !pHdl)
547 : {
548 : // water can mode
549 0 : bDefPointer = sal_False;
550 0 : mpWindow->SetPointer(Pointer(POINTER_FILL));
551 : }
552 0 : else if (!pHdl &&
553 0 : mpViewShell->GetViewFrame()->HasChildWindow(SvxBmpMaskChildWindow::GetChildWindowId()))
554 : {
555 : // pipette mode
556 0 : SvxBmpMask* pMask = (SvxBmpMask*) mpViewShell->GetViewFrame()->GetChildWindow(SvxBmpMaskChildWindow::GetChildWindowId())->GetWindow();
557 :
558 0 : if (pMask && pMask->IsEyedropping())
559 : {
560 0 : bDefPointer = sal_False;
561 0 : mpWindow->SetPointer(Pointer(POINTER_REFHAND));
562 : }
563 : }
564 0 : else if (!mpView->IsAction())
565 : {
566 0 : SdrObject* pObj = NULL;
567 0 : SdrPageView* pPV = NULL;
568 0 : SdrViewEvent aVEvt;
569 0 : SdrHitKind eHit = SDRHIT_NONE;
570 0 : SdrDragMode eDragMode = mpView->GetDragMode();
571 :
572 0 : if (pMEvt)
573 : {
574 0 : eHit = mpView->PickAnything(*pMEvt, SDRMOUSEMOVE, aVEvt);
575 : }
576 :
577 0 : if ((eDragMode == SDRDRAG_ROTATE) && (eHit == SDRHIT_MARKEDOBJECT))
578 : {
579 : // The goal of this request is show always the rotation-arrow for 3D-objects at rotation-modus
580 : // Independent of the settings at Extras->Optionen->Grafik "Objekte immer verschieben"
581 : // 2D-objects acquit in an other way. Otherwise, the rotation of 3d-objects around any axises
582 : // wouldn't be possible per default.
583 0 : const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
584 0 : SdrObject* pObject = rMarkList.GetMark(0)->GetMarkedSdrObj();
585 0 : if ((pObject->ISA(E3dObject)) && (rMarkList.GetMarkCount() == 1))
586 : {
587 0 : mpWindow->SetPointer(Pointer(POINTER_ROTATE));
588 0 : bDefPointer = sal_False; // Otherwise it'll be calles Joes routine and the mousepointer will reconfigurate again
589 : }
590 : }
591 :
592 0 : if (eHit == SDRHIT_NONE)
593 : {
594 : // found nothing -> look after at the masterpage
595 0 : mpView->PickObj(aPnt, mpView->getHitTolLog(), pObj, pPV, SDRSEARCH_ALSOONMASTER);
596 : }
597 0 : else if (eHit == SDRHIT_UNMARKEDOBJECT)
598 : {
599 0 : pObj = aVEvt.pObj;
600 : }
601 0 : else if (eHit == SDRHIT_TEXTEDITOBJ && this->ISA(FuSelection))
602 : {
603 0 : sal_uInt16 nSdrObjKind = aVEvt.pObj->GetObjIdentifier();
604 :
605 0 : if ( nSdrObjKind != OBJ_TEXT &&
606 0 : nSdrObjKind != OBJ_TITLETEXT &&
607 0 : nSdrObjKind != OBJ_OUTLINETEXT &&
608 0 : aVEvt.pObj->IsEmptyPresObj() )
609 : {
610 0 : pObj = NULL;
611 0 : bDefPointer = sal_False;
612 0 : mpWindow->SetPointer(Pointer(POINTER_ARROW));
613 : }
614 : }
615 :
616 0 : if (pObj && pMEvt && !pMEvt->IsMod2() && this->ISA(FuSelection))
617 : {
618 : // test for animation or ImageMap
619 0 : bDefPointer = !SetPointer(pObj, aPnt);
620 :
621 0 : if (bDefPointer && (pObj->ISA(SdrObjGroup) || pObj->ISA(E3dPolyScene)))
622 : {
623 : // take a glance into the group
624 0 : if (mpView->PickObj(aPnt, mpView->getHitTolLog(), pObj, pPV, SDRSEARCH_ALSOONMASTER | SDRSEARCH_DEEP))
625 0 : bDefPointer = !SetPointer(pObj, aPnt);
626 : }
627 0 : }
628 : }
629 : }
630 :
631 0 : if (bDefPointer)
632 : {
633 : mpWindow->SetPointer(mpView->GetPreferredPointer(
634 0 : aPnt, mpWindow, nModifier, bLeftDown));
635 : }
636 0 : }
637 :
638 : /**
639 : * Set cursor for animaton or imagemap
640 : */
641 0 : sal_Bool FuDraw::SetPointer(SdrObject* pObj, const Point& rPos)
642 : {
643 0 : sal_Bool bSet = sal_False;
644 :
645 0 : sal_Bool bAnimationInfo = (!mpDocSh->ISA(GraphicDocShell) &&
646 0 : mpDoc->GetAnimationInfo(pObj)) ? sal_True:sal_False;
647 :
648 0 : sal_Bool bImageMapInfo = sal_False;
649 :
650 0 : if (!bAnimationInfo)
651 0 : bImageMapInfo = mpDoc->GetIMapInfo(pObj) ? sal_True:sal_False;
652 :
653 0 : if (bAnimationInfo || bImageMapInfo)
654 : {
655 0 : const SetOfByte* pVisiLayer = &mpView->GetSdrPageView()->GetVisibleLayers();
656 0 : sal_uInt16 nHitLog(sal_uInt16 (mpWindow->PixelToLogic(Size(HITPIX,0)).Width()));
657 0 : long n2HitLog(nHitLog * 2);
658 0 : Point aHitPosR(rPos);
659 0 : Point aHitPosL(rPos);
660 0 : Point aHitPosT(rPos);
661 0 : Point aHitPosB(rPos);
662 :
663 0 : aHitPosR.X() += n2HitLog;
664 0 : aHitPosL.X() -= n2HitLog;
665 0 : aHitPosT.Y() += n2HitLog;
666 0 : aHitPosB.Y() -= n2HitLog;
667 :
668 0 : if ( !pObj->IsClosedObj() ||
669 0 : ( SdrObjectPrimitiveHit(*pObj, aHitPosR, nHitLog, *mpView->GetSdrPageView(), pVisiLayer, false) &&
670 0 : SdrObjectPrimitiveHit(*pObj, aHitPosL, nHitLog, *mpView->GetSdrPageView(), pVisiLayer, false) &&
671 0 : SdrObjectPrimitiveHit(*pObj, aHitPosT, nHitLog, *mpView->GetSdrPageView(), pVisiLayer, false) &&
672 0 : SdrObjectPrimitiveHit(*pObj, aHitPosB, nHitLog, *mpView->GetSdrPageView(), pVisiLayer, false)))
673 : {
674 : /**********************************************************
675 : * hit inside the object (without margin) or open object
676 : ********************************************************/
677 :
678 0 : if (bAnimationInfo)
679 : {
680 : /******************************************************
681 : * Click-Action
682 : ******************************************************/
683 0 : SdAnimationInfo* pInfo = mpDoc->GetAnimationInfo(pObj);
684 :
685 0 : if ((mpView->ISA(DrawView) &&
686 0 : (pInfo->meClickAction == presentation::ClickAction_BOOKMARK ||
687 0 : pInfo->meClickAction == presentation::ClickAction_DOCUMENT ||
688 0 : pInfo->meClickAction == presentation::ClickAction_PREVPAGE ||
689 0 : pInfo->meClickAction == presentation::ClickAction_NEXTPAGE ||
690 0 : pInfo->meClickAction == presentation::ClickAction_FIRSTPAGE ||
691 0 : pInfo->meClickAction == presentation::ClickAction_LASTPAGE ||
692 0 : pInfo->meClickAction == presentation::ClickAction_VERB ||
693 0 : pInfo->meClickAction == presentation::ClickAction_PROGRAM ||
694 0 : pInfo->meClickAction == presentation::ClickAction_MACRO ||
695 0 : pInfo->meClickAction == presentation::ClickAction_SOUND))
696 0 : ||
697 0 : (mpView->ISA(DrawView) &&
698 0 : SlideShow::IsRunning( mpViewShell->GetViewShellBase() ) &&
699 0 : (pInfo->meClickAction == presentation::ClickAction_VANISH ||
700 0 : pInfo->meClickAction == presentation::ClickAction_INVISIBLE ||
701 0 : pInfo->meClickAction == presentation::ClickAction_STOPPRESENTATION ||
702 0 : (pInfo->mbActive &&
703 0 : ( pInfo->meEffect != presentation::AnimationEffect_NONE ||
704 0 : pInfo->meTextEffect != presentation::AnimationEffect_NONE )))))
705 : {
706 : // Animation object
707 0 : bSet = sal_True;
708 0 : mpWindow->SetPointer(Pointer(POINTER_REFHAND));
709 : }
710 : }
711 0 : else if (bImageMapInfo &&
712 0 : mpDoc->GetHitIMapObject(pObj, rPos, *mpWindow))
713 : {
714 : /******************************************************
715 : * ImageMap
716 : ******************************************************/
717 0 : bSet = sal_True;
718 0 : mpWindow->SetPointer(Pointer(POINTER_REFHAND));
719 : }
720 : }
721 : }
722 :
723 0 : return bSet;
724 : }
725 :
726 :
727 :
728 : /**
729 : * Response of doubleclick
730 : */
731 0 : void FuDraw::DoubleClick(const MouseEvent& rMEvt)
732 : {
733 0 : sal_uInt16 nHitLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(HITPIX,0)).Width() );
734 :
735 0 : if ( mpView->AreObjectsMarked() )
736 : {
737 0 : const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
738 :
739 0 : if (rMarkList.GetMarkCount() == 1)
740 : {
741 0 : SdrMark* pMark = rMarkList.GetMark(0);
742 0 : SdrObject* pObj = pMark->GetMarkedSdrObj();
743 :
744 0 : sal_uInt32 nInv = pObj->GetObjInventor();
745 0 : sal_uInt16 nSdrObjKind = pObj->GetObjIdentifier();
746 :
747 0 : if (nInv == SdrInventor && nSdrObjKind == OBJ_OLE2)
748 : {
749 0 : DrawDocShell* pDocSh = mpDoc->GetDocSh();
750 :
751 0 : if ( !pDocSh->IsUIActive() )
752 : {
753 : /**********************************************************
754 : * activate OLE-object
755 : **********************************************************/
756 0 : mpViewShell->ActivateObject( (SdrOle2Obj*) pObj, 0);
757 0 : }
758 : }
759 0 : else if (nInv == SdrInventor && nSdrObjKind == OBJ_GRAF && pObj->IsEmptyPresObj() )
760 : {
761 : mpViewShell->GetViewFrame()->
762 : GetDispatcher()->Execute( SID_INSERT_GRAPHIC,
763 0 : SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD );
764 : }
765 0 : else if ( ( pObj->ISA(SdrTextObj) || pObj->ISA(SdrObjGroup) ) &&
766 0 : !SD_MOD()->GetWaterCan() &&
767 0 : mpViewShell->GetFrameView()->IsDoubleClickTextEdit() &&
768 0 : !mpDocSh->IsReadOnly())
769 : {
770 0 : SfxUInt16Item aItem(SID_TEXTEDIT, 2);
771 : mpViewShell->GetViewFrame()->GetDispatcher()->
772 : Execute(SID_TEXTEDIT, SFX_CALLMODE_ASYNCHRON |
773 0 : SFX_CALLMODE_RECORD, &aItem, 0L);
774 : }
775 0 : else if (nInv == SdrInventor && nSdrObjKind == OBJ_GRUP)
776 : {
777 : // hit group -> select subobject
778 0 : mpView->UnMarkAll();
779 0 : mpView->MarkObj(aMDPos, nHitLog, rMEvt.IsShift(), true);
780 : }
781 : }
782 : }
783 : else
784 0 : mpViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
785 0 : }
786 :
787 :
788 0 : sal_Bool FuDraw::RequestHelp(const HelpEvent& rHEvt)
789 : {
790 0 : sal_Bool bReturn = sal_False;
791 :
792 0 : if (Help::IsBalloonHelpEnabled() || Help::IsQuickHelpEnabled())
793 : {
794 0 : SdrViewEvent aVEvt;
795 :
796 0 : MouseEvent aMEvt(mpWindow->GetPointerPosPixel(), 1, 0, MOUSE_LEFT);
797 :
798 0 : SdrHitKind eHit = mpView->PickAnything(aMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
799 :
800 0 : SdrObject* pObj = aVEvt.pObj;
801 :
802 0 : if (eHit != SDRHIT_NONE && pObj != NULL)
803 : {
804 0 : Point aPosPixel = rHEvt.GetMousePosPixel();
805 :
806 0 : bReturn = SetHelpText(pObj, aPosPixel, aVEvt);
807 :
808 0 : if (!bReturn && (pObj->ISA(SdrObjGroup) || pObj->ISA(E3dPolyScene)))
809 : {
810 : // take a glance into the group
811 0 : SdrPageView* pPV = NULL;
812 :
813 0 : Point aPos(mpWindow->PixelToLogic(mpWindow->ScreenToOutputPixel(aPosPixel)));
814 :
815 0 : if (mpView->PickObj(aPos, mpView->getHitTolLog(), pObj, pPV, SDRSEARCH_ALSOONMASTER | SDRSEARCH_DEEP))
816 0 : bReturn = SetHelpText(pObj, aPosPixel, aVEvt);
817 : }
818 0 : }
819 : }
820 :
821 0 : if (!bReturn)
822 : {
823 0 : bReturn = FuPoor::RequestHelp(rHEvt);
824 : }
825 :
826 0 : return(bReturn);
827 : }
828 :
829 :
830 :
831 0 : sal_Bool FuDraw::SetHelpText(SdrObject* pObj, const Point& rPosPixel, const SdrViewEvent& rVEvt)
832 : {
833 0 : sal_Bool bSet = sal_False;
834 0 : OUString aHelpText;
835 0 : Point aPos(mpWindow->PixelToLogic(mpWindow->ScreenToOutputPixel(rPosPixel)));
836 :
837 : // URL for IMapObject underneath pointer is help text
838 0 : if ( mpDoc->GetIMapInfo(pObj) )
839 : {
840 0 : IMapObject* pIMapObj = mpDoc->GetHitIMapObject(pObj, aPos, *mpWindow );
841 :
842 0 : if ( pIMapObj )
843 : {
844 : // show name
845 0 : aHelpText = pIMapObj->GetAltText();
846 :
847 0 : if (aHelpText.isEmpty())
848 : {
849 : // show url if no name is available
850 0 : aHelpText = INetURLObject::decode( pIMapObj->GetURL(), '%', INetURLObject::DECODE_WITH_CHARSET );
851 : }
852 : }
853 : }
854 0 : else if (!mpDocSh->ISA(GraphicDocShell) && mpDoc->GetAnimationInfo(pObj))
855 : {
856 0 : SdAnimationInfo* pInfo = mpDoc->GetAnimationInfo(pObj);
857 :
858 0 : switch (pInfo->meClickAction)
859 : {
860 : case presentation::ClickAction_PREVPAGE:
861 : {
862 : // jump to the prior page
863 0 : aHelpText = SD_RESSTR(STR_CLICK_ACTION_PREVPAGE);
864 : }
865 0 : break;
866 :
867 : case presentation::ClickAction_NEXTPAGE:
868 : {
869 : // jump to the next page
870 0 : aHelpText = SD_RESSTR(STR_CLICK_ACTION_NEXTPAGE);
871 : }
872 0 : break;
873 :
874 : case presentation::ClickAction_FIRSTPAGE:
875 : {
876 : // jump to the first page
877 0 : aHelpText = SD_RESSTR(STR_CLICK_ACTION_FIRSTPAGE);
878 : }
879 0 : break;
880 :
881 : case presentation::ClickAction_LASTPAGE:
882 : {
883 : // jump to the last page
884 0 : aHelpText = SD_RESSTR(STR_CLICK_ACTION_LASTPAGE);
885 : }
886 0 : break;
887 :
888 : case presentation::ClickAction_BOOKMARK:
889 : {
890 : // jump to object/page
891 0 : aHelpText = SD_RESSTR(STR_CLICK_ACTION_BOOKMARK);
892 0 : aHelpText += ": ";
893 0 : aHelpText += INetURLObject::decode( pInfo->GetBookmark(), '%', INetURLObject::DECODE_WITH_CHARSET );
894 : }
895 0 : break;
896 :
897 : case presentation::ClickAction_DOCUMENT:
898 : {
899 : // jump to document (object/page)
900 0 : aHelpText = SD_RESSTR(STR_CLICK_ACTION_DOCUMENT);
901 0 : aHelpText += ": ";
902 0 : aHelpText += INetURLObject::decode( pInfo->GetBookmark(), '%', INetURLObject::DECODE_WITH_CHARSET );
903 : }
904 0 : break;
905 :
906 : case presentation::ClickAction_PROGRAM:
907 : {
908 : // execute program
909 0 : aHelpText = SD_RESSTR(STR_CLICK_ACTION_PROGRAM);
910 0 : aHelpText += ": ";
911 0 : aHelpText += INetURLObject::decode( pInfo->GetBookmark(), '%', INetURLObject::DECODE_WITH_CHARSET );
912 : }
913 0 : break;
914 :
915 : case presentation::ClickAction_MACRO:
916 : {
917 : // execute program
918 0 : aHelpText = SD_RESSTR(STR_CLICK_ACTION_MACRO);
919 0 : aHelpText += ": ";
920 :
921 0 : if ( SfxApplication::IsXScriptURL( pInfo->GetBookmark() ) )
922 : {
923 0 : aHelpText += pInfo->GetBookmark();
924 : }
925 : else
926 : {
927 0 : OUString sBookmark( pInfo->GetBookmark() );
928 0 : aHelpText += sBookmark.getToken( 2, '.' );
929 0 : aHelpText += ".";
930 0 : aHelpText += sBookmark.getToken( 1, '.' );
931 0 : aHelpText += ".";
932 0 : aHelpText += sBookmark.getToken( 0, '.' );
933 : }
934 : }
935 0 : break;
936 :
937 : case presentation::ClickAction_SOUND:
938 : {
939 : // play-back sound
940 0 : aHelpText = SD_RESSTR(STR_CLICK_ACTION_SOUND);
941 : }
942 0 : break;
943 :
944 : case presentation::ClickAction_VERB:
945 : {
946 : // execute OLE-verb
947 0 : aHelpText = SD_RESSTR(STR_CLICK_ACTION_VERB);
948 : }
949 0 : break;
950 :
951 : case presentation::ClickAction_STOPPRESENTATION:
952 : {
953 : // quit presentation
954 0 : aHelpText = SD_RESSTR(STR_CLICK_ACTION_STOPPRESENTATION);
955 : }
956 0 : break;
957 : default:
958 0 : break;
959 : }
960 : }
961 0 : else if (rVEvt.pURLField)
962 : {
963 : /**************************************************************
964 : * URL-Field
965 : **************************************************************/
966 0 : aHelpText = INetURLObject::decode( rVEvt.pURLField->GetURL(), '%', INetURLObject::DECODE_WITH_CHARSET );
967 : }
968 :
969 0 : if (!aHelpText.isEmpty())
970 : {
971 0 : bSet = sal_True;
972 0 : Rectangle aLogicPix = mpWindow->LogicToPixel(pObj->GetLogicRect());
973 0 : Rectangle aScreenRect(mpWindow->OutputToScreenPixel(aLogicPix.TopLeft()),
974 0 : mpWindow->OutputToScreenPixel(aLogicPix.BottomRight()));
975 :
976 0 : if (Help::IsBalloonHelpEnabled())
977 0 : Help::ShowBalloon( (Window*)mpWindow, rPosPixel, aScreenRect, aHelpText);
978 0 : else if (Help::IsQuickHelpEnabled())
979 0 : Help::ShowQuickHelp( (Window*)mpWindow, aScreenRect, aHelpText);
980 : }
981 :
982 0 : return bSet;
983 : }
984 :
985 :
986 : /** is called when the currenct function should be aborted. <p>
987 : This is used when a function gets a KEY_ESCAPE but can also
988 : be called directly.
989 :
990 : @returns true if a active function was aborted
991 : */
992 0 : bool FuDraw::cancel()
993 : {
994 0 : bool bReturn = false;
995 :
996 0 : if ( mpView->IsAction() )
997 : {
998 0 : mpView->BrkAction();
999 0 : bReturn = true;
1000 : }
1001 0 : else if ( mpView->IsTextEdit() )
1002 : {
1003 0 : mpView->SdrEndTextEdit();
1004 0 : bReturn = true;
1005 :
1006 0 : SfxBindings& rBindings = mpViewShell->GetViewFrame()->GetBindings();
1007 0 : rBindings.Invalidate( SID_PARASPACE_INCREASE );
1008 0 : rBindings.Invalidate( SID_PARASPACE_DECREASE );
1009 : }
1010 0 : else if ( mpView->AreObjectsMarked() )
1011 : {
1012 0 : const SdrHdlList& rHdlList = mpView->GetHdlList();
1013 0 : SdrHdl* pHdl = rHdlList.GetFocusHdl();
1014 :
1015 0 : if(pHdl)
1016 : {
1017 0 : ((SdrHdlList&)rHdlList).ResetFocusHdl();
1018 : }
1019 : else
1020 : {
1021 0 : mpView->UnmarkAll();
1022 : }
1023 :
1024 : // Switch to FuSelect.
1025 : mpViewShell->GetViewFrame()->GetDispatcher()->Execute(
1026 : SID_OBJECT_SELECT,
1027 0 : SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
1028 :
1029 0 : bReturn = true;
1030 : }
1031 :
1032 0 : return bReturn;
1033 : }
1034 :
1035 0 : } // end of namespace sd
1036 :
1037 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|