filter/source/pdf/impdialog.cxx | 42 ++++++++++++++++++++++++++++---------- filter/source/pdf/impdialog.hxx | 1 vcl/source/gdi/pdfwriter_impl.cxx | 3 ++ 3 files changed, 36 insertions(+), 10 deletions(-)
New commits: commit 68e66c283a2bd27125138d9256d68e2997b62149 Author: Tomaž Vajngerl <[email protected]> AuthorDate: Thu Dec 12 23:56:29 2024 +0900 Commit: Miklos Vajna <[email protected]> CommitDate: Mon Dec 16 13:57:58 2024 +0100 tdf#160196 Embedded files are not allowed in PDF/A-1 and PDF/A-2 This disables embedded/attached files in the UI as well as in the export filter for PDF/A-1 and 2. PDF/A-3 is almost identical to PDF/A-2 with the difference that it allows embedded/attached files. Change-Id: If8c3af6ab08ad320cf15618ead9c69fbd490d4f0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178413 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Miklos Vajna <[email protected]> diff --git a/filter/source/pdf/impdialog.cxx b/filter/source/pdf/impdialog.cxx index 296ed1babb19..572712eed10a 100644 --- a/filter/source/pdf/impdialog.cxx +++ b/filter/source/pdf/impdialog.cxx @@ -528,6 +528,13 @@ bool ImpPDFTabGeneralPage::IsPdfaSelected() const rVersion == u"4"_ustr; } +bool ImpPDFTabGeneralPage::IsPDFAVersionSelected(sal_Int32 nVersion) const +{ + OUString const& rVersion = mxRbPDFVersion->get_active_id(); + sal_Int32 nSelectedVersion = rVersion.toInt32(); + return nSelectedVersion == nVersion; +} + void ImpPDFTabGeneralPage::SetFilterConfigItem(ImpPDFTabDialog* pParent) { mpParent = pParent; @@ -619,6 +626,12 @@ void ImpPDFTabGeneralPage::SetFilterConfigItem(ImpPDFTabDialog* pParent) mbUseTaggedPDFUserSelection = pParent->mbUseTaggedPDFUserSelection; mxCbExportBookmarks->set_active(pParent->mbExportBookmarksUserSelection); + + mxCbAddStream->show(); + mxCbAddStream->set_active(pParent->mbAddStream); + mxCbAddStream->connect_toggled(LINK(this, ImpPDFTabGeneralPage, ToggleAddStreamHdl)); + ToggleAddStreamHdl(*mxCbAddStream); // init addstream dependencies + thePDFVersionChanged(); mxCbExportFormFields->set_active(pParent->mbExportFormFields); @@ -711,13 +724,6 @@ void ImpPDFTabGeneralPage::SetFilterConfigItem(ImpPDFTabDialog* pParent) mxCbExportPlaceholders->set_active(pParent->mbIsExportPlaceholders); mxCbExportPlaceholders->set_sensitive( mbIsWriter && !pParent->maConfigItem.IsReadOnly("ExportPlaceholders")); - - mxCbAddStream->show(); - mxCbAddStream->set_active(pParent->mbAddStream); - mxCbAddStream->set_sensitive(!pParent->maConfigItem.IsReadOnly("IsAddStream")); - - mxCbAddStream->connect_toggled(LINK(this, ImpPDFTabGeneralPage, ToggleAddStreamHdl)); - ToggleAddStreamHdl(*mxCbAddStream); // init addstream dependencies } void ImpPDFTabGeneralPage::GetFilterConfigItem( ImpPDFTabDialog* pParent ) @@ -933,9 +939,6 @@ void ImpPDFTabGeneralPage::thePDFVersionChanged() if (pSecPage) pSecPage->ImplPDFASecurityControl(); - mxCbTaggedPDF->set_sensitive( - !bIsPDFA && !bIsPDFUA && !IsReadOnlyProperty("UseTaggedPDF")); - mxRbPDFVersion->set_sensitive(!IsReadOnlyProperty("SelectPdfVersion")); if (bIsPDFA || bIsPDFUA) @@ -943,6 +946,7 @@ void ImpPDFTabGeneralPage::thePDFVersionChanged() // store the users selection of subordinate controls and set required PDF/A values mbUseTaggedPDFUserSelection = mxCbTaggedPDF->get_active(); mxCbTaggedPDF->set_active(true); + mxCbTaggedPDF->set_sensitive(false); // if a password was set, inform the user that this will not be used if (bIsPDFA && pSecPage && pSecPage->hasPassword()) @@ -958,6 +962,24 @@ void ImpPDFTabGeneralPage::thePDFVersionChanged() { // restore the users values of subordinate controls mxCbTaggedPDF->set_active(mbUseTaggedPDFUserSelection); + mxCbTaggedPDF->set_sensitive(!IsReadOnlyProperty("UseTaggedPDF")); + } + + if (IsPDFAVersionSelected(1) || IsPDFAVersionSelected(2)) + { + if (mxCbAddStream->get_sensitive()) + { + if (mpParent) + mpParent->mbAddStream = mxCbAddStream->get_active(); + + mxCbAddStream->set_active(false); + mxCbAddStream->set_sensitive(false); + } + } + else if (mpParent && !mxCbAddStream->get_sensitive()) + { + mxCbAddStream->set_active(mpParent->mbAddStream); + mxCbAddStream->set_sensitive(!mpParent->maConfigItem.IsReadOnly("IsAddStream")); } if (bIsPDFUA) diff --git a/filter/source/pdf/impdialog.hxx b/filter/source/pdf/impdialog.hxx index 1b697b257ece..fba49c8f0301 100644 --- a/filter/source/pdf/impdialog.hxx +++ b/filter/source/pdf/impdialog.hxx @@ -259,6 +259,7 @@ public: void GetFilterConfigItem(ImpPDFTabDialog* paParent); void SetFilterConfigItem(ImpPDFTabDialog* paParent); bool IsPdfaSelected() const; + bool IsPDFAVersionSelected(sal_Int32 nVersion) const; bool IsPdfUaSelected() const { return mxCbPDFUA->get_active(); } }; diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index 7d5d1a01de97..42bbe5c22bfa 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -3531,6 +3531,9 @@ bool PDFWriterImpl::appendDest( sal_Int32 nDestID, OStringBuffer& rBuffer ) void PDFWriterImpl::addDocumentAttachedFile(OUString const& rFileName, OUString const& rMimeType, OUString const& rDescription, std::unique_ptr<PDFOutputStream> rStream) { + if (m_nPDFA_Version == 1 || m_nPDFA_Version == 2) + return; + sal_Int32 nObjectID = addEmbeddedFile(std::move(rStream), rMimeType); auto& rAttachedFile = m_aDocumentAttachedFiles.emplace_back(); rAttachedFile.maFilename = rFileName;
