include/sfx2/devtools/DevelopmentToolDockingWindow.hxx | 6 + include/sfx2/sfxsids.hrc | 1 officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu | 8 ++ sfx2/sdi/appslots.sdi | 5 + sfx2/sdi/sfx.sdi | 16 ++++ sfx2/source/appl/appserv.cxx | 37 ++++++++++ sfx2/source/devtools/DevelopmentToolDockingWindow.cxx | 13 +-- 7 files changed, 79 insertions(+), 7 deletions(-)
New commits: commit 063602ea3791e87f9bd6685c9bd6dac7a1e4d189 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Sat Feb 13 10:42:52 2021 +0900 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Sun Feb 14 02:25:17 2021 +0100 devtools: add .uno action to trigger inspect of the selected object Added .uno:InspectSelectedObject, which can be added to context menu and when triggered, shows the current selected object in the object inspector. Change-Id: I2ade6c74197dcb3cf33b0ad2194822e6ae25fb7e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110837 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/include/sfx2/devtools/DevelopmentToolDockingWindow.hxx b/include/sfx2/devtools/DevelopmentToolDockingWindow.hxx index 4721a424e66d..987bc053a878 100644 --- a/include/sfx2/devtools/DevelopmentToolDockingWindow.hxx +++ b/include/sfx2/devtools/DevelopmentToolDockingWindow.hxx @@ -21,6 +21,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/view/XSelectionSupplier.hpp> #include <com/sun/star/frame/XController.hpp> #include <unordered_map> @@ -36,6 +37,7 @@ private: css::uno::Reference<css::uno::XInterface> mxRoot; css::uno::Reference<css::uno::XInterface> mxCurrentSelection; css::uno::Reference<css::view::XSelectionChangeListener> mxSelectionListener; + css::uno::Reference<css::view::XSelectionSupplier> mxSelectionSupplier; DocumentModelTreeHandler maDocumentModelTreeHandler; ObjectInspectorTreeHandler maObjectInspectorTreeHandler; @@ -45,7 +47,7 @@ private: void inspectDocument(); void updateSelection(); - void inspectSelectionOrRoot(css::uno::Reference<css::frame::XController> const& xController); + void inspectSelectionOrRoot(); public: DevelopmentToolDockingWindow(SfxBindings* pBindings, SfxChildWindow* pChildWindow, @@ -60,6 +62,8 @@ public: void introspect(css::uno::Reference<css::uno::XInterface> const& xInterface); void selectionChanged(css::uno::Reference<css::uno::XInterface> const& xInterface); + + void changeToCurrentSelection(); }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sfxsids.hrc b/include/sfx2/sfxsids.hrc index 8cb256ff998a..3f9d4a232fb7 100644 --- a/include/sfx2/sfxsids.hrc +++ b/include/sfx2/sfxsids.hrc @@ -51,6 +51,7 @@ class SvxSearchItem; #define SID_SAFE_MODE (SID_SFX_START + 303) #define SID_DEVELOPMENT_TOOLS_DOCKING_WINDOW (SID_SFX_START + 306) +#define SID_INSPECT_SELECTED_OBJECT (SID_SFX_START + 307) #define SID_CONTEXT (SID_SFX_START + 310) diff --git a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu index ee5c3fd9e81d..508238ccbaf4 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu @@ -7336,6 +7336,14 @@ bit 3 (0x8): #define UICOMMANDDESCRIPTION_PROPERTIES_TOGGLEBUTTON 8 <value>1</value> </prop> </node> + <node oor:name=".uno:InspectSelectedObject" oor:op="replace"> + <prop oor:name="Label" oor:type="xs:string"> + <value xml:lang="en-US">Inspect Object</value> + </prop> + <prop oor:name="Properties" oor:type="xs:int"> + <value>1</value> + </prop> + </node> </node> </node> </oor:component-data> diff --git a/sfx2/sdi/appslots.sdi b/sfx2/sdi/appslots.sdi index ee620ff3fa8c..5dbee7376b6e 100644 --- a/sfx2/sdi/appslots.sdi +++ b/sfx2/sdi/appslots.sdi @@ -219,6 +219,11 @@ interface Application ExecMethod = MiscExec_Impl ; StateMethod = MiscState_Impl ; ] + SID_INSPECT_SELECTED_OBJECT + [ + ExecMethod = MiscExec_Impl ; + StateMethod = MiscState_Impl ; + ] } diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi index 5a52dd558114..425724440d13 100644 --- a/sfx2/sdi/sfx.sdi +++ b/sfx2/sdi/sfx.sdi @@ -5640,6 +5640,22 @@ SfxBoolItem DevelopmentToolsDockingWindow SID_DEVELOPMENT_TOOLS_DOCKING_WINDOW GroupId = SfxGroupId::Application; ] +SfxVoidItem InspectSelectedObject SID_INSPECT_SELECTED_OBJECT +[ + AutoUpdate = FALSE, + FastCall = FALSE, + ReadOnlyDoc = TRUE, + Toggle = FALSE, + Container = FALSE, + RecordAbsolute = FALSE, + RecordPerSet; + + AccelConfig = TRUE, + MenuConfig = TRUE, + ToolBoxConfig = TRUE, + GroupId = SfxGroupId::View; +] + SfxVoidItem UnicodeNotationToggle SID_UNICODE_NOTATION_TOGGLE () [ diff --git a/sfx2/source/appl/appserv.cxx b/sfx2/source/appl/appserv.cxx index e5360c796183..43f36d187bfd 100644 --- a/sfx2/source/appl/appserv.cxx +++ b/sfx2/source/appl/appserv.cxx @@ -97,6 +97,7 @@ #include <sfx2/sidebar/SidebarController.hxx> #include <sfx2/safemode.hxx> #include <sfx2/sfxuno.hxx> +#include <sfx2/devtools/DevelopmentToolDockingWindow.hxx> #include <comphelper/types.hxx> #include <officecfg/Office/Common.hxx> @@ -1022,6 +1023,26 @@ void SfxApplication::MiscExec_Impl( SfxRequest& rReq ) bDone = true; break; } + case SID_INSPECT_SELECTED_OBJECT: + { + SfxViewShell* pViewShell = SfxViewShell::Current(); + SfxViewFrame* pViewFrame = pViewShell->GetViewFrame(); + + pViewFrame->ShowChildWindow(SID_DEVELOPMENT_TOOLS_DOCKING_WINDOW, true); + + SfxChildWindow* pChild = pViewFrame->GetChildWindow(SID_DEVELOPMENT_TOOLS_DOCKING_WINDOW); + if (!pChild) + return; + + auto pDockingWin = dynamic_cast<DevelopmentToolDockingWindow*>(pChild->GetWindow()); + if (pDockingWin) + { + pDockingWin->changeToCurrentSelection(); + } + + bDone = true; + break; + } case SID_SAFE_MODE: { SafeModeQueryDialog aDialog(rReq.GetFrameWeld()); @@ -1212,6 +1233,22 @@ void SfxApplication::MiscState_Impl(SfxItemSet &rSet) rSet.DisableItem(nWhich); } break; + case SID_INSPECT_SELECTED_OBJECT: + { + bool bSuccess = false; + auto* pViewShell = SfxViewShell::Current(); + if (pViewShell) + { + auto* pViewFrame = pViewShell->GetViewFrame(); + if (pViewFrame && pViewFrame->KnowsChildWindow(SID_DEVELOPMENT_TOOLS_DOCKING_WINDOW)) + { + bSuccess = true; + } + } + if (!bSuccess) + rSet.DisableItem(nWhich); + } + break; default: break; diff --git a/sfx2/source/devtools/DevelopmentToolDockingWindow.cxx b/sfx2/source/devtools/DevelopmentToolDockingWindow.cxx index 0d335b5118cc..5a5134548f11 100644 --- a/sfx2/source/devtools/DevelopmentToolDockingWindow.cxx +++ b/sfx2/source/devtools/DevelopmentToolDockingWindow.cxx @@ -48,17 +48,16 @@ DevelopmentToolDockingWindow::DevelopmentToolDockingWindow(SfxBindings* pInputBi maDocumentModelTreeHandler.inspectDocument(); mxSelectionListener.set(new SelectionChangeHandler(xController, this)); + mxSelectionSupplier.set(xController, css::uno::UNO_QUERY); - inspectSelectionOrRoot(xController); + maObjectInspectorTreeHandler.introspect(mxRoot); } -void DevelopmentToolDockingWindow::inspectSelectionOrRoot( - uno::Reference<frame::XController> const& xController) +void DevelopmentToolDockingWindow::inspectSelectionOrRoot() { - css::uno::Reference<css::view::XSelectionSupplier> xSupplier(xController, css::uno::UNO_QUERY); - if (xSupplier.is()) + if (mxSelectionSupplier.is()) { - css::uno::Any aAny = xSupplier->getSelection(); + css::uno::Any aAny = mxSelectionSupplier->getSelection(); if (aAny.hasValue()) { auto xInterface = aAny.get<css::uno::Reference<css::uno::XInterface>>(); @@ -145,4 +144,6 @@ void DevelopmentToolDockingWindow::selectionChanged( updateSelection(); } +void DevelopmentToolDockingWindow::changeToCurrentSelection() { inspectSelectionOrRoot(); } + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits