summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2015-07-08 20:45:37 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2015-07-12 18:56:48 +0200
commitefd13b27a4d5108645307b54d150c7d3fec87dcc (patch)
tree2429bb812d656f5a81e5a275da5fca0177f80a2a /chart2
parent7cad6b12c801a21b2401958c60625a50320fb5c7 (diff)
finally manage to register chart2 in the ChartController
We need to do some jumps through pink hoops to connect the chart controller with the host sidebar. Would we use the chart window as parent for our sidebar the sidebar would be directlz beside the chart and not at the border of the host window. Change-Id: Ica44ae370518882ef367999f57251b1256907016
Diffstat (limited to 'chart2')
-rw-r--r--chart2/source/controller/main/ChartController.cxx31
1 files changed, 31 insertions, 0 deletions
diff --git a/chart2/source/controller/main/ChartController.cxx b/chart2/source/controller/main/ChartController.cxx
index 4156c9d70042..3175eea6a11e 100644
--- a/chart2/source/controller/main/ChartController.cxx
+++ b/chart2/source/controller/main/ChartController.cxx
@@ -51,6 +51,7 @@
#include <com/sun/star/chart2/XChartDocument.hpp>
#include <com/sun/star/chart2/data/XDataReceiver.hpp>
#include <com/sun/star/frame/XLoadable.hpp>
+#include <com/sun/star/frame/XController2.hpp>
#include <com/sun/star/util/XCloneable.hpp>
#include <com/sun/star/embed/XEmbeddedClient.hpp>
#include <com/sun/star/util/XModeChangeBroadcaster.hpp>
@@ -58,6 +59,7 @@
#include <com/sun/star/frame/LayoutManagerEvents.hpp>
#include <com/sun/star/document/XUndoManagerSupplier.hpp>
#include <com/sun/star/document/XUndoAction.hpp>
+#include <com/sun/star/ui/XSidebar.hpp>
#include <svx/sidebar/SelectionChangeHandler.hxx>
#include <vcl/msgbox.hxx>
@@ -66,6 +68,8 @@
#include <vcl/svapp.hxx>
#include <osl/mutex.hxx>
+#include <sfx2/sidebar/SidebarController.hxx>
+
#include <com/sun/star/frame/XLayoutManager.hpp>
#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
@@ -346,6 +350,21 @@ uno::Sequence< OUString > ChartController::getSupportedServiceNames_Static()
return aSNS;
}
+namespace {
+
+uno::Reference<ui::XSidebar> getSidebarFromModel(uno::Reference<frame::XModel> xModel)
+{
+ uno::Reference<container::XChild> xChild(xModel, uno::UNO_QUERY);
+ uno::Reference<frame::XModel> xParent (xChild->getParent(), uno::UNO_QUERY_THROW);
+ uno::Reference<frame::XController2> xController(xParent->getCurrentController(), uno::UNO_QUERY);
+ uno::Reference<ui::XSidebarProvider> xSidebarProvider (xController->getSidebar(), uno::UNO_QUERY);
+ uno::Reference<ui::XSidebar> xSidebar(xSidebarProvider->getSidebar(), uno::UNO_QUERY);
+
+ return xSidebar;
+}
+
+}
+
// XController
void SAL_CALL ChartController::attachFrame(
@@ -359,6 +378,10 @@ void SAL_CALL ChartController::attachFrame(
mpSelectionChangeHandler->Connect();
+ uno::Reference<ui::XSidebar> xSidebar = getSidebarFromModel(getModel());
+ sfx2::sidebar::SidebarController* pSidebar = dynamic_cast<sfx2::sidebar::SidebarController*>(xSidebar.get());
+ sfx2::sidebar::SidebarController::registerSidebarForFrame(pSidebar, this);
+
if(m_xFrame.is()) //what happens, if we do have a Frame already??
{
//@todo? throw exception?
@@ -725,6 +748,14 @@ void SAL_CALL ChartController::dispose()
throw(uno::RuntimeException, std::exception)
{
mpSelectionChangeHandler->Disconnect();
+
+ if (getModel().is())
+ {
+ uno::Reference<ui::XSidebar> xSidebar = getSidebarFromModel(getModel());
+ sfx2::sidebar::SidebarController* pSidebar = dynamic_cast<sfx2::sidebar::SidebarController*>(xSidebar.get());
+ sfx2::sidebar::SidebarController::unregisterSidebarForFrame(pSidebar, this);
+ }
+
try
{
//This object should release all resources and references in the