sw/source/core/access/AccessibilityCheck.cxx | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-)
New commits: commit e827d051971a331c16bca8a58ab1c921736810ee Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Mon Oct 21 15:56:25 2024 +0200 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Tue Oct 22 11:46:06 2024 +0200 tdf#163543: check GetDocShell() Similar to commit c5f4fe10589acff4d253cc3d32acaf67c7456bd7 Author: Caolán McNamara <caolan.mcnam...@collabora.com> Date: Thu Oct 3 15:14:05 2024 +0100 check for null DocShell before deref Change-Id: I910fb934a36b0e68fd8bda59516c21aa9d27d09a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175338 Reviewed-by: Balazs Varga <balazs.varga.ext...@allotropia.de> Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175364 diff --git a/sw/source/core/access/AccessibilityCheck.cxx b/sw/source/core/access/AccessibilityCheck.cxx index df4a710ecf9c..0d63ed192696 100644 --- a/sw/source/core/access/AccessibilityCheck.cxx +++ b/sw/source/core/access/AccessibilityCheck.cxx @@ -553,6 +553,10 @@ private: aBackgroundColor = nParaBackColor; else { + SwDocShell* pDocShell = pTextNode->GetDoc().GetDocShell(); + if (!pDocShell) + return; + OUString sCharStyleName; Color nCharStyleBackColor(COL_AUTO); if (xProperties->getPropertyValue(u"CharStyleName"_ustr) >>= sCharStyleName) @@ -560,7 +564,7 @@ private: try { uno::Reference<style::XStyleFamiliesSupplier> xStyleFamiliesSupplier( - pTextNode->GetDoc().GetDocShell()->GetModel(), uno::UNO_QUERY); + pDocShell->GetModel(), uno::UNO_QUERY); uno::Reference<container::XNameAccess> xCont = xStyleFamiliesSupplier->getStyleFamilies(); uno::Reference<container::XNameAccess> xStyleFamily( @@ -1461,6 +1465,14 @@ public: SwTextNode* pTextNode = pCurrent->GetTextNode(); SwDoc& rDocument = pTextNode->GetDoc(); + SwDocShell* pDocShell = rDocument.GetDocShell(); + if (!pDocShell) + return; + + SwWrtShell* pWrtShell = pDocShell->GetWrtShell(); + if (!pWrtShell) + return; + auto nParagraphLength = pTextNode->GetText().getLength(); if (nParagraphLength == 0) { @@ -1468,8 +1480,7 @@ public: if (!pPrevTextNode) return; - SwWrtShell* pWrtShell = rDocument.GetDocShell()->GetWrtShell(); - if (pWrtShell && pPrevTextNode->getLayoutFrame(pWrtShell->GetLayout())) + if (pPrevTextNode->getLayoutFrame(pWrtShell->GetLayout())) { if (pPrevTextNode->GetText().getLength() == 0) { @@ -1483,8 +1494,7 @@ public: } else { - SwWrtShell* pWrtShell = rDocument.GetDocShell()->GetWrtShell(); - if (pWrtShell && pTextNode->getLayoutFrame(pWrtShell->GetLayout())) + if (pTextNode->getLayoutFrame(pWrtShell->GetLayout())) { // Check for excess lines inside this paragraph const OUString& sParagraphText = pTextNode->GetText(); @@ -2179,7 +2189,12 @@ public: } void check(SwDoc* pDoc) override { - uno::Reference<lang::XComponent> xDoc = pDoc->GetDocShell()->GetBaseModel(); + SwDocShell* pDocShell = pDoc->GetDocShell(); + if (!pDocShell) + return; + uno::Reference<lang::XComponent> xDoc = pDocShell->GetBaseModel(); + if (!xDoc) + return; uno::Reference<style::XStyleFamiliesSupplier> xStyleFamiliesSupplier(xDoc, uno::UNO_QUERY); if (!xStyleFamiliesSupplier.is()) return;