LCOV - code coverage report
Current view: top level - svx/source/dialog - graphctl.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 374 0.0 %
Date: 2014-04-11 Functions: 0 25 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 <svl/itempool.hxx>
      21             : #include <vcl/dialog.hxx>
      22             : #include <vcl/wrkwin.hxx>
      23             : #include <vcl/settings.hxx>
      24             : #include <unotools/syslocale.hxx>
      25             : #include <rtl/math.hxx>
      26             : #include <unotools/localedatawrapper.hxx>
      27             : #include <comphelper/processfactory.hxx>
      28             : #include <vcl/svapp.hxx>
      29             : #include <osl/mutex.hxx>
      30             : 
      31             : #include <svx/graphctl.hxx>
      32             : #include "GraphCtlAccessibleContext.hxx"
      33             : #include "svx/xoutbmp.hxx"
      34             : #include <svx/svxids.hrc>
      35             : #include <svx/svdpage.hxx>
      36             : 
      37             : // #i72889#
      38             : #include "svx/sdrpaintwindow.hxx"
      39             : 
      40           0 : void GraphCtrlUserCall::Changed( const SdrObject& rObj, SdrUserCallType eType, const Rectangle& /*rOldBoundRect*/ )
      41             : {
      42           0 :     switch( eType )
      43             :     {
      44             :         case( SDRUSERCALL_MOVEONLY ):
      45             :         case( SDRUSERCALL_RESIZE ):
      46           0 :             rWin.SdrObjChanged( rObj );
      47           0 :         break;
      48             : 
      49             :         case( SDRUSERCALL_INSERTED ):
      50           0 :             rWin.SdrObjCreated( rObj );
      51           0 :         break;
      52             : 
      53             :         default:
      54           0 :         break;
      55             :     }
      56           0 : }
      57             : 
      58           0 : GraphCtrl::GraphCtrl( Window* pParent, const ResId& rResId ) :
      59             :             Control         ( pParent, rResId ),
      60             :             aMap100         ( MAP_100TH_MM ),
      61             :             nWinStyle       ( 0 ),
      62             :             eObjKind        ( OBJ_NONE ),
      63             :             nPolyEdit       ( 0 ),
      64             :             bEditMode       ( false ),
      65             :             bSdrMode        ( false ),
      66             :             bAnim           ( false ),
      67             :             mpAccContext    ( NULL ),
      68             :             pModel          ( NULL ),
      69           0 :             pView           ( NULL )
      70             : {
      71           0 :     pUserCall = new GraphCtrlUserCall( *this );
      72           0 :     aUpdateTimer.SetTimeout( 500 );
      73           0 :     aUpdateTimer.SetTimeoutHdl( LINK( this, GraphCtrl, UpdateHdl ) );
      74           0 :     aUpdateTimer.Start();
      75           0 :     EnableRTL( false );
      76           0 : }
      77             : 
      78           0 : GraphCtrl::GraphCtrl( Window* pParent, WinBits nStyle ) :
      79             :             Control         ( pParent, nStyle ),
      80             :             aMap100         ( MAP_100TH_MM ),
      81             :             nWinStyle       ( 0 ),
      82             :             eObjKind        ( OBJ_NONE ),
      83             :             nPolyEdit       ( 0 ),
      84             :             bEditMode       ( false ),
      85             :             bSdrMode        ( false ),
      86             :             bAnim           ( false ),
      87             :             mpAccContext    ( NULL ),
      88             :             pModel          ( NULL ),
      89           0 :             pView           ( NULL )
      90             : {
      91           0 :     pUserCall = new GraphCtrlUserCall( *this );
      92           0 :     aUpdateTimer.SetTimeout( 500 );
      93           0 :     aUpdateTimer.SetTimeoutHdl( LINK( this, GraphCtrl, UpdateHdl ) );
      94           0 :     aUpdateTimer.Start();
      95           0 :     EnableRTL( false );
      96           0 : }
      97             : 
      98           0 : extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeGraphCtrl(Window *pParent, VclBuilder::stringmap &rMap)
      99             : {
     100           0 :     WinBits nWinStyle = 0;
     101           0 :     OString sBorder = VclBuilder::extractCustomProperty(rMap);
     102           0 :     if (!sBorder.isEmpty())
     103           0 :         nWinStyle |= WB_BORDER;
     104           0 :     return new GraphCtrl(pParent, nWinStyle);
     105             : }
     106             : 
     107           0 : GraphCtrl::~GraphCtrl()
     108             : {
     109           0 :     if( mpAccContext )
     110             :     {
     111           0 :         mpAccContext->disposing();
     112           0 :         mpAccContext->release();
     113             :     }
     114           0 :     delete pView;
     115           0 :     delete pModel;
     116           0 :     delete pUserCall;
     117           0 : }
     118             : 
     119           0 : void GraphCtrl::SetWinStyle( WinBits nWinBits )
     120             : {
     121           0 :     nWinStyle = nWinBits;
     122           0 :     bAnim = ( nWinStyle & WB_ANIMATION ) == WB_ANIMATION;
     123           0 :     bSdrMode = ( nWinStyle & WB_SDRMODE ) == WB_SDRMODE;
     124             : 
     125           0 :     const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
     126           0 :     SetBackground( Wallpaper( rStyleSettings.GetWindowColor() ) );
     127           0 :     SetMapMode( aMap100 );
     128             : 
     129           0 :     delete pView;
     130           0 :     pView = NULL;
     131             : 
     132           0 :     delete pModel;
     133           0 :     pModel = NULL;
     134             : 
     135           0 :     if ( bSdrMode )
     136           0 :         InitSdrModel();
     137           0 : }
     138             : 
     139           0 : void GraphCtrl::InitSdrModel()
     140             : {
     141           0 :     SolarMutexGuard aGuard;
     142             : 
     143             :     SdrPage* pPage;
     144             : 
     145             :     // destroy old junk
     146           0 :     delete pView;
     147           0 :     delete pModel;
     148             : 
     149             :     // Creating a Model
     150           0 :     pModel = new SdrModel;
     151           0 :     pModel->GetItemPool().FreezeIdRanges();
     152           0 :     pModel->SetScaleUnit( aMap100.GetMapUnit() );
     153           0 :     pModel->SetScaleFraction( Fraction( 1, 1 ) );
     154           0 :     pModel->SetDefaultFontHeight( 500 );
     155             : 
     156           0 :     pPage = new SdrPage( *pModel );
     157             : 
     158           0 :     pPage->SetSize( aGraphSize );
     159           0 :     pPage->SetBorder( 0, 0, 0, 0 );
     160           0 :     pModel->InsertPage( pPage );
     161           0 :     pModel->SetChanged( false );
     162             : 
     163             :     // Creating a View
     164           0 :     pView = new GraphCtrlView( pModel, this );
     165           0 :     pView->SetWorkArea( Rectangle( Point(), aGraphSize ) );
     166           0 :     pView->EnableExtendedMouseEventDispatcher( true );
     167           0 :     pView->ShowSdrPage(pView->GetModel()->GetPage(0));
     168           0 :     pView->SetFrameDragSingles( true );
     169           0 :     pView->SetMarkedPointsSmooth( SDRPATHSMOOTH_SYMMETRIC );
     170           0 :     pView->SetEditMode( true );
     171             : 
     172             :     // #i72889# set neeeded flags
     173           0 :     pView->SetPagePaintingAllowed(false);
     174           0 :     pView->SetBufferedOutputAllowed(true);
     175           0 :     pView->SetBufferedOverlayAllowed(true);
     176             : 
     177             :     // Tell the accessibility object about the changes.
     178           0 :     if (mpAccContext != NULL)
     179           0 :         mpAccContext->setModelAndView (pModel, pView);
     180           0 : }
     181             : 
     182           0 : void GraphCtrl::SetGraphic( const Graphic& rGraphic, bool bNewModel )
     183             : {
     184             :     // If possible we dither bitmaps for the display
     185           0 :     if ( !bAnim && ( rGraphic.GetType() == GRAPHIC_BITMAP )  )
     186             :     {
     187           0 :         if ( rGraphic.IsTransparent() )
     188             :         {
     189           0 :             Bitmap  aBmp( rGraphic.GetBitmap() );
     190             : 
     191           0 :             DitherBitmap( aBmp );
     192           0 :             aGraphic = Graphic( BitmapEx( aBmp, rGraphic.GetBitmapEx().GetMask() ) );
     193             :         }
     194             :         else
     195             :         {
     196           0 :             Bitmap aBmp( rGraphic.GetBitmap() );
     197           0 :             DitherBitmap( aBmp );
     198           0 :             aGraphic = aBmp;
     199             :         }
     200             :     }
     201             :     else
     202           0 :         aGraphic = rGraphic;
     203             : 
     204           0 :     if ( aGraphic.GetPrefMapMode().GetMapUnit() == MAP_PIXEL )
     205           0 :         aGraphSize = Application::GetDefaultDevice()->PixelToLogic( aGraphic.GetPrefSize(), aMap100 );
     206             :     else
     207           0 :         aGraphSize = OutputDevice::LogicToLogic( aGraphic.GetPrefSize(), aGraphic.GetPrefMapMode(), aMap100 );
     208             : 
     209           0 :     if ( bSdrMode && bNewModel )
     210           0 :         InitSdrModel();
     211             : 
     212           0 :     if ( aGraphSizeLink.IsSet() )
     213           0 :         aGraphSizeLink.Call( this );
     214             : 
     215           0 :     Resize();
     216           0 :     Invalidate();
     217           0 : }
     218             : 
     219           0 : void GraphCtrl::Resize()
     220             : {
     221           0 :     Control::Resize();
     222             : 
     223           0 :     if ( aGraphSize.Width() && aGraphSize.Height() )
     224             :     {
     225           0 :         MapMode         aDisplayMap( aMap100 );
     226           0 :         Point           aNewPos;
     227           0 :         Size            aNewSize;
     228           0 :         const Size      aWinSize = PixelToLogic( GetOutputSizePixel(), aDisplayMap );
     229           0 :         const long      nWidth = aWinSize.Width();
     230           0 :         const long      nHeight = aWinSize.Height();
     231           0 :         double          fGrfWH = (double) aGraphSize.Width() / aGraphSize.Height();
     232           0 :         double          fWinWH = (double) nWidth / nHeight;
     233             : 
     234             :         // Adapt Bitmap to Thumb size
     235           0 :         if ( fGrfWH < fWinWH)
     236             :         {
     237           0 :             aNewSize.Width() = (long) ( (double) nHeight * fGrfWH );
     238           0 :             aNewSize.Height()= nHeight;
     239             :         }
     240             :         else
     241             :         {
     242           0 :             aNewSize.Width() = nWidth;
     243           0 :             aNewSize.Height()= (long) ( (double) nWidth / fGrfWH );
     244             :         }
     245             : 
     246           0 :         aNewPos.X() = ( nWidth - aNewSize.Width() )  >> 1;
     247           0 :         aNewPos.Y() = ( nHeight - aNewSize.Height() ) >> 1;
     248             : 
     249             :         // Implementing MapMode for Engine
     250           0 :         aDisplayMap.SetScaleX( Fraction( aNewSize.Width(), aGraphSize.Width() ) );
     251           0 :         aDisplayMap.SetScaleY( Fraction( aNewSize.Height(), aGraphSize.Height() ) );
     252             : 
     253           0 :         aDisplayMap.SetOrigin( LogicToLogic( aNewPos, aMap100, aDisplayMap ) );
     254           0 :         SetMapMode( aDisplayMap );
     255             :     }
     256             : 
     257           0 :     Invalidate();
     258           0 : }
     259             : 
     260           0 : void GraphCtrl::Paint( const Rectangle& rRect )
     261             : {
     262             :     // #i72889# used splitted repaint to be able to paint an own background
     263             :     // even to the buffered view
     264           0 :     const bool bGraphicValid(GRAPHIC_NONE != aGraphic.GetType());
     265             : 
     266           0 :     if(bSdrMode)
     267             :     {
     268           0 :         SdrPaintWindow* pPaintWindow = pView->BeginCompleteRedraw(this);
     269             : 
     270           0 :         if(bGraphicValid)
     271             :         {
     272           0 :             OutputDevice& rTarget = pPaintWindow->GetTargetOutputDevice();
     273             : 
     274           0 :             rTarget.SetBackground(GetBackground());
     275           0 :             rTarget.Erase();
     276             : 
     277           0 :             aGraphic.Draw(&rTarget, Point(), aGraphSize);
     278             :         }
     279             : 
     280           0 :         const Region aRepaintRegion(rRect);
     281           0 :         pView->DoCompleteRedraw(*pPaintWindow, aRepaintRegion);
     282           0 :         pView->EndCompleteRedraw(*pPaintWindow, true);
     283             :     }
     284             :     else
     285             :     {
     286             :         // #i73381# in non-SdrMode, paint to local directly
     287           0 :         if(bGraphicValid)
     288             :         {
     289           0 :             aGraphic.Draw(this, Point(), aGraphSize);
     290             :         }
     291             :     }
     292           0 : }
     293             : 
     294           0 : void GraphCtrl::SdrObjChanged( const SdrObject&  )
     295             : {
     296           0 : }
     297             : 
     298           0 : void GraphCtrl::SdrObjCreated( const SdrObject& )
     299             : {
     300           0 : }
     301             : 
     302           0 : void GraphCtrl::MarkListHasChanged()
     303             : {
     304           0 :     if ( aMarkObjLink.IsSet() )
     305           0 :         aMarkObjLink.Call( this );
     306           0 : }
     307             : 
     308           0 : void GraphCtrl::KeyInput( const KeyEvent& rKEvt )
     309             : {
     310           0 :     KeyCode aCode( rKEvt.GetKeyCode() );
     311           0 :     bool    bProc = false;
     312             : 
     313           0 :     Dialog* pDialog = GetParentDialog();
     314             : 
     315           0 :     switch ( aCode.GetCode() )
     316             :     {
     317             :         case KEY_DELETE:
     318             :         case KEY_BACKSPACE:
     319             :         {
     320           0 :             if ( bSdrMode )
     321             :             {
     322           0 :                 pView->DeleteMarked();
     323           0 :                 bProc = true;
     324           0 :                 if (!pView->AreObjectsMarked() && pDialog)
     325           0 :                     pDialog->GrabFocusToFirstControl();
     326             :             }
     327             :         }
     328           0 :         break;
     329             : 
     330             :         case KEY_ESCAPE:
     331             :         {
     332           0 :             if ( bSdrMode )
     333             :             {
     334           0 :                 bool bGrabFocusToFirstControl = true;
     335           0 :                 if ( pView->IsAction() )
     336             :                 {
     337           0 :                     pView->BrkAction();
     338           0 :                     bGrabFocusToFirstControl = false;
     339             :                 }
     340           0 :                 else if ( pView->AreObjectsMarked() )
     341             :                 {
     342           0 :                     const SdrHdlList& rHdlList = pView->GetHdlList();
     343           0 :                     SdrHdl* pHdl = rHdlList.GetFocusHdl();
     344             : 
     345           0 :                     if(pHdl)
     346             :                     {
     347           0 :                         ((SdrHdlList&)rHdlList).ResetFocusHdl();
     348           0 :                         bGrabFocusToFirstControl = false;
     349             :                     }
     350             :                 }
     351           0 :                 if (bGrabFocusToFirstControl && pDialog)
     352           0 :                     pDialog->GrabFocusToFirstControl();
     353           0 :                 bProc = true;
     354             :             }
     355             :         }
     356           0 :         break;
     357             : 
     358             :         case KEY_F11:
     359             :         case KEY_TAB:
     360             :         {
     361           0 :             if( bSdrMode )
     362             :             {
     363           0 :                 if( !aCode.IsMod1() && !aCode.IsMod2() )
     364             :                 {
     365           0 :                     bool bForward = !aCode.IsShift();
     366             :                     // select next object
     367           0 :                     if ( ! pView->MarkNextObj( bForward ))
     368             :                     {
     369             :                         // At first or last object.  Cycle to the other end
     370             :                         // of the list.
     371           0 :                         pView->UnmarkAllObj();
     372           0 :                         pView->MarkNextObj (bForward);
     373             :                     }
     374           0 :                     bProc = true;
     375             :                 }
     376           0 :                 else if(aCode.IsMod1())
     377             :                 {
     378             :                     // select next handle
     379           0 :                     const SdrHdlList& rHdlList = pView->GetHdlList();
     380           0 :                     sal_Bool bForward(!aCode.IsShift());
     381             : 
     382           0 :                     ((SdrHdlList&)rHdlList).TravelFocusHdl(bForward);
     383             : 
     384           0 :                     bProc = true;
     385             :                 }
     386             :             }
     387             :         }
     388           0 :         break;
     389             : 
     390             :         case KEY_END:
     391             :         {
     392             : 
     393           0 :             if ( aCode.IsMod1() )
     394             :             {
     395             :                 // mark last object
     396           0 :                 pView->UnmarkAllObj();
     397           0 :                 pView->MarkNextObj(false);
     398             : 
     399           0 :                 bProc = true;
     400             :             }
     401             :         }
     402           0 :         break;
     403             : 
     404             :         case KEY_HOME:
     405             :         {
     406           0 :             if ( aCode.IsMod1() )
     407             :             {
     408           0 :                 pView->UnmarkAllObj();
     409           0 :                 pView->MarkNextObj(true);
     410             : 
     411           0 :                 bProc = true;
     412             :             }
     413             :         }
     414           0 :         break;
     415             : 
     416             :         case KEY_UP:
     417             :         case KEY_DOWN:
     418             :         case KEY_LEFT:
     419             :         case KEY_RIGHT:
     420             :         {
     421           0 :             long nX = 0;
     422           0 :             long nY = 0;
     423             : 
     424           0 :             if (aCode.GetCode() == KEY_UP)
     425             :             {
     426             :                 // Scroll up
     427           0 :                 nX = 0;
     428           0 :                 nY =-1;
     429             :             }
     430           0 :             else if (aCode.GetCode() == KEY_DOWN)
     431             :             {
     432             :                 // Scroll down
     433           0 :                 nX = 0;
     434           0 :                 nY = 1;
     435             :             }
     436           0 :             else if (aCode.GetCode() == KEY_LEFT)
     437             :             {
     438             :                 // Scroll left
     439           0 :                 nX =-1;
     440           0 :                 nY = 0;
     441             :             }
     442           0 :             else if (aCode.GetCode() == KEY_RIGHT)
     443             :             {
     444             :                 // Scroll right
     445           0 :                 nX = 1;
     446           0 :                 nY = 0;
     447             :             }
     448             : 
     449           0 :             if (pView->AreObjectsMarked() && !aCode.IsMod1() )
     450             :             {
     451           0 :                 if(aCode.IsMod2())
     452             :                 {
     453             :                     // move in 1 pixel distance
     454           0 :                     Size aLogicSizeOnePixel = PixelToLogic(Size(1,1));
     455           0 :                     nX *= aLogicSizeOnePixel.Width();
     456           0 :                     nY *= aLogicSizeOnePixel.Height();
     457             :                 }
     458             :                 else
     459             :                 {
     460             :                     // old, fixed move distance
     461           0 :                     nX *= 100;
     462           0 :                     nY *= 100;
     463             :                 }
     464             : 
     465             :                 // II
     466           0 :                 const SdrHdlList& rHdlList = pView->GetHdlList();
     467           0 :                 SdrHdl* pHdl = rHdlList.GetFocusHdl();
     468             : 
     469           0 :                 if(0L == pHdl)
     470             :                 {
     471             :                     // restrict movement to WorkArea
     472           0 :                     const Rectangle& rWorkArea = pView->GetWorkArea();
     473             : 
     474           0 :                     if(!rWorkArea.IsEmpty())
     475             :                     {
     476           0 :                         Rectangle aMarkRect(pView->GetMarkedObjRect());
     477           0 :                         aMarkRect.Move(nX, nY);
     478             : 
     479           0 :                         if(!aMarkRect.IsInside(rWorkArea))
     480             :                         {
     481           0 :                             if(aMarkRect.Left() < rWorkArea.Left())
     482             :                             {
     483           0 :                                 nX += rWorkArea.Left() - aMarkRect.Left();
     484             :                             }
     485             : 
     486           0 :                             if(aMarkRect.Right() > rWorkArea.Right())
     487             :                             {
     488           0 :                                 nX -= aMarkRect.Right() - rWorkArea.Right();
     489             :                             }
     490             : 
     491           0 :                             if(aMarkRect.Top() < rWorkArea.Top())
     492             :                             {
     493           0 :                                 nY += rWorkArea.Top() - aMarkRect.Top();
     494             :                             }
     495             : 
     496           0 :                             if(aMarkRect.Bottom() > rWorkArea.Bottom())
     497             :                             {
     498           0 :                                 nY -= aMarkRect.Bottom() - rWorkArea.Bottom();
     499             :                             }
     500             :                         }
     501             :                     }
     502             : 
     503             :                     // no handle selected
     504           0 :                     if(0 != nX || 0 != nY)
     505             :                     {
     506           0 :                         pView->MoveAllMarked(Size(nX, nY));
     507             :                     }
     508             :                 }
     509             :                 else
     510             :                 {
     511             :                     // move handle with index nHandleIndex
     512           0 :                     if(pHdl && (nX || nY))
     513             :                     {
     514             :                         // now move the Handle (nX, nY)
     515           0 :                         Point aStartPoint(pHdl->GetPos());
     516           0 :                         Point aEndPoint(pHdl->GetPos() + Point(nX, nY));
     517           0 :                         const SdrDragStat& rDragStat = pView->GetDragStat();
     518             : 
     519             :                         // start dragging
     520           0 :                         pView->BegDragObj(aStartPoint, 0, pHdl, 0);
     521             : 
     522           0 :                         if(pView->IsDragObj())
     523             :                         {
     524           0 :                             bool bWasNoSnap = rDragStat.IsNoSnap();
     525           0 :                             sal_Bool bWasSnapEnabled = pView->IsSnapEnabled();
     526             : 
     527             :                             // switch snapping off
     528           0 :                             if(!bWasNoSnap)
     529           0 :                                 ((SdrDragStat&)rDragStat).SetNoSnap(true);
     530           0 :                             if(bWasSnapEnabled)
     531           0 :                                 pView->SetSnapEnabled(false);
     532             : 
     533           0 :                             pView->MovAction(aEndPoint);
     534           0 :                             pView->EndDragObj();
     535             : 
     536             :                             // restore snap
     537           0 :                             if(!bWasNoSnap)
     538           0 :                                 ((SdrDragStat&)rDragStat).SetNoSnap(bWasNoSnap);
     539           0 :                             if(bWasSnapEnabled)
     540           0 :                                 pView->SetSnapEnabled(bWasSnapEnabled);
     541             :                         }
     542             :                     }
     543             :                 }
     544             : 
     545           0 :                 bProc = true;
     546             :             }
     547             :         }
     548           0 :         break;
     549             : 
     550             :         case KEY_SPACE:
     551             :         {
     552           0 :             const SdrHdlList& rHdlList = pView->GetHdlList();
     553           0 :             SdrHdl* pHdl = rHdlList.GetFocusHdl();
     554             : 
     555           0 :             if(pHdl)
     556             :             {
     557           0 :                 if(pHdl->GetKind() == HDL_POLY)
     558             :                 {
     559             :                     // rescue ID of point with focus
     560           0 :                     sal_uInt32 nPol(pHdl->GetPolyNum());
     561           0 :                     sal_uInt32 nPnt(pHdl->GetPointNum());
     562             : 
     563           0 :                     if(pView->IsPointMarked(*pHdl))
     564             :                     {
     565           0 :                         if(rKEvt.GetKeyCode().IsShift())
     566             :                         {
     567           0 :                             pView->UnmarkPoint(*pHdl);
     568             :                         }
     569             :                     }
     570             :                     else
     571             :                     {
     572           0 :                         if(!rKEvt.GetKeyCode().IsShift())
     573             :                         {
     574           0 :                             pView->UnmarkAllPoints();
     575             :                         }
     576             : 
     577           0 :                         pView->MarkPoint(*pHdl);
     578             :                     }
     579             : 
     580           0 :                     if(0L == rHdlList.GetFocusHdl())
     581             :                     {
     582             :                         // restore point with focus
     583           0 :                         SdrHdl* pNewOne = 0L;
     584             : 
     585           0 :                         for(sal_uInt32 a(0); !pNewOne && a < rHdlList.GetHdlCount(); a++)
     586             :                         {
     587           0 :                             SdrHdl* pAct = rHdlList.GetHdl(a);
     588             : 
     589           0 :                             if(pAct
     590           0 :                                 && pAct->GetKind() == HDL_POLY
     591           0 :                                 && pAct->GetPolyNum() == nPol
     592           0 :                                 && pAct->GetPointNum() == nPnt)
     593             :                             {
     594           0 :                                 pNewOne = pAct;
     595             :                             }
     596             :                         }
     597             : 
     598           0 :                         if(pNewOne)
     599             :                         {
     600           0 :                             ((SdrHdlList&)rHdlList).SetFocusHdl(pNewOne);
     601             :                         }
     602             :                     }
     603             : 
     604           0 :                     bProc = true;
     605             :                 }
     606             :             }
     607             :         }
     608           0 :         break;
     609             : 
     610             :         default:
     611           0 :         break;
     612             :     }
     613             : 
     614           0 :     if ( !bProc )
     615           0 :         Control::KeyInput( rKEvt );
     616             :     else
     617           0 :         ReleaseMouse();
     618           0 : }
     619             : 
     620           0 : void GraphCtrl::MouseButtonDown( const MouseEvent& rMEvt )
     621             : {
     622           0 :     if ( bSdrMode && ( rMEvt.GetClicks() < 2 ) )
     623             :     {
     624           0 :         const Point aLogPt( PixelToLogic( rMEvt.GetPosPixel() ) );
     625             : 
     626           0 :         if ( !Rectangle( Point(), aGraphSize ).IsInside( aLogPt ) && !pView->IsEditMode() )
     627           0 :             Control::MouseButtonDown( rMEvt );
     628             :         else
     629             :         {
     630             :             // Get Focus for key inputs
     631           0 :             GrabFocus();
     632             : 
     633           0 :             if ( nPolyEdit )
     634             :             {
     635           0 :                 SdrViewEvent    aVEvt;
     636           0 :                 SdrHitKind      eHit = pView->PickAnything( rMEvt, SDRMOUSEBUTTONDOWN, aVEvt );
     637             : 
     638           0 :                 if ( nPolyEdit == SID_BEZIER_INSERT && eHit == SDRHIT_MARKEDOBJECT )
     639           0 :                     pView->BegInsObjPoint( aLogPt, rMEvt.IsMod1());
     640             :                 else
     641           0 :                     pView->MouseButtonDown( rMEvt, this );
     642             :             }
     643             :             else
     644           0 :                 pView->MouseButtonDown( rMEvt, this );
     645             :         }
     646             : 
     647           0 :         SdrObject* pCreateObj = pView->GetCreateObj();
     648             : 
     649             :         // We want to realize the insert
     650           0 :         if ( pCreateObj && !pCreateObj->GetUserCall() )
     651           0 :             pCreateObj->SetUserCall( pUserCall );
     652             : 
     653           0 :         SetPointer( pView->GetPreferredPointer( aLogPt, this ) );
     654             :     }
     655             :     else
     656           0 :         Control::MouseButtonDown( rMEvt );
     657           0 : }
     658             : 
     659           0 : void GraphCtrl::MouseMove(const MouseEvent& rMEvt)
     660             : {
     661           0 :     const Point aLogPos( PixelToLogic( rMEvt.GetPosPixel() ) );
     662             : 
     663           0 :     if ( bSdrMode )
     664             :     {
     665           0 :         pView->MouseMove( rMEvt, this );
     666             : 
     667           0 :         if( ( SID_BEZIER_INSERT == nPolyEdit ) &&
     668           0 :             !pView->PickHandle( aLogPos ) &&
     669           0 :             !pView->IsInsObjPoint() )
     670             :         {
     671           0 :             SetPointer( POINTER_CROSS );
     672             :         }
     673             :         else
     674           0 :             SetPointer( pView->GetPreferredPointer( aLogPos, this ) );
     675             :     }
     676             :     else
     677           0 :         Control::MouseButtonUp( rMEvt );
     678             : 
     679           0 :     if ( aMousePosLink.IsSet() )
     680             :     {
     681           0 :         if ( Rectangle( Point(), aGraphSize ).IsInside( aLogPos ) )
     682           0 :             aMousePos = aLogPos;
     683             :         else
     684           0 :             aMousePos = Point();
     685             : 
     686           0 :         aMousePosLink.Call( this );
     687             :     }
     688           0 : }
     689             : 
     690           0 : void GraphCtrl::MouseButtonUp(const MouseEvent& rMEvt)
     691             : {
     692           0 :     if ( bSdrMode )
     693             :     {
     694           0 :         if ( pView->IsInsObjPoint() )
     695           0 :             pView->EndInsObjPoint( SDRCREATE_FORCEEND );
     696             :         else
     697           0 :             pView->MouseButtonUp( rMEvt, this );
     698             : 
     699           0 :         ReleaseMouse();
     700           0 :         SetPointer( pView->GetPreferredPointer( PixelToLogic( rMEvt.GetPosPixel() ), this ) );
     701             :     }
     702             :     else
     703           0 :         Control::MouseButtonUp( rMEvt );
     704           0 : }
     705             : 
     706           0 : SdrObject* GraphCtrl::GetSelectedSdrObject() const
     707             : {
     708           0 :     SdrObject* pSdrObj = NULL;
     709             : 
     710           0 :     if ( bSdrMode )
     711             :     {
     712           0 :         const SdrMarkList&  rMarkList = pView->GetMarkedObjectList();
     713             : 
     714           0 :         if ( rMarkList.GetMarkCount() == 1 )
     715           0 :             pSdrObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
     716             :     }
     717             : 
     718           0 :     return pSdrObj;
     719             : }
     720             : 
     721           0 : void GraphCtrl::SetEditMode( const bool _bEditMode )
     722             : {
     723           0 :     if ( bSdrMode )
     724             :     {
     725           0 :         bEditMode = _bEditMode;
     726           0 :         pView->SetEditMode( bEditMode );
     727           0 :         eObjKind = OBJ_NONE;
     728           0 :         pView->SetCurrentObj( sal::static_int_cast< sal_uInt16 >( eObjKind ) );
     729             :     }
     730             :     else
     731           0 :         bEditMode = false;
     732           0 : }
     733             : 
     734           0 : void GraphCtrl::SetPolyEditMode( const sal_uInt16 _nPolyEdit )
     735             : {
     736           0 :     if ( bSdrMode && ( _nPolyEdit != nPolyEdit ) )
     737             :     {
     738           0 :         nPolyEdit = _nPolyEdit;
     739           0 :         pView->SetFrameDragSingles( nPolyEdit == 0 );
     740             :     }
     741             :     else
     742           0 :         nPolyEdit = 0;
     743           0 : }
     744             : 
     745           0 : void GraphCtrl::SetObjKind( const SdrObjKind _eObjKind )
     746             : {
     747           0 :     if ( bSdrMode )
     748             :     {
     749           0 :         bEditMode = false;
     750           0 :         pView->SetEditMode( bEditMode );
     751           0 :         eObjKind = _eObjKind;
     752           0 :         pView->SetCurrentObj( sal::static_int_cast< sal_uInt16 >( eObjKind ) );
     753             :     }
     754             :     else
     755           0 :         eObjKind = OBJ_NONE;
     756           0 : }
     757             : 
     758           0 : IMPL_LINK( GraphCtrl, UpdateHdl, Timer*, pTimer )
     759             : {
     760           0 :     if ( aUpdateLink.IsSet() )
     761           0 :         aUpdateLink.Call( this );
     762             : 
     763           0 :     pTimer->Start();
     764             : 
     765           0 :     return 0L;
     766             : }
     767             : 
     768             : 
     769           0 : ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > GraphCtrl::CreateAccessible()
     770             : {
     771           0 :     if( mpAccContext == NULL )
     772             :     {
     773           0 :         Window* pParent = GetParent();
     774             : 
     775             :         DBG_ASSERT( pParent, "-GraphCtrl::CreateAccessible(): No Parent!" );
     776             : 
     777           0 :         if( pParent )
     778             :         {
     779           0 :             ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > xAccParent( pParent->GetAccessible() );
     780             : 
     781             :             // Disable accessibility if no model/view data available
     782           0 :             if( pView &&
     783           0 :                 pModel &&
     784           0 :                 xAccParent.is() )
     785             :             {
     786           0 :                 mpAccContext = new SvxGraphCtrlAccessibleContext( xAccParent, *this );
     787           0 :                 mpAccContext->acquire();
     788           0 :             }
     789             :         }
     790             :     }
     791             : 
     792           0 :     return mpAccContext;
     793             : }
     794             : 
     795             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10