[Libreoffice-commits] core.git: include/svx svx/source svx/uiconfig
Tomaž Vajngerl (via logerrit)
logerrit at kemper.freedesktop.org
Wed Jan 13 10:59:47 UTC 2021
include/svx/devtools/DevelopmentToolDockingWindow.hxx | 6 +
svx/source/devtools/DevelopmentToolDockingWindow.cxx | 92 +++++++++++++---
svx/uiconfig/ui/developmenttool.ui | 100 ++++++++++++++++--
3 files changed, 176 insertions(+), 22 deletions(-)
New commits:
commit 9bbf7a1a1029f780e569b5e8df79e86ba5b8c88e
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Wed Jan 6 15:58:13 2021 +0900
Commit: Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Wed Jan 13 11:59:01 2021 +0100
devtools: Add treeview with content of current object
Change-Id: I8d6dd035e60a7521c404e23045fade7eae47fc6c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108975
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
diff --git a/include/svx/devtools/DevelopmentToolDockingWindow.hxx b/include/svx/devtools/DevelopmentToolDockingWindow.hxx
index 30499379f32e..a7c39480cf64 100644
--- a/include/svx/devtools/DevelopmentToolDockingWindow.hxx
+++ b/include/svx/devtools/DevelopmentToolDockingWindow.hxx
@@ -28,6 +28,10 @@ class SAL_WARN_UNUSED SVX_DLLPUBLIC DevelopmentToolChildWindow final : public Sf
class SAL_WARN_UNUSED SVX_DLLPUBLIC DevelopmentToolDockingWindow final : public SfxDockingWindow
{
+private:
+ std::unique_ptr<weld::Label> mpClassNameLabel;
+ std::unique_ptr<weld::TreeView> mpClassListBox;
+
public:
DevelopmentToolDockingWindow(SfxBindings* pBindings, SfxChildWindow* pChildWindow,
vcl::Window* pParent);
@@ -35,6 +39,8 @@ public:
virtual ~DevelopmentToolDockingWindow() override;
virtual void ToggleFloatingMode() override;
+
+ void introspect(css::uno::Reference<css::uno::XInterface> const& xInterface);
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/devtools/DevelopmentToolDockingWindow.cxx b/svx/source/devtools/DevelopmentToolDockingWindow.cxx
index 7d2626ae7978..b1f66a3037e5 100644
--- a/svx/source/devtools/DevelopmentToolDockingWindow.cxx
+++ b/svx/source/devtools/DevelopmentToolDockingWindow.cxx
@@ -45,16 +45,6 @@ using namespace css;
namespace
{
-void introspect(uno::Reference<uno::XInterface> const& xInterface)
-{
- if (!xInterface.is())
- return;
-
- uno::Reference<uno::XComponentContext> xContext = comphelper::getProcessComponentContext();
- if (!xContext.is())
- return;
-}
-
typedef cppu::WeakComponentImplHelper<css::view::XSelectionChangeListener>
SelectionChangeHandlerInterfaceBase;
@@ -63,14 +53,19 @@ class SelectionChangeHandler final : private ::cppu::BaseMutex,
{
private:
css::uno::Reference<css::frame::XController> mxController;
+ VclPtr<DevelopmentToolDockingWindow> mpDockingWindow;
public:
- SelectionChangeHandler(const css::uno::Reference<css::frame::XController>& rxController)
+ SelectionChangeHandler(const css::uno::Reference<css::frame::XController>& rxController,
+ DevelopmentToolDockingWindow* pDockingWindow)
: SelectionChangeHandlerInterfaceBase(m_aMutex)
, mxController(rxController)
+ , mpDockingWindow(pDockingWindow)
{
}
+ ~SelectionChangeHandler() { mpDockingWindow.disposeAndClear(); }
+
virtual void SAL_CALL selectionChanged(const css::lang::EventObject& /*rEvent*/) override
{
uno::Reference<view::XSelectionSupplier> xSupplier(mxController, uno::UNO_QUERY);
@@ -78,7 +73,7 @@ public:
{
uno::Any aAny = xSupplier->getSelection();
auto aRef = aAny.get<uno::Reference<uno::XInterface>>();
- introspect(aRef);
+ mpDockingWindow->introspect(aRef);
}
}
virtual void SAL_CALL disposing(const css::lang::EventObject& /*rEvent*/) override {}
@@ -110,16 +105,18 @@ DevelopmentToolDockingWindow::DevelopmentToolDockingWindow(SfxBindings* pInputBi
vcl::Window* pParent)
: SfxDockingWindow(pInputBindings, pChildWindow, pParent, "DevelopmentTool",
"svx/ui/developmenttool.ui")
+ , mpClassNameLabel(m_xBuilder->weld_label("class_name_value_id"))
+ , mpClassListBox(m_xBuilder->weld_tree_view("class_listbox_id"))
{
auto* pViewFrame = pInputBindings->GetDispatcher()->GetFrame();
- uno::Reference<frame::XController> xCtrl = pViewFrame->GetFrame().GetController();
+ uno::Reference<frame::XController> xController = pViewFrame->GetFrame().GetController();
- uno::Reference<view::XSelectionSupplier> xSupplier(xCtrl, uno::UNO_QUERY);
+ uno::Reference<view::XSelectionSupplier> xSupplier(xController, uno::UNO_QUERY);
if (xSupplier.is())
{
uno::Reference<view::XSelectionChangeListener> xChangeListener(
- new SelectionChangeHandler(xCtrl));
+ new SelectionChangeHandler(xController, this));
xSupplier->addSelectionChangeListener(xChangeListener);
introspect(pInputBindings->GetDispatcher()->GetFrame()->GetObjectShell()->GetBaseModel());
}
@@ -137,4 +134,69 @@ void DevelopmentToolDockingWindow::ToggleFloatingMode()
Invalidate();
}
+void DevelopmentToolDockingWindow::introspect(uno::Reference<uno::XInterface> const& xInterface)
+{
+ if (!xInterface.is())
+ return;
+
+ uno::Reference<uno::XComponentContext> xContext = comphelper::getProcessComponentContext();
+ if (!xContext.is())
+ return;
+
+ auto xServiceInfo = uno::Reference<lang::XServiceInfo>(xInterface, uno::UNO_QUERY);
+ OUString aImplementationName = xServiceInfo->getImplementationName();
+
+ mpClassNameLabel->set_label(aImplementationName);
+
+ mpClassListBox->freeze();
+ mpClassListBox->clear();
+
+ std::unique_ptr<weld::TreeIter> pParent = mpClassListBox->make_iterator();
+ OUString aServicesString("Services");
+ mpClassListBox->insert(nullptr, -1, &aServicesString, nullptr, nullptr, nullptr, false,
+ pParent.get());
+ mpClassListBox->set_text_emphasis(*pParent, true, 0);
+
+ std::unique_ptr<weld::TreeIter> pResult = mpClassListBox->make_iterator();
+ const uno::Sequence<OUString> aServiceNames(xServiceInfo->getSupportedServiceNames());
+ for (auto const& aServiceName : aServiceNames)
+ {
+ mpClassListBox->insert(pParent.get(), -1, &aServiceName, nullptr, nullptr, nullptr, false,
+ pResult.get());
+ }
+
+ uno::Reference<beans::XIntrospection> xIntrospection;
+ xIntrospection = beans::theIntrospection::get(xContext);
+
+ uno::Reference<beans::XIntrospectionAccess> xIntrospectionAccess;
+ xIntrospectionAccess = xIntrospection->inspect(uno::makeAny(xInterface));
+
+ OUString aPropertiesString("Properties");
+ mpClassListBox->insert(nullptr, -1, &aPropertiesString, nullptr, nullptr, nullptr, false,
+ pParent.get());
+ mpClassListBox->set_text_emphasis(*pParent, true, 0);
+
+ const auto xProperties = xIntrospectionAccess->getProperties(
+ beans::PropertyConcept::ALL - beans::PropertyConcept::DANGEROUS);
+ for (auto const& xProperty : xProperties)
+ {
+ mpClassListBox->insert(pParent.get(), -1, &xProperty.Name, nullptr, nullptr, nullptr, false,
+ pResult.get());
+ }
+
+ OUString aMethodsString("Methods");
+ mpClassListBox->insert(nullptr, -1, &aMethodsString, nullptr, nullptr, nullptr, false,
+ pParent.get());
+ mpClassListBox->set_text_emphasis(*pParent, true, 0);
+
+ const auto xMethods = xIntrospectionAccess->getMethods(beans::MethodConcept::ALL);
+ for (auto const& xMethod : xMethods)
+ {
+ OUString aMethodName = xMethod->getName();
+ mpClassListBox->insert(pParent.get(), -1, &aMethodName, nullptr, nullptr, nullptr, false,
+ pResult.get());
+ }
+
+ mpClassListBox->thaw();
+}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/uiconfig/ui/developmenttool.ui b/svx/uiconfig/ui/developmenttool.ui
index 6bb0d69a339c..0a7670f4b94e 100644
--- a/svx/uiconfig/ui/developmenttool.ui
+++ b/svx/uiconfig/ui/developmenttool.ui
@@ -2,24 +2,110 @@
<!-- Generated with glade 3.38.2 -->
<interface domain="svx">
<requires lib="gtk+" version="3.20"/>
- <!-- n-columns=1 n-rows=1 -->
+ <object class="GtkTreeStore" id="liststore">
+ <columns>
+ <!-- column-name text1 -->
+ <column type="gchararray"/>
+ <!-- column-name text2 -->
+ <column type="gchararray"/>
+ </columns>
+ </object>
+ <!-- n-columns=2 n-rows=2 -->
<object class="GtkGrid" id="DevelopmentTool">
<property name="visible">True</property>
<property name="can-focus">False</property>
- <property name="hexpand">True</property>
- <property name="vexpand">True</property>
- <property name="row-spacing">24</property>
+ <property name="halign">baseline</property>
+ <property name="row-spacing">6</property>
+ <property name="column-spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="class_name_label">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="hexpand">False</property>
+ <property name="vexpand">False</property>
+ <property name="label" translatable="yes" context="developmenttool|classname">Class name:</property>
+ <accessibility>
+ <relation type="label-for" target="class_name_value_id"/>
+ </accessibility>
+ </object>
+ <packing>
+ <property name="left-attach">0</property>
+ <property name="top-attach">0</property>
+ </packing>
+ </child>
<child>
- <object class="GtkLabel">
+ <object class="GtkLabel" id="class_name_value_id">
+ <property name="name">class_name_id</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="hexpand">True</property>
+ <property name="selectable">True</property>
+ <accessibility>
+ <relation type="labelled-by" target="class_name_label"/>
+ </accessibility>
+ </object>
+ <packing>
+ <property name="left-attach">1</property>
+ <property name="top-attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkScrolledWindow">
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="hexpand">True</property>
<property name="vexpand">True</property>
- <property name="label" translatable="no">Test</property>
+ <property name="shadow-type">in</property>
+ <child>
+ <object class="GtkTreeView" id="class_listbox_id">
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="receives-default">True</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <property name="model">liststore</property>
+ <property name="search-column">0</property>
+ <property name="enable-tree-lines">True</property>
+ <child internal-child="selection">
+ <object class="GtkTreeSelection"/>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn" id="treeviewcolumn1">
+ <property name="resizable">True</property>
+ <property name="title" translatable="yes" context="developmenttool|class">Class</property>
+ <child>
+ <object class="GtkCellRendererText" id="cellrenderertext1">
+ <property name="ellipsize">end</property>
+ </object>
+ <attributes>
+ <attribute name="sensitive">5</attribute>
+ <attribute name="text">0</attribute>
+ <attribute name="weight">3</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn" id="treeviewcolumn2">
+ <property name="resizable">True</property>
+ <property name="title" translatable="yes" context="developmenttool|value">X</property>
+ <child>
+ <object class="GtkCellRendererText" id="cellrenderertext2"/>
+ <attributes>
+ <attribute name="sensitive">6</attribute>
+ <attribute name="text">1</attribute>
+ <attribute name="weight">4</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
</object>
<packing>
<property name="left-attach">0</property>
- <property name="top-attach">0</property>
+ <property name="top-attach">1</property>
+ <property name="width">2</property>
</packing>
</child>
</object>
More information about the Libreoffice-commits
mailing list