tdf#168572: crash during markdown export when Writer doc contains a formula

Change-Id: I7604aa1c603e41fdd2c45c8de780329abe83ffb7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191568
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
This commit is contained in:
Julien Nabet
2025-09-29 09:10:15 +02:00
committed by Miklos Vajna
parent 1a9b45700f
commit 6ed10a3e49
+19 -8
View File
@@ -47,6 +47,7 @@
#include <charatr.hxx>
#include <fmtcntnt.hxx>
#include <ndgrf.hxx>
#include <ndole.hxx>
#include <fmturl.hxx>
#include "wrtmd.hxx"
@@ -217,17 +218,27 @@ void ApplyItem(SwMDWriter& rWrt, FormattingStatus& rChange, const SfxPoolItem& r
= static_cast<const SwFlyFrameFormat&>(*rFormatFlyCnt.GetFrameFormat());
const SwFormatContent& rFlyContent = rFrameFormat.GetContent();
SwNodeOffset nStart = rFlyContent.GetContentIdx()->GetIndex() + 1;
SwGrfNode* pGrfNode = rWrt.m_pDoc->GetNodes()[nStart]->GetGrfNode();
Graphic aGraphic = pGrfNode->GetGraphic();
if (!pGrfNode->IsLinkedFile())
Graphic aGraphic;
OUString aGraphicURL;
if (rWrt.m_pDoc->GetNodes()[nStart]->GetNodeType() == SwNodeType::Grf)
{
// Not linked, ignore for now.
break;
SwGrfNode* pGrfNode = rWrt.m_pDoc->GetNodes()[nStart]->GetGrfNode();
aGraphic = pGrfNode->GetGraphic();
if (!pGrfNode->IsLinkedFile())
{
// Not linked, ignore for now.
break;
}
pGrfNode->GetFileFilterNms(&aGraphicURL, /*pFilterNm=*/nullptr);
}
else
{
SwOLENode* pOLENode = rWrt.m_pDoc->GetNodes()[nStart]->GetOLENode();
assert(pOLENode->GetGraphic());
aGraphic = *pOLENode->GetGraphic();
// TODO fill aGraphicURL with the right info
}
// Try to extract a relative URL and a title.
OUString aGraphicURL;
pGrfNode->GetFileFilterNms(&aGraphicURL, /*pFilterNm=*/nullptr);
const OUString& rBaseURL = rWrt.GetBaseURL();
if (!rBaseURL.isEmpty())
{