[Libreoffice-commits] core.git: Branch 'feature/accessibilitycheck' - filter/source filter/uiconfig include/vcl officecfg/registry vcl/source

Tomaž Vajngerl (via logerrit) logerrit at kemper.freedesktop.org
Tue Dec 24 15:10:05 UTC 2019


 filter/source/pdf/impdialog.cxx                            |   39 +++++++++----
 filter/source/pdf/impdialog.hxx                            |    5 +
 filter/source/pdf/pdfexport.cxx                            |    3 +
 filter/source/pdf/pdfexport.hxx                            |    1 
 filter/source/pdf/pdffilter.cxx                            |    1 
 filter/uiconfig/ui/pdfgeneralpage.ui                       |   22 ++++++-
 include/vcl/pdfwriter.hxx                                  |    4 +
 officecfg/registry/schema/org/openoffice/Office/Common.xcs |   14 +++-
 vcl/source/gdi/pdfwriter_impl.cxx                          |    6 ++
 9 files changed, 78 insertions(+), 17 deletions(-)

New commits:
commit 0a0a7e1795a7d8057a435a9a221b90013303d3bc
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Tue Dec 24 16:03:23 2019 +0100
Commit:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Tue Dec 24 16:03:23 2019 +0100

    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

diff --git a/filter/source/pdf/impdialog.cxx b/filter/source/pdf/impdialog.cxx
index 1b0e8c327964..16102c37b2fd 100644
--- a/filter/source/pdf/impdialog.cxx
+++ b/filter/source/pdf/impdialog.cxx
@@ -191,6 +191,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 );
@@ -373,10 +375,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 )
     {
@@ -476,6 +482,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"))
@@ -545,7 +552,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);
@@ -561,13 +568,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 ) );
@@ -679,14 +691,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;
 
     if( mxCbWatermark->get_active() )
@@ -787,20 +805,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 4827e125fbc0..910f428b163a 100644
--- a/filter/source/pdf/impdialog.hxx
+++ b/filter/source/pdf/impdialog.hxx
@@ -75,6 +75,7 @@ class ImpPDFTabDialog final : public SfxTabDialogController
     bool                        mbUseTaggedPDF;
     bool                        mbUseTaggedPDFUserSelection;
     sal_Int32                   mnPDFTypeSelection;
+    bool                        mbPDFUACompliance;
     bool                        mbExportNotes;
     bool                        mbViewPDF;
     bool                        mbUseReferenceXObject;
@@ -186,6 +187,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;
@@ -221,8 +223,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 039ac09de19c..bb8eddaf8e5a 100644
--- a/filter/source/pdf/pdfexport.cxx
+++ b/filter/source/pdf/pdfexport.cxx
@@ -97,6 +97,7 @@ PDFExport::PDFExport( const Reference< XComponent >& rxSrcDoc,
     mxIH                        ( rxIH ),
     mbUseTaggedPDF              ( false ),
     mnPDFTypeSelection          ( 0 ),
+    mbPDFUACompliance           ( false),
     mbExportNotes               ( true ),
     mbExportPlaceholders        ( false ),
     mbUseReferenceXObject       ( false ),
@@ -490,6 +491,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 f133e12c5ffa..8fec5a553ccc 100644
--- a/filter/source/pdf/pdfexport.hxx
+++ b/filter/source/pdf/pdfexport.hxx
@@ -43,6 +43,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 b79cc7884346..1abeda124ee2 100644
--- a/filter/source/pdf/pdffilter.cxx
+++ b/filter/source/pdf/pdffilter.cxx
@@ -80,6 +80,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>
diff --git a/include/vcl/pdfwriter.hxx b/include/vcl/pdfwriter.hxx
index e109cf6a76eb..40ff4802b738 100644
--- a/include/vcl/pdfwriter.hxx
+++ b/include/vcl/pdfwriter.hxx
@@ -552,6 +552,10 @@ The following structure describes the permissions used in PDF security
 
         /* decides the PDF language level to be produced */
         PDFVersion                      Version;
+
+        /* PDF/UA compliance */
+        bool UniversalAccessibilityCompliance;
+
         /* valid for PDF >= 1.4
            causes the MarkInfo entry in the document catalog to be set
         */
diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
index 185cfe69f26e..68338653f08c 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
@@ -5328,6 +5328,14 @@
             <value>0</value>
           </prop>
           <!-- END PDF Version selection -->
+          <!-- PDF/UA Compliance -->
+          <prop oor:name="PDFUACompliance" oor:type="xs:boolean" oor:nillable="false">
+            <info>
+              <desc>Specifies if the document is PDF/UA (Universal Accessibility) compliant</desc>
+            </info>
+            <value>false</value>
+          </prop>
+          <!-- END PDF/UA Compliance -->
           <!-- PDF Relative Link -->
           <prop oor:name="ExportLinksRelativeFsys" oor:type="xs:boolean" oor:nillable="false">
             <info>
@@ -5449,9 +5457,9 @@
       <prop oor:name="UseWebDAVFileLocking" oor:type="xs:boolean" oor:nillable="false">
         <info>
           <desc>Determines if WebDAV-specific file locking is used for documents
-	  on WebDAV shares. It is not recommended to set this option to 'false' in
-	  scenarios where multi-user, concurrent read/write access to WebDAV share
-	  is required</desc>
+          on WebDAV shares. It is not recommended to set this option to 'false' in
+          scenarios where multi-user, concurrent read/write access to WebDAV share
+          is required</desc>
         </info>
         <value>true</value>
       </prop>
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index b7e59c1d87f1..7b971a1fe3ea 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -1402,6 +1402,12 @@ void PDFWriterImpl::PDFPage::appendWaveLine( sal_Int32 nWidth, sal_Int32 nY, sal
     if( m_bIsPDF_A2 )
         m_aContext.Version = PDFWriter::PDFVersion::PDF_1_6; //we could even use 1.7 features
 
+    if (m_aContext.UniversalAccessibilityCompliance)
+    {
+        m_bIsPDF_UA = true;
+        m_aContext.Tagged = true;
+    }
+
     if( m_aContext.DPIx == 0 || m_aContext.DPIy == 0 )
         SetReferenceDevice( VirtualDevice::RefDevMode::PDF1 );
     else


More information about the Libreoffice-commits mailing list