merge the formfield patch from ooo-build
[ooovba.git] / sd / source / ui / func / fupoor.cxx
blob2f91cae2a868cde61ba62d1356d05ede483c92e4
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( rKEvt.GetKeyCode().IsMod1() && rKEvt.GetKeyCode().IsMod2() )
515 break;
517 if(mpViewShell->ISA(DrawViewShell) && !bSlideShow)
519 // The page-up key switches layers or pages depending on the
520 // modifier key.
521 if ( ! rKEvt.GetKeyCode().GetAllModifier())
523 // With no modifier pressed we move to the previous
524 // slide.
525 mpView->SdrEndTextEdit();
527 // Previous page.
528 bReturn = TRUE;
529 SdPage* pPage = static_cast<DrawViewShell*>(mpViewShell)->GetActualPage();
530 USHORT nSdPage = (pPage->GetPageNum() - 1) / 2;
532 if (nSdPage > 0)
534 // Switch the page and send events regarding
535 // deactivation the old page and activating the new
536 // one.
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.
553 SwitchLayer (-1);
558 break;
560 case KEY_PAGEDOWN:
562 if( rKEvt.GetKeyCode().IsMod1() && rKEvt.GetKeyCode().IsMod2() )
563 break;
564 if(mpViewShell->ISA(DrawViewShell) && !bSlideShow)
566 // The page-down key switches layers or pages depending on the
567 // modifier key.
568 if ( ! rKEvt.GetKeyCode().GetAllModifier())
570 // With no modifier pressed we move to the next slide.
571 mpView->SdrEndTextEdit();
573 // Next page.
574 bReturn = TRUE;
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
582 // one.
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.
599 SwitchLayer (+1);
604 break;
606 // #97016# II change select state when focus is on poly point
607 case KEY_SPACE:
609 const SdrHdlList& rHdlList = mpView->GetHdlList();
610 SdrHdl* pHdl = rHdlList.GetFocusHdl();
612 if(pHdl)
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);
627 else
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);
646 if(pAct
647 && pAct->GetKind() == HDL_POLY
648 && pAct->GetPolyNum() == nPol
649 && pAct->GetPointNum() == nPnt)
651 pNewOne = pAct;
655 if(pNewOne)
657 ((SdrHdlList&)rHdlList).SetFocusHdl(pNewOne);
661 bReturn = TRUE;
665 break;
667 case KEY_UP:
668 case KEY_DOWN:
669 case KEY_LEFT:
670 case KEY_RIGHT:
672 if (!mpView->IsTextEdit() && !bSlideShow)
674 long nX = 0;
675 long nY = 0;
677 if (nCode == KEY_UP)
679 // Scroll nach oben
680 nX = 0;
681 nY =-1;
683 else if (nCode == KEY_DOWN)
685 // Scroll nach unten
686 nX = 0;
687 nY = 1;
689 else if (nCode == KEY_LEFT)
691 // Scroll nach links
692 nX =-1;
693 nY = 0;
695 else if (nCode == KEY_RIGHT)
697 // Scroll nach rechts
698 nX = 1;
699 nY = 0;
702 if (mpView->AreObjectsMarked() && !rKEvt.GetKeyCode().IsMod1() &&
703 !mpDocSh->IsReadOnly())
705 // #97016# II
706 const SdrHdlList& rHdlList = mpView->GetHdlList();
707 SdrHdl* pHdl = rHdlList.GetFocusHdl();
709 // #109007#
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;
734 // #109007#
735 if(pEdgeObj)
737 // Suppress default connects to inside object and object center
738 bOldSuppress = pEdgeObj->GetSuppressDefaultConnect();
739 pEdgeObj->SetSuppressDefaultConnect(sal_True);
742 // #109007#
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();
751 else
752 nX *= 100;
754 if(100 < aHalfConSiz.Height())
755 nY *= aHalfConSiz.Height();
756 else
757 nY *= 100;
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())
768 nX *= 1000;
769 nY *= 1000;
771 else
773 // old, fixed move distance
774 nX *= 100;
775 nY *= 100;
778 if(0L == pHdl)
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));
820 // #97016# II
821 mpView->MakeVisible(mpView->GetAllMarkedRect(), *mpWindow);
825 else
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();
835 // start dragging
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
844 if(!bWasNoSnap)
845 ((SdrDragStat&)rDragStat).SetNoSnap(TRUE);
846 if(bWasSnapEnabled)
847 mpView->SetSnapEnabled(FALSE);
849 mpView->MovAction(aEndPoint);
850 mpView->EndDragObj();
852 // restore snap
853 if(!bWasNoSnap)
854 ((SdrDragStat&)rDragStat).SetNoSnap(bWasNoSnap);
855 if(bWasSnapEnabled)
856 mpView->SetSnapEnabled(bWasSnapEnabled);
859 // make moved handle visible
860 Rectangle aVisRect(aEndPoint - Point(100, 100), Size(200, 200));
861 mpView->MakeVisible(aVisRect, *mpWindow);
865 // #109007#
866 if(pEdgeObj)
868 // Restore original suppress value
869 pEdgeObj->SetSuppressDefaultConnect(bOldSuppress);
872 else
874 // Seite scrollen
875 ScrollStart();
876 mpViewShell->ScrollLines(nX, nY);
877 ScrollEnd();
880 bReturn = TRUE;
883 break;
886 if (bReturn)
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
907 // the EditEngine.
908 sal_Bool bPrintable(EditEngine::IsSimpleCharInput(rKEvt));
910 if(bPrintable)
912 // try to activate textedit mode for the selected object
913 SfxStringItem aInputString(SID_ATTR_CHAR, String(rKEvt.GetCharCode()));
915 mpViewShell->GetViewFrame()->GetDispatcher()->Execute(
916 SID_ATTR_CHAR,
917 SFX_CALLMODE_ASYNCHRON,
918 &aInputString,
919 0L);
921 // consumed
922 bReturn = TRUE;
926 else
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;
938 if(pActualPage)
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())
962 mpView->UnMarkAll();
963 mpView->MarkObj(pCandidate, mpView->GetSdrPageView());
964 SfxStringItem aInputString(SID_ATTR_CHAR, String(rKEvt.GetCharCode()));
966 mpViewShell->GetViewFrame()->GetDispatcher()->Execute(
967 SID_ATTR_CHAR,
968 SFX_CALLMODE_ASYNCHRON,
969 &aInputString,
970 0L);
972 // consumed
973 bReturn = TRUE;
980 return(bReturn);
983 BOOL FuPoor::MouseMove(const MouseEvent& )
985 return FALSE;
988 // #97016# II
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()
1003 if (mpView)
1005 mpView->DoCut(mpWindow);
1009 /*************************************************************************
1011 |* Copy object to clipboard
1013 \************************************************************************/
1015 void FuPoor::DoCopy()
1017 if (mpView)
1019 mpView->DoCopy(mpWindow);
1023 /*************************************************************************
1025 |* Paste object from clipboard
1027 \************************************************************************/
1029 void FuPoor::DoPaste()
1031 if (mpView)
1033 mpView->DoPaste(mpWindow);
1037 /*************************************************************************
1039 |* Timer-Handler fuer Drag&Drop
1041 \************************************************************************/
1043 IMPL_LINK( FuPoor, DragHdl, Timer *, EMPTYARG )
1045 if( mpView )
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 );
1058 return 0;
1061 /*************************************************************************
1063 |* Command-event
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 ();
1081 bScrollable = TRUE;
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()));
1089 return 0;
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());
1114 return FALSE;
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
1138 : pos2 - pos1;
1141 /*************************************************************************
1143 |* Help-event
1145 \************************************************************************/
1147 BOOL FuPoor::RequestHelp(const HelpEvent& rHEvt)
1149 BOOL bReturn = FALSE;
1151 SdrPageView* pPV = mpView->GetSdrPageView();
1153 if (pPV)
1155 SdPage* pPage = (SdPage*) pPV->GetPage();
1157 if (pPage)
1159 bReturn = pPage->RequestHelp(mpWindow, mpView, rHEvt);
1163 return(bReturn);
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();
1180 if (pSet)
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 /*************************************************************************
1196 |* #97016#
1198 \************************************************************************/
1200 SdrObject* FuPoor::CreateDefaultObject(const sal_uInt16, const Rectangle& )
1202 // empty base implementation
1203 return 0L;
1206 void FuPoor::ImpForceQuadratic(Rectangle& rRect)
1208 if(rRect.GetWidth() > rRect.GetHeight())
1210 rRect = Rectangle(
1211 Point(rRect.Left() + ((rRect.GetWidth() - rRect.GetHeight()) / 2), rRect.Top()),
1212 Size(rRect.GetHeight(), rRect.GetHeight()));
1214 else
1216 rRect = Rectangle(
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.
1236 if (nIndex < 0)
1237 nIndex = 0;
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
1259 be called directly.
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);
1268 return true;
1271 return false;
1274 // #i33136#
1275 bool FuPoor::doConstructOrthogonal() const
1277 return (
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