sw/inc/unocoll.hxx                     |    3 +
 sw/source/core/access/accpara.cxx      |    2 -
 sw/source/core/inc/unoport.hxx         |   51 ++++++++++++++++-----------------
 sw/source/core/unocore/unocoll.cxx     |    2 -
 sw/source/core/unocore/unoport.cxx     |   20 ++++++------
 sw/source/core/unocore/unoportenum.cxx |   34 +++++++++-------------
 sw/source/core/unocore/unoredline.cxx  |    2 -
 7 files changed, 56 insertions(+), 58 deletions(-)

New commits:
commit c921e11a4c2a282279aef9e9a72199478240f728
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Thu Dec 28 22:53:08 2023 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Fri Dec 29 18:10:40 2023 +0100

    use more concrete UNO types in sw
    
    Change-Id: I00e5222fa0943543fb5f1993a040d0836a8c9c9f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161392
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sw/inc/unocoll.hxx b/sw/inc/unocoll.hxx
index 74009f9f2450..48e1196f520e 100644
--- a/sw/inc/unocoll.hxx
+++ b/sw/inc/unocoll.hxx
@@ -38,6 +38,7 @@ namespace com::sun::star::text
 class SwFormatFootnote;
 class SwSectionFormat;
 struct SvEventDescription;
+class SwXFootnote;
 
 const SvEventDescription* sw_GetSupportedMacroItems();
 
@@ -472,7 +473,7 @@ public:
     virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) 
override;
     virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() 
override;
 
-    static css::uno::Reference< css::text::XFootnote> GetObject( SwDoc& rDoc, 
const SwFormatFootnote& rFormat );
+    static rtl::Reference<SwXFootnote> GetObject( SwDoc& rDoc, const 
SwFormatFootnote& rFormat );
 };
 
 class SwXReferenceMarks final : public SwCollectionBaseClass,
diff --git a/sw/source/core/access/accpara.cxx 
b/sw/source/core/access/accpara.cxx
index f0bd0f0653d1..c1d04758269d 100644
--- a/sw/source/core/access/accpara.cxx
+++ b/sw/source/core/access/accpara.cxx
@@ -500,7 +500,7 @@ rtl::Reference<SwXTextPortion> 
SwAccessibleParagraph::CreateUnoPortion(
     *pUnoCursor->GetMark() = pFrame->MapViewToModelPos(nEnd);
 
     // create a (dummy) text portion to be returned
-    uno::Reference<text::XText> aEmpty;
+    uno::Reference<SwXText> aEmpty;
     return new SwXTextPortion ( pUnoCursor.get(), aEmpty, PORTION_TEXT);
 }
 
diff --git a/sw/source/core/inc/unoport.hxx b/sw/source/core/inc/unoport.hxx
index d64936a70353..d932622a1138 100644
--- a/sw/source/core/inc/unoport.hxx
+++ b/sw/source/core/inc/unoport.hxx
@@ -37,6 +37,13 @@
 #include <svl/listener.hxx>
 
 #include <unocrsr.hxx>
+#include "unorefmark.hxx"
+#include "unoidx.hxx"
+#include "unofootnote.hxx"
+#include "unometa.hxx"
+#include "unocontentcontrol.hxx"
+#include "unolinebreak.hxx"
+#include "unobookmark.hxx"
 
 namespace com::sun::star::beans { struct PropertyValue; }
 namespace com::sun::star::text { class XTextField; }
@@ -96,22 +103,16 @@ class SwXTextPortion : public cppu::WeakImplHelper
 private:
 
     const SfxItemPropertySet *  m_pPropSet;
-    const css::uno::Reference< css::text::XText >
-        m_xParentText;
-    css::uno::Reference< css::text::XTextContent >
-        m_xRefMark;
-    css::uno::Reference< css::text::XTextContent >
-        m_xTOXMark;
-    css::uno::Reference< css::text::XTextContent >
-        m_xBookmark;
-    css::uno::Reference< css::text::XFootnote >
-        m_xFootnote;
+    const css::uno::Reference< SwXText > m_xParentText;
+    rtl::Reference< SwXReferenceMark > m_xRefMark;
+    rtl::Reference< SwXDocumentIndexMark > m_xTOXMark;
+    rtl::Reference< SwXBookmark > m_xBookmark;
+    rtl::Reference< SwXFootnote > m_xFootnote;
     css::uno::Reference< css::text::XTextField >
         m_xTextField;
