sw/source/core/access/accpara.cxx     |    9 +++------
 sw/source/core/access/accportions.cxx |   22 +++++++++-------------
 sw/source/core/access/accportions.hxx |    4 ++--
 3 files changed, 14 insertions(+), 21 deletions(-)

New commits:
commit 139db7a35e0541bcbbdcdfccb816b53fad088f1d
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Thu Apr 24 11:12:02 2025 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Fri Apr 25 07:29:44 2025 +0200

    sw a11y: Simply use 'this'
    
    Change-Id: I0c08e1a40e63b1f3ece3ca338b97527747837819
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184562
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/sw/source/core/access/accpara.cxx 
b/sw/source/core/access/accpara.cxx
index fbdcf7695d87..4bf046938aad 100644
--- a/sw/source/core/access/accpara.cxx
+++ b/sw/source/core/access/accpara.cxx
@@ -855,8 +855,7 @@ sal_Int32 SwAccessibleParagraph::getCaretPosition()
     }
     if( -1 != nRet )
     {
-        ::rtl::Reference < SwAccessibleContext > xThis( this );
-        GetMap()->SetCursorContext( xThis );
+        GetMap()->SetCursorContext(this);
     }
 
     return nRet;
commit b268c0e484628c8a97e415bb94f33a4089148278
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Thu Apr 24 11:07:49 2025 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Fri Apr 25 07:29:37 2025 +0200

    sw a11y: Reuse existing SwAccessibleParagraph::GetTextFrame
    
    Change-Id: I05dcda9e4543b28afe618b5382a4876d4e201a47
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184561
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/sw/source/core/access/accpara.cxx 
b/sw/source/core/access/accpara.cxx
index 94fe5b7920fc..fbdcf7695d87 100644
--- a/sw/source/core/access/accpara.cxx
+++ b/sw/source/core/access/accpara.cxx
@@ -663,9 +663,7 @@ uno::Reference<XAccessibleRelationSet> SAL_CALL 
SwAccessibleParagraph::getAccess
 
     rtl::Reference<utl::AccessibleRelationSetHelper> pHelper = new 
utl::AccessibleRelationSetHelper();
 
-    const SwTextFrame* pTextFrame = GetFrame()->DynCastTextFrame();
-    OSL_ENSURE( pTextFrame,
-            "<SwAccessibleParagraph::getAccessibleRelationSet()> - missing 
text frame");
+    const SwTextFrame* pTextFrame = GetTextFrame();
     if ( pTextFrame )
     {
         const SwContentFrame* pPrevContentFrame( pTextFrame->FindPrevCnt() );
commit 875212df8b1b3d14329ad20475ed632a79ec3ac4
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Thu Apr 24 10:59:26 2025 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Fri Apr 25 07:29:29 2025 +0200

    sw a11y: Let SwAccessiblePortionData have a ref, not ptr to frame
    
    Switch SwAccessiblePortionData::m_pTextFrame from
    a pointer to a reference (and rename it) to make
    more clear this is always non-null.
    
    This also allows to drop 2 `OSL_ENSURE`s about
    it being non-null.
    
    Change-Id: I7a0563bdc246cead294ce3ba3ec866af9cbdf6d4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184560
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/sw/source/core/access/accpara.cxx 
b/sw/source/core/access/accpara.cxx
index b5dd2d54f3cc..94fe5b7920fc 100644
--- a/sw/source/core/access/accpara.cxx
+++ b/sw/source/core/access/accpara.cxx
@@ -390,7 +390,7 @@ void SwAccessibleParagraph::UpdatePortionData()
     assert(pFrame && "The text frame has vanished!");
     // build new portion data
     m_pPortionData.reset(
-        new SwAccessiblePortionData(pFrame, 
GetMap()->GetShell().GetViewOptions()));
+        new SwAccessiblePortionData(*pFrame, 
GetMap()->GetShell().GetViewOptions()));
     pFrame->VisitPortions(*m_pPortionData);
 }
 
diff --git a/sw/source/core/access/accportions.cxx 
b/sw/source/core/access/accportions.cxx
index ddeb8d89b4f4..afbae5a9a47a 100644
--- a/sw/source/core/access/accportions.cxx
+++ b/sw/source/core/access/accportions.cxx
@@ -60,16 +60,14 @@ static size_t FindLastBreak(const std::vector<T>& 
rPositions, T nValue);
 
 
 SwAccessiblePortionData::SwAccessiblePortionData(
-    const SwTextFrame *const pTextFrame,
+    const SwTextFrame& rTextFrame,
     const SwViewOption* pViewOpt ) :
-    m_pTextFrame(pTextFrame),
+    m_rTextFrame(rTextFrame),
     m_nViewPosition( 0 ),
     m_pViewOptions( pViewOpt ),
     m_nBeforePortions( 0 ),
     m_bFinished( false )
 {
-    OSL_ENSURE( m_pTextFrame != nullptr, "Need SwTextFrame!" );
-
     // reserve some space to reduce memory allocations
     m_aLineBreaks.reserve( 5 );
     m_ViewPositions.reserve( 10 );
@@ -86,7 +84,7 @@ SwAccessiblePortionData::~SwAccessiblePortionData()
 void SwAccessiblePortionData::Text(TextFrameIndex const nLength,
         PortionType nType)
 {
-    OSL_ENSURE((m_nViewPosition + nLength) <= 
TextFrameIndex(m_pTextFrame->GetText().getLength()),
+    OSL_ENSURE((m_nViewPosition + nLength) <= 
TextFrameIndex(m_rTextFrame.GetText().getLength()),
                 "portion exceeds model string!" );
 
     OSL_ENSURE( !m_bFinished, "We are already done!" );
@@ -104,7 +102,7 @@ void SwAccessiblePortionData::Text(TextFrameIndex const 
nLength,
     m_aPortionAttrs.push_back( nAttr );
 
     // update buffer + nViewPosition
-    
m_aBuffer.append(m_pTextFrame->GetText().subView(sal_Int32(m_nViewPosition), 
sal_Int32(nLength)));
+    
m_aBuffer.append(m_rTextFrame.GetText().subView(sal_Int32(m_nViewPosition), 
sal_Int32(nLength)));
     m_nViewPosition += nLength;
 }
 
@@ -112,7 +110,7 @@ void SwAccessiblePortionData::Special(
     TextFrameIndex const nLength, const OUString& rText, PortionType nType)
 {
     OSL_ENSURE(m_nViewPosition >= TextFrameIndex(0), "illegal position");
-    OSL_ENSURE((m_nViewPosition + nLength) <= 
TextFrameIndex(m_pTextFrame->GetText().getLength()),
+    OSL_ENSURE((m_nViewPosition + nLength) <= 
TextFrameIndex(m_rTextFrame.GetText().getLength()),
                 "portion exceeds model string!" );
 
     OSL_ENSURE( !m_bFinished, "We are already done!" );
@@ -159,7 +157,7 @@ void SwAccessiblePortionData::Special(
         // #i111768# - apply patch from kstribley:
         // Include the control characters.
         case PortionType::ControlChar:
-            sDisplay = rText + 
OUStringChar(m_pTextFrame->GetText()[sal_Int32(m_nViewPosition)]);
+            sDisplay = rText + 
OUStringChar(m_rTextFrame.GetText()[sal_Int32(m_nViewPosition)]);
             break;
         case PortionType::Bookmark:
             if ( m_pViewOptions->IsShowBookmarks() )
@@ -206,7 +204,7 @@ void SwAccessiblePortionData::Skip(TextFrameIndex const 
nLength)
 {
     OSL_ENSURE( !m_bFinished, "We are already done!" );
     OSL_ENSURE( m_ViewPositions.empty(), "Never Skip() after portions" );
-    OSL_ENSURE(nLength <= TextFrameIndex(m_pTextFrame->GetText().getLength()),
+    OSL_ENSURE(nLength <= TextFrameIndex(m_rTextFrame.GetText().getLength()),
             "skip exceeds model string!" );
 
     m_nViewPosition += nLength;
@@ -465,7 +463,7 @@ void SwAccessiblePortionData::GetSentenceBoundary(
 
             sal_Int32 nNew = g_pBreakIt->GetBreakIter()->endOfSentence(
                 m_sAccessibleString, nCurrent,
-                g_pBreakIt->GetLocale(m_pTextFrame->GetLangOfChar(nFramePos, 
0, true))) + 1;
+                g_pBreakIt->GetLocale(m_rTextFrame.GetLangOfChar(nFramePos, 0, 
true))) + 1;
 
             if( (nNew < 0) && (nNew > nLength) )
                 nNew = nLength;
@@ -488,8 +486,6 @@ void SwAccessiblePortionData::GetAttributeBoundary(
     Boundary& rBound,
     sal_Int32 nPos) const
 {
-    OSL_ENSURE( m_pTextFrame != nullptr, "Need SwTextNode!" );
-
     // attribute boundaries can only occur on portion boundaries
     FillBoundary( rBound, m_aAccessiblePositions,
                   FindBreak( m_aAccessiblePositions, nPos ) );
@@ -497,7 +493,7 @@ void SwAccessiblePortionData::GetAttributeBoundary(
 
 sal_Int32 SwAccessiblePortionData::GetAccessiblePosition(TextFrameIndex const 
nPos) const
 {
-    OSL_ENSURE(nPos <= TextFrameIndex(m_pTextFrame->GetText().getLength()), 
"illegal position");
+    OSL_ENSURE(nPos <= TextFrameIndex(m_rTextFrame.GetText().getLength()), 
"illegal position");
 
     // find the portion number
     // #i70538# - consider "empty" model portions - e.g. number portion
diff --git a/sw/source/core/access/accportions.hxx 
b/sw/source/core/access/accportions.hxx
index 482355241374..37a1f013704b 100644
--- a/sw/source/core/access/accportions.hxx
+++ b/sw/source/core/access/accportions.hxx
@@ -39,7 +39,7 @@ namespace com::sun::star {
 class SwAccessiblePortionData : public SwPortionHandler
 {
     // the frame this portion is referring to
-    SwTextFrame const* m_pTextFrame;
+    const SwTextFrame& m_rTextFrame;
 
     // variables used while collecting the data
     OUStringBuffer m_aBuffer;
@@ -86,7 +86,7 @@ class SwAccessiblePortionData : public SwPortionHandler
                          TextFrameIndex& rCorePos, bool& bEdit) const;
 
 public:
-    SwAccessiblePortionData( const SwTextFrame* pTextFrame,
+    SwAccessiblePortionData(const SwTextFrame& rTextFrame,
                              const SwViewOption* pViewOpt );
     virtual ~SwAccessiblePortionData() override;
 

Reply via email to