LCOV - code coverage report
Current view: top level - sw/source/core/uibase/ribbar - drawbase.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 302 0.0 %
Date: 2014-04-11 Functions: 0 15 0.0 %
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 <hintids.hxx>
      21             : #include <svx/svdview.hxx>
      22             : #include <svx/svdobj.hxx>
      23             : #include <svl/ptitem.hxx>
      24             : #include <editeng/sizeitem.hxx>
      25             : #include <sfx2/request.hxx>
      26             : #include <sfx2/bindings.hxx>
      27             : #include <fmtclds.hxx>
      28             : #include <frmfmt.hxx>
      29             : #include "cmdid.h"
      30             : #include "basesh.hxx"
      31             : #include "view.hxx"
      32             : #include "wrtsh.hxx"
      33             : #include "drawbase.hxx"
      34             : #include "edtwin.hxx"
      35             : #include "caption.hxx"
      36             : #include "swundo.hxx"
      37             : #include <SwRewriter.hxx>
      38             : #include "comcore.hrc"
      39             : 
      40             : using namespace ::com::sun::star;
      41             : 
      42             : extern bool bNoInterrupt;       // in mainwn.cxx
      43             : 
      44           0 : SwDrawBase::SwDrawBase(SwWrtShell* pSwWrtShell, SwEditWin* pWindow, SwView* pSwView) :
      45             :     m_pView(pSwView),
      46             :     m_pSh(pSwWrtShell),
      47             :     m_pWin(pWindow),
      48             :     m_nSlotId(USHRT_MAX),
      49             :     m_bCreateObj(true),
      50           0 :     m_bInsForm(false)
      51             : {
      52           0 :     if ( !m_pSh->HasDrawView() )
      53           0 :         m_pSh->MakeDrawView();
      54           0 : }
      55             : 
      56           0 : SwDrawBase::~SwDrawBase()
      57             : {
      58           0 :     if (m_pView->GetWrtShellPtr()) // In the view-dtor could the wrtsh already been deleted...
      59           0 :         m_pSh->GetDrawView()->SetEditMode(true);
      60           0 : }
      61             : 
      62           0 : sal_Bool SwDrawBase::MouseButtonDown(const MouseEvent& rMEvt)
      63             : {
      64           0 :     sal_Bool bReturn = sal_False;
      65             : 
      66           0 :     SdrView *pSdrView = m_pSh->GetDrawView();
      67             : 
      68             :     // #i33136#
      69           0 :     pSdrView->SetOrtho(doConstructOrthogonal() ? !rMEvt.IsShift() : rMEvt.IsShift());
      70           0 :     pSdrView->SetAngleSnapEnabled(rMEvt.IsShift());
      71             : 
      72           0 :     if (rMEvt.IsMod2())
      73             :     {
      74           0 :         pSdrView->SetCreate1stPointAsCenter(true);
      75           0 :         pSdrView->SetResizeAtCenter(true);
      76             :     }
      77             :     else
      78             :     {
      79           0 :         pSdrView->SetCreate1stPointAsCenter(false);
      80           0 :         pSdrView->SetResizeAtCenter(false);
      81             :     }
      82             : 
      83           0 :     SdrViewEvent aVEvt;
      84           0 :     SdrHitKind eHit = pSdrView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
      85             : 
      86             :     // Only new object, if not in the basic mode (or pure selection mode).
      87           0 :     if (rMEvt.IsLeft() && !m_pWin->IsDrawAction())
      88             :     {
      89           0 :         if (IsCreateObj() && (eHit == SDRHIT_UNMARKEDOBJECT || eHit == SDRHIT_NONE || m_pSh->IsDrawCreate()))
      90             :         {
      91           0 :             bNoInterrupt = true;
      92           0 :             m_pWin->CaptureMouse();
      93             : 
      94           0 :             m_aStartPos = m_pWin->PixelToLogic(rMEvt.GetPosPixel());
      95             : 
      96           0 :             bReturn = m_pSh->BeginCreate( static_cast< sal_uInt16 >(m_pWin->GetSdrDrawMode()), m_aStartPos);
      97             : 
      98           0 :             SetDrawPointer();
      99             : 
     100           0 :             if ( bReturn )
     101           0 :                 m_pWin->SetDrawAction(sal_True);
     102             :         }
     103           0 :         else if (!pSdrView->IsAction())
     104             :         {
     105             :             // BEZIER-EDITOR
     106           0 :             m_pWin->CaptureMouse();
     107           0 :             m_aStartPos = m_pWin->PixelToLogic(rMEvt.GetPosPixel());
     108           0 :             sal_uInt16 nEditMode = m_pWin->GetBezierMode();
     109             : 
     110           0 :             if (eHit == SDRHIT_HANDLE && aVEvt.pHdl->GetKind() == HDL_BWGT)
     111             :             {
     112             :                 // Drag handle
     113           0 :                 bNoInterrupt = true;
     114           0 :                 bReturn = pSdrView->BegDragObj(m_aStartPos, (OutputDevice*) NULL, aVEvt.pHdl);
     115           0 :                 m_pWin->SetDrawAction(sal_True);
     116             :             }
     117           0 :             else if (eHit == SDRHIT_MARKEDOBJECT && nEditMode == SID_BEZIER_INSERT)
     118             :             {
     119             :                 // Insert gluepoint
     120           0 :                 bNoInterrupt = true;
     121           0 :                 bReturn = pSdrView->BegInsObjPoint(m_aStartPos, rMEvt.IsMod1());
     122           0 :                 m_pWin->SetDrawAction(sal_True);
     123             :             }
     124           0 :             else if (eHit == SDRHIT_MARKEDOBJECT && rMEvt.IsMod1())
     125             :             {
     126             :                 // Select gluepoint
     127           0 :                 if (!rMEvt.IsShift())
     128           0 :                     pSdrView->UnmarkAllPoints();
     129             : 
     130           0 :                 bReturn = pSdrView->BegMarkPoints(m_aStartPos);
     131           0 :                 m_pWin->SetDrawAction(sal_True);
     132             :             }
     133           0 :             else if (eHit == SDRHIT_MARKEDOBJECT && !rMEvt.IsShift() && !rMEvt.IsMod2())
     134             :             {
     135             :                 // Move objekt
     136           0 :                 return sal_False;
     137             :             }
     138           0 :             else if (eHit == SDRHIT_HANDLE)
     139             :             {
     140             :                 // Select gluepoint
     141           0 :                 if (pSdrView->HasMarkablePoints() && (!pSdrView->IsPointMarked(*aVEvt.pHdl) || rMEvt.IsShift()))
     142             :                 {
     143           0 :                     SdrHdl* pHdl = NULL;
     144             : 
     145           0 :                     if (!rMEvt.IsShift())
     146             :                     {
     147           0 :                         pSdrView->UnmarkAllPoints();
     148           0 :                         pHdl = pSdrView->PickHandle(m_aStartPos);
     149             :                     }
     150             :                     else
     151             :                     {
     152           0 :                         if (pSdrView->IsPointMarked(*aVEvt.pHdl))
     153             :                         {
     154           0 :                             bReturn = pSdrView->UnmarkPoint(*aVEvt.pHdl);
     155           0 :                             pHdl = NULL;
     156             :                         }
     157             :                         else
     158             :                         {
     159           0 :                             pHdl = pSdrView->PickHandle(m_aStartPos);
     160             :                         }
     161             :                     }
     162             : 
     163           0 :                     if (pHdl)
     164             :                     {
     165           0 :                         bNoInterrupt = true;
     166           0 :                         pSdrView->MarkPoint(*pHdl);
     167             :                     }
     168             :                 }
     169             :             }
     170             :             else
     171             :             {
     172             :                 // Select or drag object
     173           0 :                 if (m_pSh->IsObjSelectable(m_aStartPos) && eHit == SDRHIT_UNMARKEDOBJECT)
     174             :                 {
     175           0 :                     if (pSdrView->HasMarkablePoints())
     176           0 :                         pSdrView->UnmarkAllPoints();
     177             : 
     178           0 :                     bNoInterrupt = false;
     179             :                     // Use drag in edtwin
     180           0 :                     return sal_False;
     181             :                 }
     182             : 
     183           0 :                 bNoInterrupt = true;
     184             : 
     185           0 :                 if (m_pSh->IsObjSelected())
     186             :                 {
     187           0 :                     if (!rMEvt.IsShift())
     188             :                     {
     189           0 :                         if (!pSdrView->HasMarkablePoints())
     190             :                         {
     191           0 :                             bool bUnlockView = !m_pSh->IsViewLocked();
     192           0 :                             m_pSh->LockView( sal_True ); //lock visible section
     193           0 :                             m_pSh->SelectObj(Point(LONG_MAX, LONG_MAX)); // deselect all
     194           0 :                             if( bUnlockView )
     195           0 :                                 m_pSh->LockView( sal_False );
     196             :                         }
     197             :                         else
     198           0 :                             pSdrView->UnmarkAllPoints();
     199             :                     }
     200             :                 }
     201           0 :                 if (!m_pSh->IsSelFrmMode())
     202           0 :                     m_pSh->EnterSelFrmMode(NULL);
     203             : 
     204           0 :                 if( 0 != (bReturn = m_pSh->BeginMark(m_aStartPos)) )
     205           0 :                     m_pWin->SetDrawAction(sal_True);
     206             : 
     207           0 :                 SetDrawPointer();
     208             :             }
     209             :         }
     210             :     }
     211           0 :     return bReturn;
     212             : }
     213             : 
     214           0 : sal_Bool SwDrawBase::MouseMove(const MouseEvent& rMEvt)
     215             : {
     216           0 :     SdrView *pSdrView = m_pSh->GetDrawView();
     217           0 :     Point aPnt(m_pWin->PixelToLogic(rMEvt.GetPosPixel()));
     218           0 :     sal_Bool bRet = sal_False;
     219             : 
     220           0 :     if (IsCreateObj() && !m_pWin->IsDrawSelMode() && pSdrView->IsCreateObj())
     221             :     {
     222             :         // #i33136#
     223           0 :         pSdrView->SetOrtho(doConstructOrthogonal() ? !rMEvt.IsShift() : rMEvt.IsShift());
     224           0 :         pSdrView->SetAngleSnapEnabled(rMEvt.IsShift());
     225             : 
     226           0 :         m_pSh->MoveCreate(aPnt);
     227           0 :         bRet = sal_True;
     228             :     }
     229           0 :     else if (pSdrView->IsAction() || pSdrView->IsInsObjPoint() || pSdrView->IsMarkPoints())
     230             :     {
     231           0 :         m_pSh->MoveMark(aPnt);
     232           0 :         bRet = sal_True;
     233             :     }
     234             : 
     235           0 :     return (bRet);
     236             : }
     237             : 
     238           0 : sal_Bool SwDrawBase::MouseButtonUp(const MouseEvent& rMEvt)
     239             : {
     240           0 :     sal_Bool bReturn = sal_False;
     241           0 :     bool bCheckShell = false;
     242           0 :     bool bAutoCap = false;
     243             : 
     244           0 :     Point aPnt(m_pWin->PixelToLogic(rMEvt.GetPosPixel()));
     245             : 
     246           0 :     if (IsCreateObj() && m_pSh->IsDrawCreate() && !m_pWin->IsDrawSelMode())
     247             :     {
     248           0 :         const SdrObjKind nDrawMode = m_pWin->GetSdrDrawMode();
     249             :         //objects with multiple point may end at the start position
     250           0 :         bool bMultiPoint = OBJ_PLIN == nDrawMode ||
     251           0 :                                 OBJ_PATHLINE == nDrawMode ||
     252           0 :                                 OBJ_FREELINE == nDrawMode;
     253           0 :         if(rMEvt.IsRight() || (aPnt == m_aStartPos && !bMultiPoint))
     254             :         {
     255           0 :             m_pSh->BreakCreate();
     256           0 :             m_pView->LeaveDrawCreate();
     257             :         }
     258             :         else
     259             :         {
     260           0 :             if (OBJ_NONE == nDrawMode)
     261             :             {
     262           0 :                 SwRewriter aRewriter;
     263             : 
     264           0 :                 aRewriter.AddRule(UndoArg1, SW_RES(STR_FRAME));
     265           0 :                 m_pSh->StartUndo(UNDO_INSERT, &aRewriter);
     266             :             }
     267             : 
     268           0 :             m_pSh->EndCreate(SDRCREATE_FORCEEND);
     269           0 :             if (OBJ_NONE == nDrawMode)   // Text border inserted
     270             :             {
     271             :                uno::Reference< frame::XDispatchRecorder > xRecorder =
     272           0 :                     m_pSh->GetView().GetViewFrame()->GetBindings().GetRecorder();
     273           0 :                 if ( xRecorder.is() )
     274             :                 {
     275           0 :                     SfxRequest aReq(m_pSh->GetView().GetViewFrame(),FN_INSERT_FRAME);
     276             :                         aReq.AppendItem(SfxUInt16Item( FN_INSERT_FRAME,
     277           0 :                                 static_cast<sal_uInt16>(FLY_AT_PARA) ));
     278           0 :                         aReq.AppendItem(SfxPointItem( FN_PARAM_1, m_pSh->GetAnchorObjDiff()));
     279           0 :                         aReq.AppendItem(SvxSizeItem( FN_PARAM_2, m_pSh->GetObjSize()));
     280           0 :                     aReq.Done();
     281             :                 }
     282           0 :                 bAutoCap = true;
     283           0 :                 if(m_pWin->GetFrmColCount() > 1)
     284             :                 {
     285           0 :                     SfxItemSet aSet(m_pView->GetPool(),RES_COL,RES_COL);
     286           0 :                     SwFmtCol aCol((const SwFmtCol&)aSet.Get(RES_COL));
     287           0 :                     aCol.Init(m_pWin->GetFrmColCount(), aCol.GetGutterWidth(), aCol.GetWishWidth());
     288           0 :                     aSet.Put(aCol);
     289             :                     // Template AutoUpdate
     290           0 :                     SwFrmFmt* pFmt = m_pSh->GetCurFrmFmt();
     291           0 :                     if(pFmt && pFmt->IsAutoUpdateFmt())
     292           0 :                         m_pSh->AutoUpdateFrame(pFmt, aSet);
     293             :                     else
     294           0 :                         m_pSh->SetFlyFrmAttr( aSet );
     295           0 :                 }
     296             :             }
     297           0 :             if (m_pWin->GetSdrDrawMode() == OBJ_NONE)
     298             :             {
     299           0 :                 m_pSh->EndUndo();
     300             :             }
     301             :         }
     302             : 
     303           0 :         bReturn = sal_True;
     304             : 
     305           0 :         EnterSelectMode(rMEvt);
     306             :     }
     307             :     else
     308             :     {
     309           0 :         SdrView *pSdrView = m_pSh->GetDrawView();
     310             : 
     311           0 :         if (!pSdrView->HasMarkablePoints())
     312             :         {
     313             :             // NO BEZIER_EDITOR
     314           0 :             if ((m_pSh->GetDrawView()->IsMarkObj() || m_pSh->GetDrawView()->IsMarkPoints())
     315           0 :                  && rMEvt.IsLeft())
     316             :             {
     317           0 :                 bReturn = m_pSh->EndMark();
     318             : 
     319           0 :                 m_pWin->SetDrawAction(sal_False);
     320             : 
     321           0 :                 if (aPnt == m_aStartPos && m_pSh->IsObjSelectable(aPnt))
     322             :                 {
     323           0 :                     m_pSh->SelectObj(aPnt, ( rMEvt.IsShift() &&
     324           0 :                                    m_pSh->IsSelFrmMode()) ? SW_ADD_SELECT : 0);
     325             : 
     326           0 :                     if (!m_pSh->IsObjSelected())
     327             :                     {
     328           0 :                         m_pView->LeaveDrawCreate();    // Switch to selection mode
     329             : 
     330           0 :                         m_pSh->GetView().GetViewFrame()->GetBindings().Invalidate(SID_INSERT_DRAW);
     331             : 
     332           0 :                         if (m_pSh->IsSelFrmMode())
     333           0 :                             m_pSh->LeaveSelFrmMode();
     334             :                     }
     335           0 :                     m_pView->NoRotate();
     336             : 
     337           0 :                     bCheckShell = true; // if necessary turn on BezierShell
     338             :                 }
     339           0 :                 else if (!m_pSh->IsObjSelected() && !m_pWin->IsDrawAction())
     340             :                 {
     341           0 :                     if (m_pSh->IsObjSelectable(aPnt))
     342           0 :                         m_pSh->SelectObj(aPnt, ( rMEvt.IsShift() &&
     343           0 :                             m_pSh->IsSelFrmMode() ) ? SW_ADD_SELECT : 0 );
     344             :                     else
     345             :                     {
     346           0 :                         m_pView->LeaveDrawCreate();
     347           0 :                         if (m_pSh->IsSelFrmMode())
     348           0 :                             m_pSh->LeaveSelFrmMode();
     349             :                     }
     350           0 :                     m_pView->NoRotate();
     351             : 
     352           0 :                     bReturn = sal_True;
     353             :                 }
     354             :             }
     355             :         }
     356             :         else
     357             :         {
     358             :             // BEZIER_EDITOR
     359           0 :             if ( pSdrView->IsAction() )
     360             :             {
     361           0 :                 if ( pSdrView->IsInsObjPoint() )
     362           0 :                     bReturn = pSdrView->EndInsObjPoint(SDRCREATE_FORCEEND);
     363           0 :                 else if (pSdrView->IsMarkPoints() )
     364           0 :                     bReturn = pSdrView->EndMarkPoints();
     365             :                 else
     366             :                 {
     367           0 :                     pSdrView->EndAction();
     368           0 :                     bReturn = sal_True;
     369             :                 }
     370           0 :                 m_pWin->SetDrawAction(sal_False);
     371             : 
     372           0 :                 if (aPnt == m_aStartPos)
     373             :                 {
     374           0 :                     if (!m_pSh->IsObjSelectable(aPnt))
     375           0 :                         m_pSh->SelectObj(Point(LONG_MAX, LONG_MAX));
     376           0 :                     else if (!bReturn)
     377             :                     {
     378           0 :                         if (!rMEvt.IsShift())
     379           0 :                             pSdrView->UnmarkAllPoints();
     380           0 :                         m_pSh->SelectObj(aPnt, (rMEvt.IsShift() &&
     381           0 :                                        m_pSh->IsSelFrmMode()) ? SW_ADD_SELECT :0);
     382             :                     }
     383             : 
     384           0 :                     if (!m_pSh->IsObjSelected())
     385             :                     {
     386           0 :                         m_pView->LeaveDrawCreate();    // Switch to selection mode
     387             : 
     388           0 :                         m_pSh->GetView().GetViewFrame()->GetBindings().Invalidate(SID_INSERT_DRAW);
     389             : 
     390           0 :                         if (m_pSh->IsSelFrmMode())
     391           0 :                             m_pSh->LeaveSelFrmMode();
     392             :                     }
     393           0 :                     m_pView->NoRotate();
     394             : 
     395           0 :                     bCheckShell = true; // if necessary turn on BezierShell
     396             :                 }
     397             :             }
     398             : 
     399           0 :             SetDrawPointer();
     400             : 
     401           0 :             if (!m_pSh->IsObjSelected() && !m_pWin->IsDrawAction())
     402             :             {
     403           0 :                 m_pView->LeaveDrawCreate();
     404           0 :                 if (m_pSh->IsSelFrmMode())
     405           0 :                     m_pSh->LeaveSelFrmMode();
     406             : 
     407           0 :                 m_pView->NoRotate();
     408           0 :                 bReturn = sal_True;
     409             :             }
     410             :         }
     411             :     }
     412             : 
     413           0 :     if (bCheckShell)
     414           0 :         m_pView->AttrChangedNotify( m_pSh ); // if necessary turn on BezierShell
     415             : 
     416             :     //!!!!!!!!!! Attention suicide !!!!!!!!!!! Everything should be renewed once
     417           0 :     if ( bAutoCap )
     418           0 :         m_pView->AutoCaption(FRAME_CAP);   //Can currently only be FRAME, otherwise convert
     419             :                                            // to enums
     420           0 :     return (bReturn);
     421             : }
     422             : 
     423           0 : void SwDrawBase::Activate(const sal_uInt16 nSlot)
     424             : {
     425           0 :     SetSlotId(nSlot);
     426           0 :     SdrView *pSdrView = m_pSh->GetDrawView();
     427             : 
     428           0 :     pSdrView->SetCurrentObj( static_cast< sal_uInt16 >(m_pWin->GetSdrDrawMode()) );
     429           0 :     pSdrView->SetEditMode(false);
     430             : 
     431           0 :     SetDrawPointer();
     432           0 :     m_pSh->NoEdit();
     433           0 : }
     434             : 
     435           0 : void SwDrawBase::Deactivate()
     436             : {
     437           0 :     SdrView *pSdrView = m_pSh->GetDrawView();
     438           0 :     pSdrView->SetOrtho(false);
     439           0 :     pSdrView->SetAngleSnapEnabled(false);
     440             : 
     441           0 :     if (m_pWin->IsDrawAction() && m_pSh->IsDrawCreate())
     442           0 :         m_pSh->BreakCreate();
     443             : 
     444           0 :     m_pWin->SetDrawAction(sal_False);
     445             : 
     446           0 :     m_pWin->ReleaseMouse();
     447           0 :     bNoInterrupt = false;
     448             : 
     449           0 :     if(m_pWin->GetApplyTemplate())
     450           0 :         m_pWin->SetApplyTemplate(SwApplyTemplate());
     451           0 :     m_pSh->GetView().GetViewFrame()->GetBindings().Invalidate(SID_INSERT_DRAW);
     452           0 : }
     453             : 
     454             : // Process keyboard events
     455             : 
     456             : // If a KeyEvent is processed then the return value is sal_True, otherwise
     457             : // Sal_False.
     458             : 
     459           0 : sal_Bool SwDrawBase::KeyInput(const KeyEvent& rKEvt)
     460             : {
     461           0 :     sal_Bool bReturn = sal_False;
     462           0 :     sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode();
     463             : 
     464           0 :     switch (nCode)
     465             :     {
     466             :         case KEY_ESCAPE:
     467             :         {
     468           0 :             if (m_pWin->IsDrawAction())
     469             :             {
     470           0 :                 BreakCreate();
     471           0 :                 m_pView->LeaveDrawCreate();
     472             :             }
     473             : 
     474           0 :             bReturn = sal_True;
     475             :         }
     476           0 :         break;
     477             : 
     478             :         case KEY_DELETE:
     479             :         {
     480           0 :             m_pSh->DelSelectedObj();
     481           0 :             bReturn = sal_True;
     482             :         }
     483           0 :         break;
     484             : 
     485             :         case KEY_UP:
     486             :         case KEY_DOWN:
     487             :         case KEY_LEFT:
     488             :         case KEY_RIGHT:
     489             :         {
     490           0 :             SdrView *pSdrView = m_pSh->GetDrawView();
     491             : 
     492           0 :             if (!pSdrView->IsTextEdit())
     493             :             {
     494           0 :                 long nX = 0;
     495           0 :                 long nY = 0;
     496             : 
     497           0 :                 if (nCode == KEY_UP)
     498             :                 {
     499             :                     // Scroll to top
     500           0 :                     nX = 0;
     501           0 :                     nY =-1;
     502             :                 }
     503           0 :                 else if (nCode == KEY_DOWN)
     504             :                 {
     505             :                     // Scroll down
     506           0 :                     nX = 0;
     507           0 :                     nY = 1;
     508             :                 }
     509           0 :                 else if (nCode == KEY_LEFT)
     510             :                 {
     511             :                     // Scroll left
     512           0 :                     nX =-1;
     513           0 :                     nY = 0;
     514             :                 }
     515           0 :                 else if (nCode == KEY_RIGHT)
     516             :                 {
     517             :                     // Scroll right
     518           0 :                     nX = 1;
     519           0 :                     nY = 0;
     520             :                 }
     521             : 
     522           0 :                 if (pSdrView->AreObjectsMarked() && rKEvt.GetKeyCode().IsMod2())
     523             :                 {
     524             :                     // Move objects
     525           0 :                     nX *= 100;
     526           0 :                     nY *= 100;
     527           0 :                     pSdrView->MoveAllMarked(Size(nX, nY));
     528             :                 }
     529             : 
     530           0 :                 bReturn = sal_True;
     531             :             }
     532             :         }
     533           0 :         break;
     534             :     }
     535             : 
     536           0 :     return (bReturn);
     537             : }
     538             : 
     539             : // Process keyboard events
     540             : 
     541             : // If a KeyEvent is processed then the return value is sal_True, otherwise
     542             : // Sal_False.
     543             : 
     544           0 : void SwDrawBase::BreakCreate()
     545             : {
     546           0 :     m_pSh->BreakCreate();
     547           0 :     m_pWin->SetDrawAction(sal_False);
     548           0 :     m_pWin->ReleaseMouse();
     549             : 
     550           0 :     Deactivate();
     551           0 : }
     552             : 
     553           0 : void SwDrawBase::SetDrawPointer()
     554             : {
     555           0 :     SdrView *pSdrView = m_pSh->GetDrawView();
     556           0 :         Point aPnt(m_pWin->OutputToScreenPixel(m_pWin->GetPointerPosPixel()));
     557           0 :     aPnt = m_pWin->PixelToLogic(m_pWin->ScreenToOutputPixel(aPnt));
     558           0 :     const Pointer aPointTyp = pSdrView->GetPreferredPointer(aPnt, m_pSh->GetOut());
     559           0 :     const Pointer aDrawPt(aPointTyp);
     560           0 :     m_pWin->SetPointer(aDrawPt);
     561           0 : }
     562             : 
     563             : // If necessary switch into selection mode
     564             : 
     565           0 : void SwDrawBase::EnterSelectMode(const MouseEvent& rMEvt)
     566             : {
     567           0 :     m_pWin->SetDrawAction(sal_False);
     568             : 
     569           0 :     if (!m_pSh->IsObjSelected() && !m_pWin->IsDrawAction())
     570             :     {
     571           0 :         Point aPnt(m_pWin->PixelToLogic(rMEvt.GetPosPixel()));
     572             : 
     573           0 :         if (m_pSh->IsObjSelectable(aPnt))
     574             :         {
     575           0 :             m_pSh->SelectObj(aPnt);
     576           0 :             if (rMEvt.GetModifier() == KEY_SHIFT || !m_pSh->IsObjSelected())
     577             :             {
     578           0 :                 m_pView->LeaveDrawCreate();    // Switch to selection mode
     579             : 
     580           0 :                 m_pSh->GetView().GetViewFrame()->GetBindings().Invalidate(SID_INSERT_DRAW);
     581             :             }
     582             :         }
     583             :         else
     584             :         {
     585           0 :             m_pView->LeaveDrawCreate();
     586           0 :             if (m_pSh->IsSelFrmMode())
     587           0 :                 m_pSh->LeaveSelFrmMode();
     588             :         }
     589           0 :         m_pView->NoRotate();
     590             :     }
     591           0 : }
     592             : 
     593           0 : void SwDrawBase::CreateDefaultObject()
     594             : {
     595           0 :     Point aStartPos = GetDefaultCenterPos();
     596           0 :     Point aEndPos(aStartPos);
     597           0 :     aStartPos.X() -= 8 * MM50;
     598           0 :     aStartPos.Y() -= 4 * MM50;
     599           0 :     aEndPos.X() += 8 * MM50;
     600           0 :     aEndPos.Y() += 4 * MM50;
     601           0 :     Rectangle aRect(aStartPos, aEndPos);
     602           0 :     m_pSh->CreateDefaultShape( static_cast< sal_uInt16 >(m_pWin->GetSdrDrawMode()), aRect, m_nSlotId);
     603           0 : }
     604             : 
     605           0 : Point  SwDrawBase::GetDefaultCenterPos()
     606             : {
     607           0 :     Size aDocSz(m_pSh->GetDocSize());
     608           0 :     const SwRect& rVisArea = m_pSh->VisArea();
     609           0 :     Point aStartPos = rVisArea.Center();
     610           0 :     if(rVisArea.Width() > aDocSz.Width())
     611           0 :         aStartPos.X() = aDocSz.Width() / 2 + rVisArea.Left();
     612           0 :     if(rVisArea.Height() > aDocSz.Height())
     613           0 :         aStartPos.Y() = aDocSz.Height() / 2 + rVisArea.Top();
     614           0 :     return aStartPos;
     615             : }
     616             : 
     617             : // #i33136#
     618           0 : bool SwDrawBase::doConstructOrthogonal() const
     619             : {
     620           0 :     return false;
     621             : }
     622             : 
     623             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10