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

Generated by: LCOV version 1.10