122de8995SAndre Fischer /************************************************************** 222de8995SAndre Fischer * 322de8995SAndre Fischer * Licensed to the Apache Software Foundation (ASF) under one 422de8995SAndre Fischer * or more contributor license agreements. See the NOTICE file 522de8995SAndre Fischer * distributed with this work for additional information 622de8995SAndre Fischer * regarding copyright ownership. The ASF licenses this file 722de8995SAndre Fischer * to you under the Apache License, Version 2.0 (the 822de8995SAndre Fischer * "License"); you may not use this file except in compliance 922de8995SAndre Fischer * with the License. You may obtain a copy of the License at 1022de8995SAndre Fischer * 1122de8995SAndre Fischer * http://www.apache.org/licenses/LICENSE-2.0 1222de8995SAndre Fischer * 1322de8995SAndre Fischer * Unless required by applicable law or agreed to in writing, 1422de8995SAndre Fischer * software distributed under the License is distributed on an 1522de8995SAndre Fischer * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 1622de8995SAndre Fischer * KIND, either express or implied. See the License for the 1722de8995SAndre Fischer * specific language governing permissions and limitations 1822de8995SAndre Fischer * under the License. 1922de8995SAndre Fischer * 2022de8995SAndre Fischer *************************************************************/ 2122de8995SAndre Fischer 2222de8995SAndre Fischer #include "precompiled_svx.hxx" 23*b9e67834SAndre Fischer 24*b9e67834SAndre Fischer #include "svx/sidebar/ContextChangeEventMultiplexer.hxx" 25*b9e67834SAndre Fischer 2622de8995SAndre Fischer #include <com/sun/star/ui/ContextChangeEventObject.hpp> 2722de8995SAndre Fischer #include <com/sun/star/ui/XContextChangeEventMultiplexer.hpp> 2822de8995SAndre Fischer #include <com/sun/star/ui/ContextChangeEventMultiplexer.hpp> 29*b9e67834SAndre Fischer #include <com/sun/star/frame/XModuleManager.hpp> 3022de8995SAndre Fischer #include <comphelper/processfactory.hxx> 31*b9e67834SAndre Fischer #include <comphelper/componentcontext.hxx> 3222de8995SAndre Fischer 33*b9e67834SAndre Fischer #include <tools/diagnose_ex.h> 3422de8995SAndre Fischer 3522de8995SAndre Fischer using namespace css; 3622de8995SAndre Fischer using namespace cssu; 3722de8995SAndre Fischer 3822de8995SAndre Fischer #define A2S(pString) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(pString))) 3922de8995SAndre Fischer 4022de8995SAndre Fischer void ContextChangeEventMultiplexer::NotifyContextChange ( 4122de8995SAndre Fischer const cssu::Reference<css::frame::XController>& rxController, 42*b9e67834SAndre Fischer const ::sfx2::sidebar::EnumContext::Context eContext) 43*b9e67834SAndre Fischer { 44*b9e67834SAndre Fischer if (rxController.is()) 4522de8995SAndre Fischer { 4622de8995SAndre Fischer const css::ui::ContextChangeEventObject aEvent( 4722de8995SAndre Fischer rxController, 48*b9e67834SAndre Fischer GetModuleName(rxController->getFrame()), 49*b9e67834SAndre Fischer ::sfx2::sidebar::EnumContext::GetContextName(eContext)); 5022de8995SAndre Fischer 5122de8995SAndre Fischer cssu::Reference<css::ui::XContextChangeEventMultiplexer> xMultiplexer ( 5222de8995SAndre Fischer css::ui::ContextChangeEventMultiplexer::get( 5322de8995SAndre Fischer ::comphelper::getProcessComponentContext())); 5422de8995SAndre Fischer if (xMultiplexer.is()) 5522de8995SAndre Fischer xMultiplexer->broadcastContextChangeEvent(aEvent, rxController); 5622de8995SAndre Fischer } 57*b9e67834SAndre Fischer } 58*b9e67834SAndre Fischer 59*b9e67834SAndre Fischer 60*b9e67834SAndre Fischer 61*b9e67834SAndre Fischer 62*b9e67834SAndre Fischer ::rtl::OUString ContextChangeEventMultiplexer::GetModuleName ( 63*b9e67834SAndre Fischer const cssu::Reference<css::frame::XFrame>& rxFrame) 64*b9e67834SAndre Fischer { 65*b9e67834SAndre Fischer try 66*b9e67834SAndre Fischer { 67*b9e67834SAndre Fischer const ::comphelper::ComponentContext aContext (::comphelper::getProcessServiceFactory()); 68*b9e67834SAndre Fischer const Reference<frame::XModuleManager> xModuleManager ( 69*b9e67834SAndre Fischer aContext.createComponent("com.sun.star.frame.ModuleManager" ), 70*b9e67834SAndre Fischer UNO_QUERY_THROW ); 71*b9e67834SAndre Fischer return xModuleManager->identify(rxFrame); 72*b9e67834SAndre Fischer } 73*b9e67834SAndre Fischer catch (const Exception&) 74*b9e67834SAndre Fischer { 75*b9e67834SAndre Fischer DBG_UNHANDLED_EXCEPTION(); 76*b9e67834SAndre Fischer } 77*b9e67834SAndre Fischer return ::sfx2::sidebar::EnumContext::GetApplicationName( 78*b9e67834SAndre Fischer ::sfx2::sidebar::EnumContext::Application_Other); 79*b9e67834SAndre Fischer } 80