sw/inc/unocoll.hxx                                    |    1 +
 sw/source/core/unocore/unocoll.cxx                    |    8 ++++++--
 sw/source/uibase/sidebar/WriterInspectorTextPanel.cxx |   12 ++++++------
 3 files changed, 13 insertions(+), 8 deletions(-)

New commits:
commit c3088c9a8be4fa553f07be3f5e26dc39389aa513
Author:     Noel Grandin <[email protected]>
AuthorDate: Sun Nov 30 13:28:41 2025 +0200
Commit:     Noel Grandin <[email protected]>
CommitDate: Sun Nov 30 20:48:53 2025 +0100

    use more concrete UNO in UpdateTree
    
    Change-Id: I9767e26456096f9ac01d6c396ee1ab55e183ec43
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194841
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <[email protected]>

diff --git a/sw/inc/unocoll.hxx b/sw/inc/unocoll.hxx
index f9f3261d298b..c115254ade50 100644
--- a/sw/inc/unocoll.hxx
+++ b/sw/inc/unocoll.hxx
@@ -399,6 +399,7 @@ public:
     virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() 
override;
 
     SW_DLLPUBLIC rtl::Reference<SwXTextSection> getSwTextSectionByName(const 
OUString& Name);
+    rtl::Reference<SwXTextSection> getSwTextSectionByIndex(sal_Int32 nIndex);
 };
 
 class SwXBookmarks final : public SwCollectionBaseClass,
diff --git a/sw/source/core/unocore/unocoll.cxx 
b/sw/source/core/unocore/unocoll.cxx
index 2ce0d3e2f269..4789297bc8ce 100644
--- a/sw/source/core/unocore/unocoll.cxx
+++ b/sw/source/core/unocore/unocoll.cxx
@@ -1370,6 +1370,11 @@ sal_Int32 SwXTextSections::getCount()
 }
 
 uno::Any SwXTextSections::getByIndex(sal_Int32 nIndex)
+{
+    return 
Any(css::uno::Reference<css::text::XTextSection>(getSwTextSectionByIndex(nIndex)));
+}
+
+rtl::Reference<SwXTextSection> 
SwXTextSections::getSwTextSectionByIndex(sal_Int32 nIndex)
 {
     if (nIndex < 0)
         throw IndexOutOfBoundsException();
@@ -1383,8 +1388,7 @@ uno::Any SwXTextSections::getByIndex(sal_Int32 nIndex)
         if( !rSectFormats[i]->IsInNodesArr())
             nIndex2++;
         else if (nIndex2 == i)
-            return Any(css::uno::Reference<css::text::XTextSection>(
-                SwXTextSection::CreateXTextSection(rSectFormats[i])));
+            return SwXTextSection::CreateXTextSection(rSectFormats[i]);
     }
     throw IndexOutOfBoundsException();
 }
diff --git a/sw/source/uibase/sidebar/WriterInspectorTextPanel.cxx 
b/sw/source/uibase/sidebar/WriterInspectorTextPanel.cxx
index e8eb46377abd..23747a064fd9 100644
--- a/sw/source/uibase/sidebar/WriterInspectorTextPanel.cxx
+++ b/sw/source/uibase/sidebar/WriterInspectorTextPanel.cxx
@@ -24,6 +24,8 @@
 #include <docsh.hxx>
 #include <wrtsh.hxx>
 #include <unoprnms.hxx>
+#include <unocoll.hxx>
+#include <unosection.hxx>
 #include <editeng/unoprnms.hxx>
 #include <com/sun/star/text/XBookmarksSupplier.hpp>
 #include <com/sun/star/text/XTextSectionsSupplier.hpp>
@@ -692,14 +694,12 @@ static void UpdateTree(SwDocShell& rDocSh, const 
SwEditShell& rEditSh,
     }
 
     // Collect sections at character position
-    uno::Reference<container::XIndexAccess> 
xTextSections(pSwTextDocument->getTextSections(),
-                                                          uno::UNO_QUERY);
+    rtl::Reference<SwXTextSections> 
xTextSections(pSwTextDocument->getSwTextSections());
     for (sal_Int32 i = 0; i < xTextSections->getCount(); ++i)
     {
         svx::sidebar::TreeNode aCurNode;
-        uno::Reference<text::XTextContent> section;
-        xTextSections->getByIndex(i) >>= section;
-        uno::Reference<container::XNamed> xTextSection(section, 
uno::UNO_QUERY);
+        rtl::Reference<SwXTextSection> section = 
xTextSections->getSwTextSectionByIndex(i);
+        uno::Reference<container::XNamed> xTextSection(section);
 
         try
         {
@@ -710,7 +710,7 @@ static void UpdateTree(SwDocShell& rDocSh, const 
SwEditShell& rEditSh,
                 && xTextRangeCompare->compareRegionStarts(sectionRange, 
xRange) != -1
                 && xTextRangeCompare->compareRegionEnds(xRange, sectionRange) 
!= -1)
             {
-                aCurNode.sNodeName = xTextSection->getName();
+                aCurNode.sNodeName = section->getName();
                 aCurNode.NodeType = svx::sidebar::TreeNode::ComplexProperty;
 
                 MetadataToTreeNode(xTextSection, aCurNode);

Reply via email to