summaryrefslogtreecommitdiff
path: root/framework/source/services
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2015-07-13 18:54:17 +0200
committerMichael Stahl <mstahl@redhat.com>2015-07-14 11:50:44 +0200
commit9be8c4f21200aeec5b334d9536b3b7a0b72c24fa (patch)
tree43df9f096d1c16a397e56460d458406d1b9cece3 /framework/source/services
parenta792aa2c48490e43f7460c7418048d32dc891a62 (diff)
sfx2: remove the global SidebarController::maSidebarControllerContainer
This global was crashing on exit, unsurprising as it contains UNO services that reference VCL objects. It turns out that there is already a UNO singleton framework::ContextChangeEventMultiplexer that effectively contains this mapping already, so try to hook that up without creating a public API of it, which is made quite a bit harder by framework's inexplicable multitude of libraries. Change-Id: I4baf67b42c630191fa8879d650eeb62520c331a5
Diffstat (limited to 'framework/source/services')
-rw-r--r--framework/source/services/ContextChangeEventMultiplexer.cxx47
1 files changed, 46 insertions, 1 deletions
diff --git a/framework/source/services/ContextChangeEventMultiplexer.cxx b/framework/source/services/ContextChangeEventMultiplexer.cxx
index 6fe88eeebd89..d672704c23c7 100644
--- a/framework/source/services/ContextChangeEventMultiplexer.cxx
+++ b/framework/source/services/ContextChangeEventMultiplexer.cxx
@@ -17,6 +17,8 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <helper/mischelper.hxx>
+
#include <com/sun/star/lang/XComponent.hpp>
#include <com/sun/star/lang/XEventListener.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
@@ -88,7 +90,6 @@ public:
const css::lang::EventObject& rEvent)
throw (cssu::RuntimeException, std::exception) SAL_OVERRIDE;
-private:
typedef ::std::vector<cssu::Reference<css::ui::XContextChangeEventListener> > ListenerContainer;
class FocusDescriptor
{
@@ -362,6 +363,50 @@ struct Singleton:
}
+namespace framework {
+
+// right now we assume there's one matching listener
+uno::Reference<ui::XContextChangeEventListener> GetFirstListenerWith_ImplImpl(
+ 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()));
+ assert(pMultiplexer);
+
+ ContextChangeEventMultiplexer::FocusDescriptor const*const pFocusDescriptor(
+ pMultiplexer->GetFocusDescriptor(xEventFocus, false));
+ if (!pFocusDescriptor)
+ return xRet;
+
+ for (auto & xListener : pFocusDescriptor->maListeners)
+ {
+ if (rPredicate(xListener))
+ {
+ assert(!xRet.is()); // generalize this if it is used for more than 1:1 mapping?
+ xRet = xListener;
+ }
+ }
+ return xRet;
+}
+
+namespace {
+
+struct Hook
+{
+ Hook() { g_pGetMultiplexerListener = &GetFirstListenerWith_ImplImpl; }
+ ~Hook() { g_pGetMultiplexerListener = nullptr; }
+};
+
+static Hook g_hook;
+
+}
+
+}
+
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
org_apache_openoffice_comp_framework_ContextChangeEventMultiplexer_get_implementation(
css::uno::XComponentContext *,