sw/source/filter/md/wrtmd.cxx |   27 +++++++++++++++++++--------
 1 file changed, 19 insertions(+), 8 deletions(-)

New commits:
commit 7bd756e767c918e9304be5633809f2e3f7c2c5de
Author:     Julien Nabet <[email protected]>
AuthorDate: Sat Sep 27 16:58:32 2025 +0200
Commit:     Miklos Vajna <[email protected]>
CommitDate: Mon Sep 29 17:20:53 2025 +0200

    tdf#168572: crash during markdown export when Writer doc contains a formula
    
    (cherry picked from commit 6ed10a3e493a944d1e8462c46a6a98b7aff07d0b)
    
    Change-Id: I7604aa1c603e41fdd2c45c8de780329abe83ffb7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191624
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Miklos Vajna <[email protected]>

diff --git a/sw/source/filter/md/wrtmd.cxx b/sw/source/filter/md/wrtmd.cxx
index 3f4fde819a58..afa904598ec5 100644
--- a/sw/source/filter/md/wrtmd.cxx
+++ b/sw/source/filter/md/wrtmd.cxx
@@ -47,6 +47,7 @@
 #include <charatr.hxx>
 #include <fmtcntnt.hxx>
 #include <ndgrf.hxx>
+#include <ndole.hxx>
 #include <fmturl.hxx>
 #include "wrtmd.hxx"
 
@@ -207,17 +208,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())
             {

Reply via email to