1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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>
35 #include <DrawViewShell.hxx>
37 #include <drawdoc.hxx>
38 #include <DrawDocShell.hxx>
39 #include <zoomlist.hxx>
40 #include <slideshow.hxx>
41 #include <LayerTabBar.hxx>
43 #include <sfx2/viewfrm.hxx>
45 #include <svx/svditer.hxx>
47 #include <editeng/editeng.hxx>
49 using namespace ::com::sun::star
;
58 SdDrawDocument
* pDrDoc
,
63 mpDocSh( pDrDoc
->GetDocSh() ),
65 nSlotId( rReq
.GetSlot() ),
67 bNoScrollUntilInside (true),
70 bFirstMouseMove (false),
71 // remember MouseButton state
76 aScrollTimer
.SetInvokeHandler( LINK(this, FuPoor
, ScrollHdl
) );
77 aScrollTimer
.SetTimeout(SELENG_AUTOREPEAT_INTERVAL
);
79 aDragTimer
.SetInvokeHandler( LINK(this, FuPoor
, DragHdl
) );
80 aDragTimer
.SetTimeout(SELENG_DRAGDROP_TIMEOUT
);
82 aDelayToScrollTimer
.SetInvokeHandler( LINK(this, FuPoor
, DelayHdl
) );
83 aDelayToScrollTimer
.SetTimeout(2000);
90 aDelayToScrollTimer
.Stop();
93 void FuPoor::Activate()
97 void FuPoor::Deactivate()
101 aDelayToScrollTimer
.Stop ();
102 bScrollable
= bDelayActive
= false;
104 if (mpWindow
&& mpWindow
->IsMouseCaptured())
105 mpWindow
->ReleaseMouse();
108 void FuPoor::SetWindow(::sd::Window
* pWin
)
114 * scroll when approached the border of the window; is called by MouseMove
116 void FuPoor::ForceScroll(const Point
& aPixPos
)
120 if ( mpView
->IsDragHelpLine() || mpView
->IsSetPageOrg() ||
121 SlideShow::IsRunning( mpViewShell
->GetViewShellBase() ) )
124 Point aPos
= mpWindow
->OutputToScreenPixel(aPixPos
);
125 const ::tools::Rectangle
& rRect
= mpViewShell
->GetAllWindowRect();
127 if ( bNoScrollUntilInside
)
129 if ( rRect
.IsInside(aPos
) )
130 bNoScrollUntilInside
= false;
134 short dx
= 0, dy
= 0;
136 if ( aPos
.X() <= rRect
.Left() ) dx
= -1;
137 if ( aPos
.X() >= rRect
.Right() ) dx
= 1;
138 if ( aPos
.Y() <= rRect
.Top() ) dy
= -1;
139 if ( aPos
.Y() >= rRect
.Bottom() ) dy
= 1;
141 if ( dx
!= 0 || dy
!= 0 )
145 // scroll action in derived class
146 mpViewShell
->ScrollLines(dx
, dy
);
147 aScrollTimer
.Start();
149 else if (! bDelayActive
) StartDelayToScrollTimer ();
155 * timer handler for window scrolling
157 IMPL_LINK_NOARG(FuPoor
, ScrollHdl
, Timer
*, void)
159 Point
aPnt(mpWindow
->GetPointerPosPixel());
161 // use remembered MouseButton state to create correct
162 // MouseEvents for this artificial MouseMove.
163 MouseMove(MouseEvent(aPnt
, 1, MouseEventModifiers::NONE
, GetMouseButtonCode()));
167 * handle keyboard events
168 * @returns sal_True if the event was handled, sal_False otherwise
170 bool FuPoor::KeyInput(const KeyEvent
& rKEvt
)
172 sal_uInt16 nCode
= rKEvt
.GetKeyCode().GetCode();
173 bool bReturn
= false;
174 bool bSlideShow
= SlideShow::IsRunning( mpViewShell
->GetViewShellBase() );
180 if(rKEvt
.GetKeyCode().IsMod1())
182 if( dynamic_cast< const DrawViewShell
*>( mpViewShell
) != nullptr)
184 DrawViewShell
* pDrawViewShell
=
185 static_cast<DrawViewShell
*>(mpViewShell
);
186 SdPage
* pActualPage
= pDrawViewShell
->GetActualPage();
187 SdrTextObj
* pCandidate
= nullptr;
191 SdrObjListIter
aIter(pActualPage
, SdrIterMode::DeepNoGroups
);
193 while(aIter
.IsMore() && !pCandidate
)
195 SdrObject
* pObj
= aIter
.Next();
197 if(dynamic_cast< const SdrTextObj
*>( pObj
))
199 SdrInventor
nInv(pObj
->GetObjInventor());
200 sal_uInt16
nKnd(pObj
->GetObjIdentifier());
202 if(SdrInventor::Default
== nInv
&&
203 (OBJ_TITLETEXT
== nKnd
|| OBJ_OUTLINETEXT
== nKnd
|| OBJ_TEXT
== nKnd
))
205 pCandidate
= static_cast<SdrTextObj
*>(pObj
);
214 mpView
->MarkObj(pCandidate
, mpView
->GetSdrPageView());
216 mpViewShell
->GetViewFrame()->GetDispatcher()->Execute(
217 SID_ATTR_CHAR
, SfxCallMode::ASYNCHRON
);
221 // insert a new page with the same page layout
222 mpViewShell
->GetViewFrame()->GetDispatcher()->Execute(
223 SID_INSERTPAGE_QUICK
, SfxCallMode::ASYNCHRON
);
232 // activate OLE object on RETURN for selected object
233 // activate text edit on RETURN for selected object
234 const SdrMarkList
& rMarkList
= mpView
->GetMarkedObjectList();
236 if( !mpView
->IsTextEdit() && 1 == rMarkList
.GetMarkCount() )
238 SdrObject
* pObj
= rMarkList
.GetMark( 0 )->GetMarkedSdrObj();
240 if( dynamic_cast< const SdrOle2Obj
* >( pObj
) && !mpDocSh
->IsUIActive() )
242 //HMHmpView->HideMarkHdl();
243 mpViewShell
->ActivateObject( static_cast< SdrOle2Obj
* >( pObj
), 0 );
245 else if( pObj
&& pObj
->IsEmptyPresObj() && dynamic_cast< const SdrGrafObj
*>( pObj
) != nullptr )
247 mpViewShell
->GetViewFrame()->GetDispatcher()->Execute( SID_INSERT_GRAPHIC
, SfxCallMode::ASYNCHRON
| SfxCallMode::RECORD
);
251 mpViewShell
->GetViewFrame()->GetDispatcher()->Execute( SID_ATTR_CHAR
, SfxCallMode::ASYNCHRON
| SfxCallMode::RECORD
);
263 // handle Mod1 and Mod2 to get travelling running on different systems
264 if(rKEvt
.GetKeyCode().IsMod1() || rKEvt
.GetKeyCode().IsMod2())
266 // do something with a selected handle?
267 const SdrHdlList
& rHdlList
= mpView
->GetHdlList();
268 bool bForward(!rKEvt
.GetKeyCode().IsShift());
270 const_cast<SdrHdlList
&>(rHdlList
).TravelFocusHdl(bForward
);
272 // guarantee visibility of focused handle
273 SdrHdl
* pHdl
= rHdlList
.GetFocusHdl();
277 Point
aHdlPosition(pHdl
->GetPos());
278 ::tools::Rectangle
aVisRect(aHdlPosition
- Point(100, 100), Size(200, 200));
279 mpView
->MakeVisible(aVisRect
, *mpWindow
);
290 bReturn
= FuPoor::cancel();
296 if (!mpView
->IsTextEdit() && !bSlideShow
&& !mpDocSh
->IsUIActive())
299 mpViewShell
->SetZoom(mpWindow
->GetZoom() * 3 / 2);
301 if( dynamic_cast< const DrawViewShell
*>( mpViewShell
) != nullptr)
302 static_cast<DrawViewShell
*>(mpViewShell
)
303 ->SetZoomOnPage(false);
312 if (!mpView
->IsTextEdit() && !bSlideShow
&& !mpDocSh
->IsUIActive())
315 mpViewShell
->SetZoom(mpWindow
->GetZoom() * 2 / 3);
317 if( dynamic_cast< const DrawViewShell
*>( mpViewShell
) != nullptr)
318 static_cast<DrawViewShell
*>(mpViewShell
)
319 ->SetZoomOnPage(false);
328 if (!mpView
->IsTextEdit() && !bSlideShow
)
331 mpViewShell
->GetViewFrame()->GetDispatcher()->
332 Execute(SID_SIZE_PAGE
, SfxCallMode::ASYNCHRON
| SfxCallMode::RECORD
);
340 if (!mpView
->IsTextEdit() && !bSlideShow
)
342 // zoom to selected objects
343 mpViewShell
->GetViewFrame()->GetDispatcher()->
344 Execute(SID_SIZE_OPTIMAL
, SfxCallMode::ASYNCHRON
| SfxCallMode::RECORD
);
352 ZoomList
* pZoomList
= mpViewShell
->GetZoomList();
354 if (!mpView
->IsTextEdit() && pZoomList
->IsNextPossible() && !bSlideShow
&& !mpDocSh
->IsUIActive())
357 mpViewShell
->SetZoomRect(pZoomList
->GetNextZoomRect());
365 ZoomList
* pZoomList
= mpViewShell
->GetZoomList();
367 if (!mpView
->IsTextEdit() && pZoomList
->IsPreviousPossible() && !bSlideShow
&& !mpDocSh
->IsUIActive())
369 // use previous ZoomRect
370 mpViewShell
->SetZoomRect(pZoomList
->GetPreviousZoomRect());
378 if (!mpView
->IsTextEdit()
379 && dynamic_cast< const DrawViewShell
*>( mpViewShell
) != nullptr
382 // jump to first page
383 static_cast<DrawViewShell
*>(mpViewShell
)->SwitchPage(0);
391 if (!mpView
->IsTextEdit()
392 && dynamic_cast< const DrawViewShell
*>( mpViewShell
) != nullptr
397 static_cast<DrawViewShell
*>(mpViewShell
)->GetActualPage();
398 static_cast<DrawViewShell
*>(mpViewShell
)
399 ->SwitchPage(mpDoc
->GetSdPageCount(
400 pPage
->GetPageKind()) - 1);
408 if( rKEvt
.GetKeyCode().IsMod1() && rKEvt
.GetKeyCode().IsMod2() )
411 if( dynamic_cast< const DrawViewShell
*>( mpViewShell
) != nullptr && !bSlideShow
)
413 // The page-up key switches layers or pages depending on the
415 if ( ! rKEvt
.GetKeyCode().GetModifier())
417 // With no modifier pressed we move to the previous
419 mpView
->SdrEndTextEdit();
423 SdPage
* pPage
= static_cast<DrawViewShell
*>(mpViewShell
)->GetActualPage();
424 sal_uInt16 nSdPage
= (pPage
->GetPageNum() - 1) / 2;
428 // Switch the page and send events regarding
429 // deactivation the old page and activating the new
431 TabControl
& rPageTabControl
=
432 static_cast<DrawViewShell
*>(mpViewShell
)
433 ->GetPageTabControl();
434 if (rPageTabControl
.IsReallyShown())
435 rPageTabControl
.SendDeactivatePageEvent ();
436 static_cast<DrawViewShell
*>(mpViewShell
)->SwitchPage(nSdPage
- 1);
437 if (rPageTabControl
.IsReallyShown())
438 rPageTabControl
.SendActivatePageEvent ();
441 else if (rKEvt
.GetKeyCode().IsMod1())
443 // With the CONTROL modifier we switch layers.
444 if (static_cast<DrawViewShell
*>(mpViewShell
)->IsLayerModeActive())
446 // Moves to the previous layer.
456 if( rKEvt
.GetKeyCode().IsMod1() && rKEvt
.GetKeyCode().IsMod2() )
458 if(dynamic_cast< const DrawViewShell
*>( mpViewShell
) != nullptr && !bSlideShow
)
460 // The page-down key switches layers or pages depending on the
462 if ( ! rKEvt
.GetKeyCode().GetModifier())
464 // With no modifier pressed we move to the next slide.
465 mpView
->SdrEndTextEdit();
469 SdPage
* pPage
= static_cast<DrawViewShell
*>(mpViewShell
)->GetActualPage();
470 sal_uInt16 nSdPage
= (pPage
->GetPageNum() - 1) / 2;
472 if (nSdPage
< mpDoc
->GetSdPageCount(pPage
->GetPageKind()) - 1)
474 // Switch the page and send events regarding
475 // deactivation the old page and activating the new
477 TabControl
& rPageTabControl
=
478 static_cast<DrawViewShell
*>(mpViewShell
)->GetPageTabControl();
479 if (rPageTabControl
.IsReallyShown())
480 rPageTabControl
.SendDeactivatePageEvent ();
481 static_cast<DrawViewShell
*>(mpViewShell
)->SwitchPage(nSdPage
+ 1);
482 if (rPageTabControl
.IsReallyShown())
483 rPageTabControl
.SendActivatePageEvent ();
486 else if (rKEvt
.GetKeyCode().IsMod1())
488 // With the CONTROL modifier we switch layers.
489 if (static_cast<DrawViewShell
*>(mpViewShell
)->IsLayerModeActive())
491 // With the layer mode active pressing page-down
492 // moves to the next layer.
500 // change select state when focus is on poly point
503 const SdrHdlList
& rHdlList
= mpView
->GetHdlList();
504 SdrHdl
* pHdl
= rHdlList
.GetFocusHdl();
508 if(pHdl
->GetKind() == SdrHdlKind::Poly
)
510 // rescue ID of point with focus
511 sal_uInt32
nPol(pHdl
->GetPolyNum());
512 sal_uInt32
nPnt(pHdl
->GetPointNum());
514 if(mpView
->IsPointMarked(*pHdl
))
516 if(rKEvt
.GetKeyCode().IsShift())
518 mpView
->UnmarkPoint(*pHdl
);
523 if(!rKEvt
.GetKeyCode().IsShift())
525 mpView
->UnmarkAllPoints();
528 mpView
->MarkPoint(*pHdl
);
531 if(nullptr == rHdlList
.GetFocusHdl())
533 // restore point with focus
534 SdrHdl
* pNewOne
= nullptr;
536 for(size_t a
= 0; !pNewOne
&& a
< rHdlList
.GetHdlCount(); ++a
)
538 SdrHdl
* pAct
= rHdlList
.GetHdl(a
);
541 && pAct
->GetKind() == SdrHdlKind::Poly
542 && pAct
->GetPolyNum() == nPol
543 && pAct
->GetPointNum() == nPnt
)
551 const_cast<SdrHdlList
&>(rHdlList
).SetFocusHdl(pNewOne
);
566 if (!mpView
->IsTextEdit() && !bSlideShow
)
577 else if (nCode
== KEY_DOWN
)
583 else if (nCode
== KEY_LEFT
)
589 else if (nCode
== KEY_RIGHT
)
596 if (mpView
->AreObjectsMarked() && !rKEvt
.GetKeyCode().IsMod1() &&
597 !mpDocSh
->IsReadOnly())
599 const SdrHdlList
& rHdlList
= mpView
->GetHdlList();
600 SdrHdl
* pHdl
= rHdlList
.GetFocusHdl();
602 bool bIsMoveOfConnectedHandle(false);
603 bool bOldSuppress
= false;
604 SdrEdgeObj
* pEdgeObj
= nullptr;
606 if(pHdl
&& dynamic_cast< const SdrEdgeObj
*>( pHdl
->GetObj() ) && 0 == pHdl
->GetPolyNum())
608 pEdgeObj
= static_cast<SdrEdgeObj
*>(pHdl
->GetObj());
610 if(0 == pHdl
->GetPointNum())
612 if(pEdgeObj
->GetConnection(true).GetObject())
614 bIsMoveOfConnectedHandle
= true;
617 if(1 == pHdl
->GetPointNum())
619 if(pEdgeObj
->GetConnection(false).GetObject())
621 bIsMoveOfConnectedHandle
= true;
628 // Suppress default connects to inside object and object center
629 bOldSuppress
= pEdgeObj
->GetSuppressDefaultConnect();
630 pEdgeObj
->SetSuppressDefaultConnect(true);
633 if(bIsMoveOfConnectedHandle
)
635 sal_uInt16
nMarkHdSiz(mpView
->GetMarkHdlSizePixel());
636 Size
aHalfConSiz(nMarkHdSiz
+ 1, nMarkHdSiz
+ 1);
637 aHalfConSiz
= mpWindow
->PixelToLogic(aHalfConSiz
);
639 if(100 < aHalfConSiz
.Width())
640 nX
*= aHalfConSiz
.Width();
644 if(100 < aHalfConSiz
.Height())
645 nY
*= aHalfConSiz
.Height();
649 else if(rKEvt
.GetKeyCode().IsMod2())
651 // move in 1 pixel distance
652 Size aLogicSizeOnePixel
= mpWindow
->PixelToLogic(Size(1,1));
653 nX
*= aLogicSizeOnePixel
.Width();
654 nY
*= aLogicSizeOnePixel
.Height();
656 else if(rKEvt
.GetKeyCode().IsShift())
663 // old, fixed move distance
670 // only take action when move is allowed
671 if(mpView
->IsMoveAllowed())
673 // restrict movement to WorkArea
674 const ::tools::Rectangle
& rWorkArea
= mpView
->GetWorkArea();
676 if(!rWorkArea
.IsEmpty())
678 ::tools::Rectangle
aMarkRect(mpView
->GetMarkedObjRect());
679 aMarkRect
.Move(nX
, nY
);
681 if(!aMarkRect
.IsInside(rWorkArea
))
683 if(aMarkRect
.Left() < rWorkArea
.Left())
685 nX
+= rWorkArea
.Left() - aMarkRect
.Left();
688 if(aMarkRect
.Right() > rWorkArea
.Right())
690 nX
-= aMarkRect
.Right() - rWorkArea
.Right();
693 if(aMarkRect
.Top() < rWorkArea
.Top())
695 nY
+= rWorkArea
.Top() - aMarkRect
.Top();
698 if(aMarkRect
.Bottom() > rWorkArea
.Bottom())
700 nY
-= aMarkRect
.Bottom() - rWorkArea
.Bottom();
705 // no handle selected
706 if(0 != nX
|| 0 != nY
)
708 mpView
->MoveAllMarked(Size(nX
, nY
));
710 mpView
->MakeVisible(mpView
->GetAllMarkedRect(), *mpWindow
);
716 // move handle with index nHandleIndex
719 // now move the Handle (nX, nY)
720 Point
aStartPoint(pHdl
->GetPos());
721 Point
aEndPoint(pHdl
->GetPos() + Point(nX
, nY
));
722 const SdrDragStat
& rDragStat
= mpView
->GetDragStat();
725 mpView
->BegDragObj(aStartPoint
, nullptr, pHdl
, 0);
727 if(mpView
->IsDragObj())
729 bool bWasNoSnap
= rDragStat
.IsNoSnap();
730 bool bWasSnapEnabled
= mpView
->IsSnapEnabled();
732 // switch snapping off
734 const_cast<SdrDragStat
&>(rDragStat
).SetNoSnap();
736 mpView
->SetSnapEnabled(false);
738 mpView
->MovAction(aEndPoint
);
739 mpView
->EndDragObj();
743 const_cast<SdrDragStat
&>(rDragStat
).SetNoSnap(bWasNoSnap
);
745 mpView
->SetSnapEnabled(bWasSnapEnabled
);
748 // make moved handle visible
749 ::tools::Rectangle
aVisRect(aEndPoint
- Point(100, 100), Size(200, 200));
750 mpView
->MakeVisible(aVisRect
, *mpWindow
);
756 // Restore original suppress value
757 pEdgeObj
->SetSuppressDefaultConnect(bOldSuppress
);
763 mpViewShell
->ScrollLines(nX
, nY
);
774 mpWindow
->ReleaseMouse();
777 // when a text-editable object is selected and the
778 // input character is printable, activate text edit on that object
779 // and feed character to object
780 if(!bReturn
&& !mpDocSh
->IsReadOnly())
782 if (!mpView
->IsTextEdit())
784 const SdrMarkList
& rMarkList
= mpView
->GetMarkedObjectList();
786 if(1 == rMarkList
.GetMarkCount())
788 SdrObject
* pObj
= rMarkList
.GetMark(0)->GetMarkedSdrObj();
790 // #i118485# allow TextInput for OLEs, too
791 if( dynamic_cast< const SdrTextObj
*>( pObj
) != nullptr && pObj
->HasTextEdit())
793 // use common IsSimpleCharInput from the EditEngine.
794 bool bPrintable(EditEngine::IsSimpleCharInput(rKEvt
));
798 // try to activate textedit mode for the selected object
799 SfxStringItem
aInputString(SID_ATTR_CHAR
, OUString(rKEvt
.GetCharCode()));
801 mpViewShell
->GetViewFrame()->GetDispatcher()->ExecuteList(
803 SfxCallMode::ASYNCHRON
,
813 // test if there is a title object there. If yes, try to
814 // set it to edit mode and start typing...
815 DrawViewShell
* pDrawViewShell
= dynamic_cast<DrawViewShell
*>(mpViewShell
);
816 if (pDrawViewShell
&& EditEngine::IsSimpleCharInput(rKEvt
))
818 SdPage
* pActualPage
= pDrawViewShell
->GetActualPage();
819 SdrTextObj
* pCandidate
= nullptr;
823 SdrObjListIter
aIter(pActualPage
, SdrIterMode::DeepNoGroups
);
825 while(aIter
.IsMore() && !pCandidate
)
827 SdrObject
* pObj
= aIter
.Next();
829 if(dynamic_cast< const SdrTextObj
*>( pObj
))
831 SdrInventor
nInv(pObj
->GetObjInventor());
832 sal_uInt16
nKnd(pObj
->GetObjIdentifier());
834 if(SdrInventor::Default
== nInv
&& OBJ_TITLETEXT
== nKnd
)
836 pCandidate
= static_cast<SdrTextObj
*>(pObj
);
842 // when candidate found and candidate is untouched, start editing text...
843 if(pCandidate
&& pCandidate
->IsEmptyPresObj())
846 mpView
->MarkObj(pCandidate
, mpView
->GetSdrPageView());
847 SfxStringItem
aInputString(SID_ATTR_CHAR
, OUString(rKEvt
.GetCharCode()));
849 mpViewShell
->GetViewFrame()->GetDispatcher()->ExecuteList(
851 SfxCallMode::ASYNCHRON
,
865 bool FuPoor::MouseMove(const MouseEvent
& )
870 void FuPoor::SelectionHasChanged()
872 const SdrHdlList
& rHdlList
= mpView
->GetHdlList();
873 const_cast<SdrHdlList
&>(rHdlList
).ResetFocusHdl();
877 * Cut object to clipboard
888 * Copy object to clipboard
890 void FuPoor::DoCopy()
899 * Paste object from clipboard
901 void FuPoor::DoPaste()
905 mpView
->DoPaste(mpWindow
);
910 * Paste unformatted text from clipboard
912 void FuPoor::DoPasteUnformatted()
916 sal_Int8 nAction
= DND_ACTION_COPY
;
917 TransferableDataHelper
aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( mpViewShell
->GetActiveWindow() ) );
918 if (aDataHelper
.GetTransferable().is())
920 mpView
->InsertData( aDataHelper
,
921 mpWindow
->PixelToLogic( ::tools::Rectangle( Point(), mpWindow
->GetOutputSizePixel() ).Center() ),
922 nAction
, false, SotClipboardFormatId::STRING
);
928 * Timer handler for Drag&Drop
930 IMPL_LINK_NOARG(FuPoor
, DragHdl
, Timer
*, void)
935 sal_uInt16 nHitLog
= sal_uInt16 ( mpWindow
->PixelToLogic(Size(HITPIX
,0)).Width() );
936 SdrHdl
* pHdl
= mpView
->PickHandle(aMDPos
);
938 if ( pHdl
==nullptr && mpView
->IsMarkedHit(aMDPos
, nHitLog
)
939 && !mpView
->IsPresObjSelected(false) )
941 mpWindow
->ReleaseMouse();
942 bIsInDragMode
= true;
943 mpView
->StartDrag( aMDPos
, mpWindow
);
947 bool FuPoor::Command(const CommandEvent
& rCEvt
)
949 return mpView
->Command(rCEvt
,mpWindow
);
953 * Timer handler for window scrolling
955 IMPL_LINK_NOARG(FuPoor
, DelayHdl
, Timer
*, void)
957 aDelayToScrollTimer
.Stop ();
960 Point
aPnt(mpWindow
->GetPointerPosPixel());
962 // use remembered MouseButton state to create correct
963 // MouseEvents for this artificial MouseMove.
964 MouseMove(MouseEvent(aPnt
, 1, MouseEventModifiers::NONE
, GetMouseButtonCode()));
967 bool FuPoor::MouseButtonUp (const MouseEvent
& rMEvt
)
969 // remember button state for creation of own MouseEvents
970 SetMouseButtonCode(rMEvt
.GetButtons());
972 aDelayToScrollTimer
.Stop ();
974 bDelayActive
= false;
977 bool FuPoor::MouseButtonDown(const MouseEvent
& rMEvt
)
979 // remember button state for creation of own MouseEvents
980 SetMouseButtonCode(rMEvt
.GetButtons());
985 void FuPoor::StartDelayToScrollTimer ()
988 aDelayToScrollTimer
.Start ();
991 bool FuPoor::RequestHelp(const HelpEvent
& rHEvt
)
993 bool bReturn
= false;
995 SdrPageView
* pPV
= mpView
->GetSdrPageView();
999 SdPage
* pPage
= static_cast<SdPage
*>( pPV
->GetPage() );
1003 bReturn
= FmFormPage::RequestHelp(mpWindow
, mpView
, rHEvt
);
1010 void FuPoor::ReceiveRequest(SfxRequest
& /*rReq*/)
1014 SdrObjectUniquePtr
FuPoor::CreateDefaultObject(const sal_uInt16
, const ::tools::Rectangle
& )
1016 // empty base implementation
1020 void FuPoor::ImpForceQuadratic(::tools::Rectangle
& rRect
)
1022 if(rRect
.GetWidth() > rRect
.GetHeight())
1024 rRect
= ::tools::Rectangle(
1025 Point(rRect
.Left() + ((rRect
.GetWidth() - rRect
.GetHeight()) / 2), rRect
.Top()),
1026 Size(rRect
.GetHeight(), rRect
.GetHeight()));
1030 rRect
= ::tools::Rectangle(
1031 Point(rRect
.Left(), rRect
.Top() + ((rRect
.GetHeight() - rRect
.GetWidth()) / 2)),
1032 Size(rRect
.GetWidth(), rRect
.GetWidth()));
1036 void FuPoor::SwitchLayer (sal_Int32 nOffset
)
1038 auto pDrawViewShell
= dynamic_cast<DrawViewShell
*>( mpViewShell
);
1042 // Calculate the new index.
1043 sal_Int32 nIndex
= pDrawViewShell
->GetActiveTabLayerIndex() + nOffset
;
1045 // Make sure the new index lies inside the range of valid indices.
1048 else if (nIndex
>= pDrawViewShell
->GetTabLayerCount ())
1049 nIndex
= pDrawViewShell
->GetTabLayerCount() - 1;
1051 // Set the new active layer.
1052 if (nIndex
!= pDrawViewShell
->GetActiveTabLayerIndex ())
1054 LayerTabBar
* pLayerTabControl
=
1055 static_cast<DrawViewShell
*>(mpViewShell
)->GetLayerTabControl();
1056 if (pLayerTabControl
!= nullptr)
1057 pLayerTabControl
->SendDeactivatePageEvent ();
1059 pDrawViewShell
->SetActiveTabLayerIndex (nIndex
);
1061 if (pLayerTabControl
!= nullptr)
1062 pLayerTabControl
->SendActivatePageEvent ();
1066 /** is called when the current function should be aborted. <p>
1067 This is used when a function gets a KEY_ESCAPE but can also
1070 @returns true if a active function was aborted
1072 bool FuPoor::cancel()
1074 if ( dynamic_cast< const FuSelection
*>( this ) == nullptr )
1076 mpViewShell
->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT
, SfxCallMode::ASYNCHRON
);
1084 bool FuPoor::doConstructOrthogonal() const
1086 // Check whether a media object is selected
1087 bool bResizeKeepRatio
= false;
1088 // tdf#89758 Avoid interactive crop preview from being proportionally scaled by default.
1089 if (mpView
->AreObjectsMarked() && mpView
->GetDragMode() != SdrDragMode::Crop
)
1091 const SdrMarkList
& rMarkList
= mpView
->GetMarkedObjectList();
1092 if (rMarkList
.GetMarkCount() == 1)
1094 sal_uInt16 aObjIdentifier
= rMarkList
.GetMark(0)->GetMarkedSdrObj()->GetObjIdentifier();
1095 bResizeKeepRatio
= aObjIdentifier
== OBJ_GRAF
||
1096 aObjIdentifier
== OBJ_MEDIA
||
1097 aObjIdentifier
== OBJ_OLE2
;
1100 SdrHdl
* pHdl
= mpView
->PickHandle(aMDPos
);
1101 // Resize proportionally when media is selected and the user drags on a corner
1103 bResizeKeepRatio
= bResizeKeepRatio
&& pHdl
->IsCornerHdl();
1107 SID_DRAW_XLINE
== nSlotId
||
1108 SID_DRAW_CIRCLEARC
== nSlotId
||
1109 SID_DRAW_SQUARE
== nSlotId
||
1110 SID_DRAW_SQUARE_NOFILL
== nSlotId
||
1111 SID_DRAW_SQUARE_ROUND
== nSlotId
||
1112 SID_DRAW_SQUARE_ROUND_NOFILL
== nSlotId
||
1113 SID_DRAW_CIRCLE
== nSlotId
||
1114 SID_DRAW_CIRCLE_NOFILL
== nSlotId
||
1115 SID_DRAW_CIRCLEPIE
== nSlotId
||
1116 SID_DRAW_CIRCLEPIE_NOFILL
== nSlotId
||
1117 SID_DRAW_CIRCLECUT
== nSlotId
||
1118 SID_DRAW_CIRCLECUT_NOFILL
== nSlotId
||
1119 SID_DRAW_XPOLYGON
== nSlotId
||
1120 SID_DRAW_XPOLYGON_NOFILL
== nSlotId
||
1121 SID_3D_CUBE
== nSlotId
||
1122 SID_3D_SPHERE
== nSlotId
||
1123 SID_3D_SHELL
== nSlotId
||
1124 SID_3D_HALF_SPHERE
== nSlotId
||
1125 SID_3D_TORUS
== nSlotId
||
1126 SID_3D_CYLINDER
== nSlotId
||
1127 SID_3D_CONE
== nSlotId
||
1128 SID_3D_PYRAMID
== nSlotId
);
1131 void FuPoor::DoExecute( SfxRequest
& )
1135 } // end of namespace sd
1137 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */