[Libreoffice-commits] core.git: 2 commits - filter/source vcl/source

Tomaž Vajngerl (via logerrit) logerrit at kemper.freedesktop.org
Sat Jan 4 16:37:15 UTC 2020


 filter/source/pdf/pdfexport.cxx   |    7 +++++++
 vcl/source/gdi/pdfwriter_impl.cxx |   16 +++++++++++++---
 vcl/source/gdi/pdfwriter_impl.hxx |    2 ++
 3 files changed, 22 insertions(+), 3 deletions(-)

New commits:
commit b0a468d75ff96955e9e53027d35b248235cb68d0
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Sat Jan 4 11:24:24 2020 +0100
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Sat Jan 4 17:36:54 2020 +0100

    pdf: set the UniversalAccessibilityCompliance from the dialog
    
    Change-Id: I380b760a39bcdbef271c948690b1c9a95c769b4f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86213
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/filter/source/pdf/pdfexport.cxx b/filter/source/pdf/pdfexport.cxx
index 00e279047f73..5e5a9ccb930c 100644
--- a/filter/source/pdf/pdfexport.cxx
+++ b/filter/source/pdf/pdfexport.cxx
@@ -612,6 +612,13 @@ bool PDFExport::Export( const OUString& rFile, const Sequence< PropertyValue >&
                 break;
             }
 
+            // PDF/UA support
+            aContext.UniversalAccessibilityCompliance = mbPDFUACompliance;
+            if (mbPDFUACompliance)
+            {
+                mbUseTaggedPDF = true;
+            }
+
             // copy in context the values default in the constructor or set by the FilterData sequence of properties
             aContext.Tagged     = mbUseTaggedPDF;
 
commit 197bbc5f17ac7f11cb07aefb935182eae1bc5ada
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Fri Jan 3 12:40:16 2020 +0100
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Sat Jan 4 17:36:35 2020 +0100

    pdf: Only add role map when alias isn't the same as structure tag
    
    It is not allowed in PDF/UA to override a structure tag. This
    also true when you have an alias with the same name as a structure
    tage. For example to define a "H1" that is an alias for the "H1"
    structure tage. This is probably done in LO "just in case".
    
    With this change, if the structure tag and alias are the same, it
    will not get added to the role map, but this only happens when
    PDF/UA is enabled.
    
    Change-Id: Iff37c31ad31e5a01d7847ddb57f9b0e4c7b247db
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86212
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index c5078143874c..31daa05a73bd 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -10080,6 +10080,16 @@ const char* PDFWriterImpl::getStructureTag( PDFWriter::StructElement eType )
     return it != aTagStrings.end() ? it->second : "Div";
 }
 
+void PDFWriterImpl::addRoleMap(OString aAlias, PDFWriter::StructElement eType)
+{
+    OString aTag = getStructureTag(eType);
+    // For PDF/UA it's not allowed to map an alias with the same name.
+    // Not sure if this allowed, necessary or recommended otherwise, so
+    // only enable filtering when PDF/UA is enabled.
+    if (!m_bIsPDF_UA || aAlias != aTag)
+        m_aRoleMap[aAlias] = aTag;
+}
+
 void PDFWriterImpl::beginStructureElementMCSeq()
 {
     if( m_bEmitStructure &&
@@ -10209,7 +10219,7 @@ sal_Int32 PDFWriterImpl::beginStructureElement( PDFWriter::StructElement eType,
         appendName( rAlias, aNameBuf );
         OString aAliasName( aNameBuf.makeStringAndClear() );
         rEle.m_aAlias = aAliasName;
-        m_aRoleMap[ aAliasName ] = getStructureTag( eType );
+        addRoleMap(aAliasName, eType);
     }
 
     if (g_bDebugDisableCompression)
@@ -10331,8 +10341,8 @@ void PDFWriterImpl::addInternalStructureContainer( PDFStructureElement& rEle )
                 std::list< sal_Int32 > aNewChildren;
 
                 // add Div in RoleMap, in case no one else did (TODO: is it needed? Is it dangerous?)
-                OString aAliasName( "Div" );
-                m_aRoleMap[ aAliasName ] = getStructureTag( PDFWriter::Division );
+                OString aAliasName("Div");
+                addRoleMap(aAliasName, PDFWriter::Division);
 
                 while( rEle.m_aKids.size() > ncMaxPDFArraySize )
                 {
diff --git a/vcl/source/gdi/pdfwriter_impl.hxx b/vcl/source/gdi/pdfwriter_impl.hxx
index cccd38fe161f..82afd47e850e 100644
--- a/vcl/source/gdi/pdfwriter_impl.hxx
+++ b/vcl/source/gdi/pdfwriter_impl.hxx
@@ -759,6 +759,8 @@ i12626
     /* the buffer where the data are encrypted, dynamically allocated */
     std::vector<sal_uInt8>                  m_vEncryptionBuffer;
 
+    void addRoleMap(OString aAlias, PDFWriter::StructElement eType);
+
     /* this function implements part of the PDF spec algorithm 3.1 in encryption, the rest (the actual encryption) is in PDFWriterImpl::writeBuffer */
     void checkAndEnableStreamEncryption( sal_Int32 nObject );
 


More information about the Libreoffice-commits mailing list