LCOV - code coverage report
Current view: top level - sw/source/uibase/uiview - scroll.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 52 53 98.1 %
Date: 2014-11-03 Functions: 11 11 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             : #include "swtypes.hxx"
      21             : #include "swrect.hxx"
      22             : #include "scroll.hxx"
      23             : 
      24             : #define SCROLL_LINE_SIZE 250
      25             : 
      26        9416 : SwScrollbar::SwScrollbar( vcl::Window *pWin, bool bHoriz ) :
      27             :     ScrollBar( pWin,
      28             :     WinBits( WB_3DLOOK | WB_HIDE | ( bHoriz ? WB_HSCROLL : WB_VSCROLL)  ) ),
      29             :     bHori( bHoriz ),
      30             :     bAuto( false ),
      31             :     bVisible(false),
      32        9416 :     bSizeSet(false)
      33             : {
      34             :     // SSA: --- RTL --- no mirroring for horizontal scrollbars
      35        9416 :     if( bHoriz )
      36        4708 :         EnableRTL( false );
      37        9416 : }
      38             : 
      39       18824 :  SwScrollbar::~SwScrollbar() {}
      40             : 
      41             : // Will be called after a change of the document size
      42             : // to refresh the range of the scrollbars.
      43             : 
      44      105840 : void SwScrollbar::DocSzChgd( const Size &rSize )
      45             : {
      46      105840 :     aDocSz = rSize;
      47      105840 :     SetRange( Range( 0, bHori ? rSize.Width() : rSize.Height()) );
      48      105840 :     const sal_uLong nVisSize = GetVisibleSize();
      49      105840 :     SetLineSize( SCROLL_LINE_SIZE );
      50      105840 :     SetPageSize( nVisSize * 77 / 100 );
      51      105840 : }
      52             : 
      53             : // Will be called after a change of the visible view section.
      54             : 
      55       52920 : void SwScrollbar::ViewPortChgd( const Rectangle &rRect )
      56             : {
      57             :     long nThumb, nVisible;
      58       52920 :     if( bHori )
      59             :     {
      60       26460 :         nThumb = rRect.Left();
      61       26460 :         nVisible = rRect.GetWidth();
      62             :     }
      63             :     else
      64             :     {
      65       26460 :         nThumb = rRect.Top();
      66       26460 :         nVisible = rRect.GetHeight();
      67             :     }
      68             : 
      69       52920 :     SetVisibleSize( nVisible );
      70       52920 :     DocSzChgd(aDocSz);
      71       52920 :     SetThumbPos( nThumb );
      72       52920 :     if(bAuto)
      73       52778 :         AutoShow();
      74       52920 : }
      75             : 
      76       54790 : void SwScrollbar::ExtendedShow( bool bSet )
      77             : {
      78       54790 :     bVisible = bSet;
      79       54790 :     if( (!bSet ||  !bAuto) && IsUpdateMode() && bSizeSet)
      80         148 :         ScrollBar::Show(bSet);
      81       54790 : }
      82             : 
      83       46224 : void SwScrollbar::SetPosSizePixel( const Point& rNewPos, const Size& rNewSize )
      84             : {
      85       46224 :     ScrollBar::SetPosSizePixel(rNewPos, rNewSize);
      86       46224 :     bSizeSet = true;
      87       46224 :     if(bVisible)
      88       35948 :         ExtendedShow();
      89             : 
      90       46224 : }
      91             : 
      92       50888 : void SwScrollbar::SetAuto(bool bSet)
      93             : {
      94       50888 :     if(bAuto != bSet)
      95             :     {
      96        9304 :         bAuto = bSet;
      97             : 
      98             :         // hide autmatically - automatisch versteckt - then show
      99        9304 :         if(!bAuto && bVisible && !ScrollBar::IsVisible())
     100           0 :             ExtendedShow(true);
     101        9304 :         else if(bAuto)
     102        9294 :             AutoShow(); // or hide automatically
     103             :     }
     104       50888 : }
     105             : 
     106       62072 : void SwScrollbar::AutoShow()
     107             : {
     108       62072 :     long nVis = GetVisibleSize();
     109       62072 :     long nLen = GetRange().Len();
     110       62072 :         if( nVis >= nLen - 1)
     111             :         {
     112         662 :             if(ScrollBar::IsVisible())
     113         172 :                 ScrollBar::Show(false);
     114             :         }
     115       61410 :         else if ( !ScrollBar::IsVisible() )
     116             :         {
     117        9316 :             ScrollBar::Show(true);
     118             :         }
     119       62342 : }
     120             : 
     121             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10