filter/source/pdf/pdfexport.cxx   |    4 ++++
 include/vcl/pdfwriter.hxx         |    1 +
 vcl/inc/pdf/pdfwriter_impl.hxx    |    1 +
 vcl/source/gdi/pdfwriter_impl.cxx |   12 ++++++++++--
 vcl/source/pdf/XmpMetadata.cxx    |    8 ++++++++
 5 files changed, 24 insertions(+), 2 deletions(-)

New commits:
commit 7803c5749365c6dca6583708c14d6229c9659572
Author:     Sarper Akdemir <sarper.akdemir.ext...@allotropia.de>
AuthorDate: Thu Aug 10 08:49:24 2023 +0300
Commit:     Sarper Akdemir <sarper.akdemir.ext...@allotropia.de>
CommitDate: Mon Sep 4 20:53:27 2023 +0200

    tdf#138792: PDF export: export metadata xmp:ModifyDate, xmp:MetadataDate
    
    Export metadata xmp:ModifyDate & xmp:MetadataDate - populate
    both with the same information as CreateDate.
    
    Change-Id: I391a72cbe4e7d1ebba5c04c402a68534bbeb4743
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156328
    Tested-by: Jenkins
    Reviewed-by: Sarper Akdemir <sarper.akdemir.ext...@allotropia.de>

diff --git a/vcl/source/pdf/XmpMetadata.cxx b/vcl/source/pdf/XmpMetadata.cxx
index d4c58c23348b..7b0df42dbb92 100644
--- a/vcl/source/pdf/XmpMetadata.cxx
+++ b/vcl/source/pdf/XmpMetadata.cxx
@@ -155,8 +155,16 @@ void XmpMetadata::write()
         aXmlWriter.startElement("xmp:CreateDate");
         aXmlWriter.content(m_sCreateDate);
         aXmlWriter.endElement();
+
+        aXmlWriter.startElement("xmp:ModifyDate");
+        aXmlWriter.content(m_sCreateDate);
+        aXmlWriter.endElement();
+
+        aXmlWriter.startElement("xmp:MetadataDate");
+        aXmlWriter.content(m_sCreateDate);
         aXmlWriter.endElement();
 
+        aXmlWriter.endElement();
         aXmlWriter.endElement();
         aXmlWriter.endElement();
         aXmlWriter.endDocument();
commit 07ac61f2c67020ad2941462ea7081f06495bcb92
Author:     Sarper Akdemir <sarper.akdemir.ext...@allotropia.de>
AuthorDate: Mon Aug 28 11:16:34 2023 +0300
Commit:     Sarper Akdemir <sarper.akdemir.ext...@allotropia.de>
CommitDate: Mon Sep 4 20:53:17 2023 +0200

    tdf#138792: PDF export: fix date of xmp:CreateDate
    
    for pdf export xmp:CreateDate should be the modification
    date instead of the creation date.
    
    Change-Id: I2a86f30cb528cb2bd5e0f9e7c9a8a8b8d2993f50
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156327
    Tested-by: Jenkins
    Reviewed-by: Sarper Akdemir <sarper.akdemir.ext...@allotropia.de>

diff --git a/filter/source/pdf/pdfexport.cxx b/filter/source/pdf/pdfexport.cxx
index 8199132b66b4..9b6523448dfb 100644
--- a/filter/source/pdf/pdfexport.cxx
+++ b/filter/source/pdf/pdfexport.cxx
@@ -477,6 +477,10 @@ bool PDFExport::Export( const OUString& rFile, const 
Sequence< PropertyValue >&
                     aContext.DocumentInfo.Author = xDocumentProps->getAuthor();
                     aContext.DocumentInfo.Subject = 
xDocumentProps->getSubject();
                     aContext.DocumentInfo.Keywords = 
::comphelper::string::convertCommaSeparated(xDocumentProps->getKeywords());
+                    aContext.DocumentInfo.ModificationDate
+                        = xDocumentProps->getEditingCycles() < 1
+                              ? xDocumentProps->getCreationDate()
+                              : xDocumentProps->getModificationDate();
                 }
             }
 
