include/svx/devtools/DevelopmentToolDockingWindow.hxx | 2 + svx/source/devtools/DevelopmentToolDockingWindow.cxx | 29 ++++++++++++++++-- 2 files changed, 28 insertions(+), 3 deletions(-)
New commits: commit 9afdfc80a39f85b440bf753daa52832532ee1e8c Author: Tomaž Vajngerl <[email protected]> AuthorDate: Mon Feb 8 11:49:03 2021 +0900 Commit: Tomaž Vajngerl <[email protected]> CommitDate: Thu Feb 11 12:53:48 2021 +0100 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 <[email protected]> Reviewed-by: Tomaž Vajngerl <[email protected]> diff --git a/include/svx/devtools/DevelopmentToolDockingWindow.hxx b/include/svx/devtools/DevelopmentToolDockingWindow.hxx index b6fe26e67ea4..cdb20c081ba4 100644 --- a/include/svx/devtools/DevelopmentToolDockingWindow.hxx +++ b/include/svx/devtools/DevelopmentToolDockingWindow.hxx @@ -18,6 +18,7 @@ #include <com/sun/star/uno/XInterface.hpp> #include <com/sun/star/uno/Reference.hxx> #include <com/sun/star/view/XSelectionChangeListener.hpp> +#include <com/sun/star/frame/XController.hpp> #include <svx/devtools/DocumentModelTreeHandler.hxx> @@ -44,6 +45,7 @@ private: void inspectDocument(); void updateSelection(); + void inspectSelectionOrRoot(css::uno::Reference<css::frame::XController> const& xController); void clearObjectInspectorChildren(weld::TreeIter const& rParent); 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&, _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
