summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan-Marek Glogowski <jan-marek.glogowski@extern.cib.de>2019-08-01 14:10:05 +0000
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2019-08-07 10:43:27 +0200
commitaac306e7ea42eeac3d6c1860f25061148ba2f547 (patch)
treec5a53012737984e3fc4be736face589d691303b6
parent28c6af3ddc283ca9c5712359a9abcb385c1575b4 (diff)
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.Behrens@CIB.de>
-rw-r--r--filter/source/pdf/impdialog.cxx109
-rw-r--r--filter/source/pdf/impdialog.hxx4
2 files changed, 62 insertions, 51 deletions
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;