summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2021-02-08 11:49:03 +0900
committerTomaž Vajngerl <quikee@gmail.com>2021-02-11 12:53:48 +0100
commit9afdfc80a39f85b440bf753daa52832532ee1e8c (patch)
tree7ae7d19cba2d2d2c6ca53c01d5edae1557954ab8 /svx
parent6f7e48c00fc879158576c36c4bfcfdc0440f201d (diff)
devtools: inspect selected object when DevTools are started
When DevTools window is started, we check if there is a selected object and inspect that one automatically, else use the root document object. Change-Id: I1b8b5031c4ac67300bcc15d176b86bac0a4c5d4f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110732 Tested-by: Tomaž Vajngerl <quikee@gmail.com> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'svx')
-rw-r--r--svx/source/devtools/DevelopmentToolDockingWindow.cxx29
1 files changed, 26 insertions, 3 deletions
diff --git a/svx/source/devtools/DevelopmentToolDockingWindow.cxx b/svx/source/devtools/DevelopmentToolDockingWindow.cxx
index 1ab3ab997808..bcb554a2668e 100644
--- a/svx/source/devtools/DevelopmentToolDockingWindow.cxx
+++ b/svx/source/devtools/DevelopmentToolDockingWindow.cxx
@@ -30,6 +30,8 @@
#include <com/sun/star/script/XInvocation.hpp>
#include <com/sun/star/script/Invocation.hpp>
+#include <com/sun/star/view/XSelectionSupplier.hpp>
+
#include <comphelper/processfactory.hxx>
#include <sfx2/dispatch.hxx>
@@ -40,8 +42,6 @@
#include <sfx2/viewfrm.hxx>
-#include <com/sun/star/frame/XController.hpp>
-
#include <cppuhelper/compbase.hxx>
#include <cppuhelper/basemutex.hxx>
@@ -465,9 +465,32 @@ DevelopmentToolDockingWindow::DevelopmentToolDockingWindow(SfxBindings* pInputBi
mxRoot = pInputBindings->GetDispatcher()->GetFrame()->GetObjectShell()->GetBaseModel();
- introspect(mxRoot);
maDocumentModelTreeHandler.inspectDocument();
mxSelectionListener.set(new SelectionChangeHandler(xController, this));
+
+ inspectSelectionOrRoot(xController);
+}
+
+void DevelopmentToolDockingWindow::inspectSelectionOrRoot(
+ uno::Reference<frame::XController> const& xController)
+{
+ css::uno::Reference<css::view::XSelectionSupplier> xSupplier(xController, css::uno::UNO_QUERY);
+ if (xSupplier.is())
+ {
+ css::uno::Any aAny = xSupplier->getSelection();
+ if (aAny.hasValue())
+ {
+ auto xInterface = aAny.get<css::uno::Reference<css::uno::XInterface>>();
+ if (xInterface.is())
+ {
+ introspect(xInterface);
+ mpSelectionToggle->set_state(TRISTATE_TRUE);
+ return;
+ }
+ }
+ }
+ mpSelectionToggle->set_state(TRISTATE_FALSE);
+ introspect(mxRoot);
}
IMPL_LINK(DevelopmentToolDockingWindow, DocumentModelTreeViewSelectionHandler, weld::TreeView&,