summaryrefslogtreecommitdiff
path: root/filter
diff options
context:
space:
mode:
authorJan-Marek Glogowski <jan-marek.glogowski@extern.cib.de>2019-07-31 18:48:30 +0200
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2019-08-07 10:43:51 +0200
commitc864d894a90141f6d73ed80c1035909986b17074 (patch)
treed0b9b8dc37d9d3503595a706b744ca570a0e2571 /filter
parent611a8a77869f1248f2702b396cd25c198e57c9b2 (diff)
tdf#126642 always allow PDF/A form export
This generally enables form export for PDF/A. A major problem was the saved user setting for UseTaggedPDF, which was overridden by the PDF/A export and used to be stored in the user config. At this point it was impossible to actually restore the user config for the next export, because it contained the overwritten PDF/A value. So this now guarantees that the user selection is stored, which means the underlying filter reading the config has to ignore the users UseTaggedPDF setting for PDF/A, which is happening in any way. That way it is possible to correctly restore the previous user selection after unchecking the PDF/A option. And the "Create form" frame is kept sensitive, just based on the "Create form" checkbox. Change-Id: I29162b423b2d8de77f549fdaabf0aefebcefa124 Reviewed-on: https://gerrit.libreoffice.org/76765 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Diffstat (limited to 'filter')
-rw-r--r--filter/source/pdf/impdialog.cxx123
-rw-r--r--filter/source/pdf/impdialog.hxx4
-rw-r--r--filter/source/pdf/pdfexport.cxx5
3 files changed, 56 insertions, 76 deletions
diff --git a/filter/source/pdf/impdialog.cxx b/filter/source/pdf/impdialog.cxx
index f6f084fd2fb0..b2e864674705 100644
--- a/filter/source/pdf/impdialog.cxx
+++ b/filter/source/pdf/impdialog.cxx
@@ -73,6 +73,7 @@ ImpPDFTabDialog::ImpPDFTabDialog(weld::Window* pParent, Sequence< PropertyValue
mbReduceImageResolution( false ),
mnMaxImageResolution( 300 ),
mbUseTaggedPDF( false ),
+ mbUseTaggedPDFUserSelection( false ),
mbExportNotes( true ),
mbViewPDF( false ),
mbUseReferenceXObject( false ),
@@ -184,7 +185,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 )
{
@@ -203,8 +207,8 @@ ImpPDFTabDialog::ImpPDFTabDialog(weld::Window* pParent, Sequence< PropertyValue
mbIsExportPlaceholders = maConfigItem.ReadBool( "ExportPlaceholders", false );
mbAddStream = maConfigItem.ReadBool( "IsAddStream", false );
- mnFormsType = maConfigItem.ReadInt32( "FormsType", 0 );
mbExportFormFields = maConfigItem.ReadBool( "ExportFormFields", true );
+ mnFormsType = maConfigItem.ReadInt32( "FormsType", 0 );
if ( ( mnFormsType < 0 ) || ( mnFormsType > 3 ) )
mnFormsType = 0;
mbAllowDuplicateFieldNames = maConfigItem.ReadBool( "AllowDuplicateFieldNames", false );
@@ -366,7 +370,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 )
@@ -446,8 +452,7 @@ Sequence< PropertyValue > ImpPDFTabDialog::GetFilterData()
ImpPDFTabGeneralPage::ImpPDFTabGeneralPage(TabPageParent pParent, const SfxItemSet& rCoreSet)
: SfxTabPage(pParent, "filter/ui/pdfgeneralpage.ui", "PdfGeneralPage", &rCoreSet)
- , mbTaggedPDFUserSelection(false)
- , mbExportFormFieldsUserSelection(false)
+ , mbUseTaggedPDFUserSelection(false)
, mbIsPresentation(false)
, mbIsSpreadsheet(false)
, mbIsWriter(false)
@@ -535,47 +540,34 @@ void ImpPDFTabGeneralPage::SetFilterConfigItem(ImpPDFTabDialog* pParent)
mxFtWatermark->set_sensitive(false );
mxEdWatermark->set_sensitive( false );
mxCbPDFA->connect_toggled(LINK(this, ImpPDFTabGeneralPage, ToggleExportPDFAHdl));
- mxRbPDFA1b->connect_toggled(LINK(this, ImpPDFTabGeneralPage, ToggleExportPDFAHdl));
- mxRbPDFA2b->connect_toggled(LINK(this, ImpPDFTabGeneralPage, ToggleExportPDFAHdl));
+
+ const bool bIsPDFA = (1 == pParent->mnPDFTypeSelection) || (2 == pParent->mnPDFTypeSelection);
+ mxCbPDFA->set_active(bIsPDFA);
switch( pParent->mnPDFTypeSelection )
{
- default:
- // PDF 1.5
- mxCbPDFA->set_active( false );
- mxRbPDFA1b->set_active( false );
- mxRbPDFA2b->set_active( true );
- break;
- case 1:
- // PDF A-1b
- mxCbPDFA->set_active(true);
+ case 1: // PDF/A-1
mxRbPDFA1b->set_active(true);
mxRbPDFA2b->set_active(false);
break;
- case 2:
- // PDF A-2b
- mxCbPDFA->set_active(true);
- mxRbPDFA2b->set_active(true);
+ case 2: // PDF/A-2
+ default: // PDF 1.x
mxRbPDFA1b->set_active(false);
+ mxRbPDFA2b->set_active(true);
break;
}
+ // the ToggleExportPDFAHdl handler will read or write the *UserSelection based
+ // on the mxCbPDFA (= bIsPDFA) state, so we have to prepare the correct input state.
+ if (bIsPDFA)
+ mxCbTaggedPDF->set_active(pParent->mbUseTaggedPDFUserSelection);
+ else
+ mbUseTaggedPDFUserSelection = pParent->mbUseTaggedPDFUserSelection;
ToggleExportPDFAHdl( *mxCbPDFA );
+ mxCbExportFormFields->set_active(pParent->mbExportFormFields);
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( !mxCbPDFA->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 );
@@ -667,20 +659,18 @@ void ImpPDFTabGeneralPage::GetFilterConfigItem( ImpPDFTabDialog* pParent )
}
pParent->mnPDFTypeSelection = 0;
- if( mxCbPDFA->get_active() )
+ pParent->mbUseTaggedPDF = mxCbTaggedPDF->get_active();
+
+ const bool bIsPDFA = mxCbPDFA->get_active();
+ if (bIsPDFA)
{
pParent->mnPDFTypeSelection = 2;
if( mxRbPDFA1b->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;
+ pParent->mbUseTaggedPDFUserSelection = mbUseTaggedPDFUserSelection;
if( mxCbWatermark->get_active() )
pParent->maWatermarkText = mxEdWatermark->get_text();
@@ -782,51 +772,42 @@ IMPL_LINK_NOARG(ImpPDFTabGeneralPage, ToggleAddStreamHdl, weld::ToggleButton&, v
IMPL_LINK_NOARG(ImpPDFTabGeneralPage, ToggleExportPDFAHdl, weld::ToggleButton&, void)
{
+ const bool bIsPDFA = mxCbPDFA->get_active();
+
// set the security page status (and its controls as well)
ImpPDFTabSecurityPage* pSecPage = mpParent ? mpParent->getSecurityPage() : nullptr;
if (pSecPage)
- pSecPage->ImplPDFASecurityControl(!mxCbPDFA->get_active());
+ pSecPage->ImplPDFASecurityControl(!bIsPDFA);
+
+ mxCbTaggedPDF->set_sensitive(!bIsPDFA);
+ mxRbPDFA1b->set_sensitive(bIsPDFA);
+ mxRbPDFA2b->set_sensitive(bIsPDFA);
- // PDF/A-1 needs tagged PDF, so force disable the control, will be forced in pdfexport.
- bool bPDFA1Sel = mxCbPDFA->get_active();
- mxFormsFrame->set_sensitive(bPDFA1Sel);
- if(bPDFA1Sel)
+ if (bIsPDFA)
{
- // store the values of subordinate controls
- mbTaggedPDFUserSelection = mxCbTaggedPDF->get_active();
+ // 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);
- mbExportFormFieldsUserSelection = mxCbExportFormFields->get_active();
- mxCbExportFormFields->set_active(false);
- mxCbExportFormFields->set_sensitive(false);
- mxRbPDFA1b->set_sensitive(true);
- mxRbPDFA2b->set_sensitive(true);
+
+ // 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(false);
- mxCbTaggedPDF->set_sensitive(true);
- mxCbTaggedPDF->set_active(mbTaggedPDFUserSelection);
- mxCbExportFormFields->set_active(mbExportFormFieldsUserSelection);
- mxRbPDFA1b->set_sensitive(false);
- mxRbPDFA2b->set_sensitive(false);
+ // restore the users values of subordinate controls
+ mxCbTaggedPDF->set_active(mbUseTaggedPDFUserSelection);
}
- // 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 the Link page
ImpPDFTabLinksPage* pLinksPage = mpParent ? mpParent->getLinksPage() : nullptr;
if (pLinksPage)
- pLinksPage->ImplPDFALinkControl(!mxCbPDFA->get_active());
-
- // if a password was set, inform the user that this will not be used in PDF/A case
- if( mxCbPDFA->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 9f9b8e38c33f..c1a9543d09d5 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;
@@ -164,8 +165,7 @@ class ImpPDFTabGeneralPage : public SfxTabPage
{
friend class ImpPDFTabLinksPage;
- bool mbTaggedPDFUserSelection;
- bool mbExportFormFieldsUserSelection;
+ bool mbUseTaggedPDFUserSelection;
bool mbIsPresentation;
bool mbIsSpreadsheet;
bool mbIsWriter;
diff --git a/filter/source/pdf/pdfexport.cxx b/filter/source/pdf/pdfexport.cxx
index 6c293392effe..952a33ad71f4 100644
--- a/filter/source/pdf/pdfexport.cxx
+++ b/filter/source/pdf/pdfexport.cxx
@@ -599,15 +599,14 @@ bool PDFExport::Export( const OUString& rFile, const Sequence< PropertyValue >&
case 1:
aContext.Version = vcl::PDFWriter::PDFVersion::PDF_A_1;
mbUseTaggedPDF = true; // force the tagged PDF as well
- mbExportFormFields = false; // force disabling of form conversion
- mbRemoveTransparencies = true; // PDF/A does not allow transparencies
+ mbRemoveTransparencies = true; // does not allow transparencies
mbEncrypt = false; // no encryption
xEnc.clear();
break;
case 2:
aContext.Version = vcl::PDFWriter::PDFVersion::PDF_A_2;
mbUseTaggedPDF = true; // force the tagged PDF as well
- mbRemoveTransparencies = false; // PDF/A-2 does allow transparencies
+ mbRemoveTransparencies = false; // does allow transparencies
mbEncrypt = false; // no encryption
xEnc.clear();
break;