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
;
70 SdDrawDocument
* pDrDoc
,
75 mpDocSh( pDrDoc
->GetDocSh() ),
77 nSlotId( rReq
.GetSlot() ),
80 bIsInDragMode(sal_False
),
81 bNoScrollUntilInside (sal_True
),
82 bScrollable (sal_False
),
83 bDelayActive (sal_False
),
84 bFirstMouseMove (sal_False
),
85 // remember MouseButton state
90 aScrollTimer
.SetTimeoutHdl( LINK(this, FuPoor
, ScrollHdl
) );
91 aScrollTimer
.SetTimeout(SELENG_AUTOREPEAT_INTERVAL
);
93 aDragTimer
.SetTimeoutHdl( LINK(this, FuPoor
, DragHdl
) );
94 aDragTimer
.SetTimeout(SELENG_DRAGDROP_TIMEOUT
);
96 aDelayToScrollTimer
.SetTimeoutHdl( LINK(this, FuPoor
, DelayHdl
) );
97 aDelayToScrollTimer
.SetTimeout(2000);
105 aDelayToScrollTimer
.Stop ();
112 void FuPoor::Activate()
121 void FuPoor::Deactivate()
125 aDelayToScrollTimer
.Stop ();
127 bDelayActive
= sal_False
;
134 if (mpWindow
) mpWindow
->ReleaseMouse ();
138 * scroll when approached the border of the window; is called by MouseMove
140 void FuPoor::ForceScroll(const Point
& aPixPos
)
144 if ( !mpView
->IsDragHelpLine() && !mpView
->IsSetPageOrg() &&
145 !SlideShow::IsRunning( mpViewShell
->GetViewShellBase() ) )
147 Point aPos
= mpWindow
->OutputToScreenPixel(aPixPos
);
148 const Rectangle
& rRect
= mpViewShell
->GetAllWindowRect();
150 if ( bNoScrollUntilInside
)
152 if ( rRect
.IsInside(aPos
) )
153 bNoScrollUntilInside
= sal_False
;
157 short dx
= 0, dy
= 0;
159 if ( aPos
.X() <= rRect
.Left() ) dx
= -1;
160 if ( aPos
.X() >= rRect
.Right() ) dx
= 1;
161 if ( aPos
.Y() <= rRect
.Top() ) dy
= -1;
162 if ( aPos
.Y() >= rRect
.Bottom() ) dy
= 1;
164 if ( dx
!= 0 || dy
!= 0 )
168 // scroll action in derived class
169 mpViewShell
->ScrollLines(dx
, dy
);
170 aScrollTimer
.Start();
172 else if (! bDelayActive
) StartDelayToScrollTimer ();
179 * timer handler for window scrolling
181 IMPL_LINK_NOARG_INLINE_START(FuPoor
, ScrollHdl
)
183 Point
aPnt(mpWindow
->GetPointerPosPixel());
185 // use remembered MouseButton state to create correct
186 // MouseEvents for this artifical MouseMove.
187 MouseMove(MouseEvent(aPnt
, 1, 0, GetMouseButtonCode()));
191 IMPL_LINK_INLINE_END( FuPoor
, ScrollHdl
, Timer
*, pTimer
)
194 * handle keyboard events
195 * @returns sal_True if the event was handled, sal_False otherwise
197 sal_Bool
FuPoor::KeyInput(const KeyEvent
& rKEvt
)
199 sal_uInt16 nCode
= rKEvt
.GetKeyCode().GetCode();
200 sal_Bool bReturn
= sal_False
;
201 sal_Bool bSlideShow
= SlideShow::IsRunning( mpViewShell
->GetViewShellBase() );
207 if(rKEvt
.GetKeyCode().IsMod1())
209 if(mpViewShell
&& mpViewShell
->ISA(DrawViewShell
))
211 DrawViewShell
* pDrawViewShell
=
212 static_cast<DrawViewShell
*>(mpViewShell
);
213 SdPage
* pActualPage
= pDrawViewShell
->GetActualPage();
214 SdrTextObj
* pCandidate
= 0L;
218 SdrObjListIter
aIter(*pActualPage
, IM_DEEPNOGROUPS
);
220 while(aIter
.IsMore() && !pCandidate
)
222 SdrObject
* pObj
= aIter
.Next();
224 if(pObj
&& pObj
->ISA(SdrTextObj
))
226 sal_uInt32
nInv(pObj
->GetObjInventor());
227 sal_uInt16
nKnd(pObj
->GetObjIdentifier());
229 if(SdrInventor
== nInv
&&
230 (OBJ_TITLETEXT
== nKnd
|| OBJ_OUTLINETEXT
== nKnd
|| OBJ_TEXT
== nKnd
))
232 pCandidate
= (SdrTextObj
*)pObj
;
241 mpView
->MarkObj(pCandidate
, mpView
->GetSdrPageView());
243 mpViewShell
->GetViewFrame()->GetDispatcher()->Execute(
244 SID_ATTR_CHAR
, SFX_CALLMODE_ASYNCHRON
);
248 // insert a new page with the same page layout
249 mpViewShell
->GetViewFrame()->GetDispatcher()->Execute(
250 SID_INSERTPAGE_QUICK
, SFX_CALLMODE_ASYNCHRON
);
259 // activate OLE object on RETURN for selected object
260 // activate text edit on RETURN for selected object
261 const SdrMarkList
& rMarkList
= mpView
->GetMarkedObjectList();
263 if( !mpView
->IsTextEdit() && 1 == rMarkList
.GetMarkCount() )
265 SdrObject
* pObj
= rMarkList
.GetMark( 0 )->GetMarkedSdrObj();
267 if( pObj
&& pObj
->ISA( SdrOle2Obj
) && !mpDocSh
->IsUIActive() )
269 //HMHmpView->HideMarkHdl();
270 mpViewShell
->ActivateObject( static_cast< SdrOle2Obj
* >( pObj
), 0 );
272 else if( pObj
&& pObj
->IsEmptyPresObj() && pObj
->ISA( SdrGrafObj
) )
274 mpViewShell
->GetViewFrame()->GetDispatcher()->Execute( SID_INSERT_GRAPHIC
, SFX_CALLMODE_ASYNCHRON
| SFX_CALLMODE_RECORD
);
278 mpViewShell
->GetViewFrame()->GetDispatcher()->Execute( SID_ATTR_CHAR
, SFX_CALLMODE_ASYNCHRON
| SFX_CALLMODE_RECORD
);
290 // handle Mod1 and Mod2 to get travelling running on different systems
291 if(rKEvt
.GetKeyCode().IsMod1() || rKEvt
.GetKeyCode().IsMod2())
293 // do something with a selected handle?
294 const SdrHdlList
& rHdlList
= mpView
->GetHdlList();
295 sal_Bool
bForward(!rKEvt
.GetKeyCode().IsShift());
297 ((SdrHdlList
&)rHdlList
).TravelFocusHdl(bForward
);
299 // guarantee visibility of focused handle
300 SdrHdl
* pHdl
= rHdlList
.GetFocusHdl();
304 Point
aHdlPosition(pHdl
->GetPos());
305 Rectangle
aVisRect(aHdlPosition
- Point(100, 100), Size(200, 200));
306 mpView
->MakeVisible(aVisRect
, *mpWindow
);
317 bReturn
= FuPoor::cancel();
323 if (!mpView
->IsTextEdit() && !bSlideShow
&& !mpDocSh
->IsUIActive())
326 mpViewShell
->SetZoom(mpWindow
->GetZoom() * 3 / 2);
328 if (mpViewShell
->ISA(DrawViewShell
))
329 static_cast<DrawViewShell
*>(mpViewShell
)
330 ->SetZoomOnPage(sal_False
);
339 if (!mpView
->IsTextEdit() && !bSlideShow
&& !mpDocSh
->IsUIActive())
342 mpViewShell
->SetZoom(mpWindow
->GetZoom() * 2 / 3);
344 if (mpViewShell
->ISA(DrawViewShell
))
345 static_cast<DrawViewShell
*>(mpViewShell
)
346 ->SetZoomOnPage(sal_False
);
355 if (!mpView
->IsTextEdit() && !bSlideShow
)
358 mpViewShell
->GetViewFrame()->GetDispatcher()->
359 Execute(SID_SIZE_PAGE
, SFX_CALLMODE_ASYNCHRON
| SFX_CALLMODE_RECORD
);
367 if (!mpView
->IsTextEdit() && !bSlideShow
)
369 // zoom to selected objects
370 mpViewShell
->GetViewFrame()->GetDispatcher()->
371 Execute(SID_SIZE_OPTIMAL
, SFX_CALLMODE_ASYNCHRON
| SFX_CALLMODE_RECORD
);
379 ZoomList
* pZoomList
= mpViewShell
->GetZoomList();
381 if (!mpView
->IsTextEdit() && pZoomList
->IsNextPossible() && !bSlideShow
&& !mpDocSh
->IsUIActive())
384 mpViewShell
->SetZoomRect(pZoomList
->GetNextZoomRect());
392 ZoomList
* pZoomList
= mpViewShell
->GetZoomList();
394 if (!mpView
->IsTextEdit() && pZoomList
->IsPreviousPossible() && !bSlideShow
&& !mpDocSh
->IsUIActive())
396 // use previous ZoomRect
397 mpViewShell
->SetZoomRect(pZoomList
->GetPreviousZoomRect());
405 if (!mpView
->IsTextEdit()
406 && mpViewShell
->ISA(DrawViewShell
)
409 // jump to first page
410 static_cast<DrawViewShell
*>(mpViewShell
)->SwitchPage(0);
418 if (!mpView
->IsTextEdit()
419 && mpViewShell
->ISA(DrawViewShell
)
424 static_cast<DrawViewShell
*>(mpViewShell
)->GetActualPage();
425 static_cast<DrawViewShell
*>(mpViewShell
)
426 ->SwitchPage(mpDoc
->GetSdPageCount(
427 pPage
->GetPageKind()) - 1);
435 if( rKEvt
.GetKeyCode().IsMod1() && rKEvt
.GetKeyCode().IsMod2() )
438 if(mpViewShell
->ISA(DrawViewShell
) && !bSlideShow
)
440 // The page-up key switches layers or pages depending on the
442 if ( ! rKEvt
.GetKeyCode().GetAllModifier())
444 // With no modifier pressed we move to the previous
446 mpView
->SdrEndTextEdit();
450 SdPage
* pPage
= static_cast<DrawViewShell
*>(mpViewShell
)->GetActualPage();
451 sal_uInt16 nSdPage
= (pPage
->GetPageNum() - 1) / 2;
455 // Switch the page and send events regarding
456 // deactivation the old page and activating the new
458 TabControl
* pPageTabControl
=
459 static_cast<DrawViewShell
*>(mpViewShell
)
460 ->GetPageTabControl();
461 if (pPageTabControl
->IsReallyShown())
462 pPageTabControl
->SendDeactivatePageEvent ();
463 static_cast<DrawViewShell
*>(mpViewShell
)->SwitchPage(nSdPage
- 1);
464 if (pPageTabControl
->IsReallyShown())
465 pPageTabControl
->SendActivatePageEvent ();
468 else if (rKEvt
.GetKeyCode().IsMod1())
470 // With the CONTROL modifier we switch layers.
471 if (static_cast<DrawViewShell
*>(mpViewShell
)->IsLayerModeActive())
473 // Moves to the previous layer.
483 if( rKEvt
.GetKeyCode().IsMod1() && rKEvt
.GetKeyCode().IsMod2() )
485 if(mpViewShell
->ISA(DrawViewShell
) && !bSlideShow
)
487 // The page-down key switches layers or pages depending on the
489 if ( ! rKEvt
.GetKeyCode().GetAllModifier())
491 // With no modifier pressed we move to the next slide.
492 mpView
->SdrEndTextEdit();
496 SdPage
* pPage
= static_cast<DrawViewShell
*>(mpViewShell
)->GetActualPage();
497 sal_uInt16 nSdPage
= (pPage
->GetPageNum() - 1) / 2;
499 if (nSdPage
< mpDoc
->GetSdPageCount(pPage
->GetPageKind()) - 1)
501 // Switch the page and send events regarding
502 // deactivation the old page and activating the new
504 TabControl
* pPageTabControl
=
505 static_cast<DrawViewShell
*>(mpViewShell
)->GetPageTabControl();
506 if (pPageTabControl
->IsReallyShown())
507 pPageTabControl
->SendDeactivatePageEvent ();
508 static_cast<DrawViewShell
*>(mpViewShell
)->SwitchPage(nSdPage
+ 1);
509 if (pPageTabControl
->IsReallyShown())
510 pPageTabControl
->SendActivatePageEvent ();
513 else if (rKEvt
.GetKeyCode().IsMod1())
515 // With the CONTROL modifier we switch layers.
516 if (static_cast<DrawViewShell
*>(mpViewShell
)->IsLayerModeActive())
518 // With the layer mode active pressing page-down
519 // moves to the next layer.
527 // change select state when focus is on poly point
530 const SdrHdlList
& rHdlList
= mpView
->GetHdlList();
531 SdrHdl
* pHdl
= rHdlList
.GetFocusHdl();
535 if(pHdl
->GetKind() == HDL_POLY
)
537 // rescue ID of point with focus
538 sal_uInt32
nPol(pHdl
->GetPolyNum());
539 sal_uInt32
nPnt(pHdl
->GetPointNum());
541 if(mpView
->IsPointMarked(*pHdl
))
543 if(rKEvt
.GetKeyCode().IsShift())
545 mpView
->UnmarkPoint(*pHdl
);
550 if(!rKEvt
.GetKeyCode().IsShift())
552 mpView
->UnmarkAllPoints();
555 mpView
->MarkPoint(*pHdl
);
558 if(0L == rHdlList
.GetFocusHdl())
560 // restore point with focus
561 SdrHdl
* pNewOne
= 0L;
563 for(sal_uInt32
a(0); !pNewOne
&& a
< rHdlList
.GetHdlCount(); a
++)
565 SdrHdl
* pAct
= rHdlList
.GetHdl(a
);
568 && pAct
->GetKind() == HDL_POLY
569 && pAct
->GetPolyNum() == nPol
570 && pAct
->GetPointNum() == nPnt
)
578 ((SdrHdlList
&)rHdlList
).SetFocusHdl(pNewOne
);
593 if (!mpView
->IsTextEdit() && !bSlideShow
)
604 else if (nCode
== KEY_DOWN
)
610 else if (nCode
== KEY_LEFT
)
616 else if (nCode
== KEY_RIGHT
)
623 if (mpView
->AreObjectsMarked() && !rKEvt
.GetKeyCode().IsMod1() &&
624 !mpDocSh
->IsReadOnly())
626 const SdrHdlList
& rHdlList
= mpView
->GetHdlList();
627 SdrHdl
* pHdl
= rHdlList
.GetFocusHdl();
629 sal_Bool
bIsMoveOfConnectedHandle(sal_False
);
630 sal_Bool bOldSuppress
= false;
631 SdrEdgeObj
* pEdgeObj
= 0L;
633 if(pHdl
&& pHdl
->GetObj() && pHdl
->GetObj()->ISA(SdrEdgeObj
) && 0 == pHdl
->GetPolyNum())
635 pEdgeObj
= (SdrEdgeObj
*)pHdl
->GetObj();
637 if(0L == pHdl
->GetPointNum())
639 if(pEdgeObj
->GetConnection(sal_True
).GetObject())
641 bIsMoveOfConnectedHandle
= sal_True
;
644 if(1L == pHdl
->GetPointNum())
646 if(pEdgeObj
->GetConnection(sal_False
).GetObject())
648 bIsMoveOfConnectedHandle
= sal_True
;
655 // Suppress default connects to inside object and object center
656 bOldSuppress
= pEdgeObj
->GetSuppressDefaultConnect();
657 pEdgeObj
->SetSuppressDefaultConnect(sal_True
);
660 if(bIsMoveOfConnectedHandle
)
662 sal_uInt16
nMarkHdSiz(mpView
->GetMarkHdlSizePixel());
663 Size
aHalfConSiz(nMarkHdSiz
+ 1, nMarkHdSiz
+ 1);
664 aHalfConSiz
= mpWindow
->PixelToLogic(aHalfConSiz
);
666 if(100 < aHalfConSiz
.Width())
667 nX
*= aHalfConSiz
.Width();
671 if(100 < aHalfConSiz
.Height())
672 nY
*= aHalfConSiz
.Height();
676 else if(rKEvt
.GetKeyCode().IsMod2())
678 // move in 1 pixel distance
679 Size aLogicSizeOnePixel
= (mpWindow
) ? mpWindow
->PixelToLogic(Size(1,1)) : Size(100, 100);
680 nX
*= aLogicSizeOnePixel
.Width();
681 nY
*= aLogicSizeOnePixel
.Height();
683 else if(rKEvt
.GetKeyCode().IsShift())
690 // old, fixed move distance
697 // only take action when move is allowed
698 if(mpView
->IsMoveAllowed())
700 // restrict movement to WorkArea
701 const Rectangle
& rWorkArea
= mpView
->GetWorkArea();
703 if(!rWorkArea
.IsEmpty())
705 Rectangle
aMarkRect(mpView
->GetMarkedObjRect());
706 aMarkRect
.Move(nX
, nY
);
708 if(!aMarkRect
.IsInside(rWorkArea
))
710 if(aMarkRect
.Left() < rWorkArea
.Left())
712 nX
+= rWorkArea
.Left() - aMarkRect
.Left();
715 if(aMarkRect
.Right() > rWorkArea
.Right())
717 nX
-= aMarkRect
.Right() - rWorkArea
.Right();
720 if(aMarkRect
.Top() < rWorkArea
.Top())
722 nY
+= rWorkArea
.Top() - aMarkRect
.Top();
725 if(aMarkRect
.Bottom() > rWorkArea
.Bottom())
727 nY
-= aMarkRect
.Bottom() - rWorkArea
.Bottom();
732 // no handle selected
733 if(0 != nX
|| 0 != nY
)
735 mpView
->MoveAllMarked(Size(nX
, nY
));
737 mpView
->MakeVisible(mpView
->GetAllMarkedRect(), *mpWindow
);
743 // move handle with index nHandleIndex
744 if(pHdl
&& (nX
|| nY
))
746 // now move the Handle (nX, nY)
747 Point
aStartPoint(pHdl
->GetPos());
748 Point
aEndPoint(pHdl
->GetPos() + Point(nX
, nY
));
749 const SdrDragStat
& rDragStat
= mpView
->GetDragStat();
752 mpView
->BegDragObj(aStartPoint
, 0, pHdl
, 0);
754 if(mpView
->IsDragObj())
756 bool bWasNoSnap
= rDragStat
.IsNoSnap();
757 sal_Bool bWasSnapEnabled
= mpView
->IsSnapEnabled();
759 // switch snapping off
761 ((SdrDragStat
&)rDragStat
).SetNoSnap(sal_True
);
763 mpView
->SetSnapEnabled(sal_False
);
765 mpView
->MovAction(aEndPoint
);
766 mpView
->EndDragObj();
770 ((SdrDragStat
&)rDragStat
).SetNoSnap(bWasNoSnap
);
772 mpView
->SetSnapEnabled(bWasSnapEnabled
);
775 // make moved handle visible
776 Rectangle
aVisRect(aEndPoint
- Point(100, 100), Size(200, 200));
777 mpView
->MakeVisible(aVisRect
, *mpWindow
);
783 // Restore original suppress value
784 pEdgeObj
->SetSuppressDefaultConnect(bOldSuppress
);
790 mpViewShell
->ScrollLines(nX
, nY
);
801 mpWindow
->ReleaseMouse();
804 // when a text-editable object is selected and the
805 // input character is printable, activate text edit on that object
806 // and feed character to object
807 if(!bReturn
&& !mpDocSh
->IsReadOnly())
809 if(!mpView
->IsTextEdit() && mpViewShell
)
811 const SdrMarkList
& rMarkList
= mpView
->GetMarkedObjectList();
813 if(1 == rMarkList
.GetMarkCount())
815 SdrObject
* pObj
= rMarkList
.GetMark(0)->GetMarkedSdrObj();
817 // #i118485# allow TextInput for OLEs, too
818 if(pObj
->ISA(SdrTextObj
) && pObj
->HasTextEdit())
820 // use common IsSimpleCharInput from the EditEngine.
821 sal_Bool
bPrintable(EditEngine::IsSimpleCharInput(rKEvt
));
825 // try to activate textedit mode for the selected object
826 SfxStringItem
aInputString(SID_ATTR_CHAR
, OUString(rKEvt
.GetCharCode()));
828 mpViewShell
->GetViewFrame()->GetDispatcher()->Execute(
830 SFX_CALLMODE_ASYNCHRON
,
841 // test if there is a title object there. If yes, try to
842 // set it to edit mode and start typing...
843 if(mpViewShell
->ISA(DrawViewShell
)
844 && EditEngine::IsSimpleCharInput(rKEvt
))
846 DrawViewShell
* pDrawViewShell
=
847 static_cast<DrawViewShell
*>(mpViewShell
);
848 SdPage
* pActualPage
= pDrawViewShell
->GetActualPage();
849 SdrTextObj
* pCandidate
= 0L;
853 SdrObjListIter
aIter(*pActualPage
, IM_DEEPNOGROUPS
);
855 while(aIter
.IsMore() && !pCandidate
)
857 SdrObject
* pObj
= aIter
.Next();
859 if(pObj
&& pObj
->ISA(SdrTextObj
))
861 sal_uInt32
nInv(pObj
->GetObjInventor());
862 sal_uInt16
nKnd(pObj
->GetObjIdentifier());
864 if(SdrInventor
== nInv
&& OBJ_TITLETEXT
== nKnd
)
866 pCandidate
= (SdrTextObj
*)pObj
;
872 // when candidate found and candidate is untouched, start editing text...
873 if(pCandidate
&& pCandidate
->IsEmptyPresObj())
876 mpView
->MarkObj(pCandidate
, mpView
->GetSdrPageView());
877 SfxStringItem
aInputString(SID_ATTR_CHAR
, OUString(rKEvt
.GetCharCode()));
879 mpViewShell
->GetViewFrame()->GetDispatcher()->Execute(
881 SFX_CALLMODE_ASYNCHRON
,
896 sal_Bool
FuPoor::MouseMove(const MouseEvent
& )
901 void FuPoor::SelectionHasChanged()
903 const SdrHdlList
& rHdlList
= mpView
->GetHdlList();
904 ((SdrHdlList
&)rHdlList
).ResetFocusHdl();
908 * Cut object to clipboard
914 mpView
->DoCut(mpWindow
);
919 * Copy object to clipboard
921 void FuPoor::DoCopy()
925 mpView
->DoCopy(mpWindow
);
930 * Paste object from clipboard
932 void FuPoor::DoPaste()
936 mpView
->DoPaste(mpWindow
);
941 * Timer handler for Drag&Drop
943 IMPL_LINK_NOARG(FuPoor
, DragHdl
)
947 sal_uInt16 nHitLog
= sal_uInt16 ( mpWindow
->PixelToLogic(Size(HITPIX
,0)).Width() );
948 SdrHdl
* pHdl
= mpView
->PickHandle(aMDPos
);
950 if ( pHdl
==NULL
&& mpView
->IsMarkedHit(aMDPos
, nHitLog
)
951 && !mpView
->IsPresObjSelected(sal_False
, sal_True
) )
953 mpWindow
->ReleaseMouse();
954 bIsInDragMode
= sal_True
;
955 mpView
->StartDrag( aMDPos
, mpWindow
);
961 sal_Bool
FuPoor::Command(const CommandEvent
& rCEvt
)
963 return( mpView
->Command(rCEvt
,mpWindow
) );
967 * Timer handler for window scrolling
969 IMPL_LINK_NOARG_INLINE_START(FuPoor
, DelayHdl
)
971 aDelayToScrollTimer
.Stop ();
972 bScrollable
= sal_True
;
974 Point
aPnt(mpWindow
->GetPointerPosPixel());
976 // use remembered MouseButton state to create correct
977 // MouseEvents for this artifical MouseMove.
978 MouseMove(MouseEvent(aPnt
, 1, 0, GetMouseButtonCode()));
982 IMPL_LINK_INLINE_END( FuPoor
, DelayHdl
, Timer
*, pTimer
)
984 sal_Bool
FuPoor::MouseButtonUp (const MouseEvent
& rMEvt
)
986 // remember button state for creation of own MouseEvents
987 SetMouseButtonCode(rMEvt
.GetButtons());
989 aDelayToScrollTimer
.Stop ();
991 bDelayActive
= sal_False
;
994 sal_Bool
FuPoor::MouseButtonDown(const MouseEvent
& rMEvt
)
996 // remember button state for creation of own MouseEvents
997 SetMouseButtonCode(rMEvt
.GetButtons());
1002 void FuPoor::StartDelayToScrollTimer ()
1004 bDelayActive
= sal_True
;
1005 aDelayToScrollTimer
.Start ();
1008 sal_Bool
FuPoor::RequestHelp(const HelpEvent
& rHEvt
)
1010 sal_Bool bReturn
= sal_False
;
1012 SdrPageView
* pPV
= mpView
->GetSdrPageView();
1016 SdPage
* pPage
= (SdPage
*) pPV
->GetPage();
1020 bReturn
= pPage
->RequestHelp(mpWindow
, mpView
, rHEvt
);
1027 void FuPoor::Paint(const Rectangle
&, ::sd::Window
* )
1031 void FuPoor::ReceiveRequest(SfxRequest
& rReq
)
1033 const SfxItemSet
* pSet
= rReq
.GetArgs();
1037 if( pSet
->GetItemState( nSlotId
) == SFX_ITEM_SET
)
1039 const SfxPoolItem
& rItem
= pSet
->Get( nSlotId
);
1041 if( rItem
.ISA( SfxAllEnumItem
) )
1043 nSlotValue
= ( ( const SfxAllEnumItem
& ) rItem
).GetValue();
1049 SdrObject
* FuPoor::CreateDefaultObject(const sal_uInt16
, const Rectangle
& )
1051 // empty base implementation
1055 void FuPoor::ImpForceQuadratic(Rectangle
& rRect
)
1057 if(rRect
.GetWidth() > rRect
.GetHeight())
1060 Point(rRect
.Left() + ((rRect
.GetWidth() - rRect
.GetHeight()) / 2), rRect
.Top()),
1061 Size(rRect
.GetHeight(), rRect
.GetHeight()));
1066 Point(rRect
.Left(), rRect
.Top() + ((rRect
.GetHeight() - rRect
.GetWidth()) / 2)),
1067 Size(rRect
.GetWidth(), rRect
.GetWidth()));
1074 void FuPoor::SwitchLayer (sal_Int32 nOffset
)
1076 if(mpViewShell
&& mpViewShell
->ISA(DrawViewShell
))
1078 DrawViewShell
* pDrawViewShell
=
1079 static_cast<DrawViewShell
*>(mpViewShell
);
1081 // Calculate the new index.
1082 sal_Int32 nIndex
= pDrawViewShell
->GetActiveTabLayerIndex() + nOffset
;
1084 // Make sure the new index lies inside the range of valid indices.
1087 else if (nIndex
>= pDrawViewShell
->GetTabLayerCount ())
1088 nIndex
= pDrawViewShell
->GetTabLayerCount() - 1;
1090 // Set the new active layer.
1091 if (nIndex
!= pDrawViewShell
->GetActiveTabLayerIndex ())
1093 LayerTabBar
* pLayerTabControl
=
1094 static_cast<DrawViewShell
*>(mpViewShell
)->GetLayerTabControl();
1095 if (pLayerTabControl
!= NULL
)
1096 pLayerTabControl
->SendDeactivatePageEvent ();
1098 pDrawViewShell
->SetActiveTabLayerIndex (nIndex
);
1100 if (pLayerTabControl
!= NULL
)
1101 pLayerTabControl
->SendActivatePageEvent ();
1106 /** is called when the currenct function should be aborted. <p>
1107 This is used when a function gets a KEY_ESCAPE but can also
1110 @returns true if a active function was aborted
1112 bool FuPoor::cancel()
1114 if ( !this->ISA(FuSelection
) )
1116 mpViewShell
->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT
, SFX_CALLMODE_ASYNCHRON
);
1124 bool FuPoor::doConstructOrthogonal() const
1127 SID_DRAW_XLINE
== nSlotId
||
1128 SID_DRAW_CIRCLEARC
== nSlotId
||
1129 SID_DRAW_SQUARE
== nSlotId
||
1130 SID_DRAW_SQUARE_NOFILL
== nSlotId
||
1131 SID_DRAW_SQUARE_ROUND
== nSlotId
||
1132 SID_DRAW_SQUARE_ROUND_NOFILL
== nSlotId
||
1133 SID_DRAW_CIRCLE
== nSlotId
||
1134 SID_DRAW_CIRCLE_NOFILL
== nSlotId
||
1135 SID_DRAW_CIRCLEPIE
== nSlotId
||
1136 SID_DRAW_CIRCLEPIE_NOFILL
== nSlotId
||
1137 SID_DRAW_CIRCLECUT
== nSlotId
||
1138 SID_DRAW_CIRCLECUT_NOFILL
== nSlotId
||
1139 SID_DRAW_XPOLYGON
== nSlotId
||
1140 SID_DRAW_XPOLYGON_NOFILL
== nSlotId
||
1141 SID_3D_CUBE
== nSlotId
||
1142 SID_3D_SPHERE
== nSlotId
||
1143 SID_3D_SHELL
== nSlotId
||
1144 SID_3D_HALF_SPHERE
== nSlotId
||
1145 SID_3D_TORUS
== nSlotId
||
1146 SID_3D_CYLINDER
== nSlotId
||
1147 SID_3D_CONE
== nSlotId
||
1148 SID_3D_PYRAMID
== nSlotId
);
1151 void FuPoor::DoExecute( SfxRequest
& )
1155 } // end of namespace sd
1157 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */