LCOV - code coverage report
Current view: top level - chart2/source/controller/main - StatusBarCommandDispatch.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 46 49 93.9 %
Date: 2012-08-25 Functions: 9 10 90.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 42 72 58.3 %

           Branch data     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                 :            : 
      21                 :            : #include "StatusBarCommandDispatch.hxx"
      22                 :            : #include "ObjectNameProvider.hxx"
      23                 :            : #include "macros.hxx"
      24                 :            : #include <com/sun/star/util/XModifyBroadcaster.hpp>
      25                 :            : 
      26                 :            : #include "ResId.hxx"
      27                 :            : 
      28                 :            : using namespace ::com::sun::star;
      29                 :            : 
      30                 :            : using ::com::sun::star::uno::Reference;
      31                 :            : using ::com::sun::star::uno::Sequence;
      32                 :            : using ::rtl::OUString;
      33                 :            : 
      34                 :            : namespace chart
      35                 :            : {
      36                 :            : 
      37                 :         34 : StatusBarCommandDispatch::StatusBarCommandDispatch(
      38                 :            :     const Reference< uno::XComponentContext > & xContext,
      39                 :            :     const Reference< frame::XModel > & xModel,
      40                 :            :     const Reference< view::XSelectionSupplier > & xSelSupp ) :
      41                 :            :         impl::StatusBarCommandDispatch_Base( xContext ),
      42                 :            :         m_xModifiable( xModel, uno::UNO_QUERY  ),
      43                 :            :         m_xSelectionSupplier( xSelSupp ),
      44 [ +  - ][ +  - ]:         34 :         m_bIsModified( false )
      45                 :         34 : {}
      46                 :            : 
      47         [ +  - ]:         34 : StatusBarCommandDispatch::~StatusBarCommandDispatch()
      48         [ -  + ]:         68 : {}
      49                 :            : 
      50                 :         34 : void StatusBarCommandDispatch::initialize()
      51                 :            : {
      52         [ +  - ]:         34 :     if( m_xModifiable.is())
      53                 :            :     {
      54         [ +  - ]:         34 :         Reference< util::XModifyBroadcaster > xModifyBroadcaster( m_xModifiable, uno::UNO_QUERY );
      55                 :            :         OSL_ASSERT( xModifyBroadcaster.is());
      56         [ +  - ]:         34 :         if( xModifyBroadcaster.is())
      57 [ +  - ][ +  - ]:         34 :             xModifyBroadcaster->addModifyListener( this );
                 [ +  - ]
      58                 :            :     }
      59                 :            : 
      60         [ +  - ]:         34 :     if( m_xSelectionSupplier.is())
      61                 :            :     {
      62         [ +  - ]:         34 :         m_xSelectionSupplier->addSelectionChangeListener( this );
      63                 :            :     }
      64                 :         34 : }
      65                 :            : 
      66                 :       2361 : void StatusBarCommandDispatch::fireStatusEvent(
      67                 :            :     const OUString & rURL,
      68                 :            :     const Reference< frame::XStatusListener > & xSingleListener /* = 0 */ )
      69                 :            : {
      70                 :       2361 :     bool bFireAll( rURL.isEmpty() );
      71 [ +  + ][ +  + ]:       2361 :     bool bFireContext(  bFireAll || rURL == ".uno:Context" );
      72 [ +  + ][ +  + ]:       2361 :     bool bFireModified( bFireAll || rURL == ".uno:ModifiedStatus" );
      73                 :            : 
      74         [ +  + ]:       2361 :     if( bFireContext )
      75                 :            :     {
      76                 :       2327 :         uno::Any aArg;
      77         [ +  - ]:       2327 :         Reference< chart2::XChartDocument > xDoc( m_xModifiable, uno::UNO_QUERY );
      78 [ +  - ][ +  - ]:       2327 :         aArg <<= ObjectNameProvider::getSelectedObjectText( m_aSelectedOID.getObjectCID(), xDoc );
                 [ +  - ]
      79 [ +  - ][ +  - ]:       2327 :         fireStatusEventForURL( C2U(".uno:Context"), aArg, true, xSingleListener );
      80                 :            :     }
      81         [ +  + ]:       2361 :     if( bFireModified )
      82                 :            :     {
      83                 :       2327 :         uno::Any aArg;
      84         [ +  + ]:       2327 :         if( m_bIsModified )
      85 [ +  - ][ +  - ]:       2220 :             aArg <<= C2U("*");
      86 [ +  - ][ +  - ]:       2327 :         fireStatusEventForURL( C2U(".uno:ModifiedStatus"), aArg, true, xSingleListener );
      87                 :            :     }
      88                 :       2361 : }
      89                 :            : 
      90                 :            : // ____ XDispatch ____
      91                 :          0 : void SAL_CALL StatusBarCommandDispatch::dispatch(
      92                 :            :     const util::URL& /* URL */,
      93                 :            :     const Sequence< beans::PropertyValue >& /* Arguments */ )
      94                 :            :     throw (uno::RuntimeException)
      95                 :            : {
      96                 :            :     // nothing to do here
      97                 :          0 : }
      98                 :            : 
      99                 :            : // ____ WeakComponentImplHelperBase ____
     100                 :            : /// is called when this is disposed
     101                 :         34 : void SAL_CALL StatusBarCommandDispatch::disposing()
     102                 :            : {
     103                 :         34 :     m_xModifiable.clear();
     104                 :         34 :     m_xSelectionSupplier.clear();
     105                 :         34 : }
     106                 :            : 
     107                 :            : // ____ XEventListener (base of XModifyListener) ____
     108                 :         34 : void SAL_CALL StatusBarCommandDispatch::disposing( const lang::EventObject& /* Source */ )
     109                 :            :     throw (uno::RuntimeException)
     110                 :            : {
     111                 :         34 :     m_xModifiable.clear();
     112                 :         34 :     m_xSelectionSupplier.clear();
     113                 :         34 : }
     114                 :            : 
     115                 :            : // ____ XModifyListener ____
     116                 :       1544 : void SAL_CALL StatusBarCommandDispatch::modified( const lang::EventObject& aEvent )
     117                 :            :     throw (uno::RuntimeException)
     118                 :            : {
     119         [ +  - ]:       1544 :     if( m_xModifiable.is())
     120                 :       1544 :         m_bIsModified = m_xModifiable->isModified();
     121                 :            : 
     122                 :       1544 :     CommandDispatch::modified( aEvent );
     123                 :       1544 : }
     124                 :            : 
     125                 :            : // ____ XSelectionChangeListener ____
     126                 :        749 : void SAL_CALL StatusBarCommandDispatch::selectionChanged( const lang::EventObject& /* aEvent */ )
     127                 :            :     throw (uno::RuntimeException)
     128                 :            : {
     129         [ +  - ]:        749 :     if( m_xSelectionSupplier.is())
     130 [ +  - ][ +  - ]:        749 :         m_aSelectedOID = ObjectIdentifier( m_xSelectionSupplier->getSelection() );
                 [ +  - ]
     131                 :            :     else
     132         [ #  # ]:          0 :         m_aSelectedOID = ObjectIdentifier();
     133         [ +  - ]:        749 :     fireAllStatusEvents( 0 );
     134                 :        749 : }
     135                 :            : 
     136                 :            : } //  namespace chart
     137                 :            : 
     138                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10