LCOV - code coverage report
Current view: top level - sw/source/ui/uiview - scroll.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 52 53 98.1 %
Date: 2012-08-25 Functions: 9 9 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 39 46 84.8 %

           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                 :            : 
      30                 :            : #include "swtypes.hxx"
      31                 :            : #include "swrect.hxx"
      32                 :            : #include "scroll.hxx"
      33                 :            : 
      34                 :            : #define SCROLL_LINE_SIZE 250
      35                 :            : 
      36                 :            : 
      37                 :       2636 : SwScrollbar::SwScrollbar( Window *pWin, sal_Bool bHoriz ) :
      38                 :            :     ScrollBar( pWin,
      39                 :            :     WinBits( WB_3DLOOK | WB_HIDE | ( bHoriz ? WB_HSCROLL : WB_VSCROLL)  ) ),
      40                 :            :     bHori( bHoriz ),
      41                 :            :     bAuto( sal_False ),
      42                 :            :     bVisible(sal_False),
      43         [ +  + ]:       2636 :     bSizeSet(sal_False)
      44                 :            : {
      45                 :            :     // SSA: --- RTL --- no mirroring for horizontal scrollbars
      46         [ +  + ]:       2636 :     if( bHoriz )
      47         [ +  - ]:       1318 :         EnableRTL( sal_False );
      48                 :       2636 : }
      49                 :            : 
      50                 :            : 
      51         [ -  + ]:       4924 :  SwScrollbar::~SwScrollbar() {}
      52                 :            : 
      53                 :            : /*------------------------------------------------------------------------
      54                 :            :  Beschreibung:  wird nach einer Aenderung der Dokumentgroesse gerufen, um den
      55                 :            :                 Range des Scrollbars neu einzustellen.
      56                 :            : ------------------------------------------------------------------------*/
      57                 :            : 
      58                 :      12360 : void SwScrollbar::DocSzChgd( const Size &rSize )
      59                 :            : {
      60                 :      12360 :     aDocSz = rSize;
      61 [ +  + ][ +  - ]:      12360 :     SetRange( Range( 0, bHori ? rSize.Width() : rSize.Height()) );
      62                 :      12360 :     const sal_uLong nVisSize = GetVisibleSize();
      63                 :      12360 :     SetLineSize( SCROLL_LINE_SIZE );
      64                 :      12360 :     SetPageSize( nVisSize * 77 / 100 );
      65                 :      12360 : }
      66                 :            : 
      67                 :            : /*------------------------------------------------------------------------
      68                 :            :  Beschreibung:  wird nach einer Veraenderung des sichtbaren Ausschnittes
      69                 :            :                 gerufen.
      70                 :            : ------------------------------------------------------------------------*/
      71                 :            : 
      72                 :            : 
      73                 :       6180 : void SwScrollbar::ViewPortChgd( const Rectangle &rRect )
      74                 :            : {
      75                 :            :     long nThumb, nVisible;
      76         [ +  + ]:       6180 :     if( bHori )
      77                 :            :     {
      78                 :       3090 :         nThumb = rRect.Left();
      79                 :       3090 :         nVisible = rRect.GetWidth();
      80                 :            :     }
      81                 :            :     else
      82                 :            :     {
      83                 :       3090 :         nThumb = rRect.Top();
      84                 :       3090 :         nVisible = rRect.GetHeight();
      85                 :            :     }
      86                 :            : 
      87                 :       6180 :     SetVisibleSize( nVisible );
      88                 :       6180 :     DocSzChgd(aDocSz);
      89                 :       6180 :     SetThumbPos( nThumb );
      90         [ +  + ]:       6180 :     if(bAuto)
      91                 :       6133 :         AutoShow();
      92                 :       6180 : }
      93                 :            : 
      94                 :      10571 : void SwScrollbar::ExtendedShow( sal_Bool bSet )
      95                 :            : {
      96                 :      10571 :     bVisible = bSet;
      97 [ +  + ][ +  + ]:      10571 :     if( (!bSet ||  !bAuto) && IsUpdateMode() && bSizeSet)
         [ +  - ][ +  + ]
                 [ +  + ]
      98                 :         69 :         ScrollBar::Show(bSet);
      99                 :      10571 : }
     100                 :            : 
     101                 :       5746 : void SwScrollbar::SetPosSizePixel( const Point& rNewPos, const Size& rNewSize )
     102                 :            : {
     103                 :       5746 :     ScrollBar::SetPosSizePixel(rNewPos, rNewSize);
     104                 :       5746 :     bSizeSet = sal_True;
     105         [ +  + ]:       5746 :     if(bVisible)
     106                 :       5239 :         ExtendedShow();
     107                 :            : 
     108                 :       5746 : }
     109                 :            : 
     110                 :       9682 : void SwScrollbar::SetAuto(sal_Bool bSet)
     111                 :            : {
     112         [ +  + ]:       9682 :     if(bAuto != bSet)
     113                 :            :     {
     114                 :       5238 :         bAuto = bSet;
     115                 :            : 
     116                 :            :         // automatisch versteckt - dann anzeigen
     117 [ +  + ][ +  - ]:       5238 :         if(!bAuto && bVisible && !ScrollBar::IsVisible())
         [ -  + ][ -  + ]
     118                 :          0 :             ExtendedShow(sal_True);
     119         [ +  + ]:       5238 :         else if(bAuto)
     120                 :       3924 :             AutoShow(); // oder automatisch verstecken
     121                 :            :     }
     122                 :       9682 : }
     123                 :            : 
     124                 :      10057 : void SwScrollbar::AutoShow()
     125                 :            : {
     126                 :      10057 :     long nVis = GetVisibleSize();
     127                 :      10057 :     long nLen = GetRange().Len();
     128         [ +  + ]:      10057 :         if( nVis >= nLen - 1)
     129                 :            :         {
     130         [ +  + ]:        297 :             if(ScrollBar::IsVisible())
     131                 :         66 :                 ScrollBar::Show(sal_False);
     132                 :            :         }
     133         [ +  + ]:       9760 :         else if ( !ScrollBar::IsVisible() )
     134                 :            :         {
     135                 :       2668 :             ScrollBar::Show(sal_True);
     136                 :            :         }
     137                 :      10057 : }
     138                 :            : 
     139                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10