LCOV - code coverage report
Current view: top level - svx/source/stbctrls - zoomsliderctrl.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 93 186 50.0 %
Date: 2012-08-25 Functions: 10 13 76.9 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 77 272 28.3 %

           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 <svx/zoomsliderctrl.hxx>
      30                 :            : #include <vcl/status.hxx>
      31                 :            : #include <vcl/menu.hxx>
      32                 :            : #include <vcl/image.hxx>
      33                 :            : #include <vcl/svapp.hxx>
      34                 :            : #include <svx/zoomslideritem.hxx>
      35                 :            : #include <svx/dialmgr.hxx>
      36                 :            : #include <svx/dialogs.hrc>
      37                 :            : 
      38                 :            : #include <basegfx/tools/zoomtools.hxx>
      39                 :            : 
      40                 :            : #include <set>
      41                 :            : 
      42                 :            : // -----------------------------------------------------------------------
      43                 :            : 
      44         [ +  - ]:       1258 : SFX_IMPL_STATUSBAR_CONTROL( SvxZoomSliderControl, SvxZoomSliderItem );
      45                 :            : 
      46                 :            : // -----------------------------------------------------------------------
      47                 :            : 
      48 [ +  - ][ +  - ]:       1109 : struct SvxZoomSliderControl::SvxZoomSliderControl_Impl
                 [ +  - ]
      49                 :            : {
      50                 :            :     sal_uInt16                   mnCurrentZoom;
      51                 :            :     sal_uInt16                   mnMinZoom;
      52                 :            :     sal_uInt16                   mnMaxZoom;
      53                 :            :     sal_uInt16                   mnSliderCenter;
      54                 :            :     std::vector< long >      maSnappingPointOffsets;
      55                 :            :     std::vector< sal_uInt16 >    maSnappingPointZooms;
      56                 :            :     Image                    maSliderButton;
      57                 :            :     Image                    maIncreaseButton;
      58                 :            :     Image                    maDecreaseButton;
      59                 :            :     bool                     mbValuesSet;
      60                 :            :     bool                     mbOmitPaint;
      61                 :            : 
      62                 :       1109 :     SvxZoomSliderControl_Impl() :
      63                 :            :         mnCurrentZoom( 0 ),
      64                 :            :         mnMinZoom( 0 ),
      65                 :            :         mnMaxZoom( 0 ),
      66                 :            :         mnSliderCenter( 0 ),
      67                 :            :         maSnappingPointOffsets(),
      68                 :            :         maSnappingPointZooms(),
      69                 :            :         maSliderButton(),
      70                 :            :         maIncreaseButton(),
      71                 :            :         maDecreaseButton(),
      72                 :            :         mbValuesSet( false ),
      73 [ +  - ][ +  - ]:       1109 :         mbOmitPaint( false ) {}
         [ +  - ][ +  - ]
      74                 :            : };
      75                 :            : 
      76                 :            : // -----------------------------------------------------------------------
      77                 :            : 
      78                 :            : const long nButtonWidth   = 10;
      79                 :            : const long nButtonHeight  = 10;
      80                 :            : const long nIncDecWidth   = 10;
      81                 :            : const long nIncDecHeight  = 10;
      82                 :            : const long nSliderHeight  = 2;
      83                 :            : const long nSnappingHeight = 4;
      84                 :            : const long nSliderXOffset = 20;
      85                 :            : const long nSnappingEpsilon = 5; // snapping epsilon in pixels
      86                 :            : const long nSnappingPointsMinDist = nSnappingEpsilon; // minimum distance of two adjacent snapping points
      87                 :            : 
      88                 :            : // -----------------------------------------------------------------------
      89                 :            : 
      90                 :            : // nOffset referes to the origin of the control:
      91                 :            : // + ----------- -
      92                 :          0 : sal_uInt16 SvxZoomSliderControl::Offset2Zoom( long nOffset ) const
      93                 :            : {
      94 [ #  # ][ #  # ]:          0 :     const long nControlWidth = getControlRect().GetWidth();
      95                 :          0 :     sal_uInt16 nRet = 0;
      96                 :            : 
      97         [ #  # ]:          0 :     if ( nOffset < nSliderXOffset )
      98                 :          0 :         return mpImpl->mnMinZoom;
      99                 :            : 
     100         [ #  # ]:          0 :     if ( nOffset > nControlWidth - nSliderXOffset )
     101                 :          0 :         return mpImpl->mnMaxZoom;
     102                 :            : 
     103                 :            :     // check for snapping points:
     104                 :          0 :     sal_uInt16 nCount = 0;
     105                 :          0 :     std::vector< long >::iterator aSnappingPointIter;
     106   [ #  #  #  # ]:          0 :     for ( aSnappingPointIter = mpImpl->maSnappingPointOffsets.begin();
                 [ #  # ]
     107                 :          0 :           aSnappingPointIter != mpImpl->maSnappingPointOffsets.end();
     108                 :            :           ++aSnappingPointIter )
     109                 :            :     {
     110         [ #  # ]:          0 :         const long nCurrent = *aSnappingPointIter;
     111         [ #  # ]:          0 :         if ( Abs(nCurrent - nOffset) < nSnappingEpsilon )
     112                 :            :         {
     113                 :          0 :             nOffset = nCurrent;
     114         [ #  # ]:          0 :             nRet = mpImpl->maSnappingPointZooms[ nCount ];
     115                 :          0 :             break;
     116                 :            :         }
     117                 :          0 :         ++nCount;
     118                 :            :     }
     119                 :            : 
     120         [ #  # ]:          0 :     if ( 0 == nRet )
     121                 :            :     {
     122         [ #  # ]:          0 :         if ( nOffset < nControlWidth / 2 )
     123                 :            :         {
     124                 :            :             // first half of slider
     125                 :          0 :             const long nFirstHalfRange = mpImpl->mnSliderCenter - mpImpl->mnMinZoom;
     126                 :          0 :             const long nHalfSliderWidth = nControlWidth/2 - nSliderXOffset;
     127                 :          0 :             const long nZoomPerSliderPixel = (1000 * nFirstHalfRange) / nHalfSliderWidth;
     128                 :          0 :             const long nOffsetToSliderLeft = nOffset - nSliderXOffset;
     129                 :          0 :             nRet = mpImpl->mnMinZoom + sal_uInt16( nOffsetToSliderLeft * nZoomPerSliderPixel / 1000 );
     130                 :            :         }
     131                 :            :         else
     132                 :            :         {
     133                 :            :             // second half of slider
     134                 :          0 :             const long nSecondHalfRange = mpImpl->mnMaxZoom - mpImpl->mnSliderCenter;
     135                 :          0 :             const long nHalfSliderWidth = nControlWidth/2 - nSliderXOffset;
     136                 :          0 :             const long nZoomPerSliderPixel = 1000 * nSecondHalfRange / nHalfSliderWidth;
     137                 :          0 :             const long nOffsetToSliderCenter = nOffset - nControlWidth/2;
     138                 :          0 :             nRet = mpImpl->mnSliderCenter + sal_uInt16( nOffsetToSliderCenter * nZoomPerSliderPixel / 1000 );
     139                 :            :         }
     140                 :            :     }
     141                 :            : 
     142         [ #  # ]:          0 :     if ( nRet < mpImpl->mnMinZoom )
     143                 :          0 :         nRet = mpImpl->mnMinZoom;
     144         [ #  # ]:          0 :     else if ( nRet > mpImpl->mnMaxZoom )
     145                 :          0 :         nRet = mpImpl->mnMaxZoom;
     146                 :            : 
     147                 :          0 :     return nRet;
     148                 :            : }
     149                 :            : 
     150                 :            : // returns the offset to the left control border
     151                 :       5892 : long SvxZoomSliderControl::Zoom2Offset( sal_uInt16 nCurrentZoom ) const
     152                 :            : {
     153         [ +  - ]:       5892 :     const long nControlWidth = getControlRect().GetWidth();
     154                 :       5892 :     long nRet = nSliderXOffset;
     155                 :            : 
     156                 :       5892 :     const long nHalfSliderWidth = nControlWidth/2 - nSliderXOffset;
     157                 :            : 
     158         [ +  + ]:       5892 :     if ( nCurrentZoom <= mpImpl->mnSliderCenter )
     159                 :            :     {
     160                 :       5839 :         nCurrentZoom = nCurrentZoom - mpImpl->mnMinZoom;
     161                 :       5839 :         const long nFirstHalfRange = mpImpl->mnSliderCenter - mpImpl->mnMinZoom;
     162                 :       5839 :         const long nSliderPixelPerZoomPercent = 1000 * nHalfSliderWidth  / nFirstHalfRange;
     163                 :       5839 :         const long nOffset = (nSliderPixelPerZoomPercent * nCurrentZoom) / 1000;
     164                 :       5839 :         nRet += nOffset;
     165                 :            :     }
     166                 :            :     else
     167                 :            :     {
     168                 :         53 :         nCurrentZoom = nCurrentZoom - mpImpl->mnSliderCenter;
     169                 :         53 :         const long nSecondHalfRange = mpImpl->mnMaxZoom - mpImpl->mnSliderCenter;
     170                 :         53 :         const long nSliderPixelPerZoomPercent = 1000 * nHalfSliderWidth  / nSecondHalfRange;
     171                 :         53 :         const long nOffset = (nSliderPixelPerZoomPercent * nCurrentZoom) / 1000;
     172                 :         53 :         nRet += nHalfSliderWidth + nOffset;
     173                 :            :     }
     174                 :            : 
     175                 :       5892 :     return nRet;
     176                 :            : }
     177                 :            : 
     178                 :            : // -----------------------------------------------------------------------
     179                 :            : 
     180                 :       1109 : SvxZoomSliderControl::SvxZoomSliderControl( sal_uInt16 _nSlotId,  sal_uInt16 _nId, StatusBar& _rStb ) :
     181                 :            :     SfxStatusBarControl( _nSlotId, _nId, _rStb ),
     182 [ +  - ][ +  - ]:       1109 :     mpImpl( new SvxZoomSliderControl_Impl )
     183                 :            : {
     184 [ +  - ][ +  - ]:       1109 :     mpImpl->maSliderButton   = Image( SVX_RES( RID_SVXBMP_SLIDERBUTTON   ) );
         [ +  - ][ +  - ]
     185 [ +  - ][ +  - ]:       1109 :     mpImpl->maIncreaseButton = Image( SVX_RES( RID_SVXBMP_SLIDERINCREASE ) );
         [ +  - ][ +  - ]
     186 [ +  - ][ +  - ]:       1109 :     mpImpl->maDecreaseButton = Image( SVX_RES( RID_SVXBMP_SLIDERDECREASE ) );
         [ +  - ][ +  - ]
     187                 :       1109 : }
     188                 :            : 
     189                 :            : // -----------------------------------------------------------------------
     190                 :            : 
     191                 :       1109 : SvxZoomSliderControl::~SvxZoomSliderControl()
     192                 :            : {
     193 [ +  - ][ +  - ]:       1109 :     delete mpImpl;
     194         [ -  + ]:       2218 : }
     195                 :            : 
     196                 :            : // -----------------------------------------------------------------------
     197                 :            : 
     198                 :       1784 : void SvxZoomSliderControl::StateChanged( sal_uInt16 /*nSID*/, SfxItemState eState, const SfxPoolItem* pState )
     199                 :            : {
     200 [ +  - ][ -  + ]:       1784 :     if ( (SFX_ITEM_AVAILABLE != eState) || pState->ISA( SfxVoidItem ) )
                 [ -  + ]
     201                 :            :     {
     202         [ #  # ]:          0 :         GetStatusBar().SetItemText( GetId(), String() );
     203                 :          0 :         mpImpl->mbValuesSet   = false;
     204                 :            :     }
     205                 :            :     else
     206                 :            :     {
     207                 :            :         OSL_ENSURE( pState->ISA( SvxZoomSliderItem ), "invalid item type: should be a SvxZoomSliderItem" );
     208                 :       1784 :         mpImpl->mnCurrentZoom = static_cast<const SvxZoomSliderItem*>( pState )->GetValue();
     209                 :       1784 :         mpImpl->mnMinZoom     = static_cast<const SvxZoomSliderItem*>( pState )->GetMinZoom();
     210                 :       1784 :         mpImpl->mnMaxZoom     = static_cast<const SvxZoomSliderItem*>( pState )->GetMaxZoom();
     211                 :       1784 :         mpImpl->mnSliderCenter= 100;
     212                 :       1784 :         mpImpl->mbValuesSet   = true;
     213                 :            : 
     214         [ -  + ]:       1784 :         if ( mpImpl->mnSliderCenter == mpImpl->mnMaxZoom )
     215                 :          0 :             mpImpl->mnSliderCenter = mpImpl->mnMinZoom + (sal_uInt16)((mpImpl->mnMaxZoom - mpImpl->mnMinZoom) * 0.5);
     216                 :            : 
     217                 :            : 
     218                 :            :         DBG_ASSERT( mpImpl->mnMinZoom <= mpImpl->mnCurrentZoom &&
     219                 :            :                     mpImpl->mnMinZoom <  mpImpl->mnSliderCenter &&
     220                 :            :                     mpImpl->mnMaxZoom >= mpImpl->mnCurrentZoom &&
     221                 :            :                     mpImpl->mnMaxZoom > mpImpl->mnSliderCenter,
     222                 :            :                     "Looks like the zoom slider item is corrupted" );
     223                 :            : 
     224 [ +  - ][ +  - ]:       1784 :         const com::sun::star::uno::Sequence < sal_Int32 > rSnappingPoints = static_cast<const SvxZoomSliderItem*>( pState )->GetSnappingPoints();
     225                 :       1784 :         mpImpl->maSnappingPointOffsets.clear();
     226                 :       1784 :         mpImpl->maSnappingPointZooms.clear();
     227                 :            : 
     228                 :            :         // get all snapping points:
     229         [ +  - ]:       1784 :         std::set< sal_uInt16 > aTmpSnappingPoints;
     230         [ +  + ]:       6264 :         for ( sal_uInt16 j = 0; j < rSnappingPoints.getLength(); ++j )
     231                 :            :         {
     232                 :       4480 :             const sal_Int32 nSnappingPoint = rSnappingPoints[j];
     233         [ +  - ]:       4480 :             aTmpSnappingPoints.insert( (sal_uInt16)nSnappingPoint );
     234                 :            :         }
     235                 :            : 
     236                 :            :         // remove snapping points that are to close to each other:
     237         [ +  - ]:       1784 :         std::set< sal_uInt16 >::iterator aSnappingPointIter;
     238                 :       1784 :         long nLastOffset = 0;
     239                 :            : 
     240 [ +  - ][ +  - ]:       4995 :         for ( aSnappingPointIter = aTmpSnappingPoints.begin(); aSnappingPointIter != aTmpSnappingPoints.end(); ++aSnappingPointIter )
                 [ +  + ]
     241                 :            :         {
     242         [ +  - ]:       3211 :             const sal_uInt16 nCurrent = *aSnappingPointIter;
     243         [ +  - ]:       3211 :             const long nCurrentOffset = Zoom2Offset( nCurrent );
     244                 :            : 
     245         [ +  + ]:       3211 :             if ( nCurrentOffset - nLastOffset >= nSnappingPointsMinDist )
     246                 :            :             {
     247         [ +  - ]:       2432 :                 mpImpl->maSnappingPointOffsets.push_back( nCurrentOffset );
     248         [ +  - ]:       2432 :                 mpImpl->maSnappingPointZooms.push_back( nCurrent );
     249                 :       2432 :                 nLastOffset = nCurrentOffset;
     250                 :            :             }
     251         [ +  - ]:       1784 :         }
     252                 :            :     }
     253                 :            : 
     254 [ +  - ][ +  - ]:       1784 :     if ( !mpImpl->mbOmitPaint && GetStatusBar().AreItemsVisible() )
                 [ +  - ]
     255                 :       1784 :         GetStatusBar().SetItemData( GetId(), 0 );    // force repaint
     256                 :       1784 : }
     257                 :            : 
     258                 :            : // -----------------------------------------------------------------------
     259                 :            : 
     260                 :       2681 : void SvxZoomSliderControl::Paint( const UserDrawEvent& rUsrEvt )
     261                 :            : {
     262 [ +  - ][ +  - ]:       2681 :     if ( !mpImpl->mbValuesSet || mpImpl->mbOmitPaint )
     263                 :       2681 :         return;
     264                 :            : 
     265         [ +  - ]:       2681 :     const Rectangle     aControlRect = getControlRect();
     266                 :       2681 :     OutputDevice*       pDev =  rUsrEvt.GetDevice();
     267                 :       2681 :     Rectangle           aRect = rUsrEvt.GetRect();
     268                 :       2681 :     Rectangle           aSlider = aRect;
     269                 :            : 
     270         [ +  - ]:       2681 :     aSlider.Top()   += (aControlRect.GetHeight() - nSliderHeight)/2;
     271                 :       2681 :     aSlider.Bottom() = aSlider.Top() + nSliderHeight - 1;
     272                 :       2681 :     aSlider.Left()  += nSliderXOffset;
     273                 :       2681 :     aSlider.Right() -= nSliderXOffset;
     274                 :            : 
     275                 :       2681 :     Color               aOldLineColor = pDev->GetLineColor();
     276                 :       2681 :     Color               aOldFillColor = pDev->GetFillColor();
     277                 :            : 
     278         [ +  - ]:       2681 :     const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
     279         [ +  - ]:       2681 :     pDev->SetLineColor( rStyleSettings.GetShadowColor() );
     280         [ +  - ]:       2681 :     pDev->SetFillColor( rStyleSettings.GetShadowColor() );
     281                 :            : 
     282                 :            :     // draw snapping points:
     283                 :       2681 :     std::vector< long >::iterator aSnappingPointIter;
     284   [ +  -  +  - ]:      13232 :     for ( aSnappingPointIter = mpImpl->maSnappingPointOffsets.begin();
                 [ +  + ]
     285                 :       6616 :           aSnappingPointIter != mpImpl->maSnappingPointOffsets.end();
     286                 :            :           ++aSnappingPointIter )
     287                 :            :     {
     288         [ +  - ]:       3935 :         long nSnapPosX = aRect.Left() + *aSnappingPointIter;
     289                 :            : 
     290                 :       3935 :         pDev->DrawRect( Rectangle( nSnapPosX - 1, aSlider.Top() - nSnappingHeight,
     291 [ +  - ][ +  - ]:       7870 :                     nSnapPosX, aSlider.Bottom() + nSnappingHeight ) );
     292                 :            :     }
     293                 :            : 
     294                 :            :     // draw slider
     295         [ +  - ]:       2681 :     pDev->DrawRect( aSlider );
     296                 :            : 
     297                 :            :     // draw slider button
     298                 :       2681 :     Point aImagePoint = aRect.TopLeft();
     299         [ +  - ]:       2681 :     aImagePoint.X() += Zoom2Offset( mpImpl->mnCurrentZoom );
     300                 :       2681 :     aImagePoint.X() -= nButtonWidth/2;
     301         [ +  - ]:       2681 :     aImagePoint.Y() += (aControlRect.GetHeight() - nButtonHeight)/2;
     302         [ +  - ]:       2681 :     pDev->DrawImage( aImagePoint, mpImpl->maSliderButton );
     303                 :            : 
     304                 :            :     // draw decrease button
     305                 :       2681 :     aImagePoint = aRect.TopLeft();
     306                 :       2681 :     aImagePoint.X() += (nSliderXOffset - nIncDecWidth)/2;
     307         [ +  - ]:       2681 :     aImagePoint.Y() += (aControlRect.GetHeight() - nIncDecHeight)/2;
     308         [ +  - ]:       2681 :     pDev->DrawImage( aImagePoint, mpImpl->maDecreaseButton );
     309                 :            : 
     310                 :            :     // draw increase button
     311         [ +  - ]:       2681 :     aImagePoint.X() = aRect.TopLeft().X() + aControlRect.GetWidth() - nIncDecWidth - (nSliderXOffset - nIncDecWidth)/2;
     312         [ +  - ]:       2681 :     pDev->DrawImage( aImagePoint, mpImpl->maIncreaseButton );
     313                 :            : 
     314         [ +  - ]:       2681 :     pDev->SetLineColor( aOldLineColor );
     315         [ +  - ]:       2681 :     pDev->SetFillColor( aOldFillColor );
     316                 :            : }
     317                 :            : 
     318                 :            : // -----------------------------------------------------------------------
     319                 :            : 
     320                 :          0 : sal_Bool SvxZoomSliderControl::MouseButtonDown( const MouseEvent & rEvt )
     321                 :            : {
     322         [ #  # ]:          0 :     if ( !mpImpl->mbValuesSet )
     323                 :          0 :         return sal_True;
     324                 :            : 
     325         [ #  # ]:          0 :     const Rectangle aControlRect = getControlRect();
     326                 :          0 :     const Point aPoint = rEvt.GetPosPixel();
     327                 :          0 :     const sal_Int32 nXDiff = aPoint.X() - aControlRect.Left();
     328                 :            : 
     329                 :          0 :     const long nButtonLeftOffset = (nSliderXOffset - nIncDecWidth)/2;
     330                 :          0 :     const long nButtonRightOffset = (nSliderXOffset + nIncDecWidth)/2;
     331                 :            : 
     332                 :          0 :     const long nOldZoom = mpImpl->mnCurrentZoom;
     333                 :            : 
     334                 :            :     // click to - button
     335 [ #  # ][ #  # ]:          0 :     if ( nXDiff >= nButtonLeftOffset && nXDiff <= nButtonRightOffset )
     336         [ #  # ]:          0 :         mpImpl->mnCurrentZoom = basegfx::zoomtools::zoomOut( static_cast<int>(mpImpl->mnCurrentZoom) );
     337                 :            :     // click to + button
     338 [ #  # ][ #  # ]:          0 :     else if ( nXDiff >= aControlRect.GetWidth() - nSliderXOffset + nButtonLeftOffset &&
         [ #  # ][ #  # ]
     339         [ #  # ]:          0 :               nXDiff <= aControlRect.GetWidth() - nSliderXOffset + nButtonRightOffset )
     340         [ #  # ]:          0 :         mpImpl->mnCurrentZoom = basegfx::zoomtools::zoomIn( static_cast<int>(mpImpl->mnCurrentZoom) );
     341                 :            :     // click to slider
     342 [ #  # ][ #  # ]:          0 :     else if( nXDiff >= nSliderXOffset && nXDiff <= aControlRect.GetWidth() - nSliderXOffset )
         [ #  # ][ #  # ]
     343         [ #  # ]:          0 :         mpImpl->mnCurrentZoom = Offset2Zoom( nXDiff );
     344                 :            : 
     345         [ #  # ]:          0 :     if ( mpImpl->mnCurrentZoom < mpImpl->mnMinZoom )
     346                 :          0 :         mpImpl->mnCurrentZoom = mpImpl->mnMinZoom;
     347         [ #  # ]:          0 :     else if ( mpImpl->mnCurrentZoom > mpImpl->mnMaxZoom )
     348                 :          0 :         mpImpl->mnCurrentZoom = mpImpl->mnMaxZoom;
     349                 :            : 
     350         [ #  # ]:          0 :     if ( nOldZoom == mpImpl->mnCurrentZoom )
     351                 :          0 :         return sal_True;
     352                 :            : 
     353         [ #  # ]:          0 :     if ( GetStatusBar().AreItemsVisible() )
     354         [ #  # ]:          0 :         GetStatusBar().SetItemData( GetId(), 0 );    // force repaint
     355                 :            : 
     356                 :          0 :     mpImpl->mbOmitPaint = true; // optimization: paint before executing command,
     357                 :            :                                 // then omit painting which is triggered by the execute function
     358                 :            : 
     359         [ #  # ]:          0 :     SvxZoomSliderItem aZoomSliderItem( mpImpl->mnCurrentZoom );
     360                 :            : 
     361                 :          0 :     ::com::sun::star::uno::Any a;
     362         [ #  # ]:          0 :     aZoomSliderItem.QueryValue( a );
     363                 :            : 
     364         [ #  # ]:          0 :     ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aArgs( 1 );
     365 [ #  # ][ #  # ]:          0 :     aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ZoomSlider" ));
     366         [ #  # ]:          0 :     aArgs[0].Value = a;
     367                 :            : 
     368         [ #  # ]:          0 :     execute( aArgs );
     369                 :            : 
     370                 :          0 :     mpImpl->mbOmitPaint = false;
     371                 :            : 
     372 [ #  # ][ #  # ]:          0 :     return sal_True;
     373                 :            : }
     374                 :            : 
     375                 :            : // -----------------------------------------------------------------------
     376                 :            : 
     377                 :          0 : sal_Bool SvxZoomSliderControl::MouseMove( const MouseEvent & rEvt )
     378                 :            : {
     379         [ #  # ]:          0 :     if ( !mpImpl->mbValuesSet )
     380                 :          0 :         return sal_True;
     381                 :            : 
     382                 :          0 :     const short nButtons = rEvt.GetButtons();
     383                 :            : 
     384                 :            :     // check mouse move with button pressed
     385         [ #  # ]:          0 :     if ( 1 == nButtons )
     386                 :            :     {
     387         [ #  # ]:          0 :         const Rectangle aControlRect = getControlRect();
     388                 :          0 :         const Point aPoint = rEvt.GetPosPixel();
     389                 :          0 :         const sal_Int32 nXDiff = aPoint.X() - aControlRect.Left();
     390                 :            : 
     391 [ #  # ][ #  # ]:          0 :         if ( nXDiff >= nSliderXOffset && nXDiff <= aControlRect.GetWidth() - nSliderXOffset )
         [ #  # ][ #  # ]
     392                 :            :         {
     393         [ #  # ]:          0 :             mpImpl->mnCurrentZoom = Offset2Zoom( nXDiff );
     394                 :            : 
     395         [ #  # ]:          0 :             if ( GetStatusBar().AreItemsVisible() )
     396         [ #  # ]:          0 :                 GetStatusBar().SetItemData( GetId(), 0 );    // force repaint
     397                 :            : 
     398                 :          0 :             mpImpl->mbOmitPaint = true; // optimization: paint before executing command,
     399                 :            :                                         // then omit painting which is triggered by the execute function
     400                 :            : 
     401                 :            :             // commit state change
     402         [ #  # ]:          0 :             SvxZoomSliderItem aZoomSliderItem( mpImpl->mnCurrentZoom );
     403                 :            : 
     404                 :          0 :             ::com::sun::star::uno::Any a;
     405         [ #  # ]:          0 :             aZoomSliderItem.QueryValue( a );
     406                 :            : 
     407         [ #  # ]:          0 :             ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aArgs( 1 );
     408 [ #  # ][ #  # ]:          0 :             aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ZoomSlider" ));
     409         [ #  # ]:          0 :             aArgs[0].Value = a;
     410                 :            : 
     411         [ #  # ]:          0 :             execute( aArgs );
     412                 :            : 
     413 [ #  # ][ #  # ]:          0 :             mpImpl->mbOmitPaint = false;
     414                 :            :         }
     415                 :            :     }
     416                 :            : 
     417                 :          0 :     return sal_True;
     418                 :            : }
     419                 :            : 
     420                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10