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 <com/sun/star/embed/EmbedVerbs.hpp>
45 #include <sfx2/viewfrm.hxx>
47 #include <svx/svditer.hxx>
49 #include <editeng/editeng.hxx>
51 using namespace ::com::sun::star
;
60 SdDrawDocument
* pDrDoc
,
65 mpDocSh( pDrDoc
->GetDocSh() ),
67 nSlotId( rReq
.GetSlot() ),
68 aScrollTimer("sd FuPoor aScrollTimer"),
69 aDragTimer("sd FuPoor aDragTimer"),
71 bNoScrollUntilInside (true),
72 aDelayToScrollTimer("sd FuPoor aDelayToScrollTimer"),
75 bFirstMouseMove (false),
76 // remember MouseButton state
81 aScrollTimer
.SetInvokeHandler( LINK(this, FuPoor
, ScrollHdl
) );
82 aScrollTimer
.SetTimeout(SELENG_AUTOREPEAT_INTERVAL
);
84 aDragTimer
.SetInvokeHandler( LINK(this, FuPoor
, DragHdl
) );
85 aDragTimer
.SetTimeout(SELENG_DRAGDROP_TIMEOUT
);
87 aDelayToScrollTimer
.SetInvokeHandler( LINK(this, FuPoor
, DelayHdl
) );
88 aDelayToScrollTimer
.SetTimeout(2000);
95 aDelayToScrollTimer
.Stop();
98 void FuPoor::Activate()
102 void FuPoor::Deactivate()
106 aDelayToScrollTimer
.Stop ();
107 bScrollable
= bDelayActive
= false;
109 if (mpWindow
&& mpWindow
->IsMouseCaptured())
110 mpWindow
->ReleaseMouse();
113 void FuPoor::SetWindow(::sd::Window
* pWin
)
119 * scroll when approached the border of the window; is called by MouseMove
121 void FuPoor::ForceScroll(const Point
& aPixPos
)
125 if ( mpView
->IsDragHelpLine() || mpView
->IsSetPageOrg() ||
126 (SlideShow::IsRunning( mpViewShell
->GetViewShellBase() )
127 && !SlideShow::IsInteractiveSlideshow( &mpViewShell
->GetViewShellBase() )) ) // IASS
130 Point aPos
= mpWindow
->OutputToScreenPixel(aPixPos
);
131 const ::tools::Rectangle
& rRect
= mpViewShell
->GetAllWindowRect();
133 if ( bNoScrollUntilInside
)
135 if ( rRect
.Contains(aPos
) )
136 bNoScrollUntilInside
= false;
140 short dx
= 0, dy
= 0;
142 if ( aPos
.X() <= rRect
.Left() ) dx
= -1;
143 if ( aPos
.X() >= rRect
.Right() ) dx
= 1;
144 if ( aPos
.Y() <= rRect
.Top() ) dy
= -1;
145 if ( aPos
.Y() >= rRect
.Bottom() ) dy
= 1;
147 if ( dx
!= 0 || dy
!= 0 )
151 // scroll action in derived class
152 mpViewShell
->ScrollLines(dx
, dy
);
153 aScrollTimer
.Start();
155 else if (! bDelayActive
) StartDelayToScrollTimer ();
161 * timer handler for window scrolling
163 IMPL_LINK_NOARG(FuPoor
, ScrollHdl
, Timer
*, void)
165 Point
aPnt(mpWindow
->GetPointerPosPixel());
167 // use remembered MouseButton state to create correct
168 // MouseEvents for this artificial MouseMove.
169 MouseMove(MouseEvent(aPnt
, 1, MouseEventModifiers::NONE
, GetMouseButtonCode()));
173 * handle keyboard events
174 * @returns sal_True if the event was handled, sal_False otherwise
176 bool FuPoor::KeyInput(const KeyEvent
& rKEvt
)
178 sal_uInt16 nCode
= rKEvt
.GetKeyCode().GetCode();
179 bool bReturn
= false;
180 bool bSlideShow
= SlideShow::IsRunning( mpViewShell
->GetViewShellBase() )
181 && !SlideShow::IsInteractiveSlideshow( &mpViewShell
->GetViewShellBase() ); // IASS
187 if(rKEvt
.GetKeyCode().IsMod1())
189 if( auto pDrawViewShell
= dynamic_cast<DrawViewShell
*>( mpViewShell
))
191 SdPage
* pActualPage
= pDrawViewShell
->GetActualPage();
192 SdrTextObj
* pCandidate
= nullptr;
196 SdrObjListIter
aIter(pActualPage
, SdrIterMode::DeepNoGroups
);
198 while(aIter
.IsMore() && !pCandidate
)
200 SdrObject
* pObj
= aIter
.Next();
202 if(auto pTextObj
= DynCastSdrTextObj( pObj
))
204 SdrInventor
nInv(pObj
->GetObjInventor());
205 SdrObjKind
nKnd(pObj
->GetObjIdentifier());
207 if(SdrInventor::Default
== nInv
&&
208 (SdrObjKind::TitleText
== nKnd
|| SdrObjKind::OutlineText
== nKnd
|| SdrObjKind::Text
== nKnd
))
210 pCandidate
= pTextObj
;
219 mpView
->MarkObj(pCandidate
, mpView
->GetSdrPageView());
221 mpViewShell
->GetViewFrame()->GetDispatcher()->Execute(
222 SID_ATTR_CHAR
, SfxCallMode::ASYNCHRON
);
226 // insert a new page with the same page layout
227 mpViewShell
->GetViewFrame()->GetDispatcher()->Execute(
228 SID_INSERTPAGE_QUICK
, SfxCallMode::ASYNCHRON
);
235 else if (!mpDocSh
->IsReadOnly())
237 // activate OLE object on RETURN for selected object
238 // activate text edit on RETURN for selected object
239 const SdrMarkList
& rMarkList
= mpView
->GetMarkedObjectList();
241 if( !mpView
->IsTextEdit() && 1 == rMarkList
.GetMarkCount() )
243 SdrObject
* pObj
= rMarkList
.GetMark( 0 )->GetMarkedSdrObj();
245 if( dynamic_cast< const SdrOle2Obj
* >( pObj
) && !mpDocSh
->IsUIActive() )
247 //HMHmpView->HideMarkHdl();
248 mpViewShell
->ActivateObject(static_cast<SdrOle2Obj
*>(pObj
), css::embed::EmbedVerbs::MS_OLEVERB_PRIMARY
);
250 else if( pObj
&& pObj
->IsEmptyPresObj() && dynamic_cast< const SdrGrafObj
*>( pObj
) != nullptr )
252 mpViewShell
->GetViewFrame()->GetDispatcher()->Execute( SID_INSERT_GRAPHIC
, SfxCallMode::ASYNCHRON
| SfxCallMode::RECORD
);
256 mpViewShell
->GetViewFrame()->GetDispatcher()->Execute( SID_ATTR_CHAR
, SfxCallMode::ASYNCHRON
| SfxCallMode::RECORD
);
268 // handle Mod1 and Mod2 to get travelling running on different systems
269 if(rKEvt
.GetKeyCode().IsMod1() || rKEvt
.GetKeyCode().IsMod2())
271 // do something with a selected handle?
272 const SdrHdlList
& rHdlList
= mpView
->GetHdlList();
273 bool bForward(!rKEvt
.GetKeyCode().IsShift());
275 const_cast<SdrHdlList
&>(rHdlList
).TravelFocusHdl(bForward
);
277 // guarantee visibility of focused handle
278 SdrHdl
* pHdl
= rHdlList
.GetFocusHdl();
282 Point
aHdlPosition(pHdl
->GetPos());
283 ::tools::Rectangle
aVisRect(aHdlPosition
- Point(100, 100), Size(200, 200));
284 mpView
->MakeVisible(aVisRect
, *mpWindow
);
295 bReturn
= FuPoor::cancel();
301 if (!mpView
->IsTextEdit() && !bSlideShow
&& !mpDocSh
->IsUIActive())
304 mpViewShell
->SetZoom(mpWindow
->GetZoom() * 3 / 2);
306 if( auto pViewShell
= dynamic_cast<DrawViewShell
*>( mpViewShell
))
307 pViewShell
->SetZoomOnPage(false);
316 if (!mpView
->IsTextEdit() && !bSlideShow
&& !mpDocSh
->IsUIActive())
319 mpViewShell
->SetZoom(mpWindow
->GetZoom() * 2 / 3);
321 if( auto pViewShell
= dynamic_cast<DrawViewShell
*>( mpViewShell
))
322 pViewShell
->SetZoomOnPage(false);
331 if (!mpView
->IsTextEdit() && !bSlideShow
)
334 mpViewShell
->GetViewFrame()->GetDispatcher()->
335 Execute(SID_SIZE_PAGE
, SfxCallMode::ASYNCHRON
| SfxCallMode::RECORD
);
343 if (!mpView
->IsTextEdit() && !bSlideShow
)
345 // zoom to selected objects
346 mpViewShell
->GetViewFrame()->GetDispatcher()->
347 Execute(SID_SIZE_OPTIMAL
, SfxCallMode::ASYNCHRON
| SfxCallMode::RECORD
);
355 ZoomList
* pZoomList
= mpViewShell
->GetZoomList();
357 if (!mpView
->IsTextEdit() && pZoomList
->IsNextPossible() && !bSlideShow
&& !mpDocSh
->IsUIActive())
360 mpViewShell
->SetZoomRect(pZoomList
->GetNextZoomRect());
368 ZoomList
* pZoomList
= mpViewShell
->GetZoomList();
370 if (!mpView
->IsTextEdit() && pZoomList
->IsPreviousPossible() && !bSlideShow
&& !mpDocSh
->IsUIActive())
372 // use previous ZoomRect
373 mpViewShell
->SetZoomRect(pZoomList
->GetPreviousZoomRect());
381 if (!mpView
->IsTextEdit() && !bSlideShow
)
382 if (auto pDrawViewShell
= dynamic_cast<DrawViewShell
*>( mpViewShell
))
384 // jump to first page
385 pDrawViewShell
->SwitchPage(0);
393 if (!mpView
->IsTextEdit() && !bSlideShow
)
394 if (auto pDrawViewShell
= dynamic_cast<DrawViewShell
*>( mpViewShell
))
397 SdPage
* pPage
= pDrawViewShell
->GetActualPage();
398 pDrawViewShell
->SwitchPage(mpDoc
->GetSdPageCount(
399 pPage
->GetPageKind()) - 1);
407 if( rKEvt
.GetKeyCode().IsMod1() && rKEvt
.GetKeyCode().IsMod2() )
412 if( auto pDrawViewShell
= dynamic_cast<DrawViewShell
*>( mpViewShell
) )
414 // The page-up key switches layers or pages depending on the
416 if ( ! rKEvt
.GetKeyCode().GetModifier())
418 // With no modifier pressed we move to the previous
420 mpView
->SdrEndTextEdit();
424 SdPage
* pPage
= pDrawViewShell
->GetActualPage();
425 sal_uInt16 nSdPage
= (pPage
->GetPageNum() - 1) / 2;
429 // Switch the page and send events regarding
430 // deactivation the old page and activating the new
432 TabControl
& rPageTabControl
=
433 pDrawViewShell
->GetPageTabControl();
434 if (rPageTabControl
.IsReallyShown())
435 rPageTabControl
.SendDeactivatePageEvent ();
436 pDrawViewShell
->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 (pDrawViewShell
->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
)
568 ::tools::Long nX
= 0;
569 ::tools::Long nY
= 0;
577 else if (nCode
== KEY_DOWN
)
583 else if (nCode
== KEY_LEFT
)
589 else if (nCode
== KEY_RIGHT
)
596 const SdrMarkList
& rMarkList
= mpView
->GetMarkedObjectList();
597 if (rMarkList
.GetMarkCount() != 0 && !rKEvt
.GetKeyCode().IsMod1() &&
598 !mpDocSh
->IsReadOnly())
600 const SdrHdlList
& rHdlList
= mpView
->GetHdlList();
601 SdrHdl
* pHdl
= rHdlList
.GetFocusHdl();
603 bool bIsMoveOfConnectedHandle(false);
604 bool bOldSuppress
= false;
605 SdrEdgeObj
* pEdgeObj
= nullptr;
607 pEdgeObj
= dynamic_cast<SdrEdgeObj
*>( pHdl
->GetObj() );
609 if(pEdgeObj
&& 0 == pHdl
->GetPolyNum())
611 if(0 == pHdl
->GetPointNum())
613 if(pEdgeObj
->GetConnection(true).GetSdrObject())
615 bIsMoveOfConnectedHandle
= true;
618 if(1 == pHdl
->GetPointNum())
620 if(pEdgeObj
->GetConnection(false).GetSdrObject())
622 bIsMoveOfConnectedHandle
= true;
629 // Suppress default connects to inside object and object center
630 bOldSuppress
= pEdgeObj
->GetSuppressDefaultConnect();
631 pEdgeObj
->SetSuppressDefaultConnect(true);
634 if(bIsMoveOfConnectedHandle
)
636 sal_uInt16
nMarkHdSiz(mpView
->GetMarkHdlSizePixel());
637 Size
aHalfConSiz(nMarkHdSiz
+ 1, nMarkHdSiz
+ 1);
638 aHalfConSiz
= mpWindow
->PixelToLogic(aHalfConSiz
);
640 if(100 < aHalfConSiz
.Width())
641 nX
*= aHalfConSiz
.Width();
645 if(100 < aHalfConSiz
.Height())
646 nY
*= aHalfConSiz
.Height();
650 else if(rKEvt
.GetKeyCode().IsMod2())
652 // move in 1 pixel distance
653 Size aLogicSizeOnePixel
= mpWindow
->PixelToLogic(Size(1,1));
654 nX
*= aLogicSizeOnePixel
.Width();
655 nY
*= aLogicSizeOnePixel
.Height();
657 else if(rKEvt
.GetKeyCode().IsShift())
664 // old, fixed move distance
671 // only take action when move is allowed
672 if(mpView
->IsMoveAllowed())
674 // restrict movement to WorkArea
675 const ::tools::Rectangle
& rWorkArea
= mpView
->GetWorkArea();
677 if(!rWorkArea
.IsEmpty())
679 ::tools::Rectangle
aMarkRect(mpView
->GetMarkedObjRect());
680 aMarkRect
.Move(nX
, nY
);
682 if(!aMarkRect
.Contains(rWorkArea
))
684 if(aMarkRect
.Left() < rWorkArea
.Left())
686 nX
+= rWorkArea
.Left() - aMarkRect
.Left();
689 if(aMarkRect
.Right() > rWorkArea
.Right())
691 nX
-= aMarkRect
.Right() - rWorkArea
.Right();
694 if(aMarkRect
.Top() < rWorkArea
.Top())
696 nY
+= rWorkArea
.Top() - aMarkRect
.Top();
699 if(aMarkRect
.Bottom() > rWorkArea
.Bottom())
701 nY
-= aMarkRect
.Bottom() - rWorkArea
.Bottom();
706 // no handle selected
707 if(0 != nX
|| 0 != nY
)
709 mpView
->MoveAllMarked(Size(nX
, nY
));
711 mpView
->MakeVisible(mpView
->GetAllMarkedRect(), *mpWindow
);
717 // move handle with index nHandleIndex
720 // now move the Handle (nX, nY)
721 Point
aStartPoint(pHdl
->GetPos());
722 Point
aEndPoint(pHdl
->GetPos() + Point(nX
, nY
));
723 const SdrDragStat
& rDragStat
= mpView
->GetDragStat();
726 mpView
->BegDragObj(aStartPoint
, nullptr, pHdl
, 0);
728 if(mpView
->IsDragObj())
730 bool bWasNoSnap
= rDragStat
.IsNoSnap();
731 bool bWasSnapEnabled
= mpView
->IsSnapEnabled();
733 // switch snapping off
735 const_cast<SdrDragStat
&>(rDragStat
).SetNoSnap();
737 mpView
->SetSnapEnabled(false);
739 mpView
->MovAction(aEndPoint
);
740 mpView
->EndDragObj();
744 const_cast<SdrDragStat
&>(rDragStat
).SetNoSnap(bWasNoSnap
);
746 mpView
->SetSnapEnabled(bWasSnapEnabled
);
749 // make moved handle visible
750 ::tools::Rectangle
aVisRect(aEndPoint
- Point(100, 100), Size(200, 200));
751 mpView
->MakeVisible(aVisRect
, *mpWindow
);
757 // Restore original suppress value
758 pEdgeObj
->SetSuppressDefaultConnect(bOldSuppress
);
764 mpViewShell
->ScrollLines(nX
, nY
);
775 mpWindow
->ReleaseMouse();
778 // when a text-editable object is selected and the
779 // input character is printable, activate text edit on that object
780 // and feed character to object
781 if(!bReturn
&& !mpDocSh
->IsReadOnly())
783 if (!mpView
->IsTextEdit())
785 const SdrMarkList
& rMarkList
= mpView
->GetMarkedObjectList();
787 if(1 == rMarkList
.GetMarkCount())
789 SdrObject
* pObj
= rMarkList
.GetMark(0)->GetMarkedSdrObj();
791 // #i118485# allow TextInput for OLEs, too
792 if( DynCastSdrTextObj( pObj
) != nullptr && pObj
->HasTextEdit())
794 // use common IsSimpleCharInput from the EditEngine.
795 bool bPrintable(EditEngine::IsSimpleCharInput(rKEvt
));
799 // try to activate textedit mode for the selected object
800 SfxStringItem
aInputString(SID_ATTR_CHAR
, OUString(rKEvt
.GetCharCode()));
802 mpViewShell
->GetViewFrame()->GetDispatcher()->ExecuteList(
804 SfxCallMode::ASYNCHRON
,
814 // test if there is a title object there. If yes, try to
815 // set it to edit mode and start typing...
816 DrawViewShell
* pDrawViewShell
= dynamic_cast<DrawViewShell
*>(mpViewShell
);
817 if (pDrawViewShell
&& EditEngine::IsSimpleCharInput(rKEvt
))
819 SdPage
* pActualPage
= pDrawViewShell
->GetActualPage();
820 SdrTextObj
* pCandidate
= nullptr;
824 SdrObjListIter
aIter(pActualPage
, SdrIterMode::DeepNoGroups
);
826 while(aIter
.IsMore() && !pCandidate
)
828 SdrObject
* pObj
= aIter
.Next();
830 if(auto pTextObj
= DynCastSdrTextObj( pObj
))
832 SdrInventor
nInv(pObj
->GetObjInventor());
833 SdrObjKind
nKnd(pObj
->GetObjIdentifier());
835 if(SdrInventor::Default
== nInv
&& SdrObjKind::TitleText
== nKnd
)
837 pCandidate
= pTextObj
;
843 // when candidate found and candidate is untouched, start editing text...
844 if(pCandidate
&& pCandidate
->IsEmptyPresObj())
847 mpView
->MarkObj(pCandidate
, mpView
->GetSdrPageView());
848 SfxStringItem
aInputString(SID_ATTR_CHAR
, OUString(rKEvt
.GetCharCode()));
850 mpViewShell
->GetViewFrame()->GetDispatcher()->ExecuteList(
852 SfxCallMode::ASYNCHRON
,
866 bool FuPoor::MouseMove(const MouseEvent
& )
871 void FuPoor::SelectionHasChanged()
873 const SdrHdlList
& rHdlList
= mpView
->GetHdlList();
874 const_cast<SdrHdlList
&>(rHdlList
).ResetFocusHdl();
878 * Cut object to clipboard
889 * Copy object to clipboard
891 void FuPoor::DoCopy()
900 * Paste object from clipboard
902 void FuPoor::DoPaste()
906 mpView
->DoPaste(mpWindow
);
911 * Paste unformatted text from clipboard
913 void FuPoor::DoPasteUnformatted()
917 TransferableDataHelper
aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( mpViewShell
->GetActiveWindow() ) );
918 if (aDataHelper
.GetTransferable().is())
920 sal_Int8 nAction
= DND_ACTION_COPY
;
921 mpView
->InsertData( aDataHelper
,
922 mpWindow
->PixelToLogic( ::tools::Rectangle( Point(), mpWindow
->GetOutputSizePixel() ).Center() ),
923 nAction
, false, SotClipboardFormatId::STRING
);
929 * Timer handler for Drag&Drop
931 IMPL_LINK_NOARG(FuPoor
, DragHdl
, Timer
*, void)
936 sal_uInt16 nHitLog
= sal_uInt16 ( mpWindow
->PixelToLogic(Size(HITPIX
,0)).Width() );
937 SdrHdl
* pHdl
= mpView
->PickHandle(aMDPos
);
939 if ( pHdl
==nullptr && mpView
->IsMarkedHit(aMDPos
, nHitLog
)
940 && !mpView
->IsPresObjSelected(false) )
942 mpWindow
->ReleaseMouse();
943 bIsInDragMode
= true;
944 mpView
->StartDrag( aMDPos
, mpWindow
);
948 bool FuPoor::Command(const CommandEvent
& rCEvt
)
950 return mpView
->Command(rCEvt
,mpWindow
);
954 * Timer handler for window scrolling
956 IMPL_LINK_NOARG(FuPoor
, DelayHdl
, Timer
*, void)
958 aDelayToScrollTimer
.Stop ();
961 Point
aPnt(mpWindow
->GetPointerPosPixel());
963 // use remembered MouseButton state to create correct
964 // MouseEvents for this artificial MouseMove.
965 MouseMove(MouseEvent(aPnt
, 1, MouseEventModifiers::NONE
, GetMouseButtonCode()));
968 bool FuPoor::MouseButtonUp (const MouseEvent
& rMEvt
)
970 // remember button state for creation of own MouseEvents
971 SetMouseButtonCode(rMEvt
.GetButtons());
973 aDelayToScrollTimer
.Stop ();
974 bScrollable
= bDelayActive
= false;
978 bool FuPoor::MouseButtonDown(const MouseEvent
& rMEvt
)
980 // remember button state for creation of own MouseEvents
981 SetMouseButtonCode(rMEvt
.GetButtons());
986 void FuPoor::StartDelayToScrollTimer ()
989 aDelayToScrollTimer
.Start ();
992 bool FuPoor::RequestHelp(const HelpEvent
& rHEvt
)
994 bool bReturn
= false;
996 SdrPageView
* pPV
= mpView
->GetSdrPageView();
1000 SdPage
* pPage
= static_cast<SdPage
*>( pPV
->GetPage() );
1004 bReturn
= FmFormPage::RequestHelp(mpWindow
, mpView
, rHEvt
);
1011 void FuPoor::ReceiveRequest(SfxRequest
& /*rReq*/)
1015 rtl::Reference
<SdrObject
> FuPoor::CreateDefaultObject(const sal_uInt16
, const ::tools::Rectangle
& )
1017 // empty base implementation
1021 void FuPoor::ImpForceQuadratic(::tools::Rectangle
& rRect
)
1023 if(rRect
.GetWidth() > rRect
.GetHeight())
1025 rRect
= ::tools::Rectangle(
1026 Point(rRect
.Left() + ((rRect
.GetWidth() - rRect
.GetHeight()) / 2), rRect
.Top()),
1027 Size(rRect
.GetHeight(), rRect
.GetHeight()));
1031 rRect
= ::tools::Rectangle(
1032 Point(rRect
.Left(), rRect
.Top() + ((rRect
.GetHeight() - rRect
.GetWidth()) / 2)),
1033 Size(rRect
.GetWidth(), rRect
.GetWidth()));
1037 void FuPoor::SwitchLayer (sal_Int32 nOffset
)
1039 auto pDrawViewShell
= dynamic_cast<DrawViewShell
*>( mpViewShell
);
1043 // Calculate the new index.
1044 sal_Int32 nIndex
= pDrawViewShell
->GetActiveTabLayerIndex() + nOffset
;
1046 // Make sure the new index lies inside the range of valid indices.
1049 else if (nIndex
>= pDrawViewShell
->GetTabLayerCount ())
1050 nIndex
= pDrawViewShell
->GetTabLayerCount() - 1;
1052 // Set the new active layer.
1053 if (nIndex
!= pDrawViewShell
->GetActiveTabLayerIndex ())
1055 LayerTabBar
* pLayerTabControl
=
1056 static_cast<DrawViewShell
*>(mpViewShell
)->GetLayerTabControl();
1057 if (pLayerTabControl
!= nullptr)
1058 pLayerTabControl
->SendDeactivatePageEvent ();
1060 pDrawViewShell
->SetActiveTabLayerIndex (nIndex
);
1062 if (pLayerTabControl
!= nullptr)
1063 pLayerTabControl
->SendActivatePageEvent ();
1067 /** is called when the current function should be aborted. <p>
1068 This is used when a function gets a KEY_ESCAPE but can also
1071 @returns true if an active function was aborted
1073 bool FuPoor::cancel()
1075 if ( dynamic_cast< const FuSelection
*>( this ) == nullptr )
1077 mpViewShell
->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT
, SfxCallMode::ASYNCHRON
);
1085 bool FuPoor::doConstructOrthogonal() const
1087 // Check whether a media object is selected
1088 bool bResizeKeepRatio
= false;
1089 const SdrMarkList
& rMarkList
= mpView
->GetMarkedObjectList();
1090 // tdf#89758 Avoid interactive crop preview from being proportionally scaled by default.
1091 if (rMarkList
.GetMarkCount() != 0 && mpView
->GetDragMode() != SdrDragMode::Crop
)
1093 if (rMarkList
.GetMarkCount() == 1)
1095 SdrObjKind aObjIdentifier
= rMarkList
.GetMark(0)->GetMarkedSdrObj()->GetObjIdentifier();
1096 bResizeKeepRatio
= aObjIdentifier
== SdrObjKind::Graphic
||
1097 aObjIdentifier
== SdrObjKind::Media
||
1098 aObjIdentifier
== SdrObjKind::OLE2
;
1101 SdrHdl
* pHdl
= mpView
->PickHandle(aMDPos
);
1102 // Resize proportionally when media is selected and the user drags on a corner
1104 bResizeKeepRatio
= bResizeKeepRatio
&& pHdl
->IsCornerHdl();
1108 SID_DRAW_XLINE
== nSlotId
||
1109 SID_DRAW_CIRCLEARC
== nSlotId
||
1110 SID_DRAW_SQUARE
== nSlotId
||
1111 SID_DRAW_SQUARE_NOFILL
== nSlotId
||
1112 SID_DRAW_SQUARE_ROUND
== nSlotId
||
1113 SID_DRAW_SQUARE_ROUND_NOFILL
== nSlotId
||
1114 SID_DRAW_CIRCLE
== nSlotId
||
1115 SID_DRAW_CIRCLE_NOFILL
== nSlotId
||
1116 SID_DRAW_CIRCLEPIE
== nSlotId
||
1117 SID_DRAW_CIRCLEPIE_NOFILL
== nSlotId
||
1118 SID_DRAW_CIRCLECUT
== nSlotId
||
1119 SID_DRAW_CIRCLECUT_NOFILL
== nSlotId
||
1120 SID_DRAW_XPOLYGON
== nSlotId
||
1121 SID_DRAW_XPOLYGON_NOFILL
== nSlotId
||
1122 SID_3D_CUBE
== nSlotId
||
1123 SID_3D_SPHERE
== nSlotId
||
1124 SID_3D_SHELL
== nSlotId
||
1125 SID_3D_HALF_SPHERE
== nSlotId
||
1126 SID_3D_TORUS
== nSlotId
||
1127 SID_3D_CYLINDER
== nSlotId
||
1128 SID_3D_CONE
== nSlotId
||
1129 SID_3D_PYRAMID
== nSlotId
);
1132 void FuPoor::DoExecute( SfxRequest
& )
1136 } // end of namespace sd
1138 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */