sw/inc/unoredline.hxx                  |    3 +--
 sw/inc/unoredlines.hxx                 |    2 +-
 sw/source/core/unocore/unoredline.cxx  |   25 ++++++++++++-------------
 sw/source/core/unocore/unoredlines.cxx |   11 +++++------
 4 files changed, 19 insertions(+), 22 deletions(-)

New commits:
commit 187573296508e2c80d1de63e0c4db18bd7cdcf9c
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Tue Jul 1 13:58:02 2025 +0500
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Tue Jul 1 12:16:39 2025 +0200

    Simplify SwXRedline
    
    It doesn't need own m_pDoc (SwXText has one already); and its ctor
    doesn't need an SwDoc& argument (it is deducible from rRedline).
    
    Change-Id: I93e72ba824a697df2d3654336c3f5c44192083eb
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187230
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/sw/inc/unoredline.hxx b/sw/inc/unoredline.hxx
index 90f9d212a168..84c40e50bf27 100644
--- a/sw/inc/unoredline.hxx
+++ b/sw/inc/unoredline.hxx
@@ -69,10 +69,9 @@ class SwXRedline final
     , public SwXText
     , public SvtListener
 {
-    SwDoc*      m_pDoc;
     SwRangeRedline*  m_pRedline;
 public:
-    SwXRedline(SwRangeRedline& rRedline, SwDoc& rDoc);
+    SwXRedline(SwRangeRedline& rRedline);
     virtual ~SwXRedline() override;
 
 
diff --git a/sw/inc/unoredlines.hxx b/sw/inc/unoredlines.hxx
index 894f5a0e7937..d953228535ab 100644
--- a/sw/inc/unoredlines.hxx
+++ b/sw/inc/unoredlines.hxx
@@ -61,7 +61,7 @@ public:
     virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) 
override;
     virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() 
override;
 
-    static css::beans::XPropertySet*           GetObject( SwRangeRedline& 
rRedline, SwDoc& rDoc );
+    static css::uno::Reference<css::beans::XPropertySet> 
GetObject(SwRangeRedline& rRedline);
 };
 
 class SwXRedlineEnumeration final
diff --git a/sw/source/core/unocore/unoredline.cxx 
b/sw/source/core/unocore/unoredline.cxx
index 5c3861fc52b7..0c7cb87f47ec 100644
--- a/sw/source/core/unocore/unoredline.cxx
+++ b/sw/source/core/unocore/unoredline.cxx
@@ -374,12 +374,11 @@ uno::Sequence< beans::PropertyValue > 
SwXRedlinePortion::CreateRedlineProperties
     return aRet;
 }
 
-SwXRedline::SwXRedline(SwRangeRedline& rRedline, SwDoc& rDoc) :
-    SwXText(&rDoc, CursorType::Redline),
-    m_pDoc(&rDoc),
+SwXRedline::SwXRedline(SwRangeRedline& rRedline) :
+    SwXText(&rRedline.GetDoc(), CursorType::Redline),
     m_pRedline(&rRedline)
 {
-    
StartListening(m_pDoc->getIDocumentStylePoolAccess().GetPageDescFromPool(RES_POOLPAGE_STANDARD)->GetNotifier());
+    
StartListening(GetDoc()->getIDocumentStylePoolAccess().GetPageDescFromPool(RES_POOLPAGE_STANDARD)->GetNotifier());
 }
 
 SwXRedline::~SwXRedline()
@@ -396,7 +395,7 @@ uno::Reference< beans::XPropertySetInfo > 
SwXRedline::getPropertySetInfo(  )
 void SwXRedline::setPropertyValue( const OUString& rPropertyName, const 
uno::Any& aValue )
 {
     SolarMutexGuard aGuard;
-    if(!m_pDoc)
+    if (!GetDoc())
         throw uno::RuntimeException();
     if(rPropertyName == UNO_NAME_REDLINE_AUTHOR)
     {
@@ -435,7 +434,7 @@ void SwXRedline::setPropertyValue( const OUString& 
rPropertyName, const uno::Any
 uno::Any SwXRedline::getPropertyValue( const OUString& rPropertyName )
 {
     SolarMutexGuard aGuard;
-    if(!m_pDoc)
+    if (!GetDoc())
         throw uno::RuntimeException();
     uno::Any aRet;
     bool bStart = rPropertyName == UNO_NAME_REDLINE_START;
@@ -464,7 +463,7 @@ uno::Any SwXRedline::getPropertyValue( const OUString& 
rPropertyName )
             break;
             case SwNodeType::Text :
             {
-                xRet = cppu::getXWeak(SwXTextRange::CreateXTextRange(*m_pDoc, 
*pPoint, nullptr).get());
+                xRet = 
cppu::getXWeak(SwXTextRange::CreateXTextRange(*GetDoc(), *pPoint, 
nullptr).get());
             }
             break;
             default:
@@ -479,7 +478,7 @@ uno::Any SwXRedline::getPropertyValue( const OUString& 
rPropertyName )
         {
             if ( SwNodeOffset(1) < ( pNodeIdx->GetNode().EndOfSectionIndex() - 
pNodeIdx->GetNode().GetIndex() ) )
             {
-                uno::Reference<text::XText> xRet = new SwXRedlineText(m_pDoc, 
*pNodeIdx);
+                uno::Reference<text::XText> xRet = new 
SwXRedlineText(GetDoc(), *pNodeIdx);
                 aRet <<= xRet;
             }
             else {
@@ -522,7 +521,7 @@ void SwXRedline::Notify( const SfxHint& rHint )
 {
     if(rHint.GetId() == SfxHintId::Dying)
     {
-        m_pDoc = nullptr;
+        SetDoc(nullptr);
         m_pRedline = nullptr;
     }
     else if(rHint.GetId() == SfxHintId::SwFindRedline)
@@ -536,7 +535,7 @@ void SwXRedline::Notify( const SfxHint& rHint )
 uno::Reference< container::XEnumeration >  SwXRedline::createEnumeration()
 {
     SolarMutexGuard aGuard;
-    if(!m_pDoc)
+    if (!GetDoc())
         throw uno::RuntimeException();
 
     const SwNodeIndex* pNodeIndex = m_pRedline->GetContentIdx();
@@ -555,14 +554,14 @@ uno::Type SwXRedline::getElementType(  )
 
 sal_Bool SwXRedline::hasElements(  )
 {
-    if(!m_pDoc)
+    if (!GetDoc())
         throw uno::RuntimeException();
     return nullptr != m_pRedline->GetContentIdx();
 }
 
 rtl::Reference< SwXTextCursor >  SwXRedline::createXTextCursor()
 {
-    if(!m_pDoc)
+    if (!GetDoc())
         throw uno::RuntimeException();
 
     const SwNodeIndex* pNodeIndex = m_pRedline->GetContentIdx();
@@ -573,7 +572,7 @@ rtl::Reference< SwXTextCursor >  
SwXRedline::createXTextCursor()
 
     SwPosition aPos(*pNodeIndex);
     rtl::Reference<SwXTextCursor> pXCursor =
-        new SwXTextCursor(*m_pDoc, this, CursorType::Redline, aPos);
+        new SwXTextCursor(*GetDoc(), this, CursorType::Redline, aPos);
     auto& rUnoCursor(pXCursor->GetCursor());
     rUnoCursor.Move(fnMoveForward, GoInNode);
 
diff --git a/sw/source/core/unocore/unoredlines.cxx 
b/sw/source/core/unocore/unoredlines.cxx
index 70f949a33f2f..f573f835db2b 100644
--- a/sw/source/core/unocore/unoredlines.cxx
+++ b/sw/source/core/unocore/unoredlines.cxx
@@ -61,7 +61,7 @@ uno::Any SwXRedlines::getByIndex(sal_Int32 nIndex)
     if ((nIndex < 0) || (rRedTable.size() <= o3tl::make_unsigned(nIndex)))
         throw lang::IndexOutOfBoundsException();
 
-    uno::Reference<beans::XPropertySet> xRet = 
SwXRedlines::GetObject(*rRedTable[nIndex], rDoc);
+    uno::Reference<beans::XPropertySet> xRet = 
SwXRedlines::GetObject(*rRedTable[nIndex]);
     return uno::Any(xRet);
 }
 
@@ -99,12 +99,12 @@ uno::Sequence< OUString > 
SwXRedlines::getSupportedServiceNames()
     return uno::Sequence< OUString >();
 }
 
-beans::XPropertySet* SwXRedlines::GetObject( SwRangeRedline& rRedline, SwDoc& 
rDoc )
+css::uno::Reference<css::beans::XPropertySet> 
SwXRedlines::GetObject(SwRangeRedline& rRedline)
 {
     SwXRedline* pXRedline(nullptr);
     sw::FindRedlineHint aHint(rRedline, &pXRedline);
-    
rDoc.getIDocumentStylePoolAccess().GetPageDescFromPool(RES_POOLPAGE_STANDARD)->GetNotifier().Broadcast(aHint);
-    return pXRedline ? pXRedline : new SwXRedline(rRedline, rDoc);
+    
rRedline.GetDoc().getIDocumentStylePoolAccess().GetPageDescFromPool(RES_POOLPAGE_STANDARD)->GetNotifier().Broadcast(aHint);
+    return pXRedline ? pXRedline : new SwXRedline(rRedline);
 }
 
 SwXRedlineEnumeration::SwXRedlineEnumeration(SwDoc& rDoc) :
@@ -132,9 +132,8 @@ uno::Any SwXRedlineEnumeration::nextElement()
     const SwRedlineTable& rRedTable = 
m_pDoc->getIDocumentRedlineAccess().GetRedlineTable();
     if( rRedTable.size() <= m_nCurrentIndex )
         throw container::NoSuchElementException();
-    uno::Reference <beans::XPropertySet> xRet = SwXRedlines::GetObject( 
*rRedTable[m_nCurrentIndex++], *m_pDoc );
     uno::Any aRet;
-    aRet <<= xRet;
+    aRet <<= SwXRedlines::GetObject(*rRedTable[m_nCurrentIndex++]);
     return aRet;
 }
 

Reply via email to