bump product version to 5.0.4.1
[LibreOffice.git] / sd / source / ui / func / fupoor.cxx
blobe0ced626668ac5686bbf5121d0587a8a360316c6
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 );
65 FuPoor::FuPoor (
66 ViewShell* pViewSh,
67 ::sd::Window* pWin,
68 ::sd::View* pView,
69 SdDrawDocument* pDrDoc,
70 SfxRequest& rReq)
71 : mpView(pView),
72 mpViewShell(pViewSh),
73 mpWindow(pWin),
74 mpDocSh( pDrDoc->GetDocSh() ),
75 mpDoc(pDrDoc),
76 nSlotId( rReq.GetSlot() ),
77 nSlotValue(0),
78 pDialog(NULL),
79 bIsInDragMode(false),
80 bNoScrollUntilInside (true),
81 bScrollable (false),
82 bDelayActive (false),
83 bFirstMouseMove (false),
84 // remember MouseButton state
85 mnCode(0)
87 ReceiveRequest(rReq);
89 aScrollTimer.SetTimeoutHdl( LINK(this, FuPoor, ScrollHdl) );
90 aScrollTimer.SetTimeout(SELENG_AUTOREPEAT_INTERVAL);
92 aDragTimer.SetTimeoutHdl( LINK(this, FuPoor, DragHdl) );
93 aDragTimer.SetTimeout(SELENG_DRAGDROP_TIMEOUT);
95 aDelayToScrollTimer.SetTimeoutHdl( LINK(this, FuPoor, DelayHdl) );
96 aDelayToScrollTimer.SetTimeout(2000);
99 FuPoor::~FuPoor()
101 aDragTimer.Stop();
102 aScrollTimer.Stop();
103 aDelayToScrollTimer.Stop();
104 pDialog.disposeAndClear();
107 void FuPoor::Activate()
109 if (pDialog)
111 pDialog->Show();
115 void FuPoor::Deactivate()
117 aDragTimer.Stop();
118 aScrollTimer.Stop();
119 aDelayToScrollTimer.Stop ();
120 bScrollable =
121 bDelayActive = false;
123 if (pDialog)
125 pDialog->Hide();
128 if (mpWindow) mpWindow->ReleaseMouse ();
131 void FuPoor::SetWindow(::sd::Window* pWin)
133 mpWindow = pWin;
137 * scroll when approached the border of the window; is called by MouseMove
139 void FuPoor::ForceScroll(const Point& aPixPos)
141 aScrollTimer.Stop();
143 if ( !mpView->IsDragHelpLine() && !mpView->IsSetPageOrg() &&
144 !SlideShow::IsRunning( mpViewShell->GetViewShellBase() ) )
146 Point aPos = mpWindow->OutputToScreenPixel(aPixPos);
147 const Rectangle& rRect = mpViewShell->GetAllWindowRect();
149 if ( bNoScrollUntilInside )
151 if ( rRect.IsInside(aPos) )
152 bNoScrollUntilInside = false;
154 else
156 short dx = 0, dy = 0;
158 if ( aPos.X() <= rRect.Left() ) dx = -1;
159 if ( aPos.X() >= rRect.Right() ) dx = 1;
160 if ( aPos.Y() <= rRect.Top() ) dy = -1;
161 if ( aPos.Y() >= rRect.Bottom() ) dy = 1;
163 if ( dx != 0 || dy != 0 )
165 if (bScrollable)
167 // scroll action in derived class
168 mpViewShell->ScrollLines(dx, dy);
169 aScrollTimer.Start();
171 else if (! bDelayActive) StartDelayToScrollTimer ();
178 * timer handler for window scrolling
180 IMPL_LINK_NOARG_TYPED(FuPoor, ScrollHdl, Timer *, void)
182 Point aPnt(mpWindow->GetPointerPosPixel());
184 // use remembered MouseButton state to create correct
185 // MouseEvents for this artificial MouseMove.
186 MouseMove(MouseEvent(aPnt, 1, MouseEventModifiers::NONE, GetMouseButtonCode()));
190 * handle keyboard events
191 * @returns sal_True if the event was handled, sal_False otherwise
193 bool FuPoor::KeyInput(const KeyEvent& rKEvt)
195 sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode();
196 bool bReturn = false;
197 bool bSlideShow = SlideShow::IsRunning( mpViewShell->GetViewShellBase() );
199 switch (nCode)
201 case KEY_RETURN:
203 if(rKEvt.GetKeyCode().IsMod1())
205 if (mpViewShell->ISA(DrawViewShell))
207 DrawViewShell* pDrawViewShell =
208 static_cast<DrawViewShell*>(mpViewShell);
209 SdPage* pActualPage = pDrawViewShell->GetActualPage();
210 SdrTextObj* pCandidate = 0L;
212 if(pActualPage)
214 SdrObjListIter aIter(*pActualPage, IM_DEEPNOGROUPS);
216 while(aIter.IsMore() && !pCandidate)
218 SdrObject* pObj = aIter.Next();
220 if(pObj && pObj->ISA(SdrTextObj))
222 sal_uInt32 nInv(pObj->GetObjInventor());
223 sal_uInt16 nKnd(pObj->GetObjIdentifier());
225 if(SdrInventor == nInv &&
226 (OBJ_TITLETEXT == nKnd || OBJ_OUTLINETEXT == nKnd || OBJ_TEXT == nKnd))
228 pCandidate = static_cast<SdrTextObj*>(pObj);
234 if(pCandidate)
236 mpView->UnMarkAll();
237 mpView->MarkObj(pCandidate, mpView->GetSdrPageView());
239 mpViewShell->GetViewFrame()->GetDispatcher()->Execute(
240 SID_ATTR_CHAR, SfxCallMode::ASYNCHRON);
242 else
244 // insert a new page with the same page layout
245 mpViewShell->GetViewFrame()->GetDispatcher()->Execute(
246 SID_INSERTPAGE_QUICK, SfxCallMode::ASYNCHRON);
249 // consumed
250 bReturn = true;
253 else
255 // activate OLE object on RETURN for selected object
256 // activate text edit on RETURN for selected object
257 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
259 if( !mpView->IsTextEdit() && 1 == rMarkList.GetMarkCount() )
261 SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
263 if( pObj && pObj->ISA( SdrOle2Obj ) && !mpDocSh->IsUIActive() )
265 //HMHmpView->HideMarkHdl();
266 mpViewShell->ActivateObject( static_cast< SdrOle2Obj* >( pObj ), 0 );
268 else if( pObj && pObj->IsEmptyPresObj() && pObj->ISA( SdrGrafObj ) )
270 mpViewShell->GetViewFrame()->GetDispatcher()->Execute( SID_INSERT_GRAPHIC, SfxCallMode::ASYNCHRON | SfxCallMode::RECORD );
272 else
274 mpViewShell->GetViewFrame()->GetDispatcher()->Execute( SID_ATTR_CHAR, SfxCallMode::ASYNCHRON | SfxCallMode::RECORD );
277 // consumed
278 bReturn = true;
282 break;
284 case KEY_TAB:
286 // handle Mod1 and Mod2 to get travelling running on different systems
287 if(rKEvt.GetKeyCode().IsMod1() || rKEvt.GetKeyCode().IsMod2())
289 // do something with a selected handle?
290 const SdrHdlList& rHdlList = mpView->GetHdlList();
291 bool bForward(!rKEvt.GetKeyCode().IsShift());
293 ((SdrHdlList&)rHdlList).TravelFocusHdl(bForward);
295 // guarantee visibility of focused handle
296 SdrHdl* pHdl = rHdlList.GetFocusHdl();
298 if(pHdl)
300 Point aHdlPosition(pHdl->GetPos());
301 Rectangle aVisRect(aHdlPosition - Point(100, 100), Size(200, 200));
302 mpView->MakeVisible(aVisRect, *mpWindow);
305 // consumed
306 bReturn = true;
309 break;
311 case KEY_ESCAPE:
313 bReturn = FuPoor::cancel();
315 break;
317 case KEY_ADD:
319 if (!mpView->IsTextEdit() && !bSlideShow && !mpDocSh->IsUIActive())
321 // increase zoom
322 mpViewShell->SetZoom(mpWindow->GetZoom() * 3 / 2);
324 if (mpViewShell->ISA(DrawViewShell))
325 static_cast<DrawViewShell*>(mpViewShell)
326 ->SetZoomOnPage(false);
328 bReturn = true;
331 break;
333 case KEY_SUBTRACT:
335 if (!mpView->IsTextEdit() && !bSlideShow && !mpDocSh->IsUIActive())
337 // decrease zoom
338 mpViewShell->SetZoom(mpWindow->GetZoom() * 2 / 3);
340 if (mpViewShell->ISA(DrawViewShell))
341 static_cast<DrawViewShell*>(mpViewShell)
342 ->SetZoomOnPage(false);
344 bReturn = true;
347 break;
349 case KEY_MULTIPLY:
351 if (!mpView->IsTextEdit() && !bSlideShow)
353 // zoom to page
354 mpViewShell->GetViewFrame()->GetDispatcher()->
355 Execute(SID_SIZE_PAGE, SfxCallMode::ASYNCHRON | SfxCallMode::RECORD);
356 bReturn = true;
359 break;
361 case KEY_DIVIDE:
363 if (!mpView->IsTextEdit() && !bSlideShow)
365 // zoom to selected objects
366 mpViewShell->GetViewFrame()->GetDispatcher()->
367 Execute(SID_SIZE_OPTIMAL, SfxCallMode::ASYNCHRON | SfxCallMode::RECORD);
368 bReturn = true;
371 break;
373 case KEY_POINT:
375 ZoomList* pZoomList = mpViewShell->GetZoomList();
377 if (!mpView->IsTextEdit() && pZoomList->IsNextPossible() && !bSlideShow && !mpDocSh->IsUIActive())
379 // use next ZoomRect
380 mpViewShell->SetZoomRect(pZoomList->GetNextZoomRect());
381 bReturn = true;
384 break;
386 case KEY_COMMA:
388 ZoomList* pZoomList = mpViewShell->GetZoomList();
390 if (!mpView->IsTextEdit() && pZoomList->IsPreviousPossible() && !bSlideShow && !mpDocSh->IsUIActive())
392 // use previous ZoomRect
393 mpViewShell->SetZoomRect(pZoomList->GetPreviousZoomRect());
394 bReturn = true;
397 break;
399 case KEY_HOME:
401 if (!mpView->IsTextEdit()
402 && mpViewShell->ISA(DrawViewShell)
403 && !bSlideShow)
405 // jump to first page
406 static_cast<DrawViewShell*>(mpViewShell)->SwitchPage(0);
407 bReturn = true;
410 break;
412 case KEY_END:
414 if (!mpView->IsTextEdit()
415 && mpViewShell->ISA(DrawViewShell)
416 && !bSlideShow)
418 // jump to last page
419 SdPage* pPage =
420 static_cast<DrawViewShell*>(mpViewShell)->GetActualPage();
421 static_cast<DrawViewShell*>(mpViewShell)
422 ->SwitchPage(mpDoc->GetSdPageCount(
423 pPage->GetPageKind()) - 1);
424 bReturn = true;
427 break;
429 case KEY_PAGEUP:
431 if( rKEvt.GetKeyCode().IsMod1() && rKEvt.GetKeyCode().IsMod2() )
432 break;
434 if(mpViewShell->ISA(DrawViewShell) && !bSlideShow)
436 // The page-up key switches layers or pages depending on the
437 // modifier key.
438 if ( ! rKEvt.GetKeyCode().GetModifier())
440 // With no modifier pressed we move to the previous
441 // slide.
442 mpView->SdrEndTextEdit();
444 // Previous page.
445 bReturn = true;
446 SdPage* pPage = static_cast<DrawViewShell*>(mpViewShell)->GetActualPage();
447 sal_uInt16 nSdPage = (pPage->GetPageNum() - 1) / 2;
449 if (nSdPage > 0)
451 // Switch the page and send events regarding
452 // deactivation the old page and activating the new
453 // one.
454 TabControl& rPageTabControl =
455 static_cast<DrawViewShell*>(mpViewShell)
456 ->GetPageTabControl();
457 if (rPageTabControl.IsReallyShown())
458 rPageTabControl.SendDeactivatePageEvent ();
459 static_cast<DrawViewShell*>(mpViewShell)->SwitchPage(nSdPage - 1);
460 if (rPageTabControl.IsReallyShown())
461 rPageTabControl.SendActivatePageEvent ();
464 else if (rKEvt.GetKeyCode().IsMod1())
466 // With the CONTROL modifier we switch layers.
467 if (static_cast<DrawViewShell*>(mpViewShell)->IsLayerModeActive())
469 // Moves to the previous layer.
470 SwitchLayer (-1);
475 break;
477 case KEY_PAGEDOWN:
479 if( rKEvt.GetKeyCode().IsMod1() && rKEvt.GetKeyCode().IsMod2() )
480 break;
481 if(mpViewShell->ISA(DrawViewShell) && !bSlideShow)
483 // The page-down key switches layers or pages depending on the
484 // modifier key.
485 if ( ! rKEvt.GetKeyCode().GetModifier())
487 // With no modifier pressed we move to the next slide.
488 mpView->SdrEndTextEdit();
490 // Next page.
491 bReturn = true;
492 SdPage* pPage = static_cast<DrawViewShell*>(mpViewShell)->GetActualPage();
493 sal_uInt16 nSdPage = (pPage->GetPageNum() - 1) / 2;
495 if (nSdPage < mpDoc->GetSdPageCount(pPage->GetPageKind()) - 1)
497 // Switch the page and send events regarding
498 // deactivation the old page and activating the new
499 // one.
500 TabControl& rPageTabControl =
501 static_cast<DrawViewShell*>(mpViewShell)->GetPageTabControl();
502 if (rPageTabControl.IsReallyShown())
503 rPageTabControl.SendDeactivatePageEvent ();
504 static_cast<DrawViewShell*>(mpViewShell)->SwitchPage(nSdPage + 1);
505 if (rPageTabControl.IsReallyShown())
506 rPageTabControl.SendActivatePageEvent ();
509 else if (rKEvt.GetKeyCode().IsMod1())
511 // With the CONTROL modifier we switch layers.
512 if (static_cast<DrawViewShell*>(mpViewShell)->IsLayerModeActive())
514 // With the layer mode active pressing page-down
515 // moves to the next layer.
516 SwitchLayer (+1);
521 break;
523 // change select state when focus is on poly point
524 case KEY_SPACE:
526 const SdrHdlList& rHdlList = mpView->GetHdlList();
527 SdrHdl* pHdl = rHdlList.GetFocusHdl();
529 if(pHdl)
531 if(pHdl->GetKind() == HDL_POLY)
533 // rescue ID of point with focus
534 sal_uInt32 nPol(pHdl->GetPolyNum());
535 sal_uInt32 nPnt(pHdl->GetPointNum());
537 if(mpView->IsPointMarked(*pHdl))
539 if(rKEvt.GetKeyCode().IsShift())
541 mpView->UnmarkPoint(*pHdl);
544 else
546 if(!rKEvt.GetKeyCode().IsShift())
548 mpView->UnmarkAllPoints();
551 mpView->MarkPoint(*pHdl);
554 if(0L == rHdlList.GetFocusHdl())
556 // restore point with focus
557 SdrHdl* pNewOne = 0L;
559 for(size_t a = 0; !pNewOne && a < rHdlList.GetHdlCount(); ++a)
561 SdrHdl* pAct = rHdlList.GetHdl(a);
563 if(pAct
564 && pAct->GetKind() == HDL_POLY
565 && pAct->GetPolyNum() == nPol
566 && pAct->GetPointNum() == nPnt)
568 pNewOne = pAct;
572 if(pNewOne)
574 ((SdrHdlList&)rHdlList).SetFocusHdl(pNewOne);
578 bReturn = true;
582 break;
584 case KEY_UP:
585 case KEY_DOWN:
586 case KEY_LEFT:
587 case KEY_RIGHT:
589 if (!mpView->IsTextEdit() && !bSlideShow)
591 long nX = 0;
592 long nY = 0;
594 if (nCode == KEY_UP)
596 // scroll up
597 nX = 0;
598 nY =-1;
600 else if (nCode == KEY_DOWN)
602 // scroll down
603 nX = 0;
604 nY = 1;
606 else if (nCode == KEY_LEFT)
608 // scroll left
609 nX =-1;
610 nY = 0;
612 else if (nCode == KEY_RIGHT)
614 // scroll right
615 nX = 1;
616 nY = 0;
619 if (mpView->AreObjectsMarked() && !rKEvt.GetKeyCode().IsMod1() &&
620 !mpDocSh->IsReadOnly())
622 const SdrHdlList& rHdlList = mpView->GetHdlList();
623 SdrHdl* pHdl = rHdlList.GetFocusHdl();
625 bool bIsMoveOfConnectedHandle(false);
626 bool bOldSuppress = false;
627 SdrEdgeObj* pEdgeObj = 0L;
629 if(pHdl && pHdl->GetObj() && pHdl->GetObj()->ISA(SdrEdgeObj) && 0 == pHdl->GetPolyNum())
631 pEdgeObj = static_cast<SdrEdgeObj*>(pHdl->GetObj());
633 if(0L == pHdl->GetPointNum())
635 if(pEdgeObj->GetConnection(true).GetObject())
637 bIsMoveOfConnectedHandle = true;
640 if(1L == pHdl->GetPointNum())
642 if(pEdgeObj->GetConnection(false).GetObject())
644 bIsMoveOfConnectedHandle = true;
649 if(pEdgeObj)
651 // Suppress default connects to inside object and object center
652 bOldSuppress = pEdgeObj->GetSuppressDefaultConnect();
653 pEdgeObj->SetSuppressDefaultConnect(true);
656 if(bIsMoveOfConnectedHandle)
658 sal_uInt16 nMarkHdSiz(mpView->GetMarkHdlSizePixel());
659 Size aHalfConSiz(nMarkHdSiz + 1, nMarkHdSiz + 1);
660 aHalfConSiz = mpWindow->PixelToLogic(aHalfConSiz);
662 if(100 < aHalfConSiz.Width())
663 nX *= aHalfConSiz.Width();
664 else
665 nX *= 100;
667 if(100 < aHalfConSiz.Height())
668 nY *= aHalfConSiz.Height();
669 else
670 nY *= 100;
672 else if(rKEvt.GetKeyCode().IsMod2())
674 // move in 1 pixel distance
675 Size aLogicSizeOnePixel = mpWindow->PixelToLogic(Size(1,1));
676 nX *= aLogicSizeOnePixel.Width();
677 nY *= aLogicSizeOnePixel.Height();
679 else if(rKEvt.GetKeyCode().IsShift())
681 nX *= 1000;
682 nY *= 1000;
684 else
686 // old, fixed move distance
687 nX *= 100;
688 nY *= 100;
691 if(0L == pHdl)
693 // only take action when move is allowed
694 if(mpView->IsMoveAllowed())
696 // restrict movement to WorkArea
697 const Rectangle& rWorkArea = mpView->GetWorkArea();
699 if(!rWorkArea.IsEmpty())
701 Rectangle aMarkRect(mpView->GetMarkedObjRect());
702 aMarkRect.Move(nX, nY);
704 if(!aMarkRect.IsInside(rWorkArea))
706 if(aMarkRect.Left() < rWorkArea.Left())
708 nX += rWorkArea.Left() - aMarkRect.Left();
711 if(aMarkRect.Right() > rWorkArea.Right())
713 nX -= aMarkRect.Right() - rWorkArea.Right();
716 if(aMarkRect.Top() < rWorkArea.Top())
718 nY += rWorkArea.Top() - aMarkRect.Top();
721 if(aMarkRect.Bottom() > rWorkArea.Bottom())
723 nY -= aMarkRect.Bottom() - rWorkArea.Bottom();
728 // no handle selected
729 if(0 != nX || 0 != nY)
731 mpView->MoveAllMarked(Size(nX, nY));
733 mpView->MakeVisible(mpView->GetAllMarkedRect(), *mpWindow);
737 else
739 // move handle with index nHandleIndex
740 if(pHdl && (nX || nY))
742 // now move the Handle (nX, nY)
743 Point aStartPoint(pHdl->GetPos());
744 Point aEndPoint(pHdl->GetPos() + Point(nX, nY));
745 const SdrDragStat& rDragStat = mpView->GetDragStat();
747 // start dragging
748 mpView->BegDragObj(aStartPoint, 0, pHdl, 0);
750 if(mpView->IsDragObj())
752 bool bWasNoSnap = rDragStat.IsNoSnap();
753 bool bWasSnapEnabled = mpView->IsSnapEnabled();
755 // switch snapping off
756 if(!bWasNoSnap)
757 ((SdrDragStat&)rDragStat).SetNoSnap(true);
758 if(bWasSnapEnabled)
759 mpView->SetSnapEnabled(false);
761 mpView->MovAction(aEndPoint);
762 mpView->EndDragObj();
764 // restore snap
765 if(!bWasNoSnap)
766 ((SdrDragStat&)rDragStat).SetNoSnap(bWasNoSnap);
767 if(bWasSnapEnabled)
768 mpView->SetSnapEnabled(bWasSnapEnabled);
771 // make moved handle visible
772 Rectangle aVisRect(aEndPoint - Point(100, 100), Size(200, 200));
773 mpView->MakeVisible(aVisRect, *mpWindow);
777 if(pEdgeObj)
779 // Restore original suppress value
780 pEdgeObj->SetSuppressDefaultConnect(bOldSuppress);
783 else
785 // scroll page
786 mpViewShell->ScrollLines(nX, nY);
789 bReturn = true;
792 break;
795 if (bReturn)
797 mpWindow->ReleaseMouse();
800 // when a text-editable object is selected and the
801 // input character is printable, activate text edit on that object
802 // and feed character to object
803 if(!bReturn && !mpDocSh->IsReadOnly())
805 if(!mpView->IsTextEdit() && mpViewShell)
807 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
809 if(1 == rMarkList.GetMarkCount())
811 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
813 // #i118485# allow TextInput for OLEs, too
814 if(pObj->ISA(SdrTextObj) && pObj->HasTextEdit())
816 // use common IsSimpleCharInput from the EditEngine.
817 bool bPrintable(EditEngine::IsSimpleCharInput(rKEvt));
819 if(bPrintable)
821 // try to activate textedit mode for the selected object
822 SfxStringItem aInputString(SID_ATTR_CHAR, OUString(rKEvt.GetCharCode()));
824 mpViewShell->GetViewFrame()->GetDispatcher()->Execute(
825 SID_ATTR_CHAR,
826 SfxCallMode::ASYNCHRON,
827 &aInputString,
828 0L);
830 // consumed
831 bReturn = true;
835 else
837 // test if there is a title object there. If yes, try to
838 // set it to edit mode and start typing...
839 if(mpViewShell->ISA(DrawViewShell)
840 && EditEngine::IsSimpleCharInput(rKEvt))
842 DrawViewShell* pDrawViewShell =
843 static_cast<DrawViewShell*>(mpViewShell);
844 SdPage* pActualPage = pDrawViewShell->GetActualPage();
845 SdrTextObj* pCandidate = 0L;
847 if(pActualPage)
849 SdrObjListIter aIter(*pActualPage, IM_DEEPNOGROUPS);
851 while(aIter.IsMore() && !pCandidate)
853 SdrObject* pObj = aIter.Next();
855 if(pObj && pObj->ISA(SdrTextObj))
857 sal_uInt32 nInv(pObj->GetObjInventor());
858 sal_uInt16 nKnd(pObj->GetObjIdentifier());
860 if(SdrInventor == nInv && OBJ_TITLETEXT == nKnd)
862 pCandidate = static_cast<SdrTextObj*>(pObj);
868 // when candidate found and candidate is untouched, start editing text...
869 if(pCandidate && pCandidate->IsEmptyPresObj())
871 mpView->UnMarkAll();
872 mpView->MarkObj(pCandidate, mpView->GetSdrPageView());
873 SfxStringItem aInputString(SID_ATTR_CHAR, OUString(rKEvt.GetCharCode()));
875 mpViewShell->GetViewFrame()->GetDispatcher()->Execute(
876 SID_ATTR_CHAR,
877 SfxCallMode::ASYNCHRON,
878 &aInputString,
879 0L);
881 // consumed
882 bReturn = true;
889 return bReturn;
892 bool FuPoor::MouseMove(const MouseEvent& )
894 return false;
897 void FuPoor::SelectionHasChanged()
899 const SdrHdlList& rHdlList = mpView->GetHdlList();
900 ((SdrHdlList&)rHdlList).ResetFocusHdl();
904 * Cut object to clipboard
906 void FuPoor::DoCut()
908 if (mpView)
910 mpView->DoCut(mpWindow);
915 * Copy object to clipboard
917 void FuPoor::DoCopy()
919 if (mpView)
921 mpView->DoCopy(mpWindow);
926 * Paste object from clipboard
928 void FuPoor::DoPaste()
930 if (mpView)
932 mpView->DoPaste(mpWindow);
937 * Paste unformatted text from clipboard
939 void FuPoor::DoPasteUnformatted()
941 if (mpView)
943 sal_Int8 nAction = DND_ACTION_COPY;
944 TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( mpViewShell->GetActiveWindow() ) );
945 if (aDataHelper.GetTransferable().is())
947 mpView->InsertData( aDataHelper,
948 mpWindow->PixelToLogic( Rectangle( Point(), mpWindow->GetOutputSizePixel() ).Center() ),
949 nAction, false, SotClipboardFormatId::STRING);
955 * Timer handler for Drag&Drop
957 IMPL_LINK_NOARG_TYPED(FuPoor, DragHdl, Timer *, void)
959 if( mpView )
961 sal_uInt16 nHitLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(HITPIX,0)).Width() );
962 SdrHdl* pHdl = mpView->PickHandle(aMDPos);
964 if ( pHdl==NULL && mpView->IsMarkedHit(aMDPos, nHitLog)
965 && !mpView->IsPresObjSelected(false, true) )
967 mpWindow->ReleaseMouse();
968 bIsInDragMode = true;
969 mpView->StartDrag( aMDPos, mpWindow );
974 bool FuPoor::Command(const CommandEvent& rCEvt)
976 return mpView->Command(rCEvt,mpWindow);
980 * Timer handler for window scrolling
982 IMPL_LINK_NOARG_TYPED(FuPoor, DelayHdl, Timer *, void)
984 aDelayToScrollTimer.Stop ();
985 bScrollable = true;
987 Point aPnt(mpWindow->GetPointerPosPixel());
989 // use remembered MouseButton state to create correct
990 // MouseEvents for this artificial MouseMove.
991 MouseMove(MouseEvent(aPnt, 1, MouseEventModifiers::NONE, GetMouseButtonCode()));
994 bool FuPoor::MouseButtonUp (const MouseEvent& rMEvt)
996 // remember button state for creation of own MouseEvents
997 SetMouseButtonCode(rMEvt.GetButtons());
999 aDelayToScrollTimer.Stop ();
1000 return bScrollable =
1001 bDelayActive = false;
1004 bool FuPoor::MouseButtonDown(const MouseEvent& rMEvt)
1006 // remember button state for creation of own MouseEvents
1007 SetMouseButtonCode(rMEvt.GetButtons());
1009 return false;
1012 void FuPoor::StartDelayToScrollTimer ()
1014 bDelayActive = true;
1015 aDelayToScrollTimer.Start ();
1018 bool FuPoor::RequestHelp(const HelpEvent& rHEvt)
1020 bool bReturn = false;
1022 SdrPageView* pPV = mpView->GetSdrPageView();
1024 if (pPV)
1026 SdPage* pPage = static_cast<SdPage*>( pPV->GetPage() );
1028 if (pPage)
1030 bReturn = FmFormPage::RequestHelp(mpWindow, mpView, rHEvt);
1034 return bReturn;
1037 void FuPoor::ReceiveRequest(SfxRequest& rReq)
1039 const SfxItemSet* pSet = rReq.GetArgs();
1041 if (pSet)
1043 if( pSet->GetItemState( nSlotId ) == SfxItemState::SET )
1045 const SfxPoolItem& rItem = pSet->Get( nSlotId );
1047 if( rItem.ISA( SfxAllEnumItem ) )
1049 nSlotValue = static_cast<const SfxAllEnumItem&>( rItem ).GetValue();
1055 SdrObject* FuPoor::CreateDefaultObject(const sal_uInt16, const Rectangle& )
1057 // empty base implementation
1058 return 0L;
1061 void FuPoor::ImpForceQuadratic(Rectangle& rRect)
1063 if(rRect.GetWidth() > rRect.GetHeight())
1065 rRect = Rectangle(
1066 Point(rRect.Left() + ((rRect.GetWidth() - rRect.GetHeight()) / 2), rRect.Top()),
1067 Size(rRect.GetHeight(), rRect.GetHeight()));
1069 else
1071 rRect = Rectangle(
1072 Point(rRect.Left(), rRect.Top() + ((rRect.GetHeight() - rRect.GetWidth()) / 2)),
1073 Size(rRect.GetWidth(), rRect.GetWidth()));
1077 void FuPoor::SwitchLayer (sal_Int32 nOffset)
1079 if(mpViewShell && mpViewShell->ISA(DrawViewShell))
1081 DrawViewShell* pDrawViewShell =
1082 static_cast<DrawViewShell*>(mpViewShell);
1084 // Calculate the new index.
1085 sal_Int32 nIndex = pDrawViewShell->GetActiveTabLayerIndex() + nOffset;
1087 // Make sure the new index lies inside the range of valid indices.
1088 if (nIndex < 0)
1089 nIndex = 0;
1090 else if (nIndex >= pDrawViewShell->GetTabLayerCount ())
1091 nIndex = pDrawViewShell->GetTabLayerCount() - 1;
1093 // Set the new active layer.
1094 if (nIndex != pDrawViewShell->GetActiveTabLayerIndex ())
1096 LayerTabBar* pLayerTabControl =
1097 static_cast<DrawViewShell*>(mpViewShell)->GetLayerTabControl();
1098 if (pLayerTabControl != NULL)
1099 pLayerTabControl->SendDeactivatePageEvent ();
1101 pDrawViewShell->SetActiveTabLayerIndex (nIndex);
1103 if (pLayerTabControl != NULL)
1104 pLayerTabControl->SendActivatePageEvent ();
1109 /** is called when the current function should be aborted. <p>
1110 This is used when a function gets a KEY_ESCAPE but can also
1111 be called directly.
1113 @returns true if a active function was aborted
1115 bool FuPoor::cancel()
1117 if ( !this->ISA(FuSelection) )
1119 mpViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SfxCallMode::ASYNCHRON);
1120 return true;
1123 return false;
1126 // #i33136#
1127 bool FuPoor::doConstructOrthogonal() const
1129 return (
1130 SID_DRAW_XLINE == nSlotId ||
1131 SID_DRAW_CIRCLEARC == nSlotId ||
1132 SID_DRAW_SQUARE == nSlotId ||
1133 SID_DRAW_SQUARE_NOFILL == nSlotId ||
1134 SID_DRAW_SQUARE_ROUND == nSlotId ||
1135 SID_DRAW_SQUARE_ROUND_NOFILL == nSlotId ||
1136 SID_DRAW_CIRCLE == nSlotId ||
1137 SID_DRAW_CIRCLE_NOFILL == nSlotId ||
1138 SID_DRAW_CIRCLEPIE == nSlotId ||
1139 SID_DRAW_CIRCLEPIE_NOFILL == nSlotId ||
1140 SID_DRAW_CIRCLECUT == nSlotId ||
1141 SID_DRAW_CIRCLECUT_NOFILL == nSlotId ||
1142 SID_DRAW_XPOLYGON == nSlotId ||
1143 SID_DRAW_XPOLYGON_NOFILL == nSlotId ||
1144 SID_3D_CUBE == nSlotId ||
1145 SID_3D_SPHERE == nSlotId ||
1146 SID_3D_SHELL == nSlotId ||
1147 SID_3D_HALF_SPHERE == nSlotId ||
1148 SID_3D_TORUS == nSlotId ||
1149 SID_3D_CYLINDER == nSlotId ||
1150 SID_3D_CONE == nSlotId ||
1151 SID_3D_PYRAMID == nSlotId);
1154 void FuPoor::DoExecute( SfxRequest& )
1158 } // end of namespace sd
1160 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */