sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx |   18 +++++------
 1 file changed, 9 insertions(+), 9 deletions(-)

New commits:
commit 2cf36848ddfd802287f467aaf85b1c73739634f4
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Tue Apr 29 18:08:25 2025 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Tue Apr 29 23:11:09 2025 +0200

    sc a11y: Switch ScNotesChildren::mpAccDoc to ref
    
    Use a reference instead of a pointer, to make clearer this is always
    non-null. This also allows to drop a null check in
    ScNotesChildren::DataChanged.
    
    Change-Id: Ief02eaafa7cd67a1ceb9562bf0a62435e4b877a2
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184791
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx 
b/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx
index 65c2e9b35c56..cbfc9403b9cd 100644
--- a/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx
+++ b/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx
@@ -87,7 +87,7 @@ struct ScAccNote
 class ScNotesChildren
 {
 public:
-    ScNotesChildren(ScPreviewShell* pViewShell, 
ScAccessibleDocumentPagePreview* pAccDoc);
+    ScNotesChildren(ScPreviewShell* pViewShell, 
ScAccessibleDocumentPagePreview& rAccDoc);
     ~ScNotesChildren();
     void Init(const tools::Rectangle& rVisRect, sal_Int32 nOffset);
 
@@ -99,7 +99,7 @@ public:
 
 private:
     ScPreviewShell*         mpViewShell;
-    ScAccessibleDocumentPagePreview* mpAccDoc;
+    ScAccessibleDocumentPagePreview& mrAccDoc;
     typedef std::vector<ScAccNote> ScAccNotes;
     mutable ScAccNotes      maNotes;
     mutable ScAccNotes      maMarks;
@@ -118,9 +118,9 @@ private:
     inline ScDocument* GetDocument() const;
 };
 
-ScNotesChildren::ScNotesChildren(ScPreviewShell* pViewShell, 
ScAccessibleDocumentPagePreview* pAccDoc)
+ScNotesChildren::ScNotesChildren(ScPreviewShell* pViewShell, 
ScAccessibleDocumentPagePreview& rAccDoc)
     : mpViewShell(pViewShell),
-    mpAccDoc(pAccDoc),
+    mrAccDoc(rAccDoc),
     mnParagraphs(0),
     mnOffset(0)
 {
@@ -145,7 +145,7 @@ ScNotesChildren::~ScNotesChildren()
 ::accessibility::AccessibleTextHelper* ScNotesChildren::CreateTextHelper(const 
OUString& rString, const tools::Rectangle& rVisRect, const ScAddress& aCellPos, 
bool bMarkNote, sal_Int32 nChildOffset) const
 {
     ::accessibility::AccessibleTextHelper* pTextHelper = new 
::accessibility::AccessibleTextHelper(std::make_unique<ScAccessibilityEditSource>(std::make_unique<ScAccessibleNoteTextData>(mpViewShell,
 rString, aCellPos, bMarkNote)));
-    pTextHelper->SetEventSource(mpAccDoc);
+    pTextHelper->SetEventSource(&mrAccDoc);
     pTextHelper->SetStartIndex(nChildOffset);
     pTextHelper->SetOffset(rVisRect.TopLeft());
 
@@ -461,7 +461,7 @@ struct ScChildNew
 
 void ScNotesChildren::DataChanged(const tools::Rectangle& rVisRect)
 {
-    if (!(mpViewShell && mpAccDoc))
+    if (!mpViewShell)
         return;
 
     ScXAccVector aNewParas;
@@ -477,8 +477,8 @@ void ScNotesChildren::DataChanged(const tools::Rectangle& 
rVisRect)
         maNotes = std::move(aNewNotes);
     }
 
-    std::for_each(aOldParas.begin(), aOldParas.end(), ScChildGone(mpAccDoc));
-    std::for_each(aNewParas.begin(), aNewParas.end(), ScChildNew(mpAccDoc));
+    std::for_each(aOldParas.begin(), aOldParas.end(), ScChildGone(&mrAccDoc));
+    std::for_each(aNewParas.begin(), aNewParas.end(), ScChildNew(&mrAccDoc));
 }
 
 inline ScDocument* ScNotesChildren::GetDocument() const
@@ -1496,7 +1496,7 @@ ScNotesChildren* 
ScAccessibleDocumentPagePreview::GetNotesChildren()
 {
     if (!mpNotesChildren && mpViewShell)
     {
-        mpNotesChildren.reset( new ScNotesChildren(mpViewShell, this) );
+        mpNotesChildren.reset(new ScNotesChildren(mpViewShell, *this));
 
         const ScPreviewLocationData& rData = mpViewShell->GetLocationData();
         ScPagePreviewCountData aCount( rData, mpViewShell->GetWindow(), 
GetNotesChildren(), GetShapeChildren() );

Reply via email to