sw/source/core/text/EnhancedPDFExportHelper.cxx |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

New commits:
commit 4666d701312615b43e698f67e3443dc1a13dcf20
Author:     Michael Stahl <michael.st...@collabora.com>
AuthorDate: Wed Sep 10 20:38:40 2025 +0200
Commit:     Thorsten Behrens <thorsten.behr...@collabora.com>
CommitDate: Mon Sep 15 15:03:24 2025 +0200

    sw: PDF export: fix crash on section in table in section
    
    soffice.bin: vcl/source/gdi/pdfextoutdevdata.cxx:798: void 
vcl::PDFExtOutDevData::EndStructureElement(): Assertion 
`mpGlobalSyncData->mCurrentStructElement != 0' failed.
    
    The problem is that the parent-opening code in
    SwTaggedPDFHelper::BeginBlockStructureElements() when called for a
    section in a table cell opens a section that is outside the table.
    
    In this case, there are actually 2 section frames, one containing the
    table and one in the table cell, so reopening the outer section frame
    that is already on the stack ends up restoring a 0 parent SE and that
    triggers the assert.
    
    (regression from commit d5f68529a79c615f989fcfeef248d887a6e10f5a)
    
    Change-Id: Idd5be655345f96e1c2de84c5623f6e1dba4aae1b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190781
    Reviewed-by: Michael Stahl <michael.st...@collabora.com>
    Tested-by: Jenkins
    (cherry picked from commit 7a036a64581a96a05e4833611801ac304d75524f)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190817
    Reviewed-by: Thorsten Behrens <thorsten.behr...@collabora.com>

diff --git a/sw/source/core/text/EnhancedPDFExportHelper.cxx 
b/sw/source/core/text/EnhancedPDFExportHelper.cxx
index 62052080d479..af0960ce4653 100644
--- a/sw/source/core/text/EnhancedPDFExportHelper.cxx
+++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx
@@ -1449,10 +1449,13 @@ void SwTaggedPDFHelper::BeginBlockStructureElements()
                 // open all parent sections, so that the SEs of sections
                 // are nested in the same way as their SwSectionNodes
                 std::vector<SwSection const*> parents;
-                for (SwSection const* pParent = pSection->GetParent();
-                     pParent != nullptr; pParent = pParent->GetParent())
+                // iterate only *direct* parents - do not leave table cell!
+                for (SwSectionNode const* pSectionNode{pSection->GetFormat()
+                        
->GetSectionNode()->StartOfSectionNode()->GetSectionNode()};
+                    pSectionNode != nullptr;
+                    pSectionNode = 
pSectionNode->StartOfSectionNode()->GetSectionNode())
                 {
-                    parents.push_back(pParent);
+                    parents.push_back(&pSectionNode->GetSection());
                 }
                 for (auto it = parents.rbegin(); it != parents.rend(); ++it)
                 {

Reply via email to