[Libreoffice-commits] core.git: Branch 'libreoffice-7-0-2' - vcl/inc vcl/source

Jan-Marek Glogowski (via logerrit) logerrit at kemper.freedesktop.org
Thu Sep 17 14:39:52 UTC 2020


 vcl/inc/pdf/XmpMetadata.hxx       |    3 ++
 vcl/source/gdi/pdfwriter_impl.cxx |   47 +++++++++++++-------------------------
 vcl/source/pdf/XmpMetadata.cxx    |   15 ++++++++++++
 3 files changed, 35 insertions(+), 30 deletions(-)

New commits:
commit 749b206f1d2e31128762be9d727f1dc4c764aed5
Author:     Jan-Marek Glogowski <glogow at fbihome.de>
AuthorDate: Wed Sep 16 23:40:51 2020 +0200
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Thu Sep 17 16:39:17 2020 +0200

    tdf#136805 PDF export: re-add XMP basic meta data
    
    VeraPDF complains about:
    
    <rule specification="ISO 19005-1:2005" clause="6.7.3"
        testNumber="1" status="failed" passedChecks="0"
        failedChecks="1">
      <description>If a document information dictionary does appear
        at a document, then all of its entries that have analogous
        properties in predefined XMP schemas, shall also be embedded
        in the file in XMP form with equivalent values.</description>
      <object>CosDocument</object>
      <test>doesInfoMatchXMP</test>
      <check status="failed">
        <context>root</context>
      </check>
    </rule>
    
    The regressing commit dropped the XMP Basic schema meta data
    (http://ns.adobe.com/xap/1.0/"). FWIW: xmp is the referred prefix,
    so we'll continue to use it.
    
    Regressed-by: d016e052ddf30649ad9b729b59134ce1e90a0263
    Change-Id: I11b06fdafcb07732b92f0bd99b18afa3a9e498ef
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102888
    Tested-by: Jenkins
    Reviewed-by: Jan-Marek Glogowski <glogow at fbihome.de>
    (cherry picked from commit 06e35b3289090ec623fe5284976ee6f40681e1d5)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102771
    Reviewed-by: Michael Stahl <michael.stahl at cib.de>
    (cherry picked from commit 4684f8e09ac540a85b843b2306a9e9edeb8c17ec)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102773
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/vcl/inc/pdf/XmpMetadata.hxx b/vcl/inc/pdf/XmpMetadata.hxx
index cc3f8da1a34c..61438e0e50b8 100644
--- a/vcl/inc/pdf/XmpMetadata.hxx
+++ b/vcl/inc/pdf/XmpMetadata.hxx
@@ -30,6 +30,9 @@ public:
     OString msSubject;
     OString msProducer;
     OString msKeywords;
+    OString m_sCreatorTool;
+    OString m_sCreateDate;
+
     sal_Int32 mnPDF_A;
     bool mbPDF_UA;
 
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index 03553d7aa6ee..7e02762d6e36 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -5122,6 +5122,16 @@ static void escapeStringXML( const OUString& rStr, OUString &rValue)
     }
 }
 
+static void lcl_assignMeta(const OUString& aValue, OString& aMeta)
+{
+    if (!aValue.isEmpty())
+    {
+        OUString aTempString;
+        escapeStringXML(aValue, aTempString);
+        aMeta = OUStringToOString(aTempString, RTL_TEXTENCODING_UTF8);
+    }
+}
+
 // emits the document metadata
 sal_Int32 PDFWriterImpl::emitDocumentMetadata()
 {
@@ -5144,36 +5154,13 @@ sal_Int32 PDFWriterImpl::emitDocumentMetadata()
 
         aMetadata.mbPDF_UA = m_bIsPDF_UA;
 
-        if (!m_aContext.DocumentInfo.Title.isEmpty())
-        {
-            OUString aTempString;
-            escapeStringXML(m_aContext.DocumentInfo.Title, aTempString);
-            aMetadata.msTitle = OUStringToOString(aTempString, RTL_TEXTENCODING_UTF8);
-        }
-        if (!m_aContext.DocumentInfo.Author.isEmpty())
-        {
-            OUString aTempString;
-            escapeStringXML(m_aContext.DocumentInfo.Author, aTempString);
-            aMetadata.msAuthor = OUStringToOString(aTempString, RTL_TEXTENCODING_UTF8);
-        }
-        if (!m_aContext.DocumentInfo.Subject.isEmpty())
-        {
-            OUString aTempString;
-            escapeStringXML(m_aContext.DocumentInfo.Subject, aTempString);
-            aMetadata.msSubject = OUStringToOString(aTempString, RTL_TEXTENCODING_UTF8);
-        }
-        if (!m_aContext.DocumentInfo.Producer.isEmpty())
-        {
-            OUString aTempString;
-            escapeStringXML(m_aContext.DocumentInfo.Producer, aTempString);
-            aMetadata.msProducer = OUStringToOString(aTempString, RTL_TEXTENCODING_UTF8);
-        }
-        if (!m_aContext.DocumentInfo.Keywords.isEmpty())
-        {
-            OUString aTempString;
-            escapeStringXML(m_aContext.DocumentInfo.Keywords, aTempString);
-            aMetadata.msKeywords = OUStringToOString(aTempString, RTL_TEXTENCODING_UTF8);
-        }
+        lcl_assignMeta(m_aContext.DocumentInfo.Title, aMetadata.msTitle);
+        lcl_assignMeta(m_aContext.DocumentInfo.Author, aMetadata.msAuthor);
+        lcl_assignMeta(m_aContext.DocumentInfo.Subject, aMetadata.msSubject);
+        lcl_assignMeta(m_aContext.DocumentInfo.Producer, aMetadata.msProducer);
+        lcl_assignMeta(m_aContext.DocumentInfo.Keywords, aMetadata.msKeywords);
+        lcl_assignMeta(m_aContext.DocumentInfo.Creator, aMetadata.m_sCreatorTool);
+        aMetadata.m_sCreateDate = m_aCreationMetaDateString;
 
         OStringBuffer aMetadataObj( 1024 );
 
diff --git a/vcl/source/pdf/XmpMetadata.cxx b/vcl/source/pdf/XmpMetadata.cxx
index 281183c205e8..70588dab31cd 100644
--- a/vcl/source/pdf/XmpMetadata.cxx
+++ b/vcl/source/pdf/XmpMetadata.cxx
@@ -143,6 +143,21 @@ void XmpMetadata::write()
             }
             aXmlWriter.endElement();
         }
+
+        aXmlWriter.startElement("rdf:Description");
+        aXmlWriter.attribute("rdf:about", OString(""));
+        aXmlWriter.attribute("xmlns:xmp", OString("http://ns.adobe.com/xap/1.0/"));
+        if (!m_sCreatorTool.isEmpty())
+        {
+            aXmlWriter.startElement("xmp:CreatorTool");
+            aXmlWriter.content(m_sCreatorTool);
+            aXmlWriter.endElement();
+        }
+        aXmlWriter.startElement("xmp:CreateDate");
+        aXmlWriter.content(m_sCreateDate);
+        aXmlWriter.endElement();
+        aXmlWriter.endElement();
+
         aXmlWriter.endElement();
         aXmlWriter.endElement();
         aXmlWriter.endDocument();


More information about the Libreoffice-commits mailing list