update dev300-m58
[ooovba.git] / sd / source / ui / func / fupoor.cxx
blob12fa4db54356977fd3c9211bdabbb3241a01302d
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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"
35 #include "fupoor.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"
56 #endif
57 #include "app.hrc"
58 #include "fusel.hxx"
59 #include "sdpage.hxx"
60 #include "drawview.hxx"
61 #include "DrawViewShell.hxx"
62 #ifndef SD_WINDOW_SHELL_HXX
63 #include "Window.hxx"
64 #endif
65 #include "drawdoc.hxx"
66 #include "DrawDocShell.hxx"
67 #include "zoomlist.hxx"
68 #include "Client.hxx"
69 #include "slideshow.hxx"
70 #include "LayerTabBar.hxx"
72 #include <sfx2/viewfrm.hxx>
74 // #97016# IV
75 #include <svx/svditer.hxx>
77 // #98533#
78 #include <svx/editeng.hxx>
80 using namespace ::com::sun::star;
81 using ::com::sun::star::uno::Reference;
83 namespace sd {
85 TYPEINIT0( FuPoor );
87 /*************************************************************************
89 |* Konstruktor
91 \************************************************************************/
93 FuPoor::FuPoor (
94 ViewShell* pViewSh,
95 ::sd::Window* pWin,
96 ::sd::View* pView,
97 SdDrawDocument* pDrDoc,
98 SfxRequest& rReq)
99 : mpView(pView),
100 mpViewShell(pViewSh),
101 mpWindow(pWin),
102 mpDocSh( pDrDoc->GetDocSh() ),
103 mpDoc(pDrDoc),
104 nSlotId( rReq.GetSlot() ),
105 nSlotValue(0),
106 pDialog(NULL),
107 bIsInDragMode(FALSE),
108 bNoScrollUntilInside (TRUE),
109 bScrollable (FALSE),
110 bDelayActive (FALSE),
111 // #95491# remember MouseButton state
112 mnCode(0)
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 /*************************************************************************
128 |* Destruktor
130 \************************************************************************/
132 FuPoor::~FuPoor()
134 aDragTimer.Stop();
135 aScrollTimer.Stop();
136 aDelayToScrollTimer.Stop ();
138 if (pDialog)
139 delete pDialog;
142 /*************************************************************************
144 |* Function aktivieren
146 \************************************************************************/
148 void FuPoor::Activate()
150 if (pDialog)
152 pDialog->Show();
156 /*************************************************************************
158 |* Function deaktivieren
160 \************************************************************************/
162 void FuPoor::Deactivate()
164 aDragTimer.Stop();
165 aScrollTimer.Stop();
166 aDelayToScrollTimer.Stop ();
167 bScrollable =
168 bDelayActive = FALSE;
170 if (pDialog)
172 pDialog->Hide();
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)
187 aScrollTimer.Stop();
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;
208 else
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 )
219 if (bScrollable)
221 // Scrollaktion in abgeleiteter Klasse
222 ScrollStart();
223 mpViewShell->ScrollLines(dx, dy);
224 ScrollEnd();
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()));
247 return 0;
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
266 |* FALSE.
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() );
276 switch (nCode)
278 // #97016# IV
279 case KEY_RETURN:
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;
290 if(pActualPage)
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;
312 if(pCandidate)
314 mpView->UnMarkAll();
315 mpView->MarkObj(pCandidate, mpView->GetSdrPageView());
317 mpViewShell->GetViewFrame()->GetDispatcher()->Execute(
318 SID_ATTR_CHAR, SFX_CALLMODE_ASYNCHRON);
320 else
322 // insert a new page with the same page layout
323 mpViewShell->GetViewFrame()->GetDispatcher()->Execute(
324 SID_INSERTPAGE_QUICK, SFX_CALLMODE_ASYNCHRON);
327 // consumed
328 bReturn = TRUE;
331 else
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 );
346 else
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 );
354 else
356 mpViewShell->GetViewFrame()->GetDispatcher()->Execute( SID_ATTR_CHAR, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD );
359 // consumed
360 bReturn = TRUE;
364 break;
366 // #97016# II
367 case KEY_TAB:
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();
381 if(pHdl)
383 Point aHdlPosition(pHdl->GetPos());
384 Rectangle aVisRect(aHdlPosition - Point(100, 100), Size(200, 200));
385 mpView->MakeVisible(aVisRect, *mpWindow);
388 // consumed
389 bReturn = TRUE;
392 break;
394 case KEY_ESCAPE:
396 bReturn = FuPoor::cancel();
398 break;
400 case KEY_ADD:
402 if (!mpView->IsTextEdit() && !bSlideShow && !mpDocSh->IsUIActive())
404 // Zoom vergroessern
405 mpViewShell->SetZoom(mpWindow->GetZoom() * 3 / 2);
407 if (mpViewShell->ISA(DrawViewShell))
408 static_cast<DrawViewShell*>(mpViewShell)
409 ->SetZoomOnPage(FALSE);
411 bReturn = TRUE;
414 break;
416 case KEY_SUBTRACT:
418 if (!mpView->IsTextEdit() && !bSlideShow && !mpDocSh->IsUIActive())
420 // Zoom verringern
421 mpViewShell->SetZoom(mpWindow->GetZoom() * 2 / 3);
423 if (mpViewShell->ISA(DrawViewShell))
424 static_cast<DrawViewShell*>(mpViewShell)
425 ->SetZoomOnPage(FALSE);
427 bReturn = TRUE;
430 break;
432 case KEY_MULTIPLY:
434 if (!mpView->IsTextEdit() && !bSlideShow)
436 // Zoom auf Seite
437 mpViewShell->GetViewFrame()->GetDispatcher()->
438 Execute(SID_SIZE_PAGE, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
439 bReturn = TRUE;
442 break;
444 case KEY_DIVIDE:
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);
451 bReturn = TRUE;
454 break;
456 case KEY_POINT:
458 ZoomList* pZoomList = mpViewShell->GetZoomList();
460 if (!mpView->IsTextEdit() && pZoomList->IsNextPossible() && !bSlideShow && !mpDocSh->IsUIActive())
462 // Naechstes ZoomRect einstellen
463 mpViewShell->SetZoomRect(pZoomList->GetNextZoomRect());
464 bReturn = TRUE;
467 break;
469 case KEY_COMMA:
471 ZoomList* pZoomList = mpViewShell->GetZoomList();
473 if (!mpView->IsTextEdit() && pZoomList->IsPreviousPossible() && !bSlideShow && !mpDocSh->IsUIActive())
475 // Vorheriges ZoomRect einstellen
476 mpViewShell->SetZoomRect(pZoomList->GetPreviousZoomRect());
477 bReturn = TRUE;
480 break;
482 case KEY_HOME:
484 if (!mpView->IsTextEdit()
485 && mpViewShell->ISA(DrawViewShell)
486 && !bSlideShow)
488 // Sprung zu erster Seite
489 static_cast<DrawViewShell*>(mpViewShell)->SwitchPage(0);
490 bReturn = TRUE;
493 break;
495 case KEY_END:
497 if (!mpView->IsTextEdit()
498 && mpViewShell->ISA(DrawViewShell)
499 && !bSlideShow)
501 // Sprung zu letzter Seite
502 SdPage* pPage =
503 static_cast<DrawViewShell*>(mpViewShell)->GetActualPage();
504 static_cast<DrawViewShell*>(mpViewShell)
505 ->SwitchPage(mpDoc->GetSdPageCount(
506 pPage->GetPageKind()) - 1);
507 bReturn = TRUE;
510 break;
512 case KEY_PAGEUP:
514 if(mpViewShell->ISA(DrawViewShell) && !bSlideShow)
516 // The page-up key switches layers or pages depending on the
517 // modifier key.
518 if ( ! rKEvt.GetKeyCode().GetAllModifier())
520 // With no modifier pressed we move to the previous
521 // slide.
522 mpView->SdrEndTextEdit();
524 // Previous page.
525 bReturn = TRUE;
526 SdPage* pPage = static_cast<DrawViewShell*>(mpViewShell)->GetActualPage();
527 USHORT nSdPage = (pPage->GetPageNum() - 1) / 2;
529 if (nSdPage > 0)
531 // Switch the page and send events regarding
532 // deactivation the old page and activating the new
533 // one.
534 TabControl* pPageTabControl =
535 static_cast<DrawViewShell*>(mpViewShell)
536 ->GetPageTabControl();
537 if (pPageTabControl->IsReallyShown())
538 pPageTabControl->SendDeactivatePageEvent ();
539 static_cast<DrawViewShell*>(mpViewShell)->SwitchPage(nSdPage - 1);
540 if (pPageTabControl->IsReallyShown())
541 pPageTabControl->SendActivatePageEvent ();
544 else if (rKEvt.GetKeyCode().IsMod1())
546 // With the CONTROL modifier we switch layers.
547 if (static_cast<DrawViewShell*>(mpViewShell)->IsLayerModeActive())
549 // Moves to the previous layer.
550 SwitchLayer (-1);
555 break;
557 case KEY_PAGEDOWN:
559 if(mpViewShell->ISA(DrawViewShell) && !bSlideShow)
561 // The page-down key switches layers or pages depending on the
562 // modifier key.
563 if ( ! rKEvt.GetKeyCode().GetAllModifier())
565 // With no modifier pressed we move to the next slide.
566 mpView->SdrEndTextEdit();
568 // Next page.
569 bReturn = TRUE;
570 SdPage* pPage = static_cast<DrawViewShell*>(mpViewShell)->GetActualPage();
571 USHORT nSdPage = (pPage->GetPageNum() - 1) / 2;
573 if (nSdPage < mpDoc->GetSdPageCount(pPage->GetPageKind()) - 1)
575 // Switch the page and send events regarding
576 // deactivation the old page and activating the new
577 // one.
578 TabControl* pPageTabControl =
579 static_cast<DrawViewShell*>(mpViewShell)->GetPageTabControl();
580 if (pPageTabControl->IsReallyShown())
581 pPageTabControl->SendDeactivatePageEvent ();
582 static_cast<DrawViewShell*>(mpViewShell)->SwitchPage(nSdPage + 1);
583 if (pPageTabControl->IsReallyShown())
584 pPageTabControl->SendActivatePageEvent ();
587 else if (rKEvt.GetKeyCode().IsMod1())
589 // With the CONTROL modifier we switch layers.
590 if (static_cast<DrawViewShell*>(mpViewShell)->IsLayerModeActive())
592 // With the layer mode active pressing page-down
593 // moves to the next layer.
594 SwitchLayer (+1);
599 break;
601 // #97016# II change select state when focus is on poly point
602 case KEY_SPACE:
604 const SdrHdlList& rHdlList = mpView->GetHdlList();
605 SdrHdl* pHdl = rHdlList.GetFocusHdl();
607 if(pHdl)
609 if(pHdl->GetKind() == HDL_POLY)
611 // rescue ID of point with focus
612 sal_uInt32 nPol(pHdl->GetPolyNum());
613 sal_uInt32 nPnt(pHdl->GetPointNum());
615 if(mpView->IsPointMarked(*pHdl))
617 if(rKEvt.GetKeyCode().IsShift())
619 mpView->UnmarkPoint(*pHdl);
622 else
624 if(!rKEvt.GetKeyCode().IsShift())
626 mpView->UnmarkAllPoints();
629 mpView->MarkPoint(*pHdl);
632 if(0L == rHdlList.GetFocusHdl())
634 // restore point with focus
635 SdrHdl* pNewOne = 0L;
637 for(sal_uInt32 a(0); !pNewOne && a < rHdlList.GetHdlCount(); a++)
639 SdrHdl* pAct = rHdlList.GetHdl(a);
641 if(pAct
642 && pAct->GetKind() == HDL_POLY
643 && pAct->GetPolyNum() == nPol
644 && pAct->GetPointNum() == nPnt)
646 pNewOne = pAct;
650 if(pNewOne)
652 ((SdrHdlList&)rHdlList).SetFocusHdl(pNewOne);
656 bReturn = TRUE;
660 break;
662 case KEY_UP:
663 case KEY_DOWN:
664 case KEY_LEFT:
665 case KEY_RIGHT:
667 if (!mpView->IsTextEdit() && !bSlideShow)
669 long nX = 0;
670 long nY = 0;
672 if (nCode == KEY_UP)
674 // Scroll nach oben
675 nX = 0;
676 nY =-1;
678 else if (nCode == KEY_DOWN)
680 // Scroll nach unten
681 nX = 0;
682 nY = 1;
684 else if (nCode == KEY_LEFT)
686 // Scroll nach links
687 nX =-1;
688 nY = 0;
690 else if (nCode == KEY_RIGHT)
692 // Scroll nach rechts
693 nX = 1;
694 nY = 0;
697 if (mpView->AreObjectsMarked() && !rKEvt.GetKeyCode().IsMod1() &&
698 !mpDocSh->IsReadOnly())
700 // #97016# II
701 const SdrHdlList& rHdlList = mpView->GetHdlList();
702 SdrHdl* pHdl = rHdlList.GetFocusHdl();
704 // #109007#
705 sal_Bool bIsMoveOfConnectedHandle(sal_False);
706 sal_Bool bOldSuppress = false;
707 SdrEdgeObj* pEdgeObj = 0L;
709 if(pHdl && pHdl->GetObj() && pHdl->GetObj()->ISA(SdrEdgeObj) && 0 == pHdl->GetPolyNum())
711 pEdgeObj = (SdrEdgeObj*)pHdl->GetObj();
713 if(0L == pHdl->GetPointNum())
715 if(pEdgeObj->GetConnection(sal_True).GetObject())
717 bIsMoveOfConnectedHandle = sal_True;
720 if(1L == pHdl->GetPointNum())
722 if(pEdgeObj->GetConnection(sal_False).GetObject())
724 bIsMoveOfConnectedHandle = sal_True;
729 // #109007#
730 if(pEdgeObj)
732 // Suppress default connects to inside object and object center
733 bOldSuppress = pEdgeObj->GetSuppressDefaultConnect();
734 pEdgeObj->SetSuppressDefaultConnect(sal_True);
737 // #109007#
738 if(bIsMoveOfConnectedHandle)
740 sal_uInt16 nMarkHdSiz(mpView->GetMarkHdlSizePixel());
741 Size aHalfConSiz(nMarkHdSiz + 1, nMarkHdSiz + 1);
742 aHalfConSiz = mpWindow->PixelToLogic(aHalfConSiz);
744 if(100 < aHalfConSiz.Width())
745 nX *= aHalfConSiz.Width();
746 else
747 nX *= 100;
749 if(100 < aHalfConSiz.Height())
750 nY *= aHalfConSiz.Height();
751 else
752 nY *= 100;
754 else if(rKEvt.GetKeyCode().IsMod2())
756 // #97016# move in 1 pixel distance
757 Size aLogicSizeOnePixel = (mpWindow) ? mpWindow->PixelToLogic(Size(1,1)) : Size(100, 100);
758 nX *= aLogicSizeOnePixel.Width();
759 nY *= aLogicSizeOnePixel.Height();
761 else if(rKEvt.GetKeyCode().IsShift())
763 nX *= 1000;
764 nY *= 1000;
766 else
768 // old, fixed move distance
769 nX *= 100;
770 nY *= 100;
773 if(0L == pHdl)
775 // #67368# only take action when move is allowed
776 if(mpView->IsMoveAllowed())
778 // #90129# restrict movement to WorkArea
779 const Rectangle& rWorkArea = mpView->GetWorkArea();
781 if(!rWorkArea.IsEmpty())
783 Rectangle aMarkRect(mpView->GetMarkedObjRect());
784 aMarkRect.Move(nX, nY);
786 if(!aMarkRect.IsInside(rWorkArea))
788 if(aMarkRect.Left() < rWorkArea.Left())
790 nX += rWorkArea.Left() - aMarkRect.Left();
793 if(aMarkRect.Right() > rWorkArea.Right())
795 nX -= aMarkRect.Right() - rWorkArea.Right();
798 if(aMarkRect.Top() < rWorkArea.Top())
800 nY += rWorkArea.Top() - aMarkRect.Top();
803 if(aMarkRect.Bottom() > rWorkArea.Bottom())
805 nY -= aMarkRect.Bottom() - rWorkArea.Bottom();
810 // no handle selected
811 if(0 != nX || 0 != nY)
813 mpView->MoveAllMarked(Size(nX, nY));
815 // #97016# II
816 mpView->MakeVisible(mpView->GetAllMarkedRect(), *mpWindow);
820 else
822 // move handle with index nHandleIndex
823 if(pHdl && (nX || nY))
825 // now move the Handle (nX, nY)
826 Point aStartPoint(pHdl->GetPos());
827 Point aEndPoint(pHdl->GetPos() + Point(nX, nY));
828 const SdrDragStat& rDragStat = mpView->GetDragStat();
830 // start dragging
831 mpView->BegDragObj(aStartPoint, 0, pHdl, 0);
833 if(mpView->IsDragObj())
835 FASTBOOL bWasNoSnap = rDragStat.IsNoSnap();
836 BOOL bWasSnapEnabled = mpView->IsSnapEnabled();
838 // switch snapping off
839 if(!bWasNoSnap)
840 ((SdrDragStat&)rDragStat).SetNoSnap(TRUE);
841 if(bWasSnapEnabled)
842 mpView->SetSnapEnabled(FALSE);
844 mpView->MovAction(aEndPoint);
845 mpView->EndDragObj();
847 // restore snap
848 if(!bWasNoSnap)
849 ((SdrDragStat&)rDragStat).SetNoSnap(bWasNoSnap);
850 if(bWasSnapEnabled)
851 mpView->SetSnapEnabled(bWasSnapEnabled);
854 // make moved handle visible
855 Rectangle aVisRect(aEndPoint - Point(100, 100), Size(200, 200));
856 mpView->MakeVisible(aVisRect, *mpWindow);
860 // #109007#
861 if(pEdgeObj)
863 // Restore original suppress value
864 pEdgeObj->SetSuppressDefaultConnect(bOldSuppress);
867 else
869 // Seite scrollen
870 ScrollStart();
871 mpViewShell->ScrollLines(nX, nY);
872 ScrollEnd();
875 bReturn = TRUE;
878 break;
881 if (bReturn)
883 mpWindow->ReleaseMouse();
886 // #98198# when a text-editable object is selected and the
887 // input character is printable, activate text edit on that object
888 // and feed character to object
889 if(!bReturn && !mpDocSh->IsReadOnly())
891 if(!mpView->IsTextEdit() && mpViewShell)
893 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
895 if(1 == rMarkList.GetMarkCount())
897 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
899 if(pObj->ISA(SdrTextObj) && pObj->HasTextEdit() && !pObj->ISA(SdrOle2Obj))
901 // #98533# use common IsSimpleCharInput from
902 // the EditEngine.
903 sal_Bool bPrintable(EditEngine::IsSimpleCharInput(rKEvt));
905 if(bPrintable)
907 // try to activate textedit mode for the selected object
908 SfxStringItem aInputString(SID_ATTR_CHAR, String(rKEvt.GetCharCode()));
910 mpViewShell->GetViewFrame()->GetDispatcher()->Execute(
911 SID_ATTR_CHAR,
912 SFX_CALLMODE_ASYNCHRON,
913 &aInputString,
914 0L);
916 // consumed
917 bReturn = TRUE;
921 else
923 // #99039# test if there is a title object there. If yes, try to
924 // set it to edit mode and start typing...
925 if(mpViewShell->ISA(DrawViewShell)
926 && EditEngine::IsSimpleCharInput(rKEvt))
928 DrawViewShell* pDrawViewShell =
929 static_cast<DrawViewShell*>(mpViewShell);
930 SdPage* pActualPage = pDrawViewShell->GetActualPage();
931 SdrTextObj* pCandidate = 0L;
933 if(pActualPage)
935 SdrObjListIter aIter(*pActualPage, IM_DEEPNOGROUPS);
937 while(aIter.IsMore() && !pCandidate)
939 SdrObject* pObj = aIter.Next();
941 if(pObj && pObj->ISA(SdrTextObj))
943 sal_uInt32 nInv(pObj->GetObjInventor());
944 sal_uInt16 nKnd(pObj->GetObjIdentifier());
946 if(SdrInventor == nInv && OBJ_TITLETEXT == nKnd)
948 pCandidate = (SdrTextObj*)pObj;
954 // when candidate found and candidate is untouched, start editing text...
955 if(pCandidate && pCandidate->IsEmptyPresObj())
957 mpView->UnMarkAll();
958 mpView->MarkObj(pCandidate, mpView->GetSdrPageView());
959 SfxStringItem aInputString(SID_ATTR_CHAR, String(rKEvt.GetCharCode()));
961 mpViewShell->GetViewFrame()->GetDispatcher()->Execute(
962 SID_ATTR_CHAR,
963 SFX_CALLMODE_ASYNCHRON,
964 &aInputString,
965 0L);
967 // consumed
968 bReturn = TRUE;
975 return(bReturn);
978 BOOL FuPoor::MouseMove(const MouseEvent& )
980 return FALSE;
983 // #97016# II
984 void FuPoor::SelectionHasChanged()
986 const SdrHdlList& rHdlList = mpView->GetHdlList();
987 ((SdrHdlList&)rHdlList).ResetFocusHdl();
990 /*************************************************************************
992 |* Cut object to clipboard
994 \************************************************************************/
996 void FuPoor::DoCut()
998 if (mpView)
1000 mpView->DoCut(mpWindow);
1004 /*************************************************************************
1006 |* Copy object to clipboard
1008 \************************************************************************/
1010 void FuPoor::DoCopy()
1012 if (mpView)
1014 mpView->DoCopy(mpWindow);
1018 /*************************************************************************
1020 |* Paste object from clipboard
1022 \************************************************************************/
1024 void FuPoor::DoPaste()
1026 if (mpView)
1028 mpView->DoPaste(mpWindow);
1032 /*************************************************************************
1034 |* Timer-Handler fuer Drag&Drop
1036 \************************************************************************/
1038 IMPL_LINK( FuPoor, DragHdl, Timer *, EMPTYARG )
1040 if( mpView )
1042 USHORT nHitLog = USHORT ( mpWindow->PixelToLogic(Size(HITPIX,0)).Width() );
1043 SdrHdl* pHdl = mpView->PickHandle(aMDPos);
1045 if ( pHdl==NULL && mpView->IsMarkedHit(aMDPos, nHitLog)
1046 && !mpView->IsPresObjSelected(FALSE, TRUE) )
1048 mpWindow->ReleaseMouse();
1049 bIsInDragMode = TRUE;
1050 mpView->StartDrag( aMDPos, mpWindow );
1053 return 0;
1056 /*************************************************************************
1058 |* Command-event
1060 \************************************************************************/
1062 BOOL FuPoor::Command(const CommandEvent& rCEvt)
1064 return( mpView->Command(rCEvt,mpWindow) );
1067 /*************************************************************************
1069 |* Timer-Handler fuer Fensterscrolling
1071 \************************************************************************/
1073 IMPL_LINK_INLINE_START( FuPoor, DelayHdl, Timer *, EMPTYARG )
1075 aDelayToScrollTimer.Stop ();
1076 bScrollable = TRUE;
1078 Point aPnt(mpWindow->GetPointerPosPixel());
1080 // #95491# use remembered MouseButton state to create correct
1081 // MouseEvents for this artifical MouseMove.
1082 MouseMove(MouseEvent(aPnt, 1, 0, GetMouseButtonCode()));
1084 return 0;
1086 IMPL_LINK_INLINE_END( FuPoor, DelayHdl, Timer *, pTimer )
1088 /*************************************************************************
1090 |* Handler fuer Maustaste
1092 \************************************************************************/
1094 BOOL FuPoor::MouseButtonUp (const MouseEvent& rMEvt)
1096 // #95491# remember button state for creation of own MouseEvents
1097 SetMouseButtonCode(rMEvt.GetButtons());
1099 aDelayToScrollTimer.Stop ();
1100 return bScrollable =
1101 bDelayActive = FALSE;
1104 BOOL FuPoor::MouseButtonDown(const MouseEvent& rMEvt)
1106 // #95491# remember button state for creation of own MouseEvents
1107 SetMouseButtonCode(rMEvt.GetButtons());
1109 return FALSE;
1112 /*************************************************************************
1114 |* Handler fuer Maustaste
1116 \************************************************************************/
1118 void FuPoor::StartDelayToScrollTimer ()
1120 bDelayActive = TRUE;
1121 aDelayToScrollTimer.Start ();
1124 /*************************************************************************
1126 |* Handler fuer Maustaste
1128 \************************************************************************/
1130 long FuPoor::diffPoint (long pos1, long pos2)
1132 return (pos1 > pos2) ? pos1 - pos2
1133 : pos2 - pos1;
1136 /*************************************************************************
1138 |* Help-event
1140 \************************************************************************/
1142 BOOL FuPoor::RequestHelp(const HelpEvent& rHEvt)
1144 BOOL bReturn = FALSE;
1146 SdrPageView* pPV = mpView->GetSdrPageView();
1148 if (pPV)
1150 SdPage* pPage = (SdPage*) pPV->GetPage();
1152 if (pPage)
1154 bReturn = pPage->RequestHelp(mpWindow, mpView, rHEvt);
1158 return(bReturn);
1161 void FuPoor::Paint(const Rectangle&, ::sd::Window* )
1165 /*************************************************************************
1167 |* Request verarbeiten
1169 \************************************************************************/
1171 void FuPoor::ReceiveRequest(SfxRequest& rReq)
1173 const SfxItemSet* pSet = rReq.GetArgs();
1175 if (pSet)
1177 if( pSet->GetItemState( nSlotId ) == SFX_ITEM_SET )
1179 const SfxPoolItem& rItem = pSet->Get( nSlotId );
1181 if( rItem.ISA( SfxAllEnumItem ) )
1183 nSlotValue = ( ( const SfxAllEnumItem& ) rItem ).GetValue();
1189 /*************************************************************************
1191 |* #97016#
1193 \************************************************************************/
1195 SdrObject* FuPoor::CreateDefaultObject(const sal_uInt16, const Rectangle& )
1197 // empty base implementation
1198 return 0L;
1201 void FuPoor::ImpForceQuadratic(Rectangle& rRect)
1203 if(rRect.GetWidth() > rRect.GetHeight())
1205 rRect = Rectangle(
1206 Point(rRect.Left() + ((rRect.GetWidth() - rRect.GetHeight()) / 2), rRect.Top()),
1207 Size(rRect.GetHeight(), rRect.GetHeight()));
1209 else
1211 rRect = Rectangle(
1212 Point(rRect.Left(), rRect.Top() + ((rRect.GetHeight() - rRect.GetWidth()) / 2)),
1213 Size(rRect.GetWidth(), rRect.GetWidth()));
1220 void FuPoor::SwitchLayer (sal_Int32 nOffset)
1222 if(mpViewShell && mpViewShell->ISA(DrawViewShell))
1224 DrawViewShell* pDrawViewShell =
1225 static_cast<DrawViewShell*>(mpViewShell);
1227 // Calculate the new index.
1228 sal_Int32 nIndex = pDrawViewShell->GetActiveTabLayerIndex() + nOffset;
1230 // Make sure the new index lies inside the range of valid indices.
1231 if (nIndex < 0)
1232 nIndex = 0;
1233 else if (nIndex >= pDrawViewShell->GetTabLayerCount ())
1234 nIndex = pDrawViewShell->GetTabLayerCount() - 1;
1236 // Set the new active layer.
1237 if (nIndex != pDrawViewShell->GetActiveTabLayerIndex ())
1239 LayerTabBar* pLayerTabControl =
1240 static_cast<DrawViewShell*>(mpViewShell)->GetLayerTabControl();
1241 if (pLayerTabControl != NULL)
1242 pLayerTabControl->SendDeactivatePageEvent ();
1244 pDrawViewShell->SetActiveTabLayerIndex (nIndex);
1246 if (pLayerTabControl != NULL)
1247 pLayerTabControl->SendActivatePageEvent ();
1252 /** is called when the currenct function should be aborted. <p>
1253 This is used when a function gets a KEY_ESCAPE but can also
1254 be called directly.
1256 @returns true if a active function was aborted
1258 bool FuPoor::cancel()
1260 if ( !this->ISA(FuSelection) )
1262 mpViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON);
1263 return true;
1266 return false;
1269 // #i33136#
1270 bool FuPoor::doConstructOrthogonal() const
1272 return (
1273 SID_DRAW_XLINE == nSlotId ||
1274 SID_DRAW_CIRCLEARC == nSlotId ||
1275 SID_DRAW_SQUARE == nSlotId ||
1276 SID_DRAW_SQUARE_NOFILL == nSlotId ||
1277 SID_DRAW_SQUARE_ROUND == nSlotId ||
1278 SID_DRAW_SQUARE_ROUND_NOFILL == nSlotId ||
1279 SID_DRAW_CIRCLE == nSlotId ||
1280 SID_DRAW_CIRCLE_NOFILL == nSlotId ||
1281 SID_DRAW_CIRCLEPIE == nSlotId ||
1282 SID_DRAW_CIRCLEPIE_NOFILL == nSlotId ||
1283 SID_DRAW_CIRCLECUT == nSlotId ||
1284 SID_DRAW_CIRCLECUT_NOFILL == nSlotId ||
1285 SID_DRAW_XPOLYGON == nSlotId ||
1286 SID_DRAW_XPOLYGON_NOFILL == nSlotId ||
1287 SID_3D_CUBE == nSlotId ||
1288 SID_3D_SPHERE == nSlotId ||
1289 SID_3D_SHELL == nSlotId ||
1290 SID_3D_HALF_SPHERE == nSlotId ||
1291 SID_3D_TORUS == nSlotId ||
1292 SID_3D_CYLINDER == nSlotId ||
1293 SID_3D_CONE == nSlotId ||
1294 SID_3D_PYRAMID == nSlotId);
1297 void FuPoor::DoExecute( SfxRequest& )
1301 } // end of namespace sd