LCOV - code coverage report
Current view: top level - svx/source/sidebar - SelectionChangeHandler.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 27 30 90.0 %
Date: 2014-04-11 Functions: 7 8 87.5 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * This file is part of the LibreOffice project.
       3             :  *
       4             :  * This Source Code Form is subject to the terms of the Mozilla Public
       5             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       6             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       7             :  *
       8             :  * This file incorporates work covered by the following license notice:
       9             :  *
      10             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      11             :  *   contributor license agreements. See the NOTICE file distributed
      12             :  *   with this work for additional information regarding copyright
      13             :  *   ownership. The ASF licenses this file to you under the Apache
      14             :  *   License, Version 2.0 (the "License"); you may not use this file
      15             :  *   except in compliance with the License. You may obtain a copy of
      16             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      17             :  */
      18             : #include "svx/sidebar/SelectionChangeHandler.hxx"
      19             : #include "svx/sidebar/SelectionAnalyzer.hxx"
      20             : #include "svx/sidebar/ContextChangeEventMultiplexer.hxx"
      21             : #include "svx/svdmrkv.hxx"
      22             : 
      23             : #include <sfx2/sidebar/EnumContext.hxx>
      24             : #include <sfx2/shell.hxx>
      25             : 
      26             : 
      27             : using namespace css;
      28             : using namespace cssu;
      29             : 
      30             : using namespace sfx2::sidebar;
      31             : 
      32             : namespace svx { namespace sidebar {
      33             : 
      34          74 : SelectionChangeHandler::SelectionChangeHandler (
      35             :     const boost::function<rtl::OUString(void)>& rSelectionChangeCallback,
      36             :     const Reference<frame::XController>& rxController,
      37             :     const EnumContext::Context eDefaultContext)
      38             :     : SelectionChangeHandlerInterfaceBase(m_aMutex),
      39             :       maSelectionChangeCallback(rSelectionChangeCallback),
      40             :       mxController(rxController),
      41             :       meDefaultContext(eDefaultContext),
      42          74 :       mbIsConnected(false)
      43             : {
      44          74 : }
      45             : 
      46             : 
      47             : 
      48             : 
      49         148 : SelectionChangeHandler::~SelectionChangeHandler (void)
      50             : {
      51         148 : }
      52             : 
      53             : 
      54             : 
      55             : 
      56         149 : void SAL_CALL SelectionChangeHandler::selectionChanged (const lang::EventObject&)
      57             :     throw (uno::RuntimeException, std::exception)
      58             : {
      59         149 :     if (maSelectionChangeCallback)
      60             :     {
      61             :         const EnumContext::Context eContext (
      62         149 :             EnumContext::GetContextEnum(maSelectionChangeCallback()));
      63             :         ContextChangeEventMultiplexer::NotifyContextChange(
      64             :             mxController,
      65             :             eContext==EnumContext::Context_Unknown
      66             :                 ? meDefaultContext
      67         149 :                 : eContext);
      68             :     }
      69         149 : }
      70             : 
      71             : 
      72             : 
      73             : 
      74           0 : void SAL_CALL SelectionChangeHandler::disposing (const lang::EventObject&)
      75             :     throw (uno::RuntimeException, std::exception)
      76             : {
      77           0 : }
      78             : 
      79             : 
      80             : 
      81             : 
      82          74 : void SAL_CALL SelectionChangeHandler::disposing (void)
      83             :     throw (uno::RuntimeException)
      84             : {
      85          74 :     if (mbIsConnected)
      86           0 :         Disconnect();
      87          74 : }
      88             : 
      89             : 
      90             : 
      91             : 
      92          70 : void SelectionChangeHandler::Connect (void)
      93             : {
      94          70 :     uno::Reference<view::XSelectionSupplier> xSupplier (mxController, uno::UNO_QUERY);
      95          70 :     if (xSupplier.is())
      96             :     {
      97          70 :         mbIsConnected = true;
      98          70 :         xSupplier->addSelectionChangeListener(this);
      99          70 :     }
     100          70 : }
     101             : 
     102             : 
     103             : 
     104             : 
     105          70 : void SelectionChangeHandler::Disconnect (void)
     106             : {
     107          70 :     uno::Reference<view::XSelectionSupplier> xSupplier (mxController, uno::UNO_QUERY);
     108          70 :     if (xSupplier.is())
     109             :     {
     110          70 :         mbIsConnected = false;
     111          70 :         xSupplier->removeSelectionChangeListener(this);
     112          70 :     }
     113          70 : }
     114             : 
     115             : 
     116             : } } // end of namespace svx::sidebar

Generated by: LCOV version 1.10