summaryrefslogtreecommitdiff
path: root/sfx2/source/sidebar/SidebarController.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sfx2/source/sidebar/SidebarController.cxx')
-rw-r--r--sfx2/source/sidebar/SidebarController.cxx49
1 files changed, 34 insertions, 15 deletions
diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx
index d98a5b53d52b..61492cea88c7 100644
--- a/sfx2/source/sidebar/SidebarController.cxx
+++ b/sfx2/source/sidebar/SidebarController.cxx
@@ -124,15 +124,7 @@ SidebarController::SidebarController (
// Decks and panel collections for this sidebar
mpResourceManager = std::unique_ptr<ResourceManager>(new ResourceManager());
- // Listen for context change events.
- css::uno::Reference<css::ui::XContextChangeEventMultiplexer> xMultiplexer (
- css::ui::ContextChangeEventMultiplexer::get(
- ::comphelper::getProcessComponentContext()));
- if (xMultiplexer.is())
- xMultiplexer->addContextChangeEventListener(
- static_cast<css::ui::XContextChangeEventListener*>(this),
- mxFrame->getController());
-
+ registerSidebarForFrame(this, mxFrame->getController());
// Listen for window events.
mpParentWindow->AddEventListener(LINK(this, SidebarController, WindowEventHandler));
@@ -149,12 +141,6 @@ SidebarController::SidebarController (
mxReadOnlyModeDispatch->addStatusListener(this, aURL);
SwitchToDeck(gsDefaultDeckId);
-
- WeakReference<SidebarController> xWeakController (this);
- maSidebarControllerContainer.insert(
- SidebarControllerContainer::value_type(
- rxFrame->getController(),
- xWeakController));
}
SidebarController::~SidebarController()
@@ -175,6 +161,39 @@ SidebarController* SidebarController::GetSidebarControllerForFrame (
return dynamic_cast<SidebarController*>(xController.get());
}
+void SidebarController::registerSidebarForFrame(SidebarController* pController, css::uno::Reference<css::frame::XController> xController)
+{
+ // Listen for context change events.
+ css::uno::Reference<css::ui::XContextChangeEventMultiplexer> xMultiplexer (
+ css::ui::ContextChangeEventMultiplexer::get(
+ ::comphelper::getProcessComponentContext()));
+ if (xMultiplexer.is())
+ xMultiplexer->addContextChangeEventListener(
+ static_cast<css::ui::XContextChangeEventListener*>(pController),
+ xController);
+
+ WeakReference<SidebarController> xWeakController (pController);
+ maSidebarControllerContainer.insert(
+ SidebarControllerContainer::value_type(
+ xController,
+ xWeakController));
+}
+
+void SidebarController::unregisterSidebarForFrame(SidebarController* pController, css::uno::Reference<css::frame::XController> xController)
+{
+ SidebarControllerContainer::iterator iEntry (maSidebarControllerContainer.find(xController));
+ if (iEntry != maSidebarControllerContainer.end())
+ maSidebarControllerContainer.erase(iEntry);
+
+ css::uno::Reference<css::ui::XContextChangeEventMultiplexer> xMultiplexer (
+ css::ui::ContextChangeEventMultiplexer::get(
+ ::comphelper::getProcessComponentContext()));
+ if (xMultiplexer.is())
+ xMultiplexer->removeContextChangeEventListener(
+ static_cast<css::ui::XContextChangeEventListener*>(pController),
+ xController);
+}
+
void SAL_CALL SidebarController::disposing()
{
mpCloseIndicator.disposeAndClear();