ContextChangeEventMultiplexer.cxx (22de8995) ContextChangeEventMultiplexer.cxx (b9e67834)
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

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

15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22#include "precompiled_svx.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

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

15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22#include "precompiled_svx.hxx"
23
24#include "svx/sidebar/ContextChangeEventMultiplexer.hxx"
25
23#include <com/sun/star/ui/ContextChangeEventObject.hpp>
24#include <com/sun/star/ui/XContextChangeEventMultiplexer.hpp>
25#include <com/sun/star/ui/ContextChangeEventMultiplexer.hpp>
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>
26#include <comphelper/processfactory.hxx>
30#include <comphelper/processfactory.hxx>
27#include "svx/sidebar/ContextChangeEventMultiplexer.hxx"
28#include <boost/scoped_ptr.hpp>
31#include <comphelper/componentcontext.hxx>
29
32
33#include <tools/diagnose_ex.h>
30
31using namespace css;
32using namespace cssu;
33
34#define A2S(pString) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(pString)))
35
34
35using namespace css;
36using namespace cssu;
37
38#define A2S(pString) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(pString)))
39
36const ::rtl::OUString ContextChangeEventMultiplexer::Application_Impress (A2S("impress"));
37
38const ::rtl::OUString ContextChangeEventMultiplexer::Context_TextEdit (A2S("text-edit"));
39const ::rtl::OUString ContextChangeEventMultiplexer::Context_Default (A2S("default"));
40
41
42void ContextChangeEventMultiplexer::NotifyContextChange (
43 const cssu::Reference<css::frame::XController>& rxController,
40void ContextChangeEventMultiplexer::NotifyContextChange (
41 const cssu::Reference<css::frame::XController>& rxController,
44 const ::rtl::OUString& rsApplicationName,
45 const ::rtl::OUString& rsContextName)
42 const ::sfx2::sidebar::EnumContext::Context eContext)
46{
43{
47 const css::ui::ContextChangeEventObject aEvent(
44 if (rxController.is())
45 {
46 const css::ui::ContextChangeEventObject aEvent(
48 rxController,
47 rxController,
49 rsApplicationName,
50 rsContextName);
48 GetModuleName(rxController->getFrame()),
49 ::sfx2::sidebar::EnumContext::GetContextName(eContext));
51
50
52 cssu::Reference<css::ui::XContextChangeEventMultiplexer> xMultiplexer (
53 css::ui::ContextChangeEventMultiplexer::get(
54 ::comphelper::getProcessComponentContext()));
55 if (xMultiplexer.is())
56 xMultiplexer->broadcastContextChangeEvent(aEvent, rxController);
51 cssu::Reference<css::ui::XContextChangeEventMultiplexer> xMultiplexer (
52 css::ui::ContextChangeEventMultiplexer::get(
53 ::comphelper::getProcessComponentContext()));
54 if (xMultiplexer.is())
55 xMultiplexer->broadcastContextChangeEvent(aEvent, rxController);
56 }
57}
57}
58
59
60
61
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 DBG_UNHANDLED_EXCEPTION();
76 }
77 return ::sfx2::sidebar::EnumContext::GetApplicationName(
78 ::sfx2::sidebar::EnumContext::Application_Other);
79}