[Libreoffice-commits] core.git: include/sfx2 sfx2/source sfx2/uiconfig

Tomaž Vajngerl (via logerrit) logerrit at kemper.freedesktop.org
Tue Mar 16 23:27:59 UTC 2021


 include/sfx2/devtools/DevelopmentToolDockingWindow.hxx |    2 
 include/sfx2/devtools/DocumentModelTreeHandler.hxx     |    3 +
 sfx2/source/devtools/DevelopmentToolDockingWindow.cxx  |   14 ++++-
 sfx2/source/devtools/DocumentModelTreeHandler.cxx      |   14 +++++
 sfx2/uiconfig/ui/developmenttool.ui                    |   47 +++++++++++++++--
 5 files changed, 74 insertions(+), 6 deletions(-)

New commits:
commit a873ef61534353df3251dd879f8deabde9295145
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Tue Mar 16 23:12:51 2021 +0900
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Wed Mar 17 00:27:11 2021 +0100

    devtools: add refresh button for the DocumentObjectTreeView
    
    Change-Id: I4fea7dd2a12bc04649ff62e0d04e3058cf09c884
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112579
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/include/sfx2/devtools/DevelopmentToolDockingWindow.hxx b/include/sfx2/devtools/DevelopmentToolDockingWindow.hxx
index 1c4826f975f6..171ff96ad5fb 100644
--- a/include/sfx2/devtools/DevelopmentToolDockingWindow.hxx
+++ b/include/sfx2/devtools/DevelopmentToolDockingWindow.hxx
@@ -38,6 +38,7 @@ private:
     std::unique_ptr<ObjectInspectorWidgets> mpObjectInspectorWidgets;
     std::unique_ptr<weld::TreeView> mpDocumentModelTreeView;
     std::unique_ptr<weld::ToggleButton> mpSelectionToggle;
+    std::unique_ptr<weld::Toolbar> mpDomToolbar;
 
     // Reference to the root object for the current document
     css::uno::Reference<css::uno::XInterface> mxRoot;
@@ -53,6 +54,7 @@ private:
 
     DECL_LINK(DocumentModelTreeViewSelectionHandler, weld::TreeView&, void);
     DECL_LINK(SelectionToggled, weld::ToggleButton&, void);
+    DECL_LINK(DomToolbarButtonClicked, const OString&, void);
 
     void updateSelection();
 
diff --git a/include/sfx2/devtools/DocumentModelTreeHandler.hxx b/include/sfx2/devtools/DocumentModelTreeHandler.hxx
index 17b853b36c6f..c63986ad1476 100644
--- a/include/sfx2/devtools/DocumentModelTreeHandler.hxx
+++ b/include/sfx2/devtools/DocumentModelTreeHandler.hxx
@@ -33,6 +33,9 @@ private:
     // identified by the input tree iter.
     void clearChildren(weld::TreeIter const& rParent);
 
+    // Clear all tree view nodes.
+    void clearAll();
+
 public:
     DocumentModelTreeHandler(std::unique_ptr<weld::TreeView>& pDocumentModelTree,
                              css::uno::Reference<css::uno::XInterface> const& xDocument);
diff --git a/sfx2/source/devtools/DevelopmentToolDockingWindow.cxx b/sfx2/source/devtools/DevelopmentToolDockingWindow.cxx
index 6fcbcc68812d..32ef347eded7 100644
--- a/sfx2/source/devtools/DevelopmentToolDockingWindow.cxx
+++ b/sfx2/source/devtools/DevelopmentToolDockingWindow.cxx
@@ -29,7 +29,8 @@ DevelopmentToolDockingWindow::DevelopmentToolDockingWindow(SfxBindings* pInputBi
                        "sfx/ui/developmenttool.ui")
     , mpObjectInspectorWidgets(new ObjectInspectorWidgets(m_xBuilder))
     , mpDocumentModelTreeView(m_xBuilder->weld_tree_view("leftside_treeview_id"))
-    , mpSelectionToggle(m_xBuilder->weld_toggle_button("selection_toggle"))
+    , mpSelectionToggle(m_xBuilder->weld_toggle_button("dom_selection_toggle"))
+    , mpDomToolbar(m_xBuilder->weld_toolbar("dom_toolbar"))
     , maDocumentModelTreeHandler(
           mpDocumentModelTreeView,
           pInputBindings->GetDispatcher()->GetFrame()->GetObjectShell()->GetBaseModel())
