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