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@fbihome.de>
(cherry picked from commit 06e35b3289090ec623fe5284976ee6f40681e1d5)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102771
Reviewed-by: Michael Stahl <michael.stahl@cib.de>
(cherry picked from commit 4684f8e09ac540a85b843b2306a9e9edeb8c17ec)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102773
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/vcl/inc/pdf/XmpMetadata.hxx b/vcl/inc/pdf/XmpMetadata.hxx
index cc3f8da..61438e0 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 03553d7..7e02762 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 281183c..70588da 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();