diff options
author | Jan-Marek Glogowski <glogow@fbihome.de> | 2020-09-16 23:40:51 +0200 |
---|---|---|
committer | Jan-Marek Glogowski <glogow@fbihome.de> | 2020-09-17 07:33:39 +0200 |
commit | 06e35b3289090ec623fe5284976ee6f40681e1d5 (patch) | |
tree | 5a936974ee7e432b1d5bd34d2d5f67ca241471da /vcl | |
parent | bd066a17a22826ceb10e7763074704289f838f74 (diff) |
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>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/pdf/XmpMetadata.hxx | 3 | ||||
-rw-r--r-- | vcl/source/gdi/pdfwriter_impl.cxx | 47 | ||||
-rw-r--r-- | vcl/source/pdf/XmpMetadata.cxx | 15 |
3 files changed, 35 insertions, 30 deletions
diff --git a/vcl/inc/pdf/XmpMetadata.hxx b/vcl/inc/pdf/XmpMetadata.hxx index ae3ffadcd847..7526d2bf9b4b 100644 --- a/vcl/inc/pdf/XmpMetadata.hxx +++ b/vcl/inc/pdf/XmpMetadata.hxx @@ -29,6 +29,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 e955bb9b7842..b8c9614359c7 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -5223,6 +5223,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() { @@ -5245,36 +5255,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(); |