[Libreoffice-commits] core.git: Branch 'distro/cib/libreoffice-6-1' - cui/source uui/source xmlsecurity/inc xmlsecurity/source xmlsecurity/uiconfig

Jan-Marek Glogowski (via logerrit) logerrit at kemper.freedesktop.org
Tue Jan 21 12:31:27 UTC 2020


 cui/source/options/optinet2.cxx              |   14 ------
 uui/source/secmacrowarnings.cxx              |    4 -
 xmlsecurity/inc/macrosecurity.hxx            |    2 
 xmlsecurity/source/dialogs/macrosecurity.cxx |   62 +++++++++++++++++----------
 xmlsecurity/uiconfig/ui/securitytrustpage.ui |    4 +
 5 files changed, 48 insertions(+), 38 deletions(-)

New commits:
commit e2914435983f2eb3347195199b063a17dc9438d6
Author:     Jan-Marek Glogowski <jan-marek.glogowski at extern.cib.de>
AuthorDate: Wed Dec 11 10:24:37 2019 +0100
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Tue Jan 21 13:30:56 2020 +0100

    Fix macro security UI usability problems
    
    * Don't hide the option dialogs "Macro security" push button.
      I don't see any reason, why these settings should be hidden, if
      macros are disabled or settings locked. At least a user can now
      check, what is going on (still nothing shows disabled macros for
      a document in the UI AFAIK).
    * Don't scale the lock icons of the trusted list boxes.
      This just uses the same alignments, which the macro security
      level lock image uses, otherwise the image is scaled to fit the
      whole space of its layout cell.
    * Don't disable the trusted list boxes.
      If the setting is locked, it's sufficient to disable all the
      buttons, which allow modification (so View can stay enabled).
      This way you can still scroll the list. Correct button handling
      is already implemented and works for me.
    * Catch exceptions of broken certificate data.
      If your config contains certificates, which can't be correctly
      decoded, the NSS backend will throw an exception, which kills
      the dialog, but not the nested loop, resulting in a locked LO.
    
    Since we don't want a string change in LTS, this drops the whole
    "broken certificate" warning dialog. There already are SAL_WARNs,
    which log the same warning, and are considered sufficient for
    debugging broken configurations.
    
    Reviewed-on: https://gerrit.libreoffice.org/85056
    Tested-by: Jenkins
    Reviewed-by: Jan-Marek Glogowski <glogow at fbihome.de>
    (cherry picked from commit b3348ce498b3d54b3e5e6518954ad9d5e917b8f2)
    Reviewed-on: https://gerrit.libreoffice.org/85282
    (cherry picked from commit ad1a41032054991cfb8b9e821c1dd25ec21d0aec)
    
    Change-Id: I79002e0ce85cf9a9017caf858407f2f635a3a074
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/85756
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
    Tested-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>

