LCOV - code coverage report
Current view: top level - sw/source/uibase/uiview - scroll.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 52 53 98.1 %
Date: 2015-06-13 12:38:46 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             : #include "swtypes.hxx"
      21             : #include "swrect.hxx"
      22             : #include "scroll.hxx"
      23             : 
      24             : #define SCROLL_LINE_SIZE 250
      25             : 
      26        5522 : 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        5522 :     bSizeSet(false)
      33             : {
      34             :     // SSA: --- RTL --- no mirroring for horizontal scrollbars
      35        5522 :     if( bHoriz )
      36        2761 :         EnableRTL( false );
      37        5522 : }
      38             : 
      39       11028 :  SwScrollbar::~SwScrollbar() {}
      40             : 
      41             : // Will be called after a change of the document size
      42             : // to refresh the range of the scrollbars.
      43             : 
      44       61748 : void SwScrollbar::DocSzChgd( const Size &rSize )
      45             : {
      46       61748 :     aDocSz = rSize;
      47       61748 :     SetRange( Range( 0, bHori ? rSize.Width() : rSize.Height()) );
      48       61748 :     const sal_uLong nVisSize = GetVisibleSize();
      49       61748 :     SetLineSize( SCROLL_LINE_SIZE );
      50       61748 :     SetPageSize( nVisSize * 77 / 100 );
      51       61748 : }
      52             : 
      53             : // Will be called after a change of the visible view section.
      54             : 
      55       30874 : void SwScrollbar::ViewPortChgd( const Rectangle &rRect )
      56             : {
      57             :     long nThumb, nVisible;
      58       30874 :     if( bHori )
      59             :     {
      60       15437 :         nThumb = rRect.Left();
      61       15437 :         nVisible = rRect.GetWidth();
      62             :     }
      63             :     else
      64             :     {
      65       15437 :         nThumb = rRect.Top();
      66       15437 :         nVisible = rRect.GetHeight();
      67             :     }
      68             : 
      69       30874 :     SetVisibleSize( nVisible );
      70       30874 :     DocSzChgd(aDocSz);
      71       30874 :     SetThumbPos( nThumb );
      72       30874 :     if(bAuto)
      73       30799 :         AutoShow();
      74       30874 : }
      75             : 
      76       32757 : void SwScrollbar::ExtendedShow( bool bSet )
      77             : {
      78       32757 :     bVisible = bSet;
      79       32757 :     if( (!bSet ||  !bAuto) && IsUpdateMode() && bSizeSet)
      80         211 :         ScrollBar::Show(bSet);
      81       32757 : }
      82             : 
      83       27714 : void SwScrollbar::SetPosSizePixel( const Point& rNewPos, const Size& rNewSize )
      84             : {
      85       27714 :     ScrollBar::SetPosSizePixel(rNewPos, rNewSize);
      86       27714 :     bSizeSet = true;
      87       27714 :     if(bVisible)
      88       21699 :         ExtendedShow();
      89             : 
      90       27714 : }
      91             : 
      92       30419 : void SwScrollbar::SetAuto(bool bSet)
      93             : {
      94       30419 :     if(bAuto != bSet)
      95             :     {
      96        5342 :         bAuto = bSet;
      97             : 
      98             :         // hide autmatically - automatisch versteckt - then show
      99        5342 :         if(!bAuto && bVisible && !ScrollBar::IsVisible())
     100           0 :             ExtendedShow(true);
     101        5342 :         else if(bAuto)
     102        5337 :             AutoShow(); // or hide automatically
     103             :     }
     104       30419 : }
     105             : 
     106       36136 : void SwScrollbar::AutoShow()
     107             : {
     108       36136 :     long nVis = GetVisibleSize();
     109       36136 :     long nLen = GetRange().Len();
     110       36136 :         if( nVis >= nLen - 1)
     111             :         {
     112         886 :             if(ScrollBar::IsVisible())
     113         237 :                 ScrollBar::Show(false);
     114             :         }
     115       35250 :         else if ( !ScrollBar::IsVisible() )
     116             :         {
     117        5358 :             ScrollBar::Show(true);
     118             :         }
     119       36136 : }
     120             : 
     121             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11