LCOV - code coverage report
Current view: top level - svx/source/sidebar - SelectionChangeHandler.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 28 31 90.3 %
Date: 2014-11-03 Functions: 9 10 90.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             : #include "svx/sidebar/SelectionChangeHandler.hxx"
      20             : #include "svx/sidebar/SelectionAnalyzer.hxx"
      21             : #include "svx/sidebar/ContextChangeEventMultiplexer.hxx"
      22             : #include "svx/svdmrkv.hxx"
      23             : 
      24             : #include <sfx2/sidebar/EnumContext.hxx>
      25             : #include <sfx2/shell.hxx>
      26             : 
      27             : 
      28             : using namespace css;
      29             : using namespace css::uno;
      30             : 
      31             : using namespace sfx2::sidebar;
      32             : 
      33             : namespace svx { namespace sidebar {
      34             : 
      35         214 : SelectionChangeHandler::SelectionChangeHandler (
      36             :     const boost::function<rtl::OUString(void)>& rSelectionChangeCallback,
      37             :     const Reference<frame::XController>& rxController,
      38             :     const EnumContext::Context eDefaultContext)
      39             :     : SelectionChangeHandlerInterfaceBase(m_aMutex),
      40             :       maSelectionChangeCallback(rSelectionChangeCallback),
      41             :       mxController(rxController),
      42             :       meDefaultContext(eDefaultContext),
      43         214 :       mbIsConnected(false)
      44             : {
      45         214 : }
      46             : 
      47             : 
      48             : 
      49             : 
      50         428 : SelectionChangeHandler::~SelectionChangeHandler (void)
      51             : {
      52         428 : }
      53             : 
      54             : 
      55             : 
      56             : 
      57         446 : void SAL_CALL SelectionChangeHandler::selectionChanged (const lang::EventObject&)
      58             :     throw (uno::RuntimeException, std::exception)
      59             : {
      60         446 :     if (maSelectionChangeCallback)
      61             :     {
      62             :         const EnumContext::Context eContext (
      63         446 :             EnumContext::GetContextEnum(maSelectionChangeCallback()));
      64             :         ContextChangeEventMultiplexer::NotifyContextChange(
      65             :             mxController,
      66             :             eContext==EnumContext::Context_Unknown
      67             :                 ? meDefaultContext
      68         446 :                 : eContext);
      69             :     }
      70         446 : }
      71             : 
      72             : 
      73             : 
      74             : 
      75           0 : void SAL_CALL SelectionChangeHandler::disposing (const lang::EventObject&)
      76             :     throw (uno::RuntimeException, std::exception)
      77             : {
      78           0 : }
      79             : 
      80             : 
      81             : 
      82             : 
      83         214 : void SAL_CALL SelectionChangeHandler::disposing (void)
      84             :     throw (uno::RuntimeException)
      85             : {
      86         214 :     if (mbIsConnected)
      87           0 :         Disconnect();
      88         214 : }
      89             : 
      90             : 
      91             : 
      92             : 
      93         214 : void SelectionChangeHandler::Connect (void)
      94             : {
      95         214 :     uno::Reference<view::XSelectionSupplier> xSupplier (mxController, uno::UNO_QUERY);
      96         214 :     if (xSupplier.is())
      97             :     {
      98         214 :         mbIsConnected = true;
      99         214 :         xSupplier->addSelectionChangeListener(this);
     100         214 :     }
     101         214 : }
     102             : 
     103             : 
     104             : 
     105             : 
     106         214 : void SelectionChangeHandler::Disconnect (void)
     107             : {
     108         214 :     uno::Reference<view::XSelectionSupplier> xSupplier (mxController, uno::UNO_QUERY);
     109         214 :     if (xSupplier.is())
     110             :     {
     111         214 :         mbIsConnected = false;
     112         214 :         xSupplier->removeSelectionChangeListener(this);
     113         214 :     }
     114         214 : }
     115             : 
     116             : 
     117         594 : } } // end of namespace svx::sidebar
     118             : 
     119             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10