diff --git a/include/vcl/pdfwriter.hxx b/include/vcl/pdfwriter.hxx
index 796c1f03cd9b..2b62b26b6ef4 100644
--- a/include/vcl/pdfwriter.hxx
+++ b/include/vcl/pdfwriter.hxx
@@ -559,6 +559,7 @@ The following structure describes the permissions used in 
PDF security
         OUString          Author;         // document author
         OUString          Subject;        // subject
         OUString          Keywords;       // keywords
+        css::util::DateTime ModificationDate;
         OUString          Creator;        // application that created the 
original document
         OUString          Producer;       // OpenOffice
     };
diff --git a/vcl/inc/pdf/pdfwriter_impl.hxx b/vcl/inc/pdf/pdfwriter_impl.hxx
index 75f613060c04..b9eaf4686b95 100644
--- a/vcl/inc/pdf/pdfwriter_impl.hxx
+++ b/vcl/inc/pdf/pdfwriter_impl.hxx
@@ -1115,6 +1115,7 @@ i12626
     static void computeDocumentIdentifier( std::vector< sal_uInt8 >& 
o_rIdentifier,
                                            const vcl::PDFWriter::PDFDocInfo& 
i_rDocInfo,
                                            const OString& i_rCString1,
+                                           const css::util::DateTime& 
rCreationMetaDate,
                                            OString& o_rCString2
                                           );
     static sal_Int32 computeAccessPermissions( const 
vcl::PDFWriter::PDFEncryptionProperties& i_rProperties,
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx 
b/vcl/source/gdi/pdfwriter_impl.cxx
index 55ed6d514b9d..def3d4ee3ba5 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -1375,7 +1375,7 @@ void PDFWriterImpl::setupDocInfo()
 {
     std::vector< sal_uInt8 > aId;
     m_aCreationDateString = PDFWriter::GetDateTime();
-    computeDocumentIdentifier( aId, m_aContext.DocumentInfo, 
m_aCreationDateString, m_aCreationMetaDateString );
+    computeDocumentIdentifier( aId, m_aContext.DocumentInfo, 
m_aCreationDateString, m_aContext.DocumentInfo.ModificationDate, 
m_aCreationMetaDateString );
     if( m_aContext.Encryption.DocumentIdentifier.empty() )
         m_aContext.Encryption.DocumentIdentifier = aId;
 }
@@ -1401,6 +1401,7 @@ OString PDFWriter::GetDateTime()
 void PDFWriterImpl::computeDocumentIdentifier( std::vector< sal_uInt8 >& 
o_rIdentifier,
                                                const 
vcl::PDFWriter::PDFDocInfo& i_rDocInfo,
                                                const OString& i_rCString1,
+                                               const css::util::DateTime& 
rCreationMetaDate,
                                                OString& o_rCString2
                                                )
 {
@@ -1424,9 +1425,16 @@ void PDFWriterImpl::computeDocumentIdentifier( 
std::vector< sal_uInt8 >& o_rIden
 
     TimeValue aTVal, aGMT;
     oslDateTime aDT;
+    aDT.NanoSeconds = rCreationMetaDate.NanoSeconds;
+    aDT.Seconds = rCreationMetaDate.Seconds;
+    aDT.Minutes = rCreationMetaDate.Minutes;
+    aDT.Hours = rCreationMetaDate.Hours;
+    aDT.Day = rCreationMetaDate.Day;
+    aDT.Month = rCreationMetaDate.Month;
+    aDT.Year = rCreationMetaDate.Year;
+
     osl_getSystemTime( &aGMT );
     osl_getLocalTimeFromSystemTime( &aGMT, &aTVal );
-    osl_getDateTimeFromTimeValue( &aTVal, &aDT );
     OStringBuffer aCreationMetaDateString(64);
 
     // i59651: we fill the Metadata date string as well, if PDF/A is requested

Reply via email to