@@ -38,6 +39,8 @@ DevelopmentToolDockingWindow::DevelopmentToolDockingWindow(SfxBindings* pInputBi
     mpDocumentModelTreeView->connect_changed(
         LINK(this, DevelopmentToolDockingWindow, DocumentModelTreeViewSelectionHandler));
     mpSelectionToggle->connect_toggled(LINK(this, DevelopmentToolDockingWindow, SelectionToggled));
+    mpDomToolbar->connect_clicked(
+        LINK(this, DevelopmentToolDockingWindow, DomToolbarButtonClicked));
 
     auto* pViewFrame = pInputBindings->GetDispatcher()->GetFrame();
 
@@ -69,6 +72,14 @@ IMPL_LINK_NOARG(DevelopmentToolDockingWindow, SelectionToggled, weld::ToggleButt
     updateSelection();
 }
 
+IMPL_LINK(DevelopmentToolDockingWindow, DomToolbarButtonClicked, const OString&, rSelectionId, void)
+{
+    if (rSelectionId == "dom_refresh_button")
+    {
+        maDocumentModelTreeHandler.inspectDocument();
+    }
+}
+
 DevelopmentToolDockingWindow::~DevelopmentToolDockingWindow() { disposeOnce(); }
 
 void DevelopmentToolDockingWindow::dispose()
@@ -86,6 +97,7 @@ void DevelopmentToolDockingWindow::dispose()
     // dispose welded objects
     mpObjectInspectorWidgets.reset();
     mpSelectionToggle.reset();
+    mpDomToolbar.reset();
     mpDocumentModelTreeView.reset();
 
     SfxDockingWindow::dispose();
diff --git a/sfx2/source/devtools/DocumentModelTreeHandler.cxx b/sfx2/source/devtools/DocumentModelTreeHandler.cxx
index 047b1d97b19d..7645fc327686 100644
--- a/sfx2/source/devtools/DocumentModelTreeHandler.cxx
+++ b/sfx2/source/devtools/DocumentModelTreeHandler.cxx
@@ -719,6 +719,18 @@ uno::Reference<uno::XInterface> DocumentModelTreeHandler::getObjectByID(OUString
     return pEntry->getMainObject();
 }
 
+void DocumentModelTreeHandler::clearAll()
+{
+    // destroy all DocumetModelTreeEntries from the tree
+    mpDocumentModelTree->all_foreach([this](weld::TreeIter& rEntry) {
+        OUString sID = mpDocumentModelTree->get_id(rEntry);
+        auto* pEntry = reinterpret_cast<DocumentModelTreeEntry*>(sID.toInt64());
+        delete pEntry;
+        return false;
+    });
+    mpDocumentModelTree->clear();
+}
+
 void DocumentModelTreeHandler::clearChildren(weld::TreeIter const& rParent)
 {
     bool bChild = false;
@@ -783,6 +795,8 @@ void DocumentModelTreeHandler::selectObject(
 
 void DocumentModelTreeHandler::inspectDocument()
 {
+    clearAll();
+
     uno::Reference<lang::XServiceInfo> xDocumentServiceInfo(mxDocument, uno::UNO_QUERY_THROW);
 
     lclAppend(mpDocumentModelTree, new DocumentRootEntry(SfxResId(STR_DOCUMENT_ENTRY), mxDocument));
diff --git a/sfx2/uiconfig/ui/developmenttool.ui b/sfx2/uiconfig/ui/developmenttool.ui
index 94f96dcdd334..62df00e9d708 100644
--- a/sfx2/uiconfig/ui/developmenttool.ui
+++ b/sfx2/uiconfig/ui/developmenttool.ui
@@ -66,7 +66,7 @@
         <property name="can-focus">True</property>
         <property name="hexpand">True</property>
         <property name="vexpand">True</property>
-        <property name="position">250</property>
+        <property name="position">270</property>
         <property name="wide-handle">True</property>
         <child>
           <!-- n-columns=1 n-rows=2 -->
@@ -119,11 +119,48 @@
               </packing>
             </child>
             <child>
-              <object class="GtkToggleButton" id="selection_toggle">
-                <property name="label" translatable="yes" context="developmenttool|selection_toggle">Current Selection</property>
+              <object class="GtkBox">
                 <property name="visible">True</property>
-                <property name="can-focus">True</property>
-                <property name="receives-default">True</property>
+                <property name="can-focus">False</property>
+                <property name="border-width">3</property>
+                <property name="spacing">12</property>
+                <child>
+                  <object class="GtkToggleButton" id="dom_selection_toggle">
+                    <property name="label" translatable="yes" context="developmenttool|dom_selection_toggle">Current Selection</property>
+                    <property name="visible">True</property>
+                    <property name="can-focus">True</property>
+                    <property name="receives-default">True</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkToolbar" id="dom_toolbar">
+                    <property name="visible">True</property>
+                    <property name="can-focus">False</property>
+                    <child>
+                      <object class="GtkToolButton" id="dom_refresh_button">
+                        <property name="visible">True</property>
+                        <property name="can-focus">False</property>
+                        <property name="label" translatable="yes" context="developmenttool|dom_refresh_button">Refresh</property>
+                        <property name="use-underline">True</property>
+                        <property name="icon-name">cmd/lc_reload.png</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="homogeneous">True</property>
+                      </packing>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
               </object>
               <packing>
                 <property name="left-attach">0</property>


More information about the Libreoffice-commits mailing list