LCOV - code coverage report
Current view: top level - sc/source/ui/drawfunc - fudraw.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 6 330 1.8 %
Date: 2014-04-11 Functions: 4 19 21.1 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      20             : #include <editeng/editeng.hxx>
      21             : #include <editeng/outlobj.hxx>
      22             : #include <svx/svdobj.hxx>
      23             : #include <svx/svdoole2.hxx>
      24             : #include <svx/svdouno.hxx>
      25             : #include <svx/svdocapt.hxx>
      26             : #include <svx/svdpage.hxx>
      27             : #include <svx/svditer.hxx>
      28             : #include <svx/svdundo.hxx>
      29             : #include <sfx2/dispatch.hxx>
      30             : #include <sfx2/viewfrm.hxx>
      31             : 
      32             : #include "sc.hrc"
      33             : #include "fudraw.hxx"
      34             : #include "futext.hxx"
      35             : #include "tabvwsh.hxx"
      36             : #include "drwlayer.hxx"
      37             : #include "scresid.hxx"
      38             : #include "userdat.hxx"
      39             : #include "docsh.hxx"
      40             : #include "postit.hxx"
      41             : #include "globstr.hrc"
      42             : #include "drawview.hxx"
      43             : 
      44             : /*************************************************************************
      45             : |*
      46             : |* Basisklasse fuer alle Drawmodul-spezifischen Funktionen
      47             : |*
      48             : \************************************************************************/
      49             : 
      50         222 : FuDraw::FuDraw(ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pViewP,
      51             :                SdrModel* pDoc, SfxRequest& rReq) :
      52             :     FuPoor      (pViewSh, pWin, pViewP, pDoc, rReq),
      53             :     aNewPointer ( POINTER_ARROW ),
      54         222 :     aOldPointer ( POINTER_ARROW )
      55             : {
      56         222 : }
      57             : 
      58             : /*************************************************************************
      59             : |*
      60             : |* Destruktor
      61             : |*
      62             : \************************************************************************/
      63             : 
      64         218 : FuDraw::~FuDraw()
      65             : {
      66         218 : }
      67             : 
      68             : /*************************************************************************
      69             : |*
      70             : |* Modifier-Tasten auswerten
      71             : |*
      72             : \************************************************************************/
      73             : 
      74           0 : void FuDraw::DoModifiers(const MouseEvent& rMEvt)
      75             : {
      76             :     //  Shift   = Ortho und AngleSnap
      77             :     //  Control = Snap (Toggle)
      78             :     //  Alt     = zentrisch
      79             : 
      80           0 :     sal_Bool bShift = rMEvt.IsShift();
      81           0 :     sal_Bool bAlt   = rMEvt.IsMod2();
      82             : 
      83           0 :     bool bOrtho     = bShift;
      84           0 :     bool bAngleSnap = bShift;
      85           0 :     bool bCenter    = bAlt;
      86             : 
      87             :     // #i33136#
      88           0 :     if(doConstructOrthogonal())
      89             :     {
      90           0 :         bOrtho = !bShift;
      91             :     }
      92             : 
      93           0 :     if (pView->IsOrtho() != bOrtho)
      94           0 :         pView->SetOrtho(bOrtho);
      95           0 :     if (pView->IsAngleSnapEnabled() != bAngleSnap)
      96           0 :         pView->SetAngleSnapEnabled(bAngleSnap);
      97             : 
      98           0 :     if (pView->IsCreate1stPointAsCenter() != bCenter)
      99           0 :         pView->SetCreate1stPointAsCenter(bCenter);
     100           0 :     if (pView->IsResizeAtCenter() != bCenter)
     101           0 :         pView->SetResizeAtCenter(bCenter);
     102             : 
     103           0 : }
     104             : 
     105           0 : void FuDraw::ResetModifiers()
     106             : {
     107           0 :     ScViewData* pViewData = pViewShell->GetViewData();
     108           0 :     const ScViewOptions& rOpt = pViewData->GetOptions();
     109           0 :     const ScGridOptions& rGrid = rOpt.GetGridOptions();
     110           0 :     bool bGridOpt = rGrid.GetUseGridSnap();
     111             : 
     112           0 :     if (pView->IsOrtho())
     113           0 :         pView->SetOrtho(false);
     114           0 :     if (pView->IsAngleSnapEnabled())
     115           0 :         pView->SetAngleSnapEnabled(false);
     116             : 
     117           0 :     if (pView->IsGridSnap() != bGridOpt)
     118           0 :         pView->SetGridSnap(bGridOpt);
     119           0 :     if (pView->IsSnapEnabled() != bGridOpt)
     120           0 :         pView->SetSnapEnabled(bGridOpt);
     121             : 
     122           0 :     if (pView->IsCreate1stPointAsCenter())
     123           0 :         pView->SetCreate1stPointAsCenter(false);
     124           0 :     if (pView->IsResizeAtCenter())
     125           0 :         pView->SetResizeAtCenter(false);
     126           0 : }
     127             : 
     128             : /*************************************************************************
     129             : |*
     130             : |* MouseButtonDown-event
     131             : |*
     132             : \************************************************************************/
     133             : 
     134           0 : bool FuDraw::MouseButtonDown(const MouseEvent& rMEvt)
     135             : {
     136             :     // remember button state for creation of own MouseEvents
     137           0 :     SetMouseButtonCode(rMEvt.GetButtons());
     138             : 
     139           0 :     DoModifiers( rMEvt );
     140           0 :     return false;
     141             : }
     142             : 
     143             : /*************************************************************************
     144             : |*
     145             : |* MouseMove-event
     146             : |*
     147             : \************************************************************************/
     148             : 
     149           0 : bool FuDraw::MouseMove(const MouseEvent& rMEvt)
     150             : {
     151             :     //  evaluate modifiers only if in a drawing layer action
     152             :     //  (don't interfere with keyboard shortcut handling)
     153           0 :     if (pView->IsAction())
     154           0 :         DoModifiers( rMEvt );
     155             : 
     156           0 :     return false;
     157             : }
     158             : 
     159             : /*************************************************************************
     160             : |*
     161             : |* MouseButtonUp-event
     162             : |*
     163             : \************************************************************************/
     164             : 
     165           0 : bool FuDraw::MouseButtonUp(const MouseEvent& rMEvt)
     166             : {
     167             :     // remember button state for creation of own MouseEvents
     168           0 :     SetMouseButtonCode(rMEvt.GetButtons());
     169             : 
     170           0 :     ResetModifiers();
     171           0 :     return false;
     172             : }
     173             : 
     174             : /*************************************************************************
     175             : |*
     176             : |* Tastaturereignisse bearbeiten
     177             : |*
     178             : |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert sal_True, andernfalls
     179             : |* FALSE.
     180             : |*
     181             : \************************************************************************/
     182             : 
     183           0 : static sal_Bool lcl_KeyEditMode( SdrObject* pObj, ScTabViewShell* pViewShell, const KeyEvent* pInitialKey )
     184             : {
     185           0 :     sal_Bool bReturn = false;
     186           0 :     if ( pObj && pObj->ISA(SdrTextObj) && !pObj->ISA(SdrUnoObj) )
     187             :     {
     188             :         // start text edit - like FuSelection::MouseButtonUp,
     189             :         // but with bCursorToEnd instead of mouse position
     190             : 
     191           0 :         OutlinerParaObject* pOPO = pObj->GetOutlinerParaObject();
     192           0 :         sal_Bool bVertical = ( pOPO && pOPO->IsVertical() );
     193           0 :         sal_uInt16 nTextSlotId = bVertical ? SID_DRAW_TEXT_VERTICAL : SID_DRAW_TEXT;
     194             : 
     195             :         // don't switch shells if text shell is already active
     196           0 :         FuPoor* pPoor = pViewShell->GetViewData()->GetView()->GetDrawFuncPtr();
     197           0 :         if ( !pPoor || pPoor->GetSlotID() != nTextSlotId )
     198             :         {
     199           0 :             pViewShell->GetViewData()->GetDispatcher().
     200           0 :                 Execute(nTextSlotId, SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD);
     201             :         }
     202             : 
     203             :         // get the resulting FuText and set in edit mode
     204           0 :         pPoor = pViewShell->GetViewData()->GetView()->GetDrawFuncPtr();
     205           0 :         if ( pPoor && pPoor->GetSlotID() == nTextSlotId )    // no RTTI
     206             :         {
     207           0 :             FuText* pText = (FuText*)pPoor;
     208           0 :             pText->SetInEditMode( pObj, NULL, true, pInitialKey );
     209             :             //! set cursor to end of text
     210             :         }
     211           0 :         bReturn = sal_True;
     212             :     }
     213           0 :     return bReturn;
     214             : }
     215             : 
     216           0 : bool FuDraw::KeyInput(const KeyEvent& rKEvt)
     217             : {
     218           0 :     bool bReturn = false;
     219           0 :     ScViewData& rViewData = *pViewShell->GetViewData();
     220             : 
     221           0 :     switch ( rKEvt.GetKeyCode().GetCode() )
     222             :     {
     223             :         case KEY_ESCAPE:
     224           0 :             if ( pViewShell->IsDrawTextShell() || aSfxRequest.GetSlot() == SID_DRAW_NOTEEDIT )
     225             :             {
     226             :                 // in normale Draw-Shell, wenn Objekt selektiert, sonst Zeichnen aus
     227           0 :                 rViewData.GetDispatcher().Execute(aSfxRequest.GetSlot(), SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
     228           0 :                 bReturn = true;
     229             :             }
     230           0 :             else if ( pViewShell->IsDrawSelMode() )
     231             :             {
     232           0 :                 pView->UnmarkAll();
     233           0 :                 rViewData.GetDispatcher().Execute(SID_OBJECT_SELECT, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
     234           0 :                 bReturn = true;
     235             :             }
     236           0 :             else if ( pView->AreObjectsMarked() )
     237             :             {
     238             :                 // III
     239           0 :                 SdrHdlList& rHdlList = const_cast< SdrHdlList& >( pView->GetHdlList() );
     240           0 :                 if( rHdlList.GetFocusHdl() )
     241           0 :                     rHdlList.ResetFocusHdl();
     242             :                 else
     243           0 :                     pView->UnmarkAll();
     244             : 
     245             :                 //  Beim Bezier-Editieren ist jetzt wieder das Objekt selektiert
     246           0 :                 if (!pView->AreObjectsMarked())
     247           0 :                     pViewShell->SetDrawShell( false );
     248             : 
     249           0 :                 bReturn = true;
     250             :             }
     251           0 :             break;
     252             : 
     253             :         case KEY_DELETE:                    //! ueber Accelerator
     254           0 :             pView->DeleteMarked();
     255           0 :             bReturn = true;
     256           0 :         break;
     257             : 
     258             :         case KEY_RETURN:
     259             :         {
     260           0 :             if( rKEvt.GetKeyCode().GetModifier() == 0 )
     261             :             {
     262             :                 // activate OLE object on RETURN for selected object
     263             :                 // put selected text object in edit mode
     264           0 :                 const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
     265           0 :                 if( !pView->IsTextEdit() && 1 == rMarkList.GetMarkCount() )
     266             :                 {
     267           0 :                     sal_Bool bOle = pViewShell->GetViewFrame()->GetFrame().IsInPlace();
     268           0 :                     SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
     269           0 :                     if( pObj && pObj->ISA( SdrOle2Obj ) && !bOle )
     270             :                     {
     271           0 :                         pViewShell->ActivateObject( static_cast< SdrOle2Obj* >( pObj ), 0 );
     272             : 
     273             :                         // consumed
     274           0 :                         bReturn = true;
     275             :                     }
     276           0 :                     else if ( lcl_KeyEditMode( pObj, pViewShell, NULL ) )       // start text edit for suitable object
     277           0 :                         bReturn = true;
     278             :                 }
     279             :             }
     280             :         }
     281           0 :         break;
     282             : 
     283             :         case KEY_F2:
     284             :         {
     285           0 :             if( rKEvt.GetKeyCode().GetModifier() == 0 )
     286             :             {
     287             :                 // put selected text object in edit mode
     288             :                 // (this is not SID_SETINPUTMODE, but F2 hardcoded, like in Writer)
     289           0 :                 const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
     290           0 :                 if( !pView->IsTextEdit() && 1 == rMarkList.GetMarkCount() )
     291             :                 {
     292           0 :                     SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
     293           0 :                     if ( lcl_KeyEditMode( pObj, pViewShell, NULL ) )            // start text edit for suitable object
     294           0 :                         bReturn = true;
     295             :                 }
     296             :             }
     297             :         }
     298           0 :         break;
     299             : 
     300             :         // #97016#
     301             :         case KEY_TAB:
     302             :         {
     303             :             // in calc do NOT start draw object selection using TAB/SHIFT-TAB when
     304             :             // there is not yet a object selected
     305           0 :             if(pView->AreObjectsMarked())
     306             :             {
     307           0 :                 KeyCode aCode = rKEvt.GetKeyCode();
     308             : 
     309           0 :                 if ( !aCode.IsMod1() && !aCode.IsMod2() )
     310             :                 {
     311             :                     // changeover to the next object
     312           0 :                     if(!pView->MarkNextObj( !aCode.IsShift() ))
     313             :                     {
     314             :                         //If there is only one object, don't do the UnmarkAlllObj() & MarkNextObj().
     315           0 :                         if ( pView->GetMarkableObjCount() > 1 && pView->HasMarkableObj() )
     316             :                         {
     317             :                             // No next object: go over open end and
     318             :                             // get first from the other side
     319           0 :                             pView->UnmarkAllObj();
     320           0 :                             pView->MarkNextObj(!aCode.IsShift());
     321             :                         }
     322             :                     }
     323             : 
     324             :                     // II
     325           0 :                     if(pView->AreObjectsMarked())
     326           0 :                         pView->MakeVisible(pView->GetAllMarkedRect(), *pWindow);
     327             : 
     328           0 :                     bReturn = true;
     329             :                 }
     330             : 
     331             :                 // handle Mod1 and Mod2 to get travelling running on different systems
     332           0 :                 if(rKEvt.GetKeyCode().IsMod1() || rKEvt.GetKeyCode().IsMod2())
     333             :                 {
     334             :                     // II do something with a selected handle?
     335           0 :                     const SdrHdlList& rHdlList = pView->GetHdlList();
     336           0 :                     sal_Bool bForward(!rKEvt.GetKeyCode().IsShift());
     337             : 
     338           0 :                     ((SdrHdlList&)rHdlList).TravelFocusHdl(bForward);
     339             : 
     340             :                     // guarantee visibility of focused handle
     341           0 :                     SdrHdl* pHdl = rHdlList.GetFocusHdl();
     342             : 
     343           0 :                     if(pHdl)
     344             :                     {
     345           0 :                         Point aHdlPosition(pHdl->GetPos());
     346           0 :                         Rectangle aVisRect(aHdlPosition - Point(100, 100), Size(200, 200));
     347           0 :                         pView->MakeVisible(aVisRect, *pWindow);
     348             :                     }
     349             : 
     350             :                     // consumed
     351           0 :                     bReturn = true;
     352             :                 }
     353             :             }
     354             :         }
     355           0 :         break;
     356             : 
     357             :         // #97016#
     358             :         case KEY_END:
     359             :         {
     360             :             // in calc do NOT select the last draw object when
     361             :             // there is not yet a object selected
     362           0 :             if(pView->AreObjectsMarked())
     363             :             {
     364           0 :                 KeyCode aCode = rKEvt.GetKeyCode();
     365             : 
     366           0 :                 if ( aCode.IsMod1() )
     367             :                 {
     368             :                     // mark last object
     369           0 :                     pView->UnmarkAllObj();
     370           0 :                     pView->MarkNextObj(false);
     371             : 
     372             :                     // II
     373           0 :                     if(pView->AreObjectsMarked())
     374           0 :                         pView->MakeVisible(pView->GetAllMarkedRect(), *pWindow);
     375             : 
     376           0 :                     bReturn = true;
     377             :                 }
     378             :             }
     379             :         }
     380           0 :         break;
     381             : 
     382             :         // #97016#
     383             :         case KEY_HOME:
     384             :         {
     385             :             // in calc do NOT select the first draw object when
     386             :             // there is not yet a object selected
     387           0 :             if(pView->AreObjectsMarked())
     388             :             {
     389           0 :                 KeyCode aCode = rKEvt.GetKeyCode();
     390             : 
     391           0 :                 if ( aCode.IsMod1() )
     392             :                 {
     393             :                     // mark first object
     394           0 :                     pView->UnmarkAllObj();
     395           0 :                     pView->MarkNextObj(true);
     396             : 
     397             :                     // II
     398           0 :                     if(pView->AreObjectsMarked())
     399           0 :                         pView->MakeVisible(pView->GetAllMarkedRect(), *pWindow);
     400             : 
     401           0 :                     bReturn = true;
     402             :                 }
     403             :             }
     404             :         }
     405           0 :         break;
     406             : 
     407             :         // #97016#
     408             :         case KEY_UP:
     409             :         case KEY_DOWN:
     410             :         case KEY_LEFT:
     411             :         case KEY_RIGHT:
     412             :         {
     413             :             // in calc do cursor travelling of draw objects only when
     414             :             // there is a object selected yet
     415           0 :             if(pView->AreObjectsMarked())
     416             :             {
     417             : 
     418           0 :                 const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
     419           0 :                 if(rMarkList.GetMarkCount() == 1)
     420             :                 {
     421             :                     // disable cursor travelling on note objects as the tail connector position
     422             :                     // must not move.
     423           0 :                     SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
     424           0 :                     if( ScDrawLayer::IsNoteCaption( pObj ) )
     425           0 :                         break;
     426             :                 }
     427             : 
     428           0 :                 long nX = 0;
     429           0 :                 long nY = 0;
     430           0 :                 sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode();
     431             : 
     432           0 :                 if (nCode == KEY_UP)
     433             :                 {
     434             :                     // Scroll nach oben
     435           0 :                     nX = 0;
     436           0 :                     nY =-1;
     437             :                 }
     438           0 :                 else if (nCode == KEY_DOWN)
     439             :                 {
     440             :                     // Scroll nach unten
     441           0 :                     nX = 0;
     442           0 :                     nY = 1;
     443             :                 }
     444           0 :                 else if (nCode == KEY_LEFT)
     445             :                 {
     446             :                     // Scroll nach links
     447           0 :                     nX =-1;
     448           0 :                     nY = 0;
     449             :                 }
     450           0 :                 else if (nCode == KEY_RIGHT)
     451             :                 {
     452             :                     // Scroll nach rechts
     453           0 :                     nX = 1;
     454           0 :                     nY = 0;
     455             :                 }
     456             : 
     457           0 :                 sal_Bool bReadOnly = rViewData.GetDocShell()->IsReadOnly();
     458             : 
     459           0 :                 if(!rKEvt.GetKeyCode().IsMod1() && !bReadOnly)
     460             :                 {
     461           0 :                     if(rKEvt.GetKeyCode().IsMod2())
     462             :                     {
     463             :                         // move in 1 pixel distance
     464           0 :                         Size aLogicSizeOnePixel = (pWindow) ? pWindow->PixelToLogic(Size(1,1)) : Size(100, 100);
     465           0 :                         nX *= aLogicSizeOnePixel.Width();
     466           0 :                         nY *= aLogicSizeOnePixel.Height();
     467             :                     }
     468           0 :                     else if(rKEvt.GetKeyCode().IsShift()) // #i121236# Support for shift key in calc
     469             :                     {
     470           0 :                         nX *= 1000;
     471           0 :                         nY *= 1000;
     472             :                     }
     473             :                     else
     474             :                     {
     475             :                         // old, fixed move distance
     476           0 :                         nX *= 100;
     477           0 :                         nY *= 100;
     478             :                     }
     479             : 
     480             :                     // is there a movement to do?
     481           0 :                     if(0 != nX || 0 != nY)
     482             :                     {
     483             :                         // II
     484           0 :                         const SdrHdlList& rHdlList = pView->GetHdlList();
     485           0 :                         SdrHdl* pHdl = rHdlList.GetFocusHdl();
     486             : 
     487           0 :                         if(0L == pHdl)
     488             :                         {
     489             :                             // only take action when move is allowed
     490           0 :                             if(pView->IsMoveAllowed())
     491             :                             {
     492             :                                 // restrict movement to WorkArea
     493           0 :                                 const Rectangle& rWorkArea = pView->GetWorkArea();
     494             : 
     495           0 :                                 if(!rWorkArea.IsEmpty())
     496             :                                 {
     497           0 :                                     Rectangle aMarkRect(pView->GetMarkedObjRect());
     498           0 :                                     aMarkRect.Move(nX, nY);
     499             : 
     500           0 :                                     if(!aMarkRect.IsInside(rWorkArea))
     501             :                                     {
     502           0 :                                         if(aMarkRect.Left() < rWorkArea.Left())
     503             :                                         {
     504           0 :                                             nX += rWorkArea.Left() - aMarkRect.Left();
     505             :                                         }
     506             : 
     507           0 :                                         if(aMarkRect.Right() > rWorkArea.Right())
     508             :                                         {
     509           0 :                                             nX -= aMarkRect.Right() - rWorkArea.Right();
     510             :                                         }
     511             : 
     512           0 :                                         if(aMarkRect.Top() < rWorkArea.Top())
     513             :                                         {
     514           0 :                                             nY += rWorkArea.Top() - aMarkRect.Top();
     515             :                                         }
     516             : 
     517           0 :                                         if(aMarkRect.Bottom() > rWorkArea.Bottom())
     518             :                                         {
     519           0 :                                             nY -= aMarkRect.Bottom() - rWorkArea.Bottom();
     520             :                                         }
     521             :                                     }
     522             :                                 }
     523             : 
     524             :                                 // now move the selected draw objects
     525           0 :                                 pView->MoveAllMarked(Size(nX, nY));
     526             : 
     527             :                                 // II
     528           0 :                                 pView->MakeVisible(pView->GetAllMarkedRect(), *pWindow);
     529             : 
     530           0 :                                 bReturn = true;
     531             :                             }
     532             :                         }
     533             :                         else
     534             :                         {
     535             :                             // move handle with index nHandleIndex
     536           0 :                             if(pHdl && (nX || nY))
     537             :                             {
     538             :                                 // now move the Handle (nX, nY)
     539           0 :                                 Point aStartPoint(pHdl->GetPos());
     540           0 :                                 Point aEndPoint(pHdl->GetPos() + Point(nX, nY));
     541           0 :                                 const SdrDragStat& rDragStat = pView->GetDragStat();
     542             : 
     543             :                                 // start dragging
     544           0 :                                 pView->BegDragObj(aStartPoint, 0, pHdl, 0);
     545             : 
     546           0 :                                 if(pView->IsDragObj())
     547             :                                 {
     548           0 :                                     bool bWasNoSnap = rDragStat.IsNoSnap();
     549           0 :                                     sal_Bool bWasSnapEnabled = pView->IsSnapEnabled();
     550             : 
     551             :                                     // switch snapping off
     552           0 :                                     if(!bWasNoSnap)
     553           0 :                                         ((SdrDragStat&)rDragStat).SetNoSnap(true);
     554           0 :                                     if(bWasSnapEnabled)
     555           0 :                                         pView->SetSnapEnabled(false);
     556             : 
     557           0 :                                     pView->MovAction(aEndPoint);
     558           0 :                                     pView->EndDragObj();
     559             : 
     560             :                                     // restore snap
     561           0 :                                     if(!bWasNoSnap)
     562           0 :                                         ((SdrDragStat&)rDragStat).SetNoSnap(bWasNoSnap);
     563           0 :                                     if(bWasSnapEnabled)
     564           0 :                                         pView->SetSnapEnabled(bWasSnapEnabled);
     565             :                                 }
     566             : 
     567             :                                 // make moved handle visible
     568           0 :                                 Rectangle aVisRect(aEndPoint - Point(100, 100), Size(200, 200));
     569           0 :                                 pView->MakeVisible(aVisRect, *pWindow);
     570             : 
     571           0 :                                 bReturn = true;
     572             :                             }
     573             :                         }
     574             :                     }
     575             :                 }
     576             :             }
     577             :         }
     578           0 :         break;
     579             : 
     580             :         // #97016#
     581             :         case KEY_SPACE:
     582             :         {
     583             :             // in calc do only something when draw objects are selected
     584           0 :             if(pView->AreObjectsMarked())
     585             :             {
     586           0 :                 const SdrHdlList& rHdlList = pView->GetHdlList();
     587           0 :                 SdrHdl* pHdl = rHdlList.GetFocusHdl();
     588             : 
     589           0 :                 if(pHdl)
     590             :                 {
     591           0 :                     if(pHdl->GetKind() == HDL_POLY)
     592             :                     {
     593             :                         // rescue ID of point with focus
     594           0 :                         sal_uInt32 nPol(pHdl->GetPolyNum());
     595           0 :                         sal_uInt32 nPnt(pHdl->GetPointNum());
     596             : 
     597           0 :                         if(pView->IsPointMarked(*pHdl))
     598             :                         {
     599           0 :                             if(rKEvt.GetKeyCode().IsShift())
     600             :                             {
     601           0 :                                 pView->UnmarkPoint(*pHdl);
     602             :                             }
     603             :                         }
     604             :                         else
     605             :                         {
     606           0 :                             if(!rKEvt.GetKeyCode().IsShift())
     607             :                             {
     608           0 :                                 pView->UnmarkAllPoints();
     609             :                             }
     610             : 
     611           0 :                             pView->MarkPoint(*pHdl);
     612             :                         }
     613             : 
     614           0 :                         if(0L == rHdlList.GetFocusHdl())
     615             :                         {
     616             :                             // restore point with focus
     617           0 :                             SdrHdl* pNewOne = 0L;
     618             : 
     619           0 :                             for(sal_uInt32 a(0); !pNewOne && a < rHdlList.GetHdlCount(); a++)
     620             :                             {
     621           0 :                                 SdrHdl* pAct = rHdlList.GetHdl(a);
     622             : 
     623           0 :                                 if(pAct
     624           0 :                                     && pAct->GetKind() == HDL_POLY
     625           0 :                                     && pAct->GetPolyNum() == nPol
     626           0 :                                     && pAct->GetPointNum() == nPnt)
     627             :                                 {
     628           0 :                                     pNewOne = pAct;
     629             :                                 }
     630             :                             }
     631             : 
     632           0 :                             if(pNewOne)
     633             :                             {
     634           0 :                                 ((SdrHdlList&)rHdlList).SetFocusHdl(pNewOne);
     635             :                             }
     636             :                         }
     637             : 
     638           0 :                         bReturn = true;
     639             :                     }
     640             :                 }
     641             :             }
     642             :         }
     643           0 :         break;
     644             :     }
     645             : 
     646           0 :     if (!bReturn)
     647             :     {
     648           0 :         bReturn = FuPoor::KeyInput(rKEvt);
     649             :     }
     650             : 
     651           0 :     if (!bReturn)
     652             :     {
     653             :         // allow direct typing into a selected text object
     654             : 
     655           0 :         const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
     656           0 :         if( !pView->IsTextEdit() && 1 == rMarkList.GetMarkCount() && EditEngine::IsSimpleCharInput(rKEvt) )
     657             :         {
     658           0 :             SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
     659             : 
     660             :             // start text edit for suitable object, pass key event to OutlinerView
     661           0 :             if ( lcl_KeyEditMode( pObj, pViewShell, &rKEvt ) )
     662           0 :                 bReturn = true;
     663             :         }
     664             :     }
     665             : 
     666           0 :     return bReturn;
     667             : }
     668             : 
     669             : // II
     670           0 : void FuDraw::SelectionHasChanged()
     671             : {
     672           0 :     const SdrHdlList& rHdlList = pView->GetHdlList();
     673           0 :     ((SdrHdlList&)rHdlList).ResetFocusHdl();
     674           0 : }
     675             : 
     676             : /*************************************************************************
     677             : |*
     678             : |* Function aktivieren
     679             : |*
     680             : \************************************************************************/
     681             : 
     682           0 : void FuDraw::Activate()
     683             : {
     684           0 :     FuPoor::Activate();
     685           0 : }
     686             : 
     687             : /*************************************************************************
     688             : |*
     689             : |* Function deaktivieren
     690             : |*
     691             : \************************************************************************/
     692             : 
     693           0 : void FuDraw::Deactivate()
     694             : {
     695           0 :     FuPoor::Deactivate();
     696           0 : }
     697             : 
     698             : /*************************************************************************
     699             : |*
     700             : |* Maus-Pointer umschalten
     701             : |*
     702             : \************************************************************************/
     703             : 
     704           0 : static sal_Bool lcl_UrlHit( SdrView* pView, const Point& rPosPixel, Window* pWindow )
     705             : {
     706           0 :     SdrViewEvent aVEvt;
     707           0 :     MouseEvent aMEvt( rPosPixel, 1, 0, MOUSE_LEFT );
     708           0 :     SdrHitKind eHit = pView->PickAnything( aMEvt, SDRMOUSEBUTTONDOWN, aVEvt );
     709             : 
     710           0 :     if ( eHit != SDRHIT_NONE && aVEvt.pObj != NULL )
     711             :     {
     712           0 :         if ( ScDrawLayer::GetIMapInfo( aVEvt.pObj ) && ScDrawLayer::GetHitIMapObject(
     713           0 :                                 aVEvt.pObj, pWindow->PixelToLogic(rPosPixel), *pWindow ) )
     714           0 :             return sal_True;
     715             : 
     716           0 :         if ( aVEvt.eEvent == SDREVENT_EXECUTEURL )
     717           0 :             return sal_True;
     718             :     }
     719             : 
     720           0 :     return false;
     721             : }
     722             : 
     723           0 : void FuDraw::ForcePointer(const MouseEvent* pMEvt)
     724             : {
     725           0 :     if ( !pView->IsAction() )
     726             :     {
     727           0 :         Point aPosPixel = pWindow->GetPointerPosPixel();
     728           0 :         sal_Bool bAlt       = pMEvt && pMEvt->IsMod2();
     729           0 :         Point aPnt      = pWindow->PixelToLogic( aPosPixel );
     730           0 :         SdrHdl* pHdl    = pView->PickHandle(aPnt);
     731             :         SdrObject* pObj;
     732             :         SdrPageView* pPV;
     733             : 
     734           0 :         ScMacroInfo* pInfo = 0;
     735           0 :         if ( pView->PickObj(aPnt, pView->getHitTolLog(), pObj, pPV, SDRSEARCH_ALSOONMASTER) )
     736             :         {
     737           0 :             if ( pObj->IsGroupObject() )
     738             :             {
     739           0 :                 SdrObject* pHit = 0;
     740           0 :                 if ( pView->PickObj(aMDPos, pView->getHitTolLog(), pHit, pPV, SDRSEARCH_DEEP ) )
     741           0 :                     pObj = pHit;
     742             :             }
     743           0 :             pInfo = ScDrawLayer::GetMacroInfo( pObj );
     744             :         }
     745             : 
     746           0 :         if ( pView->IsTextEdit() )
     747             :         {
     748           0 :             pViewShell->SetActivePointer(Pointer(POINTER_TEXT));        // kann nicht sein ?
     749             :         }
     750           0 :         else if ( pHdl )
     751             :         {
     752             :             pViewShell->SetActivePointer(
     753           0 :                 pView->GetPreferredPointer( aPnt, pWindow ) );
     754             :         }
     755           0 :         else if ( pView->IsMarkedHit(aPnt) )
     756             :         {
     757           0 :             pViewShell->SetActivePointer( Pointer(POINTER_MOVE) );
     758             :         }
     759           0 :         else if ( !bAlt && ( !pMEvt || !pMEvt->GetButtons() )
     760           0 :                         && lcl_UrlHit( pView, aPosPixel, pWindow ) )
     761             :         {
     762             :             //  kann mit ALT unterdrueckt werden
     763           0 :             pWindow->SetPointer( Pointer( POINTER_REFHAND ) );          // Text-URL / ImageMap
     764             :         }
     765           0 :         else if ( !bAlt && pView->PickObj(aPnt, pView->getHitTolLog(), pObj, pPV, SDRSEARCH_PICKMACRO) )
     766             :         {
     767             :             //  kann mit ALT unterdrueckt werden
     768           0 :             SdrObjMacroHitRec aHitRec;  //! muss da noch irgendwas gesetzt werden ????
     769           0 :             pViewShell->SetActivePointer( pObj->GetMacroPointer(aHitRec) );
     770             :         }
     771           0 :         else if ( !bAlt && pInfo && (!pInfo->GetMacro().isEmpty() || !pInfo->GetHlink().isEmpty()) )
     772           0 :             pWindow->SetPointer( Pointer( POINTER_REFHAND ) );
     773           0 :         else if ( IsDetectiveHit( aPnt ) )
     774           0 :             pViewShell->SetActivePointer( Pointer( POINTER_DETECTIVE ) );
     775             :         else
     776           0 :             pViewShell->SetActivePointer( aNewPointer );            //! in Gridwin?
     777             :     }
     778           0 : }
     779             : 
     780           0 : bool FuDraw::IsEditingANote() const
     781             : {
     782           0 :     const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
     783           0 :     sal_Int32 backval=rMarkList.GetMarkCount();
     784           0 :     for (sal_Int32 nlv1=0;nlv1<backval;nlv1++)
     785             :     {
     786           0 :         SdrObject* pObj = rMarkList.GetMark( nlv1 )->GetMarkedSdrObj();
     787           0 :         if ( ScDrawLayer::IsNoteCaption( pObj ) )
     788             :         {
     789           0 :             return true;
     790             :         }
     791             :     }
     792           0 :     return false;
     793             : }
     794             : 
     795           0 : bool FuDraw::IsSizingOrMovingNote( const MouseEvent& rMEvt ) const
     796             : {
     797           0 :     bool bIsSizingOrMoving = false;
     798           0 :     if ( rMEvt.IsLeft() )
     799             :     {
     800           0 :         const SdrMarkList& rNoteMarkList = pView->GetMarkedObjectList();
     801           0 :         if(rNoteMarkList.GetMarkCount() == 1)
     802             :         {
     803           0 :             SdrObject* pObj = rNoteMarkList.GetMark( 0 )->GetMarkedSdrObj();
     804           0 :             if ( ScDrawLayer::IsNoteCaption( pObj ) )
     805             :             {
     806           0 :                 Point aMPos = pWindow->PixelToLogic( rMEvt.GetPosPixel() );
     807             :                 bIsSizingOrMoving =
     808           0 :                     pView->PickHandle( aMPos ) ||      // handles to resize the note
     809           0 :                     pView->IsTextEditFrameHit( aMPos );         // frame for moving the note
     810             :             }
     811             :         }
     812             :     }
     813           0 :     return bIsSizingOrMoving;
     814         102 : }
     815             : 
     816             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10