1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: fupoor.cxx,v $
10 * $Revision: 1.50.74.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
37 #include <svx/svxids.hrc>
38 #include <svtools/aeitem.hxx>
39 #include <svx/svdpagv.hxx>
40 #include <svx/svdoole2.hxx>
41 #include <svx/svdograf.hxx>
42 #include <vcl/seleng.hxx>
43 #include <sfx2/app.hxx>
44 #include <sfx2/dispatch.hxx>
45 #include <sfx2/bindings.hxx>
46 #include <sfx2/request.hxx>
47 #include <vcl/dialog.hxx>
48 #include <com/sun/star/beans/XPropertySet.hpp>
49 #include <com/sun/star/drawing/XLayer.hpp>
50 #include <com/sun/star/drawing/XLayerManager.hpp>
51 #include <com/sun/star/container/XChild.hpp>
52 #include <com/sun/star/embed/EmbedVerbs.hpp>
54 #ifndef SD_FRAMW_VIEW_HXX
55 #include "FrameView.hxx"
60 #include "drawview.hxx"
61 #include "DrawViewShell.hxx"
62 #ifndef SD_WINDOW_SHELL_HXX
65 #include "drawdoc.hxx"
66 #include "DrawDocShell.hxx"
67 #include "zoomlist.hxx"
69 #include "slideshow.hxx"
70 #include "LayerTabBar.hxx"
72 #include <sfx2/viewfrm.hxx>
75 #include <svx/svditer.hxx>
78 #include <svx/editeng.hxx>
80 using namespace ::com::sun::star
;
81 using ::com::sun::star::uno::Reference
;
87 /*************************************************************************
91 \************************************************************************/
97 SdDrawDocument
* pDrDoc
,
100 mpViewShell(pViewSh
),
102 mpDocSh( pDrDoc
->GetDocSh() ),
104 nSlotId( rReq
.GetSlot() ),
107 bIsInDragMode(FALSE
),
108 bNoScrollUntilInside (TRUE
),
110 bDelayActive (FALSE
),
111 // #95491# remember MouseButton state
114 ReceiveRequest(rReq
);
116 aScrollTimer
.SetTimeoutHdl( LINK(this, FuPoor
, ScrollHdl
) );
117 aScrollTimer
.SetTimeout(SELENG_AUTOREPEAT_INTERVAL
);
119 aDragTimer
.SetTimeoutHdl( LINK(this, FuPoor
, DragHdl
) );
120 aDragTimer
.SetTimeout(SELENG_DRAGDROP_TIMEOUT
);
122 aDelayToScrollTimer
.SetTimeoutHdl( LINK(this, FuPoor
, DelayHdl
) );
123 aDelayToScrollTimer
.SetTimeout(2000);
126 /*************************************************************************
130 \************************************************************************/
136 aDelayToScrollTimer
.Stop ();
142 /*************************************************************************
144 |* Function aktivieren
146 \************************************************************************/
148 void FuPoor::Activate()
156 /*************************************************************************
158 |* Function deaktivieren
160 \************************************************************************/
162 void FuPoor::Deactivate()
166 aDelayToScrollTimer
.Stop ();
168 bDelayActive
= FALSE
;
175 if (mpWindow
) mpWindow
->ReleaseMouse ();
178 /*************************************************************************
180 |* Scrollen bei Erreichen des Fensterrandes; wird von
181 |* MouseMove aufgerufen
183 \************************************************************************/
185 void FuPoor::ForceScroll(const Point
& aPixPos
)
189 if ( !mpView
->IsDragHelpLine() && !mpView
->IsSetPageOrg() &&
190 !SlideShow::IsRunning( mpViewShell
->GetViewShellBase() ) )
192 /* Size aSize = mpWindow->GetSizePixel();
193 short dx = 0, dy = 0;
195 if ( aPixPos.X() <= 0 ) dx = -1;
196 if ( aPixPos.X() >= aSize.Width() ) dx = 1;
197 if ( aPixPos.Y() <= 0 ) dy = -1;
198 if ( aPixPos.Y() >= aSize.Height() ) dy = 1;
200 Point aPos
= mpWindow
->OutputToScreenPixel(aPixPos
);
201 const Rectangle
& rRect
= mpViewShell
->GetAllWindowRect();
203 if ( bNoScrollUntilInside
)
205 if ( rRect
.IsInside(aPos
) )
206 bNoScrollUntilInside
= FALSE
;
210 short dx
= 0, dy
= 0;
212 if ( aPos
.X() <= rRect
.Left() ) dx
= -1;
213 if ( aPos
.X() >= rRect
.Right() ) dx
= 1;
214 if ( aPos
.Y() <= rRect
.Top() ) dy
= -1;
215 if ( aPos
.Y() >= rRect
.Bottom() ) dy
= 1;
217 if ( dx
!= 0 || dy
!= 0 )
221 // Scrollaktion in abgeleiteter Klasse
223 mpViewShell
->ScrollLines(dx
, dy
);
225 aScrollTimer
.Start();
227 else if (! bDelayActive
) StartDelayToScrollTimer ();
233 /*************************************************************************
235 |* Timer-Handler fuer Fensterscrolling
237 \************************************************************************/
239 IMPL_LINK_INLINE_START( FuPoor
, ScrollHdl
, Timer
*, EMPTYARG
)
241 Point
aPnt(mpWindow
->GetPointerPosPixel());
243 // #95491# use remembered MouseButton state to create correct
244 // MouseEvents for this artifical MouseMove.
245 MouseMove(MouseEvent(aPnt
, 1, 0, GetMouseButtonCode()));
249 IMPL_LINK_INLINE_END( FuPoor
, ScrollHdl
, Timer
*, pTimer
)
251 /*************************************************************************
253 |* String in Applikations-Statuszeile ausgeben
255 \************************************************************************/
257 void FuPoor::WriteStatus(const String
& )
261 /*************************************************************************
263 |* Tastaturereignisse bearbeiten
265 |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert TRUE, andernfalls
268 \************************************************************************/
270 BOOL
FuPoor::KeyInput(const KeyEvent
& rKEvt
)
272 USHORT nCode
= rKEvt
.GetKeyCode().GetCode();
273 BOOL bReturn
= FALSE
;
274 BOOL bSlideShow
= SlideShow::IsRunning( mpViewShell
->GetViewShellBase() );
281 if(rKEvt
.GetKeyCode().IsMod1())
283 if(mpViewShell
&& mpViewShell
->ISA(DrawViewShell
))
285 DrawViewShell
* pDrawViewShell
=
286 static_cast<DrawViewShell
*>(mpViewShell
);
287 SdPage
* pActualPage
= pDrawViewShell
->GetActualPage();
288 SdrTextObj
* pCandidate
= 0L;
292 SdrObjListIter
aIter(*pActualPage
, IM_DEEPNOGROUPS
);
294 while(aIter
.IsMore() && !pCandidate
)
296 SdrObject
* pObj
= aIter
.Next();
298 if(pObj
&& pObj
->ISA(SdrTextObj
))
300 sal_uInt32
nInv(pObj
->GetObjInventor());
301 sal_uInt16
nKnd(pObj
->GetObjIdentifier());
303 if(SdrInventor
== nInv
&&
304 (OBJ_TITLETEXT
== nKnd
|| OBJ_OUTLINETEXT
== nKnd
|| OBJ_TEXT
== nKnd
))
306 pCandidate
= (SdrTextObj
*)pObj
;
315 mpView
->MarkObj(pCandidate
, mpView
->GetSdrPageView());
317 mpViewShell
->GetViewFrame()->GetDispatcher()->Execute(
318 SID_ATTR_CHAR
, SFX_CALLMODE_ASYNCHRON
);
322 // insert a new page with the same page layout
323 mpViewShell
->GetViewFrame()->GetDispatcher()->Execute(
324 SID_INSERTPAGE_QUICK
, SFX_CALLMODE_ASYNCHRON
);
333 // #98255# activate OLE object on RETURN for selected object
334 // #98198# activate text edit on RETURN for selected object
335 const SdrMarkList
& rMarkList
= mpView
->GetMarkedObjectList();
337 if( !mpView
->IsTextEdit() && 1 == rMarkList
.GetMarkCount() )
339 SdrObject
* pObj
= rMarkList
.GetMark( 0 )->GetMarkedSdrObj();
341 if( pObj
&& pObj
->ISA( SdrOle2Obj
) && !mpDocSh
->IsUIActive() )
343 if(rKEvt
.GetKeyCode().IsShift())
344 mpViewShell
->ActivateObject( static_cast< SdrOle2Obj
* >( pObj
),
345 embed::EmbedVerbs::MS_OLEVERB_OPEN
);
347 mpViewShell
->ActivateObject( static_cast< SdrOle2Obj
* >( pObj
),
348 embed::EmbedVerbs::MS_OLEVERB_PRIMARY
);
350 else if( pObj
&& pObj
->IsEmptyPresObj() && pObj
->ISA( SdrGrafObj
) )
352 mpViewShell
->GetViewFrame()->GetDispatcher()->Execute( SID_INSERT_GRAPHIC
, SFX_CALLMODE_ASYNCHRON
| SFX_CALLMODE_RECORD
);
356 mpViewShell
->GetViewFrame()->GetDispatcher()->Execute( SID_ATTR_CHAR
, SFX_CALLMODE_ASYNCHRON
| SFX_CALLMODE_RECORD
);
369 // #98994# handle Mod1 and Mod2 to get travelling running on different systems
370 if(rKEvt
.GetKeyCode().IsMod1() || rKEvt
.GetKeyCode().IsMod2())
372 // #97016# II do something with a selected handle?
373 const SdrHdlList
& rHdlList
= mpView
->GetHdlList();
374 sal_Bool
bForward(!rKEvt
.GetKeyCode().IsShift());
376 ((SdrHdlList
&)rHdlList
).TravelFocusHdl(bForward
);
378 // guarantee visibility of focused handle
379 SdrHdl
* pHdl
= rHdlList
.GetFocusHdl();
383 Point
aHdlPosition(pHdl
->GetPos());
384 Rectangle
aVisRect(aHdlPosition
- Point(100, 100), Size(200, 200));
385 mpView
->MakeVisible(aVisRect
, *mpWindow
);
396 bReturn
= FuPoor::cancel();
402 if (!mpView
->IsTextEdit() && !bSlideShow
&& !mpDocSh
->IsUIActive())
405 mpViewShell
->SetZoom(mpWindow
->GetZoom() * 3 / 2);
407 if (mpViewShell
->ISA(DrawViewShell
))
408 static_cast<DrawViewShell
*>(mpViewShell
)
409 ->SetZoomOnPage(FALSE
);
418 if (!mpView
->IsTextEdit() && !bSlideShow
&& !mpDocSh
->IsUIActive())
421 mpViewShell
->SetZoom(mpWindow
->GetZoom() * 2 / 3);
423 if (mpViewShell
->ISA(DrawViewShell
))
424 static_cast<DrawViewShell
*>(mpViewShell
)
425 ->SetZoomOnPage(FALSE
);
434 if (!mpView
->IsTextEdit() && !bSlideShow
)
437 mpViewShell
->GetViewFrame()->GetDispatcher()->
438 Execute(SID_SIZE_PAGE
, SFX_CALLMODE_ASYNCHRON
| SFX_CALLMODE_RECORD
);
446 if (!mpView
->IsTextEdit() && !bSlideShow
)
448 // Zoom auf selektierte Objekte
449 mpViewShell
->GetViewFrame()->GetDispatcher()->
450 Execute(SID_SIZE_OPTIMAL
, SFX_CALLMODE_ASYNCHRON
| SFX_CALLMODE_RECORD
);
458 ZoomList
* pZoomList
= mpViewShell
->GetZoomList();
460 if (!mpView
->IsTextEdit() && pZoomList
->IsNextPossible() && !bSlideShow
&& !mpDocSh
->IsUIActive())
462 // Naechstes ZoomRect einstellen
463 mpViewShell
->SetZoomRect(pZoomList
->GetNextZoomRect());
471 ZoomList
* pZoomList
= mpViewShell
->GetZoomList();
473 if (!mpView
->IsTextEdit() && pZoomList
->IsPreviousPossible() && !bSlideShow
&& !mpDocSh
->IsUIActive())
475 // Vorheriges ZoomRect einstellen
476 mpViewShell
->SetZoomRect(pZoomList
->GetPreviousZoomRect());
484 if (!mpView
->IsTextEdit()
485 && mpViewShell
->ISA(DrawViewShell
)
488 // Sprung zu erster Seite
489 static_cast<DrawViewShell
*>(mpViewShell
)->SwitchPage(0);
497 if (!mpView
->IsTextEdit()
498 && mpViewShell
->ISA(DrawViewShell
)
501 // Sprung zu letzter Seite
503 static_cast<DrawViewShell
*>(mpViewShell
)->GetActualPage();
504 static_cast<DrawViewShell
*>(mpViewShell
)
505 ->SwitchPage(mpDoc
->GetSdPageCount(
506 pPage
->GetPageKind()) - 1);
514 if( rKEvt
.GetKeyCode().IsMod1() && rKEvt
.GetKeyCode().IsMod2() )
517 if(mpViewShell
->ISA(DrawViewShell
) && !bSlideShow
)
519 // The page-up key switches layers or pages depending on the
521 if ( ! rKEvt
.GetKeyCode().GetAllModifier())
523 // With no modifier pressed we move to the previous
525 mpView
->SdrEndTextEdit();
529 SdPage
* pPage
= static_cast<DrawViewShell
*>(mpViewShell
)->GetActualPage();
530 USHORT nSdPage
= (pPage
->GetPageNum() - 1) / 2;
534 // Switch the page and send events regarding
535 // deactivation the old page and activating the new
537 TabControl
* pPageTabControl
=
538 static_cast<DrawViewShell
*>(mpViewShell
)
539 ->GetPageTabControl();
540 if (pPageTabControl
->IsReallyShown())
541 pPageTabControl
->SendDeactivatePageEvent ();
542 static_cast<DrawViewShell
*>(mpViewShell
)->SwitchPage(nSdPage
- 1);
543 if (pPageTabControl
->IsReallyShown())
544 pPageTabControl
->SendActivatePageEvent ();
547 else if (rKEvt
.GetKeyCode().IsMod1())
549 // With the CONTROL modifier we switch layers.
550 if (static_cast<DrawViewShell
*>(mpViewShell
)->IsLayerModeActive())
552 // Moves to the previous layer.
562 if( rKEvt
.GetKeyCode().IsMod1() && rKEvt
.GetKeyCode().IsMod2() )
564 if(mpViewShell
->ISA(DrawViewShell
) && !bSlideShow
)
566 // The page-down key switches layers or pages depending on the
568 if ( ! rKEvt
.GetKeyCode().GetAllModifier())
570 // With no modifier pressed we move to the next slide.
571 mpView
->SdrEndTextEdit();
575 SdPage
* pPage
= static_cast<DrawViewShell
*>(mpViewShell
)->GetActualPage();
576 USHORT nSdPage
= (pPage
->GetPageNum() - 1) / 2;
578 if (nSdPage
< mpDoc
->GetSdPageCount(pPage
->GetPageKind()) - 1)
580 // Switch the page and send events regarding
581 // deactivation the old page and activating the new
583 TabControl
* pPageTabControl
=
584 static_cast<DrawViewShell
*>(mpViewShell
)->GetPageTabControl();
585 if (pPageTabControl
->IsReallyShown())
586 pPageTabControl
->SendDeactivatePageEvent ();
587 static_cast<DrawViewShell
*>(mpViewShell
)->SwitchPage(nSdPage
+ 1);
588 if (pPageTabControl
->IsReallyShown())
589 pPageTabControl
->SendActivatePageEvent ();
592 else if (rKEvt
.GetKeyCode().IsMod1())
594 // With the CONTROL modifier we switch layers.
595 if (static_cast<DrawViewShell
*>(mpViewShell
)->IsLayerModeActive())
597 // With the layer mode active pressing page-down
598 // moves to the next layer.
606 // #97016# II change select state when focus is on poly point
609 const SdrHdlList
& rHdlList
= mpView
->GetHdlList();
610 SdrHdl
* pHdl
= rHdlList
.GetFocusHdl();
614 if(pHdl
->GetKind() == HDL_POLY
)
616 // rescue ID of point with focus
617 sal_uInt32
nPol(pHdl
->GetPolyNum());
618 sal_uInt32
nPnt(pHdl
->GetPointNum());
620 if(mpView
->IsPointMarked(*pHdl
))
622 if(rKEvt
.GetKeyCode().IsShift())
624 mpView
->UnmarkPoint(*pHdl
);
629 if(!rKEvt
.GetKeyCode().IsShift())
631 mpView
->UnmarkAllPoints();
634 mpView
->MarkPoint(*pHdl
);
637 if(0L == rHdlList
.GetFocusHdl())
639 // restore point with focus
640 SdrHdl
* pNewOne
= 0L;
642 for(sal_uInt32
a(0); !pNewOne
&& a
< rHdlList
.GetHdlCount(); a
++)
644 SdrHdl
* pAct
= rHdlList
.GetHdl(a
);
647 && pAct
->GetKind() == HDL_POLY
648 && pAct
->GetPolyNum() == nPol
649 && pAct
->GetPointNum() == nPnt
)
657 ((SdrHdlList
&)rHdlList
).SetFocusHdl(pNewOne
);
672 if (!mpView
->IsTextEdit() && !bSlideShow
)
683 else if (nCode
== KEY_DOWN
)
689 else if (nCode
== KEY_LEFT
)
695 else if (nCode
== KEY_RIGHT
)
697 // Scroll nach rechts
702 if (mpView
->AreObjectsMarked() && !rKEvt
.GetKeyCode().IsMod1() &&
703 !mpDocSh
->IsReadOnly())
706 const SdrHdlList
& rHdlList
= mpView
->GetHdlList();
707 SdrHdl
* pHdl
= rHdlList
.GetFocusHdl();
710 sal_Bool
bIsMoveOfConnectedHandle(sal_False
);
711 sal_Bool bOldSuppress
= false;
712 SdrEdgeObj
* pEdgeObj
= 0L;
714 if(pHdl
&& pHdl
->GetObj() && pHdl
->GetObj()->ISA(SdrEdgeObj
) && 0 == pHdl
->GetPolyNum())
716 pEdgeObj
= (SdrEdgeObj
*)pHdl
->GetObj();
718 if(0L == pHdl
->GetPointNum())
720 if(pEdgeObj
->GetConnection(sal_True
).GetObject())
722 bIsMoveOfConnectedHandle
= sal_True
;
725 if(1L == pHdl
->GetPointNum())
727 if(pEdgeObj
->GetConnection(sal_False
).GetObject())
729 bIsMoveOfConnectedHandle
= sal_True
;
737 // Suppress default connects to inside object and object center
738 bOldSuppress
= pEdgeObj
->GetSuppressDefaultConnect();
739 pEdgeObj
->SetSuppressDefaultConnect(sal_True
);
743 if(bIsMoveOfConnectedHandle
)
745 sal_uInt16
nMarkHdSiz(mpView
->GetMarkHdlSizePixel());
746 Size
aHalfConSiz(nMarkHdSiz
+ 1, nMarkHdSiz
+ 1);
747 aHalfConSiz
= mpWindow
->PixelToLogic(aHalfConSiz
);
749 if(100 < aHalfConSiz
.Width())
750 nX
*= aHalfConSiz
.Width();
754 if(100 < aHalfConSiz
.Height())
755 nY
*= aHalfConSiz
.Height();
759 else if(rKEvt
.GetKeyCode().IsMod2())
761 // #97016# move in 1 pixel distance
762 Size aLogicSizeOnePixel
= (mpWindow
) ? mpWindow
->PixelToLogic(Size(1,1)) : Size(100, 100);
763 nX
*= aLogicSizeOnePixel
.Width();
764 nY
*= aLogicSizeOnePixel
.Height();
766 else if(rKEvt
.GetKeyCode().IsShift())
773 // old, fixed move distance
780 // #67368# only take action when move is allowed
781 if(mpView
->IsMoveAllowed())
783 // #90129# restrict movement to WorkArea
784 const Rectangle
& rWorkArea
= mpView
->GetWorkArea();
786 if(!rWorkArea
.IsEmpty())
788 Rectangle
aMarkRect(mpView
->GetMarkedObjRect());
789 aMarkRect
.Move(nX
, nY
);
791 if(!aMarkRect
.IsInside(rWorkArea
))
793 if(aMarkRect
.Left() < rWorkArea
.Left())
795 nX
+= rWorkArea
.Left() - aMarkRect
.Left();
798 if(aMarkRect
.Right() > rWorkArea
.Right())
800 nX
-= aMarkRect
.Right() - rWorkArea
.Right();
803 if(aMarkRect
.Top() < rWorkArea
.Top())
805 nY
+= rWorkArea
.Top() - aMarkRect
.Top();
808 if(aMarkRect
.Bottom() > rWorkArea
.Bottom())
810 nY
-= aMarkRect
.Bottom() - rWorkArea
.Bottom();
815 // no handle selected
816 if(0 != nX
|| 0 != nY
)
818 mpView
->MoveAllMarked(Size(nX
, nY
));
821 mpView
->MakeVisible(mpView
->GetAllMarkedRect(), *mpWindow
);
827 // move handle with index nHandleIndex
828 if(pHdl
&& (nX
|| nY
))
830 // now move the Handle (nX, nY)
831 Point
aStartPoint(pHdl
->GetPos());
832 Point
aEndPoint(pHdl
->GetPos() + Point(nX
, nY
));
833 const SdrDragStat
& rDragStat
= mpView
->GetDragStat();
836 mpView
->BegDragObj(aStartPoint
, 0, pHdl
, 0);
838 if(mpView
->IsDragObj())
840 FASTBOOL bWasNoSnap
= rDragStat
.IsNoSnap();
841 BOOL bWasSnapEnabled
= mpView
->IsSnapEnabled();
843 // switch snapping off
845 ((SdrDragStat
&)rDragStat
).SetNoSnap(TRUE
);
847 mpView
->SetSnapEnabled(FALSE
);
849 mpView
->MovAction(aEndPoint
);
850 mpView
->EndDragObj();
854 ((SdrDragStat
&)rDragStat
).SetNoSnap(bWasNoSnap
);
856 mpView
->SetSnapEnabled(bWasSnapEnabled
);
859 // make moved handle visible
860 Rectangle
aVisRect(aEndPoint
- Point(100, 100), Size(200, 200));
861 mpView
->MakeVisible(aVisRect
, *mpWindow
);
868 // Restore original suppress value
869 pEdgeObj
->SetSuppressDefaultConnect(bOldSuppress
);
876 mpViewShell
->ScrollLines(nX
, nY
);
888 mpWindow
->ReleaseMouse();
891 // #98198# when a text-editable object is selected and the
892 // input character is printable, activate text edit on that object
893 // and feed character to object
894 if(!bReturn
&& !mpDocSh
->IsReadOnly())
896 if(!mpView
->IsTextEdit() && mpViewShell
)
898 const SdrMarkList
& rMarkList
= mpView
->GetMarkedObjectList();
900 if(1 == rMarkList
.GetMarkCount())
902 SdrObject
* pObj
= rMarkList
.GetMark(0)->GetMarkedSdrObj();
904 if(pObj
->ISA(SdrTextObj
) && pObj
->HasTextEdit() && !pObj
->ISA(SdrOle2Obj
))
906 // #98533# use common IsSimpleCharInput from
908 sal_Bool
bPrintable(EditEngine::IsSimpleCharInput(rKEvt
));
912 // try to activate textedit mode for the selected object
913 SfxStringItem
aInputString(SID_ATTR_CHAR
, String(rKEvt
.GetCharCode()));
915 mpViewShell
->GetViewFrame()->GetDispatcher()->Execute(
917 SFX_CALLMODE_ASYNCHRON
,
928 // #99039# test if there is a title object there. If yes, try to
929 // set it to edit mode and start typing...
930 if(mpViewShell
->ISA(DrawViewShell
)
931 && EditEngine::IsSimpleCharInput(rKEvt
))
933 DrawViewShell
* pDrawViewShell
=
934 static_cast<DrawViewShell
*>(mpViewShell
);
935 SdPage
* pActualPage
= pDrawViewShell
->GetActualPage();
936 SdrTextObj
* pCandidate
= 0L;
940 SdrObjListIter
aIter(*pActualPage
, IM_DEEPNOGROUPS
);
942 while(aIter
.IsMore() && !pCandidate
)
944 SdrObject
* pObj
= aIter
.Next();
946 if(pObj
&& pObj
->ISA(SdrTextObj
))
948 sal_uInt32
nInv(pObj
->GetObjInventor());
949 sal_uInt16
nKnd(pObj
->GetObjIdentifier());
951 if(SdrInventor
== nInv
&& OBJ_TITLETEXT
== nKnd
)
953 pCandidate
= (SdrTextObj
*)pObj
;
959 // when candidate found and candidate is untouched, start editing text...
960 if(pCandidate
&& pCandidate
->IsEmptyPresObj())
963 mpView
->MarkObj(pCandidate
, mpView
->GetSdrPageView());
964 SfxStringItem
aInputString(SID_ATTR_CHAR
, String(rKEvt
.GetCharCode()));
966 mpViewShell
->GetViewFrame()->GetDispatcher()->Execute(
968 SFX_CALLMODE_ASYNCHRON
,
983 BOOL
FuPoor::MouseMove(const MouseEvent
& )
989 void FuPoor::SelectionHasChanged()
991 const SdrHdlList
& rHdlList
= mpView
->GetHdlList();
992 ((SdrHdlList
&)rHdlList
).ResetFocusHdl();
995 /*************************************************************************
997 |* Cut object to clipboard
999 \************************************************************************/
1001 void FuPoor::DoCut()
1005 mpView
->DoCut(mpWindow
);
1009 /*************************************************************************
1011 |* Copy object to clipboard
1013 \************************************************************************/
1015 void FuPoor::DoCopy()
1019 mpView
->DoCopy(mpWindow
);
1023 /*************************************************************************
1025 |* Paste object from clipboard
1027 \************************************************************************/
1029 void FuPoor::DoPaste()
1033 mpView
->DoPaste(mpWindow
);
1037 /*************************************************************************
1039 |* Timer-Handler fuer Drag&Drop
1041 \************************************************************************/
1043 IMPL_LINK( FuPoor
, DragHdl
, Timer
*, EMPTYARG
)
1047 USHORT nHitLog
= USHORT ( mpWindow
->PixelToLogic(Size(HITPIX
,0)).Width() );
1048 SdrHdl
* pHdl
= mpView
->PickHandle(aMDPos
);
1050 if ( pHdl
==NULL
&& mpView
->IsMarkedHit(aMDPos
, nHitLog
)
1051 && !mpView
->IsPresObjSelected(FALSE
, TRUE
) )
1053 mpWindow
->ReleaseMouse();
1054 bIsInDragMode
= TRUE
;
1055 mpView
->StartDrag( aMDPos
, mpWindow
);
1061 /*************************************************************************
1065 \************************************************************************/
1067 BOOL
FuPoor::Command(const CommandEvent
& rCEvt
)
1069 return( mpView
->Command(rCEvt
,mpWindow
) );
1072 /*************************************************************************
1074 |* Timer-Handler fuer Fensterscrolling
1076 \************************************************************************/
1078 IMPL_LINK_INLINE_START( FuPoor
, DelayHdl
, Timer
*, EMPTYARG
)
1080 aDelayToScrollTimer
.Stop ();
1083 Point
aPnt(mpWindow
->GetPointerPosPixel());
1085 // #95491# use remembered MouseButton state to create correct
1086 // MouseEvents for this artifical MouseMove.
1087 MouseMove(MouseEvent(aPnt
, 1, 0, GetMouseButtonCode()));
1091 IMPL_LINK_INLINE_END( FuPoor
, DelayHdl
, Timer
*, pTimer
)
1093 /*************************************************************************
1095 |* Handler fuer Maustaste
1097 \************************************************************************/
1099 BOOL
FuPoor::MouseButtonUp (const MouseEvent
& rMEvt
)
1101 // #95491# remember button state for creation of own MouseEvents
1102 SetMouseButtonCode(rMEvt
.GetButtons());
1104 aDelayToScrollTimer
.Stop ();
1105 return bScrollable
=
1106 bDelayActive
= FALSE
;
1109 BOOL
FuPoor::MouseButtonDown(const MouseEvent
& rMEvt
)
1111 // #95491# remember button state for creation of own MouseEvents
1112 SetMouseButtonCode(rMEvt
.GetButtons());
1117 /*************************************************************************
1119 |* Handler fuer Maustaste
1121 \************************************************************************/
1123 void FuPoor::StartDelayToScrollTimer ()
1125 bDelayActive
= TRUE
;
1126 aDelayToScrollTimer
.Start ();
1129 /*************************************************************************
1131 |* Handler fuer Maustaste
1133 \************************************************************************/
1135 long FuPoor::diffPoint (long pos1
, long pos2
)
1137 return (pos1
> pos2
) ? pos1
- pos2
1141 /*************************************************************************
1145 \************************************************************************/
1147 BOOL
FuPoor::RequestHelp(const HelpEvent
& rHEvt
)
1149 BOOL bReturn
= FALSE
;
1151 SdrPageView
* pPV
= mpView
->GetSdrPageView();
1155 SdPage
* pPage
= (SdPage
*) pPV
->GetPage();
1159 bReturn
= pPage
->RequestHelp(mpWindow
, mpView
, rHEvt
);
1166 void FuPoor::Paint(const Rectangle
&, ::sd::Window
* )
1170 /*************************************************************************
1172 |* Request verarbeiten
1174 \************************************************************************/
1176 void FuPoor::ReceiveRequest(SfxRequest
& rReq
)
1178 const SfxItemSet
* pSet
= rReq
.GetArgs();
1182 if( pSet
->GetItemState( nSlotId
) == SFX_ITEM_SET
)
1184 const SfxPoolItem
& rItem
= pSet
->Get( nSlotId
);
1186 if( rItem
.ISA( SfxAllEnumItem
) )
1188 nSlotValue
= ( ( const SfxAllEnumItem
& ) rItem
).GetValue();
1194 /*************************************************************************
1198 \************************************************************************/
1200 SdrObject
* FuPoor::CreateDefaultObject(const sal_uInt16
, const Rectangle
& )
1202 // empty base implementation
1206 void FuPoor::ImpForceQuadratic(Rectangle
& rRect
)
1208 if(rRect
.GetWidth() > rRect
.GetHeight())
1211 Point(rRect
.Left() + ((rRect
.GetWidth() - rRect
.GetHeight()) / 2), rRect
.Top()),
1212 Size(rRect
.GetHeight(), rRect
.GetHeight()));
1217 Point(rRect
.Left(), rRect
.Top() + ((rRect
.GetHeight() - rRect
.GetWidth()) / 2)),
1218 Size(rRect
.GetWidth(), rRect
.GetWidth()));
1225 void FuPoor::SwitchLayer (sal_Int32 nOffset
)
1227 if(mpViewShell
&& mpViewShell
->ISA(DrawViewShell
))
1229 DrawViewShell
* pDrawViewShell
=
1230 static_cast<DrawViewShell
*>(mpViewShell
);
1232 // Calculate the new index.
1233 sal_Int32 nIndex
= pDrawViewShell
->GetActiveTabLayerIndex() + nOffset
;
1235 // Make sure the new index lies inside the range of valid indices.
1238 else if (nIndex
>= pDrawViewShell
->GetTabLayerCount ())
1239 nIndex
= pDrawViewShell
->GetTabLayerCount() - 1;
1241 // Set the new active layer.
1242 if (nIndex
!= pDrawViewShell
->GetActiveTabLayerIndex ())
1244 LayerTabBar
* pLayerTabControl
=
1245 static_cast<DrawViewShell
*>(mpViewShell
)->GetLayerTabControl();
1246 if (pLayerTabControl
!= NULL
)
1247 pLayerTabControl
->SendDeactivatePageEvent ();
1249 pDrawViewShell
->SetActiveTabLayerIndex (nIndex
);
1251 if (pLayerTabControl
!= NULL
)
1252 pLayerTabControl
->SendActivatePageEvent ();
1257 /** is called when the currenct function should be aborted. <p>
1258 This is used when a function gets a KEY_ESCAPE but can also
1261 @returns true if a active function was aborted
1263 bool FuPoor::cancel()
1265 if ( !this->ISA(FuSelection
) )
1267 mpViewShell
->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT
, SFX_CALLMODE_ASYNCHRON
);
1275 bool FuPoor::doConstructOrthogonal() const
1278 SID_DRAW_XLINE
== nSlotId
||
1279 SID_DRAW_CIRCLEARC
== nSlotId
||
1280 SID_DRAW_SQUARE
== nSlotId
||
1281 SID_DRAW_SQUARE_NOFILL
== nSlotId
||
1282 SID_DRAW_SQUARE_ROUND
== nSlotId
||
1283 SID_DRAW_SQUARE_ROUND_NOFILL
== nSlotId
||
1284 SID_DRAW_CIRCLE
== nSlotId
||
1285 SID_DRAW_CIRCLE_NOFILL
== nSlotId
||
1286 SID_DRAW_CIRCLEPIE
== nSlotId
||
1287 SID_DRAW_CIRCLEPIE_NOFILL
== nSlotId
||
1288 SID_DRAW_CIRCLECUT
== nSlotId
||
1289 SID_DRAW_CIRCLECUT_NOFILL
== nSlotId
||
1290 SID_DRAW_XPOLYGON
== nSlotId
||
1291 SID_DRAW_XPOLYGON_NOFILL
== nSlotId
||
1292 SID_3D_CUBE
== nSlotId
||
1293 SID_3D_SPHERE
== nSlotId
||
1294 SID_3D_SHELL
== nSlotId
||
1295 SID_3D_HALF_SPHERE
== nSlotId
||
1296 SID_3D_TORUS
== nSlotId
||
1297 SID_3D_CYLINDER
== nSlotId
||
1298 SID_3D_CONE
== nSlotId
||
1299 SID_3D_PYRAMID
== nSlotId
);
1302 void FuPoor::DoExecute( SfxRequest
& )
1306 } // end of namespace sd