LCOV - code coverage report
Current view: top level - framework/source/helper - statusindicatorfactory.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 277 0.0 %
Date: 2014-04-14 Functions: 0 19 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 <algorithm>
      21             : #include <helper/statusindicatorfactory.hxx>
      22             : #include <helper/statusindicator.hxx>
      23             : #include <helper/vclstatusindicator.hxx>
      24             : #include <threadhelp/lockhelper.hxx>
      25             : #include <services.h>
      26             : #include <properties.h>
      27             : 
      28             : #include <com/sun/star/awt/Rectangle.hpp>
      29             : 
      30             : #include <com/sun/star/awt/XControl.hpp>
      31             : #include <com/sun/star/awt/XLayoutConstrains.hpp>
      32             : #include <com/sun/star/awt/DeviceInfo.hpp>
      33             : #include <com/sun/star/awt/PosSize.hpp>
      34             : #include <com/sun/star/awt/WindowAttribute.hpp>
      35             : #include <com/sun/star/awt/XTopWindow.hpp>
      36             : #include <com/sun/star/awt/XWindow2.hpp>
      37             : #include <com/sun/star/beans/XPropertySet.hpp>
      38             : #include <com/sun/star/frame/XLayoutManager2.hpp>
      39             : 
      40             : #include <toolkit/helper/vclunohelper.hxx>
      41             : 
      42             : #include <comphelper/sequenceashashmap.hxx>
      43             : #include <unotools/mediadescriptor.hxx>
      44             : #include <vcl/svapp.hxx>
      45             : #include <osl/mutex.hxx>
      46             : #include <rtl/ref.hxx>
      47             : 
      48             : #include <officecfg/Office/Common.hxx>
      49             : 
      50             : namespace framework{
      51             : 
      52             : sal_Int32 StatusIndicatorFactory::m_nInReschedule = 0;  /// static counter for rescheduling
      53             : const char PROGRESS_RESOURCE[] = "private:resource/progressbar/progressbar";
      54             : 
      55           0 : StatusIndicatorFactory::StatusIndicatorFactory(const css::uno::Reference< css::uno::XComponentContext >& xContext)
      56             :     : m_xContext          (xContext )
      57             :     , m_pWakeUp           (0        )
      58             :     , m_bAllowReschedule  (false)
      59             :     , m_bAllowParentShow  (false)
      60           0 :     , m_bDisableReschedule(false)
      61             : {
      62           0 : }
      63             : 
      64           0 : StatusIndicatorFactory::~StatusIndicatorFactory()
      65             : {
      66           0 :     impl_stopWakeUpThread();
      67           0 : }
      68             : 
      69           0 : 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           0 :     if (lArguments.getLength() > 0) {
      74           0 :         osl::MutexGuard g(m_mutex);
      75             : 
      76           0 :         css::uno::Reference< css::frame::XFrame > xTmpFrame;
      77           0 :         css::uno::Reference< css::awt::XWindow > xTmpWindow;
      78           0 :         bool b1 = lArguments[0] >>= xTmpFrame;
      79           0 :         bool b2 = lArguments[0] >>= xTmpWindow;
      80           0 :         if (lArguments.getLength() == 3 && b1) {
      81             :            // it's the first service constructor "createWithFrame"
      82           0 :             m_xFrame = xTmpFrame;
      83           0 :             lArguments[1] >>= m_bDisableReschedule;
      84           0 :             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"  , sal_False                        );
      97           0 :             m_bDisableReschedule = lArgs.getUnpackedValueOrDefault("DisableReschedule", sal_False                        );
      98           0 :        }
      99             :     }
     100             : 
     101           0 :     impl_createProgress();
     102           0 : }
     103             : 
     104           0 : css::uno::Reference< css::task::XStatusIndicator > SAL_CALL StatusIndicatorFactory::createStatusIndicator()
     105             :     throw(css::uno::RuntimeException, std::exception)
     106             : {
     107           0 :     StatusIndicator* pIndicator = new StatusIndicator(this);
     108           0 :     css::uno::Reference< css::task::XStatusIndicator > xIndicator(static_cast< ::cppu::OWeakObject* >(pIndicator), css::uno::UNO_QUERY_THROW);
     109             : 
     110           0 :     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           0 : void StatusIndicatorFactory::start(const css::uno::Reference< css::task::XStatusIndicator >& xChild,
     121             :                                    const OUString&                                    sText ,
     122             :                                          sal_Int32                                           nRange)
     123             : {
     124             :     // SAFE -> ----------------------------------
     125           0 :     osl::ClearableMutexGuard aWriteLock(m_mutex);
     126             : 
     127             :     // create new info structure for this child or move it to the front of our stack
     128           0 :     IndicatorStack::iterator pItem = ::std::find(m_aStack.begin(), m_aStack.end(), xChild);
     129           0 :     if (pItem != m_aStack.end())
     130           0 :         m_aStack.erase(pItem);
     131           0 :     IndicatorInfo aInfo(xChild, sText, nRange);
     132           0 :     m_aStack.push_back (aInfo                );
     133             : 
     134           0 :     m_xActiveChild = xChild;
     135           0 :     css::uno::Reference< css::task::XStatusIndicator > xProgress = m_xProgress;
     136             : 
     137           0 :     aWriteLock.clear();
     138             :     // <- SAFE ----------------------------------
     139             : 
     140           0 :     implts_makeParentVisibleIfAllowed();
     141             : 
     142           0 :     if (xProgress.is())
     143           0 :         xProgress->start(sText, nRange);
     144             : 
     145           0 :     impl_startWakeUpThread();
     146           0 :     impl_reschedule(true);
     147           0 : }
     148             : 
     149           0 : void StatusIndicatorFactory::reset(const css::uno::Reference< css::task::XStatusIndicator >& xChild)
     150             : {
     151             :     // SAFE -> ----------------------------------
     152           0 :     osl::ClearableMutexGuard aReadLock(m_mutex);
     153             : 
     154             :     // reset the internal info structure related to this child
     155           0 :     IndicatorStack::iterator pItem = ::std::find(m_aStack.begin(), m_aStack.end(), xChild);
     156           0 :     if (pItem != m_aStack.end())
     157             :     {
     158           0 :         pItem->m_nValue = 0;
     159           0 :         pItem->m_sText  = OUString();
     160             :     }
     161             : 
     162           0 :     css::uno::Reference< css::task::XStatusIndicator > xActive   = m_xActiveChild;
     163           0 :     css::uno::Reference< css::task::XStatusIndicator > xProgress = m_xProgress;
     164             : 
     165           0 :     aReadLock.clear();
     166             :     // <- SAFE ----------------------------------
     167             : 
     168             :     // not the top most child => dont change UI
     169             :     // But dont forget Reschedule!
     170           0 :     if (
     171           0 :         (xChild == xActive) &&
     172           0 :         (xProgress.is()   )
     173             :        )
     174           0 :         xProgress->reset();
     175             : 
     176           0 :     impl_reschedule(true);
     177           0 : }
     178             : 
     179           0 : void StatusIndicatorFactory::end(const css::uno::Reference< css::task::XStatusIndicator >& xChild)
     180             : {
     181             :     // SAFE -> ----------------------------------
     182           0 :     osl::ClearableMutexGuard aWriteLock(m_mutex);
     183             : 
     184             :     // remove this child from our stack
     185           0 :     IndicatorStack::iterator pItem = ::std::find(m_aStack.begin(), m_aStack.end(), xChild);
     186           0 :     if (pItem != m_aStack.end())
     187           0 :         m_aStack.erase(pItem);
     188             : 
     189             :     // activate next child ... or finish the progress if there is no further one.
     190           0 :     m_xActiveChild.clear();
     191           0 :     OUString                  sText;
     192           0 :     sal_Int32                        nValue = 0;
     193           0 :     IndicatorStack::reverse_iterator pNext  = m_aStack.rbegin();
     194           0 :     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           0 :     css::uno::Reference< css::task::XStatusIndicator > xActive   = m_xActiveChild;
     202           0 :     css::uno::Reference< css::task::XStatusIndicator > xProgress = m_xProgress;
     203             : 
     204           0 :     aWriteLock.clear();
     205             :     // <- SAFE ----------------------------------
     206             : 
     207           0 :     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           0 :         if (xProgress.is())
     222           0 :             xProgress->end();
     223             :         // Now hide the progress bar again.
     224           0 :         impl_hideProgress();
     225             : 
     226           0 :         impl_stopWakeUpThread();
     227             :     }
     228             : 
     229           0 :     impl_reschedule(true);
     230           0 : }
     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           0 : void StatusIndicatorFactory::setValue( const css::uno::Reference< css::task::XStatusIndicator >& xChild ,
     262             :                                              sal_Int32                                           nValue )
     263             : {
     264             :     // SAFE -> ----------------------------------
     265           0 :     osl::ClearableMutexGuard aWriteLock(m_mutex);
     266             : 
     267           0 :     sal_Int32 nOldValue = 0;
     268           0 :     IndicatorStack::iterator pItem = ::std::find(m_aStack.begin(), m_aStack.end(), xChild);
     269           0 :     if (pItem != m_aStack.end())
     270             :     {
     271           0 :         nOldValue       = pItem->m_nValue;
     272           0 :         pItem->m_nValue = nValue;
     273             :     }
     274             : 
     275           0 :     css::uno::Reference< css::task::XStatusIndicator > xActive    = m_xActiveChild;
     276           0 :     css::uno::Reference< css::task::XStatusIndicator > xProgress  = m_xProgress;
     277             : 
     278           0 :     aWriteLock.clear();
     279             :     // SAFE -> ----------------------------------
     280             : 
     281           0 :     if (
     282           0 :         (xChild    == xActive) &&
     283           0 :         (nOldValue != nValue ) &&
     284           0 :         (xProgress.is()      )
     285             :        )
     286             :     {
     287           0 :         xProgress->setValue(nValue);
     288             :     }
     289             : 
     290           0 :     impl_reschedule(false);
     291           0 : }
     292             : 
     293           0 : void StatusIndicatorFactory::implts_makeParentVisibleIfAllowed()
     294             : {
     295             :     // SAFE -> ----------------------------------
     296           0 :     osl::ClearableMutexGuard aReadLock(m_mutex);
     297             : 
     298           0 :     if (!m_bAllowParentShow)
     299           0 :         return;
     300             : 
     301           0 :     css::uno::Reference< css::frame::XFrame > xFrame      (m_xFrame.get()      , css::uno::UNO_QUERY);
     302           0 :     css::uno::Reference< css::awt::XWindow >  xPluggWindow(m_xPluggWindow.get(), css::uno::UNO_QUERY);
     303           0 :     css::uno::Reference< css::uno::XComponentContext > xContext( m_xContext);
     304             : 
     305           0 :     aReadLock.clear();
     306             :     // <- SAFE ----------------------------------
     307             : 
     308           0 :     css::uno::Reference< css::awt::XWindow > xParentWindow;
     309           0 :     if (xFrame.is())
     310           0 :         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             :     // Supress any setVisible() or toFront() call in case the initial show was
     316             :     // already made.
     317           0 :     css::uno::Reference< css::awt::XWindow2 > xVisibleCheck(xParentWindow, css::uno::UNO_QUERY);
     318           0 :     bool bIsVisible = false;
     319           0 :     if (xVisibleCheck.is())
     320           0 :         bIsVisible = xVisibleCheck->isVisible();
     321             : 
     322           0 :     if (bIsVisible)
     323             :     {
     324           0 :         impl_showProgress();
     325           0 :         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           0 :     css::uno::Reference< css::beans::XPropertySet > xPropSet(xFrame, css::uno::UNO_QUERY);
     331           0 :     if (xPropSet.is())
     332             :     {
     333           0 :         css::uno::Reference< css::frame::XLayoutManager2 > xLayoutManager;
     334           0 :         xPropSet->getPropertyValue(FRAME_PROPNAME_LAYOUTMANAGER) >>= xLayoutManager;
     335           0 :         if (xLayoutManager.is())
     336             :         {
     337           0 :             if ( !xLayoutManager->isVisible() )
     338           0 :                 return;
     339           0 :         }
     340             :     }
     341             : 
     342             :     // Ok the window should be made visible ... because it isnt 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           0 :     bool bHiddenDoc = false;
     349           0 :     if (xFrame.is())
     350             :     {
     351           0 :         css::uno::Reference< css::frame::XController > xController;
     352           0 :         css::uno::Reference< css::frame::XModel >      xModel;
     353           0 :         xController = xFrame->getController();
     354           0 :         if (xController.is())
     355           0 :             xModel = xController->getModel();
     356           0 :         if (xModel.is())
     357             :         {
     358           0 :             utl::MediaDescriptor lDocArgs(xModel->getArgs());
     359             :             bHiddenDoc = lDocArgs.getUnpackedValueOrDefault(
     360           0 :                 utl::MediaDescriptor::PROP_HIDDEN(),
     361           0 :                 sal_False);
     362           0 :         }
     363             :     }
     364             : 
     365           0 :     if (bHiddenDoc)
     366           0 :         return;
     367             : 
     368             :     // OK: The document was not opened in hidden mode ...
     369             :     // and the window isnt 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           0 :     impl_showProgress();
     374             : 
     375           0 :     SolarMutexGuard aSolarGuard;
     376           0 :     Window* pWindow = VCLUnoHelper::GetWindow(xParentWindow);
     377           0 :     if ( pWindow )
     378             :     {
     379           0 :         bool bForceFrontAndFocus(officecfg::Office::Common::View::NewDocumentHandling::ForceFocusAndToFront::get(xContext));
     380           0 :         pWindow->Show(true, bForceFrontAndFocus ? SHOW_FOREGROUNDTASK : 0 );
     381           0 :     }
     382             : 
     383             : }
     384             : 
     385           0 : void StatusIndicatorFactory::impl_createProgress()
     386             : {
     387             :     // SAFE -> ----------------------------------
     388           0 :     osl::ClearableMutexGuard aReadLock(m_mutex);
     389             : 
     390           0 :     css::uno::Reference< css::frame::XFrame >              xFrame (m_xFrame.get()      , css::uno::UNO_QUERY);
     391           0 :     css::uno::Reference< css::awt::XWindow >               xWindow(m_xPluggWindow.get(), css::uno::UNO_QUERY);
     392             : 
     393           0 :     aReadLock.clear();
     394             :     // <- SAFE ----------------------------------
     395             : 
     396           0 :     css::uno::Reference< css::task::XStatusIndicator > xProgress;
     397             : 
     398           0 :     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           0 :     else if (xFrame.is())
     405             :     {
     406             :         // use frame layouted progress implementation
     407           0 :         css::uno::Reference< css::beans::XPropertySet > xPropSet(xFrame, css::uno::UNO_QUERY);
     408           0 :         if (xPropSet.is())
     409             :         {
     410           0 :             css::uno::Reference< css::frame::XLayoutManager2 > xLayoutManager;
     411           0 :             xPropSet->getPropertyValue(FRAME_PROPNAME_LAYOUTMANAGER) >>= xLayoutManager;
     412           0 :             if (xLayoutManager.is())
     413             :             {
     414           0 :                 xLayoutManager->lock();
     415           0 :                 OUString sPROGRESS_RESOURCE(PROGRESS_RESOURCE);
     416           0 :                 xLayoutManager->createElement( sPROGRESS_RESOURCE );
     417           0 :                 xLayoutManager->hideElement( sPROGRESS_RESOURCE );
     418             : 
     419           0 :                 css::uno::Reference< css::ui::XUIElement > xProgressBar = xLayoutManager->getElement(sPROGRESS_RESOURCE);
     420           0 :                 if (xProgressBar.is())
     421           0 :                     xProgress = css::uno::Reference< css::task::XStatusIndicator >(xProgressBar->getRealInterface(), css::uno::UNO_QUERY);
     422           0 :                 xLayoutManager->unlock();
     423           0 :             }
     424           0 :         }
     425             :     }
     426             : 
     427           0 :     osl::MutexGuard g(m_mutex);
     428           0 :     m_xProgress = xProgress;
     429           0 : }
     430             : 
     431           0 : void StatusIndicatorFactory::impl_showProgress()
     432             : {
     433             :     // SAFE -> ----------------------------------
     434           0 :     osl::ClearableMutexGuard aReadLock(m_mutex);
     435             : 
     436           0 :     css::uno::Reference< css::frame::XFrame >              xFrame (m_xFrame.get()      , css::uno::UNO_QUERY);
     437           0 :     css::uno::Reference< css::awt::XWindow >               xWindow(m_xPluggWindow.get(), css::uno::UNO_QUERY);
     438             : 
     439           0 :     aReadLock.clear();
     440             :     // <- SAFE ----------------------------------
     441             : 
     442           0 :     css::uno::Reference< css::task::XStatusIndicator > xProgress;
     443             : 
     444           0 :     if (xFrame.is())
     445             :     {
     446             :         // use frame layouted progress implementation
     447           0 :         css::uno::Reference< css::beans::XPropertySet > xPropSet(xFrame, css::uno::UNO_QUERY);
     448           0 :         if (xPropSet.is())
     449             :         {
     450           0 :             css::uno::Reference< css::frame::XLayoutManager2 > xLayoutManager;
     451           0 :             xPropSet->getPropertyValue(FRAME_PROPNAME_LAYOUTMANAGER) >>= xLayoutManager;
     452           0 :             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           0 :                 OUString sPROGRESS_RESOURCE(PROGRESS_RESOURCE);
     458           0 :                 xLayoutManager->createElement( sPROGRESS_RESOURCE );
     459           0 :                 xLayoutManager->showElement( sPROGRESS_RESOURCE );
     460             : 
     461           0 :                 css::uno::Reference< css::ui::XUIElement > xProgressBar = xLayoutManager->getElement(sPROGRESS_RESOURCE);
     462           0 :                 if (xProgressBar.is())
     463           0 :                     xProgress = css::uno::Reference< css::task::XStatusIndicator >(xProgressBar->getRealInterface(), css::uno::UNO_QUERY);
     464           0 :             }
     465             :         }
     466             : 
     467           0 :         osl::MutexGuard g(m_mutex);
     468           0 :         m_xProgress = xProgress;
     469           0 :     }
     470           0 : }
     471             : 
     472           0 : void StatusIndicatorFactory::impl_hideProgress()
     473             : {
     474             :     // SAFE -> ----------------------------------
     475           0 :     osl::ClearableMutexGuard aReadLock(m_mutex);
     476             : 
     477           0 :     css::uno::Reference< css::frame::XFrame >              xFrame (m_xFrame.get()      , css::uno::UNO_QUERY);
     478           0 :     css::uno::Reference< css::awt::XWindow >               xWindow(m_xPluggWindow.get(), css::uno::UNO_QUERY);
     479             : 
     480           0 :     aReadLock.clear();
     481             :     // <- SAFE ----------------------------------
     482             : 
     483           0 :     if (xFrame.is())
     484             :     {
     485             :         // use frame layouted progress implementation
     486           0 :         css::uno::Reference< css::beans::XPropertySet > xPropSet(xFrame, css::uno::UNO_QUERY);
     487           0 :         if (xPropSet.is())
     488             :         {
     489           0 :             css::uno::Reference< css::frame::XLayoutManager2 > xLayoutManager;
     490           0 :             xPropSet->getPropertyValue(FRAME_PROPNAME_LAYOUTMANAGER) >>= xLayoutManager;
     491           0 :             if (xLayoutManager.is())
     492           0 :                 xLayoutManager->hideElement( OUString(PROGRESS_RESOURCE) );
     493           0 :         }
     494           0 :     }
     495           0 : }
     496             : 
     497           0 : void StatusIndicatorFactory::impl_reschedule(bool bForce)
     498             : {
     499             :     // SAFE ->
     500           0 :     osl::ClearableMutexGuard aReadLock(m_mutex);
     501           0 :     if (m_bDisableReschedule)
     502           0 :         return;
     503           0 :     aReadLock.clear();
     504             :     // <- SAFE
     505             : 
     506           0 :     bool bReschedule = bForce;
     507           0 :     if (!bReschedule)
     508             :     {
     509           0 :         osl::MutexGuard g(m_mutex);
     510           0 :         bReschedule        = m_bAllowReschedule;
     511           0 :         m_bAllowReschedule = false;
     512             :     }
     513             : 
     514           0 :     if (!bReschedule)
     515           0 :         return;
     516             : 
     517             :     // SAFE ->
     518           0 :     osl::ResettableMutexGuard aGlobalLock(LockHelper::getGlobalLock());
     519             : 
     520           0 :     if (m_nInReschedule == 0)
     521             :     {
     522           0 :         ++m_nInReschedule;
     523           0 :         aGlobalLock.clear();
     524             :         // <- SAFE
     525             : 
     526             :         {
     527           0 :             SolarMutexGuard g;
     528           0 :             Application::Reschedule(true);
     529             :         }
     530             : 
     531             :         // SAFE ->
     532           0 :         aGlobalLock.reset();
     533           0 :         --m_nInReschedule;
     534           0 :     }
     535             : }
     536             : 
     537           0 : void StatusIndicatorFactory::impl_startWakeUpThread()
     538             : {
     539           0 :     osl::MutexGuard g(m_mutex);
     540             : 
     541           0 :     if (m_bDisableReschedule)
     542           0 :         return;
     543             : 
     544           0 :     if (!m_pWakeUp)
     545             :     {
     546           0 :         m_pWakeUp = new WakeUpThread(this);
     547           0 :         m_pWakeUp->create();
     548           0 :     }
     549             : }
     550             : 
     551           0 : void StatusIndicatorFactory::impl_stopWakeUpThread()
     552             : {
     553           0 :     osl::MutexGuard g(m_mutex);
     554           0 :     if (m_pWakeUp)
     555             :     {
     556             :         // Thread kill itself after terminate()!
     557           0 :         m_pWakeUp->terminate();
     558           0 :         m_pWakeUp = 0;
     559           0 :     }
     560           0 : }
     561             : 
     562             : } // namespace framework
     563             : 
     564             : extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
     565           0 : com_sun_star_comp_framework_StatusIndicatorFactory_get_implementation(
     566             :     css::uno::XComponentContext *context,
     567             :     css::uno::Sequence<css::uno::Any> const &)
     568             : {
     569           0 :     return cppu::acquire(new framework::StatusIndicatorFactory(context));
     570             : }
     571             : 
     572             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10