-    css::uno::Reference< css::text::XTextContent >
-        m_xMeta;
-    css::uno::Reference<css::text::XTextContent> m_xLineBreak;
-    css::uno::Reference<css::text::XTextContent> m_xContentControl;
+    rtl::Reference< SwXMeta > m_xMeta;
+    rtl::Reference<SwXLineBreak> m_xLineBreak;
+    rtl::Reference<SwXContentControl> m_xContentControl;
     std::optional< css::uno::Any > m_oRubyText;
     std::optional< css::uno::Any > m_oRubyStyle;
     std::optional< css::uno::Any > m_oRubyAdjust;
@@ -157,13 +158,13 @@ protected:
     virtual void Notify(const SfxHint& rHint) override;
 
 public:
-    SwXTextPortion(const SwUnoCursor* pPortionCursor, css::uno::Reference< 
css::text::XText > xParent, SwTextPortionType   eType   );
-    SwXTextPortion(const SwUnoCursor* pPortionCursor, css::uno::Reference< 
css::text::XText > xParent, SwFrameFormat& rFormat );
+    SwXTextPortion(const SwUnoCursor* pPortionCursor, css::uno::Reference< 
SwXText > xParent, SwTextPortionType   eType   );
+    SwXTextPortion(const SwUnoCursor* pPortionCursor, css::uno::Reference< 
SwXText > xParent, SwFrameFormat& rFormat );
 
     // for Ruby
     SwXTextPortion(const SwUnoCursor* pPortionCursor,
         SwTextRuby const& rAttr,
-        css::uno::Reference< css::text::XText > xParent,
+        css::uno::Reference< SwXText > xParent,
         bool bIsEnd );
 
     //XTextRange
@@ -209,30 +210,30 @@ public:
     virtual css::uno::Reference< css::container::XEnumeration >  SAL_CALL 
createContentEnumeration(const OUString& aServiceName) override;
     virtual css::uno::Sequence< OUString > SAL_CALL getAvailableServiceNames() 
override;
 
-    void SetRefMark( css::uno::Reference< css::text::XTextContent > const & 
xMark)
+    void SetRefMark( rtl::Reference< SwXReferenceMark > const & xMark)
     { m_xRefMark = xMark; }
 
-    void SetTOXMark( css::uno::Reference< css::text::XTextContent > const & 
xMark)
+    void SetTOXMark( rtl::Reference< SwXDocumentIndexMark > const & xMark)
     { m_xTOXMark = xMark; }
 
-    void SetBookmark( css::uno::Reference< css::text::XTextContent > const & 
xMark)
+    void SetBookmark( rtl::Reference< SwXBookmark > const & xMark)
     { m_xBookmark = xMark; }
 
-    void SetFootnote( css::uno::Reference< css::text::XFootnote > const & 
xNote)
+    void SetFootnote( rtl::Reference< SwXFootnote > const & xNote)
     { m_xFootnote = xNote; }
 
     void SetTextField( css::uno::Reference< css::text::XTextField> const & 
xField)
     { m_xTextField = xField; }
 
-    void SetMeta( css::uno::Reference< css::text::XTextContent > const & xMeta)
+    void SetMeta( rtl::Reference< SwXMeta > const & xMeta)
     { m_xMeta = xMeta; }
 
-    void SetLineBreak(css::uno::Reference<css::text::XTextContent> const& 
xLineBreak)
+    void SetLineBreak(rtl::Reference<SwXLineBreak> const& xLineBreak)
     {
         m_xLineBreak = xLineBreak;
     }
 
-    void SetContentControl(const css::uno::Reference<css::text::XTextContent>& 
xContentControl)
+    void SetContentControl(const rtl::Reference<SwXContentControl>& 
xContentControl)
     {
         m_xContentControl = xContentControl;
     }
