summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2021-02-13 10:42:52 +0900
committerTomaž Vajngerl <quikee@gmail.com>2021-02-14 02:25:17 +0100
commit063602ea3791e87f9bd6685c9bd6dac7a1e4d189 (patch)
tree1877be9ba55888b23ab2ff8b64a74629258e84f5 /sfx2
parente1948634a55ac91c7a49beda358b770b46b55b01 (diff)
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 <quikee@gmail.com>
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/sdi/appslots.sdi5
-rw-r--r--sfx2/sdi/sfx.sdi16
-rw-r--r--sfx2/source/appl/appserv.cxx37
-rw-r--r--sfx2/source/devtools/DevelopmentToolDockingWindow.cxx13
4 files changed, 65 insertions, 6 deletions
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: */