LCOV - code coverage report
Current view: top level - xmloff/source/core - ProgressBarHelper.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 28 0.0 %
Date: 2014-04-14 Functions: 0 4 0.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 <xmloff/ProgressBarHelper.hxx>
      21             : #include <tools/debug.hxx>
      22             : #include <xmloff/xmltoken.hxx>
      23             : 
      24             : #include <stdlib.h>
      25             : 
      26             : using namespace ::com::sun::star;
      27             : 
      28             : static const sal_Int32 nDefaultProgressBarRange = 1000000;
      29             : 
      30           0 : ProgressBarHelper::ProgressBarHelper(const ::com::sun::star::uno::Reference < ::com::sun::star::task::XStatusIndicator>& xTempStatusIndicator,
      31             :                                     const bool bTempStrict)
      32             : : xStatusIndicator(xTempStatusIndicator)
      33             : , nRange(nDefaultProgressBarRange)
      34             : , nReference(100)
      35             : , nValue(0)
      36             : , bStrict(bTempStrict)
      37           0 : , bRepeat(true)
      38             : #ifdef DBG_UTIL
      39             : , bFailure(false)
      40             : #endif
      41             : {
      42           0 : }
      43             : 
      44           0 : ProgressBarHelper::~ProgressBarHelper()
      45             : {
      46           0 : }
      47             : 
      48           0 : sal_Int32 ProgressBarHelper::ChangeReference(sal_Int32 nNewReference)
      49             : {
      50           0 :     if((nNewReference > 0) && (nNewReference != nReference))
      51             :     {
      52           0 :         if (nReference)
      53             :         {
      54           0 :             double fPercent(nNewReference / nReference);
      55           0 :             double fValue(nValue * fPercent);
      56             : #if OSL_DEBUG_LEVEL > 0
      57             :             // workaround for toolchain bug on solaris/x86 Sun C++ 5.5
      58             :             // just call some function here
      59             :             (void) abs(nValue);
      60             : #endif
      61           0 :             nValue = static_cast< sal_Int32 >(fValue);
      62           0 :             nReference = nNewReference;
      63             :         }
      64             :         else
      65             :         {
      66           0 :             nReference = nNewReference;
      67           0 :             nValue = 0;
      68             :         }
      69             :     }
      70           0 :     return nValue;
      71             : }
      72             : 
      73           0 : void ProgressBarHelper::SetValue(sal_Int32 nTempValue)
      74             : {
      75           0 :     if (xStatusIndicator.is() && (nReference > 0))
      76             :     {
      77           0 :         if ((nTempValue >= nValue) && (!bStrict || (bStrict && (nTempValue <= nReference))))
      78             :         {
      79             :             // #91317# no progress bar with values > 100%
      80           0 :             if (nTempValue > nReference)
      81             :             {
      82           0 :                 if (!bRepeat)
      83           0 :                     nValue = nReference;
      84             :                 else
      85             :                 {
      86           0 :                     xStatusIndicator->reset();
      87           0 :                     nValue = 0;
      88             :                 }
      89             :             }
      90             :             else
      91           0 :                 nValue = nTempValue;
      92             : 
      93           0 :             double fValue(nValue);
      94           0 :             double fNewValue ((fValue * nRange) / nReference);
      95             : 
      96           0 :             xStatusIndicator->setValue((sal_Int32)fNewValue);
      97             : 
      98             :             // #95181# disabled, because we want to call setValue very often to enable a good reschedule
      99             :         }
     100             : #ifdef DBG_UTIL
     101             :         else if (!bFailure)
     102             :         {
     103             :             OSL_FAIL("tried to set a wrong value on the progressbar");
     104             :             bFailure = true;
     105             :         }
     106             : #endif
     107             :     }
     108           0 : }
     109             : 
     110             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10