diff --git a/cui/source/options/optinet2.cxx b/cui/source/options/optinet2.cxx
index bf7f6bd26737..2964531afc84 100644
--- a/cui/source/options/optinet2.cxx
+++ b/cui/source/options/optinet2.cxx
@@ -834,20 +834,6 @@ IMPL_STATIC_LINK_NOARG(SvxSecurityTabPage, MacroSecPBHdl, Button*, void)
 
 void SvxSecurityTabPage::InitControls()
 {
-    // Hide all controls which belong to the macro security button in case the macro
-    // security settings managed by the macro security dialog opened via the button
-    // are all readonly or if the macros are disabled in general.
-    // @@@ Better would be to query the dialog whether it is 'useful' or not. Exposing
-    //     macro security dialog implementations here, which is bad.
-    if (    mpSecOptions->IsMacroDisabled()
-         || (    mpSecOptions->IsReadOnly( SvtSecurityOptions::EOption::MacroSecLevel )
-              && mpSecOptions->IsReadOnly( SvtSecurityOptions::EOption::MacroTrustedAuthors )
-              && mpSecOptions->IsReadOnly( SvtSecurityOptions::EOption::SecureUrls ) ) )
-    {
-        //Hide these
-        m_pMacroSecFrame->Hide();
-    }
-
 #ifndef UNX
     m_pCertFrame->Hide();
 #endif
diff --git a/uui/source/secmacrowarnings.cxx b/uui/source/secmacrowarnings.cxx
index e90b2520d865..8e1b25d2f1d2 100644
--- a/uui/source/secmacrowarnings.cxx
+++ b/uui/source/secmacrowarnings.cxx
@@ -107,7 +107,7 @@ IMPL_LINK_NOARG(MacroWarning, ViewSignsBtnHdl, weld::Button&, void)
 IMPL_LINK_NOARG(MacroWarning, EnableBtnHdl, weld::Button&, void)
 {
     if (mbSignedMode && mxAlwaysTrustCB->get_active())
-    {   // insert path into trusted path list
+    {
         uno::Reference< security::XDocumentDigitalSignatures > xD(
             security::DocumentDigitalSignatures::createWithVersion(comphelper::getProcessComponentContext(), maODFVersion));
         if( mxCert.is() )
@@ -137,7 +137,7 @@ void MacroWarning::InitControls()
     if (mbShowSignatures)
     {
         mxViewSignsBtn->connect_clicked(LINK(this, MacroWarning, ViewSignsBtnHdl));
-        mxViewSignsBtn->set_sensitive(false);   // default
+        mxViewSignsBtn->set_sensitive(false);
         mxAlwaysTrustCB->connect_clicked(LINK(this, MacroWarning, AlwaysTrustCheckHdl));
 
         mnActSecLevel = SvtSecurityOptions().GetMacroSecurityLevel();
diff --git a/xmlsecurity/inc/macrosecurity.hxx b/xmlsecurity/inc/macrosecurity.hxx
index 6a3198284368..2e6dc419488c 100644
--- a/xmlsecurity/inc/macrosecurity.hxx
+++ b/xmlsecurity/inc/macrosecurity.hxx
@@ -130,7 +130,7 @@ private:
     DECL_LINK(    TrustCertLBSelectHdl, SvTreeListBox*, void );
     DECL_LINK(    TrustFileLocLBSelectHdl, ListBox&, void );
 
-    void                FillCertLB();
+    void FillCertLB(const bool bShowWarnings = false);
     void                ImplCheckButtons();
 
 public:
diff --git a/xmlsecurity/source/dialogs/macrosecurity.cxx b/xmlsecurity/source/dialogs/macrosecurity.cxx
index 91f14846d37f..92cdae2976c1 100644
--- a/xmlsecurity/source/dialogs/macrosecurity.cxx
+++ b/xmlsecurity/source/dialogs/macrosecurity.cxx
@@ -27,7 +27,6 @@
 #include <vcl/help.hxx>
 #include <vcl/layout.hxx>
 
-
 #include <com/sun/star/xml/crypto/XSecurityEnvironment.hpp>
 #include <comphelper/sequence.hxx>
 #include <sfx2/filedlghelper.hxx>
@@ -209,20 +208,33 @@ void MacroSecurityTrustedSourcesTP::ImplCheckButtons()
     m_pRemoveLocPB->Enable( bLocationSelected && !mbURLsReadonly);
 }
 
-
 IMPL_LINK_NOARG(MacroSecurityTrustedSourcesTP, ViewCertPBHdl, Button*, void)
 {
     if( m_pTrustCertLB->FirstSelected() )
     {
-        sal_uInt16 nSelected = sal_uInt16( sal_uIntPtr( m_pTrustCertLB->FirstSelected()->GetUserData() ) );
-
-        uno::Reference< css::security::XCertificate > xCert = mpDlg->mxSecurityEnvironment->getCertificate( maTrustedAuthors[nSelected][0], xmlsecurity::numericStringToBigInteger( maTrustedAuthors[nSelected][1] ) );
-
-        // If we don't get it, create it from signature data:
-        if ( !xCert.is() )
-            xCert = mpDlg->mxSecurityEnvironment->createCertificateFromAscii( maTrustedAuthors[nSelected][2] ) ;
+        const sal_uInt16 nSelected = sal_uInt16(sal_uIntPtr(m_pTrustCertLB->FirstSelected()->GetUserData()));
+        uno::Reference< css::security::XCertificate > xCert;
+        try
+        {
+            xCert = mpDlg->mxSecurityEnvironment->getCertificate(maTrustedAuthors[nSelected][0],
+                           xmlsecurity::numericStringToBigInteger(maTrustedAuthors[nSelected][1]));
+        }
+        catch (...)
+        {
+            SAL_WARN("xmlsecurity.dialogs", "matching certificate not found for: " << maTrustedAuthors[nSelected][0]);
+        }
 
-        SAL_WARN_IF( !xCert.is(), "xmlsecurity.dialogs", "*MacroSecurityTrustedSourcesTP::ViewCertPBHdl(): Certificate not found and can't be created!" );
+        if (!xCert.is())
+        {
+            try
+            {
+                xCert = mpDlg->mxSecurityEnvironment->createCertificateFromAscii(maTrustedAuthors[nSelected][2]);
+            }
+            catch (...)
+            {
+                SAL_WARN("xmlsecurity.dialogs", "certificate data couldn't be parsed: " << maTrustedAuthors[nSelected][2]);
+            }
+        }
 
         if ( xCert.is() )
         {
@@ -311,7 +323,7 @@ IMPL_LINK_NOARG(MacroSecurityTrustedSourcesTP, TrustFileLocLBSelectHdl, ListBox&
     ImplCheckButtons();
 }
 
-void MacroSecurityTrustedSourcesTP::FillCertLB()
+void MacroSecurityTrustedSourcesTP::FillCertLB(const bool bShowWarnings)
 {
     m_pTrustCertLB->Clear();
 
@@ -324,13 +336,23 @@ void MacroSecurityTrustedSourcesTP::FillCertLB()
             css::uno::Sequence< OUString >&              rEntry = maTrustedAuthors[ nEntry ];
             uno::Reference< css::security::XCertificate >   xCert;
 
-            // create from RawData
-            xCert = mpDlg->mxSecurityEnvironment->createCertificateFromAscii( rEntry[ 2 ] );
-
-            SvTreeListEntry*    pLBEntry = m_pTrustCertLB->InsertEntry( XmlSec::GetContentPart( xCert->getSubjectName() ) );
-            m_pTrustCertLB->SetEntryText( XmlSec::GetContentPart( xCert->getIssuerName() ), pLBEntry, 1 );
-            m_pTrustCertLB->SetEntryText( XmlSec::GetDateTimeString( xCert->getNotValidAfter() ), pLBEntry, 2 );
-            pLBEntry->SetUserData( reinterpret_cast<void*>(nEntry) );      // misuse user data as index
+            try
+            {
+                // create from RawData
+                xCert = mpDlg->mxSecurityEnvironment->createCertificateFromAscii( rEntry[ 2 ] );
+
+                SvTreeListEntry*    pLBEntry = m_pTrustCertLB->InsertEntry( XmlSec::GetContentPart( xCert->getSubjectName() ) );
+                m_pTrustCertLB->SetEntryText( XmlSec::GetContentPart( xCert->getIssuerName() ), pLBEntry, 1 );
+                m_pTrustCertLB->SetEntryText( XmlSec::GetDateTimeString( xCert->getNotValidAfter() ), pLBEntry, 2 );
+                pLBEntry->SetUserData( reinterpret_cast<void*>(nEntry) );      // misuse user data as index
+            }
+            catch (...)
+            {
+                if (bShowWarnings)
+                {
+                    SAL_WARN("xmlsecurity.dialogs", "certificate data couldn't be parsed: " << rEntry[2]);
+                }
+            }
         }
     }
 }
@@ -388,14 +410,12 @@ MacroSecurityTrustedSourcesTP::MacroSecurityTrustedSourcesTP(vcl::Window* _pPare
     maTrustedAuthors = mpDlg->maSecOptions.GetTrustedAuthors();
     mbAuthorsReadonly = mpDlg->maSecOptions.IsReadOnly( SvtSecurityOptions::EOption::MacroTrustedAuthors );
     m_pTrustCertROFI->Show( mbAuthorsReadonly );
-    mbAuthorsReadonly ? m_pTrustCertLB->DisableTable() : m_pTrustCertLB->EnableTable();
 
-    FillCertLB();
+    FillCertLB(true);
 
     css::uno::Sequence< OUString > aSecureURLs = mpDlg->maSecOptions.GetSecureURLs();
     mbURLsReadonly = mpDlg->maSecOptions.IsReadOnly( SvtSecurityOptions::EOption::SecureUrls );
     m_pTrustFileROFI->Show( mbURLsReadonly );
-    m_pTrustFileLocLB->Enable( !mbURLsReadonly );
     m_pAddLocPB->Enable( !mbURLsReadonly );
 
     sal_Int32 nEntryCnt = aSecureURLs.getLength();
diff --git a/xmlsecurity/uiconfig/ui/securitytrustpage.ui b/xmlsecurity/uiconfig/ui/securitytrustpage.ui
index 5e0a8472f594..0709770f2e33 100644
--- a/xmlsecurity/uiconfig/ui/securitytrustpage.ui
+++ b/xmlsecurity/uiconfig/ui/securitytrustpage.ui
@@ -153,6 +153,8 @@
                     <property name="can_focus">False</property>
                     <property name="no_show_all">True</property>
                     <property name="pixbuf">res/lock.png</property>
+                    <property name="halign">center</property>
+                    <property name="valign">center</property>
                   </object>
                   <packing>
                     <property name="left_attach">0</property>
@@ -296,6 +298,8 @@
                     <property name="can_focus">False</property>
                     <property name="no_show_all">True</property>
                     <property name="pixbuf">res/lock.png</property>
+                    <property name="halign">center</property>
+                    <property name="valign">center</property>
                   </object>
                   <packing>
                     <property name="left_attach">0</property>


More information about the Libreoffice-commits mailing list