LCOV - code coverage report
Current view: top level - framework/source/helper - statusindicatorfactory.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 238 266 89.5 %
Date: 2012-08-25 Functions: 25 31 80.6 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 285 656 43.4 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <algorithm>
      30                 :            : #include <helper/statusindicatorfactory.hxx>
      31                 :            : #include <helper/statusindicator.hxx>
      32                 :            : #include <helper/vclstatusindicator.hxx>
      33                 :            : #include <threadhelp/writeguard.hxx>
      34                 :            : #include <threadhelp/readguard.hxx>
      35                 :            : #include <services.h>
      36                 :            : #include <properties.h>
      37                 :            : 
      38                 :            : #include <com/sun/star/awt/Rectangle.hpp>
      39                 :            : 
      40                 :            : #include <com/sun/star/awt/XControl.hpp>
      41                 :            : #include <com/sun/star/awt/XLayoutConstrains.hpp>
      42                 :            : #include <com/sun/star/awt/DeviceInfo.hpp>
      43                 :            : #include <com/sun/star/awt/PosSize.hpp>
      44                 :            : #include <com/sun/star/awt/WindowAttribute.hpp>
      45                 :            : #include <com/sun/star/awt/XTopWindow.hpp>
      46                 :            : #include <com/sun/star/awt/XWindow2.hpp>
      47                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      48                 :            : #include <com/sun/star/frame/XLayoutManager.hpp>
      49                 :            : 
      50                 :            : #include <toolkit/unohlp.hxx>
      51                 :            : 
      52                 :            : #include <comphelper/sequenceashashmap.hxx>
      53                 :            : #include <comphelper/mediadescriptor.hxx>
      54                 :            : #include <comphelper/configurationhelper.hxx>
      55                 :            : #include <vcl/svapp.hxx>
      56                 :            : #include <osl/mutex.hxx>
      57                 :            : 
      58                 :            : 
      59                 :            : namespace framework{
      60                 :            : 
      61                 :            : 
      62                 :            : sal_Int32 StatusIndicatorFactory::m_nInReschedule = 0;  /// static counter for rescheduling
      63                 :            : const char PROGRESS_RESOURCE[] = "private:resource/progressbar/progressbar";
      64                 :            : 
      65                 :            : //-----------------------------------------------
      66 [ +  + ][ +  - ]:     193833 : DEFINE_XINTERFACE_5(StatusIndicatorFactory                              ,
      67                 :            :                     OWeakObject                                         ,
      68                 :            :                     DIRECT_INTERFACE(css::lang::XTypeProvider          ),
      69                 :            :                     DIRECT_INTERFACE(css::lang::XServiceInfo           ),
      70                 :            :                     DIRECT_INTERFACE(css::lang::XInitialization        ),
      71                 :            :                     DIRECT_INTERFACE(css::task::XStatusIndicatorFactory),
      72                 :            :                     DIRECT_INTERFACE(css::util::XUpdatable             ))
      73                 :            : 
      74 [ #  # ][ #  # ]:          0 : DEFINE_XTYPEPROVIDER_5(StatusIndicatorFactory            ,
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
      75                 :            :                        css::lang::XTypeProvider          ,
      76                 :            :                        css::lang::XServiceInfo           ,
      77                 :            :                        css::lang::XInitialization        ,
      78                 :            :                        css::task::XStatusIndicatorFactory,
      79                 :            :                        css::util::XUpdatable             )
      80                 :            : 
      81 [ +  - ][ +  - ]:       3040 : DEFINE_XSERVICEINFO_MULTISERVICE(StatusIndicatorFactory                   ,
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ #  # ][ #  # ]
      82                 :            :                                  ::cppu::OWeakObject                      ,
      83                 :            :                                  SERVICENAME_STATUSINDICATORFACTORY       ,
      84                 :            :                                  IMPLEMENTATIONNAME_STATUSINDICATORFACTORY)
      85                 :            : 
      86                 :       1747 : DEFINE_INIT_SERVICE(StatusIndicatorFactory,
      87                 :            :                     {
      88                 :            :                         /*Attention
      89                 :            :                             I think we don't need any mutex or lock here ... because we are called by our own static method impl_createInstance()
      90                 :            :                             to create a new instance of this class by our own supported service factory.
      91                 :            :                             see macro DEFINE_XSERVICEINFO_MULTISERVICE and "impl_initService()" for further informations!
      92                 :            :                         */
      93                 :            :                     }
      94                 :            :                    )
      95                 :            : 
      96                 :            : //-----------------------------------------------
      97                 :       1747 : StatusIndicatorFactory::StatusIndicatorFactory(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR)
      98                 :            :     : ThreadHelpBase      (         )
      99                 :            :     , ::cppu::OWeakObject (         )
     100                 :            :     , m_xSMGR             (xSMGR    )
     101                 :            :     , m_pWakeUp           (0        )
     102                 :            :     , m_bAllowReschedule  (sal_False)
     103                 :            :     , m_bAllowParentShow  (sal_False)
     104 [ +  - ][ +  - ]:       1747 :     , m_bDisableReschedule(sal_False)
         [ +  - ][ +  - ]
     105                 :            : {
     106                 :       1747 : }
     107                 :            : 
     108                 :            : //-----------------------------------------------
     109 [ +  - ][ +  - ]:       1656 : StatusIndicatorFactory::~StatusIndicatorFactory()
         [ +  - ][ +  - ]
     110                 :            : {
     111         [ +  - ]:       1656 :     impl_stopWakeUpThread();
     112         [ -  + ]:       3312 : }
     113                 :            : 
     114                 :            : //-----------------------------------------------
     115                 :       1747 : void SAL_CALL StatusIndicatorFactory::initialize(const css::uno::Sequence< css::uno::Any >& lArguments)
     116                 :            :     throw(css::uno::Exception       ,
     117                 :            :           css::uno::RuntimeException)
     118                 :            : {
     119         [ +  - ]:       1747 :     ::comphelper::SequenceAsHashMap lArgs(lArguments);
     120                 :            : 
     121                 :            :     // SAFE -> ----------------------------------
     122         [ +  - ]:       1747 :     WriteGuard aWriteLock(m_aLock);
     123                 :            : 
     124 [ +  - ][ +  - ]:       1747 :     m_xFrame             = lArgs.getUnpackedValueOrDefault(STATUSINDICATORFACTORY_PROPNAME_FRAME            , css::uno::Reference< css::frame::XFrame >());
                 [ +  - ]
     125 [ +  - ][ +  - ]:       1747 :     m_xPluggWindow       = lArgs.getUnpackedValueOrDefault(STATUSINDICATORFACTORY_PROPNAME_WINDOW           , css::uno::Reference< css::awt::XWindow >() );
                 [ +  - ]
     126 [ +  - ][ +  - ]:       1747 :     m_bAllowParentShow   = lArgs.getUnpackedValueOrDefault(STATUSINDICATORFACTORY_PROPNAME_ALLOWPARENTSHOW  , (sal_Bool)sal_False                        );
     127 [ +  - ][ +  - ]:       1747 :     m_bDisableReschedule = lArgs.getUnpackedValueOrDefault(STATUSINDICATORFACTORY_PROPNAME_DISABLERESCHEDULE, (sal_Bool)sal_False                        );
     128                 :            : 
     129         [ +  - ]:       1747 :     aWriteLock.unlock();
     130                 :            :     // <- SAFE ----------------------------------
     131                 :            : 
     132 [ +  - ][ +  - ]:       1747 :     impl_createProgress();
                 [ +  - ]
     133                 :       1747 : }
     134                 :            : 
     135                 :            : //-----------------------------------------------
     136                 :       1743 : css::uno::Reference< css::task::XStatusIndicator > SAL_CALL StatusIndicatorFactory::createStatusIndicator()
     137                 :            :     throw(css::uno::RuntimeException)
     138                 :            : {
     139         [ +  - ]:       1743 :     StatusIndicator* pIndicator = new StatusIndicator(this);
     140         [ +  - ]:       1743 :     css::uno::Reference< css::task::XStatusIndicator > xIndicator(static_cast< ::cppu::OWeakObject* >(pIndicator), css::uno::UNO_QUERY_THROW);
     141                 :            : 
     142                 :       1743 :     return xIndicator;
     143                 :            : }
     144                 :            : 
     145                 :            : //-----------------------------------------------
     146                 :       6602 : void SAL_CALL StatusIndicatorFactory::update()
     147                 :            :     throw(css::uno::RuntimeException)
     148                 :            : {
     149                 :            :     // SAFE -> ----------------------------------
     150         [ +  - ]:       6602 :     WriteGuard aWriteLock(m_aLock);
     151                 :       6602 :     m_bAllowReschedule = sal_True;
     152 [ +  - ][ +  - ]:       6602 :     aWriteLock.unlock();
     153                 :            :     // <- SAFE ----------------------------------
     154                 :       6602 : }
     155                 :            : 
     156                 :            : //-----------------------------------------------
     157                 :        432 : void StatusIndicatorFactory::start(const css::uno::Reference< css::task::XStatusIndicator >& xChild,
     158                 :            :                                    const ::rtl::OUString&                                    sText ,
     159                 :            :                                          sal_Int32                                           nRange)
     160                 :            : {
     161                 :            :     // SAFE -> ----------------------------------
     162         [ +  - ]:        432 :     WriteGuard aWriteLock(m_aLock);
     163                 :            : 
     164                 :            :     // create new info structure for this child or move it to the front of our stack
     165         [ +  - ]:        432 :     IndicatorStack::iterator pItem = ::std::find(m_aStack.begin(), m_aStack.end(), xChild);
     166 [ +  - ][ +  + ]:        432 :     if (pItem != m_aStack.end())
     167         [ +  - ]:         21 :         m_aStack.erase(pItem);
     168         [ +  - ]:        432 :     IndicatorInfo aInfo(xChild, sText, nRange);
     169         [ +  - ]:        432 :     m_aStack.push_back (aInfo                );
     170                 :            : 
     171         [ +  - ]:        432 :     m_xActiveChild = xChild;
     172                 :        432 :     css::uno::Reference< css::task::XStatusIndicator > xProgress = m_xProgress;
     173                 :            : 
     174         [ +  - ]:        432 :     aWriteLock.unlock();
     175                 :            :     // <- SAFE ----------------------------------
     176                 :            : 
     177         [ +  - ]:        432 :     implts_makeParentVisibleIfAllowed();
     178                 :            : 
     179         [ +  - ]:        432 :     if (xProgress.is())
     180 [ +  - ][ +  - ]:        432 :         xProgress->start(sText, nRange);
     181                 :            : 
     182         [ +  - ]:        432 :     impl_startWakeUpThread();
     183 [ +  - ][ +  - ]:        432 :     impl_reschedule(sal_True);
                 [ +  - ]
     184                 :        432 : }
     185                 :            : 
     186                 :            : //-----------------------------------------------
     187                 :         76 : void StatusIndicatorFactory::reset(const css::uno::Reference< css::task::XStatusIndicator >& xChild)
     188                 :            : {
     189                 :            :     // SAFE -> ----------------------------------
     190         [ +  - ]:         76 :     ReadGuard aReadLock(m_aLock);
     191                 :            : 
     192                 :            :     // reset the internal info structure related to this child
     193         [ +  - ]:         76 :     IndicatorStack::iterator pItem = ::std::find(m_aStack.begin(), m_aStack.end(), xChild);
     194 [ +  - ][ +  - ]:         76 :     if (pItem != m_aStack.end())
     195                 :            :     {
     196                 :         76 :         pItem->m_nValue = 0;
     197                 :         76 :         pItem->m_sText  = ::rtl::OUString();
     198                 :            :     }
     199                 :            : 
     200                 :         76 :     css::uno::Reference< css::task::XStatusIndicator > xActive   = m_xActiveChild;
     201                 :         76 :     css::uno::Reference< css::task::XStatusIndicator > xProgress = m_xProgress;
     202                 :            : 
     203         [ +  - ]:         76 :     aReadLock.unlock();
     204                 :            :     // <- SAFE ----------------------------------
     205                 :            : 
     206                 :            :     // not the top most child => dont change UI
     207                 :            :     // But dont forget Reschedule!
     208   [ +  -  +  - ]:        152 :     if (
                 [ +  - ]
     209         [ +  - ]:         76 :         (xChild == xActive) &&
     210                 :         76 :         (xProgress.is()   )
     211                 :            :        )
     212 [ +  - ][ +  - ]:         76 :         xProgress->reset();
     213                 :            : 
     214 [ +  - ][ +  - ]:         76 :     impl_reschedule(sal_True);
     215                 :         76 : }
     216                 :            : 
     217                 :            : //-----------------------------------------------
     218                 :        439 : void StatusIndicatorFactory::end(const css::uno::Reference< css::task::XStatusIndicator >& xChild)
     219                 :            : {
     220                 :            :     // SAFE -> ----------------------------------
     221         [ +  - ]:        439 :     WriteGuard aWriteLock(m_aLock);
     222                 :            : 
     223                 :            :     // remove this child from our stack
     224         [ +  - ]:        439 :     IndicatorStack::iterator pItem = ::std::find(m_aStack.begin(), m_aStack.end(), xChild);
     225 [ +  - ][ +  + ]:        439 :     if (pItem != m_aStack.end())
     226         [ +  - ]:        411 :         m_aStack.erase(pItem);
     227                 :            : 
     228                 :            :     // activate next child ... or finish the progress if there is no further one.
     229                 :        439 :     m_xActiveChild.clear();
     230                 :        439 :     ::rtl::OUString                  sText;
     231                 :        439 :     sal_Int32                        nValue = 0;
     232                 :        439 :     IndicatorStack::reverse_iterator pNext  = m_aStack.rbegin();
     233 [ -  + ][ +  - ]:        439 :     if (pNext != m_aStack.rend())
     234                 :            :     {
     235 [ #  # ][ #  # ]:          0 :         m_xActiveChild = pNext->m_xIndicator;
     236         [ #  # ]:          0 :         sText          = pNext->m_sText;
     237         [ #  # ]:          0 :         nValue         = pNext->m_nValue;
     238                 :            :     }
     239                 :            : 
     240                 :        439 :     css::uno::Reference< css::task::XStatusIndicator > xActive   = m_xActiveChild;
     241                 :        439 :     css::uno::Reference< css::task::XStatusIndicator > xProgress = m_xProgress;
     242                 :            : 
     243         [ +  - ]:        439 :     aWriteLock.unlock();
     244                 :            :     // <- SAFE ----------------------------------
     245                 :            : 
     246         [ -  + ]:        439 :     if (xActive.is())
     247                 :            :     {
     248                 :            :         // There is at least one further child indicator.
     249                 :            :         // Actualize our progress, so it shows these values from now.
     250         [ #  # ]:          0 :         if (xProgress.is())
     251                 :            :         {
     252 [ #  # ][ #  # ]:          0 :             xProgress->setText (sText );
     253 [ #  # ][ #  # ]:          0 :             xProgress->setValue(nValue);
     254                 :            :         }
     255                 :            :     }
     256                 :            :     else
     257                 :            :     {
     258                 :            :         // Our stack is empty. No further child exists.
     259                 :            :         // Se we must "end" our progress realy
     260         [ +  - ]:        439 :         if (xProgress.is())
     261 [ +  - ][ +  - ]:        439 :             xProgress->end();
     262                 :            :         // Now hide the progress bar again.
     263         [ +  - ]:        439 :         impl_hideProgress();
     264                 :            : 
     265         [ +  - ]:        439 :         impl_stopWakeUpThread();
     266                 :            :     }
     267                 :            : 
     268 [ +  - ][ +  - ]:        439 :     impl_reschedule(sal_True);
     269                 :        439 : }
     270                 :            : 
     271                 :            : //-----------------------------------------------
     272                 :          0 : void StatusIndicatorFactory::setText(const css::uno::Reference< css::task::XStatusIndicator >& xChild,
     273                 :            :                                      const ::rtl::OUString&                                    sText )
     274                 :            : {
     275                 :            :     // SAFE -> ----------------------------------
     276         [ #  # ]:          0 :     WriteGuard aWriteLock(m_aLock);
     277                 :            : 
     278         [ #  # ]:          0 :     IndicatorStack::iterator pItem = ::std::find(m_aStack.begin(), m_aStack.end(), xChild);
     279 [ #  # ][ #  # ]:          0 :     if (pItem != m_aStack.end())
     280                 :          0 :         pItem->m_sText = sText;
     281                 :            : 
     282                 :          0 :     css::uno::Reference< css::task::XStatusIndicator > xActive   = m_xActiveChild;
     283                 :          0 :     css::uno::Reference< css::task::XStatusIndicator > xProgress = m_xProgress;
     284                 :            : 
     285         [ #  # ]:          0 :     aWriteLock.unlock();
     286                 :            :     // SAFE -> ----------------------------------
     287                 :            : 
     288                 :            :     // paint only the top most indicator
     289                 :            :     // but dont forget to Reschedule!
     290   [ #  #  #  # ]:          0 :     if (
                 [ #  # ]
     291         [ #  # ]:          0 :         (xChild == xActive) &&
     292                 :          0 :         (xProgress.is()   )
     293                 :            :        )
     294                 :            :     {
     295 [ #  # ][ #  # ]:          0 :         xProgress->setText(sText);
     296                 :            :     }
     297                 :            : 
     298 [ #  # ][ #  # ]:          0 :     impl_reschedule(sal_True);
     299                 :          0 : }
     300                 :            : 
     301                 :            : //-----------------------------------------------
     302                 :      14258 : void StatusIndicatorFactory::setValue( const css::uno::Reference< css::task::XStatusIndicator >& xChild ,
     303                 :            :                                              sal_Int32                                           nValue )
     304                 :            : {
     305                 :            :     // SAFE -> ----------------------------------
     306         [ +  - ]:      14258 :     WriteGuard aWriteLock(m_aLock);
     307                 :            : 
     308                 :      14258 :     sal_Int32 nOldValue = 0;
     309         [ +  - ]:      14258 :     IndicatorStack::iterator pItem = ::std::find(m_aStack.begin(), m_aStack.end(), xChild);
     310 [ +  - ][ +  - ]:      14258 :     if (pItem != m_aStack.end())
     311                 :            :     {
     312                 :      14258 :         nOldValue       = pItem->m_nValue;
     313                 :      14258 :         pItem->m_nValue = nValue;
     314                 :            :     }
     315                 :            : 
     316                 :      14258 :     css::uno::Reference< css::task::XStatusIndicator > xActive    = m_xActiveChild;
     317                 :      14258 :     css::uno::Reference< css::task::XStatusIndicator > xProgress  = m_xProgress;
     318                 :            : 
     319         [ +  - ]:      14258 :     aWriteLock.unlock();
     320                 :            :     // SAFE -> ----------------------------------
     321                 :            : 
     322         [ +  - ]:      27556 :     if (
           [ +  +  +  - ]
                 [ +  + ]
     323         [ +  - ]:      14258 :         (xChild    == xActive) &&
     324                 :            :         (nOldValue != nValue ) &&
     325                 :      13298 :         (xProgress.is()      )
     326                 :            :        )
     327                 :            :     {
     328 [ +  - ][ +  - ]:      13298 :         xProgress->setValue(nValue);
     329                 :            :     }
     330                 :            : 
     331 [ +  - ][ +  - ]:      14258 :     impl_reschedule(sal_False);
     332                 :      14258 : }
     333                 :            : 
     334                 :            : //-----------------------------------------------
     335                 :        432 : void StatusIndicatorFactory::implts_makeParentVisibleIfAllowed()
     336                 :            : {
     337                 :            :     // SAFE -> ----------------------------------
     338         [ +  - ]:        432 :     ReadGuard aReadLock(m_aLock);
     339                 :            : 
     340         [ -  + ]:        432 :     if (!m_bAllowParentShow)
     341                 :            :         return;
     342                 :            : 
     343 [ +  - ][ +  - ]:        432 :     css::uno::Reference< css::frame::XFrame > xFrame      (m_xFrame.get()      , css::uno::UNO_QUERY);
     344 [ +  - ][ +  - ]:        432 :     css::uno::Reference< css::awt::XWindow >  xPluggWindow(m_xPluggWindow.get(), css::uno::UNO_QUERY);
     345 [ +  - ][ +  - ]:        432 :     css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR( m_xSMGR.get(), css::uno::UNO_QUERY);
     346                 :            : 
     347         [ +  - ]:        432 :     aReadLock.unlock();
     348                 :            :     // <- SAFE ----------------------------------
     349                 :            : 
     350                 :        432 :     css::uno::Reference< css::awt::XWindow > xParentWindow;
     351         [ +  - ]:        432 :     if (xFrame.is())
     352 [ +  - ][ +  - ]:        432 :         xParentWindow = xFrame->getContainerWindow();
                 [ +  - ]
     353                 :            :     else
     354         [ #  # ]:          0 :         xParentWindow = xPluggWindow;
     355                 :            : 
     356                 :            :     // dont disturb user in case he put the loading document into the background!
     357                 :            :     // Supress any setVisible() or toFront() call in case the initial show was
     358                 :            :     // already made.
     359         [ +  - ]:        432 :     css::uno::Reference< css::awt::XWindow2 > xVisibleCheck(xParentWindow, css::uno::UNO_QUERY);
     360                 :        432 :     sal_Bool bIsVisible = sal_False;
     361         [ +  - ]:        432 :     if (xVisibleCheck.is())
     362 [ +  - ][ +  - ]:        432 :         bIsVisible = xVisibleCheck->isVisible();
     363                 :            : 
     364         [ +  + ]:        432 :     if (bIsVisible)
     365                 :            :     {
     366         [ +  - ]:         27 :         impl_showProgress();
     367                 :            :         return;
     368                 :            :     }
     369                 :            : 
     370                 :            :     // Check if the layout manager has been set to invisible state. It this case we are also
     371                 :            :     // not allowed to set the frame visible!
     372         [ +  - ]:        405 :     css::uno::Reference< css::beans::XPropertySet > xPropSet(xFrame, css::uno::UNO_QUERY);
     373         [ +  - ]:        405 :     if (xPropSet.is())
     374                 :            :     {
     375                 :        405 :         css::uno::Reference< css::frame::XLayoutManager > xLayoutManager;
     376 [ +  - ][ +  - ]:        405 :         xPropSet->getPropertyValue(FRAME_PROPNAME_LAYOUTMANAGER) >>= xLayoutManager;
         [ +  - ][ +  - ]
     377         [ +  - ]:        405 :         if (xLayoutManager.is())
     378                 :            :         {
     379 [ +  - ][ +  - ]:        405 :             if ( !xLayoutManager->isVisible() )
                 [ -  + ]
     380                 :            :                 return;
     381         [ +  - ]:        405 :         }
     382                 :            :     }
     383                 :            : 
     384                 :            :     // Ok the window should be made visible ... becuase it isnt currently visible.
     385                 :            :     // BUT ..!
     386                 :            :     // We need a Hack for our applications: They get her progress from the frame directly
     387                 :            :     // on saving documents. Because there is no progress set on the MediaDescriptor.
     388                 :            :     // But that's wrong. In case the document was opened hidden, they shouldnt use any progress .-(
     389                 :            :     // They only possible workaround: dont show the parent window here, if the document was opened hidden.
     390                 :        405 :     sal_Bool bHiddenDoc = sal_False;
     391         [ +  - ]:        405 :     if (xFrame.is())
     392                 :            :     {
     393                 :        405 :         css::uno::Reference< css::frame::XController > xController;
     394                 :        405 :         css::uno::Reference< css::frame::XModel >      xModel     ;
     395 [ +  - ][ +  - ]:        405 :         xController = xFrame->getController();
                 [ +  - ]
     396         [ -  + ]:        405 :         if (xController.is())
     397 [ #  # ][ #  # ]:          0 :             xModel = xController->getModel();
                 [ #  # ]
     398         [ -  + ]:        405 :         if (xModel.is())
     399                 :            :         {
     400 [ #  # ][ #  # ]:          0 :             ::comphelper::MediaDescriptor lDocArgs(xModel->getArgs());
         [ #  # ][ #  # ]
     401                 :            :             bHiddenDoc = lDocArgs.getUnpackedValueOrDefault(
     402         [ #  # ]:          0 :                 ::comphelper::MediaDescriptor::PROP_HIDDEN(),
     403 [ #  # ][ #  # ]:          0 :                 (sal_Bool)sal_False);
     404                 :        405 :         }
     405                 :            :     }
     406                 :            : 
     407         [ -  + ]:        405 :     if (bHiddenDoc)
     408                 :            :         return;
     409                 :            : 
     410                 :            :     // OK: The document was not opened in hidden mode ...
     411                 :            :     // and the window isnt already visible.
     412                 :            :     // Show it and bring it to front.
     413                 :            :     // But before we have to be sure, that our internal used helper progress
     414                 :            :     // is visible too.
     415         [ +  - ]:        405 :     impl_showProgress();
     416                 :            : 
     417         [ +  - ]:        405 :     SolarMutexGuard aSolarGuard;
     418         [ +  - ]:        405 :     Window* pWindow = VCLUnoHelper::GetWindow(xParentWindow);
     419         [ +  - ]:        405 :     if ( pWindow )
     420                 :            :     {
     421                 :        405 :         bool bForceFrontAndFocus(false);
     422                 :            :         ::comphelper::ConfigurationHelper::readDirectKey(
     423                 :            :             xSMGR,
     424                 :            :             ::rtl::OUString("org.openoffice.Office.Common/View"),
     425                 :            :             ::rtl::OUString("NewDocumentHandling"),
     426                 :            :             ::rtl::OUString("ForceFocusAndToFront"),
     427         [ +  - ]:        405 :             ::comphelper::ConfigurationHelper::E_READONLY) >>= bForceFrontAndFocus;
     428                 :            : 
     429 [ +  - ][ +  + ]:        405 :         pWindow->Show(sal_True, bForceFrontAndFocus ? SHOW_FOREGROUNDTASK : 0 );
     430 [ +  - ][ -  + ]:        432 :     }
         [ +  + ][ +  + ]
         [ +  + ][ +  + ]
         [ +  + ][ +  - ]
                 [ +  + ]
     431                 :            : 
     432                 :            : }
     433                 :            : 
     434                 :            : //-----------------------------------------------
     435                 :       1747 : void StatusIndicatorFactory::impl_createProgress()
     436                 :            : {
     437                 :            :     // SAFE -> ----------------------------------
     438         [ +  - ]:       1747 :     ReadGuard aReadLock(m_aLock);
     439                 :            : 
     440 [ +  - ][ +  - ]:       1747 :     css::uno::Reference< css::frame::XFrame >              xFrame (m_xFrame.get()      , css::uno::UNO_QUERY);
     441 [ +  - ][ +  - ]:       1747 :     css::uno::Reference< css::awt::XWindow >               xWindow(m_xPluggWindow.get(), css::uno::UNO_QUERY);
     442                 :       1747 :     css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR  = m_xSMGR;
     443                 :            : 
     444         [ +  - ]:       1747 :     aReadLock.lock();
     445                 :            :     // <- SAFE ----------------------------------
     446                 :            : 
     447                 :       1747 :     css::uno::Reference< css::task::XStatusIndicator > xProgress;
     448                 :            : 
     449         [ -  + ]:       1747 :     if (xWindow.is())
     450                 :            :     {
     451                 :            :         // use vcl based progress implementation in plugged mode
     452         [ #  # ]:          0 :         VCLStatusIndicator* pVCLProgress = new VCLStatusIndicator(xSMGR, xWindow);
     453 [ #  # ][ #  # ]:          0 :         xProgress = css::uno::Reference< css::task::XStatusIndicator >(static_cast< css::task::XStatusIndicator* >(pVCLProgress), css::uno::UNO_QUERY);
     454                 :            :     }
     455                 :            :     else
     456         [ +  - ]:       1747 :     if (xFrame.is())
     457                 :            :     {
     458                 :            :         // use frame layouted progress implementation
     459         [ +  - ]:       1747 :         css::uno::Reference< css::beans::XPropertySet > xPropSet(xFrame, css::uno::UNO_QUERY);
     460         [ +  - ]:       1747 :         if (xPropSet.is())
     461                 :            :         {
     462                 :       1747 :             css::uno::Reference< css::frame::XLayoutManager > xLayoutManager;
     463 [ +  - ][ +  - ]:       1747 :             xPropSet->getPropertyValue(FRAME_PROPNAME_LAYOUTMANAGER) >>= xLayoutManager;
         [ +  - ][ +  - ]
     464         [ +  - ]:       1747 :             if (xLayoutManager.is())
     465                 :            :             {
     466 [ +  - ][ +  - ]:       1747 :                 xLayoutManager->lock();
     467                 :       1747 :                 rtl::OUString sPROGRESS_RESOURCE(PROGRESS_RESOURCE);
     468 [ +  - ][ +  - ]:       1747 :                 xLayoutManager->createElement( sPROGRESS_RESOURCE );
     469 [ +  - ][ +  - ]:       1747 :                 xLayoutManager->hideElement( sPROGRESS_RESOURCE );
     470                 :            : 
     471 [ +  - ][ +  - ]:       1747 :                 css::uno::Reference< css::ui::XUIElement > xProgressBar = xLayoutManager->getElement(sPROGRESS_RESOURCE);
     472         [ +  - ]:       1747 :                 if (xProgressBar.is())
     473 [ +  - ][ +  - ]:       1747 :                     xProgress = css::uno::Reference< css::task::XStatusIndicator >(xProgressBar->getRealInterface(), css::uno::UNO_QUERY);
         [ +  - ][ +  - ]
     474 [ +  - ][ +  - ]:       1747 :                 xLayoutManager->unlock();
     475                 :       1747 :             }
     476                 :       1747 :         }
     477                 :            :     }
     478                 :            : 
     479                 :            :     // SAFE -> ----------------------------------
     480         [ +  - ]:       1747 :     WriteGuard aWriteLock(m_aLock);
     481         [ +  - ]:       1747 :     m_xProgress = xProgress;
     482 [ +  - ][ +  - ]:       1747 :     aWriteLock.lock();
                 [ +  - ]
     483                 :            :     // <- SAFE ----------------------------------
     484                 :       1747 : }
     485                 :            : 
     486                 :            : //-----------------------------------------------
     487                 :        432 : void StatusIndicatorFactory::impl_showProgress()
     488                 :            : {
     489                 :            :     // SAFE -> ----------------------------------
     490         [ +  - ]:        432 :     ReadGuard aReadLock(m_aLock);
     491                 :            : 
     492 [ +  - ][ +  - ]:        432 :     css::uno::Reference< css::frame::XFrame >              xFrame (m_xFrame.get()      , css::uno::UNO_QUERY);
     493 [ +  - ][ +  - ]:        432 :     css::uno::Reference< css::awt::XWindow >               xWindow(m_xPluggWindow.get(), css::uno::UNO_QUERY);
     494                 :        432 :     css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR  = m_xSMGR;
     495                 :            : 
     496         [ +  - ]:        432 :     aReadLock.lock();
     497                 :            :     // <- SAFE ----------------------------------
     498                 :            : 
     499                 :        432 :     css::uno::Reference< css::task::XStatusIndicator > xProgress;
     500                 :            : 
     501         [ +  - ]:        432 :     if (xFrame.is())
     502                 :            :     {
     503                 :            :         // use frame layouted progress implementation
     504         [ +  - ]:        432 :         css::uno::Reference< css::beans::XPropertySet > xPropSet(xFrame, css::uno::UNO_QUERY);
     505         [ +  - ]:        432 :         if (xPropSet.is())
     506                 :            :         {
     507                 :        432 :             css::uno::Reference< css::frame::XLayoutManager > xLayoutManager;
     508 [ +  - ][ +  - ]:        432 :             xPropSet->getPropertyValue(FRAME_PROPNAME_LAYOUTMANAGER) >>= xLayoutManager;
         [ +  - ][ +  - ]
     509         [ +  - ]:        432 :             if (xLayoutManager.is())
     510                 :            :             {
     511                 :            :                 // Be sure that we have always a progress. It can be that our frame
     512                 :            :                 // was recycled and therefore the progress was destroyed!
     513                 :            :                 // CreateElement does nothing if there is already a valid progress.
     514                 :        432 :                 rtl::OUString sPROGRESS_RESOURCE(PROGRESS_RESOURCE);
     515 [ +  - ][ +  - ]:        432 :                 xLayoutManager->createElement( sPROGRESS_RESOURCE );
     516 [ +  - ][ +  - ]:        432 :                 xLayoutManager->showElement( sPROGRESS_RESOURCE );
     517                 :            : 
     518 [ +  - ][ +  - ]:        432 :                 css::uno::Reference< css::ui::XUIElement > xProgressBar = xLayoutManager->getElement(sPROGRESS_RESOURCE);
     519         [ +  - ]:        432 :                 if (xProgressBar.is())
     520 [ +  - ][ +  - ]:        432 :                     xProgress = css::uno::Reference< css::task::XStatusIndicator >(xProgressBar->getRealInterface(), css::uno::UNO_QUERY);
         [ +  - ][ +  - ]
     521                 :        432 :             }
     522                 :            :         }
     523                 :            : 
     524                 :            :         // SAFE -> ----------------------------------
     525         [ +  - ]:        432 :         WriteGuard aWriteLock(m_aLock);
     526         [ +  - ]:        432 :         m_xProgress = xProgress;
     527 [ +  - ][ +  - ]:        432 :         aWriteLock.lock();
     528                 :            :         // <- SAFE ----------------------------------
     529         [ +  - ]:        432 :     }
     530                 :        432 : }
     531                 :            : 
     532                 :            : //-----------------------------------------------
     533                 :        439 : void StatusIndicatorFactory::impl_hideProgress()
     534                 :            : {
     535                 :            :     // SAFE -> ----------------------------------
     536         [ +  - ]:        439 :     ReadGuard aReadLock(m_aLock);
     537                 :            : 
     538 [ +  - ][ +  - ]:        439 :     css::uno::Reference< css::frame::XFrame >              xFrame (m_xFrame.get()      , css::uno::UNO_QUERY);
     539 [ +  - ][ +  - ]:        439 :     css::uno::Reference< css::awt::XWindow >               xWindow(m_xPluggWindow.get(), css::uno::UNO_QUERY);
     540                 :        439 :     css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR  = m_xSMGR;
     541                 :            : 
     542         [ +  - ]:        439 :     aReadLock.lock();
     543                 :            :     // <- SAFE ----------------------------------
     544                 :            : 
     545         [ +  - ]:        439 :     if (xFrame.is())
     546                 :            :     {
     547                 :            :         // use frame layouted progress implementation
     548         [ +  - ]:        439 :         css::uno::Reference< css::beans::XPropertySet > xPropSet(xFrame, css::uno::UNO_QUERY);
     549         [ +  - ]:        439 :         if (xPropSet.is())
     550                 :            :         {
     551                 :        439 :             css::uno::Reference< css::frame::XLayoutManager > xLayoutManager;
     552 [ +  - ][ +  - ]:        439 :             xPropSet->getPropertyValue(FRAME_PROPNAME_LAYOUTMANAGER) >>= xLayoutManager;
         [ +  - ][ +  - ]
     553         [ +  - ]:        439 :             if (xLayoutManager.is())
     554 [ +  - ][ +  - ]:        439 :                 xLayoutManager->hideElement( rtl::OUString(PROGRESS_RESOURCE) );
     555                 :        439 :         }
     556         [ +  - ]:        439 :     }
     557                 :        439 : }
     558                 :            : 
     559                 :            : //-----------------------------------------------
     560                 :      15205 : void StatusIndicatorFactory::impl_reschedule(sal_Bool bForce)
     561                 :            : {
     562                 :            :     // SAFE ->
     563         [ +  - ]:      15205 :     ReadGuard aReadLock(m_aLock);
     564         [ -  + ]:      15205 :     if (m_bDisableReschedule)
     565                 :            :         return;
     566         [ +  - ]:      15205 :     aReadLock.unlock();
     567                 :            :     // <- SAFE
     568                 :            : 
     569                 :      15205 :     sal_Bool bReschedule = bForce;
     570         [ +  + ]:      15205 :     if (!bReschedule)
     571                 :            :     {
     572                 :            :         // SAFE ->
     573         [ +  - ]:      14258 :         WriteGuard aWriteLock(m_aLock);
     574                 :      14258 :         bReschedule        = m_bAllowReschedule;
     575                 :      14258 :         m_bAllowReschedule = sal_False;
     576 [ +  - ][ +  - ]:      14258 :         aWriteLock.unlock();
     577                 :            :         // <- SAFE
     578                 :            :     }
     579                 :            : 
     580         [ +  + ]:      15205 :     if (!bReschedule)
     581                 :            :         return;
     582                 :            : 
     583                 :            :     // SAFE ->
     584 [ +  - ][ +  - ]:       2355 :     WriteGuard aGlobalLock(LockHelper::getGlobalLock());
     585                 :            : 
     586         [ +  - ]:       2355 :     if (m_nInReschedule == 0)
     587                 :            :     {
     588                 :       2355 :         ++m_nInReschedule;
     589         [ +  - ]:       2355 :         aGlobalLock.unlock();
     590                 :            :         // <- SAFE
     591                 :            : 
     592         [ +  - ]:       2355 :         Application::Reschedule(true);
     593                 :            : 
     594                 :            :         // SAFE ->
     595         [ +  - ]:       2355 :         aGlobalLock.lock();
     596                 :       2355 :         --m_nInReschedule;
     597 [ +  - ][ +  - ]:      15205 :     }
                 [ +  + ]
     598                 :            : }
     599                 :            : 
     600                 :            : //-----------------------------------------------
     601                 :        432 : void StatusIndicatorFactory::impl_startWakeUpThread()
     602                 :            : {
     603                 :            :     // SAFE ->
     604         [ +  - ]:        432 :     WriteGuard aWriteLock(m_aLock);
     605                 :            : 
     606         [ -  + ]:        432 :     if (m_bDisableReschedule)
     607                 :        432 :         return;
     608                 :            : 
     609         [ +  + ]:        432 :     if (!m_pWakeUp)
     610                 :            :     {
     611 [ +  - ][ +  - ]:        411 :         m_pWakeUp = new WakeUpThread(this);
     612         [ +  - ]:        411 :         m_pWakeUp->create();
     613                 :            :     }
     614 [ +  - ][ +  - ]:        432 :     aWriteLock.unlock();
                 [ +  - ]
     615                 :            :     // <- SAFE
     616                 :            : }
     617                 :            : 
     618                 :            : //-----------------------------------------------
     619                 :       2095 : void StatusIndicatorFactory::impl_stopWakeUpThread()
     620                 :            : {
     621                 :            :     // SAFE ->
     622         [ +  - ]:       2095 :     WriteGuard aWriteLock(m_aLock);
     623         [ +  + ]:       2095 :     if (m_pWakeUp)
     624                 :            :     {
     625                 :            :         // Thread kill itself after terminate()!
     626         [ +  - ]:        411 :         m_pWakeUp->terminate();
     627                 :        411 :         m_pWakeUp = 0;
     628                 :            :     }
     629 [ +  - ][ +  - ]:       2095 :     aWriteLock.unlock();
     630                 :            :     // <- SAFE
     631                 :       2095 : }
     632                 :            : 
     633                 :            : } // namespace framework
     634                 :            : 
     635                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10