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