diff options
-rw-r--r-- | sw/source/uibase/utlui/content.cxx | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx index 2f0bdc06f739..c5f2b3e3afa9 100644 --- a/sw/source/uibase/utlui/content.cxx +++ b/sw/source/uibase/utlui/content.cxx @@ -6092,8 +6092,24 @@ void SwContentTree::BringEntryToAttention(const weld::TreeIter& rEntry) } else if (nType == ContentTypeId::URLFIELD) { - BringURLFieldsToAttention(SwGetINetAttrs {SwGetINetAttr(pCnt->GetName(), - *static_cast<SwURLFieldContent*>(pCnt)->GetINetAttr())}); + // tdf#159147 - Assure the SwURLFieldContent::SwTextINetFormat pointer is valid + // before bringing to attention. + const SwTextINetFormat* pTextINetFormat + = static_cast<SwURLFieldContent*>(pCnt)->GetINetAttr(); + const SwCharFormats* pFormats = m_pActiveShell->GetDoc()->GetCharFormats(); + for (auto n = pFormats->size(); 1 < n;) + { + SwIterator<SwTextINetFormat, SwCharFormat> aIter(*(*pFormats)[--n]); + for (SwTextINetFormat* pFnd = aIter.First(); pFnd; pFnd = aIter.Next() ) + { + if (pTextINetFormat == pFnd) + { + BringURLFieldsToAttention(SwGetINetAttrs {SwGetINetAttr(pCnt->GetName(), + *pTextINetFormat)}); + break; + } + } + } } else if (nType == ContentTypeId::REFERENCE) { |