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 <svl/aeitem.hxx>
24 #include <svx/svdpagv.hxx>
25 #include <svx/svdoole2.hxx>
26 #include <svx/svdograf.hxx>
27 #include <vcl/seleng.hxx>
28 #include <sfx2/app.hxx>
29 #include <sfx2/dispatch.hxx>
30 #include <sfx2/bindings.hxx>
31 #include <sfx2/request.hxx>
32 #include <vcl/dialog.hxx>
33 #include <com/sun/star/beans/XPropertySet.hpp>
34 #include <com/sun/star/drawing/XLayer.hpp>
35 #include <com/sun/star/drawing/XLayerManager.hpp>
36 #include <com/sun/star/container/XChild.hpp>
38 #include "FrameView.hxx"
42 #include "drawview.hxx"
43 #include "DrawViewShell.hxx"
45 #include "drawdoc.hxx"
46 #include "DrawDocShell.hxx"
47 #include "zoomlist.hxx"
49 #include "slideshow.hxx"
50 #include "LayerTabBar.hxx"
52 #include <sfx2/viewfrm.hxx>
54 #include <svx/svditer.hxx>
56 #include <editeng/editeng.hxx>
58 using namespace ::com::sun::star
;
59 using ::com::sun::star::uno::Reference
;
69 SdDrawDocument
* pDrDoc
,
74 mpDocSh( pDrDoc
->GetDocSh() ),
76 nSlotId( rReq
.GetSlot() ),
80 bNoScrollUntilInside (true),
83 bFirstMouseMove (false),
84 // remember MouseButton state
89 aScrollTimer
.SetTimeoutHdl( LINK(this, FuPoor
, ScrollHdl
) );
90 aScrollTimer
.SetTimeout(SELENG_AUTOREPEAT_INTERVAL
);
92 aDragTimer
.SetTimeoutHdl( LINK(this, FuPoor
, DragHdl
) );
93 aDragTimer
.SetTimeout(SELENG_DRAGDROP_TIMEOUT
);
95 aDelayToScrollTimer
.SetTimeoutHdl( LINK(this, FuPoor
, DelayHdl
) );
96 aDelayToScrollTimer
.SetTimeout(2000);
103 aDelayToScrollTimer
.Stop();
104 pDialog
.disposeAndClear();
107 void FuPoor::Activate()
115 void FuPoor::Deactivate()
119 aDelayToScrollTimer
.Stop ();
121 bDelayActive
= false;
128 if (mpWindow
) mpWindow
->ReleaseMouse ();
131 void FuPoor::SetWindow(::sd::Window
* pWin
)
137 * scroll when approached the border of the window; is called by MouseMove
139 void FuPoor::ForceScroll(const Point
& aPixPos
)
143 if ( !mpView
->IsDragHelpLine() && !mpView
->IsSetPageOrg() &&
144 !SlideShow::IsRunning( mpViewShell
->GetViewShellBase() ) )
146 Point aPos
= mpWindow
->OutputToScreenPixel(aPixPos
);
147 const Rectangle
& rRect
= mpViewShell
->GetAllWindowRect();
149 if ( bNoScrollUntilInside
)
151 if ( rRect
.IsInside(aPos
) )
152 bNoScrollUntilInside
= false;
156 short dx
= 0, dy
= 0;
158 if ( aPos
.X() <= rRect
.Left() ) dx
= -1;
159 if ( aPos
.X() >= rRect
.Right() ) dx
= 1;
160 if ( aPos
.Y() <= rRect
.Top() ) dy
= -1;
161 if ( aPos
.Y() >= rRect
.Bottom() ) dy
= 1;
163 if ( dx
!= 0 || dy
!= 0 )
167 // scroll action in derived class
168 mpViewShell
->ScrollLines(dx
, dy
);
169 aScrollTimer
.Start();
171 else if (! bDelayActive
) StartDelayToScrollTimer ();
178 * timer handler for window scrolling
180 IMPL_LINK_NOARG_TYPED(FuPoor
, ScrollHdl
, Timer
*, void)
182 Point
aPnt(mpWindow
->GetPointerPosPixel());
184 // use remembered MouseButton state to create correct
185 // MouseEvents for this artificial MouseMove.
186 MouseMove(MouseEvent(aPnt
, 1, MouseEventModifiers::NONE
, GetMouseButtonCode()));
190 * handle keyboard events
191 * @returns sal_True if the event was handled, sal_False otherwise
193 bool FuPoor::KeyInput(const KeyEvent
& rKEvt
)
195 sal_uInt16 nCode
= rKEvt
.GetKeyCode().GetCode();
196 bool bReturn
= false;
197 bool bSlideShow
= SlideShow::IsRunning( mpViewShell
->GetViewShellBase() );
203 if(rKEvt
.GetKeyCode().IsMod1())
205 if (mpViewShell
->ISA(DrawViewShell
))
207 DrawViewShell
* pDrawViewShell
=
208 static_cast<DrawViewShell
*>(mpViewShell
);
209 SdPage
* pActualPage
= pDrawViewShell
->GetActualPage();
210 SdrTextObj
* pCandidate
= 0L;
214 SdrObjListIter
aIter(*pActualPage
, IM_DEEPNOGROUPS
);
216 while(aIter
.IsMore() && !pCandidate
)
218 SdrObject
* pObj
= aIter
.Next();
220 if(pObj
&& pObj
->ISA(SdrTextObj
))
222 sal_uInt32
nInv(pObj
->GetObjInventor());
223 sal_uInt16
nKnd(pObj
->GetObjIdentifier());
225 if(SdrInventor
== nInv
&&
226 (OBJ_TITLETEXT
== nKnd
|| OBJ_OUTLINETEXT
== nKnd
|| OBJ_TEXT
== nKnd
))
228 pCandidate
= static_cast<SdrTextObj
*>(pObj
);
237 mpView
->MarkObj(pCandidate
, mpView
->GetSdrPageView());
239 mpViewShell
->GetViewFrame()->GetDispatcher()->Execute(
240 SID_ATTR_CHAR
, SfxCallMode::ASYNCHRON
);
244 // insert a new page with the same page layout
245 mpViewShell
->GetViewFrame()->GetDispatcher()->Execute(
246 SID_INSERTPAGE_QUICK
, SfxCallMode::ASYNCHRON
);
255 // activate OLE object on RETURN for selected object
256 // activate text edit on RETURN for selected object
257 const SdrMarkList
& rMarkList
= mpView
->GetMarkedObjectList();
259 if( !mpView
->IsTextEdit() && 1 == rMarkList
.GetMarkCount() )
261 SdrObject
* pObj
= rMarkList
.GetMark( 0 )->GetMarkedSdrObj();
263 if( pObj
&& pObj
->ISA( SdrOle2Obj
) && !mpDocSh
->IsUIActive() )
265 //HMHmpView->HideMarkHdl();
266 mpViewShell
->ActivateObject( static_cast< SdrOle2Obj
* >( pObj
), 0 );
268 else if( pObj
&& pObj
->IsEmptyPresObj() && pObj
->ISA( SdrGrafObj
) )
270 mpViewShell
->GetViewFrame()->GetDispatcher()->Execute( SID_INSERT_GRAPHIC
, SfxCallMode::ASYNCHRON
| SfxCallMode::RECORD
);
274 mpViewShell
->GetViewFrame()->GetDispatcher()->Execute( SID_ATTR_CHAR
, SfxCallMode::ASYNCHRON
| SfxCallMode::RECORD
);
286 // handle Mod1 and Mod2 to get travelling running on different systems
287 if(rKEvt
.GetKeyCode().IsMod1() || rKEvt
.GetKeyCode().IsMod2())
289 // do something with a selected handle?
290 const SdrHdlList
& rHdlList
= mpView
->GetHdlList();
291 bool bForward(!rKEvt
.GetKeyCode().IsShift());
293 ((SdrHdlList
&)rHdlList
).TravelFocusHdl(bForward
);
295 // guarantee visibility of focused handle
296 SdrHdl
* pHdl
= rHdlList
.GetFocusHdl();
300 Point
aHdlPosition(pHdl
->GetPos());
301 Rectangle
aVisRect(aHdlPosition
- Point(100, 100), Size(200, 200));
302 mpView
->MakeVisible(aVisRect
, *mpWindow
);
313 bReturn
= FuPoor::cancel();
319 if (!mpView
->IsTextEdit() && !bSlideShow
&& !mpDocSh
->IsUIActive())
322 mpViewShell
->SetZoom(mpWindow
->GetZoom() * 3 / 2);
324 if (mpViewShell
->ISA(DrawViewShell
))
325 static_cast<DrawViewShell
*>(mpViewShell
)
326 ->SetZoomOnPage(false);
335 if (!mpView
->IsTextEdit() && !bSlideShow
&& !mpDocSh
->IsUIActive())
338 mpViewShell
->SetZoom(mpWindow
->GetZoom() * 2 / 3);
340 if (mpViewShell
->ISA(DrawViewShell
))
341 static_cast<DrawViewShell
*>(mpViewShell
)
342 ->SetZoomOnPage(false);
351 if (!mpView
->IsTextEdit() && !bSlideShow
)
354 mpViewShell
->GetViewFrame()->GetDispatcher()->
355 Execute(SID_SIZE_PAGE
, SfxCallMode::ASYNCHRON
| SfxCallMode::RECORD
);
363 if (!mpView
->IsTextEdit() && !bSlideShow
)
365 // zoom to selected objects
366 mpViewShell
->GetViewFrame()->GetDispatcher()->
367 Execute(SID_SIZE_OPTIMAL
, SfxCallMode::ASYNCHRON
| SfxCallMode::RECORD
);
375 ZoomList
* pZoomList
= mpViewShell
->GetZoomList();
377 if (!mpView
->IsTextEdit() && pZoomList
->IsNextPossible() && !bSlideShow
&& !mpDocSh
->IsUIActive())
380 mpViewShell
->SetZoomRect(pZoomList
->GetNextZoomRect());
388 ZoomList
* pZoomList
= mpViewShell
->GetZoomList();
390 if (!mpView
->IsTextEdit() && pZoomList
->IsPreviousPossible() && !bSlideShow
&& !mpDocSh
->IsUIActive())
392 // use previous ZoomRect
393 mpViewShell
->SetZoomRect(pZoomList
->GetPreviousZoomRect());
401 if (!mpView
->IsTextEdit()
402 && mpViewShell
->ISA(DrawViewShell
)
405 // jump to first page
406 static_cast<DrawViewShell
*>(mpViewShell
)->SwitchPage(0);
414 if (!mpView
->IsTextEdit()
415 && mpViewShell
->ISA(DrawViewShell
)
420 static_cast<DrawViewShell
*>(mpViewShell
)->GetActualPage();
421 static_cast<DrawViewShell
*>(mpViewShell
)
422 ->SwitchPage(mpDoc
->GetSdPageCount(
423 pPage
->GetPageKind()) - 1);
431 if( rKEvt
.GetKeyCode().IsMod1() && rKEvt
.GetKeyCode().IsMod2() )
434 if(mpViewShell
->ISA(DrawViewShell
) && !bSlideShow
)
436 // The page-up key switches layers or pages depending on the
438 if ( ! rKEvt
.GetKeyCode().GetModifier())
440 // With no modifier pressed we move to the previous
442 mpView
->SdrEndTextEdit();
446 SdPage
* pPage
= static_cast<DrawViewShell
*>(mpViewShell
)->GetActualPage();
447 sal_uInt16 nSdPage
= (pPage
->GetPageNum() - 1) / 2;
451 // Switch the page and send events regarding
452 // deactivation the old page and activating the new
454 TabControl
& rPageTabControl
=
455 static_cast<DrawViewShell
*>(mpViewShell
)
456 ->GetPageTabControl();
457 if (rPageTabControl
.IsReallyShown())
458 rPageTabControl
.SendDeactivatePageEvent ();
459 static_cast<DrawViewShell
*>(mpViewShell
)->SwitchPage(nSdPage
- 1);
460 if (rPageTabControl
.IsReallyShown())
461 rPageTabControl
.SendActivatePageEvent ();
464 else if (rKEvt
.GetKeyCode().IsMod1())
466 // With the CONTROL modifier we switch layers.
467 if (static_cast<DrawViewShell
*>(mpViewShell
)->IsLayerModeActive())
469 // Moves to the previous layer.
479 if( rKEvt
.GetKeyCode().IsMod1() && rKEvt
.GetKeyCode().IsMod2() )
481 if(mpViewShell
->ISA(DrawViewShell
) && !bSlideShow
)
483 // The page-down key switches layers or pages depending on the
485 if ( ! rKEvt
.GetKeyCode().GetModifier())
487 // With no modifier pressed we move to the next slide.
488 mpView
->SdrEndTextEdit();
492 SdPage
* pPage
= static_cast<DrawViewShell
*>(mpViewShell
)->GetActualPage();
493 sal_uInt16 nSdPage
= (pPage
->GetPageNum() - 1) / 2;
495 if (nSdPage
< mpDoc
->GetSdPageCount(pPage
->GetPageKind()) - 1)
497 // Switch the page and send events regarding
498 // deactivation the old page and activating the new
500 TabControl
& rPageTabControl
=
501 static_cast<DrawViewShell
*>(mpViewShell
)->GetPageTabControl();
502 if (rPageTabControl
.IsReallyShown())
503 rPageTabControl
.SendDeactivatePageEvent ();
504 static_cast<DrawViewShell
*>(mpViewShell
)->SwitchPage(nSdPage
+ 1);
505 if (rPageTabControl
.IsReallyShown())
506 rPageTabControl
.SendActivatePageEvent ();
509 else if (rKEvt
.GetKeyCode().IsMod1())
511 // With the CONTROL modifier we switch layers.
512 if (static_cast<DrawViewShell
*>(mpViewShell
)->IsLayerModeActive())
514 // With the layer mode active pressing page-down
515 // moves to the next layer.
523 // change select state when focus is on poly point
526 const SdrHdlList
& rHdlList
= mpView
->GetHdlList();
527 SdrHdl
* pHdl
= rHdlList
.GetFocusHdl();
531 if(pHdl
->GetKind() == HDL_POLY
)
533 // rescue ID of point with focus
534 sal_uInt32
nPol(pHdl
->GetPolyNum());
535 sal_uInt32
nPnt(pHdl
->GetPointNum());
537 if(mpView
->IsPointMarked(*pHdl
))
539 if(rKEvt
.GetKeyCode().IsShift())
541 mpView
->UnmarkPoint(*pHdl
);
546 if(!rKEvt
.GetKeyCode().IsShift())
548 mpView
->UnmarkAllPoints();
551 mpView
->MarkPoint(*pHdl
);
554 if(0L == rHdlList
.GetFocusHdl())
556 // restore point with focus
557 SdrHdl
* pNewOne
= 0L;
559 for(size_t a
= 0; !pNewOne
&& a
< rHdlList
.GetHdlCount(); ++a
)
561 SdrHdl
* pAct
= rHdlList
.GetHdl(a
);
564 && pAct
->GetKind() == HDL_POLY
565 && pAct
->GetPolyNum() == nPol
566 && pAct
->GetPointNum() == nPnt
)
574 ((SdrHdlList
&)rHdlList
).SetFocusHdl(pNewOne
);
589 if (!mpView
->IsTextEdit() && !bSlideShow
)
600 else if (nCode
== KEY_DOWN
)
606 else if (nCode
== KEY_LEFT
)
612 else if (nCode
== KEY_RIGHT
)
619 if (mpView
->AreObjectsMarked() && !rKEvt
.GetKeyCode().IsMod1() &&
620 !mpDocSh
->IsReadOnly())
622 const SdrHdlList
& rHdlList
= mpView
->GetHdlList();
623 SdrHdl
* pHdl
= rHdlList
.GetFocusHdl();
625 bool bIsMoveOfConnectedHandle(false);
626 bool bOldSuppress
= false;
627 SdrEdgeObj
* pEdgeObj
= 0L;
629 if(pHdl
&& pHdl
->GetObj() && pHdl
->GetObj()->ISA(SdrEdgeObj
) && 0 == pHdl
->GetPolyNum())
631 pEdgeObj
= static_cast<SdrEdgeObj
*>(pHdl
->GetObj());
633 if(0L == pHdl
->GetPointNum())
635 if(pEdgeObj
->GetConnection(true).GetObject())
637 bIsMoveOfConnectedHandle
= true;
640 if(1L == pHdl
->GetPointNum())
642 if(pEdgeObj
->GetConnection(false).GetObject())
644 bIsMoveOfConnectedHandle
= true;
651 // Suppress default connects to inside object and object center
652 bOldSuppress
= pEdgeObj
->GetSuppressDefaultConnect();
653 pEdgeObj
->SetSuppressDefaultConnect(true);
656 if(bIsMoveOfConnectedHandle
)
658 sal_uInt16
nMarkHdSiz(mpView
->GetMarkHdlSizePixel());
659 Size
aHalfConSiz(nMarkHdSiz
+ 1, nMarkHdSiz
+ 1);
660 aHalfConSiz
= mpWindow
->PixelToLogic(aHalfConSiz
);
662 if(100 < aHalfConSiz
.Width())
663 nX
*= aHalfConSiz
.Width();
667 if(100 < aHalfConSiz
.Height())
668 nY
*= aHalfConSiz
.Height();
672 else if(rKEvt
.GetKeyCode().IsMod2())
674 // move in 1 pixel distance
675 Size aLogicSizeOnePixel
= mpWindow
->PixelToLogic(Size(1,1));
676 nX
*= aLogicSizeOnePixel
.Width();
677 nY
*= aLogicSizeOnePixel
.Height();
679 else if(rKEvt
.GetKeyCode().IsShift())
686 // old, fixed move distance
693 // only take action when move is allowed
694 if(mpView
->IsMoveAllowed())
696 // restrict movement to WorkArea
697 const Rectangle
& rWorkArea
= mpView
->GetWorkArea();
699 if(!rWorkArea
.IsEmpty())
701 Rectangle
aMarkRect(mpView
->GetMarkedObjRect());
702 aMarkRect
.Move(nX
, nY
);
704 if(!aMarkRect
.IsInside(rWorkArea
))
706 if(aMarkRect
.Left() < rWorkArea
.Left())
708 nX
+= rWorkArea
.Left() - aMarkRect
.Left();
711 if(aMarkRect
.Right() > rWorkArea
.Right())
713 nX
-= aMarkRect
.Right() - rWorkArea
.Right();
716 if(aMarkRect
.Top() < rWorkArea
.Top())
718 nY
+= rWorkArea
.Top() - aMarkRect
.Top();
721 if(aMarkRect
.Bottom() > rWorkArea
.Bottom())
723 nY
-= aMarkRect
.Bottom() - rWorkArea
.Bottom();
728 // no handle selected
729 if(0 != nX
|| 0 != nY
)
731 mpView
->MoveAllMarked(Size(nX
, nY
));
733 mpView
->MakeVisible(mpView
->GetAllMarkedRect(), *mpWindow
);
739 // move handle with index nHandleIndex
740 if(pHdl
&& (nX
|| nY
))
742 // now move the Handle (nX, nY)
743 Point
aStartPoint(pHdl
->GetPos());
744 Point
aEndPoint(pHdl
->GetPos() + Point(nX
, nY
));
745 const SdrDragStat
& rDragStat
= mpView
->GetDragStat();
748 mpView
->BegDragObj(aStartPoint
, 0, pHdl
, 0);
750 if(mpView
->IsDragObj())
752 bool bWasNoSnap
= rDragStat
.IsNoSnap();
753 bool bWasSnapEnabled
= mpView
->IsSnapEnabled();
755 // switch snapping off
757 ((SdrDragStat
&)rDragStat
).SetNoSnap(true);
759 mpView
->SetSnapEnabled(false);
761 mpView
->MovAction(aEndPoint
);
762 mpView
->EndDragObj();
766 ((SdrDragStat
&)rDragStat
).SetNoSnap(bWasNoSnap
);
768 mpView
->SetSnapEnabled(bWasSnapEnabled
);
771 // make moved handle visible
772 Rectangle
aVisRect(aEndPoint
- Point(100, 100), Size(200, 200));
773 mpView
->MakeVisible(aVisRect
, *mpWindow
);
779 // Restore original suppress value
780 pEdgeObj
->SetSuppressDefaultConnect(bOldSuppress
);
786 mpViewShell
->ScrollLines(nX
, nY
);
797 mpWindow
->ReleaseMouse();
800 // when a text-editable object is selected and the
801 // input character is printable, activate text edit on that object
802 // and feed character to object
803 if(!bReturn
&& !mpDocSh
->IsReadOnly())
805 if(!mpView
->IsTextEdit() && mpViewShell
)
807 const SdrMarkList
& rMarkList
= mpView
->GetMarkedObjectList();
809 if(1 == rMarkList
.GetMarkCount())
811 SdrObject
* pObj
= rMarkList
.GetMark(0)->GetMarkedSdrObj();
813 // #i118485# allow TextInput for OLEs, too
814 if(pObj
->ISA(SdrTextObj
) && pObj
->HasTextEdit())
816 // use common IsSimpleCharInput from the EditEngine.
817 bool bPrintable(EditEngine::IsSimpleCharInput(rKEvt
));
821 // try to activate textedit mode for the selected object
822 SfxStringItem
aInputString(SID_ATTR_CHAR
, OUString(rKEvt
.GetCharCode()));
824 mpViewShell
->GetViewFrame()->GetDispatcher()->Execute(
826 SfxCallMode::ASYNCHRON
,
837 // test if there is a title object there. If yes, try to
838 // set it to edit mode and start typing...
839 if(mpViewShell
->ISA(DrawViewShell
)
840 && EditEngine::IsSimpleCharInput(rKEvt
))
842 DrawViewShell
* pDrawViewShell
=
843 static_cast<DrawViewShell
*>(mpViewShell
);
844 SdPage
* pActualPage
= pDrawViewShell
->GetActualPage();
845 SdrTextObj
* pCandidate
= 0L;
849 SdrObjListIter
aIter(*pActualPage
, IM_DEEPNOGROUPS
);
851 while(aIter
.IsMore() && !pCandidate
)
853 SdrObject
* pObj
= aIter
.Next();
855 if(pObj
&& pObj
->ISA(SdrTextObj
))
857 sal_uInt32
nInv(pObj
->GetObjInventor());
858 sal_uInt16
nKnd(pObj
->GetObjIdentifier());
860 if(SdrInventor
== nInv
&& OBJ_TITLETEXT
== nKnd
)
862 pCandidate
= static_cast<SdrTextObj
*>(pObj
);
868 // when candidate found and candidate is untouched, start editing text...
869 if(pCandidate
&& pCandidate
->IsEmptyPresObj())
872 mpView
->MarkObj(pCandidate
, mpView
->GetSdrPageView());
873 SfxStringItem
aInputString(SID_ATTR_CHAR
, OUString(rKEvt
.GetCharCode()));
875 mpViewShell
->GetViewFrame()->GetDispatcher()->Execute(
877 SfxCallMode::ASYNCHRON
,
892 bool FuPoor::MouseMove(const MouseEvent
& )
897 void FuPoor::SelectionHasChanged()
899 const SdrHdlList
& rHdlList
= mpView
->GetHdlList();
900 ((SdrHdlList
&)rHdlList
).ResetFocusHdl();
904 * Cut object to clipboard
910 mpView
->DoCut(mpWindow
);
915 * Copy object to clipboard
917 void FuPoor::DoCopy()
921 mpView
->DoCopy(mpWindow
);
926 * Paste object from clipboard
928 void FuPoor::DoPaste()
932 mpView
->DoPaste(mpWindow
);
937 * Paste unformatted text from clipboard
939 void FuPoor::DoPasteUnformatted()
943 sal_Int8 nAction
= DND_ACTION_COPY
;
944 TransferableDataHelper
aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( mpViewShell
->GetActiveWindow() ) );
945 if (aDataHelper
.GetTransferable().is())
947 mpView
->InsertData( aDataHelper
,
948 mpWindow
->PixelToLogic( Rectangle( Point(), mpWindow
->GetOutputSizePixel() ).Center() ),
949 nAction
, false, SotClipboardFormatId::STRING
);
955 * Timer handler for Drag&Drop
957 IMPL_LINK_NOARG_TYPED(FuPoor
, DragHdl
, Timer
*, void)
961 sal_uInt16 nHitLog
= sal_uInt16 ( mpWindow
->PixelToLogic(Size(HITPIX
,0)).Width() );
962 SdrHdl
* pHdl
= mpView
->PickHandle(aMDPos
);
964 if ( pHdl
==NULL
&& mpView
->IsMarkedHit(aMDPos
, nHitLog
)
965 && !mpView
->IsPresObjSelected(false, true) )
967 mpWindow
->ReleaseMouse();
968 bIsInDragMode
= true;
969 mpView
->StartDrag( aMDPos
, mpWindow
);
974 bool FuPoor::Command(const CommandEvent
& rCEvt
)
976 return mpView
->Command(rCEvt
,mpWindow
);
980 * Timer handler for window scrolling
982 IMPL_LINK_NOARG_TYPED(FuPoor
, DelayHdl
, Timer
*, void)
984 aDelayToScrollTimer
.Stop ();
987 Point
aPnt(mpWindow
->GetPointerPosPixel());
989 // use remembered MouseButton state to create correct
990 // MouseEvents for this artificial MouseMove.
991 MouseMove(MouseEvent(aPnt
, 1, MouseEventModifiers::NONE
, GetMouseButtonCode()));
994 bool FuPoor::MouseButtonUp (const MouseEvent
& rMEvt
)
996 // remember button state for creation of own MouseEvents
997 SetMouseButtonCode(rMEvt
.GetButtons());
999 aDelayToScrollTimer
.Stop ();
1000 return bScrollable
=
1001 bDelayActive
= false;
1004 bool FuPoor::MouseButtonDown(const MouseEvent
& rMEvt
)
1006 // remember button state for creation of own MouseEvents
1007 SetMouseButtonCode(rMEvt
.GetButtons());
1012 void FuPoor::StartDelayToScrollTimer ()
1014 bDelayActive
= true;
1015 aDelayToScrollTimer
.Start ();
1018 bool FuPoor::RequestHelp(const HelpEvent
& rHEvt
)
1020 bool bReturn
= false;
1022 SdrPageView
* pPV
= mpView
->GetSdrPageView();
1026 SdPage
* pPage
= static_cast<SdPage
*>( pPV
->GetPage() );
1030 bReturn
= FmFormPage::RequestHelp(mpWindow
, mpView
, rHEvt
);
1037 void FuPoor::ReceiveRequest(SfxRequest
& rReq
)
1039 const SfxItemSet
* pSet
= rReq
.GetArgs();
1043 if( pSet
->GetItemState( nSlotId
) == SfxItemState::SET
)
1045 const SfxPoolItem
& rItem
= pSet
->Get( nSlotId
);
1047 if( rItem
.ISA( SfxAllEnumItem
) )
1049 nSlotValue
= static_cast<const SfxAllEnumItem
&>( rItem
).GetValue();
1055 SdrObject
* FuPoor::CreateDefaultObject(const sal_uInt16
, const Rectangle
& )
1057 // empty base implementation
1061 void FuPoor::ImpForceQuadratic(Rectangle
& rRect
)
1063 if(rRect
.GetWidth() > rRect
.GetHeight())
1066 Point(rRect
.Left() + ((rRect
.GetWidth() - rRect
.GetHeight()) / 2), rRect
.Top()),
1067 Size(rRect
.GetHeight(), rRect
.GetHeight()));
1072 Point(rRect
.Left(), rRect
.Top() + ((rRect
.GetHeight() - rRect
.GetWidth()) / 2)),
1073 Size(rRect
.GetWidth(), rRect
.GetWidth()));
1077 void FuPoor::SwitchLayer (sal_Int32 nOffset
)
1079 if(mpViewShell
&& mpViewShell
->ISA(DrawViewShell
))
1081 DrawViewShell
* pDrawViewShell
=
1082 static_cast<DrawViewShell
*>(mpViewShell
);
1084 // Calculate the new index.
1085 sal_Int32 nIndex
= pDrawViewShell
->GetActiveTabLayerIndex() + nOffset
;
1087 // Make sure the new index lies inside the range of valid indices.
1090 else if (nIndex
>= pDrawViewShell
->GetTabLayerCount ())
1091 nIndex
= pDrawViewShell
->GetTabLayerCount() - 1;
1093 // Set the new active layer.
1094 if (nIndex
!= pDrawViewShell
->GetActiveTabLayerIndex ())
1096 LayerTabBar
* pLayerTabControl
=
1097 static_cast<DrawViewShell
*>(mpViewShell
)->GetLayerTabControl();
1098 if (pLayerTabControl
!= NULL
)
1099 pLayerTabControl
->SendDeactivatePageEvent ();
1101 pDrawViewShell
->SetActiveTabLayerIndex (nIndex
);
1103 if (pLayerTabControl
!= NULL
)
1104 pLayerTabControl
->SendActivatePageEvent ();
1109 /** is called when the current function should be aborted. <p>
1110 This is used when a function gets a KEY_ESCAPE but can also
1113 @returns true if a active function was aborted
1115 bool FuPoor::cancel()
1117 if ( !this->ISA(FuSelection
) )
1119 mpViewShell
->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT
, SfxCallMode::ASYNCHRON
);
1127 bool FuPoor::doConstructOrthogonal() const
1130 SID_DRAW_XLINE
== nSlotId
||
1131 SID_DRAW_CIRCLEARC
== nSlotId
||
1132 SID_DRAW_SQUARE
== nSlotId
||
1133 SID_DRAW_SQUARE_NOFILL
== nSlotId
||
1134 SID_DRAW_SQUARE_ROUND
== nSlotId
||
1135 SID_DRAW_SQUARE_ROUND_NOFILL
== nSlotId
||
1136 SID_DRAW_CIRCLE
== nSlotId
||
1137 SID_DRAW_CIRCLE_NOFILL
== nSlotId
||
1138 SID_DRAW_CIRCLEPIE
== nSlotId
||
1139 SID_DRAW_CIRCLEPIE_NOFILL
== nSlotId
||
1140 SID_DRAW_CIRCLECUT
== nSlotId
||
1141 SID_DRAW_CIRCLECUT_NOFILL
== nSlotId
||
1142 SID_DRAW_XPOLYGON
== nSlotId
||
1143 SID_DRAW_XPOLYGON_NOFILL
== nSlotId
||
1144 SID_3D_CUBE
== nSlotId
||
1145 SID_3D_SPHERE
== nSlotId
||
1146 SID_3D_SHELL
== nSlotId
||
1147 SID_3D_HALF_SPHERE
== nSlotId
||
1148 SID_3D_TORUS
== nSlotId
||
1149 SID_3D_CYLINDER
== nSlotId
||
1150 SID_3D_CONE
== nSlotId
||
1151 SID_3D_PYRAMID
== nSlotId
);
1154 void FuPoor::DoExecute( SfxRequest
& )
1158 } // end of namespace sd
1160 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */