LibreOffice Module sd (master) 1
fupoor.cxx
Go to the documentation of this file.
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 <fupoor.hxx>
21
22#include <svx/svxids.hrc>
23#include <svx/svdpagv.hxx>
24#include <svx/svdoole2.hxx>
25#include <svx/svdograf.hxx>
26#include <vcl/seleng.hxx>
27#include <sfx2/dispatch.hxx>
28#include <sfx2/bindings.hxx>
29#include <sfx2/request.hxx>
30#include <svl/stritem.hxx>
31
32#include <app.hrc>
33#include <fusel.hxx>
34#include <sdpage.hxx>
35#include <DrawViewShell.hxx>
36#include <Window.hxx>
37#include <drawdoc.hxx>
38#include <DrawDocShell.hxx>
39#include <zoomlist.hxx>
40#include <slideshow.hxx>
41#include <LayerTabBar.hxx>
42
43#include <com/sun/star/embed/EmbedVerbs.hpp>
44
45#include <sfx2/viewfrm.hxx>
46
47#include <svx/svditer.hxx>
48
49#include <editeng/editeng.hxx>
50
51using namespace ::com::sun::star;
52
53namespace sd {
54
55
57 ViewShell* pViewSh,
58 ::sd::Window* pWin,
59 ::sd::View* pView,
60 SdDrawDocument* pDrDoc,
61 SfxRequest& rReq)
62 : mpView(pView),
63 mpViewShell(pViewSh),
64 mpWindow(pWin),
65 mpDocSh( pDrDoc->GetDocSh() ),
66 mpDoc(pDrDoc),
67 nSlotId( rReq.GetSlot() ),
68 aScrollTimer("sd FuPoor aScrollTimer"),
69 aDragTimer("sd FuPoor aDragTimer"),
70 bIsInDragMode(false),
71 bNoScrollUntilInside (true),
72 aDelayToScrollTimer("sd FuPoor aDelayToScrollTimer"),
73 bScrollable (false),
74 bDelayActive (false),
75 bFirstMouseMove (false),
76 // remember MouseButton state
77 mnCode(0)
78{
79 ReceiveRequest(rReq);
80
81 aScrollTimer.SetInvokeHandler( LINK(this, FuPoor, ScrollHdl) );
83
84 aDragTimer.SetInvokeHandler( LINK(this, FuPoor, DragHdl) );
86
89}
90
92{
96}
97
99{
100}
101
103{
107 bScrollable = bDelayActive = false;
108
109 if (mpWindow && mpWindow->IsMouseCaptured())
110 mpWindow->ReleaseMouse();
111}
112
114{
115 mpWindow = pWin;
116}
117
121void FuPoor::ForceScroll(const Point& aPixPos)
122{
124
127 return;
128
129 Point aPos = mpWindow->OutputToScreenPixel(aPixPos);
130 const ::tools::Rectangle& rRect = mpViewShell->GetAllWindowRect();
131
133 {
134 if ( rRect.Contains(aPos) )
135 bNoScrollUntilInside = false;
136 }
137 else
138 {
139 short dx = 0, dy = 0;
140
141 if ( aPos.X() <= rRect.Left() ) dx = -1;
142 if ( aPos.X() >= rRect.Right() ) dx = 1;
143 if ( aPos.Y() <= rRect.Top() ) dy = -1;
144 if ( aPos.Y() >= rRect.Bottom() ) dy = 1;
145
146 if ( dx != 0 || dy != 0 )
147 {
148 if (bScrollable)
149 {
150 // scroll action in derived class
151 mpViewShell->ScrollLines(dx, dy);
153 }
155 }
156 }
157}
158
162IMPL_LINK_NOARG(FuPoor, ScrollHdl, Timer *, void)
163{
164 Point aPnt(mpWindow->GetPointerPosPixel());
165
166 // use remembered MouseButton state to create correct
167 // MouseEvents for this artificial MouseMove.
168 MouseMove(MouseEvent(aPnt, 1, MouseEventModifiers::NONE, GetMouseButtonCode()));
169}
170
175bool FuPoor::KeyInput(const KeyEvent& rKEvt)
176{
177 sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode();
178 bool bReturn = false;
179 bool bSlideShow = SlideShow::IsRunning( mpViewShell->GetViewShellBase() );
180
181 switch (nCode)
182 {
183 case KEY_RETURN:
184 {
185 if(rKEvt.GetKeyCode().IsMod1())
186 {
187 if( auto pDrawViewShell = dynamic_cast<DrawViewShell *>( mpViewShell ))
188 {
189 SdPage* pActualPage = pDrawViewShell->GetActualPage();
190 SdrTextObj* pCandidate = nullptr;
191
192 if(pActualPage)
193 {
194 SdrObjListIter aIter(pActualPage, SdrIterMode::DeepNoGroups);
195
196 while(aIter.IsMore() && !pCandidate)
197 {
198 SdrObject* pObj = aIter.Next();
199
200 if(auto pTextObj = DynCastSdrTextObj( pObj ))
201 {
202 SdrInventor nInv(pObj->GetObjInventor());
203 SdrObjKind nKnd(pObj->GetObjIdentifier());
204
205 if(SdrInventor::Default == nInv &&
206 (SdrObjKind::TitleText == nKnd || SdrObjKind::OutlineText == nKnd || SdrObjKind::Text == nKnd))
207 {
208 pCandidate = pTextObj;
209 }
210 }
211 }
212 }
213
214 if(pCandidate)
215 {
216 mpView->UnMarkAll();
217 mpView->MarkObj(pCandidate, mpView->GetSdrPageView());
218
220 SID_ATTR_CHAR, SfxCallMode::ASYNCHRON);
221 }
222 else
223 {
224 // insert a new page with the same page layout
226 SID_INSERTPAGE_QUICK, SfxCallMode::ASYNCHRON);
227 }
228
229 // consumed
230 bReturn = true;
231 }
232 }
233 else
234 {
235 // activate OLE object on RETURN for selected object
236 // activate text edit on RETURN for selected object
237 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
238
239 if( !mpView->IsTextEdit() && 1 == rMarkList.GetMarkCount() )
240 {
241 SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
242
243 if( dynamic_cast< const SdrOle2Obj* >( pObj ) && !mpDocSh->IsUIActive() )
244 {
245 //HMHmpView->HideMarkHdl();
246 mpViewShell->ActivateObject(static_cast<SdrOle2Obj*>(pObj), css::embed::EmbedVerbs::MS_OLEVERB_PRIMARY);
247 }
248 else if( pObj && pObj->IsEmptyPresObj() && dynamic_cast< const SdrGrafObj *>( pObj ) != nullptr )
249 {
250 mpViewShell->GetViewFrame()->GetDispatcher()->Execute( SID_INSERT_GRAPHIC, SfxCallMode::ASYNCHRON | SfxCallMode::RECORD );
251 }
252 else
253 {
254 mpViewShell->GetViewFrame()->GetDispatcher()->Execute( SID_ATTR_CHAR, SfxCallMode::ASYNCHRON | SfxCallMode::RECORD );
255 }
256
257 // consumed
258 bReturn = true;
259 }
260 }
261 }
262 break;
263
264 case KEY_TAB:
265 {
266 // handle Mod1 and Mod2 to get travelling running on different systems
267 if(rKEvt.GetKeyCode().IsMod1() || rKEvt.GetKeyCode().IsMod2())
268 {
269 // do something with a selected handle?
270 const SdrHdlList& rHdlList = mpView->GetHdlList();
271 bool bForward(!rKEvt.GetKeyCode().IsShift());
272
273 const_cast<SdrHdlList&>(rHdlList).TravelFocusHdl(bForward);
274
275 // guarantee visibility of focused handle
276 SdrHdl* pHdl = rHdlList.GetFocusHdl();
277
278 if(pHdl)
279 {
280 Point aHdlPosition(pHdl->GetPos());
281 ::tools::Rectangle aVisRect(aHdlPosition - Point(100, 100), Size(200, 200));
282 mpView->MakeVisible(aVisRect, *mpWindow);
283 }
284
285 // consumed
286 bReturn = true;
287 }
288 }
289 break;
290
291 case KEY_ESCAPE:
292 {
293 bReturn = FuPoor::cancel();
294 }
295 break;
296
297 case KEY_ADD:
298 {
299 if (!mpView->IsTextEdit() && !bSlideShow && !mpDocSh->IsUIActive())
300 {
301 // increase zoom
302 mpViewShell->SetZoom(mpWindow->GetZoom() * 3 / 2);
303
304 if( auto pViewShell = dynamic_cast<DrawViewShell *>( mpViewShell ))
305 pViewShell->SetZoomOnPage(false);
306
307 bReturn = true;
308 }
309 }
310 break;
311
312 case KEY_SUBTRACT:
313 {
314 if (!mpView->IsTextEdit() && !bSlideShow && !mpDocSh->IsUIActive())
315 {
316 // decrease zoom
317 mpViewShell->SetZoom(mpWindow->GetZoom() * 2 / 3);
318
319 if( auto pViewShell = dynamic_cast<DrawViewShell *>( mpViewShell ))
320 pViewShell->SetZoomOnPage(false);
321
322 bReturn = true;
323 }
324 }
325 break;
326
327 case KEY_MULTIPLY:
328 {
329 if (!mpView->IsTextEdit() && !bSlideShow)
330 {
331 // zoom to page
333 Execute(SID_SIZE_PAGE, SfxCallMode::ASYNCHRON | SfxCallMode::RECORD);
334 bReturn = true;
335 }
336 }
337 break;
338
339 case KEY_DIVIDE:
340 {
341 if (!mpView->IsTextEdit() && !bSlideShow)
342 {
343 // zoom to selected objects
345 Execute(SID_SIZE_OPTIMAL, SfxCallMode::ASYNCHRON | SfxCallMode::RECORD);
346 bReturn = true;
347 }
348 }
349 break;
350
351 case KEY_POINT:
352 {
353 ZoomList* pZoomList = mpViewShell->GetZoomList();
354
355 if (!mpView->IsTextEdit() && pZoomList->IsNextPossible() && !bSlideShow && !mpDocSh->IsUIActive())
356 {
357 // use next ZoomRect
359 bReturn = true;
360 }
361 }
362 break;
363
364 case KEY_COMMA:
365 {
366 ZoomList* pZoomList = mpViewShell->GetZoomList();
367
368 if (!mpView->IsTextEdit() && pZoomList->IsPreviousPossible() && !bSlideShow && !mpDocSh->IsUIActive())
369 {
370 // use previous ZoomRect
372 bReturn = true;
373 }
374 }
375 break;
376
377 case KEY_HOME:
378 {
379 if (!mpView->IsTextEdit() && !bSlideShow)
380 if (auto pDrawViewShell = dynamic_cast<DrawViewShell *>( mpViewShell ))
381 {
382 // jump to first page
383 pDrawViewShell->SwitchPage(0);
384 bReturn = true;
385 }
386 }
387 break;
388
389 case KEY_END:
390 {
391 if (!mpView->IsTextEdit() && !bSlideShow)
392 if (auto pDrawViewShell = dynamic_cast<DrawViewShell *>( mpViewShell ))
393 {
394 // jump to last page
395 SdPage* pPage = pDrawViewShell->GetActualPage();
396 pDrawViewShell->SwitchPage(mpDoc->GetSdPageCount(
397 pPage->GetPageKind()) - 1);
398 bReturn = true;
399 }
400 }
401 break;
402
403 case KEY_PAGEUP:
404 {
405 if( rKEvt.GetKeyCode().IsMod1() && rKEvt.GetKeyCode().IsMod2() )
406 break;
407 if( bSlideShow)
408 break;
409
410 if( auto pDrawViewShell = dynamic_cast<DrawViewShell *>( mpViewShell ) )
411 {
412 // The page-up key switches layers or pages depending on the
413 // modifier key.
414 if ( ! rKEvt.GetKeyCode().GetModifier())
415 {
416 // With no modifier pressed we move to the previous
417 // slide.
419
420 // Previous page.
421 bReturn = true;
422 SdPage* pPage = pDrawViewShell->GetActualPage();
423 sal_uInt16 nSdPage = (pPage->GetPageNum() - 1) / 2;
424
425 if (nSdPage > 0)
426 {
427 // Switch the page and send events regarding
428 // deactivation the old page and activating the new
429 // one.
430 TabControl& rPageTabControl =
431 pDrawViewShell->GetPageTabControl();
432 if (rPageTabControl.IsReallyShown())
433 rPageTabControl.SendDeactivatePageEvent ();
434 pDrawViewShell->SwitchPage(nSdPage - 1);
435 if (rPageTabControl.IsReallyShown())
436 rPageTabControl.SendActivatePageEvent ();
437 }
438 }
439 else if (rKEvt.GetKeyCode().IsMod1())
440 {
441 // With the CONTROL modifier we switch layers.
442 if (pDrawViewShell->IsLayerModeActive())
443 {
444 // Moves to the previous layer.
445 SwitchLayer (-1);
446 }
447 }
448 }
449 }
450 break;
451
452 case KEY_PAGEDOWN:
453 {
454 if( rKEvt.GetKeyCode().IsMod1() && rKEvt.GetKeyCode().IsMod2() )
455 break;
456 if(dynamic_cast< const DrawViewShell *>( mpViewShell ) != nullptr && !bSlideShow)
457 {
458 // The page-down key switches layers or pages depending on the
459 // modifier key.
460 if ( ! rKEvt.GetKeyCode().GetModifier())
461 {
462 // With no modifier pressed we move to the next slide.
464
465 // Next page.
466 bReturn = true;
467 SdPage* pPage = static_cast<DrawViewShell*>(mpViewShell)->GetActualPage();
468 sal_uInt16 nSdPage = (pPage->GetPageNum() - 1) / 2;
469
470 if (nSdPage < mpDoc->GetSdPageCount(pPage->GetPageKind()) - 1)
471 {
472 // Switch the page and send events regarding
473 // deactivation the old page and activating the new
474 // one.
475 TabControl& rPageTabControl =
476 static_cast<DrawViewShell*>(mpViewShell)->GetPageTabControl();
477 if (rPageTabControl.IsReallyShown())
478 rPageTabControl.SendDeactivatePageEvent ();
479 static_cast<DrawViewShell*>(mpViewShell)->SwitchPage(nSdPage + 1);
480 if (rPageTabControl.IsReallyShown())
481 rPageTabControl.SendActivatePageEvent ();
482 }
483 }
484 else if (rKEvt.GetKeyCode().IsMod1())
485 {
486 // With the CONTROL modifier we switch layers.
487 if (static_cast<DrawViewShell*>(mpViewShell)->IsLayerModeActive())
488 {
489 // With the layer mode active pressing page-down
490 // moves to the next layer.
491 SwitchLayer (+1);
492 }
493 }
494 }
495 }
496 break;
497
498 // change select state when focus is on poly point
499 case KEY_SPACE:
500 {
501 const SdrHdlList& rHdlList = mpView->GetHdlList();
502 SdrHdl* pHdl = rHdlList.GetFocusHdl();
503
504 if(pHdl)
505 {
506 if(pHdl->GetKind() == SdrHdlKind::Poly)
507 {
508 // rescue ID of point with focus
509 sal_uInt32 nPol(pHdl->GetPolyNum());
510 sal_uInt32 nPnt(pHdl->GetPointNum());
511
512 if(mpView->IsPointMarked(*pHdl))
513 {
514 if(rKEvt.GetKeyCode().IsShift())
515 {
516 mpView->UnmarkPoint(*pHdl);
517 }
518 }
519 else
520 {
521 if(!rKEvt.GetKeyCode().IsShift())
522 {
524 }
525
526 mpView->MarkPoint(*pHdl);
527 }
528
529 if(nullptr == rHdlList.GetFocusHdl())
530 {
531 // restore point with focus
532 SdrHdl* pNewOne = nullptr;
533
534 for(size_t a = 0; !pNewOne && a < rHdlList.GetHdlCount(); ++a)
535 {
536 SdrHdl* pAct = rHdlList.GetHdl(a);
537
538 if(pAct
539 && pAct->GetKind() == SdrHdlKind::Poly
540 && pAct->GetPolyNum() == nPol
541 && pAct->GetPointNum() == nPnt)
542 {
543 pNewOne = pAct;
544 }
545 }
546
547 if(pNewOne)
548 {
549 const_cast<SdrHdlList&>(rHdlList).SetFocusHdl(pNewOne);
550 }
551 }
552
553 bReturn = true;
554 }
555 }
556 }
557 break;
558
559 case KEY_UP:
560 case KEY_DOWN:
561 case KEY_LEFT:
562 case KEY_RIGHT:
563 {
564 if (!mpView->IsTextEdit() && !bSlideShow)
565 {
566 ::tools::Long nX = 0;
567 ::tools::Long nY = 0;
568
569 if (nCode == KEY_UP)
570 {
571 // scroll up
572 nX = 0;
573 nY =-1;
574 }
575 else if (nCode == KEY_DOWN)
576 {
577 // scroll down
578 nX = 0;
579 nY = 1;
580 }
581 else if (nCode == KEY_LEFT)
582 {
583 // scroll left
584 nX =-1;
585 nY = 0;
586 }
587 else if (nCode == KEY_RIGHT)
588 {
589 // scroll right
590 nX = 1;
591 nY = 0;
592 }
593
594 if (mpView->AreObjectsMarked() && !rKEvt.GetKeyCode().IsMod1() &&
596 {
597 const SdrHdlList& rHdlList = mpView->GetHdlList();
598 SdrHdl* pHdl = rHdlList.GetFocusHdl();
599
600 bool bIsMoveOfConnectedHandle(false);
601 bool bOldSuppress = false;
602 SdrEdgeObj* pEdgeObj = nullptr;
603 if(pHdl)
604 pEdgeObj = dynamic_cast<SdrEdgeObj *>( pHdl->GetObj() );
605
606 if(pEdgeObj && 0 == pHdl->GetPolyNum())
607 {
608 if(0 == pHdl->GetPointNum())
609 {
610 if(pEdgeObj->GetConnection(true).GetObject())
611 {
612 bIsMoveOfConnectedHandle = true;
613 }
614 }
615 if(1 == pHdl->GetPointNum())
616 {
617 if(pEdgeObj->GetConnection(false).GetObject())
618 {
619 bIsMoveOfConnectedHandle = true;
620 }
621 }
622 }
623
624 if(pEdgeObj)
625 {
626 // Suppress default connects to inside object and object center
627 bOldSuppress = pEdgeObj->GetSuppressDefaultConnect();
628 pEdgeObj->SetSuppressDefaultConnect(true);
629 }
630
631 if(bIsMoveOfConnectedHandle)
632 {
633 sal_uInt16 nMarkHdSiz(mpView->GetMarkHdlSizePixel());
634 Size aHalfConSiz(nMarkHdSiz + 1, nMarkHdSiz + 1);
635 aHalfConSiz = mpWindow->PixelToLogic(aHalfConSiz);
636
637 if(100 < aHalfConSiz.Width())
638 nX *= aHalfConSiz.Width();
639 else
640 nX *= 100;
641
642 if(100 < aHalfConSiz.Height())
643 nY *= aHalfConSiz.Height();
644 else
645 nY *= 100;
646 }
647 else if(rKEvt.GetKeyCode().IsMod2())
648 {
649 // move in 1 pixel distance
650 Size aLogicSizeOnePixel = mpWindow->PixelToLogic(Size(1,1));
651 nX *= aLogicSizeOnePixel.Width();
652 nY *= aLogicSizeOnePixel.Height();
653 }
654 else if(rKEvt.GetKeyCode().IsShift())
655 {
656 nX *= 1000;
657 nY *= 1000;
658 }
659 else
660 {
661 // old, fixed move distance
662 nX *= 100;
663 nY *= 100;
664 }
665
666 if(nullptr == pHdl)
667 {
668 // only take action when move is allowed
669 if(mpView->IsMoveAllowed())
670 {
671 // restrict movement to WorkArea
672 const ::tools::Rectangle& rWorkArea = mpView->GetWorkArea();
673
674 if(!rWorkArea.IsEmpty())
675 {
677 aMarkRect.Move(nX, nY);
678
679 if(!aMarkRect.Contains(rWorkArea))
680 {
681 if(aMarkRect.Left() < rWorkArea.Left())
682 {
683 nX += rWorkArea.Left() - aMarkRect.Left();
684 }
685
686 if(aMarkRect.Right() > rWorkArea.Right())
687 {
688 nX -= aMarkRect.Right() - rWorkArea.Right();
689 }
690
691 if(aMarkRect.Top() < rWorkArea.Top())
692 {
693 nY += rWorkArea.Top() - aMarkRect.Top();
694 }
695
696 if(aMarkRect.Bottom() > rWorkArea.Bottom())
697 {
698 nY -= aMarkRect.Bottom() - rWorkArea.Bottom();
699 }
700 }
701 }
702
703 // no handle selected
704 if(0 != nX || 0 != nY)
705 {
706 mpView->MoveAllMarked(Size(nX, nY));
707
709 }
710 }
711 }
712 else
713 {
714 // move handle with index nHandleIndex
715 if (nX || nY)
716 {
717 // now move the Handle (nX, nY)
718 Point aStartPoint(pHdl->GetPos());
719 Point aEndPoint(pHdl->GetPos() + Point(nX, nY));
720 const SdrDragStat& rDragStat = mpView->GetDragStat();
721
722 // start dragging
723 mpView->BegDragObj(aStartPoint, nullptr, pHdl, 0);
724
725 if(mpView->IsDragObj())
726 {
727 bool bWasNoSnap = rDragStat.IsNoSnap();
728 bool bWasSnapEnabled = mpView->IsSnapEnabled();
729
730 // switch snapping off
731 if(!bWasNoSnap)
732 const_cast<SdrDragStat&>(rDragStat).SetNoSnap();
733 if(bWasSnapEnabled)
734 mpView->SetSnapEnabled(false);
735
736 mpView->MovAction(aEndPoint);
738
739 // restore snap
740 if(!bWasNoSnap)
741 const_cast<SdrDragStat&>(rDragStat).SetNoSnap(bWasNoSnap);
742 if(bWasSnapEnabled)
743 mpView->SetSnapEnabled(bWasSnapEnabled);
744 }
745
746 // make moved handle visible
747 ::tools::Rectangle aVisRect(aEndPoint - Point(100, 100), Size(200, 200));
748 mpView->MakeVisible(aVisRect, *mpWindow);
749 }
750 }
751
752 if(pEdgeObj)
753 {
754 // Restore original suppress value
755 pEdgeObj->SetSuppressDefaultConnect(bOldSuppress);
756 }
757 }
758 else
759 {
760 // scroll page
761 mpViewShell->ScrollLines(nX, nY);
762 }
763
764 bReturn = true;
765 }
766 }
767 break;
768 }
769
770 if (bReturn)
771 {
772 mpWindow->ReleaseMouse();
773 }
774
775 // when a text-editable object is selected and the
776 // input character is printable, activate text edit on that object
777 // and feed character to object
778 if(!bReturn && !mpDocSh->IsReadOnly())
779 {
780 if (!mpView->IsTextEdit())
781 {
782 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
783
784 if(1 == rMarkList.GetMarkCount())
785 {
786 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
787
788 // #i118485# allow TextInput for OLEs, too
789 if( DynCastSdrTextObj( pObj ) != nullptr && pObj->HasTextEdit())
790 {
791 // use common IsSimpleCharInput from the EditEngine.
792 bool bPrintable(EditEngine::IsSimpleCharInput(rKEvt));
793
794 if(bPrintable)
795 {
796 // try to activate textedit mode for the selected object
797 SfxStringItem aInputString(SID_ATTR_CHAR, OUString(rKEvt.GetCharCode()));
798
800 SID_ATTR_CHAR,
801 SfxCallMode::ASYNCHRON,
802 { &aInputString });
803
804 // consumed
805 bReturn = true;
806 }
807 }
808 }
809 else
810 {
811 // test if there is a title object there. If yes, try to
812 // set it to edit mode and start typing...
813 DrawViewShell* pDrawViewShell = dynamic_cast<DrawViewShell*>(mpViewShell);
814 if (pDrawViewShell && EditEngine::IsSimpleCharInput(rKEvt))
815 {
816 SdPage* pActualPage = pDrawViewShell->GetActualPage();
817 SdrTextObj* pCandidate = nullptr;
818
819 if(pActualPage)
820 {
821 SdrObjListIter aIter(pActualPage, SdrIterMode::DeepNoGroups);
822
823 while(aIter.IsMore() && !pCandidate)
824 {
825 SdrObject* pObj = aIter.Next();
826
827 if(auto pTextObj = DynCastSdrTextObj( pObj ))
828 {
829 SdrInventor nInv(pObj->GetObjInventor());
830 SdrObjKind nKnd(pObj->GetObjIdentifier());
831
832 if(SdrInventor::Default == nInv && SdrObjKind::TitleText == nKnd)
833 {
834 pCandidate = pTextObj;
835 }
836 }
837 }
838 }
839
840 // when candidate found and candidate is untouched, start editing text...
841 if(pCandidate && pCandidate->IsEmptyPresObj())
842 {
843 mpView->UnMarkAll();
844 mpView->MarkObj(pCandidate, mpView->GetSdrPageView());
845 SfxStringItem aInputString(SID_ATTR_CHAR, OUString(rKEvt.GetCharCode()));
846
848 SID_ATTR_CHAR,
849 SfxCallMode::ASYNCHRON,
850 { &aInputString });
851
852 // consumed
853 bReturn = true;
854 }
855 }
856 }
857 }
858 }
859
860 return bReturn;
861}
862
864{
865 return false;
866}
867
869{
870 const SdrHdlList& rHdlList = mpView->GetHdlList();
871 const_cast<SdrHdlList&>(rHdlList).ResetFocusHdl();
872}
873
878{
879 if (mpView)
880 {
881 mpView->DoCut();
882 }
883}
884
889{
890 if (mpView)
891 {
892 mpView->DoCopy();
893 }
894}
895
900{
901 if (mpView)
902 {
904 }
905}
906
911{
912 if (mpView)
913 {
915 if (aDataHelper.GetTransferable().is())
916 {
917 sal_Int8 nAction = DND_ACTION_COPY;
918 mpView->InsertData( aDataHelper,
919 mpWindow->PixelToLogic( ::tools::Rectangle( Point(), mpWindow->GetOutputSizePixel() ).Center() ),
920 nAction, false, SotClipboardFormatId::STRING);
921 }
922 }
923}
924
928IMPL_LINK_NOARG(FuPoor, DragHdl, Timer *, void)
929{
930 if( !mpView )
931 return;
932
933 sal_uInt16 nHitLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(HITPIX,0)).Width() );
934 SdrHdl* pHdl = mpView->PickHandle(aMDPos);
935
936 if ( pHdl==nullptr && mpView->IsMarkedHit(aMDPos, nHitLog)
937 && !mpView->IsPresObjSelected(false) )
938 {
939 mpWindow->ReleaseMouse();
940 bIsInDragMode = true;
941 mpView->StartDrag( aMDPos, mpWindow );
942 }
943}
944
946{
947 return mpView->Command(rCEvt,mpWindow);
948}
949
953IMPL_LINK_NOARG(FuPoor, DelayHdl, Timer *, void)
954{
955 aDelayToScrollTimer.Stop ();
956 bScrollable = true;
957
958 Point aPnt(mpWindow->GetPointerPosPixel());
959
960 // use remembered MouseButton state to create correct
961 // MouseEvents for this artificial MouseMove.
962 MouseMove(MouseEvent(aPnt, 1, MouseEventModifiers::NONE, GetMouseButtonCode()));
963}
964
966{
967 // remember button state for creation of own MouseEvents
969
971 bScrollable = bDelayActive = false;
972 return bScrollable;
973}
974
976{
977 // remember button state for creation of own MouseEvents
979
980 return false;
981}
982
984{
985 bDelayActive = true;
987}
988
990{
991 bool bReturn = false;
992
994
995 if (pPV)
996 {
997 SdPage* pPage = static_cast<SdPage*>( pPV->GetPage() );
998
999 if (pPage)
1000 {
1001 bReturn = FmFormPage::RequestHelp(mpWindow, mpView, rHEvt);
1002 }
1003 }
1004
1005 return bReturn;
1006}
1007
1009{
1010}
1011
1012rtl::Reference<SdrObject> FuPoor::CreateDefaultObject(const sal_uInt16, const ::tools::Rectangle& )
1013{
1014 // empty base implementation
1015 return nullptr;
1016}
1017
1019{
1020 if(rRect.GetWidth() > rRect.GetHeight())
1021 {
1022 rRect = ::tools::Rectangle(
1023 Point(rRect.Left() + ((rRect.GetWidth() - rRect.GetHeight()) / 2), rRect.Top()),
1024 Size(rRect.GetHeight(), rRect.GetHeight()));
1025 }
1026 else
1027 {
1028 rRect = ::tools::Rectangle(
1029 Point(rRect.Left(), rRect.Top() + ((rRect.GetHeight() - rRect.GetWidth()) / 2)),
1030 Size(rRect.GetWidth(), rRect.GetWidth()));
1031 }
1032}
1033
1034void FuPoor::SwitchLayer (sal_Int32 nOffset)
1035{
1036 auto pDrawViewShell = dynamic_cast<DrawViewShell *>( mpViewShell );
1037 if(!pDrawViewShell)
1038 return;
1039
1040 // Calculate the new index.
1041 sal_Int32 nIndex = pDrawViewShell->GetActiveTabLayerIndex() + nOffset;
1042
1043 // Make sure the new index lies inside the range of valid indices.
1044 if (nIndex < 0)
1045 nIndex = 0;
1046 else if (nIndex >= pDrawViewShell->GetTabLayerCount ())
1047 nIndex = pDrawViewShell->GetTabLayerCount() - 1;
1048
1049 // Set the new active layer.
1050 if (nIndex != pDrawViewShell->GetActiveTabLayerIndex ())
1051 {
1052 LayerTabBar* pLayerTabControl =
1053 static_cast<DrawViewShell*>(mpViewShell)->GetLayerTabControl();
1054 if (pLayerTabControl != nullptr)
1055 pLayerTabControl->SendDeactivatePageEvent ();
1056
1057 pDrawViewShell->SetActiveTabLayerIndex (nIndex);
1058
1059 if (pLayerTabControl != nullptr)
1060 pLayerTabControl->SendActivatePageEvent ();
1061 }
1062}
1063
1071{
1072 if ( dynamic_cast< const FuSelection *>( this ) == nullptr )
1073 {
1074 mpViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SfxCallMode::ASYNCHRON);
1075 return true;
1076 }
1077
1078 return false;
1079}
1080
1081// #i33136#
1083{
1084 // Check whether a media object is selected
1085 bool bResizeKeepRatio = false;
1086 // tdf#89758 Avoid interactive crop preview from being proportionally scaled by default.
1087 if (mpView->AreObjectsMarked() && mpView->GetDragMode() != SdrDragMode::Crop)
1088 {
1089 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
1090 if (rMarkList.GetMarkCount() == 1)
1091 {
1092 SdrObjKind aObjIdentifier = rMarkList.GetMark(0)->GetMarkedSdrObj()->GetObjIdentifier();
1093 bResizeKeepRatio = aObjIdentifier == SdrObjKind::Graphic ||
1094 aObjIdentifier == SdrObjKind::Media ||
1095 aObjIdentifier == SdrObjKind::OLE2;
1096 }
1097 }
1098 SdrHdl* pHdl = mpView->PickHandle(aMDPos);
1099 // Resize proportionally when media is selected and the user drags on a corner
1100 if (pHdl)
1101 bResizeKeepRatio = bResizeKeepRatio && pHdl->IsCornerHdl();
1102
1103 return (
1104 bResizeKeepRatio ||
1105 SID_DRAW_XLINE == nSlotId ||
1106 SID_DRAW_CIRCLEARC == nSlotId ||
1107 SID_DRAW_SQUARE == nSlotId ||
1108 SID_DRAW_SQUARE_NOFILL == nSlotId ||
1109 SID_DRAW_SQUARE_ROUND == nSlotId ||
1110 SID_DRAW_SQUARE_ROUND_NOFILL == nSlotId ||
1111 SID_DRAW_CIRCLE == nSlotId ||
1112 SID_DRAW_CIRCLE_NOFILL == nSlotId ||
1113 SID_DRAW_CIRCLEPIE == nSlotId ||
1114 SID_DRAW_CIRCLEPIE_NOFILL == nSlotId ||
1115 SID_DRAW_CIRCLECUT == nSlotId ||
1116 SID_DRAW_CIRCLECUT_NOFILL == nSlotId ||
1117 SID_DRAW_XPOLYGON == nSlotId ||
1118 SID_DRAW_XPOLYGON_NOFILL == nSlotId ||
1119 SID_3D_CUBE == nSlotId ||
1120 SID_3D_SPHERE == nSlotId ||
1121 SID_3D_SHELL == nSlotId ||
1122 SID_3D_HALF_SPHERE == nSlotId ||
1123 SID_3D_TORUS == nSlotId ||
1124 SID_3D_CYLINDER == nSlotId ||
1125 SID_3D_CONE == nSlotId ||
1126 SID_3D_PYRAMID == nSlotId);
1127}
1128
1130{
1131}
1132
1133} // end of namespace sd
1134
1135/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual bool BegDragObj(const Point &rPnt, OutputDevice *pOut, SdrHdl *pHdl, short nMinMov=-3, SdrDragMethod *pForcedMeth=nullptr) override
virtual void MovAction(const Point &rPnt) override
static bool IsSimpleCharInput(const KeyEvent &rKeyEvent)
static bool RequestHelp(vcl::Window *pWin, SdrView const *pView, const HelpEvent &rEvt)
sal_Unicode GetCharCode() const
const vcl::KeyCode & GetKeyCode() const
sal_uInt16 GetButtons() const
constexpr tools::Long Y() const
constexpr tools::Long X() const
sal_uInt16 GetSdPageCount(PageKind ePgKind) const
Definition: drawdoc2.cxx:212
PageKind GetPageKind() const
Definition: sdpage.hxx:205
bool IsNoSnap() const
bool EndDragObj(bool bCopy=false)
const tools::Rectangle & GetWorkArea() const
bool IsDragObj() const
void SetSuppressDefaultConnect(bool bNew)
SdrObjConnection & GetConnection(bool bTail1)
bool GetSuppressDefaultConnect() const
bool IsMoveAllowed() const
void MoveAllMarked(const Size &rSiz, bool bCopy=false)
size_t GetHdlCount() const
SdrHdl * GetFocusHdl() const
SdrHdl * GetHdl(size_t nNum) const
SdrHdlKind GetKind() const
bool IsCornerHdl() const
sal_uInt32 GetPolyNum() const
SdrObject * GetObj() const
const Point & GetPos() const
sal_uInt32 GetPointNum() const
size_t GetMarkCount() const
SdrMark * GetMark(size_t nNum) const
SdrHdl * PickHandle(const Point &rPnt) const
const SdrMarkList & GetMarkedObjectList() const
bool AreObjectsMarked() const
const SdrHdlList & GetHdlList() const
void UnMarkAll(SdrPageView const *pPV=nullptr)
SdrDragMode GetDragMode() const
sal_uInt16 GetMarkHdlSizePixel() const
bool UnmarkAllPoints()
const tools::Rectangle & GetMarkedObjRect() const
const tools::Rectangle & GetAllMarkedRect() const
bool UnmarkPoint(SdrHdl &rHdl)
bool MarkObj(const Point &rPnt, short nTol=-2, bool bToggle=false, bool bDeep=false)
bool IsPointMarked(const SdrHdl &rHdl) const
SdrObject * GetMarkedSdrObj() const
SdrObject * GetObject() const
virtual bool IsTextEdit() const final override
SdrObject * Next()
bool IsMore() const
virtual SdrInventor GetObjInventor() const
bool IsEmptyPresObj() const
virtual bool HasTextEdit() const
virtual SdrObjKind GetObjIdentifier() const
SdrPage * GetPage() const
sal_uInt16 GetPageNum() const
virtual void MakeVisible(const tools::Rectangle &rRect, vcl::Window &rWin)
const SdrDragStat & GetDragStat() const
SdrPageView * GetSdrPageView() const
bool IsSetPageOrg() const
void SetSnapEnabled(bool bOn)
bool IsSnapEnabled() const
bool IsDragHelpLine() const
virtual bool Command(const CommandEvent &rCEvt, vcl::Window *pWin) override
const SfxPoolItem * Execute(sal_uInt16 nSlot, SfxCallMode nCall=SfxCallMode::SLOT, const SfxPoolItem **pArgs=nullptr, sal_uInt16 nModi=0, const SfxPoolItem **pInternalArgs=nullptr)
const SfxPoolItem * ExecuteList(sal_uInt16 nSlot, SfxCallMode nCall, std::initializer_list< SfxPoolItem const * > args, std::initializer_list< SfxPoolItem const * > internalargs=std::initializer_list< SfxPoolItem const * >())
bool IsUIActive() const
bool IsReadOnly() const
SfxDispatcher * GetDispatcher()
constexpr tools::Long Height() const
constexpr tools::Long Width() const
void Stop()
void SetTimeout(sal_uInt64 nTimeoutMs)
void SetInvokeHandler(const Link< Timer *, void > &rLink)
virtual void Start(bool bStartTimer=true) override
static TransferableDataHelper CreateFromSystemClipboard(vcl::Window *pWindow)
const css::uno::Reference< css::datatransfer::XTransferable > & GetTransferable() const
Base class of the stacked shells that provide graphical views to Draw and Impress documents and editi...
bool IsLayerModeActive() const
virtual SdPage * GetActualPage() override
Base class for all functions.
Definition: fupoor.hxx:48
bool bScrollable
Definition: fupoor.hxx:166
virtual bool doConstructOrthogonal() const
Decide if the object to be created should be created orthogonal.
Definition: fupoor.cxx:1082
virtual bool Command(const CommandEvent &rCEvt)
Definition: fupoor.cxx:945
SdDrawDocument * mpDoc
Definition: fupoor.hxx:148
Timer aScrollTimer
for auto-scrolling
Definition: fupoor.hxx:152
virtual void DoCopy()
Copy object to clipboard.
Definition: fupoor.cxx:888
FuPoor(ViewShell *pViewSh, ::sd::Window *pWin, ::sd::View *pView, SdDrawDocument *pDoc, SfxRequest &rReq)
Definition: fupoor.cxx:56
bool bDelayActive
Definition: fupoor.hxx:167
void SwitchLayer(sal_Int32 nOffset)
Switch to another layer.
Definition: fupoor.cxx:1034
virtual bool MouseButtonDown(const MouseEvent &rMEvt)
Definition: fupoor.cxx:975
virtual bool MouseMove(const MouseEvent &)
Definition: fupoor.cxx:863
void StartDelayToScrollTimer()
Definition: fupoor.cxx:983
virtual bool MouseButtonUp(const MouseEvent &rMEvt)
Definition: fupoor.cxx:965
virtual bool RequestHelp(const HelpEvent &rHEvt)
Definition: fupoor.cxx:989
virtual bool KeyInput(const KeyEvent &rKEvt)
handle keyboard events
Definition: fupoor.cxx:175
void SetWindow(::sd::Window *pWin)
Definition: fupoor.cxx:113
virtual void Activate()
activates the function
Definition: fupoor.cxx:98
VclPtr< ::sd::Window > mpWindow
Definition: fupoor.hxx:146
Point aMDPos
position of MouseButtonDown
Definition: fupoor.hxx:159
static void ImpForceQuadratic(::tools::Rectangle &rRect)
Definition: fupoor.cxx:1018
virtual void DoCut()
Cut object to clipboard.
Definition: fupoor.cxx:877
virtual void DoPasteUnformatted()
Paste unformatted text from clipboard.
Definition: fupoor.cxx:910
ViewShell * mpViewShell
Definition: fupoor.hxx:145
bool bNoScrollUntilInside
Flag to prevent auto-scrolling until one drags from outside into the window.
Definition: fupoor.hxx:162
void SetMouseButtonCode(sal_uInt16 nNew)
Definition: fupoor.hxx:57
virtual void DoPaste()
Paste object from clipboard.
Definition: fupoor.cxx:899
virtual ~FuPoor() override
Definition: fupoor.cxx:91
virtual void SelectionHasChanged()
Definition: fupoor.cxx:868
sal_uInt16 nSlotId
Definition: fupoor.hxx:150
void ForceScroll(const Point &aPixPos)
scroll when approached the border of the window; is called by MouseMove
Definition: fupoor.cxx:121
virtual void Deactivate()
deactivates the function
Definition: fupoor.cxx:102
virtual void ReceiveRequest(SfxRequest &rReq)
Definition: fupoor.cxx:1008
Timer aDragTimer
for Drag&Drop
Definition: fupoor.hxx:156
virtual rtl::Reference< SdrObject > CreateDefaultObject(const sal_uInt16 nID, const ::tools::Rectangle &rRectangle)
Definition: fupoor.cxx:1012
DrawDocShell * mpDocSh
Definition: fupoor.hxx:147
::sd::View * mpView
Definition: fupoor.hxx:144
virtual bool cancel()
is called when the current function should be aborted.
Definition: fupoor.cxx:1070
virtual void DoExecute(SfxRequest &rReq)
Definition: fupoor.cxx:1129
Timer aDelayToScrollTimer
timer to delay scrolling (~ 1 sec) when dragging out of the window
Definition: fupoor.hxx:165
void SendDeactivatePageEvent()
Inform all listeners of this control that the current layer has been deactivated.
void SendActivatePageEvent()
Inform all listeners of this control that the current layer has been activated.
static bool IsRunning(ViewShellBase const &rBase)
returns true if there is a running presentation for the given ViewShellBase
Definition: slideshow.cxx:208
void SendDeactivatePageEvent()
Inform all listeners of this control that the current page has been deactivated.
Definition: tabcontr.cxx:350
void SendActivatePageEvent()
Inform all listeners of this control that the current page has been activated.
Definition: tabcontr.cxx:344
Base class of the stacked shell hierarchy.
Definition: ViewShell.hxx:92
virtual void SetZoom(::tools::Long nZoom)
Set zoom factor for all split windows.
Definition: viewshe2.cxx:309
virtual bool ActivateObject(SdrOle2Obj *pObj, sal_Int32 nVerb)
Definition: viewshe2.cxx:624
const ::tools::Rectangle & GetAllWindowRect()
Return the rectangle that encloses all windows of the view.
Definition: viewshe2.cxx:791
void ScrollLines(::tools::Long nX, ::tools::Long nY)
Scroll a specific number of lines.
Definition: viewshe2.cxx:251
::sd::Window * GetActiveWindow() const
The active window is usually the mpContentWindow.
Definition: ViewShell.hxx:155
virtual void SetZoomRect(const ::tools::Rectangle &rZoomRect)
Set zoom rectangle for active window.
Definition: viewshe2.cxx:358
ZoomList * GetZoomList()
Definition: ViewShell.hxx:219
SD_DLLPUBLIC ViewShellBase & GetViewShellBase() const
Definition: viewshel.cxx:1397
SD_DLLPUBLIC SfxViewFrame * GetViewFrame() const
Definition: viewshel.cxx:118
bool InsertData(const TransferableDataHelper &rDataHelper, const Point &rPos, sal_Int8 &rDnDAction, bool bDrag, SotClipboardFormatId nFormat=SotClipboardFormatId::NONE, sal_uInt16 nPage=SDRPAGE_NOTFOUND, SdrLayerID nLayer=SDRLAYER_NOTFOUND)
Definition: sdview3.cxx:254
virtual SdrEndTextEditKind SdrEndTextEdit(bool bDontDeleteReally=false) override
ends current text editing
Definition: sdview.cxx:772
virtual bool MarkPoint(SdrHdl &rHdl, bool bUnmark=false) override
Definition: sdview.cxx:1159
void DoCopy()
Definition: sdview2.cxx:256
void DoCut()
Definition: sdview2.cxx:239
void DoPaste(::sd::Window *pWindow=nullptr)
Definition: sdview2.cxx:269
An SdWindow contains the actual working area of ViewShell.
Definition: Window.hxx:45
bool IsPreviousPossible() const
Definition: zoomlist.cxx:90
bool IsNextPossible() const
Definition: zoomlist.cxx:83
::tools::Rectangle const & GetNextZoomRect()
Definition: zoomlist.cxx:56
::tools::Rectangle const & GetPreviousZoomRect()
Definition: zoomlist.cxx:71
constexpr Point Center() const
constexpr tools::Long GetWidth() const
bool Contains(const Point &rPOINT) const
constexpr tools::Long Top() const
void Move(tools::Long nHorzMoveDelta, tools::Long nVertMoveDelta)
constexpr tools::Long Right() const
constexpr tools::Long GetHeight() const
constexpr tools::Long Left() const
constexpr tools::Long Bottom() const
bool IsMod1() const
sal_uInt16 GetCode() const
sal_uInt16 GetModifier() const
bool IsShift() const
bool IsMod2() const
sal_Int32 nIndex
uno_Any a
constexpr sal_uInt16 KEY_RETURN
constexpr sal_uInt16 KEY_ESCAPE
constexpr sal_uInt16 KEY_HOME
constexpr sal_uInt16 KEY_ADD
constexpr sal_uInt16 KEY_LEFT
constexpr sal_uInt16 KEY_PAGEDOWN
constexpr sal_uInt16 KEY_TAB
constexpr sal_uInt16 KEY_COMMA
constexpr sal_uInt16 KEY_POINT
constexpr sal_uInt16 KEY_UP
constexpr sal_uInt16 KEY_RIGHT
constexpr sal_uInt16 KEY_DOWN
constexpr sal_uInt16 KEY_SPACE
constexpr sal_uInt16 KEY_PAGEUP
constexpr sal_uInt16 KEY_SUBTRACT
constexpr sal_uInt16 KEY_DIVIDE
constexpr sal_uInt16 KEY_END
constexpr sal_uInt16 KEY_MULTIPLY
IMPL_LINK_NOARG(MainSequence, onTimerHdl, Timer *, void)
const ::avmedia::MediaItem * Execute(const SdrMarkView *pSdrView, SfxRequest const &rReq)
long Long
#define SELENG_AUTOREPEAT_INTERVAL
#define SELENG_DRAGDROP_TIMEOUT
UnoViewSharedPtr mpView
SdrInventor
SVXCORE_DLLPUBLIC SdrTextObj * DynCastSdrTextObj(SdrObject *)
SdrObjKind
#define DND_ACTION_COPY
signed char sal_Int8
VclPtr< vcl::Window > mpWindow