vcl/source/gdi/pdfwriter_impl.cxx |    3 +++
 1 file changed, 3 insertions(+)

New commits:
commit 22fd7ccb913c55db14adf736859fc9e0e7f00630
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Tue Apr 4 12:25:44 2023 +0200
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Tue Apr 4 13:54:25 2023 +0200

    vcl: PDF export: fix erroneous MCID produced for 1st page
    
    PDFWriterImpl::beginStructureElementMCSeq() emits a spurious MCID
    definition outside of any stream, before the 1st page:
    
      /Document<</MCID 1>>BDC
      % PDFPage::emit
      1 0 obj
      <</Type/Page/Parent...
    
    This is because SwPageFrame is translated to a Document StructElem in
    EnhancedPDFExportHelper, but PDFPage::emit is called at a later time
    than when the page content stream is produced, so this is just wrong; an
    MCID inside the page content stream is pointless because that's an
    object already anyway, so just suppress this.
    
    Looks like other applications don't produce Document currently.
    
    Change-Id: Ic2e30e4125c0e97c8e47330c7a247f74efc18f98
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150017
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/vcl/source/gdi/pdfwriter_impl.cxx 
b/vcl/source/gdi/pdfwriter_impl.cxx
index f5837c48ba7b..242172313940 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -10622,6 +10622,9 @@ void PDFWriterImpl::beginStructureElementMCSeq()
 {
     if( m_bEmitStructure &&
         m_nCurrentStructElement > 0 && // StructTreeRoot
+        // Document = SwPageFrame => this is not *inside* the page content
+        // stream so do not emit MCID!
+        m_aStructure[m_nCurrentStructElement].m_eType != PDFWriter::Document &&
         ! m_aStructure[ m_nCurrentStructElement ].m_bOpenMCSeq // already 
opened sequence
         )
     {

Reply via email to