LCOV - code coverage report
Current view: top level - svx/source/dialog - graphctl.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 355 0.0 %
Date: 2012-08-25 Functions: 0 23 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 573 0.0 %

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

Generated by: LCOV version 1.10