LCOV - code coverage report
Current view: top level - libreoffice/sdext/source/presenter - PresenterFrameworkObserver.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 55 0.0 %
Date: 2012-12-27 Functions: 0 9 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "PresenterFrameworkObserver.hxx"
      21             : #include <com/sun/star/lang/IllegalArgumentException.hpp>
      22             : 
      23             : using namespace ::com::sun::star;
      24             : using namespace ::com::sun::star::uno;
      25             : using namespace ::com::sun::star::drawing::framework;
      26             : 
      27             : using ::rtl::OUString;
      28             : 
      29             : #define A2S(pString) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(pString)))
      30             : 
      31             : namespace sdext { namespace presenter {
      32             : 
      33           0 : PresenterFrameworkObserver::PresenterFrameworkObserver (
      34             :     const css::uno::Reference<css::drawing::framework::XConfigurationController>&rxController,
      35             :     const OUString& rsEventName,
      36             :     const Predicate& rPredicate,
      37             :     const Action& rAction)
      38             :     : PresenterFrameworkObserverInterfaceBase(m_aMutex),
      39             :       mxConfigurationController(rxController),
      40             :       maPredicate(rPredicate),
      41           0 :       maAction(rAction)
      42             : {
      43           0 :     if ( ! mxConfigurationController.is())
      44           0 :         throw lang::IllegalArgumentException();
      45             : 
      46           0 :     if (mxConfigurationController->hasPendingRequests())
      47             :     {
      48           0 :         if (!rsEventName.isEmpty())
      49             :         {
      50           0 :             mxConfigurationController->addConfigurationChangeListener(
      51             :                 this,
      52             :                 rsEventName,
      53           0 :                 Any());
      54             :         }
      55           0 :         mxConfigurationController->addConfigurationChangeListener(
      56             :             this,
      57             :             A2S("ConfigurationUpdateEnd"),
      58           0 :             Any());
      59             :     }
      60             :     else
      61             :     {
      62           0 :         rAction(maPredicate());
      63             :     }
      64           0 : }
      65             : 
      66           0 : PresenterFrameworkObserver::~PresenterFrameworkObserver (void)
      67             : {
      68           0 : }
      69             : 
      70           0 : void PresenterFrameworkObserver::RunOnUpdateEnd (
      71             :     const css::uno::Reference<css::drawing::framework::XConfigurationController>&rxController,
      72             :     const Action& rAction)
      73             : {
      74             :     new PresenterFrameworkObserver(
      75             :         rxController,
      76             :         OUString(),
      77             :         &PresenterFrameworkObserver::True,
      78           0 :         rAction);
      79           0 : }
      80             : 
      81           0 : bool PresenterFrameworkObserver::True (void)
      82             : {
      83           0 :     return true;
      84             : }
      85             : 
      86           0 : void SAL_CALL PresenterFrameworkObserver::disposing (void)
      87             : {
      88           0 :     if ( ! maAction.empty())
      89           0 :         maAction(false);
      90           0 :     Shutdown();
      91           0 : }
      92             : 
      93           0 : void PresenterFrameworkObserver::Shutdown (void)
      94             : {
      95           0 :     maAction = Action();
      96           0 :     maPredicate = Predicate();
      97             : 
      98           0 :     if (mxConfigurationController != NULL)
      99             :     {
     100           0 :         mxConfigurationController->removeConfigurationChangeListener(this);
     101           0 :         mxConfigurationController = NULL;
     102             :     }
     103           0 : }
     104             : 
     105           0 : void SAL_CALL PresenterFrameworkObserver::disposing (const lang::EventObject& rEvent)
     106             :     throw (RuntimeException)
     107             : {
     108           0 :     if ( ! rEvent.Source.is())
     109           0 :         return;
     110             : 
     111           0 :     if (rEvent.Source == mxConfigurationController)
     112             :     {
     113           0 :         mxConfigurationController = NULL;
     114           0 :         if ( ! maAction.empty())
     115           0 :             maAction(false);
     116             :     }
     117             : }
     118             : 
     119           0 : void SAL_CALL PresenterFrameworkObserver::notifyConfigurationChange (
     120             :     const ConfigurationChangeEvent& rEvent)
     121             :     throw (RuntimeException)
     122             : {
     123           0 :     bool bDispose(false);
     124             : 
     125           0 :     Action aAction (maAction);
     126           0 :     Predicate aPredicate (maPredicate);
     127           0 :     if (rEvent.Type.equals(A2S("ConfigurationUpdateEnd")))
     128             :     {
     129           0 :         Shutdown();
     130           0 :         aAction(aPredicate);
     131           0 :         bDispose = true;
     132             :     }
     133           0 :     else if (aPredicate())
     134             :     {
     135           0 :         Shutdown();
     136           0 :         aAction(true);
     137           0 :         bDispose = true;
     138             :     }
     139             : 
     140           0 :     if (bDispose)
     141             :     {
     142           0 :         maAction.clear();
     143           0 :         dispose();
     144           0 :     }
     145           0 : }
     146             : 
     147             : } }  // end of namespace ::sdext::presenter
     148             : 
     149             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10