vcl/inc/pdf/pdfwriter_impl.hxx | 3 ++- vcl/source/gdi/pdfwriter_impl.cxx | 25 ++++++++++++------------- 2 files changed, 14 insertions(+), 14 deletions(-)
New commits: commit 6d265f9f8ec4332f7f3a05a3d263b6ac6b6b3ef3 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Thu Oct 31 23:59:00 2024 +0100 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Fri Nov 8 14:41:40 2024 +0100 pdf: add m_nPDFA_Version to simplify PDF/A versions We have a bool for each PDFA version, which is inflexible when checking if the feature is supported in a range of versions so this adds a version number which simplifies checks a bit. Change-Id: If162e305766baa61278872297c9ab1eb41cb57d9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175924 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/vcl/inc/pdf/pdfwriter_impl.hxx b/vcl/inc/pdf/pdfwriter_impl.hxx index 2d528af29d87..54de33b52145 100644 --- a/vcl/inc/pdf/pdfwriter_impl.hxx +++ b/vcl/inc/pdf/pdfwriter_impl.hxx @@ -1082,10 +1082,11 @@ i12626 /* true if PDF/A-4 is output */ bool m_bIsPDF_A4 = false; + sal_Int32 m_nPDFA_Version = 0; + /* PDF/UA support enabled */ bool m_bIsPDF_UA = false; - PDFWriter& m_rOuterFace; /* diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index c44ad77acd47..e23e20c87fea 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -1395,18 +1395,22 @@ PDFWriterImpl::PDFWriterImpl( const PDFWriter::PDFWriterContext& rContext, switch (m_aContext.Version) { case PDFWriter::PDFVersion::PDF_A_1: + m_nPDFA_Version = 1; m_bIsPDF_A1 = true; m_aContext.Version = PDFWriter::PDFVersion::PDF_1_4; //meaning we need PDF 1.4, PDF/A flavour break; case PDFWriter::PDFVersion::PDF_A_2: + m_nPDFA_Version = 2; m_bIsPDF_A2 = true; m_aContext.Version = PDFWriter::PDFVersion::PDF_1_7; break; case PDFWriter::PDFVersion::PDF_A_3: + m_nPDFA_Version = 3; m_bIsPDF_A3 = true; m_aContext.Version = PDFWriter::PDFVersion::PDF_1_7; break; case PDFWriter::PDFVersion::PDF_A_4: + m_nPDFA_Version = 4; m_bIsPDF_A4 = true; m_aContext.Version = PDFWriter::PDFVersion::PDF_2_0; break; @@ -3769,7 +3773,7 @@ bool PDFWriterImpl::emitLinkAnnotations() // i59651: key /F set bits Print to 1 rest to 0. We don't set NoZoom NoRotate to 1, since it's a 'should' // see PDF 8.4.2 and ISO 19005-1:2005 6.5.3 aLine.append( "<</Type/Annot" ); - if (m_bIsPDF_A1 || m_bIsPDF_A2 || m_bIsPDF_A3 || m_bIsPDF_A4) + if (m_nPDFA_Version > 0) aLine.append( "/F 4" ); aLine.append( "/Subtype/Link/Border[0 0 0]/Rect[" ); @@ -4114,7 +4118,7 @@ void PDFWriterImpl::emitTextAnnotationLine(OStringBuffer & aLine, PDFNoteEntry c // i59651: key /F set bits Print to 1 rest to 0. We don't set NoZoom NoRotate to 1, since it's a 'should' // see PDF 8.4.2 and ISO 19005-1:2005 6.5.3 - if (m_bIsPDF_A1 || m_bIsPDF_A2 || m_bIsPDF_A3 || m_bIsPDF_A4) + if (m_nPDFA_Version > 0) aLine.append("/F 4 "); aLine.append("/Popup "); @@ -4707,7 +4711,7 @@ bool PDFWriterImpl::emitAppearances( PDFWidget& rWidget, OStringBuffer& rAnnotDi // PDF/A requires sub-dicts for /FT/Btn objects (clause // 6.3.3) - if( m_bIsPDF_A1 || m_bIsPDF_A2 || m_bIsPDF_A3 || m_bIsPDF_A4) + if (m_nPDFA_Version > 0) { if( rWidget.m_eType == PDFWriter::RadioButton || rWidget.m_eType == PDFWriter::CheckBox || @@ -5615,7 +5619,7 @@ bool PDFWriterImpl::emitCatalog() aLine.append( getResourceDictObj() ); aLine.append( " 0 R" ); // NeedAppearances must not be used if PDF is signed - if(m_bIsPDF_A1 || m_bIsPDF_A2 || m_bIsPDF_A3 || m_bIsPDF_A4 + if (m_nPDFA_Version > 0 #if HAVE_FEATURE_NSS || ( m_nSignatureObject != -1 ) #endif @@ -5927,7 +5931,7 @@ sal_Int32 PDFWriterImpl::emitNamedDestinations() // emits the output intent dictionary sal_Int32 PDFWriterImpl::emitOutputIntent() { - if (!m_bIsPDF_A1 && !m_bIsPDF_A2 && !m_bIsPDF_A3 && !m_bIsPDF_A4) + if (m_nPDFA_Version == 0) // not PDFA return 0; //emit the sRGB standard profile, in ICC format, in a stream, per IEC61966-2.1 @@ -6028,6 +6032,7 @@ static void lcl_assignMeta(const css::uno::Sequence<OUString>& rValues, std::vec } // emits the document metadata +// Since in PDF 1.4 sal_Int32 PDFWriterImpl::emitDocumentMetadata() { if( !m_bIsPDF_A1 && !m_bIsPDF_A2 && !m_bIsPDF_A3 && !m_bIsPDF_A4 && !m_bIsPDF_UA) @@ -6040,14 +6045,8 @@ sal_Int32 PDFWriterImpl::emitDocumentMetadata() { pdf::XmpMetadata aMetadata; - if (m_bIsPDF_A1) - aMetadata.mnPDF_A = 1; - else if (m_bIsPDF_A2) - aMetadata.mnPDF_A = 2; - else if (m_bIsPDF_A3) - aMetadata.mnPDF_A = 3; - else if (m_bIsPDF_A4) - aMetadata.mnPDF_A = 4; + if (m_nPDFA_Version > 0) + aMetadata.mnPDF_A = m_nPDFA_Version; aMetadata.mbPDF_UA = m_bIsPDF_UA;