include/vcl/pdfwriter.hxx | 2 sd/source/ui/unoidl/unomodel.cxx | 12 +---- vcl/source/gdi/pdfwriter_impl.cxx | 78 ++++++++++++++++++++++++-------------- 3 files changed, 55 insertions(+), 37 deletions(-)
New commits: commit ea33cf88688b4816dc2eaa21b5a360b8245a4145 Author: Tomaž Vajngerl <[email protected]> AuthorDate: Sat Jun 20 09:16:11 2020 +0200 Commit: Tomaž Vajngerl <[email protected]> CommitDate: Mon Jun 29 21:53:36 2020 +0200 pdf export: add support for modification time/date in annotations Previously the modification date was written to the annotation "title" as string, together with the username. This is however not neccessary as PDF supports the modification date perfectly fine. Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96766 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <[email protected]> (cherry picked from commit 235c54e115b66c880d3da0b8018f8ef29d20bc42) Change-Id: I6f55e4fe63d9c3c81ec557f6cfd3387f011e67c0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97444 Tested-by: Tomaž Vajngerl <[email protected]> Reviewed-by: Tomaž Vajngerl <[email protected]> diff --git a/include/vcl/pdfwriter.hxx b/include/vcl/pdfwriter.hxx index 858d8a36dec1..19e4c530a4db 100644 --- a/include/vcl/pdfwriter.hxx +++ b/include/vcl/pdfwriter.hxx @@ -31,6 +31,7 @@ #include <vcl/graph.hxx> #include <com/sun/star/lang/Locale.hpp> +#include <com/sun/star/util/DateTime.hpp> #include <memory> #include <vector> @@ -63,6 +64,7 @@ struct PDFNote { OUString Title; // optional title for the popup containing the note OUString Contents; // contents of the note + css::util::DateTime maModificationDate; }; class VCL_DLLPUBLIC PDFOutputStream diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx index 7b8e09adf038..5b8386022652 100644 --- a/sd/source/ui/unoidl/unomodel.cxx +++ b/sd/source/ui/unoidl/unomodel.cxx @@ -1547,24 +1547,18 @@ static void ImplPDFExportComments( const uno::Reference< drawing::XDrawPage >& x uno::Reference< office::XAnnotationAccess > xAnnotationAccess( xPage, uno::UNO_QUERY_THROW ); uno::Reference< office::XAnnotationEnumeration > xAnnotationEnumeration( xAnnotationAccess->createAnnotationEnumeration() ); - LanguageType eLanguage = Application::GetSettings().GetLanguageTag().getLanguageType(); while( xAnnotationEnumeration->hasMoreElements() ) { uno::Reference< office::XAnnotation > xAnnotation( xAnnotationEnumeration->nextElement() ); geometry::RealPoint2D aRealPoint2D( xAnnotation->getPosition() ); uno::Reference< text::XText > xText( xAnnotation->getTextRange() ); - util::DateTime aDateTime( xAnnotation->getDateTime() ); - - Date aDate( aDateTime.Day, aDateTime.Month, aDateTime.Year ); - ::tools::Time aTime( ::tools::Time::EMPTY ); - OUString aStr = SvxDateTimeField::GetFormatted( aDate, aTime, - SvxDateFormat::B, SvxTimeFormat::AppDefault, - *(SD_MOD()->GetNumberFormatter()), eLanguage ); vcl::PDFNote aNote; - aNote.Title = xAnnotation->getAuthor() + ", " + aStr; + aNote.Title = xAnnotation->getAuthor(); aNote.Contents = xText->getString(); + aNote.maModificationDate = xAnnotation->getDateTime(); + rPDFExtOutDevData.CreateNote( ::tools::Rectangle( Point( static_cast< long >( aRealPoint2D.X * 100 ), static_cast< long >( aRealPoint2D.Y * 100 ) ), Size( 1000, 1000 ) ), aNote ); } diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index 2ef065f61afd..963967e02ae6 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -735,6 +735,49 @@ void PDFWriterImpl::ResourceDict::append( OStringBuffer& rBuf, sal_Int32 nFontDi rBuf.append( "]\n>>\n" ); }; +namespace +{ + +void appendPdfTimeDate(OStringBuffer & rBuffer, + sal_Int16 year, sal_uInt16 month, sal_uInt16 day, sal_uInt16 hours, sal_uInt16 minutes, sal_uInt16 seconds, sal_uInt32 tzDelta) +{ + rBuffer.append("D:"); + rBuffer.append(char('0' + ((year / 1000) % 10))); + rBuffer.append(char('0' + ((year / 100) % 10))); + rBuffer.append(char('0' + ((year / 10) % 10))); + rBuffer.append(char('0' + (year % 10))); + rBuffer.append(char('0' + ((month / 10) % 10))); + rBuffer.append(char('0' + (month % 10))); + rBuffer.append(char('0' + ((day / 10) % 10))); + rBuffer.append(char('0' + (day % 10))); + rBuffer.append(char('0' + ((hours / 10) % 10))); + rBuffer.append(char('0' + (hours % 10))); + rBuffer.append(char('0' + ((minutes / 10) % 10))); + rBuffer.append(char('0' + (minutes % 10))); + rBuffer.append(char('0' + ((seconds / 10) % 10))); + rBuffer.append(char('0' + (seconds % 10))); + + if (tzDelta == 0) + { + rBuffer.append("Z"); + } + else + { + if (tzDelta > 0 ) + rBuffer.append("+"); + else + rBuffer.append("-"); + + rBuffer.append(char('0' + ((tzDelta / 36000) % 10))); + rBuffer.append(char('0' + ((tzDelta / 3600) % 10))); + rBuffer.append("'"); + rBuffer.append(char('0' + ((tzDelta / 600) % 6))); + rBuffer.append(char('0' + ((tzDelta / 60) % 10))); + } +} + +} // end namespace + PDFWriterImpl::PDFPage::PDFPage( PDFWriterImpl* pWriter, double nPageWidth, double nPageHeight, PDFWriter::Orientation eOrientation ) : m_pWriter( pWriter ), @@ -1464,46 +1507,20 @@ OString PDFWriter::GetDateTime() osl_getSystemTime(&aGMT); osl_getLocalTimeFromSystemTime(&aGMT, &aTVal); osl_getDateTimeFromTimeValue(&aTVal, &aDT); - aRet.append("D:"); - aRet.append(static_cast<sal_Char>('0' + ((aDT.Year / 1000) % 10))); - aRet.append(static_cast<sal_Char>('0' + ((aDT.Year / 100) % 10))); - aRet.append(static_cast<sal_Char>('0' + ((aDT.Year / 10) % 10))); - aRet.append(static_cast<sal_Char>('0' + (aDT.Year % 10))); - aRet.append(static_cast<sal_Char>('0' + ((aDT.Month / 10) % 10))); - aRet.append(static_cast<sal_Char>('0' + (aDT.Month % 10))); - aRet.append(static_cast<sal_Char>('0' + ((aDT.Day / 10) % 10))); - aRet.append(static_cast<sal_Char>('0' + (aDT.Day % 10))); - aRet.append(static_cast<sal_Char>('0' + ((aDT.Hours / 10) % 10))); - aRet.append(static_cast<sal_Char>('0' + (aDT.Hours % 10))); - aRet.append(static_cast<sal_Char>('0' + ((aDT.Minutes / 10) % 10))); - aRet.append(static_cast<sal_Char>('0' + (aDT.Minutes % 10))); - aRet.append(static_cast<sal_Char>('0' + ((aDT.Seconds / 10) % 10))); - aRet.append(static_cast<sal_Char>('0' + (aDT.Seconds % 10))); sal_uInt32 nDelta = 0; if (aGMT.Seconds > aTVal.Seconds) { - aRet.append("-"); nDelta = aGMT.Seconds-aTVal.Seconds; } else if (aGMT.Seconds < aTVal.Seconds) { - aRet.append("+"); nDelta = aTVal.Seconds-aGMT.Seconds; } - else - aRet.append("Z"); - if (nDelta) - { - aRet.append(static_cast<sal_Char>('0' + ((nDelta / 36000) % 10))); - aRet.append(static_cast<sal_Char>('0' + ((nDelta / 3600) % 10))); - aRet.append("'"); - aRet.append(static_cast<sal_Char>('0' + ((nDelta / 600) % 6))); - aRet.append(static_cast<sal_Char>('0' + ((nDelta / 60) % 10))); - } - aRet.append( "'" ); + appendPdfTimeDate(aRet, aDT.Year, aDT.Month, aDT.Day, aDT.Hours, aDT.Minutes, aDT.Seconds, nDelta); + aRet.append("'"); return aRet.makeStringAndClear(); } @@ -3613,6 +3630,11 @@ void PDFWriterImpl::emitTextAnnotationLine(OStringBuffer & aLine, PDFNoteEntry c aLine.append("/Popup "); appendObjectReference(rNote.m_aPopUpAnnotation.m_nObject, aLine); + auto & rDateTime = rNote.m_aContents.maModificationDate; + + aLine.append("/M "); + appendPdfTimeDate(aLine, rDateTime.Year, rDateTime.Month, rDateTime.Day, rDateTime.Hours, rDateTime.Minutes, rDateTime.Seconds, 0); + // contents of the note (type text string) aLine.append("/Contents "); appendUnicodeTextStringEncrypt(rNote.m_aContents.Contents, rNote.m_nObject, aLine); _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
