LCOV - code coverage report
Current view: top level - sd/source/ui/func - fusel.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 40 655 6.1 %
Date: 2014-04-11 Functions: 9 22 40.9 %
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 "fusel.hxx"
      21             : #include <basic/sbstar.hxx>
      22             : #include <svx/svdpagv.hxx>
      23             : #include <svx/svdogrp.hxx>
      24             : #include <svx/polysc3d.hxx>
      25             : #include "drawview.hxx"
      26             : #include <svtools/imapobj.hxx>
      27             : #include <svl/urihelper.hxx>
      28             : #include <unotools/localfilehelper.hxx>
      29             : #include <svx/svxids.hrc>
      30             : #include <svx/xfillit0.hxx>
      31             : #include <sfx2/app.hxx>
      32             : #include <sfx2/viewfrm.hxx>
      33             : #include <svl/aeitem.hxx>
      34             : #include <svl/stritem.hxx>
      35             : #include <svl/intitem.hxx>
      36             : #include <sfx2/dispatch.hxx>
      37             : #include <tools/urlobj.hxx>
      38             : #include <sfx2/docfile.hxx>
      39             : #include <editeng/eeitem.hxx>
      40             : #include <editeng/flditem.hxx>
      41             : 
      42             : #include <svx/svdotable.hxx>
      43             : 
      44             : #include "app.hrc"
      45             : #include "strings.hrc"
      46             : #include "res_bmp.hrc"
      47             : #include "GraphicDocShell.hxx"
      48             : #include "sdmod.hxx"
      49             : #include "DrawDocShell.hxx"
      50             : #include "stlpool.hxx"
      51             : #include "anminfo.hxx"
      52             : #include "fudraw.hxx"
      53             : #include "ViewShell.hxx"
      54             : #include "ViewShellBase.hxx"
      55             : #include "FrameView.hxx"
      56             : #include "View.hxx"
      57             : #include "Window.hxx"
      58             : #include "drawdoc.hxx"
      59             : #include "sdpage.hxx"
      60             : #include "DrawViewShell.hxx"
      61             : #include "ToolBarManager.hxx"
      62             : #include "pgjump.hxx"
      63             : #include <svx/globl3d.hxx>
      64             : #include "Client.hxx"
      65             : 
      66             : #include "slideshow.hxx"
      67             : 
      68             : #include <svx/svdundo.hxx>
      69             : #include <avmedia/mediawindow.hxx>
      70             : 
      71             : #include <svx/sdrhittesthelper.hxx>
      72             : 
      73             : using namespace ::com::sun::star;
      74             : 
      75             : namespace sd {
      76             : 
      77           0 : TYPEINIT1( FuSelection, FuDraw );
      78             : 
      79          73 : FuSelection::FuSelection (
      80             :     ViewShell* pViewSh,
      81             :     ::sd::Window* pWin,
      82             :     ::sd::View* pView,
      83             :     SdDrawDocument* pDoc,
      84             :     SfxRequest& rReq)
      85             :     : FuDraw(pViewSh, pWin, pView, pDoc, rReq),
      86             :       bTempRotation(sal_False),
      87             :       bSelectionChanged(sal_False),
      88             :       bHideAndAnimate(sal_False),
      89             :       pHdl(NULL),
      90             :       bSuppressChangesOfSelection(sal_False),
      91             :       bMirrorSide0(sal_False),
      92             :       nEditMode(SID_BEZIER_MOVE),
      93             :       pWaterCanCandidate(NULL)
      94             :      //Add Shift+UP/DOWN/LEFT/RIGHT key to move the position of insert point,
      95             :      //and SHIFT+ENTER key to decide the postion and draw the new insert point
      96             :     ,bBeginInsertPoint(sal_False),
      97             :       oldPoint(0,0)
      98          73 :   ,bMovedToCenterPoint(sal_False)
      99             : {
     100          73 : }
     101             : 
     102          73 : rtl::Reference<FuPoor> FuSelection::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
     103             : {
     104          73 :     rtl::Reference<FuPoor> xFunc( new FuSelection( pViewSh, pWin, pView, pDoc, rReq ) );
     105          73 :     xFunc->DoExecute(rReq);
     106          73 :     return xFunc;
     107             : }
     108             : 
     109          73 : void FuSelection::DoExecute( SfxRequest& rReq )
     110             : {
     111          73 :     FuDraw::DoExecute( rReq );
     112             : 
     113             :     // Select object bar
     114          73 :     SelectionHasChanged();
     115          73 : }
     116             : 
     117         219 : FuSelection::~FuSelection()
     118             : {
     119          73 :     mpView->UnmarkAllPoints();
     120          73 :     mpView->ResetCreationActive();
     121             : 
     122          73 :     if ( mpView->GetDragMode() != SDRDRAG_MOVE )
     123             :     {
     124           0 :         mpView->SetDragMode(SDRDRAG_MOVE);
     125             :     }
     126         146 : }
     127             : 
     128           0 : sal_Bool FuSelection::MouseButtonDown(const MouseEvent& rMEvt)
     129             : {
     130             :     // Hack for #?????#
     131           0 :     bHideAndAnimate = sal_False;
     132             : 
     133           0 :     pHdl = NULL;
     134           0 :     sal_Bool bReturn = FuDraw::MouseButtonDown(rMEvt);
     135           0 :     sal_Bool bWaterCan = SD_MOD()->GetWaterCan();
     136           0 :     const bool bReadOnly = mpDocSh->IsReadOnly();
     137             :     // When the right mouse button is pressed then only select objects
     138             :     // (and deselect others) as a preparation for showing the context
     139             :     // menu.
     140           0 :     const bool bSelectionOnly = rMEvt.IsRight();
     141             : 
     142           0 :     bMBDown = sal_True;
     143           0 :     bSelectionChanged = sal_False;
     144             : 
     145           0 :     if ( mpView->IsAction() )
     146             :     {
     147           0 :         if ( rMEvt.IsRight() )
     148           0 :             mpView->BckAction();
     149           0 :         return sal_True;
     150             :     }
     151             : 
     152           0 :     sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
     153           0 :     sal_uInt16 nHitLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(HITPIX,0)).Width() );
     154             : 
     155             :     // The following code is executed for right clicks as well as for left
     156             :     // clicks in order to modify the selection for the right button as a
     157             :     // preparation for the context menu.  The functions BegMarkObject() and
     158             :     // BegDragObject(), however, are not called for right clicks because a)
     159             :     // it makes no sense and b) to have IsAction() return sal_False when called
     160             :     // from Command() which is a prerequisite for the context menu.
     161           0 :     if ((rMEvt.IsLeft() || rMEvt.IsRight())
     162           0 :         && !mpView->IsAction()
     163           0 :         && (mpView->IsFrameDragSingles() || !mpView->HasMarkablePoints()))
     164             :     {
     165             :         /******************************************************************
     166             :         * NO BEZIER_EDITOR
     167             :         ******************************************************************/
     168           0 :         mpWindow->CaptureMouse();
     169           0 :         pHdl = mpView->PickHandle(aMDPos);
     170             :         SdrObject* pObj;
     171             :         SdrPageView* pPV;
     172             : 
     173           0 :         long nAngle0  = GetAngle(aMDPos - mpView->GetRef1());
     174           0 :         nAngle0 -= 27000;
     175           0 :         nAngle0 = NormAngle360(nAngle0);
     176           0 :         bMirrorSide0 = sal_Bool (nAngle0 < 18000L);
     177             : 
     178           0 :         if (!pHdl && mpView->Is3DRotationCreationActive())
     179             :         {
     180             :             /******************************************************************
     181             :             * If 3D-rotation bodies are about to be created,
     182             :             * end creation now.
     183             :             ******************************************************************/
     184           0 :             bSuppressChangesOfSelection = sal_True;
     185           0 :             if(mpWindow)
     186           0 :                 mpWindow->EnterWait();
     187           0 :             mpView->End3DCreation();
     188           0 :             bSuppressChangesOfSelection = sal_False;
     189           0 :             mpView->ResetCreationActive();
     190           0 :             if(mpWindow)
     191           0 :                 mpWindow->LeaveWait();
     192             :         }
     193             : 
     194           0 :         sal_Bool bTextEdit = sal_False;
     195           0 :         SdrViewEvent aVEvt;
     196           0 :         SdrHitKind eHit = mpView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
     197             : 
     198           0 :         if ( eHit == SDRHIT_TEXTEDITOBJ && ( mpViewShell->GetFrameView()->IsQuickEdit() || dynamic_cast< sdr::table::SdrTableObj* >( aVEvt.pObj ) != NULL ) )
     199             :         {
     200           0 :             bTextEdit = sal_True;
     201             :         }
     202             : 
     203           0 :         if(!bTextEdit
     204           0 :             && !mpDocSh->IsReadOnly()
     205           0 :             && ((mpView->IsMarkedHit(aMDPos, nHitLog) && !rMEvt.IsShift() && !rMEvt.IsMod2()) || pHdl != NULL)
     206           0 :             && (rMEvt.GetClicks() != 2)
     207             :             )
     208             :         {
     209           0 :             if (!pHdl && mpView->Is3DRotationCreationActive())
     210             :             {
     211             :                 // Switch between 3D-rotation body -> selection
     212           0 :                 mpView->ResetCreationActive();
     213             :             }
     214           0 :             else if (bWaterCan)
     215             :             {
     216             :                 // Remember the selected object for proper handling in
     217             :                 // MouseButtonUp().
     218           0 :                 pWaterCanCandidate = pickObject (aMDPos);
     219             :             }
     220             :             else
     221             :             {
     222             :                 // hit handle or marked object
     223           0 :                 bFirstMouseMove = sal_True;
     224           0 :                 aDragTimer.Start();
     225             :             }
     226             : 
     227           0 :             if ( ! rMEvt.IsRight())
     228           0 :                 mpView->BegDragObj(aMDPos, (OutputDevice*) NULL, pHdl, nDrgLog);
     229           0 :             bReturn = sal_True;
     230             :         }
     231             :         else
     232             :         {
     233           0 :             if (!rMEvt.IsMod2() && mpView->PickObj(aMDPos, mpView->getHitTolLog(), pObj, pPV, SDRSEARCH_PICKMACRO))
     234             :             {
     235           0 :                 mpView->BegMacroObj(aMDPos, nHitLog, pObj, pPV, mpWindow);
     236           0 :                 bReturn = sal_True;
     237             :             }
     238           0 :             else if ( bTextEdit )
     239             :             {
     240           0 :                 sal_uInt16 nSdrObjKind = aVEvt.pObj->GetObjIdentifier();
     241             : 
     242           0 :                 if (aVEvt.pObj->GetObjInventor() == SdrInventor &&
     243           0 :                     (nSdrObjKind == OBJ_TEXT ||
     244           0 :                      nSdrObjKind == OBJ_TITLETEXT ||
     245           0 :                      nSdrObjKind == OBJ_OUTLINETEXT ||
     246           0 :                      !aVEvt.pObj->IsEmptyPresObj()))
     247             :                 {
     248             :                     // Seamless Editing: branch to text input
     249           0 :                     if (!rMEvt.IsShift())
     250           0 :                         mpView->UnmarkAll();
     251             : 
     252           0 :                     SfxUInt16Item aItem(SID_TEXTEDIT, 1);
     253             :                     mpViewShell->GetViewFrame()->GetDispatcher()->
     254             :                     Execute(SID_TEXTEDIT, SFX_CALLMODE_SYNCHRON |
     255           0 :                             SFX_CALLMODE_RECORD, &aItem, 0L);
     256           0 :                     return bReturn; // CAUTION, due to the synchronous slot the object is deleted now
     257             :                 }
     258             :             }
     259           0 :             else if ( !rMEvt.IsMod2() && rMEvt.GetClicks() == 1 &&
     260           0 :                       aVEvt.eEvent == SDREVENT_EXECUTEURL )
     261             :              {
     262           0 :                 mpWindow->ReleaseMouse();
     263           0 :                 SfxStringItem aStrItem(SID_FILE_NAME, aVEvt.pURLField->GetURL());
     264           0 :                 SfxStringItem aReferer(SID_REFERER, mpDocSh->GetMedium()->GetName());
     265           0 :                 SfxBoolItem aBrowseItem( SID_BROWSE, true );
     266           0 :                 SfxViewFrame* pFrame = mpViewShell->GetViewFrame();
     267           0 :                 mpWindow->ReleaseMouse();
     268             : 
     269           0 :                 if (rMEvt.IsMod1())
     270             :                 {
     271             :                     // Open in new frame
     272             :                     pFrame->GetDispatcher()->Execute(SID_OPENDOC, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
     273           0 :                                 &aStrItem, &aBrowseItem, &aReferer, 0L);
     274             :                 }
     275             :                 else
     276             :                 {
     277             :                     // Open in current frame
     278           0 :                     SfxFrameItem aFrameItem(SID_DOCFRAME, pFrame);
     279             :                     pFrame->GetDispatcher()->Execute(SID_OPENDOC, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
     280           0 :                                 &aStrItem, &aFrameItem, &aBrowseItem, &aReferer, 0L);
     281             :                 }
     282             : 
     283           0 :                 bReturn = sal_True;
     284             :             }
     285           0 :             else if(!rMEvt.IsMod2()
     286           0 :                 && mpViewShell->ISA(DrawViewShell)
     287             :                 )
     288             :             {
     289           0 :                 if(mpView->PickObj(aMDPos, mpView->getHitTolLog(), pObj, pPV, SDRSEARCH_ALSOONMASTER))
     290             :                 {
     291             :                     // Animate object when not just selecting.
     292           0 :                     if ( ! bSelectionOnly)
     293           0 :                         bReturn = AnimateObj(pObj, aMDPos);
     294             : 
     295           0 :                     if (!bReturn && (pObj->ISA(SdrObjGroup) || pObj->ISA(E3dPolyScene)))
     296             :                     {
     297           0 :                         if(rMEvt.GetClicks() == 1)
     298             :                         {
     299             :                             // Look into the group
     300           0 :                             if (mpView->PickObj(aMDPos, mpView->getHitTolLog(), pObj, pPV, SDRSEARCH_ALSOONMASTER | SDRSEARCH_DEEP))
     301           0 :                                 bReturn = AnimateObj(pObj, aMDPos);
     302             :                         }
     303           0 :                         else if( !bReadOnly && rMEvt.GetClicks() == 2)
     304             :                         {
     305             :                             // New: double click on selected Group object
     306             :                             // enter group
     307           0 :                             if ( ! bSelectionOnly
     308           0 :                                 && pObj
     309           0 :                                 && pObj->GetPage() == pPV->GetPage())
     310           0 :                                 bReturn = pPV->EnterGroup(pObj);
     311             :                         }
     312             :                     }
     313             :                 }
     314             : 
     315             :                 // #i71727# replaced else here with two possibilities, once the original else (!pObj)
     316             :                 // and also ignoring the found object when it's on a masterpage
     317           0 :                 if(!pObj || (pObj->GetPage() && pObj->GetPage()->IsMasterPage()))
     318             :                 {
     319           0 :                     if(mpView->IsGroupEntered() && 2 == rMEvt.GetClicks())
     320             :                     {
     321             :                         // New: double click on empty space/on obj on MasterPage, leave group
     322           0 :                         mpView->LeaveOneGroup();
     323           0 :                         bReturn = sal_True;
     324             :                     }
     325             :                 }
     326             :             }
     327             : 
     328           0 :             if (!bReturn)
     329             :             {
     330           0 :                 if (bWaterCan)
     331             :                 {
     332           0 :                     if ( ! (rMEvt.IsShift() || rMEvt.IsMod2()))
     333             :                     {
     334             :                         // Find the object under the current mouse position
     335             :                         // and store it for the MouseButtonUp() method to
     336             :                         // evaluate.
     337           0 :                         pWaterCanCandidate = pickObject (aMDPos);
     338             :                     }
     339             :                 }
     340             :                 else
     341             :                 {
     342           0 :                     bReturn = sal_True;
     343           0 :                     sal_Bool bDeactivateOLE = sal_False;
     344             : 
     345           0 :                     if ( !rMEvt.IsShift() && !rMEvt.IsMod2() )
     346             :                     {
     347             :                         OSL_ASSERT (mpViewShell->GetViewShell()!=NULL);
     348             :                         Client* pIPClient = static_cast<Client*>(
     349           0 :                             mpViewShell->GetViewShell()->GetIPClient());
     350             : 
     351           0 :                         if (pIPClient && pIPClient->IsObjectInPlaceActive())
     352             :                         {
     353             :                             // OLE-Objekt gets deactivated in subsequent UnmarkAll()
     354           0 :                             bDeactivateOLE = sal_True;
     355             :                         }
     356             : 
     357           0 :                         mpView->UnmarkAll();
     358             :                     }
     359             : 
     360           0 :                     sal_Bool bMarked = sal_False;
     361             : 
     362           0 :                     if ( !rMEvt.IsMod1() && !bDeactivateOLE)
     363             :                     {
     364           0 :                         if ( rMEvt.IsMod2() )
     365             :                         {
     366           0 :                             bMarked = mpView->MarkNextObj(aMDPos, nHitLog, rMEvt.IsShift() );
     367             :                         }
     368             :                         else
     369             :                         {
     370           0 :                             sal_Bool bToggle = sal_False;
     371             : 
     372           0 :                             if (rMEvt.IsShift() && mpView->GetMarkedObjectList().GetMarkCount() > 1)
     373             :                             {
     374             :                                 // No Toggle on single selection
     375           0 :                                 bToggle = sal_True;
     376             :                             }
     377             : 
     378           0 :                             bMarked = mpView->MarkObj(aMDPos, nHitLog, bToggle, false);
     379             :                         }
     380             :                     }
     381             : 
     382           0 :                     if( !bDeactivateOLE )
     383             :                     {
     384           0 :                         if ( !bReadOnly &&
     385           0 :                              bMarked                                                   &&
     386           0 :                              (!rMEvt.IsShift() || mpView->IsMarkedHit(aMDPos, nHitLog)))
     387             :                         {
     388             :                             /**********************************************************
     389             :                              * Move object
     390             :                              **********************************************************/
     391           0 :                             aDragTimer.Start();
     392             : 
     393           0 :                             pHdl=mpView->PickHandle(aMDPos);
     394           0 :                             if ( ! rMEvt.IsRight())
     395           0 :                                 mpView->BegDragObj(aMDPos, (OutputDevice*) NULL, pHdl, nDrgLog);
     396             :                         }
     397             :                         else
     398             :                         {
     399             :                             /**********************************************************
     400             :                              * Select object
     401             :                              **********************************************************/
     402           0 :                             if ( ! rMEvt.IsRight())
     403           0 :                                 mpView->BegMarkObj(aMDPos);
     404             :                         }
     405             :                     }
     406             : 
     407           0 :                     if( bMarked && bTempRotation && (nSlotId == SID_OBJECT_ROTATE) && !rMEvt.IsShift() && (rMEvt.GetClicks() != 2) )
     408             :                     {
     409           0 :                         nSlotId = SID_OBJECT_SELECT;
     410           0 :                         Activate();
     411             :                     }
     412             :                 }
     413             :             }
     414           0 :         }
     415             :     }
     416           0 :     else if ( !bReadOnly
     417           0 :               && (rMEvt.IsLeft() || rMEvt.IsRight())
     418           0 :               && !mpView->IsAction())
     419             :     {
     420             :         /**********************************************************************
     421             :         * BEZIER-EDITOR
     422             :         **********************************************************************/
     423           0 :         mpWindow->CaptureMouse();
     424           0 :         SdrViewEvent aVEvt;
     425           0 :         SdrHitKind eHit = mpView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
     426             : 
     427           0 :         if (eHit == SDRHIT_HANDLE && aVEvt.pHdl->GetKind() == HDL_BWGT)
     428             :         {
     429             :             /******************************************************************
     430             :             * Drag Handle
     431             :             ******************************************************************/
     432           0 :             if ( ! rMEvt.IsRight())
     433           0 :                 mpView->BegDragObj(aMDPos, (OutputDevice*) NULL, aVEvt.pHdl, nDrgLog);
     434             :         }
     435           0 :         else if (eHit == SDRHIT_MARKEDOBJECT && nEditMode == SID_BEZIER_INSERT)
     436             :         {
     437             :             /******************************************************************
     438             :             * Insert glue point
     439             :             ******************************************************************/
     440           0 :             mpView->BegInsObjPoint(aMDPos, rMEvt.IsMod1());
     441             :         }
     442           0 :         else if (eHit == SDRHIT_MARKEDOBJECT && rMEvt.IsMod1())
     443             :         {
     444             :             /******************************************************************
     445             :             * Select glue point
     446             :             ******************************************************************/
     447           0 :             if (!rMEvt.IsShift())
     448           0 :                 mpView->UnmarkAllPoints();
     449             : 
     450           0 :             if ( ! rMEvt.IsRight())
     451           0 :                 mpView->BegMarkPoints(aMDPos);
     452             :         }
     453           0 :         else if (eHit == SDRHIT_MARKEDOBJECT && !rMEvt.IsShift() && !rMEvt.IsMod2())
     454             :         {
     455             :             /******************************************************************
     456             :             * Move object
     457             :             ******************************************************************/
     458           0 :             if ( ! rMEvt.IsRight())
     459           0 :                 mpView->BegDragObj(aMDPos, (OutputDevice*) NULL, NULL, nDrgLog);
     460             :         }
     461           0 :         else if (eHit == SDRHIT_HANDLE)
     462             :         {
     463             :             /******************************************************************
     464             :             * Select glue point
     465             :             ******************************************************************/
     466           0 :             if (!mpView->IsPointMarked(*aVEvt.pHdl) || rMEvt.IsShift())
     467             :             {
     468           0 :                 if (!rMEvt.IsShift())
     469             :                 {
     470           0 :                     mpView->UnmarkAllPoints();
     471           0 :                     pHdl = mpView->PickHandle(aMDPos);
     472             :                 }
     473             :                 else
     474             :                 {
     475           0 :                     if (mpView->IsPointMarked(*aVEvt.pHdl))
     476             :                     {
     477           0 :                         mpView->UnmarkPoint(*aVEvt.pHdl);
     478           0 :                         pHdl = NULL;
     479             :                     }
     480             :                     else
     481             :                     {
     482           0 :                         pHdl = mpView->PickHandle(aMDPos);
     483             :                     }
     484             :                 }
     485             : 
     486           0 :                 if (pHdl)
     487             :                 {
     488           0 :                     mpView->MarkPoint(*pHdl);
     489           0 :                     if ( ! rMEvt.IsRight())
     490           0 :                         mpView->BegDragObj(aMDPos, (OutputDevice*) NULL, pHdl, nDrgLog);
     491             :                 }
     492             :             }
     493             :             else
     494             :             {
     495             :                 // Point IS marked and NO shift is pressed. Start
     496             :                 // dragging of selected point(s)
     497           0 :                 pHdl = mpView->PickHandle(aMDPos);
     498           0 :                 if(pHdl)
     499           0 :                     if ( ! rMEvt.IsRight())
     500           0 :                         mpView->BegDragObj(aMDPos, (OutputDevice*)NULL, pHdl, nDrgLog);
     501             :             }
     502             :         }
     503             :         else
     504             :         {
     505             :             /******************************************************************
     506             :             * Select or drag object
     507             :             ******************************************************************/
     508           0 :             if (!rMEvt.IsShift() && !rMEvt.IsMod2() && eHit == SDRHIT_UNMARKEDOBJECT)
     509             :             {
     510           0 :                mpView->UnmarkAllObj();
     511             :             }
     512             : 
     513           0 :             sal_Bool bMarked = sal_False;
     514             : 
     515           0 :             if (!rMEvt.IsMod1())
     516             :             {
     517           0 :                 if (rMEvt.IsMod2())
     518             :                 {
     519           0 :                     bMarked = mpView->MarkNextObj(aMDPos, nHitLog, rMEvt.IsShift());
     520             :                 }
     521             :                 else
     522             :                 {
     523           0 :                     bMarked = mpView->MarkObj(aMDPos, nHitLog, rMEvt.IsShift(), false);
     524             :                 }
     525             :             }
     526             : 
     527           0 :             if (bMarked &&
     528           0 :                 (!rMEvt.IsShift() || eHit == SDRHIT_MARKEDOBJECT))
     529             :             {
     530             :                 // Move object
     531           0 :                 if ( ! rMEvt.IsRight())
     532           0 :                     mpView->BegDragObj(aMDPos, (OutputDevice*) NULL, aVEvt.pHdl, nDrgLog);
     533             :             }
     534           0 :             else if (mpView->AreObjectsMarked())
     535             :             {
     536             :                 /**************************************************************
     537             :                 * Select glue point
     538             :                 **************************************************************/
     539           0 :                 if (!rMEvt.IsShift())
     540           0 :                     mpView->UnmarkAllPoints();
     541             : 
     542           0 :                 if ( ! rMEvt.IsRight())
     543           0 :                     mpView->BegMarkPoints(aMDPos);
     544             :             }
     545             :             else
     546             :             {
     547             :                 /**************************************************************
     548             :                 * Select object
     549             :                 **************************************************************/
     550           0 :                 if ( ! rMEvt.IsRight())
     551           0 :                     mpView->BegMarkObj(aMDPos);
     552             :             }
     553             : 
     554           0 :             ForcePointer(&rMEvt);
     555           0 :         }
     556             :     }
     557             : 
     558           0 :     if (!bIsInDragMode)
     559             :     {
     560           0 :         ForcePointer(&rMEvt);
     561             :     }
     562             : 
     563           0 :     return bReturn;
     564             : }
     565             : 
     566           0 : sal_Bool FuSelection::MouseMove(const MouseEvent& rMEvt)
     567             : {
     568           0 :     sal_Bool bReturn = FuDraw::MouseMove(rMEvt);
     569             : 
     570           0 :     if (aDragTimer.IsActive())
     571             :     {
     572           0 :         if(bFirstMouseMove)
     573             :         {
     574           0 :             bFirstMouseMove = sal_False;
     575             :         }
     576             :         else
     577             :         {
     578           0 :             aDragTimer.Stop();
     579             :         }
     580             :     }
     581             : 
     582           0 :     if (mpView->IsAction())
     583             :     {
     584           0 :         Point aPix(rMEvt.GetPosPixel());
     585           0 :         Point aPnt(mpWindow->PixelToLogic(aPix));
     586             : 
     587           0 :         ForceScroll(aPix);
     588             : 
     589           0 :         if (mpView->IsInsObjPoint())
     590             :         {
     591           0 :             mpView->MovInsObjPoint(aPnt);
     592             :         }
     593             :         else
     594             :         {
     595           0 :             mpView->MovAction(aPnt);
     596             :         }
     597             :     }
     598             : 
     599           0 :     ForcePointer(&rMEvt);
     600             : 
     601           0 :     return (bReturn);
     602             : }
     603             : 
     604           0 : sal_Bool FuSelection::MouseButtonUp(const MouseEvent& rMEvt)
     605             : {
     606           0 :     sal_Bool bReturn = sal_False;
     607             :     // When the right mouse button is pressed then only select objects
     608             :     // (and deselect others) as a preparation for showing the context
     609             :     // menu.
     610           0 :     const bool bSelectionOnly = rMEvt.IsRight();
     611             :     SdrObject* pObj;
     612             :     SdrPageView* pPV;
     613             : 
     614           0 :     if (bHideAndAnimate)
     615             :     {
     616             :         // Animation is still running -> return immediately
     617           0 :         bHideAndAnimate = sal_False;
     618           0 :         pHdl = NULL;
     619           0 :         mpWindow->ReleaseMouse();
     620           0 :         return(sal_True);
     621             :     }
     622             : 
     623           0 :     if (aDragTimer.IsActive() )
     624             :     {
     625           0 :         aDragTimer.Stop();
     626           0 :         bIsInDragMode = sal_False;
     627             :     }
     628             : 
     629           0 :     if( !mpView )
     630           0 :         return (sal_False);
     631             : 
     632           0 :     Point aPnt( mpWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
     633           0 :     sal_uInt16 nHitLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(HITPIX,0)).Width() );
     634           0 :     sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
     635             : 
     636           0 :     if (mpView->IsFrameDragSingles() || !mpView->HasMarkablePoints())
     637             :     {
     638             :         /**********************************************************************
     639             :         * NO BEZIER_EDITOR
     640             :         **********************************************************************/
     641           0 :         if ( mpView->IsDragObj() )
     642             :         {
     643             :             /******************************************************************
     644             :             * Object was moved
     645             :             ******************************************************************/
     646           0 :             FrameView* pFrameView = mpViewShell->GetFrameView();
     647           0 :             sal_Bool bDragWithCopy = (rMEvt.IsMod1() && pFrameView->IsDragWithCopy());
     648             : 
     649           0 :             if (bDragWithCopy)
     650             :             {
     651           0 :                 bDragWithCopy = !mpView->IsPresObjSelected(sal_False, sal_True);
     652             :             }
     653             : 
     654           0 :             mpView->SetDragWithCopy(bDragWithCopy);
     655           0 :             mpView->EndDragObj( mpView->IsDragWithCopy() );
     656             : 
     657           0 :             mpView->ForceMarkedToAnotherPage();
     658             : 
     659           0 :             if (!rMEvt.IsShift() && !rMEvt.IsMod1() && !rMEvt.IsMod2() &&
     660           0 :                 !bSelectionChanged                   &&
     661           0 :                 std::abs(aPnt.X() - aMDPos.X()) < nDrgLog &&
     662           0 :                 std::abs(aPnt.Y() - aMDPos.Y()) < nDrgLog)
     663             :             {
     664             :                 /*************************************************************
     665             :                 * If a user wants to click on an object in front of a marked
     666             :                 * one, he releases the mouse button immediately
     667             :                 **************************************************************/
     668           0 :                 if (mpView->PickObj(aMDPos, mpView->getHitTolLog(), pObj, pPV, SDRSEARCH_ALSOONMASTER | SDRSEARCH_BEFOREMARK))
     669             :                 {
     670           0 :                     mpView->UnmarkAllObj();
     671           0 :                     mpView->MarkObj(pObj,pPV,false,false);
     672           0 :                     return (sal_True);
     673             :                 }
     674             :                 /**************************************************************
     675             :                 * Toggle between selection and rotation
     676             :                 **************************************************************/
     677           0 :                 SdrObject* pSingleObj = NULL;
     678           0 :                 sal_uLong nMarkCount = mpView->GetMarkedObjectList().GetMarkCount();
     679             : 
     680           0 :                 if (nMarkCount==1)
     681             :                 {
     682           0 :                     pSingleObj = mpView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj();
     683             :                 }
     684             : 
     685           0 :                 if (nSlotId == SID_OBJECT_SELECT
     686           0 :                     && mpView->IsRotateAllowed()
     687             : 
     688           0 :                     && (rMEvt.GetClicks() != 2)
     689           0 :                     && (mpViewShell->GetFrameView()->IsClickChangeRotation()
     690           0 :                         || (pSingleObj
     691           0 :                             && pSingleObj->GetObjInventor()==E3dInventor))
     692           0 :                     && ! bSelectionOnly)
     693             : 
     694             :                 {
     695           0 :                     bTempRotation = sal_True;
     696           0 :                     nSlotId = SID_OBJECT_ROTATE;
     697           0 :                     Activate();
     698             :                 }
     699           0 :                 else if (nSlotId == SID_OBJECT_ROTATE)
     700             :                 {
     701           0 :                     nSlotId = SID_OBJECT_SELECT;
     702           0 :                     Activate();
     703             :                 }
     704             :             }
     705           0 :             else if (nSlotId == SID_CONVERT_TO_3D_LATHE)
     706             :             {
     707           0 :                 if (!pHdl)
     708             :                 {
     709           0 :                     bSuppressChangesOfSelection = sal_True;
     710           0 :                     mpView->Start3DCreation();
     711           0 :                     bSuppressChangesOfSelection = sal_False;
     712             :                 }
     713           0 :                 else if (pHdl->GetKind() != HDL_MIRX &&
     714           0 :                          pHdl->GetKind() != HDL_REF1 &&
     715           0 :                          pHdl->GetKind() != HDL_REF2 && mpView->Is3DRotationCreationActive())
     716             :                 {
     717             :                     /*********************************************************
     718             :                     * If 3D-rotation bodies are about to be created,
     719             :                     * end creation now
     720             :                     **********************************************************/
     721           0 :                      long nAngle1  = GetAngle(aPnt - mpView->GetRef1());
     722           0 :                      nAngle1 -= 27000;
     723           0 :                      nAngle1 = NormAngle360(nAngle1);
     724           0 :                      sal_Bool bMirrorSide1 = sal_Bool (nAngle1 < 18000L);
     725             : 
     726           0 :                      if (bMirrorSide0 != bMirrorSide1)
     727             :                      {
     728           0 :                          bSuppressChangesOfSelection = sal_True;
     729           0 :                         if(mpWindow)
     730           0 :                             mpWindow->EnterWait();
     731           0 :                          mpView->End3DCreation();
     732           0 :                          bSuppressChangesOfSelection = sal_False;
     733           0 :                          nSlotId = SID_OBJECT_SELECT;
     734           0 :                         if(mpWindow)
     735           0 :                             mpWindow->LeaveWait();
     736           0 :                          Activate();
     737             :                     }
     738             :                 }
     739             :             }
     740             :         }
     741           0 :         else if (rMEvt.IsMod1()
     742           0 :             && !rMEvt.IsMod2()
     743           0 :             && std::abs(aPnt.X() - aMDPos.X()) < nDrgLog
     744           0 :             && std::abs(aPnt.Y() - aMDPos.Y()) < nDrgLog)
     745             :         {
     746             :             // Enter group
     747           0 :             mpView->MarkObj(aPnt, nHitLog, rMEvt.IsShift(), rMEvt.IsMod1());
     748             :         }
     749             : 
     750           0 :         if (mpView->IsAction() )
     751             :         {
     752           0 :             mpView->EndAction();
     753             :         }
     754             : 
     755           0 :         if( SD_MOD()->GetWaterCan() )
     756             :         {
     757           0 :             if( rMEvt.IsRight() )
     758             :             {
     759             :                 // In watering-can mode, on press onto right mouse button, a undo is executed
     760           0 :                 mpViewShell->GetViewFrame()->GetDispatcher()->Execute( SID_UNDO, SFX_CALLMODE_ASYNCHRON );
     761             :             }
     762           0 :             else if (pWaterCanCandidate != NULL)
     763             :             {
     764             :                 // Is the candiate object still under the mouse?
     765           0 :                 if (pickObject (aPnt) == pWaterCanCandidate)
     766             :                 {
     767             :                     SdStyleSheetPool* pPool = static_cast<SdStyleSheetPool*>(
     768           0 :                         mpDocSh->GetStyleSheetPool());
     769           0 :                     if (pPool != NULL)
     770             :                     {
     771             :                         SfxStyleSheet* pStyleSheet = static_cast<SfxStyleSheet*>(
     772           0 :                             pPool->GetActualStyleSheet());
     773           0 :                         if (pStyleSheet != NULL && mpView->IsUndoEnabled() )
     774             :                         {
     775             :                             // Added UNDOs for the WaterCan mode. This was never done in
     776             :                             // the past, thus it was missing all the time.
     777           0 :                             SdrUndoAction* pUndoAttr = mpDoc->GetSdrUndoFactory().CreateUndoAttrObject(*pWaterCanCandidate, true, true);
     778           0 :                             mpView->BegUndo(pUndoAttr->GetComment());
     779           0 :                             mpView->AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoGeoObject(*pWaterCanCandidate));
     780           0 :                             mpView->AddUndo(pUndoAttr);
     781             : 
     782           0 :                             pWaterCanCandidate->SetStyleSheet (pStyleSheet, false);
     783             : 
     784           0 :                             mpView->EndUndo();
     785             :                         }
     786             :                     }
     787             :                 }
     788             :             }
     789             :             // else when there has been no object under the mouse when the
     790             :             // button was pressed then nothing happens even when there is
     791             :             // one now.
     792             :         }
     793             : 
     794           0 :         sal_uInt16 nClicks = rMEvt.GetClicks();
     795             : 
     796           0 :         if (nClicks == 2 && rMEvt.IsLeft() && bMBDown &&
     797           0 :             !rMEvt.IsMod1() && !rMEvt.IsShift() )
     798             :         {
     799           0 :             DoubleClick(rMEvt);
     800             :         }
     801             : 
     802           0 :         bMBDown = sal_False;
     803             : 
     804           0 :         ForcePointer(&rMEvt);
     805           0 :         pHdl = NULL;
     806           0 :         mpWindow->ReleaseMouse();
     807           0 :         SdrObject* pSingleObj = NULL;
     808           0 :         sal_uLong nMarkCount = mpView->GetMarkedObjectList().GetMarkCount();
     809             : 
     810           0 :         if (nMarkCount==1)
     811             :         {
     812           0 :             pSingleObj = mpView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj();
     813             :         }
     814             : 
     815           0 :         if ( (nSlotId != SID_OBJECT_SELECT && nMarkCount==0)                    ||
     816           0 :              ( mpView->GetDragMode() == SDRDRAG_CROOK &&
     817           0 :               !mpView->IsCrookAllowed( mpView->IsCrookNoContortion() ) ) ||
     818           0 :              ( mpView->GetDragMode() == SDRDRAG_SHEAR &&
     819           0 :               !mpView->IsShearAllowed() && !mpView->IsDistortAllowed() ) ||
     820           0 :              ( nSlotId==SID_CONVERT_TO_3D_LATHE && pSingleObj &&
     821           0 :               (pSingleObj->GetObjInventor() != SdrInventor         ||
     822           0 :                pSingleObj->GetObjIdentifier() == OBJ_MEASURE) ) )
     823             :         {
     824           0 :             bReturn = sal_True;
     825           0 :             ForcePointer(&rMEvt);
     826           0 :             pHdl = NULL;
     827           0 :             mpWindow->ReleaseMouse();
     828           0 :             FuDraw::MouseButtonUp(rMEvt);
     829           0 :             mpViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_SYNCHRON);
     830           0 :             return bReturn; // CAUTION, due to the synchronous slot, the object is deleted now.
     831             :         }
     832             : 
     833           0 :         FuDraw::MouseButtonUp(rMEvt);
     834             :     }
     835             :     else
     836             :     {
     837             :         /**********************************************************************
     838             :         * BEZIER_EDITOR
     839             :         **********************************************************************/
     840           0 :         if ( mpView->IsAction() )
     841             :         {
     842           0 :             if ( mpView->IsInsObjPoint() )
     843             :             {
     844           0 :                 mpView->EndInsObjPoint(SDRCREATE_FORCEEND);
     845             :             }
     846           0 :             else if ( mpView->IsDragObj() )
     847             :             {
     848           0 :                 FrameView* pFrameView = mpViewShell->GetFrameView();
     849           0 :                 sal_Bool bDragWithCopy = (rMEvt.IsMod1() && pFrameView->IsDragWithCopy());
     850             : 
     851           0 :                 if (bDragWithCopy)
     852             :                 {
     853           0 :                     bDragWithCopy = !mpView->IsPresObjSelected(sal_False, sal_True);
     854             :                 }
     855             : 
     856           0 :                 mpView->SetDragWithCopy(bDragWithCopy);
     857           0 :                 mpView->EndDragObj( mpView->IsDragWithCopy() );
     858             :             }
     859             :             else
     860             :             {
     861           0 :                 mpView->EndAction();
     862             : 
     863           0 :                 sal_uInt16 nDrgLog2 = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
     864           0 :                 Point aPos = mpWindow->PixelToLogic( rMEvt.GetPosPixel() );
     865             : 
     866           0 :                 if (std::abs(aMDPos.X() - aPos.X()) < nDrgLog2 &&
     867           0 :                     std::abs(aMDPos.Y() - aPos.Y()) < nDrgLog2 &&
     868           0 :                     !rMEvt.IsShift() && !rMEvt.IsMod2())
     869             :                 {
     870           0 :                     SdrViewEvent aVEvt;
     871           0 :                     SdrHitKind eHit = mpView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
     872             : 
     873           0 :                     if (eHit == SDRHIT_NONE)
     874             :                     {
     875             :                         // Click on the same place - unselect
     876           0 :                         mpView->UnmarkAllObj();
     877           0 :                     }
     878             :                 }
     879             :             }
     880             :         }
     881           0 :         else if (!rMEvt.IsShift() && rMEvt.IsMod1() && !rMEvt.IsMod2() &&
     882           0 :                  std::abs(aPnt.X() - aMDPos.X()) < nDrgLog &&
     883           0 :                  std::abs(aPnt.Y() - aMDPos.Y()) < nDrgLog)
     884             :         {
     885             :             // Enter group
     886           0 :             mpView->MarkObj(aPnt, nHitLog, false, rMEvt.IsMod1());
     887             :         }
     888             : 
     889             : 
     890           0 :         ForcePointer(&rMEvt);
     891           0 :         pHdl = NULL;
     892           0 :         mpWindow->ReleaseMouse();
     893             : 
     894           0 :         FuDraw::MouseButtonUp(rMEvt);
     895             :     }
     896             : 
     897           0 :     return (bReturn);
     898             : }
     899             : 
     900             : /**
     901             :  * Process keyboard input
     902             :  * @returns sal_True if a KeyEvent is being processed, sal_False otherwise
     903             :  */
     904           0 : sal_Bool FuSelection::KeyInput(const KeyEvent& rKEvt)
     905             : {
     906           0 :     sal_Bool bReturn = sal_False;
     907             : 
     908           0 :     switch (rKEvt.GetKeyCode().GetCode())
     909             :     {
     910             :         case KEY_ESCAPE:
     911             :         {
     912           0 :             bReturn = FuSelection::cancel();
     913             :         }
     914           0 :         break;
     915             :         //add keyboard operation for insert points in drawing curve
     916             :         case KEY_UP:
     917             :         case KEY_DOWN:
     918             :         case KEY_LEFT:
     919             :         case KEY_RIGHT:
     920             :         {
     921           0 :             if(rKEvt.GetKeyCode().IsShift()&&(nEditMode == SID_BEZIER_INSERT)){
     922           0 :                 long nX = 0;
     923           0 :                 long nY = 0;
     924           0 :                 sal_uInt16  nCode = rKEvt.GetKeyCode().GetCode();
     925           0 :                 if (nCode == KEY_UP)
     926             :                 {
     927             :                     // Scroll nach oben
     928           0 :                     nX = 0;
     929           0 :                     nY =-1;
     930             :                 }
     931           0 :                 else if (nCode == KEY_DOWN)
     932             :                 {
     933             :                     // Scroll nach unten
     934           0 :                     nX = 0;
     935           0 :                     nY = 1;
     936             :                 }
     937           0 :                 else if (nCode == KEY_LEFT)
     938             :                 {
     939             :                     // Scroll nach links
     940           0 :                     nX =-1;
     941           0 :                     nY = 0;
     942             :                 }
     943           0 :                 else if (nCode == KEY_RIGHT)
     944             :                 {
     945             :                     // Scroll nach rechts
     946           0 :                     nX = 1;
     947           0 :                     nY = 0;
     948             :                 }
     949             : 
     950           0 :                 Point centerPoint;
     951           0 :                 Rectangle rect = mpView->GetMarkedObjRect();
     952           0 :                 centerPoint = mpWindow->LogicToPixel(rect.Center());
     953           0 :                 Point aPoint = bMovedToCenterPoint? oldPoint:centerPoint;
     954           0 :                 Point ePoint = aPoint + Point(nX,nY);
     955           0 :                 mpWindow->SetPointerPosPixel(ePoint);
     956             :                 //simulate mouse move action
     957           0 :                 MouseEvent eMevt(ePoint,1,2, MOUSE_LEFT, 0);
     958           0 :                 MouseMove(eMevt);
     959           0 :                 oldPoint = ePoint;
     960           0 :                 bMovedToCenterPoint = sal_True;
     961           0 :                 bReturn = sal_True;
     962             :             }
     963             :         }
     964           0 :         break;
     965             :         case KEY_RETURN:
     966           0 :             if(rKEvt.GetKeyCode().IsShift()&&(nEditMode == SID_BEZIER_INSERT))
     967             :             {
     968           0 :                 if(!bBeginInsertPoint)
     969             :                 {
     970             :                     //simulate mouse button down action
     971           0 :                     MouseEvent aMevt(oldPoint,1,3, MOUSE_LEFT, KEY_SHIFT);
     972           0 :                     MouseButtonDown(aMevt);
     973           0 :                     mpWindow->CaptureMouse();
     974           0 :                     bBeginInsertPoint = sal_True;
     975             :                 }
     976             :                 else
     977             :                 {
     978             :                     //simulate mouse button up action
     979           0 :                     MouseEvent rMEvt(oldPoint,1,17, MOUSE_LEFT, KEY_SHIFT);
     980           0 :                     MouseButtonUp(rMEvt);
     981           0 :                     bBeginInsertPoint = sal_False;
     982             :                 }
     983           0 :                 bReturn= sal_True;
     984             :             }
     985           0 :             break;
     986             :     }
     987           0 :     if (!bReturn)
     988             :     {
     989           0 :         bReturn = FuDraw::KeyInput(rKEvt);
     990             : 
     991           0 :         if(mpView->GetMarkedObjectList().GetMarkCount() == 0)
     992             :         {
     993           0 :             mpView->ResetCreationActive();
     994             : 
     995           0 :             mpViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
     996             :         }
     997             :     }
     998             : 
     999           0 :     return(bReturn);
    1000             : 
    1001             : }
    1002             : 
    1003             : 
    1004         205 : void FuSelection::Activate()
    1005             : {
    1006             :     SdrDragMode eMode;
    1007         205 :     mpView->ResetCreationActive();
    1008         205 :     mpView->SetEditMode(SDREDITMODE_EDIT);
    1009             : 
    1010         205 :     switch( nSlotId )
    1011             :     {
    1012             :         case SID_OBJECT_ROTATE:
    1013             :         {
    1014             :             // (mapped) Slot is explicitly set to rotate
    1015           0 :             if( mpViewShell->ISA(DrawViewShell) )
    1016             :             {
    1017             :                 sal_uInt16* pSlotArray =
    1018           0 :                     static_cast<DrawViewShell*>(mpViewShell)->GetSlotArray();
    1019           0 :                 pSlotArray[ 1 ] = SID_OBJECT_ROTATE;
    1020             :             }
    1021             : 
    1022           0 :             eMode = SDRDRAG_ROTATE;
    1023             : 
    1024           0 :             if ( mpView->GetDragMode() != eMode )
    1025           0 :                 mpView->SetDragMode(eMode);
    1026             :         }
    1027           0 :         break;
    1028             : 
    1029             :         case SID_OBJECT_MIRROR:
    1030             :         {
    1031           0 :             eMode = SDRDRAG_MIRROR;
    1032             : 
    1033           0 :             if ( mpView->GetDragMode() != eMode )
    1034           0 :                 mpView->SetDragMode(eMode);
    1035             :         }
    1036           0 :         break;
    1037             : 
    1038             :         case SID_OBJECT_CROP:
    1039             :         {
    1040           0 :             eMode = SDRDRAG_CROP;
    1041             : 
    1042           0 :             if ( mpView->GetDragMode() != eMode )
    1043           0 :                 mpView->SetDragMode(eMode);
    1044             :         }
    1045           0 :         break;
    1046             : 
    1047             :         case SID_OBJECT_TRANSPARENCE:
    1048             :         {
    1049           0 :             eMode = SDRDRAG_TRANSPARENCE;
    1050             : 
    1051           0 :             if ( mpView->GetDragMode() != eMode )
    1052           0 :                 mpView->SetDragMode(eMode);
    1053             :         }
    1054           0 :         break;
    1055             : 
    1056             :         case SID_OBJECT_GRADIENT:
    1057             :         {
    1058           0 :             eMode = SDRDRAG_GRADIENT;
    1059             : 
    1060           0 :             if ( mpView->GetDragMode() != eMode )
    1061           0 :                 mpView->SetDragMode(eMode);
    1062             :         }
    1063           0 :         break;
    1064             : 
    1065             :         case SID_OBJECT_SHEAR:
    1066             :         {
    1067           0 :             eMode = SDRDRAG_SHEAR;
    1068             : 
    1069           0 :             if ( mpView->GetDragMode() != eMode )
    1070           0 :                 mpView->SetDragMode(eMode);
    1071             :         }
    1072           0 :         break;
    1073             : 
    1074             :         case SID_OBJECT_CROOK_ROTATE:
    1075             :         {
    1076           0 :             eMode = SDRDRAG_CROOK;
    1077             : 
    1078           0 :             if ( mpView->GetDragMode() != eMode )
    1079             :             {
    1080           0 :                 mpView->SetDragMode(eMode);
    1081           0 :                 mpView->SetCrookMode(SDRCROOK_ROTATE);
    1082             :             }
    1083             :         }
    1084           0 :         break;
    1085             : 
    1086             :         case SID_OBJECT_CROOK_SLANT:
    1087             :         {
    1088           0 :             eMode = SDRDRAG_CROOK;
    1089             : 
    1090           0 :             if ( mpView->GetDragMode() != eMode )
    1091             :             {
    1092           0 :                 mpView->SetDragMode(eMode);
    1093           0 :                 mpView->SetCrookMode(SDRCROOK_SLANT);
    1094             :             }
    1095             :         }
    1096           0 :         break;
    1097             : 
    1098             :         case SID_OBJECT_CROOK_STRETCH:
    1099             :         {
    1100           0 :             eMode = SDRDRAG_CROOK;
    1101             : 
    1102           0 :             if ( mpView->GetDragMode() != eMode )
    1103             :             {
    1104           0 :                 mpView->SetDragMode(eMode);
    1105           0 :                 mpView->SetCrookMode(SDRCROOK_STRETCH);
    1106             :             }
    1107             :         }
    1108           0 :         break;
    1109             : 
    1110             :         case SID_CONVERT_TO_3D_LATHE:
    1111             :         {
    1112           0 :             eMode = SDRDRAG_MIRROR;
    1113           0 :             bSuppressChangesOfSelection = sal_True;
    1114             : 
    1115           0 :             if ( mpView->GetDragMode() != eMode )
    1116           0 :                 mpView->SetDragMode(eMode);
    1117             : 
    1118           0 :             if (!mpView->Is3DRotationCreationActive())
    1119           0 :                 mpView->Start3DCreation();
    1120             : 
    1121           0 :             bSuppressChangesOfSelection = sal_False;
    1122             :         }
    1123           0 :         break;
    1124             : 
    1125             :         default:
    1126             :         {
    1127         205 :             eMode = SDRDRAG_MOVE;
    1128             : 
    1129         205 :             if ( mpView->GetDragMode() != eMode )
    1130           0 :                 mpView->SetDragMode(eMode);
    1131             :         }
    1132         205 :         break;
    1133             :     }
    1134             : 
    1135         205 :     if (nSlotId != SID_OBJECT_ROTATE)
    1136             :     {
    1137         205 :         bTempRotation = sal_False;
    1138             :     }
    1139             : 
    1140         205 :     FuDraw::Activate();
    1141         205 : }
    1142             : 
    1143             : 
    1144             : 
    1145         195 : void FuSelection::Deactivate()
    1146             : {
    1147         195 :     FuDraw::Deactivate();
    1148         195 : }
    1149             : 
    1150             : 
    1151          74 : void FuSelection::SelectionHasChanged()
    1152             : {
    1153          74 :     bSelectionChanged = sal_True;
    1154             : 
    1155          74 :     FuDraw::SelectionHasChanged();
    1156             : 
    1157          74 :     if ((mpView->Is3DRotationCreationActive() && !bSuppressChangesOfSelection))
    1158             :     {
    1159             :         // Switch rotation body -> selection
    1160           0 :         mpView->ResetCreationActive();
    1161           0 :         nSlotId = SID_OBJECT_SELECT;
    1162           0 :         Activate();
    1163             :     }
    1164             : 
    1165             :     // Activate the right tool bar for the current context of the view.
    1166          74 :     mpViewShell->GetViewShellBase().GetToolBarManager()->SelectionHasChanged(*mpViewShell, *mpView);
    1167          74 : }
    1168             : 
    1169             : 
    1170             : /**
    1171             :  * Set current bezier edit mode
    1172             :  */
    1173           0 : void FuSelection::SetEditMode(sal_uInt16 nMode)
    1174             : {
    1175           0 :     nEditMode = nMode;
    1176             : 
    1177           0 :     if (nEditMode == SID_BEZIER_INSERT)
    1178             :     {
    1179           0 :         mpView->SetInsObjPointMode(true);
    1180             :     }
    1181             :     else
    1182             :     {
    1183           0 :         mpView->SetInsObjPointMode(false);
    1184             :     }
    1185             : 
    1186           0 :     ForcePointer();
    1187             : 
    1188           0 :     SfxBindings& rBindings = mpViewShell->GetViewFrame()->GetBindings();
    1189           0 :     rBindings.Invalidate(SID_BEZIER_MOVE);
    1190           0 :     rBindings.Invalidate(SID_BEZIER_INSERT);
    1191           0 : }
    1192             : 
    1193             : /**
    1194             :  * Execute animation or interaction
    1195             :  */
    1196           0 : sal_Bool FuSelection::AnimateObj(SdrObject* pObj, const Point& rPos)
    1197             : {
    1198           0 :     sal_Bool bAnimated = sal_False;
    1199           0 :     sal_Bool bClosed = pObj->IsClosedObj();
    1200           0 :     sal_Bool bFilled = sal_False;
    1201             : 
    1202           0 :     if (bClosed)
    1203             :     {
    1204           0 :         SfxItemSet aSet(mpDoc->GetPool());
    1205             : 
    1206           0 :         aSet.Put(pObj->GetMergedItemSet());
    1207             : 
    1208           0 :         const XFillStyleItem& rFillStyle = (const XFillStyleItem&) aSet.Get(XATTR_FILLSTYLE);
    1209           0 :         bFilled = rFillStyle.GetValue() != XFILL_NONE;
    1210             :     }
    1211             : 
    1212           0 :     const SetOfByte* pVisiLayer = &mpView->GetSdrPageView()->GetVisibleLayers();
    1213           0 :     sal_uInt16 nHitLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(HITPIX,0)).Width() );
    1214           0 :     const long  n2HitLog = nHitLog * 2;
    1215           0 :     Point aHitPosR(rPos);
    1216           0 :     Point aHitPosL(rPos);
    1217           0 :     Point aHitPosT(rPos);
    1218           0 :     Point aHitPosB(rPos);
    1219             : 
    1220           0 :     aHitPosR.X() += n2HitLog;
    1221           0 :     aHitPosL.X() -= n2HitLog;
    1222           0 :     aHitPosT.Y() += n2HitLog;
    1223           0 :     aHitPosB.Y() -= n2HitLog;
    1224             : 
    1225           0 :     if ( !bClosed                                      ||
    1226           0 :          !bFilled                                      ||
    1227           0 :          (SdrObjectPrimitiveHit(*pObj, aHitPosR, nHitLog, *mpView->GetSdrPageView(), pVisiLayer, false) &&
    1228           0 :           SdrObjectPrimitiveHit(*pObj, aHitPosL, nHitLog, *mpView->GetSdrPageView(), pVisiLayer, false) &&
    1229           0 :           SdrObjectPrimitiveHit(*pObj, aHitPosT, nHitLog, *mpView->GetSdrPageView(), pVisiLayer, false) &&
    1230           0 :           SdrObjectPrimitiveHit(*pObj, aHitPosB, nHitLog, *mpView->GetSdrPageView(), pVisiLayer, false) ) )
    1231             :     {
    1232           0 :         if ( mpDoc->GetIMapInfo( pObj ) )
    1233             :         {
    1234           0 :             const IMapObject* pIMapObj = mpDoc->GetHitIMapObject( pObj, rPos, *mpWindow );
    1235             : 
    1236           0 :             if ( pIMapObj && !pIMapObj->GetURL().isEmpty() )
    1237             :             {
    1238             :                 // Jump to Document
    1239           0 :                 mpWindow->ReleaseMouse();
    1240           0 :                 SfxStringItem aStrItem(SID_FILE_NAME, pIMapObj->GetURL());
    1241           0 :                 SfxStringItem aReferer(SID_REFERER, mpDocSh->GetMedium()->GetName());
    1242           0 :                 SfxViewFrame* pFrame = mpViewShell->GetViewFrame();
    1243           0 :                 SfxFrameItem aFrameItem(SID_DOCFRAME, pFrame);
    1244           0 :                 SfxBoolItem aBrowseItem( SID_BROWSE, true );
    1245           0 :                 mpWindow->ReleaseMouse();
    1246             :                 pFrame->GetDispatcher()->
    1247             :                     Execute(SID_OPENDOC, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
    1248           0 :                             &aStrItem, &aFrameItem, &aBrowseItem, &aReferer, 0L);
    1249             : 
    1250           0 :                 bAnimated = sal_True;
    1251             :             }
    1252             :         }
    1253           0 :         else if (!mpDocSh->ISA(GraphicDocShell)        &&
    1254           0 :                  mpView->ISA(DrawView)                 &&
    1255           0 :                  mpDoc->GetAnimationInfo(pObj))
    1256             :         {
    1257             :             /**********************************************************
    1258             :             * Animation-object hit in the middle -> interaction
    1259             :             **********************************************************/
    1260           0 :             SdAnimationInfo* pInfo = mpDoc->GetAnimationInfo(pObj);
    1261           0 :             DrawViewShell* pDrViewSh = static_cast<DrawViewShell*>(mpViewShell);
    1262           0 :             mpWindow->ReleaseMouse();
    1263             : 
    1264           0 :             switch (pInfo->meClickAction)
    1265             :             {
    1266             :                 case presentation::ClickAction_BOOKMARK:
    1267             :                 {
    1268             :                      // Jump to Bookmark (Page or Object)
    1269           0 :                     SfxStringItem aItem(SID_NAVIGATOR_OBJECT, pInfo->GetBookmark());
    1270             :                     mpViewShell->GetViewFrame()->GetDispatcher()->
    1271           0 :                     Execute(SID_NAVIGATOR_OBJECT, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD, &aItem, 0L);
    1272           0 :                     bAnimated = sal_True;
    1273             :                 }
    1274           0 :                 break;
    1275             : 
    1276             :                 case presentation::ClickAction_DOCUMENT:
    1277             :                 {
    1278           0 :                     OUString sBookmark( pInfo->GetBookmark() );
    1279             :                     // Jump to document
    1280           0 :                     if (!sBookmark.isEmpty())
    1281             :                     {
    1282           0 :                         SfxStringItem aReferer(SID_REFERER, mpDocSh->GetMedium()->GetName());
    1283           0 :                         SfxStringItem aStrItem(SID_FILE_NAME, sBookmark);
    1284           0 :                         SfxViewFrame* pFrame = mpViewShell->GetViewFrame();
    1285           0 :                         SfxFrameItem aFrameItem(SID_DOCFRAME, pFrame);
    1286           0 :                         SfxBoolItem aBrowseItem( SID_BROWSE, true );
    1287             :                         pFrame->GetDispatcher()->
    1288             :                         Execute(SID_OPENDOC, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
    1289           0 :                                 &aStrItem, &aFrameItem, &aBrowseItem, &aReferer, 0L);
    1290             :                     }
    1291             : 
    1292           0 :                     bAnimated = sal_True;
    1293             :                 }
    1294           0 :                 break;
    1295             : 
    1296             :                 case presentation::ClickAction_PREVPAGE:
    1297             :                 {
    1298             :                     // Jump to the previous page
    1299           0 :                     SfxUInt16Item aItem(SID_NAVIGATOR_PAGE, PAGE_PREVIOUS);
    1300             :                     mpViewShell->GetViewFrame()->GetDispatcher()->
    1301             :                     Execute(SID_NAVIGATOR_PAGE, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD,
    1302           0 :                             &aItem, 0L);
    1303           0 :                     bAnimated = sal_True;
    1304             :                 }
    1305           0 :                 break;
    1306             : 
    1307             :                 case presentation::ClickAction_NEXTPAGE:
    1308             :                 {
    1309             :                     // Jump to the next page
    1310           0 :                     SfxUInt16Item aItem(SID_NAVIGATOR_PAGE, PAGE_NEXT);
    1311             :                     mpViewShell->GetViewFrame()->GetDispatcher()->
    1312             :                     Execute(SID_NAVIGATOR_PAGE, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD,
    1313           0 :                             &aItem, 0L);
    1314           0 :                     bAnimated = sal_True;
    1315             :                 }
    1316           0 :                 break;
    1317             : 
    1318             :                 case presentation::ClickAction_FIRSTPAGE:
    1319             :                 {
    1320             :                     // Jump to the first page
    1321           0 :                     SfxUInt16Item aItem(SID_NAVIGATOR_PAGE, PAGE_FIRST);
    1322             :                     mpViewShell->GetViewFrame()->GetDispatcher()->
    1323             :                     Execute(SID_NAVIGATOR_PAGE, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD,
    1324           0 :                             &aItem, 0L);
    1325           0 :                     bAnimated = sal_True;
    1326             :                 }
    1327           0 :                 break;
    1328             : 
    1329             :                 case presentation::ClickAction_LASTPAGE:
    1330             :                 {
    1331             :                     // Jump to the last page
    1332           0 :                     SfxUInt16Item aItem(SID_NAVIGATOR_PAGE, PAGE_LAST);
    1333             :                     mpViewShell->GetViewFrame()->GetDispatcher()->
    1334             :                     Execute(SID_NAVIGATOR_PAGE, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD,
    1335           0 :                             &aItem, 0L);
    1336           0 :                     bAnimated = sal_True;
    1337             :                 }
    1338           0 :                 break;
    1339             : 
    1340             :                 case presentation::ClickAction_SOUND:
    1341             :                 {
    1342             :                         try
    1343             :                         {
    1344           0 :                             mxPlayer.set( avmedia::MediaWindow::createPlayer( pInfo->GetBookmark(), ""/*TODO?*/), uno::UNO_QUERY_THROW );
    1345           0 :                             mxPlayer->start();
    1346             :                         }
    1347           0 :                         catch( uno::Exception& )
    1348             :                         {
    1349             :                         }
    1350           0 :                     bAnimated = sal_True;
    1351             :                 }
    1352           0 :                 break;
    1353             : 
    1354             :                 case presentation::ClickAction_VERB:
    1355             :                 {
    1356             :                     // Assign verb
    1357           0 :                     mpView->UnmarkAll();
    1358           0 :                     mpView->MarkObj(pObj, mpView->GetSdrPageView(), false, false);
    1359           0 :                     pDrViewSh->DoVerb((sal_Int16)pInfo->mnVerb);
    1360           0 :                     bAnimated = sal_True;
    1361             :                 }
    1362           0 :                 break;
    1363             : 
    1364             :                 case presentation::ClickAction_PROGRAM:
    1365             :                 {
    1366           0 :                    OUString aBaseURL = GetDocSh()->GetMedium()->GetBaseURL();
    1367             :                    INetURLObject aURL( ::URIHelper::SmartRel2Abs( INetURLObject(aBaseURL), pInfo->GetBookmark(),
    1368             :                                                 URIHelper::GetMaybeFileHdl(), true, false,
    1369           0 :                                                 INetURLObject::WAS_ENCODED, INetURLObject::DECODE_UNAMBIGUOUS ) );
    1370             : 
    1371           0 :                    if( INET_PROT_FILE == aURL.GetProtocol() )
    1372             :                    {
    1373           0 :                         SfxStringItem aUrl( SID_FILE_NAME, aURL.GetMainURL( INetURLObject::NO_DECODE ) );
    1374           0 :                         SfxBoolItem aBrowsing( SID_BROWSE, true );
    1375             : 
    1376           0 :                         SfxViewFrame* pViewFrm = SfxViewFrame::Current();
    1377           0 :                         if (pViewFrm)
    1378             :                             pViewFrm->GetDispatcher()->Execute( SID_OPENDOC,
    1379             :                                                           SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
    1380             :                                                         &aUrl,
    1381             :                                                         &aBrowsing,
    1382           0 :                                                         0L );
    1383             :                    }
    1384             : 
    1385           0 :                     bAnimated = sal_True;
    1386             :                 }
    1387           0 :                 break;
    1388             : 
    1389             :                 case presentation::ClickAction_MACRO:
    1390             :                 {
    1391             :                     // Execute macro
    1392           0 :                     OUString aMacro = pInfo->GetBookmark();
    1393             : 
    1394           0 :                     if ( SfxApplication::IsXScriptURL( aMacro ) )
    1395             :                     {
    1396           0 :                         uno::Any aRet;
    1397           0 :                         uno::Sequence< sal_Int16 > aOutArgsIndex;
    1398           0 :                         uno::Sequence< uno::Any > aOutArgs;
    1399             :                         uno::Sequence< uno::Any >* pInArgs =
    1400           0 :                             new uno::Sequence< uno::Any >(0);
    1401             : 
    1402             :                         ErrCode eErr = mpDocSh->CallXScript( aMacro,
    1403           0 :                             *pInArgs, aRet, aOutArgsIndex, aOutArgs);
    1404             : 
    1405             :                         // Check the return value from the script
    1406           0 :                         sal_Bool bTmp = sal_False;
    1407           0 :                         if ( eErr == ERRCODE_NONE &&
    1408           0 :                              aRet.getValueType() == getCppuBooleanType() &&
    1409           0 :                              ( aRet >>= bTmp ) &&
    1410           0 :                              bTmp == sal_True )
    1411             :                         {
    1412           0 :                             bAnimated = sal_True;
    1413             :                         }
    1414             :                         else
    1415             :                         {
    1416           0 :                             bAnimated = sal_False;
    1417           0 :                         }
    1418             :                     }
    1419             :                     else
    1420             :                     {
    1421             :                         // aMacro has got following format:
    1422             :                         // "Macroname.Modulname.Libname.Documentname" or
    1423             :                         // "Macroname.Modulname.Libname.Applicationname"
    1424           0 :                         OUString aMacroName = aMacro.getToken(0, '.');
    1425           0 :                         OUString aModulName = aMacro.getToken(1, '.');
    1426             : 
    1427             :                         // In this moment the Call-method only
    1428             :                         // resolves modulename+macroname
    1429           0 :                         OUString aExecMacro(aModulName + "." + aMacroName);
    1430           0 :                         bAnimated = mpDocSh->GetBasic()->Call(aExecMacro);
    1431           0 :                     }
    1432             :                 }
    1433           0 :                 break;
    1434             : 
    1435             :                 default:
    1436             :                 {
    1437           0 :                     bAnimated = sal_False;
    1438             :                 }
    1439           0 :                 break;
    1440             :             }
    1441             :         }
    1442             : 
    1443           0 :         if (!bAnimated                               &&
    1444           0 :             mpView->ISA(DrawView)                 &&
    1445           0 :             !mpDocSh->ISA(GraphicDocShell)        &&
    1446           0 :             SlideShow::IsRunning( mpViewShell->GetViewShellBase() ) &&
    1447           0 :             mpDoc->GetAnimationInfo(pObj))
    1448             :         {
    1449             :             /**********************************************************
    1450             :             * Effect-Object hit in the middle -> Play effect
    1451             :             **********************************************************/
    1452           0 :             SdAnimationInfo* pInfo = mpDoc->GetAnimationInfo(pObj);
    1453             : 
    1454           0 :             switch (pInfo->meClickAction)
    1455             :             {
    1456             :                 case presentation::ClickAction_VANISH:
    1457             :                 case presentation::ClickAction_INVISIBLE:
    1458           0 :                     break;
    1459             : 
    1460             :                 default:
    1461           0 :                     bAnimated = sal_False;
    1462           0 :                 break;
    1463             :             }
    1464             :         }
    1465             :     }
    1466             : 
    1467           0 :     return bAnimated;
    1468             : }
    1469             : 
    1470             : 
    1471             : 
    1472             : /** is called when the current function should be aborted. <p>
    1473             :     This is used when a function gets a KEY_ESCAPE but can also
    1474             :     be called directly.
    1475             : 
    1476             :     @returns true if a active function was aborted
    1477             : */
    1478           0 : bool FuSelection::cancel()
    1479             : {
    1480           0 :     if (mpView->Is3DRotationCreationActive())
    1481             :     {
    1482           0 :         mpView->ResetCreationActive();
    1483           0 :         mpViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
    1484           0 :         return true;
    1485             :     }
    1486             :     else
    1487             :     {
    1488           0 :         return false;
    1489             :     }
    1490             : }
    1491             : 
    1492             : 
    1493             : 
    1494             : 
    1495           0 : SdrObject* FuSelection::pickObject (const Point& rTestPoint)
    1496             : {
    1497           0 :     SdrObject* pObject = NULL;
    1498             :     SdrPageView* pPageView;
    1499           0 :     sal_uInt16 nHitLog = sal_uInt16 (mpWindow->PixelToLogic(Size(HITPIX,0)).Width());
    1500           0 :     mpView->PickObj (rTestPoint, nHitLog, pObject, pPageView, SDRSEARCH_PICKMARKABLE);
    1501           0 :     return pObject;
    1502             : }
    1503             : 
    1504         205 : void FuSelection::ForcePointer(const MouseEvent* pMEvt)
    1505             : {
    1506         205 :     if(bMovedToCenterPoint && !bBeginInsertPoint && pMEvt)
    1507             :     {
    1508           0 :         MouseEvent aMEvt(pMEvt->GetPosPixel(), pMEvt->GetClicks(),
    1509           0 :             pMEvt->GetMode(), pMEvt->GetButtons(), pMEvt->GetModifier() & ~KEY_SHIFT);
    1510           0 :         FuDraw::ForcePointer(&aMEvt);
    1511             :     }
    1512             :     else
    1513             :     {
    1514         205 :         FuDraw::ForcePointer(pMEvt);
    1515             :     }
    1516         205 : }
    1517             : 
    1518             : } // end of namespace sd
    1519             : 
    1520             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10