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

Generated by: LCOV version 1.10