bump product version to 4.1.6.2
[LibreOffice.git] / sd / source / ui / func / fupoor.cxx
blob9bf40b570052493309342d4c636936634b02a79e
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #include "fupoor.hxx"
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"
39 #include "app.hrc"
40 #include "fusel.hxx"
41 #include "sdpage.hxx"
42 #include "drawview.hxx"
43 #include "DrawViewShell.hxx"
44 #include "Window.hxx"
45 #include "drawdoc.hxx"
46 #include "DrawDocShell.hxx"
47 #include "zoomlist.hxx"
48 #include "Client.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;
61 namespace sd {
63 TYPEINIT0( FuPoor );
66 FuPoor::FuPoor (
67 ViewShell* pViewSh,
68 ::sd::Window* pWin,
69 ::sd::View* pView,
70 SdDrawDocument* pDrDoc,
71 SfxRequest& rReq)
72 : mpView(pView),
73 mpViewShell(pViewSh),
74 mpWindow(pWin),
75 mpDocSh( pDrDoc->GetDocSh() ),
76 mpDoc(pDrDoc),
77 nSlotId( rReq.GetSlot() ),
78 nSlotValue(0),
79 pDialog(NULL),
80 bIsInDragMode(sal_False),
81 bNoScrollUntilInside (sal_True),
82 bScrollable (sal_False),
83 bDelayActive (sal_False),
84 bFirstMouseMove (sal_False),
85 // remember MouseButton state
86 mnCode(0)
88 ReceiveRequest(rReq);
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);
101 FuPoor::~FuPoor()
103 aDragTimer.Stop();
104 aScrollTimer.Stop();
105 aDelayToScrollTimer.Stop ();
107 if (pDialog)
108 delete pDialog;
112 void FuPoor::Activate()
114 if (pDialog)
116 pDialog->Show();
121 void FuPoor::Deactivate()
123 aDragTimer.Stop();
124 aScrollTimer.Stop();
125 aDelayToScrollTimer.Stop ();
126 bScrollable =
127 bDelayActive = sal_False;
129 if (pDialog)
131 pDialog->Hide();
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)
142 aScrollTimer.Stop();
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;
155 else
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 )
166 if (bScrollable)
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()));
189 return 0;
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() );
203 switch (nCode)
205 case KEY_RETURN:
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;
216 if(pActualPage)
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;
238 if(pCandidate)
240 mpView->UnMarkAll();
241 mpView->MarkObj(pCandidate, mpView->GetSdrPageView());
243 mpViewShell->GetViewFrame()->GetDispatcher()->Execute(
244 SID_ATTR_CHAR, SFX_CALLMODE_ASYNCHRON);
246 else
248 // insert a new page with the same page layout
249 mpViewShell->GetViewFrame()->GetDispatcher()->Execute(
250 SID_INSERTPAGE_QUICK, SFX_CALLMODE_ASYNCHRON);
253 // consumed
254 bReturn = sal_True;
257 else
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 );
276 else
278 mpViewShell->GetViewFrame()->GetDispatcher()->Execute( SID_ATTR_CHAR, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD );
281 // consumed
282 bReturn = sal_True;
286 break;
288 case KEY_TAB:
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();
302 if(pHdl)
304 Point aHdlPosition(pHdl->GetPos());
305 Rectangle aVisRect(aHdlPosition - Point(100, 100), Size(200, 200));
306 mpView->MakeVisible(aVisRect, *mpWindow);
309 // consumed
310 bReturn = sal_True;
313 break;
315 case KEY_ESCAPE:
317 bReturn = FuPoor::cancel();
319 break;
321 case KEY_ADD:
323 if (!mpView->IsTextEdit() && !bSlideShow && !mpDocSh->IsUIActive())
325 // increase zoom
326 mpViewShell->SetZoom(mpWindow->GetZoom() * 3 / 2);
328 if (mpViewShell->ISA(DrawViewShell))
329 static_cast<DrawViewShell*>(mpViewShell)
330 ->SetZoomOnPage(sal_False);
332 bReturn = sal_True;
335 break;
337 case KEY_SUBTRACT:
339 if (!mpView->IsTextEdit() && !bSlideShow && !mpDocSh->IsUIActive())
341 // decrease zoom
342 mpViewShell->SetZoom(mpWindow->GetZoom() * 2 / 3);
344 if (mpViewShell->ISA(DrawViewShell))
345 static_cast<DrawViewShell*>(mpViewShell)
346 ->SetZoomOnPage(sal_False);
348 bReturn = sal_True;
351 break;
353 case KEY_MULTIPLY:
355 if (!mpView->IsTextEdit() && !bSlideShow)
357 // zoom to page
358 mpViewShell->GetViewFrame()->GetDispatcher()->
359 Execute(SID_SIZE_PAGE, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
360 bReturn = sal_True;
363 break;
365 case KEY_DIVIDE:
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);
372 bReturn = sal_True;
375 break;
377 case KEY_POINT:
379 ZoomList* pZoomList = mpViewShell->GetZoomList();
381 if (!mpView->IsTextEdit() && pZoomList->IsNextPossible() && !bSlideShow && !mpDocSh->IsUIActive())
383 // use next ZoomRect
384 mpViewShell->SetZoomRect(pZoomList->GetNextZoomRect());
385 bReturn = sal_True;
388 break;
390 case KEY_COMMA:
392 ZoomList* pZoomList = mpViewShell->GetZoomList();
394 if (!mpView->IsTextEdit() && pZoomList->IsPreviousPossible() && !bSlideShow && !mpDocSh->IsUIActive())
396 // use previous ZoomRect
397 mpViewShell->SetZoomRect(pZoomList->GetPreviousZoomRect());
398 bReturn = sal_True;
401 break;
403 case KEY_HOME:
405 if (!mpView->IsTextEdit()
406 && mpViewShell->ISA(DrawViewShell)
407 && !bSlideShow)
409 // jump to first page
410 static_cast<DrawViewShell*>(mpViewShell)->SwitchPage(0);
411 bReturn = sal_True;
414 break;
416 case KEY_END:
418 if (!mpView->IsTextEdit()
419 && mpViewShell->ISA(DrawViewShell)
420 && !bSlideShow)
422 // jump to last page
423 SdPage* pPage =
424 static_cast<DrawViewShell*>(mpViewShell)->GetActualPage();
425 static_cast<DrawViewShell*>(mpViewShell)
426 ->SwitchPage(mpDoc->GetSdPageCount(
427 pPage->GetPageKind()) - 1);
428 bReturn = sal_True;
431 break;
433 case KEY_PAGEUP:
435 if( rKEvt.GetKeyCode().IsMod1() && rKEvt.GetKeyCode().IsMod2() )
436 break;
438 if(mpViewShell->ISA(DrawViewShell) && !bSlideShow)
440 // The page-up key switches layers or pages depending on the
441 // modifier key.
442 if ( ! rKEvt.GetKeyCode().GetAllModifier())
444 // With no modifier pressed we move to the previous
445 // slide.
446 mpView->SdrEndTextEdit();
448 // Previous page.
449 bReturn = sal_True;
450 SdPage* pPage = static_cast<DrawViewShell*>(mpViewShell)->GetActualPage();
451 sal_uInt16 nSdPage = (pPage->GetPageNum() - 1) / 2;
453 if (nSdPage > 0)
455 // Switch the page and send events regarding
456 // deactivation the old page and activating the new
457 // one.
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.
474 SwitchLayer (-1);
479 break;
481 case KEY_PAGEDOWN:
483 if( rKEvt.GetKeyCode().IsMod1() && rKEvt.GetKeyCode().IsMod2() )
484 break;
485 if(mpViewShell->ISA(DrawViewShell) && !bSlideShow)
487 // The page-down key switches layers or pages depending on the
488 // modifier key.
489 if ( ! rKEvt.GetKeyCode().GetAllModifier())
491 // With no modifier pressed we move to the next slide.
492 mpView->SdrEndTextEdit();
494 // Next page.
495 bReturn = sal_True;
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
503 // one.
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.
520 SwitchLayer (+1);
525 break;
527 // change select state when focus is on poly point
528 case KEY_SPACE:
530 const SdrHdlList& rHdlList = mpView->GetHdlList();
531 SdrHdl* pHdl = rHdlList.GetFocusHdl();
533 if(pHdl)
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);
548 else
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);
567 if(pAct
568 && pAct->GetKind() == HDL_POLY
569 && pAct->GetPolyNum() == nPol
570 && pAct->GetPointNum() == nPnt)
572 pNewOne = pAct;
576 if(pNewOne)
578 ((SdrHdlList&)rHdlList).SetFocusHdl(pNewOne);
582 bReturn = sal_True;
586 break;
588 case KEY_UP:
589 case KEY_DOWN:
590 case KEY_LEFT:
591 case KEY_RIGHT:
593 if (!mpView->IsTextEdit() && !bSlideShow)
595 long nX = 0;
596 long nY = 0;
598 if (nCode == KEY_UP)
600 // scroll up
601 nX = 0;
602 nY =-1;
604 else if (nCode == KEY_DOWN)
606 // scroll down
607 nX = 0;
608 nY = 1;
610 else if (nCode == KEY_LEFT)
612 // scroll left
613 nX =-1;
614 nY = 0;
616 else if (nCode == KEY_RIGHT)
618 // scroll right
619 nX = 1;
620 nY = 0;
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;
653 if(pEdgeObj)
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();
668 else
669 nX *= 100;
671 if(100 < aHalfConSiz.Height())
672 nY *= aHalfConSiz.Height();
673 else
674 nY *= 100;
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())
685 nX *= 1000;
686 nY *= 1000;
688 else
690 // old, fixed move distance
691 nX *= 100;
692 nY *= 100;
695 if(0L == pHdl)
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);
741 else
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();
751 // start dragging
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
760 if(!bWasNoSnap)
761 ((SdrDragStat&)rDragStat).SetNoSnap(sal_True);
762 if(bWasSnapEnabled)
763 mpView->SetSnapEnabled(sal_False);
765 mpView->MovAction(aEndPoint);
766 mpView->EndDragObj();
768 // restore snap
769 if(!bWasNoSnap)
770 ((SdrDragStat&)rDragStat).SetNoSnap(bWasNoSnap);
771 if(bWasSnapEnabled)
772 mpView->SetSnapEnabled(bWasSnapEnabled);
775 // make moved handle visible
776 Rectangle aVisRect(aEndPoint - Point(100, 100), Size(200, 200));
777 mpView->MakeVisible(aVisRect, *mpWindow);
781 if(pEdgeObj)
783 // Restore original suppress value
784 pEdgeObj->SetSuppressDefaultConnect(bOldSuppress);
787 else
789 // scroll page
790 mpViewShell->ScrollLines(nX, nY);
793 bReturn = sal_True;
796 break;
799 if (bReturn)
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));
823 if(bPrintable)
825 // try to activate textedit mode for the selected object
826 SfxStringItem aInputString(SID_ATTR_CHAR, OUString(rKEvt.GetCharCode()));
828 mpViewShell->GetViewFrame()->GetDispatcher()->Execute(
829 SID_ATTR_CHAR,
830 SFX_CALLMODE_ASYNCHRON,
831 &aInputString,
832 0L);
834 // consumed
835 bReturn = sal_True;
839 else
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;
851 if(pActualPage)
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())
875 mpView->UnMarkAll();
876 mpView->MarkObj(pCandidate, mpView->GetSdrPageView());
877 SfxStringItem aInputString(SID_ATTR_CHAR, OUString(rKEvt.GetCharCode()));
879 mpViewShell->GetViewFrame()->GetDispatcher()->Execute(
880 SID_ATTR_CHAR,
881 SFX_CALLMODE_ASYNCHRON,
882 &aInputString,
883 0L);
885 // consumed
886 bReturn = sal_True;
893 return(bReturn);
896 sal_Bool FuPoor::MouseMove(const MouseEvent& )
898 return sal_False;
901 void FuPoor::SelectionHasChanged()
903 const SdrHdlList& rHdlList = mpView->GetHdlList();
904 ((SdrHdlList&)rHdlList).ResetFocusHdl();
908 * Cut object to clipboard
910 void FuPoor::DoCut()
912 if (mpView)
914 mpView->DoCut(mpWindow);
919 * Copy object to clipboard
921 void FuPoor::DoCopy()
923 if (mpView)
925 mpView->DoCopy(mpWindow);
930 * Paste object from clipboard
932 void FuPoor::DoPaste()
934 if (mpView)
936 mpView->DoPaste(mpWindow);
941 * Timer handler for Drag&Drop
943 IMPL_LINK_NOARG(FuPoor, DragHdl)
945 if( mpView )
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 );
958 return 0;
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()));
980 return 0;
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 ();
990 return bScrollable =
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());
999 return sal_False;
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();
1014 if (pPV)
1016 SdPage* pPage = (SdPage*) pPV->GetPage();
1018 if (pPage)
1020 bReturn = pPage->RequestHelp(mpWindow, mpView, rHEvt);
1024 return(bReturn);
1027 void FuPoor::Paint(const Rectangle&, ::sd::Window* )
1031 void FuPoor::ReceiveRequest(SfxRequest& rReq)
1033 const SfxItemSet* pSet = rReq.GetArgs();
1035 if (pSet)
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
1052 return 0L;
1055 void FuPoor::ImpForceQuadratic(Rectangle& rRect)
1057 if(rRect.GetWidth() > rRect.GetHeight())
1059 rRect = Rectangle(
1060 Point(rRect.Left() + ((rRect.GetWidth() - rRect.GetHeight()) / 2), rRect.Top()),
1061 Size(rRect.GetHeight(), rRect.GetHeight()));
1063 else
1065 rRect = Rectangle(
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.
1085 if (nIndex < 0)
1086 nIndex = 0;
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
1108 be called directly.
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);
1117 return true;
1120 return false;
1123 // #i33136#
1124 bool FuPoor::doConstructOrthogonal() const
1126 return (
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: */