ContextChangeEventMultiplexer.cxx (95a18594) ContextChangeEventMultiplexer.cxx (f120fe41)
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 15 unchanged lines hidden (view full) ---

24#include "svx/sidebar/ContextChangeEventMultiplexer.hxx"
25
26#include <com/sun/star/ui/ContextChangeEventObject.hpp>
27#include <com/sun/star/ui/XContextChangeEventMultiplexer.hpp>
28#include <com/sun/star/ui/ContextChangeEventMultiplexer.hpp>
29#include <com/sun/star/frame/XModuleManager.hpp>
30#include <comphelper/processfactory.hxx>
31#include <comphelper/componentcontext.hxx>
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 15 unchanged lines hidden (view full) ---

24#include "svx/sidebar/ContextChangeEventMultiplexer.hxx"
25
26#include <com/sun/star/ui/ContextChangeEventObject.hpp>
27#include <com/sun/star/ui/XContextChangeEventMultiplexer.hpp>
28#include <com/sun/star/ui/ContextChangeEventMultiplexer.hpp>
29#include <com/sun/star/frame/XModuleManager.hpp>
30#include <comphelper/processfactory.hxx>
31#include <comphelper/componentcontext.hxx>
32
32#include <sfx2/viewsh.hxx>
33#include <tools/diagnose_ex.h>
34
35using namespace css;
36using namespace cssu;
37
33#include <tools/diagnose_ex.h>
34
35using namespace css;
36using namespace cssu;
37
38#define A2S(pString) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(pString)))
39
40void ContextChangeEventMultiplexer::NotifyContextChange (
41 const cssu::Reference<css::frame::XController>& rxController,
42 const ::sfx2::sidebar::EnumContext::Context eContext)
43{
44 if (rxController.is() && rxController->getFrame().is())
45 {
46 const css::ui::ContextChangeEventObject aEvent(

--- 7 unchanged lines hidden (view full) ---

54 if (xMultiplexer.is())
55 xMultiplexer->broadcastContextChangeEvent(aEvent, rxController);
56 }
57}
58
59
60
61
38
39void ContextChangeEventMultiplexer::NotifyContextChange (
40 const cssu::Reference<css::frame::XController>& rxController,
41 const ::sfx2::sidebar::EnumContext::Context eContext)
42{
43 if (rxController.is() && rxController->getFrame().is())
44 {
45 const css::ui::ContextChangeEventObject aEvent(

--- 7 unchanged lines hidden (view full) ---

53 if (xMultiplexer.is())
54 xMultiplexer->broadcastContextChangeEvent(aEvent, rxController);
55 }
56}
57
58
59
60
61void ContextChangeEventMultiplexer::NotifyContextChange (
62 SfxViewShell* pViewShell,
63 const ::sfx2::sidebar::EnumContext::Context eContext)
64{
65 if (pViewShell != NULL)
66 NotifyContextChange(pViewShell->GetController(), eContext);
67}
68
69
70
71
62::rtl::OUString ContextChangeEventMultiplexer::GetModuleName (
63 const cssu::Reference<css::frame::XFrame>& rxFrame)
64{
65 try
66 {
67 const ::comphelper::ComponentContext aContext (::comphelper::getProcessServiceFactory());
68 const Reference<frame::XModuleManager> xModuleManager (
69 aContext.createComponent("com.sun.star.frame.ModuleManager" ),
70 UNO_QUERY_THROW );
71 return xModuleManager->identify(rxFrame);
72 }
73 catch (const Exception&)
74 {
75 // An exception typically means that a context change is notified
76 // during initialization or destruction of a view.
77 // Ignore it.
78 }
79 return ::sfx2::sidebar::EnumContext::GetApplicationName(
72::rtl::OUString ContextChangeEventMultiplexer::GetModuleName (
73 const cssu::Reference<css::frame::XFrame>& rxFrame)
74{
75 try
76 {
77 const ::comphelper::ComponentContext aContext (::comphelper::getProcessServiceFactory());
78 const Reference<frame::XModuleManager> xModuleManager (
79 aContext.createComponent("com.sun.star.frame.ModuleManager" ),
80 UNO_QUERY_THROW );
81 return xModuleManager->identify(rxFrame);
82 }
83 catch (const Exception&)
84 {
85 // An exception typically means that a context change is notified
86 // during initialization or destruction of a view.
87 // Ignore it.
88 }
89 return ::sfx2::sidebar::EnumContext::GetApplicationName(
80 ::sfx2::sidebar::EnumContext::Application_Unknown);
90 ::sfx2::sidebar::EnumContext::Application_None);
81}
91}