LCOV - code coverage report
Current view: top level - framework/source/helper - vclstatusindicator.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 65 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 9 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 <helper/vclstatusindicator.hxx>
      21             : 
      22             : #include <toolkit/helper/vclunohelper.hxx>
      23             : #include <vcl/svapp.hxx>
      24             : 
      25             : namespace framework {
      26             : 
      27           0 : VCLStatusIndicator::VCLStatusIndicator(const css::uno::Reference< css::awt::XWindow >&               xParentWindow)
      28             :     : m_xParentWindow    (xParentWindow                )
      29             :     , m_pStatusBar       (0                            )
      30             :     , m_nRange           (0                            )
      31           0 :     , m_nValue           (0                            )
      32             : {
      33           0 :     if (!m_xParentWindow.is())
      34             :         throw css::uno::RuntimeException(
      35             :                 OUString("Can't work without a parent window!"),
      36           0 :                 static_cast< css::task::XStatusIndicator* >(this));
      37           0 : }
      38             : 
      39           0 : VCLStatusIndicator::~VCLStatusIndicator()
      40             : {
      41           0 : }
      42             : 
      43           0 : void SAL_CALL VCLStatusIndicator::start(const OUString& sText ,
      44             :                                               sal_Int32        nRange)
      45             :     throw(css::uno::RuntimeException, std::exception)
      46             : {
      47           0 :     SolarMutexGuard aSolarGuard;
      48             : 
      49           0 :     vcl::Window* pParentWindow = VCLUnoHelper::GetWindow(m_xParentWindow);
      50           0 :     if (!m_pStatusBar)
      51           0 :         m_pStatusBar = VclPtr<StatusBar>::Create(pParentWindow, WB_3DLOOK|WB_BORDER);
      52             : 
      53           0 :     VCLStatusIndicator::impl_recalcLayout(m_pStatusBar, pParentWindow);
      54             : 
      55           0 :     m_pStatusBar->Show();
      56           0 :     m_pStatusBar->StartProgressMode(sText);
      57           0 :     m_pStatusBar->SetProgressValue(0);
      58             : 
      59             :     // force repaint!
      60           0 :     pParentWindow->Show();
      61           0 :     pParentWindow->Invalidate(InvalidateFlags::Children);
      62           0 :     pParentWindow->Flush();
      63             : 
      64           0 :     m_sText  = sText;
      65           0 :     m_nRange = nRange;
      66           0 :     m_nValue = 0;
      67           0 : }
      68             : 
      69           0 : void SAL_CALL VCLStatusIndicator::reset()
      70             :     throw(css::uno::RuntimeException, std::exception)
      71             : {
      72           0 :     SolarMutexGuard aSolarGuard;
      73           0 :     if (m_pStatusBar)
      74             :     {
      75           0 :         m_pStatusBar->SetProgressValue(0);
      76           0 :         m_pStatusBar->SetText(OUString());
      77           0 :     }
      78           0 : }
      79             : 
      80           0 : void SAL_CALL VCLStatusIndicator::end()
      81             :     throw(css::uno::RuntimeException, std::exception)
      82             : {
      83           0 :     SolarMutexGuard aSolarGuard;
      84             : 
      85           0 :     m_sText.clear();
      86           0 :     m_nRange = 0;
      87           0 :     m_nValue = 0;
      88             : 
      89           0 :     if (m_pStatusBar)
      90             :     {
      91           0 :         m_pStatusBar->EndProgressMode();
      92           0 :         m_pStatusBar->Show(false);
      93             : 
      94           0 :         m_pStatusBar.disposeAndClear();
      95           0 :     }
      96           0 : }
      97             : 
      98           0 : void SAL_CALL VCLStatusIndicator::setText(const OUString& sText)
      99             :     throw(css::uno::RuntimeException, std::exception)
     100             : {
     101           0 :     SolarMutexGuard aSolarGuard;
     102           0 :     m_sText = sText;
     103           0 :     if (m_pStatusBar)
     104           0 :         m_pStatusBar->SetText(sText);
     105           0 : }
     106             : 
     107           0 : void SAL_CALL VCLStatusIndicator::setValue(sal_Int32 nValue)
     108             :     throw(css::uno::RuntimeException, std::exception)
     109             : {
     110           0 :     SolarMutexGuard aSolarGuard;
     111             : 
     112           0 :     if (nValue <= m_nRange)
     113           0 :         m_nValue = nValue;
     114             :     else
     115           0 :         m_nValue = m_nRange;
     116             : 
     117           0 :     sal_Int32 nRange = m_nRange;
     118           0 :     nValue = m_nValue;
     119             : 
     120             :     // normalize value to fit the range of 0-100%
     121             :     sal_uInt16 nPercent = sal::static_int_cast< sal_uInt16 >(
     122             :         ::std::min(
     123           0 :             ((nValue*100) / ::std::max(nRange,(sal_Int32)1)), (sal_Int32)100));
     124             : 
     125           0 :     if (m_pStatusBar)
     126           0 :         m_pStatusBar->SetProgressValue(nPercent);
     127           0 : }
     128             : 
     129           0 : void VCLStatusIndicator::impl_recalcLayout(vcl::Window* pStatusBar   ,
     130             :                                            vcl::Window* pParentWindow)
     131             : {
     132           0 :     if (
     133           0 :         (!pStatusBar   ) ||
     134             :         (!pParentWindow)
     135             :        )
     136           0 :        return;
     137             : 
     138           0 :     Size aParentSize = pParentWindow->GetSizePixel();
     139             :     pStatusBar->setPosSizePixel(0,
     140             :                                 0,
     141           0 :                                 aParentSize.Width(),
     142           0 :                                 aParentSize.Height());
     143             : }
     144             : 
     145             : } // namespace framework
     146             : 
     147             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11