vcl/source/pdf/pdfwriter_impl.cxx |   25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

New commits:
commit 4bf07d898cd3084ff9012f11776d1489b103236c
Author:     Xisco Fauli <[email protected]>
AuthorDate: Wed Feb 25 17:57:39 2026 +0100
Commit:     Xisco Fauli <[email protected]>
CommitDate: Wed Feb 25 21:19:31 2026 +0100

    tdf#168057: use RoleMapNS in PDF/UA-2
    
    This commit reverts my previous attempt at fixing the same issue
    commit 5dbf35a932bfa00e17f17b1f2337de7403754b8d
    Author: Xisco Fauli <[email protected]>
    Date:   Wed Feb 25 12:54:41 2026 +0100
    
        tdf#168057: Don't use aliases in StructElem when exporting to PDF/UA-2
    
    Change-Id: I20ef86c780224909a7fa9414fea628415289af60
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200350
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <[email protected]>

diff --git a/vcl/source/pdf/pdfwriter_impl.cxx 
b/vcl/source/pdf/pdfwriter_impl.cxx
index d8262a94c6aa..25354a1e4604 100644
--- a/vcl/source/pdf/pdfwriter_impl.cxx
+++ b/vcl/source/pdf/pdfwriter_impl.cxx
@@ -1027,11 +1027,21 @@ void PDFWriterImpl::emitNamespaces()
         if (!updateObject(nObject))
             return;
 
-        COSWriter aWriter(m_aContext.Encryption.getParams(), m_pPDFEncryptor);
+        OStringBuffer aLine;
+        COSWriter aWriter(aLine, m_aContext.Encryption.getParams(), 
m_pPDFEncryptor);
         aWriter.startObject(nObject);
         aWriter.startDict();
         aWriter.write("/Type", "/Namespace");
         aWriter.writeKeyAndLiteral("/NS", sNamespace);
+        if( ! m_aRoleMap.empty() )
+        {
+            aLine.append( "/RoleMapNS<<" );
+            for (auto const& role : m_aRoleMap)
+            {
+                aLine.append( "/" + role.first + "/" + role.second + "
" );
+            }
+            aLine.append( ">>
" );
+        }
         aWriter.endDict();
         aWriter.endObject();
 
@@ -1130,17 +1140,10 @@ sal_Int32 PDFWriterImpl::emitStructure( 
PDFStructureElement& rEle )
                 aWriter.writeKeyAndReference("/NS", iterator->second);
         }
         aLine.append("/S/");
-        if (m_aContext.Version >= PDFWriter::PDFVersion::PDF_2_0)
-        {
-            aLine.append( getStructureTag(*rEle.m_oType) );
-        }
+        if( !rEle.m_aAlias.isEmpty() )
+            aLine.append( rEle.m_aAlias );
         else
-        {
-            if( !rEle.m_aAlias.isEmpty() )
-                aLine.append( rEle.m_aAlias );
-            else
-                aLine.append( getStructureTag(*rEle.m_oType) );
-        }
+            aLine.append( getStructureTag(*rEle.m_oType) );
         if (m_StructElemObjsWithID.find(rEle.m_nObject) != 
m_StructElemObjsWithID.end())
         {
             aLine.append("
/ID ");

Reply via email to