diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2019-12-24 16:03:23 +0100 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2019-12-29 17:00:44 +0100 |
commit | 5a7cfe98e96489b7fa19d286ddd1e8c8e591d7dd (patch) | |
tree | d6a1496ac0e143d99d162b5e7002e07a73fa8841 /filter | |
parent | 50f13bbedf0bba0509b7bf98bc782ec821c7777b (diff) |
pdf: Add option for PDF/UA to the PDF export dialog
This is adding PDF/UA option to the PDF export dialog. When PDF/UA
support is enabled, it automatically enables PDFTag support as it
is required for PDF/UA.
Change-Id: Ib3dece964523d4ed9884c98a6022a91120c6065f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/85921
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'filter')
-rw-r--r-- | filter/source/pdf/impdialog.cxx | 39 | ||||
-rw-r--r-- | filter/source/pdf/impdialog.hxx | 5 | ||||
-rw-r--r-- | filter/source/pdf/pdfexport.cxx | 3 | ||||
-rw-r--r-- | filter/source/pdf/pdfexport.hxx | 1 | ||||
-rw-r--r-- | filter/source/pdf/pdffilter.cxx | 1 | ||||
-rw-r--r-- | filter/uiconfig/ui/pdfgeneralpage.ui | 22 |
6 files changed, 57 insertions, 14 deletions
diff --git a/filter/source/pdf/impdialog.cxx b/filter/source/pdf/impdialog.cxx index 477098a85114..d19458a00e4d 100644 --- a/filter/source/pdf/impdialog.cxx +++ b/filter/source/pdf/impdialog.cxx @@ -186,6 +186,8 @@ ImpPDFTabDialog::ImpPDFTabDialog(weld::Window* pParent, Sequence< PropertyValue mbUseTaggedPDFUserSelection = mbUseTaggedPDF; mnPDFTypeSelection = maConfigItem.ReadInt32( "SelectPdfVersion", 0 ); + mbPDFUACompliance = maConfigItem.ReadBool("PDFUACompliance", false); + if ( mbIsPresentation ) { mbExportNotesPages = maConfigItem.ReadBool( "ExportNotesPages", false ); @@ -368,10 +370,14 @@ Sequence< PropertyValue > ImpPDFTabDialog::GetFilterData() maConfigItem.WriteBool( "ReduceImageResolution", mbReduceImageResolution ); maConfigItem.WriteInt32("MaxImageResolution", mnMaxImageResolution ); - // always write the user selection, never the overridden PDF/A value + // always write the user selection, never the overridden value + const bool bIsPDFUA = mbPDFUACompliance; const bool bIsPDFA = (1 == mnPDFTypeSelection) || (2 == mnPDFTypeSelection); - maConfigItem.WriteBool("UseTaggedPDF", bIsPDFA ? mbUseTaggedPDFUserSelection : mbUseTaggedPDF); + const bool bUserSelectionTags = bIsPDFA || bIsPDFUA; + maConfigItem.WriteBool("UseTaggedPDF", bUserSelectionTags ? mbUseTaggedPDFUserSelection : mbUseTaggedPDF); + maConfigItem.WriteInt32("SelectPdfVersion", mnPDFTypeSelection ); + maConfigItem.WriteBool("PDFUACompliance", mbPDFUACompliance); if ( mbIsPresentation ) { @@ -471,6 +477,7 @@ ImpPDFTabGeneralPage::ImpPDFTabGeneralPage(weld::Container* pPage, weld::DialogC , mxCbPDFA(m_xBuilder->weld_check_button("pdfa")) , mxRbPDFA1b(m_xBuilder->weld_radio_button("pdfa1")) , mxRbPDFA2b(m_xBuilder->weld_radio_button("pdfa2")) + , mxCbPDFUA(m_xBuilder->weld_check_button("pdfua")) , mxCbTaggedPDF(m_xBuilder->weld_check_button("tagged")) , mxCbExportFormFields(m_xBuilder->weld_check_button("forms")) , mxFormsFrame(m_xBuilder->weld_widget("formsframe")) @@ -540,7 +547,7 @@ void ImpPDFTabGeneralPage::SetFilterConfigItem(ImpPDFTabDialog* pParent) mxCbWatermark->connect_toggled( LINK( this, ImpPDFTabGeneralPage, ToggleWatermarkHdl ) ); mxFtWatermark->set_sensitive(false ); mxEdWatermark->set_sensitive( false ); - mxCbPDFA->connect_toggled(LINK(this, ImpPDFTabGeneralPage, ToggleExportPDFAHdl)); + mxCbPDFA->connect_toggled(LINK(this, ImpPDFTabGeneralPage, TogglePDFVersionOrUniversalAccessibilityHandle)); const bool bIsPDFA = (1 == pParent->mnPDFTypeSelection) || (2 == pParent->mnPDFTypeSelection); mxCbPDFA->set_active(bIsPDFA); @@ -556,13 +563,18 @@ void ImpPDFTabGeneralPage::SetFilterConfigItem(ImpPDFTabDialog* pParent) mxRbPDFA2b->set_active(true); break; } - // the ToggleExportPDFAHdl handler will read or write the *UserSelection based + + const bool bIsPDFUA = pParent->mbPDFUACompliance; + mxCbPDFUA->set_active(bIsPDFUA); + mxCbPDFUA->connect_toggled(LINK(this, ImpPDFTabGeneralPage, TogglePDFVersionOrUniversalAccessibilityHandle)); + + // the TogglePDFVersionOrUniversalAccessibilityHandle handler will read or write the *UserSelection based // on the mxCbPDFA (= bIsPDFA) state, so we have to prepare the correct input state. - if (bIsPDFA) + if (bIsPDFA || bIsPDFUA) mxCbTaggedPDF->set_active(pParent->mbUseTaggedPDFUserSelection); else mbUseTaggedPDFUserSelection = pParent->mbUseTaggedPDFUserSelection; - ToggleExportPDFAHdl( *mxCbPDFA ); + TogglePDFVersionOrUniversalAccessibilityHandle(*mxCbPDFA); mxCbExportFormFields->set_active(pParent->mbExportFormFields); mxCbExportFormFields->connect_toggled( LINK( this, ImpPDFTabGeneralPage, ToggleExportFormFieldsHdl ) ); @@ -675,14 +687,20 @@ void ImpPDFTabGeneralPage::GetFilterConfigItem( ImpPDFTabDialog* pParent ) pParent->mbUseTaggedPDF = mxCbTaggedPDF->get_active(); const bool bIsPDFA = mxCbPDFA->get_active(); + const bool bIsPDFUA = mxCbPDFUA->get_active(); + if (bIsPDFA) { pParent->mnPDFTypeSelection = 2; if( mxRbPDFA1b->get_active() ) pParent->mnPDFTypeSelection = 1; } - else + + pParent->mbPDFUACompliance = bIsPDFUA; + + if (!bIsPDFA && !bIsPDFUA) mbUseTaggedPDFUserSelection = pParent->mbUseTaggedPDF; + pParent->mbUseTaggedPDFUserSelection = mbUseTaggedPDFUserSelection; pParent->mbExportFormFields = mxCbExportFormFields->get_active(); @@ -784,20 +802,21 @@ IMPL_LINK_NOARG(ImpPDFTabGeneralPage, ToggleAddStreamHdl, weld::ToggleButton&, v } } -IMPL_LINK_NOARG(ImpPDFTabGeneralPage, ToggleExportPDFAHdl, weld::ToggleButton&, void) +IMPL_LINK_NOARG(ImpPDFTabGeneralPage, TogglePDFVersionOrUniversalAccessibilityHandle, weld::ToggleButton&, void) { const bool bIsPDFA = mxCbPDFA->get_active(); + const bool bIsPDFUA = mxCbPDFUA->get_active(); // set the security page status (and its controls as well) ImpPDFTabSecurityPage* pSecPage = mpParent ? mpParent->getSecurityPage() : nullptr; if (pSecPage) pSecPage->ImplPDFASecurityControl(!bIsPDFA); - mxCbTaggedPDF->set_sensitive(!bIsPDFA); + mxCbTaggedPDF->set_sensitive(!bIsPDFA && !bIsPDFUA); mxRbPDFA1b->set_sensitive(bIsPDFA); mxRbPDFA2b->set_sensitive(bIsPDFA); - if (bIsPDFA) + if (bIsPDFA || bIsPDFUA) { // store the users selection of subordinate controls and set required PDF/A values mbUseTaggedPDFUserSelection = mxCbTaggedPDF->get_active(); diff --git a/filter/source/pdf/impdialog.hxx b/filter/source/pdf/impdialog.hxx index f3599f6587ec..52a37ad5cf4a 100644 --- a/filter/source/pdf/impdialog.hxx +++ b/filter/source/pdf/impdialog.hxx @@ -78,6 +78,7 @@ class ImpPDFTabDialog final : public SfxTabDialogController bool mbUseTaggedPDF; bool mbUseTaggedPDFUserSelection; sal_Int32 mnPDFTypeSelection; + bool mbPDFUACompliance; bool mbExportNotes; bool mbViewPDF; bool mbUseReferenceXObject; @@ -189,6 +190,7 @@ class ImpPDFTabGeneralPage : public SfxTabPage std::unique_ptr<weld::CheckButton> mxCbPDFA; std::unique_ptr<weld::RadioButton> mxRbPDFA1b; std::unique_ptr<weld::RadioButton> mxRbPDFA2b; + std::unique_ptr<weld::CheckButton> mxCbPDFUA; std::unique_ptr<weld::CheckButton> mxCbTaggedPDF; std::unique_ptr<weld::CheckButton> mxCbExportFormFields; std::unique_ptr<weld::Widget> mxFormsFrame; @@ -224,8 +226,9 @@ class ImpPDFTabGeneralPage : public SfxTabPage void TogglePagesHdl(); void EnableExportNotesPages(); + DECL_LINK(TogglePDFVersionOrUniversalAccessibilityHandle, weld::ToggleButton&, void); + public: - DECL_LINK(ToggleExportPDFAHdl, weld::ToggleButton&, void); ImpPDFTabGeneralPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet); virtual ~ImpPDFTabGeneralPage() override; diff --git a/filter/source/pdf/pdfexport.cxx b/filter/source/pdf/pdfexport.cxx index d00e371338b4..00e279047f73 100644 --- a/filter/source/pdf/pdfexport.cxx +++ b/filter/source/pdf/pdfexport.cxx @@ -80,6 +80,7 @@ PDFExport::PDFExport( const Reference< XComponent >& rxSrcDoc, mxIH ( rxIH ), mbUseTaggedPDF ( false ), mnPDFTypeSelection ( 0 ), + mbPDFUACompliance ( false), mbExportNotes ( true ), mbExportPlaceholders ( false ), mbUseReferenceXObject ( false ), @@ -473,6 +474,8 @@ bool PDFExport::Export( const OUString& rFile, const Sequence< PropertyValue >& rFilterData[ nData ].Value >>= mbUseTaggedPDF; else if ( rFilterData[ nData ].Name == "SelectPdfVersion" ) rFilterData[ nData ].Value >>= mnPDFTypeSelection; + else if ( rFilterData[ nData ].Name == "PDFUACompliance" ) + rFilterData[ nData ].Value >>= mbPDFUACompliance; else if ( rFilterData[ nData ].Name == "ExportNotes" ) rFilterData[ nData ].Value >>= mbExportNotes; else if ( rFilterData[ nData ].Name == "ExportNotesPages" ) diff --git a/filter/source/pdf/pdfexport.hxx b/filter/source/pdf/pdfexport.hxx index 426416628e24..54784cce1abb 100644 --- a/filter/source/pdf/pdfexport.hxx +++ b/filter/source/pdf/pdfexport.hxx @@ -52,6 +52,7 @@ private: bool mbUseTaggedPDF; sal_Int32 mnPDFTypeSelection; + bool mbPDFUACompliance; bool mbExportNotes; bool mbExportPlaceholders; bool mbUseReferenceXObject; diff --git a/filter/source/pdf/pdffilter.cxx b/filter/source/pdf/pdffilter.cxx index 5dfb9396a590..5a7e5fbaedf0 100644 --- a/filter/source/pdf/pdffilter.cxx +++ b/filter/source/pdf/pdffilter.cxx @@ -84,6 +84,7 @@ bool PDFFilter::implExport( const Sequence< PropertyValue >& rDescriptor ) aCfgItem.ReadInt32( "MaxImageResolution", 300 ); aCfgItem.ReadBool( "UseTaggedPDF", false ); aCfgItem.ReadInt32( "SelectPdfVersion", 0 ); + aCfgItem.ReadBool("PDFUACompliance", false); aCfgItem.ReadBool( "ExportNotes", false ); aCfgItem.ReadBool( "ExportPlaceholders", false ); aCfgItem.ReadBool( "ExportNotesPages", false ); diff --git a/filter/uiconfig/ui/pdfgeneralpage.ui b/filter/uiconfig/ui/pdfgeneralpage.ui index 3d59a633b027..1fbde5ceb6f4 100644 --- a/filter/uiconfig/ui/pdfgeneralpage.ui +++ b/filter/uiconfig/ui/pdfgeneralpage.ui @@ -473,7 +473,7 @@ </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">2</property> + <property name="top_attach">3</property> </packing> </child> <child> @@ -489,7 +489,7 @@ </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">3</property> + <property name="top_attach">4</property> </packing> </child> <child> @@ -554,7 +554,7 @@ </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">4</property> + <property name="top_attach">5</property> </packing> </child> <child> @@ -631,6 +631,22 @@ <property name="top_attach">1</property> </packing> </child> + <child> + <object class="GtkCheckButton" id="pdfua"> + <property name="label" translatable="yes" context="pdfgeneralpage|pdfua">U_niversal Accessibility (PDF/UA)</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="tooltip_text" translatable="yes" context="pdfgeneralpage|pdfua|tooltip_text">Creates an universal accessibility compliant PDF file that follows the requirements of PDF/UA (ISO 14289) specifications.</property> + <property name="halign">start</property> + <property name="use_underline">True</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">2</property> + </packing> + </child> </object> </child> </object> |