LCOV - code coverage report
Current view: top level - forms/source/richtext - attributedispatcher.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 37 0.0 %
Date: 2014-04-14 Functions: 0 8 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 "attributedispatcher.hxx"
      21             : 
      22             : #include <editeng/editview.hxx>
      23             : 
      24             : 
      25             : namespace frm
      26             : {
      27             : 
      28             : 
      29             :     using namespace ::com::sun::star::uno;
      30             :     using namespace ::com::sun::star::frame;
      31             :     using namespace ::com::sun::star::lang;
      32             :     using namespace ::com::sun::star::util;
      33             :     using namespace ::com::sun::star::beans;
      34             : 
      35             : 
      36             :     //= OAttributeDispatcher
      37             : 
      38             : 
      39           0 :     OAttributeDispatcher::OAttributeDispatcher( EditView& _rView, AttributeId _nAttributeId, const URL& _rURL,
      40             :             IMultiAttributeDispatcher* _pMasterDispatcher )
      41             :         :ORichTextFeatureDispatcher( _rView, _rURL )
      42             :         ,m_pMasterDispatcher( _pMasterDispatcher )
      43           0 :         ,m_nAttributeId( _nAttributeId )
      44             :     {
      45             :         OSL_ENSURE( m_pMasterDispatcher, "OAttributeDispatcher::OAttributeDispatcher: invalid master dispatcher!" );
      46           0 :     }
      47             : 
      48             : 
      49           0 :     OAttributeDispatcher::~OAttributeDispatcher( )
      50             :     {
      51           0 :         acquire();
      52           0 :         dispose();
      53           0 :     }
      54             : 
      55             : 
      56           0 :     void OAttributeDispatcher::disposing( ::osl::ClearableMutexGuard& _rClearBeforeNotify )
      57             :     {
      58           0 :         m_pMasterDispatcher = NULL;
      59           0 :         ORichTextFeatureDispatcher::disposing( _rClearBeforeNotify );
      60           0 :     }
      61             : 
      62             : 
      63           0 :     void OAttributeDispatcher::fillFeatureEventFromAttributeState( FeatureStateEvent& _rEvent, const AttributeState& _rState ) const
      64             :     {
      65           0 :         if ( _rState.eSimpleState == eChecked )
      66           0 :             _rEvent.State <<= (sal_Bool)sal_True;
      67           0 :         else if ( _rState.eSimpleState == eUnchecked )
      68           0 :             _rEvent.State <<= (sal_Bool)sal_False;
      69           0 :     }
      70             : 
      71             : 
      72           0 :     FeatureStateEvent OAttributeDispatcher::buildStatusEvent() const
      73             :     {
      74           0 :         FeatureStateEvent aEvent( ORichTextFeatureDispatcher::buildStatusEvent() );
      75           0 :         aEvent.IsEnabled = getEditView() ? !getEditView()->IsReadOnly() : sal_False;
      76             : 
      77           0 :         AttributeState aState;
      78           0 :         if ( m_pMasterDispatcher )
      79           0 :             aState = m_pMasterDispatcher->getState( m_nAttributeId );
      80             : 
      81           0 :         fillFeatureEventFromAttributeState( aEvent, aState );
      82             : 
      83           0 :         return aEvent;
      84             :     }
      85             : 
      86             : 
      87           0 :     void SAL_CALL OAttributeDispatcher::dispatch( const URL& _rURL, const Sequence< PropertyValue >& _rArguments ) throw (RuntimeException, std::exception)
      88             :     {
      89           0 :         ::osl::MutexGuard aGuard( m_aMutex );
      90             : 
      91           0 :         checkDisposed();
      92             : 
      93             :         (void)_rURL;
      94             :         (void)_rArguments;
      95             : 
      96             :         OSL_ENSURE( _rURL.Complete == getFeatureURL().Complete, "OAttributeDispatcher::dispatch: invalid URL!" );
      97             : #if OSL_DEBUG_LEVEL > 0
      98             :         if ( _rArguments.getLength() )
      99             :         {
     100             :             OString sMessage( "OAttributeDispatcher::dispatch: found arguments, but can't handle arguments at all" );
     101             :             sMessage += "\n (URL: ";
     102             :             sMessage += OString( _rURL.Complete.getStr(), _rURL.Complete.getLength(), RTL_TEXTENCODING_ASCII_US );
     103             :             sMessage += ")";
     104             :             OSL_FAIL( sMessage.getStr() );
     105             :         }
     106             : #endif
     107             : 
     108           0 :         if ( m_pMasterDispatcher )
     109           0 :             m_pMasterDispatcher->executeAttribute( m_nAttributeId, NULL );
     110           0 :     }
     111             : 
     112             : 
     113           0 :     void OAttributeDispatcher::onAttributeStateChanged( AttributeId _nAttributeId, const AttributeState& /*_rState*/ )
     114             :     {
     115             :         OSL_ENSURE( _nAttributeId == m_nAttributeId, "OAttributeDispatcher::onAttributeStateChanged: wrong attribute!" );
     116             :         (void)_nAttributeId;
     117             : 
     118           0 :         FeatureStateEvent aEvent( buildStatusEvent() );
     119           0 :         ::cppu::OInterfaceIteratorHelper aIter( getStatusListeners() );
     120           0 :         while ( aIter.hasMoreElements() )
     121           0 :             doNotify( static_cast< XStatusListener* >( aIter.next() ), aEvent );
     122           0 :     }
     123             : 
     124             : 
     125             : }   // namespace frm
     126             : 
     127             : 
     128             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10