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

Generated by: LCOV version 1.10