summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--framework/inc/helper/mischelper.hxx2
-rw-r--r--framework/source/fwe/classes/sfxhelperfunctions.cxx3
-rw-r--r--framework/source/fwi/helper/mischelper.cxx4
-rw-r--r--framework/source/services/ContextChangeEventMultiplexer.cxx24
-rw-r--r--framework/util/fwk.component3
-rw-r--r--include/framework/ContextChangeEventMultiplexerTunnel.hxx2
-rw-r--r--sfx2/source/sidebar/SidebarController.cxx4
7 files changed, 20 insertions, 22 deletions
diff --git a/framework/inc/helper/mischelper.hxx b/framework/inc/helper/mischelper.hxx
index 4dcb94003449..d05ae360a082 100644
--- a/framework/inc/helper/mischelper.hxx
+++ b/framework/inc/helper/mischelper.hxx
@@ -246,10 +246,12 @@ class WeakDocumentEventListener final : public ::cppu::WeakImplHelper<css::docum
css::uno::Reference<css::ui::XContextChangeEventListener>
GetFirstListenerWith_Impl(
+ css::uno::Reference<css::uno::XComponentContext> const & xComponentContext,
css::uno::Reference<css::uno::XInterface> const& xEventFocus,
std::function<bool (css::uno::Reference<css::ui::XContextChangeEventListener> const&)> const& rPredicate);
extern auto (*g_pGetMultiplexerListener)(
+ css::uno::Reference<css::uno::XComponentContext> const & xComponentContext,
css::uno::Reference<css::uno::XInterface> const&,
std::function<bool (css::uno::Reference<css::ui::XContextChangeEventListener> const&)> const&)
-> css::uno::Reference<css::ui::XContextChangeEventListener>;
diff --git a/framework/source/fwe/classes/sfxhelperfunctions.cxx b/framework/source/fwe/classes/sfxhelperfunctions.cxx
index e456a7a42460..9adc5931a7e3 100644
--- a/framework/source/fwe/classes/sfxhelperfunctions.cxx
+++ b/framework/source/fwe/classes/sfxhelperfunctions.cxx
@@ -146,10 +146,11 @@ bool IsDockingWindowVisible( const css::uno::Reference< css::frame::XFrame >& rF
using namespace ::com::sun::star;
uno::Reference<ui::XContextChangeEventListener> GetFirstListenerWith(
+ css::uno::Reference<css::uno::XComponentContext> const & xComponentContext,
uno::Reference<uno::XInterface> const& xEventFocus,
std::function<bool (uno::Reference<ui::XContextChangeEventListener> const&)> const& rPredicate)
{
- return GetFirstListenerWith_Impl(xEventFocus, rPredicate);
+ return GetFirstListenerWith_Impl(xComponentContext, xEventFocus, rPredicate);
}
}
diff --git a/framework/source/fwi/helper/mischelper.cxx b/framework/source/fwi/helper/mischelper.cxx
index b53cd0f2672d..e9c664d474df 100644
--- a/framework/source/fwi/helper/mischelper.cxx
+++ b/framework/source/fwi/helper/mischelper.cxx
@@ -133,17 +133,19 @@ void FillLangItems( std::set< OUString > &rLangItems,
}
auto (*g_pGetMultiplexerListener)(
+ css::uno::Reference<css::uno::XComponentContext> const & xComponentContext,
uno::Reference<uno::XInterface> const&,
std::function<bool (uno::Reference<ui::XContextChangeEventListener> const&)> const&)
-> uno::Reference<ui::XContextChangeEventListener> = nullptr;
uno::Reference<ui::XContextChangeEventListener>
GetFirstListenerWith_Impl(
+ css::uno::Reference<css::uno::XComponentContext> const & xComponentContext,
uno::Reference<uno::XInterface> const& xEventFocus,
std::function<bool (uno::Reference<ui::XContextChangeEventListener> const&)> const& rPredicate)
{
assert(g_pGetMultiplexerListener != nullptr); // should not be called too early, nor too late
- return g_pGetMultiplexerListener(xEventFocus, rPredicate);
+ return g_pGetMultiplexerListener(xComponentContext, xEventFocus, rPredicate);
}
diff --git a/framework/source/services/ContextChangeEventMultiplexer.cxx b/framework/source/services/ContextChangeEventMultiplexer.cxx
index fe24c2b6d770..3e647985cb40 100644
--- a/framework/source/services/ContextChangeEventMultiplexer.cxx
+++ b/framework/source/services/ContextChangeEventMultiplexer.cxx
@@ -23,11 +23,13 @@
#include <com/sun/star/lang/XEventListener.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/ui/XContextChangeEventMultiplexer.hpp>
+#include <com/sun/star/ui/ContextChangeEventMultiplexer.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <cppuhelper/compbase.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <cppuhelper/basemutex.hxx>
+#include <rtl/ref.hxx>
#include <algorithm>
#include <map>
@@ -324,34 +326,21 @@ void SAL_CALL ContextChangeEventMultiplexer::disposing ( const css::lang::EventO
maListeners.erase(iDescriptor);
}
-struct Instance {
- explicit Instance():
- instance(static_cast<cppu::OWeakObject *>(
- new ContextChangeEventMultiplexer()))
- {
- }
-
- css::uno::Reference<css::uno::XInterface> instance;
-};
-
-struct Singleton:
- public rtl::Static<Instance, Singleton>
-{};
-
}
namespace framework {
// right now we assume there's one matching listener
static uno::Reference<ui::XContextChangeEventListener> GetFirstListenerWith_ImplImpl(
+ css::uno::Reference<css::uno::XComponentContext> const & xComponentContext,
uno::Reference<uno::XInterface> const& xEventFocus,
std::function<bool (uno::Reference<ui::XContextChangeEventListener> const&)> const& rPredicate)
{
assert(xEventFocus.is()); // in current usage it's a bug if the XController is null here
uno::Reference<ui::XContextChangeEventListener> xRet;
- ContextChangeEventMultiplexer *const pMultiplexer(
- dynamic_cast<ContextChangeEventMultiplexer *>(Singleton::get().instance.get()));
+ rtl::Reference<ContextChangeEventMultiplexer> pMultiplexer =
+ dynamic_cast<ContextChangeEventMultiplexer *>(ui::ContextChangeEventMultiplexer::get(xComponentContext).get());
assert(pMultiplexer);
ContextChangeEventMultiplexer::FocusDescriptor const*const pFocusDescriptor(
@@ -389,8 +378,7 @@ org_apache_openoffice_comp_framework_ContextChangeEventMultiplexer_get_implement
css::uno::XComponentContext *,
css::uno::Sequence<css::uno::Any> const &)
{
- return cppu::acquire(static_cast<cppu::OWeakObject *>(
- Singleton::get().instance.get()));
+ return cppu::acquire(new ContextChangeEventMultiplexer());
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/util/fwk.component b/framework/util/fwk.component
index bb74eb817d12..2b9eb7807fee 100644
--- a/framework/util/fwk.component
+++ b/framework/util/fwk.component
@@ -47,7 +47,8 @@
<service name="com.sun.star.ui.DocumentAcceleratorConfiguration"/>
</implementation>
<implementation name="org.apache.openoffice.comp.framework.ContextChangeEventMultiplexer"
- constructor="org_apache_openoffice_comp_framework_ContextChangeEventMultiplexer_get_implementation">
+ constructor="org_apache_openoffice_comp_framework_ContextChangeEventMultiplexer_get_implementation"
+ single-instance="true">
<singleton name="com.sun.star.ui.ContextChangeEventMultiplexer"/>
</implementation>
<implementation name="com.sun.star.comp.framework.Frame"
diff --git a/include/framework/ContextChangeEventMultiplexerTunnel.hxx b/include/framework/ContextChangeEventMultiplexerTunnel.hxx
index bd02b7270ee2..d2ff18bbeb87 100644
--- a/include/framework/ContextChangeEventMultiplexerTunnel.hxx
+++ b/include/framework/ContextChangeEventMultiplexerTunnel.hxx
@@ -14,12 +14,14 @@
namespace com::sun::star::ui { class XContextChangeEventListener; }
namespace com::sun::star::uno { class XInterface; }
+namespace com::sun::star::uno { class XComponentContext; }
namespace framework {
// this is pretty horrible, don't use it!
FWK_DLLPUBLIC css::uno::Reference<css::ui::XContextChangeEventListener>
GetFirstListenerWith(
+ css::uno::Reference<css::uno::XComponentContext> const & xComponentContext,
css::uno::Reference<css::uno::XInterface> const& xEventFocus,
std::function<bool (css::uno::Reference<css::ui::XContextChangeEventListener> const&)> const& rPredicate);
diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx
index f839fd98e0a9..b2e8ef949b79 100644
--- a/sfx2/source/sidebar/SidebarController.cxx
+++ b/sfx2/source/sidebar/SidebarController.cxx
@@ -185,7 +185,9 @@ SidebarController* SidebarController::GetSidebarControllerForFrame (
return nullptr;
}
uno::Reference<ui::XContextChangeEventListener> const xListener(
- framework::GetFirstListenerWith(xController,
+ framework::GetFirstListenerWith(
+ ::comphelper::getProcessComponentContext(),
+ xController,
[] (uno::Reference<uno::XInterface> const& xRef)
{ return nullptr != dynamic_cast<SidebarController*>(xRef.get()); }
));