summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan-Marek Glogowski <jan-marek.glogowski@extern.cib.de>2019-08-01 14:10:05 +0000
committerJan-Marek Glogowski <jan-marek.glogowski@extern.cib.de>2019-08-07 10:33:39 +0000
commit599447d56e3b2625f5e6d843b77b41ffd4b4f1f2 (patch)
tree0d98497a623f66778d98e625f790ca1f0354f18d
parentdc9bd8f552cc2960784ee9d2d0edf20810ed2a8c (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. This includes some adaptions, as the customer branch just contains the first commit from tdf#62728. Reviewed-on: https://gerrit.libreoffice.org/76820 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de> (cherry picked from commit aac306e7ea42eeac3d6c1860f25061148ba2f547) Change-Id: I31f96a36d776468a5547042fb9e4c0605751fbba
-rw-r--r--filter/source/pdf/impdialog.cxx110
-rw-r--r--filter/source/pdf/impdialog.hxx4
2 files changed, 63 insertions, 51 deletions
diff --git a/filter/source/pdf/impdialog.cxx b/filter/source/pdf/impdialog.cxx
index 372505851e33..e55e9f10c33a 100644
--- a/filter/source/pdf/impdialog.cxx
+++ b/filter/source/pdf/impdialog.cxx
@@ -70,6 +70,7 @@ ImpPDFTabDialog::ImpPDFTabDialog(weld::Window* pParent, Sequence< PropertyValue
mbReduceImageResolution( false ),
mnMaxImageResolution( 300 ),
mbUseTaggedPDF( false ),
+ mbUseTaggedPDFUserSelection( false ),
mbExportNotes( true ),
mbViewPDF( false ),
mbUseReferenceXObject( false ),
@@ -81,6 +82,7 @@ ImpPDFTabDialog::ImpPDFTabDialog(weld::Window* pParent, Sequence< PropertyValue
mbAddStream( false ),
mnFormsType( 0 ),
mbExportFormFields( true ),
+ mbExportFormFieldsUserSelection( true ),
mbAllowDuplicateFieldNames( false ),
mbExportBookmarks( true ),
mbExportHiddenSlides ( false),
@@ -181,7 +183,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 )
{
@@ -200,8 +205,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 );
@@ -365,7 +373,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) || (2 == mnPDFTypeSelection);
+ maConfigItem.WriteBool("UseTaggedPDF", bIsPDFA ? mbUseTaggedPDFUserSelection : mbUseTaggedPDF);
maConfigItem.WriteInt32("SelectPdfVersion", mnPDFTypeSelection );
if ( mbIsPresentation )
@@ -389,7 +399,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 );
@@ -445,7 +456,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)
@@ -539,24 +550,25 @@ void ImpPDFTabGeneralPage::SetFilterConfigItem(ImpPDFTabDialog* pParent)
case 2: mxCbPDFA2b->set_active(true); // PDF/A-2a
break;
}
- ToggleExportPDFAHdl( *mxCbPDFA2b );
-
- 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( !mxCbPDFA2b->get_active() )
+ // the ToggleExportPDFAHdl handler will read or write the *UserSelection variables based
+ // on the mxCbPDFA2b state, so we have to prepare the correct input state.
+ if (mxCbPDFA2b->get_active())
{
- // the value for PDF/A set by the ToggleExportPDFAHdl method called before
- mxCbTaggedPDF->set_active( mbTaggedPDFUserSelection );
- mxCbExportFormFields->set_active( mbExportFormFieldsUserSelection );
+ mxCbTaggedPDF->set_active(pParent->mbUseTaggedPDFUserSelection);
+ mxCbExportFormFields->set_active(pParent->mbExportFormFieldsUserSelection);
}
+ else
+ {
+ mbUseTaggedPDFUserSelection = pParent->mbUseTaggedPDFUserSelection;
+ mbExportFormFieldsUserSelection = pParent->mbExportFormFieldsUserSelection;
+ }
+ ToggleExportPDFAHdl( *mxCbPDFA2b );
+
+ mxCbExportFormFields->connect_toggled( LINK( this, ImpPDFTabGeneralPage, ToggleExportFormFieldsHdl ) );
mxLbFormsFormat->set_active(static_cast<sal_uInt16>(pParent->mnFormsType));
mxCbAllowDuplicateFieldNames->set_active( pParent->mbAllowDuplicateFieldNames );
- mxFormsFrame->set_sensitive( pParent->mbExportFormFields );
mxCbExportBookmarks->set_active( pParent->mbExportBookmarks );
@@ -643,17 +655,18 @@ void ImpPDFTabGeneralPage::GetFilterConfigItem( ImpPDFTabDialog* pParent )
}
pParent->mnPDFTypeSelection = 0;
+ pParent->mbUseTaggedPDF = mxCbTaggedPDF->get_active();
+ pParent->mbExportFormFields = mxCbExportFormFields->get_active();
+
if( mxCbPDFA2b->get_active() )
- {
pParent->mnPDFTypeSelection = 2;
- 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();
@@ -755,49 +768,46 @@ IMPL_LINK_NOARG(ImpPDFTabGeneralPage, ToggleAddStreamHdl, weld::ToggleButton&, v
IMPL_LINK_NOARG(ImpPDFTabGeneralPage, ToggleExportPDFAHdl, weld::ToggleButton&, void)
{
+ const bool bIsPDFA = mxCbPDFA2b->get_active();
+
// set the security page status (and its controls as well)
ImpPDFTabSecurityPage* pSecPage = mpParent ? mpParent->getSecurityPage() : nullptr;
if (pSecPage)
- {
- pSecPage->ImplPDFASecurityControl(!mxCbPDFA2b->get_active());
- }
+ pSecPage->ImplPDFASecurityControl(!bIsPDFA);
+
+ mxCbTaggedPDF->set_sensitive(!bIsPDFA);
+ mxCbExportFormFields->set_sensitive(!bIsPDFA);
+ mxFormsFrame->set_sensitive(!bIsPDFA);
- // PDF/A-1 needs tagged PDF, so force disable the control, will be forced in pdfexport.
- bool bPDFA1Sel = mxCbPDFA2b->get_active();
- mxFormsFrame->set_sensitive(bPDFA1Sel);
- if(bPDFA1Sel)
+ 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-2 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(!mxCbPDFA2b->get_active());
-
- // if a password was set, inform the user that this will not be used in PDF/A case
- if( mxCbPDFA2b->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 6381c554bc47..c9d205a4a063 100644
--- a/filter/source/pdf/impdialog.hxx
+++ b/filter/source/pdf/impdialog.hxx
@@ -81,6 +81,7 @@ class ImpPDFTabDialog final : public SfxTabDialogController
bool mbReduceImageResolution;
sal_Int32 mnMaxImageResolution;
bool mbUseTaggedPDF;
+ bool mbUseTaggedPDFUserSelection;
sal_Int32 mnPDFTypeSelection;
bool mbExportNotes;
bool mbViewPDF;
@@ -93,6 +94,7 @@ class ImpPDFTabDialog final : public SfxTabDialogController
bool mbAddStream;
sal_Int32 mnFormsType;
bool mbExportFormFields;
+ bool mbExportFormFieldsUserSelection;
bool mbAllowDuplicateFieldNames;
bool mbExportBookmarks;
bool mbExportHiddenSlides;
@@ -172,7 +174,7 @@ class ImpPDFTabGeneralPage : public SfxTabPage
{
friend class ImpPDFTabLinksPage;
- bool mbTaggedPDFUserSelection;
+ bool mbUseTaggedPDFUserSelection;
bool mbExportFormFieldsUserSelection;
bool mbIsPresentation;
bool mbIsSpreadsheet;