filter/source/pdf/impdialog.cxx | 109 +++++++++++++++++++++------------------- filter/source/pdf/impdialog.hxx | 4 + 2 files changed, 62 insertions(+), 51 deletions(-)
New commits: commit ea8caf9ce1f569b58d076ecd7cde76f51badcbcb Author: Jan-Marek Glogowski <jan-marek.glogow...@extern.cib.de> AuthorDate: Thu Aug 1 14:10:05 2019 +0000 Commit: Andras Timar <andras.ti...@collabora.com> CommitDate: Thu Aug 29 09:16:20 2019 +0200 tdf#126642 correctly handle the PDF/A settings This is in the spirit of the master fix. But instead of enabling broken PDF/A form handling, which would eventually require many more fixes, this correctly handles the user setting and disables the form export for PDF/A. The code therefore is almost the same, minus the radio button PDF/A type handling plus disabling the form frame. Change-Id: I31f96a36d776468a5547042fb9e4c0605751fbba Reviewed-on: https://gerrit.libreoffice.org/76820 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <thorsten.behr...@cib.de> Reviewed-on: https://gerrit.libreoffice.org/77898 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Andras Timar <andras.ti...@collabora.com> diff --git a/filter/source/pdf/impdialog.cxx b/filter/source/pdf/impdialog.cxx index 8b372cf752cf..b2e3b1fa3fd6 100644 --- a/filter/source/pdf/impdialog.cxx +++ b/filter/source/pdf/impdialog.cxx @@ -71,6 +71,7 @@ ImpPDFTabDialog::ImpPDFTabDialog(weld::Window* pParent, Sequence< PropertyValue mbReduceImageResolution( false ), mnMaxImageResolution( 300 ), mbUseTaggedPDF( false ), + mbUseTaggedPDFUserSelection( false ), mbExportNotes( true ), mbViewPDF( false ), mbUseReferenceXObject( false ), @@ -82,6 +83,7 @@ ImpPDFTabDialog::ImpPDFTabDialog(weld::Window* pParent, Sequence< PropertyValue mbAddStream( false ), mnFormsType( 0 ), mbExportFormFields( true ), + mbExportFormFieldsUserSelection( true ), mbAllowDuplicateFieldNames( false ), mbExportBookmarks( true ), mbExportHiddenSlides ( false), @@ -182,7 +184,10 @@ ImpPDFTabDialog::ImpPDFTabDialog(weld::Window* pParent, Sequence< PropertyValue mbReduceImageResolution = maConfigItem.ReadBool( "ReduceImageResolution", false ); mnMaxImageResolution = maConfigItem.ReadInt32( "MaxImageResolution", 300 ); + // this is always the user selection, independent from the PDF/A forced selection mbUseTaggedPDF = maConfigItem.ReadBool( "UseTaggedPDF", false ); + mbUseTaggedPDFUserSelection = mbUseTaggedPDF; + mnPDFTypeSelection = maConfigItem.ReadInt32( "SelectPdfVersion", 0 ); if ( mbIsPresentation ) { @@ -201,8 +206,11 @@ ImpPDFTabDialog::ImpPDFTabDialog(weld::Window* pParent, Sequence< PropertyValue mbIsExportPlaceholders = maConfigItem.ReadBool( "ExportPlaceholders", false ); mbAddStream = maConfigItem.ReadBool( "IsAddStream", false ); - mnFormsType = maConfigItem.ReadInt32( "FormsType", 0 ); + // this is always the user selection, independent from the PDF/A forced selection mbExportFormFields = maConfigItem.ReadBool( "ExportFormFields", true ); + mbExportFormFieldsUserSelection = mbExportFormFields; + + mnFormsType = maConfigItem.ReadInt32( "FormsType", 0 ); if ( ( mnFormsType < 0 ) || ( mnFormsType > 3 ) ) mnFormsType = 0; mbAllowDuplicateFieldNames = maConfigItem.ReadBool( "AllowDuplicateFieldNames", false ); @@ -364,7 +372,9 @@ Sequence< PropertyValue > ImpPDFTabDialog::GetFilterData() maConfigItem.WriteBool( "ReduceImageResolution", mbReduceImageResolution ); maConfigItem.WriteInt32("MaxImageResolution", mnMaxImageResolution ); - maConfigItem.WriteBool( "UseTaggedPDF", mbUseTaggedPDF ); + // always write the user selection, never the overridden PDF/A value + const bool bIsPDFA = (1 == mnPDFTypeSelection); + maConfigItem.WriteBool("UseTaggedPDF", bIsPDFA ? mbUseTaggedPDFUserSelection : mbUseTaggedPDF); maConfigItem.WriteInt32("SelectPdfVersion", mnPDFTypeSelection ); if ( mbIsPresentation ) @@ -388,7 +398,8 @@ Sequence< PropertyValue > ImpPDFTabDialog::GetFilterData() * ever be an additional form submit format this could get invalid. */ maConfigItem.WriteInt32( "FormsType", mnFormsType ); - maConfigItem.WriteBool( "ExportFormFields", mbExportFormFields ); + // always write the user selection, never the overridden PDF/A value + maConfigItem.WriteBool("ExportFormFields", bIsPDFA ? mbExportFormFieldsUserSelection : mbExportFormFields); maConfigItem.WriteBool( "AllowDuplicateFieldNames", mbAllowDuplicateFieldNames ); maConfigItem.WriteBool( "HideViewerToolbar", mbHideViewerToolbar ); @@ -444,7 +455,7 @@ Sequence< PropertyValue > ImpPDFTabDialog::GetFilterData() ImpPDFTabGeneralPage::ImpPDFTabGeneralPage(TabPageParent pParent, const SfxItemSet& rCoreSet) : SfxTabPage(pParent, "filter/ui/pdfgeneralpage.ui", "PdfGeneralPage", &rCoreSet) - , mbTaggedPDFUserSelection(false) + , mbUseTaggedPDFUserSelection(false) , mbExportFormFieldsUserSelection(false) , mbIsPresentation(false) , mbIsSpreadsheet(false) @@ -538,24 +549,24 @@ void ImpPDFTabGeneralPage::SetFilterConfigItem(ImpPDFTabDialog* pParent) case 1: mxCbPDFA1b->set_active(true); // PDF/A-1a break; } + // the ToggleExportPDFAHdl handler will read or write the *UserSelection variables based + // on the mxCbPDFA1b state, so we have to prepare the correct input state. + if (mxCbPDFA1b->get_active()) + { + mxCbTaggedPDF->set_active(pParent->mbUseTaggedPDFUserSelection); + mxCbExportFormFields->set_active(pParent->mbExportFormFieldsUserSelection); + } + else + { + mbUseTaggedPDFUserSelection = pParent->mbUseTaggedPDFUserSelection; + mbExportFormFieldsUserSelection = pParent->mbExportFormFieldsUserSelection; + } ToggleExportPDFAHdl( *mxCbPDFA1b ); mxCbExportFormFields->connect_toggled( LINK( this, ImpPDFTabGeneralPage, ToggleExportFormFieldsHdl ) ); - // get the form values, for use with PDF/A-1 selection interface - mbTaggedPDFUserSelection = pParent->mbUseTaggedPDF; - mbExportFormFieldsUserSelection = pParent->mbExportFormFields; - - if( !mxCbPDFA1b->get_active() ) - { - // the value for PDF/A set by the ToggleExportPDFAHdl method called before - mxCbTaggedPDF->set_active( mbTaggedPDFUserSelection ); - mxCbExportFormFields->set_active( mbExportFormFieldsUserSelection ); - } - mxLbFormsFormat->set_active(static_cast<sal_uInt16>(pParent->mnFormsType)); mxCbAllowDuplicateFieldNames->set_active( pParent->mbAllowDuplicateFieldNames ); - mxFormsFrame->set_sensitive( pParent->mbExportFormFields ); mxCbExportBookmarks->set_active( pParent->mbExportBookmarks ); @@ -642,17 +653,18 @@ void ImpPDFTabGeneralPage::GetFilterConfigItem( ImpPDFTabDialog* pParent ) } pParent->mnPDFTypeSelection = 0; + pParent->mbUseTaggedPDF = mxCbTaggedPDF->get_active(); + pParent->mbExportFormFields = mxCbExportFormFields->get_active(); + if( mxCbPDFA1b->get_active() ) - { pParent->mnPDFTypeSelection = 1; - pParent->mbUseTaggedPDF = mbTaggedPDFUserSelection; - pParent->mbExportFormFields = mbExportFormFieldsUserSelection; - } else { - pParent->mbUseTaggedPDF = mxCbTaggedPDF->get_active(); - pParent->mbExportFormFields = mxCbExportFormFields->get_active(); + mbUseTaggedPDFUserSelection = pParent->mbUseTaggedPDF; + mbExportFormFieldsUserSelection = pParent->mbExportFormFields; } + pParent->mbUseTaggedPDFUserSelection = mbUseTaggedPDFUserSelection; + pParent->mbExportFormFieldsUserSelection = mbExportFormFieldsUserSelection; if( mxCbWatermark->get_active() ) pParent->maWatermarkText = mxEdWatermark->get_text(); @@ -754,49 +766,46 @@ IMPL_LINK_NOARG(ImpPDFTabGeneralPage, ToggleAddStreamHdl, weld::ToggleButton&, v IMPL_LINK_NOARG(ImpPDFTabGeneralPage, ToggleExportPDFAHdl, weld::ToggleButton&, void) { + const bool bIsPDFA = mxCbPDFA1b->get_active(); + // set the security page status (and its controls as well) ImpPDFTabSecurityPage* pSecPage = mpParent ? mpParent->getSecurityPage() : nullptr; if (pSecPage) - { - pSecPage->ImplPDFASecurityControl(!mxCbPDFA1b->get_active()); - } + pSecPage->ImplPDFASecurityControl(!bIsPDFA); - // PDF/A-1 needs tagged PDF, so force disable the control, will be forced in pdfexport. - bool bPDFA1Sel = mxCbPDFA1b->get_active(); - mxFormsFrame->set_sensitive(bPDFA1Sel); - if(bPDFA1Sel) + mxCbTaggedPDF->set_sensitive(!bIsPDFA); + mxCbExportFormFields->set_sensitive(!bIsPDFA); + mxFormsFrame->set_sensitive(!bIsPDFA); + + if (bIsPDFA) { - // store the values of subordinate controls - mbTaggedPDFUserSelection = mxCbTaggedPDF->get_active(); - mxCbTaggedPDF->set_active(true); - mxCbTaggedPDF->set_sensitive(false); + // store the users selection of subordinate controls and set required PDF/A values + mbUseTaggedPDFUserSelection = mxCbTaggedPDF->get_active(); mbExportFormFieldsUserSelection = mxCbExportFormFields->get_active(); + + mxCbTaggedPDF->set_active(true); mxCbExportFormFields->set_active(false); - mxCbExportFormFields->set_sensitive(false); + + // if a password was set, inform the user that this will not be used + if (pSecPage && pSecPage->hasPassword()) + { + std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(m_xContainer.get(), + VclMessageType::Warning, VclButtonsType::Ok, + PDFFilterResId(STR_WARN_PASSWORD_PDFA))); + xBox->run(); + } } else { - // retrieve the values of subordinate controls - mxCbTaggedPDF->set_sensitive(true); - mxCbTaggedPDF->set_active(mbTaggedPDFUserSelection); + // restore the users values of subordinate controls + mxCbTaggedPDF->set_active(mbUseTaggedPDFUserSelection); mxCbExportFormFields->set_active(mbExportFormFieldsUserSelection); - mxCbExportFormFields->set_sensitive(true); } - // PDF/A-1 doesn't allow launch action, so enable/disable the selection on - // Link page + // PDF/A doesn't allow launch action, so enable/disable the selection on Link page ImpPDFTabLinksPage* pLinksPage = mpParent ? mpParent->getLinksPage() : nullptr; if (pLinksPage) - pLinksPage->ImplPDFALinkControl(!mxCbPDFA1b->get_active()); - - // if a password was set, inform the user that this will not be used in PDF/A case - if( mxCbPDFA1b->get_active() && pSecPage && pSecPage->hasPassword() ) - { - std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(m_xContainer.get(), - VclMessageType::Warning, VclButtonsType::Ok, - PDFFilterResId(STR_WARN_PASSWORD_PDFA))); - xBox->run(); - } + pLinksPage->ImplPDFALinkControl(!bIsPDFA); } /// The option features tab page diff --git a/filter/source/pdf/impdialog.hxx b/filter/source/pdf/impdialog.hxx index f54d7147b07a..768ab2ac96a8 100644 --- a/filter/source/pdf/impdialog.hxx +++ b/filter/source/pdf/impdialog.hxx @@ -73,6 +73,7 @@ class ImpPDFTabDialog final : public SfxTabDialogController bool mbReduceImageResolution; sal_Int32 mnMaxImageResolution; bool mbUseTaggedPDF; + bool mbUseTaggedPDFUserSelection; sal_Int32 mnPDFTypeSelection; bool mbExportNotes; bool mbViewPDF; @@ -85,6 +86,7 @@ class ImpPDFTabDialog final : public SfxTabDialogController bool mbAddStream; sal_Int32 mnFormsType; bool mbExportFormFields; + bool mbExportFormFieldsUserSelection; bool mbAllowDuplicateFieldNames; bool mbExportBookmarks; bool mbExportHiddenSlides; @@ -164,7 +166,7 @@ class ImpPDFTabGeneralPage : public SfxTabPage { friend class ImpPDFTabLinksPage; - bool mbTaggedPDFUserSelection; + bool mbUseTaggedPDFUserSelection; bool mbExportFormFieldsUserSelection; bool mbIsPresentation; bool mbIsSpreadsheet; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits