LCOV - code coverage report
Current view: top level - svx/source/sidebar - ContextChangeEventMultiplexer.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 17 0.0 %
Date: 2014-04-14 Functions: 0 3 0.0 %
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             : 
      19             : #include "svx/sidebar/ContextChangeEventMultiplexer.hxx"
      20             : 
      21             : #include <com/sun/star/ui/ContextChangeEventObject.hpp>
      22             : #include <com/sun/star/ui/XContextChangeEventMultiplexer.hpp>
      23             : #include <com/sun/star/ui/ContextChangeEventMultiplexer.hpp>
      24             : #include <com/sun/star/frame/ModuleManager.hpp>
      25             : #include <comphelper/processfactory.hxx>
      26             : #include <sfx2/viewsh.hxx>
      27             : #include <tools/diagnose_ex.h>
      28             : 
      29             : using namespace css;
      30             : using namespace cssu;
      31             : 
      32             : 
      33           0 : void ContextChangeEventMultiplexer::NotifyContextChange (
      34             :     const cssu::Reference<css::frame::XController>& rxController,
      35             :     const ::sfx2::sidebar::EnumContext::Context eContext)
      36             : {
      37           0 :     if (rxController.is() && rxController->getFrame().is())
      38             :     {
      39             :         const css::ui::ContextChangeEventObject aEvent(
      40             :             rxController,
      41           0 :             GetModuleName(rxController->getFrame()),
      42           0 :             ::sfx2::sidebar::EnumContext::GetContextName(eContext));
      43             : 
      44             :         cssu::Reference<css::ui::XContextChangeEventMultiplexer> xMultiplexer (
      45             :             css::ui::ContextChangeEventMultiplexer::get(
      46           0 :                 ::comphelper::getProcessComponentContext()));
      47           0 :         if (xMultiplexer.is())
      48           0 :             xMultiplexer->broadcastContextChangeEvent(aEvent, rxController);
      49             :     }
      50           0 : }
      51             : 
      52             : 
      53             : 
      54             : 
      55           0 : void ContextChangeEventMultiplexer::NotifyContextChange (
      56             :     SfxViewShell* pViewShell,
      57             :     const ::sfx2::sidebar::EnumContext::Context eContext)
      58             : {
      59           0 :     if (pViewShell != NULL)
      60           0 :         NotifyContextChange(pViewShell->GetController(), eContext);
      61           0 : }
      62             : 
      63             : 
      64             : 
      65             : 
      66           0 : ::rtl::OUString ContextChangeEventMultiplexer::GetModuleName (
      67             :     const cssu::Reference<css::frame::XFrame>& rxFrame)
      68             : {
      69             :     try
      70             :     {
      71             :         const Reference<frame::XModuleManager> xModuleManager =
      72           0 :             frame::ModuleManager::create( comphelper::getProcessComponentContext() );
      73           0 :         return xModuleManager->identify(rxFrame);
      74             :     }
      75           0 :     catch (const Exception&)
      76             :     {
      77             :         // An exception typically means that a context change is notified
      78             :         // during initialization or destruction of a view.
      79             :         // Ignore it.
      80             :     }
      81             :     return ::sfx2::sidebar::EnumContext::GetApplicationName(
      82           0 :         ::sfx2::sidebar::EnumContext::Application_None);
      83             : }

Generated by: LCOV version 1.10