LCOV - code coverage report
Current view: top level - framework/source/helper - statusindicatorfactory.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 238 278 85.6 %
Date: 2014-11-03 Functions: 20 21 95.2 %
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 <algorithm>
      21             : #include <helper/statusindicatorfactory.hxx>
      22             : #include <helper/statusindicator.hxx>
      23             : #include <helper/vclstatusindicator.hxx>
      24             : #include <services.h>
      25             : #include <properties.h>
      26             : 
      27             : #include <com/sun/star/awt/Rectangle.hpp>
      28             : 
      29             : #include <com/sun/star/awt/XControl.hpp>
      30             : #include <com/sun/star/awt/XLayoutConstrains.hpp>
      31             : #include <com/sun/star/awt/DeviceInfo.hpp>
      32             : #include <com/sun/star/awt/PosSize.hpp>
      33             : #include <com/sun/star/awt/WindowAttribute.hpp>
      34             : #include <com/sun/star/awt/XTopWindow.hpp>
      35             : #include <com/sun/star/awt/XWindow2.hpp>
      36             : #include <com/sun/star/beans/XPropertySet.hpp>
      37             : #include <com/sun/star/frame/XLayoutManager2.hpp>
      38             : 
      39             : #include <toolkit/helper/vclunohelper.hxx>
      40             : 
      41             : #include <comphelper/sequenceashashmap.hxx>
      42             : #include <unotools/mediadescriptor.hxx>
      43             : #include <vcl/svapp.hxx>
      44             : #include <osl/mutex.hxx>
      45             : #include <rtl/ref.hxx>
      46             : 
      47             : #include <officecfg/Office/Common.hxx>
      48             : 
      49             : namespace framework{
      50             : 
      51             : sal_Int32 StatusIndicatorFactory::m_nInReschedule = 0;  ///< static counter for rescheduling
      52             : struct RescheduleLock: public rtl::Static<osl::Mutex, RescheduleLock> {}; ///< mutex to guard the m_nInReschedule
      53             : 
      54             : const char PROGRESS_RESOURCE[] = "private:resource/progressbar/progressbar";
      55             : 
      56        5572 : StatusIndicatorFactory::StatusIndicatorFactory(const css::uno::Reference< css::uno::XComponentContext >& xContext)
      57             :     : m_xContext          (xContext )
      58             :     , m_pWakeUp           (0        )
      59             :     , m_bAllowReschedule  (false)
      60             :     , m_bAllowParentShow  (false)
      61        5572 :     , m_bDisableReschedule(false)
      62             : {
      63        5572 : }
      64             : 
      65       16698 : StatusIndicatorFactory::~StatusIndicatorFactory()
      66             : {
      67        5566 :     impl_stopWakeUpThread();
      68       11132 : }
      69             : 
      70        5572 : void SAL_CALL StatusIndicatorFactory::initialize(const css::uno::Sequence< css::uno::Any >& lArguments)
      71             :     throw(css::uno::Exception       ,
      72             :           css::uno::RuntimeException, std::exception)
      73             : {
      74        5572 :     if (lArguments.getLength() > 0) {
      75        5572 :         osl::MutexGuard g(m_mutex);
      76             : 
      77       11144 :         css::uno::Reference< css::frame::XFrame > xTmpFrame;
      78       11144 :         css::uno::Reference< css::awt::XWindow > xTmpWindow;
      79        5572 :         bool b1 = lArguments[0] >>= xTmpFrame;
      80        5572 :         bool b2 = lArguments[0] >>= xTmpWindow;
      81        5572 :         if (lArguments.getLength() == 3 && b1) {
      82             :            // it's the first service constructor "createWithFrame"
      83        5572 :             m_xFrame = xTmpFrame;
      84        5572 :             lArguments[1] >>= m_bDisableReschedule;
      85        5572 :             lArguments[2] >>= m_bAllowParentShow;
      86           0 :         } else if (lArguments.getLength() == 3 && b2) {
      87             :            // it's the second service constructor "createWithWindow"
      88           0 :             m_xPluggWindow = xTmpWindow;
      89           0 :             lArguments[1] >>= m_bDisableReschedule;
      90           0 :             lArguments[2] >>= m_bAllowParentShow;
      91             :         } else {
      92             :            // it's an old-style initialisation using properties
      93           0 :             ::comphelper::SequenceAsHashMap lArgs(lArguments);
      94             : 
      95           0 :             m_xFrame             = lArgs.getUnpackedValueOrDefault("Frame"            , css::uno::Reference< css::frame::XFrame >());
      96           0 :             m_xPluggWindow       = lArgs.getUnpackedValueOrDefault("Window"           , css::uno::Reference< css::awt::XWindow >() );
      97           0 :             m_bAllowParentShow   = lArgs.getUnpackedValueOrDefault("AllowParentShow"  , sal_False                        );
      98           0 :             m_bDisableReschedule = lArgs.getUnpackedValueOrDefault("DisableReschedule", sal_False                        );
      99        5572 :        }
     100             :     }
     101             : 
     102        5572 :     impl_createProgress();
     103        5572 : }
     104             : 
     105        5504 : css::uno::Reference< css::task::XStatusIndicator > SAL_CALL StatusIndicatorFactory::createStatusIndicator()
     106             :     throw(css::uno::RuntimeException, std::exception)
     107             : {
     108        5504 :     StatusIndicator* pIndicator = new StatusIndicator(this);
     109        5504 :     css::uno::Reference< css::task::XStatusIndicator > xIndicator(static_cast< ::cppu::OWeakObject* >(pIndicator), css::uno::UNO_QUERY_THROW);
     110             : 
     111        5504 :     return xIndicator;
     112             : }
     113             : 
     114       16736 : void SAL_CALL StatusIndicatorFactory::update()
     115             :     throw(css::uno::RuntimeException, std::exception)
     116             : {
     117       16736 :     osl::MutexGuard g(m_mutex);
     118       16736 :     m_bAllowReschedule = true;
     119       16736 : }
     120             : 
     121        3930 : void StatusIndicatorFactory::start(const css::uno::Reference< css::task::XStatusIndicator >& xChild,
     122             :                                    const OUString&                                    sText ,
     123             :                                          sal_Int32                                           nRange)
     124             : {
     125             :     // SAFE -> ----------------------------------
     126        3930 :     osl::ClearableMutexGuard aWriteLock(m_mutex);
     127             : 
     128             :     // create new info structure for this child or move it to the front of our stack
     129        3930 :     IndicatorStack::iterator pItem = ::std::find(m_aStack.begin(), m_aStack.end(), xChild);
     130        3930 :     if (pItem != m_aStack.end())
     131          74 :         m_aStack.erase(pItem);
     132        7860 :     IndicatorInfo aInfo(xChild, sText, nRange);
     133        3930 :     m_aStack.push_back (aInfo                );
     134             : 
     135        3930 :     m_xActiveChild = xChild;
     136        7860 :     css::uno::Reference< css::task::XStatusIndicator > xProgress = m_xProgress;
     137             : 
     138        3930 :     aWriteLock.clear();
     139             :     // <- SAFE ----------------------------------
     140             : 
     141        3930 :     implts_makeParentVisibleIfAllowed();
     142             : 
     143        3930 :     if (xProgress.is())
     144        3930 :         xProgress->start(sText, nRange);
     145             : 
     146        3930 :     impl_startWakeUpThread();
     147        7860 :     impl_reschedule(true);
     148        3930 : }
     149             : 
     150         446 : void StatusIndicatorFactory::reset(const css::uno::Reference< css::task::XStatusIndicator >& xChild)
     151             : {
     152             :     // SAFE -> ----------------------------------
     153         446 :     osl::ClearableMutexGuard aReadLock(m_mutex);
     154             : 
     155             :     // reset the internal info structure related to this child
     156         446 :     IndicatorStack::iterator pItem = ::std::find(m_aStack.begin(), m_aStack.end(), xChild);
     157         446 :     if (pItem != m_aStack.end())
     158             :     {
     159         446 :         pItem->m_nValue = 0;
     160         446 :         pItem->m_sText  = OUString();
     161             :     }
     162             : 
     163         892 :     css::uno::Reference< css::task::XStatusIndicator > xActive   = m_xActiveChild;
     164         892 :     css::uno::Reference< css::task::XStatusIndicator > xProgress = m_xProgress;
     165             : 
     166         446 :     aReadLock.clear();
     167             :     // <- SAFE ----------------------------------
     168             : 
     169             :     // not the top most child => dont change UI
     170             :     // But dont forget Reschedule!
     171         446 :     if (
     172         892 :         (xChild == xActive) &&
     173         446 :         (xProgress.is()   )
     174             :        )
     175         446 :         xProgress->reset();
     176             : 
     177         892 :     impl_reschedule(true);
     178         446 : }
     179             : 
     180        4160 : void StatusIndicatorFactory::end(const css::uno::Reference< css::task::XStatusIndicator >& xChild)
     181             : {
     182             :     // SAFE -> ----------------------------------
     183        4160 :     osl::ClearableMutexGuard aWriteLock(m_mutex);
     184             : 
     185             :     // remove this child from our stack
     186        4160 :     IndicatorStack::iterator pItem = ::std::find(m_aStack.begin(), m_aStack.end(), xChild);
     187        4160 :     if (pItem != m_aStack.end())
     188        3856 :         m_aStack.erase(pItem);
     189             : 
     190             :     // activate next child ... or finish the progress if there is no further one.
     191        4160 :     m_xActiveChild.clear();
     192        8320 :     OUString                  sText;
     193        4160 :     sal_Int32                        nValue = 0;
     194        4160 :     IndicatorStack::reverse_iterator pNext  = m_aStack.rbegin();
     195        4160 :     if (pNext != m_aStack.rend())
     196             :     {
     197           0 :         m_xActiveChild = pNext->m_xIndicator;
     198           0 :         sText          = pNext->m_sText;
     199           0 :         nValue         = pNext->m_nValue;
     200             :     }
     201             : 
     202        8320 :     css::uno::Reference< css::task::XStatusIndicator > xActive   = m_xActiveChild;
     203        8320 :     css::uno::Reference< css::task::XStatusIndicator > xProgress = m_xProgress;
     204             : 
     205        4160 :     aWriteLock.clear();
     206             :     // <- SAFE ----------------------------------
     207             : 
     208        4160 :     if (xActive.is())
     209             :     {
     210             :         // There is at least one further child indicator.
     211             :         // Actualize our progress, so it shows these values from now.
     212           0 :         if (xProgress.is())
     213             :         {
     214           0 :             xProgress->setText (sText );
     215           0 :             xProgress->setValue(nValue);
     216             :         }
     217             :     }
     218             :     else
     219             :     {
     220             :         // Our stack is empty. No further child exists.
     221             :         // Se we must "end" our progress really
     222        4160 :         if (xProgress.is())
     223        4160 :             xProgress->end();
     224             :         // Now hide the progress bar again.
     225        4160 :         impl_hideProgress();
     226             : 
     227        4160 :         impl_stopWakeUpThread();
     228             :     }
     229             : 
     230        8320 :     impl_reschedule(true);
     231        4160 : }
     232             : 
     233           0 : void StatusIndicatorFactory::setText(const css::uno::Reference< css::task::XStatusIndicator >& xChild,
     234             :                                      const OUString&                                    sText )
     235             : {
     236             :     // SAFE -> ----------------------------------
     237           0 :     osl::ClearableMutexGuard aWriteLock(m_mutex);
     238             : 
     239           0 :     IndicatorStack::iterator pItem = ::std::find(m_aStack.begin(), m_aStack.end(), xChild);
     240           0 :     if (pItem != m_aStack.end())
     241           0 :         pItem->m_sText = sText;
     242             : 
     243           0 :     css::uno::Reference< css::task::XStatusIndicator > xActive   = m_xActiveChild;
     244           0 :     css::uno::Reference< css::task::XStatusIndicator > xProgress = m_xProgress;
     245             : 
     246           0 :     aWriteLock.clear();
     247             :     // SAFE -> ----------------------------------
     248             : 
     249             :     // paint only the top most indicator
     250             :     // but dont forget to Reschedule!
     251           0 :     if (
     252           0 :         (xChild == xActive) &&
     253           0 :         (xProgress.is()   )
     254             :        )
     255             :     {
     256           0 :         xProgress->setText(sText);
     257             :     }
     258             : 
     259           0 :     impl_reschedule(true);
     260           0 : }
     261             : 
     262       51050 : void StatusIndicatorFactory::setValue( const css::uno::Reference< css::task::XStatusIndicator >& xChild ,
     263             :                                              sal_Int32                                           nValue )
     264             : {
     265             :     // SAFE -> ----------------------------------
     266       51050 :     osl::ClearableMutexGuard aWriteLock(m_mutex);
     267             : 
     268       51050 :     sal_Int32 nOldValue = 0;
     269       51050 :     IndicatorStack::iterator pItem = ::std::find(m_aStack.begin(), m_aStack.end(), xChild);
     270       51050 :     if (pItem != m_aStack.end())
     271             :     {
     272       51048 :         nOldValue       = pItem->m_nValue;
     273       51048 :         pItem->m_nValue = nValue;
     274             :     }
     275             : 
     276      102100 :     css::uno::Reference< css::task::XStatusIndicator > xActive    = m_xActiveChild;
     277      102100 :     css::uno::Reference< css::task::XStatusIndicator > xProgress  = m_xProgress;
     278             : 
     279       51050 :     aWriteLock.clear();
     280             :     // SAFE -> ----------------------------------
     281             : 
     282       51050 :     if (
     283      102098 :         (xChild    == xActive) &&
     284       97715 :         (nOldValue != nValue ) &&
     285       46665 :         (xProgress.is()      )
     286             :        )
     287             :     {
     288       46665 :         xProgress->setValue(nValue);
     289             :     }
     290             : 
     291      102100 :     impl_reschedule(false);
     292       51050 : }
     293             : 
     294        3930 : void StatusIndicatorFactory::implts_makeParentVisibleIfAllowed()
     295             : {
     296             :     // SAFE -> ----------------------------------
     297        3930 :     osl::ClearableMutexGuard aReadLock(m_mutex);
     298             : 
     299        3930 :     if (!m_bAllowParentShow)
     300           0 :         return;
     301             : 
     302        7728 :     css::uno::Reference< css::frame::XFrame > xFrame      (m_xFrame.get()      , css::uno::UNO_QUERY);
     303        7728 :     css::uno::Reference< css::awt::XWindow >  xPluggWindow(m_xPluggWindow.get(), css::uno::UNO_QUERY);
     304        7728 :     css::uno::Reference< css::uno::XComponentContext > xContext( m_xContext);
     305             : 
     306        3930 :     aReadLock.clear();
     307             :     // <- SAFE ----------------------------------
     308             : 
     309        7728 :     css::uno::Reference< css::awt::XWindow > xParentWindow;
     310        3930 :     if (xFrame.is())
     311        3930 :         xParentWindow = xFrame->getContainerWindow();
     312             :     else
     313           0 :         xParentWindow = xPluggWindow;
     314             : 
     315             :     // dont disturb user in case he put the loading document into the background!
     316             :     // Suppress any setVisible() or toFront() call in case the initial show was
     317             :     // already made.
     318        7728 :     css::uno::Reference< css::awt::XWindow2 > xVisibleCheck(xParentWindow, css::uno::UNO_QUERY);
     319        3930 :     bool bIsVisible = false;
     320        3930 :     if (xVisibleCheck.is())
     321        3930 :         bIsVisible = xVisibleCheck->isVisible();
     322             : 
     323        3930 :     if (bIsVisible)
     324             :     {
     325         132 :         impl_showProgress();
     326         132 :         return;
     327             :     }
     328             : 
     329             :     // Check if the layout manager has been set to invisible state. It this case we are also
     330             :     // not allowed to set the frame visible!
     331        7596 :     css::uno::Reference< css::beans::XPropertySet > xPropSet(xFrame, css::uno::UNO_QUERY);
     332        3798 :     if (xPropSet.is())
     333             :     {
     334        3798 :         css::uno::Reference< css::frame::XLayoutManager2 > xLayoutManager;
     335        3798 :         xPropSet->getPropertyValue(FRAME_PROPNAME_LAYOUTMANAGER) >>= xLayoutManager;
     336        3798 :         if (xLayoutManager.is())
     337             :         {
     338        3798 :             if ( !xLayoutManager->isVisible() )
     339           0 :                 return;
     340        3798 :         }
     341             :     }
     342             : 
     343             :     // Ok the window should be made visible ... because it isnt currently visible.
     344             :     // BUT ..!
     345             :     // We need a Hack for our applications: They get her progress from the frame directly
     346             :     // on saving documents. Because there is no progress set on the MediaDescriptor.
     347             :     // But that's wrong. In case the document was opened hidden, they should not use any progress .-(
     348             :     // They only possible workaround: dont show the parent window here, if the document was opened hidden.
     349        3798 :     bool bHiddenDoc = false;
     350        3798 :     if (xFrame.is())
     351             :     {
     352        3798 :         css::uno::Reference< css::frame::XController > xController;
     353        7596 :         css::uno::Reference< css::frame::XModel >      xModel;
     354        3798 :         xController = xFrame->getController();
     355        3798 :         if (xController.is())
     356           0 :             xModel = xController->getModel();
     357        3798 :         if (xModel.is())
     358             :         {
     359           0 :             utl::MediaDescriptor lDocArgs(xModel->getArgs());
     360             :             bHiddenDoc = lDocArgs.getUnpackedValueOrDefault(
     361           0 :                 utl::MediaDescriptor::PROP_HIDDEN(),
     362           0 :                 sal_False);
     363        3798 :         }
     364             :     }
     365             : 
     366        3798 :     if (bHiddenDoc)
     367           0 :         return;
     368             : 
     369             :     // OK: The document was not opened in hidden mode ...
     370             :     // and the window isn't already visible.
     371             :     // Show it and bring it to front.
     372             :     // But before we have to be sure, that our internal used helper progress
     373             :     // is visible too.
     374        3798 :     impl_showProgress();
     375             : 
     376        7596 :     SolarMutexGuard aSolarGuard;
     377        3798 :     vcl::Window* pWindow = VCLUnoHelper::GetWindow(xParentWindow);
     378        3798 :     if ( pWindow )
     379             :     {
     380        3798 :         bool bForceFrontAndFocus(officecfg::Office::Common::View::NewDocumentHandling::ForceFocusAndToFront::get(xContext));
     381        3798 :         pWindow->Show(true, bForceFrontAndFocus ? SHOW_FOREGROUNDTASK : 0 );
     382        3798 :     }
     383             : 
     384             : }
     385             : 
     386        5572 : void StatusIndicatorFactory::impl_createProgress()
     387             : {
     388             :     // SAFE -> ----------------------------------
     389        5572 :     osl::ClearableMutexGuard aReadLock(m_mutex);
     390             : 
     391       11144 :     css::uno::Reference< css::frame::XFrame >              xFrame (m_xFrame.get()      , css::uno::UNO_QUERY);
     392       11144 :     css::uno::Reference< css::awt::XWindow >               xWindow(m_xPluggWindow.get(), css::uno::UNO_QUERY);
     393             : 
     394        5572 :     aReadLock.clear();
     395             :     // <- SAFE ----------------------------------
     396             : 
     397       11144 :     css::uno::Reference< css::task::XStatusIndicator > xProgress;
     398             : 
     399        5572 :     if (xWindow.is())
     400             :     {
     401             :         // use vcl based progress implementation in plugged mode
     402           0 :         VCLStatusIndicator* pVCLProgress = new VCLStatusIndicator(xWindow);
     403           0 :         xProgress = css::uno::Reference< css::task::XStatusIndicator >(static_cast< css::task::XStatusIndicator* >(pVCLProgress), css::uno::UNO_QUERY);
     404             :     }
     405        5572 :     else if (xFrame.is())
     406             :     {
     407             :         // use frame layouted progress implementation
     408        5572 :         css::uno::Reference< css::beans::XPropertySet > xPropSet(xFrame, css::uno::UNO_QUERY);
     409        5572 :         if (xPropSet.is())
     410             :         {
     411        5572 :             css::uno::Reference< css::frame::XLayoutManager2 > xLayoutManager;
     412        5572 :             xPropSet->getPropertyValue(FRAME_PROPNAME_LAYOUTMANAGER) >>= xLayoutManager;
     413        5572 :             if (xLayoutManager.is())
     414             :             {
     415        5572 :                 xLayoutManager->lock();
     416        5572 :                 OUString sPROGRESS_RESOURCE(PROGRESS_RESOURCE);
     417        5572 :                 xLayoutManager->createElement( sPROGRESS_RESOURCE );
     418        5572 :                 xLayoutManager->hideElement( sPROGRESS_RESOURCE );
     419             : 
     420       11144 :                 css::uno::Reference< css::ui::XUIElement > xProgressBar = xLayoutManager->getElement(sPROGRESS_RESOURCE);
     421        5572 :                 if (xProgressBar.is())
     422        5572 :                     xProgress = css::uno::Reference< css::task::XStatusIndicator >(xProgressBar->getRealInterface(), css::uno::UNO_QUERY);
     423       11144 :                 xLayoutManager->unlock();
     424        5572 :             }
     425        5572 :         }
     426             :     }
     427             : 
     428       11144 :     osl::MutexGuard g(m_mutex);
     429       11144 :     m_xProgress = xProgress;
     430        5572 : }
     431             : 
     432        3930 : void StatusIndicatorFactory::impl_showProgress()
     433             : {
     434             :     // SAFE -> ----------------------------------
     435        3930 :     osl::ClearableMutexGuard aReadLock(m_mutex);
     436             : 
     437        7860 :     css::uno::Reference< css::frame::XFrame >              xFrame (m_xFrame.get()      , css::uno::UNO_QUERY);
     438        7860 :     css::uno::Reference< css::awt::XWindow >               xWindow(m_xPluggWindow.get(), css::uno::UNO_QUERY);
     439             : 
     440        3930 :     aReadLock.clear();
     441             :     // <- SAFE ----------------------------------
     442             : 
     443        7860 :     css::uno::Reference< css::task::XStatusIndicator > xProgress;
     444             : 
     445        3930 :     if (xFrame.is())
     446             :     {
     447             :         // use frame layouted progress implementation
     448        3930 :         css::uno::Reference< css::beans::XPropertySet > xPropSet(xFrame, css::uno::UNO_QUERY);
     449        3930 :         if (xPropSet.is())
     450             :         {
     451        3930 :             css::uno::Reference< css::frame::XLayoutManager2 > xLayoutManager;
     452        3930 :             xPropSet->getPropertyValue(FRAME_PROPNAME_LAYOUTMANAGER) >>= xLayoutManager;
     453        3930 :             if (xLayoutManager.is())
     454             :             {
     455             :                 // Be sure that we have always a progress. It can be that our frame
     456             :                 // was recycled and therefore the progress was destroyed!
     457             :                 // CreateElement does nothing if there is already a valid progress.
     458        3930 :                 OUString sPROGRESS_RESOURCE(PROGRESS_RESOURCE);
     459        3930 :                 xLayoutManager->createElement( sPROGRESS_RESOURCE );
     460        3930 :                 xLayoutManager->showElement( sPROGRESS_RESOURCE );
     461             : 
     462        7860 :                 css::uno::Reference< css::ui::XUIElement > xProgressBar = xLayoutManager->getElement(sPROGRESS_RESOURCE);
     463        3930 :                 if (xProgressBar.is())
     464        7860 :                     xProgress = css::uno::Reference< css::task::XStatusIndicator >(xProgressBar->getRealInterface(), css::uno::UNO_QUERY);
     465        3930 :             }
     466             :         }
     467             : 
     468        7860 :         osl::MutexGuard g(m_mutex);
     469        7860 :         m_xProgress = xProgress;
     470        3930 :     }
     471        3930 : }
     472             : 
     473        4160 : void StatusIndicatorFactory::impl_hideProgress()
     474             : {
     475             :     // SAFE -> ----------------------------------
     476        4160 :     osl::ClearableMutexGuard aReadLock(m_mutex);
     477             : 
     478        8320 :     css::uno::Reference< css::frame::XFrame >              xFrame (m_xFrame.get()      , css::uno::UNO_QUERY);
     479        8320 :     css::uno::Reference< css::awt::XWindow >               xWindow(m_xPluggWindow.get(), css::uno::UNO_QUERY);
     480             : 
     481        4160 :     aReadLock.clear();
     482             :     // <- SAFE ----------------------------------
     483             : 
     484        4160 :     if (xFrame.is())
     485             :     {
     486             :         // use frame layouted progress implementation
     487        4160 :         css::uno::Reference< css::beans::XPropertySet > xPropSet(xFrame, css::uno::UNO_QUERY);
     488        4160 :         if (xPropSet.is())
     489             :         {
     490        4160 :             css::uno::Reference< css::frame::XLayoutManager2 > xLayoutManager;
     491        4160 :             xPropSet->getPropertyValue(FRAME_PROPNAME_LAYOUTMANAGER) >>= xLayoutManager;
     492        4160 :             if (xLayoutManager.is())
     493        4160 :                 xLayoutManager->hideElement( OUString(PROGRESS_RESOURCE) );
     494        4160 :         }
     495        4160 :     }
     496        4160 : }
     497             : 
     498       59586 : void StatusIndicatorFactory::impl_reschedule(bool bForce)
     499             : {
     500             :     // SAFE ->
     501       59586 :     osl::ClearableMutexGuard aReadLock(m_mutex);
     502       59586 :     if (m_bDisableReschedule)
     503           0 :         return;
     504       59586 :     aReadLock.clear();
     505             :     // <- SAFE
     506             : 
     507       59586 :     bool bReschedule = bForce;
     508       59586 :     if (!bReschedule)
     509             :     {
     510       51050 :         osl::MutexGuard g(m_mutex);
     511       51050 :         bReschedule        = m_bAllowReschedule;
     512       51050 :         m_bAllowReschedule = false;
     513             :     }
     514             : 
     515       59586 :     if (!bReschedule)
     516       47918 :         return;
     517             : 
     518             :     // SAFE ->
     519       23336 :     osl::ResettableMutexGuard aRescheduleGuard(RescheduleLock::get());
     520             : 
     521       11668 :     if (m_nInReschedule == 0)
     522             :     {
     523       11668 :         ++m_nInReschedule;
     524       11668 :         aRescheduleGuard.clear();
     525             :         // <- SAFE
     526             : 
     527             :         {
     528       11668 :             SolarMutexGuard g;
     529       11668 :             Application::Reschedule(true);
     530             :         }
     531             : 
     532             :         // SAFE ->
     533       11668 :         aRescheduleGuard.reset();
     534       11668 :         --m_nInReschedule;
     535       11668 :     }
     536             : }
     537             : 
     538        3930 : void StatusIndicatorFactory::impl_startWakeUpThread()
     539             : {
     540        3930 :     osl::MutexGuard g(m_mutex);
     541             : 
     542        3930 :     if (m_bDisableReschedule)
     543        3930 :         return;
     544             : 
     545        3930 :     if (!m_pWakeUp)
     546             :     {
     547        3856 :         m_pWakeUp = new WakeUpThread(this);
     548        3856 :         m_pWakeUp->create();
     549        3930 :     }
     550             : }
     551             : 
     552        9726 : void StatusIndicatorFactory::impl_stopWakeUpThread()
     553             : {
     554        9726 :     osl::MutexGuard g(m_mutex);
     555        9726 :     if (m_pWakeUp)
     556             :     {
     557             :         // Thread kill itself after terminate()!
     558        3856 :         m_pWakeUp->terminate();
     559        3856 :         m_pWakeUp = 0;
     560        9726 :     }
     561        9726 : }
     562             : 
     563             : } // namespace framework
     564             : 
     565             : extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
     566        5572 : com_sun_star_comp_framework_StatusIndicatorFactory_get_implementation(
     567             :     css::uno::XComponentContext *context,
     568             :     css::uno::Sequence<css::uno::Any> const &)
     569             : {
     570        5572 :     return cppu::acquire(new framework::StatusIndicatorFactory(context));
     571         951 : }
     572             : 
     573             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10