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

Generated by: LCOV version 1.11