summaryrefslogtreecommitdiff
path: root/vcl/source
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2024-10-31 23:59:00 +0100
committerTomaž Vajngerl <quikee@gmail.com>2024-11-04 21:51:12 +0100
commit152780e4340e12397a64320bc66185000871be35 (patch)
tree88a7604e21dd63ca693f394856bbec780a8b772f /vcl/source
parentb0a6a402f00e966c24f5b1e74b9c8aefeb62af8b (diff)
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/+/176025 Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> Tested-by: Jenkins
Diffstat (limited to 'vcl/source')
-rw-r--r--vcl/source/gdi/pdfwriter_impl.cxx25
1 files changed, 12 insertions, 13 deletions
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index b5d7ad31cf08..fd9d3ee1ef30 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -1394,18 +1394,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;
@@ -3802,7 +3806,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[" );
@@ -4148,7 +4152,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 ");
@@ -4757,7 +4761,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 ||
@@ -5664,7 +5668,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
@@ -5981,7 +5985,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
@@ -6082,6 +6086,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)
@@ -6094,14 +6099,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;