LCOV - code coverage report
Current view: top level - libreoffice/sw/source/ui/uiview - scroll.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 52 53 98.1 %
Date: 2012-12-17 Functions: 9 9 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : 
      21             : #include "swtypes.hxx"
      22             : #include "swrect.hxx"
      23             : #include "scroll.hxx"
      24             : 
      25             : #define SCROLL_LINE_SIZE 250
      26             : 
      27             : 
      28         956 : SwScrollbar::SwScrollbar( Window *pWin, sal_Bool bHoriz ) :
      29             :     ScrollBar( pWin,
      30             :     WinBits( WB_3DLOOK | WB_HIDE | ( bHoriz ? WB_HSCROLL : WB_VSCROLL)  ) ),
      31             :     bHori( bHoriz ),
      32             :     bAuto( sal_False ),
      33             :     bVisible(sal_False),
      34         956 :     bSizeSet(sal_False)
      35             : {
      36             :     // SSA: --- RTL --- no mirroring for horizontal scrollbars
      37         956 :     if( bHoriz )
      38         478 :         EnableRTL( sal_False );
      39         956 : }
      40             : 
      41             : 
      42         288 :  SwScrollbar::~SwScrollbar() {}
      43             : 
      44             : /*------------------------------------------------------------------------
      45             :  Beschreibung:  wird nach einer Aenderung der Dokumentgroesse gerufen, um den
      46             :                 Range des Scrollbars neu einzustellen.
      47             : ------------------------------------------------------------------------*/
      48             : 
      49        5616 : void SwScrollbar::DocSzChgd( const Size &rSize )
      50             : {
      51        5616 :     aDocSz = rSize;
      52        5616 :     SetRange( Range( 0, bHori ? rSize.Width() : rSize.Height()) );
      53        5616 :     const sal_uLong nVisSize = GetVisibleSize();
      54        5616 :     SetLineSize( SCROLL_LINE_SIZE );
      55        5616 :     SetPageSize( nVisSize * 77 / 100 );
      56        5616 : }
      57             : 
      58             : /*------------------------------------------------------------------------
      59             :  Beschreibung:  wird nach einer Veraenderung des sichtbaren Ausschnittes
      60             :                 gerufen.
      61             : ------------------------------------------------------------------------*/
      62             : 
      63             : 
      64        2808 : void SwScrollbar::ViewPortChgd( const Rectangle &rRect )
      65             : {
      66             :     long nThumb, nVisible;
      67        2808 :     if( bHori )
      68             :     {
      69        1404 :         nThumb = rRect.Left();
      70        1404 :         nVisible = rRect.GetWidth();
      71             :     }
      72             :     else
      73             :     {
      74        1404 :         nThumb = rRect.Top();
      75        1404 :         nVisible = rRect.GetHeight();
      76             :     }
      77             : 
      78        2808 :     SetVisibleSize( nVisible );
      79        2808 :     DocSzChgd(aDocSz);
      80        2808 :     SetThumbPos( nThumb );
      81        2808 :     if(bAuto)
      82        2708 :         AutoShow();
      83        2808 : }
      84             : 
      85        3470 : void SwScrollbar::ExtendedShow( sal_Bool bSet )
      86             : {
      87        3470 :     bVisible = bSet;
      88        3470 :     if( (!bSet ||  !bAuto) && IsUpdateMode() && bSizeSet)
      89          16 :         ScrollBar::Show(bSet);
      90        3470 : }
      91             : 
      92        2542 : void SwScrollbar::SetPosSizePixel( const Point& rNewPos, const Size& rNewSize )
      93             : {
      94        2542 :     ScrollBar::SetPosSizePixel(rNewPos, rNewSize);
      95        2542 :     bSizeSet = sal_True;
      96        2542 :     if(bVisible)
      97        1744 :         ExtendedShow();
      98             : 
      99        2542 : }
     100             : 
     101        3008 : void SwScrollbar::SetAuto(sal_Bool bSet)
     102             : {
     103        3008 :     if(bAuto != bSet)
     104             :     {
     105         760 :         bAuto = bSet;
     106             : 
     107             :         // automatisch versteckt - dann anzeigen
     108         760 :         if(!bAuto && bVisible && !ScrollBar::IsVisible())
     109           0 :             ExtendedShow(sal_True);
     110         760 :         else if(bAuto)
     111         760 :             AutoShow(); // oder automatisch verstecken
     112             :     }
     113        3008 : }
     114             : 
     115        3468 : void SwScrollbar::AutoShow()
     116             : {
     117        3468 :     long nVis = GetVisibleSize();
     118        3468 :     long nLen = GetRange().Len();
     119        3468 :         if( nVis >= nLen - 1)
     120             :         {
     121          80 :             if(ScrollBar::IsVisible())
     122          22 :                 ScrollBar::Show(sal_False);
     123             :         }
     124        3388 :         else if ( !ScrollBar::IsVisible() )
     125             :         {
     126         760 :             ScrollBar::Show(sal_True);
     127             :         }
     128        3468 : }
     129             : 
     130             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10