@@ -291,7 +292,7 @@ public:
     SwXRedlinePortion(
         SwRangeRedline const& rRedline,
         SwUnoCursor const* pPortionCursor,
-        css::uno::Reference< css::text::XText > const& xParent,
+        css::uno::Reference< SwXText > const& xParent,
         bool const bIsStart);
 
     /// @throws std::exception
diff --git a/sw/source/core/unocore/unocoll.cxx 
b/sw/source/core/unocore/unocoll.cxx
index d0f33324214b..9f7677899c9e 100644
--- a/sw/source/core/unocore/unocoll.cxx
+++ b/sw/source/core/unocore/unocoll.cxx
@@ -1748,7 +1748,7 @@ sal_Bool SwXFootnotes::hasElements()
     return !GetDoc().GetFootnoteIdxs().empty();
 }
 
-Reference<XFootnote>    SwXFootnotes::GetObject( SwDoc& rDoc, const 
SwFormatFootnote& rFormat )
+rtl::Reference<SwXFootnote> SwXFootnotes::GetObject( SwDoc& rDoc, const 
SwFormatFootnote& rFormat )
 {
     return SwXFootnote::CreateXFootnote(rDoc, 
&const_cast<SwFormatFootnote&>(rFormat));
 }
diff --git a/sw/source/core/unocore/unoport.cxx 
b/sw/source/core/unocore/unoport.cxx
index cfbe918ba2bb..bd0b9c929a75 100644
--- a/sw/source/core/unocore/unoport.cxx
+++ b/sw/source/core/unocore/unoport.cxx
@@ -62,7 +62,7 @@ void SwXTextPortion::init(const SwUnoCursor* pPortionCursor)
 
 SwXTextPortion::SwXTextPortion(
     const SwUnoCursor* pPortionCursor,
-        uno::Reference< text::XText > xParent,
+        uno::Reference< SwXText > xParent,
         SwTextPortionType eType)
     : m_pPropSet(aSwMapProvider.GetPropertySet(
         (PORTION_REDLINE_START == eType ||
@@ -84,7 +84,7 @@ SwXTextPortion::SwXTextPortion(
 
 SwXTextPortion::SwXTextPortion(
     const SwUnoCursor* pPortionCursor,
-    uno::Reference< text::XText > xParent,
+    uno::Reference< SwXText > xParent,
     SwFrameFormat& rFormat )
     : m_pPropSet(aSwMapProvider.GetPropertySet(
                     PROPERTY_MAP_TEXTPORTION_EXTENSIONS))
@@ -101,7 +101,7 @@ SwXTextPortion::SwXTextPortion(
 SwXTextPortion::SwXTextPortion(
     const SwUnoCursor* pPortionCursor,
     SwTextRuby const& rAttr,
-    uno::Reference< text::XText >  xParent,
+    uno::Reference< SwXText >  xParent,
     bool bIsEnd )
     : m_pPropSet(aSwMapProvider.GetPropertySet(
                     PROPERTY_MAP_TEXTPORTION_EXTENSIONS))
@@ -284,28 +284,28 @@ void SwXTextPortion::GetPropertyValue(
         case FN_UNO_CONTROL_CHARACTER: // obsolete!
         break;
         case FN_UNO_DOCUMENT_INDEX_MARK:
-            rVal <<= m_xTOXMark;
+            rVal <<= uno::Reference<css::text::XTextContent>(m_xTOXMark);
         break;
         case FN_UNO_REFERENCE_MARK:
-            rVal <<= m_xRefMark;
+            rVal <<= uno::Reference<css::text::XTextContent>(m_xRefMark);
         break;
         case FN_UNO_BOOKMARK:
-            rVal <<= m_xBookmark;
+            rVal <<= uno::Reference<css::text::XTextContent>(m_xBookmark);
         break;
         case FN_UNO_FOOTNOTE:
-            rVal <<= m_xFootnote;
+            rVal <<= uno::Reference<css::text::XFootnote>(m_xFootnote);
         break;
         case FN_UNO_TEXT_FIELD:
             rVal <<= m_xTextField;
         break;
         case FN_UNO_META:
-            rVal <<= m_xMeta;
+            rVal <<= uno::Reference<css::text::XTextContent>(m_xMeta);
         break;
         case FN_UNO_LINEBREAK:
-            rVal <<= m_xLineBreak;
+            rVal <<= uno::Reference<css::text::XTextContent>(m_xLineBreak);
             break;
         case FN_UNO_CONTENT_CONTROL:
-            rVal <<= m_xContentControl;
+            rVal <<= 
uno::Reference<css::text::XTextContent>(m_xContentControl);
             break;
         case FN_UNO_IS_COLLAPSED:
         {
diff --git a/sw/source/core/unocore/unoportenum.cxx 
b/sw/source/core/unocore/unoportenum.cxx
index 4b50a72cf5ad..74dea59d09bc 100644
--- a/sw/source/core/unocore/unoportenum.cxx
+++ b/sw/source/core/unocore/unoportenum.cxx
@@ -89,11 +89,11 @@ namespace
 
     struct SwXBookmarkPortion_Impl
     {
-        Reference<XTextContent>     xBookmark;
+        rtl::Reference<SwXBookmark> xBookmark;
         BkmType                     nBkmType;
         const SwPosition            aPosition;
 
-        SwXBookmarkPortion_Impl(uno::Reference<text::XTextContent> xMark,
+        SwXBookmarkPortion_Impl(rtl::Reference<SwXBookmark> xMark,
                 const BkmType nType, SwPosition _aPosition)
         : xBookmark (std::move( xMark ))
         , nBkmType  ( nType )
@@ -373,7 +373,7 @@ lcl_FillFieldMarkArray(std::deque<sal_Int32> & rFieldMarks, 
SwUnoCursor const &
 
 static rtl::Reference<SwXTextPortion>
 lcl_ExportFieldMark(
-        uno::Reference< text::XText > const & i_xParentText,
+        uno::Reference< SwXText > const & i_xParentText,
         SwUnoCursor * const pUnoCursor,
         const SwTextNode * const pTextNode )
 {
@@ -445,18 +445,14 @@ lcl_ExportFieldMark(
 
 static rtl::Reference<SwXTextPortion>
 lcl_CreateRefMarkPortion(
-    Reference<XText> const& xParent,
+    uno::Reference<SwXText> const& xParent,
     const SwUnoCursor * const pUnoCursor,
     const SwTextAttr & rAttr, const bool bEnd)
 {
     SwDoc& rDoc = pUnoCursor->GetDoc();
     SwFormatRefMark& rRefMark = const_cast<SwFormatRefMark&>(
             static_cast<const SwFormatRefMark&>(rAttr.GetAttr()));
-    Reference<XTextContent> xContent;
-    if (!xContent.is())
-    {
-        xContent = SwXReferenceMark::CreateXReferenceMark(rDoc, &rRefMark);
-    }
+    rtl::Reference<SwXReferenceMark> xContent = 
SwXReferenceMark::CreateXReferenceMark(rDoc, &rRefMark);
 
     rtl::Reference<SwXTextPortion> pPortion;
     if (!bEnd)
@@ -476,7 +472,7 @@ lcl_CreateRefMarkPortion(
 static void
 lcl_InsertRubyPortion(
     TextRangeList_t & rPortions,
-    Reference<XText> const& xParent,
+    uno::Reference<SwXText> const& xParent,
     const SwUnoCursor * const pUnoCursor,
     const SwTextAttr & rAttr, const bool bEnd)
 {
@@ -488,14 +484,14 @@ lcl_InsertRubyPortion(
 
 static rtl::Reference<SwXTextPortion>
 lcl_CreateTOXMarkPortion(
-    Reference<XText> const& xParent,
+    uno::Reference<SwXText> const& xParent,
     const SwUnoCursor * const pUnoCursor,
     SwTextAttr & rAttr, const bool bEnd)
 {
     SwDoc& rDoc = pUnoCursor->GetDoc();
     SwTOXMark & rTOXMark = static_cast<SwTOXMark&>(rAttr.GetAttr());
 
-    const Reference<XTextContent> xContent =
+    const rtl::Reference<SwXDocumentIndexMark> xContent =
         SwXDocumentIndexMark::CreateXDocumentIndexMark(rDoc, & rTOXMark);
 
     rtl::Reference<SwXTextPortion> pPortion;
@@ -568,7 +564,7 @@ lcl_CreateContentControlPortion(const 
css::uno::Reference<SwXText>& xParent,
  */
 static void lcl_ExportBookmark(
     TextRangeList_t & rPortions,
-    Reference<XText> const& xParent,
+    uno::Reference<SwXText> const& xParent,
     const SwUnoCursor * const pUnoCursor,
     SwXBookmarkPortion_ImplList& rBkmArr,
     const sal_Int32 nIndex,
@@ -628,7 +624,7 @@ static void lcl_ExportBookmark(
 
 static void lcl_ExportSoftPageBreak(
     TextRangeList_t & rPortions,
-    Reference<XText> const& xParent,
+    uno::Reference<SwXText> const& xParent,
     const SwUnoCursor * const pUnoCursor,
     SwSoftPageBreakList& rBreakArr,
     const sal_Int32 nIndex)
@@ -925,7 +921,7 @@ lcl_ExportHints(
                                 break;
                             pPortion = new SwXTextPortion(
                                 pUnoCursor, xParent, PORTION_FOOTNOTE);
-                            Reference<XFootnote> xContent =
+                            rtl::Reference<SwXFootnote> xContent =
                                 SwXFootnotes::GetObject(rDoc, 
pAttr->GetFootnote());
                             pPortion->SetFootnote(xContent);
                         }
@@ -1126,7 +1122,7 @@ static void lcl_FillSoftPageBreakArray(
 
 static void lcl_ExportRedline(
     TextRangeList_t & rPortions,
-    Reference<XText> const& xParent,
+    uno::Reference<SwXText> const& xParent,
     const SwUnoCursor * const pUnoCursor,
     SwXRedlinePortion_ImplList& rRedlineArr,
     const sal_Int32 nIndex)
@@ -1157,7 +1153,7 @@ static void lcl_ExportRedline(
 
 static void lcl_ExportBkmAndRedline(
     TextRangeList_t & rPortions,
-    Reference<XText> const & xParent,
+    uno::Reference<SwXText> const & xParent,
     const SwUnoCursor * const pUnoCursor,
     SwXBookmarkPortion_ImplList& rBkmArr,
     SwXRedlinePortion_ImplList& rRedlineArr,
@@ -1195,7 +1191,7 @@ static void lcl_ExportBkmAndRedline(
  */
 static void lcl_ExportAnnotationStarts(
     TextRangeList_t & rPortions,
-    Reference<XText> const & xParent,
+    uno::Reference<SwXText> const & xParent,
     const SwUnoCursor * const pUnoCursor,
     SwAnnotationStartPortion_ImplList& rAnnotationStartArr,
     const sal_Int32 nIndex,
@@ -1264,7 +1260,7 @@ static void 
lcl_ExtractFramePositions(FrameClientSortList_t& rFrames, sal_Int32
  */
 static sal_Int32 lcl_ExportFrames(
     TextRangeList_t & rPortions,
-    Reference<XText> const & i_xParent,
+    uno::Reference<SwXText> const & i_xParent,
     SwUnoCursor const * const i_pUnoCursor,
     FrameClientSortList_t & i_rFrames,
     sal_Int32 const i_nCurrentIndex)
diff --git a/sw/source/core/unocore/unoredline.cxx 
b/sw/source/core/unocore/unoredline.cxx
index feeceec92b31..fe16324e4238 100644
--- a/sw/source/core/unocore/unoredline.cxx
+++ b/sw/source/core/unocore/unoredline.cxx
@@ -157,7 +157,7 @@ sal_Bool SwXRedlineText::hasElements(  )
 
 SwXRedlinePortion::SwXRedlinePortion(SwRangeRedline const& rRedline,
         SwUnoCursor const*const pPortionCursor,
-        uno::Reference< text::XText > const& xParent, bool const bStart)
+        uno::Reference< SwXText > const& xParent, bool const bStart)
     : SwXTextPortion(pPortionCursor, xParent,
             bStart ? PORTION_REDLINE_START : PORTION_REDLINE_END)
     , m_rRedline(rRedline)

Reply via email to