[Libreoffice-commits] core.git: xmlsecurity/inc xmlsecurity/source xmlsecurity/uiconfig

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Feb 14 12:06:33 UTC 2019


 xmlsecurity/inc/certificatechooser.hxx                     |   42 --
 xmlsecurity/inc/certificateviewer.hxx                      |    2 
 xmlsecurity/inc/strings.hrc                                |   11 
 xmlsecurity/source/component/documentdigitalsignatures.cxx |   10 
 xmlsecurity/source/dialogs/certificatechooser.cxx          |  190 ++++------
 xmlsecurity/source/dialogs/certificateviewer.cxx           |    2 
 xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx     |    8 
 xmlsecurity/uiconfig/ui/selectcertificatedialog.ui         |  228 +++++--------
 8 files changed, 221 insertions(+), 272 deletions(-)

New commits:
commit 762740f6dbbb3818323dc33f0062cf27ab8fd638
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Wed Feb 13 11:49:34 2019 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Thu Feb 14 13:06:03 2019 +0100

    weld CertificateChooser
    
    Change-Id: I46087a58d5cff7ea8ac86ef8ee670cc4a59d0120
    Reviewed-on: https://gerrit.libreoffice.org/67795
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/xmlsecurity/inc/certificatechooser.hxx b/xmlsecurity/inc/certificatechooser.hxx
index d01b95edda24..b98b30fdc6b3 100644
--- a/xmlsecurity/inc/certificatechooser.hxx
+++ b/xmlsecurity/inc/certificatechooser.hxx
@@ -20,16 +20,12 @@
 #ifndef INCLUDED_XMLSECURITY_INC_CERTIFICATECHOOSER_HXX
 #define INCLUDED_XMLSECURITY_INC_CERTIFICATECHOOSER_HXX
 
-#include <svtools/simptabl.hxx>
-#include <vcl/dialog.hxx>
-#include <vcl/fixed.hxx>
-#include <vcl/button.hxx>
 #include <com/sun/star/xml/crypto/XSecurityEnvironment.hpp>
 #include <com/sun/star/xml/crypto/XXMLSecurityContext.hpp>
 #include <com/sun/star/uno/XComponentContext.hpp>
 #include <com/sun/star/uno/Sequence.hxx>
 #include <svl/sigstruct.hxx>
-
+#include <vcl/weld.hxx>
 
 namespace com {
 namespace sun {
@@ -40,8 +36,6 @@ namespace xml { namespace crypto {
     class XSecurityEnvironment; }}
 }}}
 
-class HeaderBar;
-
 struct UserData
 {
     css::uno::Reference<css::security::XCertificate> xCertificate;
@@ -56,45 +50,43 @@ enum class UserAction
     Encrypt
 };
 
-class CertificateChooser : public ModalDialog
+class CertificateChooser : public weld::GenericDialogController
 {
 private:
     css::uno::Reference< css::uno::XComponentContext > mxCtx;
     std::vector< css::uno::Reference< css::xml::crypto::XXMLSecurityContext > > mxSecurityContexts;
     std::vector<std::shared_ptr<UserData>> mvUserData;
 
-    VclPtr<FixedText>      m_pFTSign;
-    VclPtr<FixedText>      m_pFTEncrypt;
-
-    VclPtr<SvSimpleTable>   m_pCertLB;
-    VclPtr<PushButton>      m_pViewBtn;
-    VclPtr<OKButton>        m_pOKBtn;
-    VclPtr<FixedText>       m_pFTDescription;
-    VclPtr<Edit>            m_pDescriptionED;
-
     bool                    mbInitialized;
     UserAction const        meAction;
     OUString                msPreferredKey;
     css::uno::Reference<css::security::XCertificate> mxEncryptToSelf;
 
-    DECL_LINK(ViewButtonHdl, Button*, void);
-    DECL_LINK(CertificateHighlightHdl, SvTreeListBox*, void );
-    DECL_LINK(CertificateSelectHdl, SvTreeListBox*, bool );
+    std::unique_ptr<weld::Label>    m_xFTSign;
+    std::unique_ptr<weld::Label>    m_xFTEncrypt;
+    std::unique_ptr<weld::TreeView> m_xCertLB;
+    std::unique_ptr<weld::Button>   m_xViewBtn;
+    std::unique_ptr<weld::Button>   m_xOKBtn;
+    std::unique_ptr<weld::Label>    m_xFTDescription;
+    std::unique_ptr<weld::Entry>    m_xDescriptionED;
+
+    DECL_LINK(ViewButtonHdl, weld::Button&, void);
+    DECL_LINK(CertificateHighlightHdl, weld::TreeView&, void);
+    DECL_LINK(CertificateSelectHdl, weld::TreeView&, void);
 
     void ImplShowCertificateDetails();
     void ImplInitialize();
 
-    void HandleOneUsageBit(OUString& string, int& bits, int bit, const char *name);
+    static void HandleOneUsageBit(OUString& string, int& bits, int bit, const char *name);
 
 public:
-    CertificateChooser(vcl::Window* pParent,
+    CertificateChooser(weld::Window* pParent,
                        css::uno::Reference< css::uno::XComponentContext> const & rxCtx,
                        std::vector< css::uno::Reference< css::xml::crypto::XXMLSecurityContext > > const & rxSecurityContexts,
                        UserAction eAction);
     virtual ~CertificateChooser() override;
-    virtual void dispose() override;
 
-    short Execute() override;
+    short run() override;
 
     css::uno::Sequence<css::uno::Reference< css::security::XCertificate > > GetSelectedCertificates();
     css::uno::Reference< css::xml::crypto::XXMLSecurityContext > GetSelectedSecurityContext();
@@ -104,7 +96,7 @@ public:
     /// Returns the usage string of the selected certificate, if any.
     OUString GetUsageText();
 
-    OUString UsageInClearText(int bits);
+    static OUString UsageInClearText(int bits);
 };
 
 #endif // INCLUDED_XMLSECURITY_INC_CERTIFICATECHOOSER_HXX
diff --git a/xmlsecurity/inc/certificateviewer.hxx b/xmlsecurity/inc/certificateviewer.hxx
index 9f816c9a0671..a117ad39cbb8 100644
--- a/xmlsecurity/inc/certificateviewer.hxx
+++ b/xmlsecurity/inc/certificateviewer.hxx
@@ -53,7 +53,7 @@ private:
     css::uno::Reference< css::xml::crypto::XSecurityEnvironment > mxSecurityEnvironment;
     css::uno::Reference< css::security::XCertificate > mxCert;
 
-    VclPtr<CertificateChooser> mpParentChooser;
+    CertificateChooser* mpParentChooser;
 
     std::unique_ptr<weld::Notebook> mxTabCtrl;
 
diff --git a/xmlsecurity/inc/strings.hrc b/xmlsecurity/inc/strings.hrc
index c44617e10fed..deed17e9e1a2 100644
--- a/xmlsecurity/inc/strings.hrc
+++ b/xmlsecurity/inc/strings.hrc
@@ -51,6 +51,17 @@
 
 #define RID_XMLSECWB_NO_MOZILLA_PROFILE             NC_("RID_XMLSECWB_NO_MOZILLA_PROFILE", "Digital signatures functionality could not be used, because no Mozilla user profile was found. Please check the Mozilla installation.")
 
+#define STR_DIGITAL_SIGNATURE                       NC_("selectcertificatedialog|STR_DIGITAL_SIGNATURE", "Digital signature")
+#define STR_NON_REPUDIATION                         NC_("selectcertificatedialog|STR_NON_REPUDIATION", "Non-repudiation")
+#define STR_KEY_ENCIPHERMENT                        NC_("selectcertificatedialog|STR_KEY_ENCIPHERMENT", "Key encipherment")
+#define STR_DATA_ENCIPHERMENT                       NC_("selectcertificatedialog|STR_DATA_ENCIPHERMENT", "Data encipherment")
+#define STR_KEY_AGREEMENT                           NC_("selectcertificatedialog|STR_KEY_AGREEMENT", "Key Agreement")
+#define STR_KEY_CERT_SIGN                           NC_("selectcertificatedialog|STR_KEY_CERT_SIGN", "Certificate signature verification")
+#define STR_CRL_SIGN                                NC_("selectcertificatedialog|STR_CRL_SIGN", "CRL signature verification")
+#define STR_ENCIPHER_ONLY                           NC_("selectcertificatedialog|STR_ENCIPHER_ONLY", "Only for encipherment")
+#define STR_SIGN                                    NC_("selectcertificatedialog|str_sign", "Sign")
+#define STR_SELECTSIGN                              NC_("selectcertificatedialog|str_selectsign", "Select")
+#define STR_ENCRYPT                                 NC_("selectcertificatedialog|str_encrypt", "Encrypt")
 
 #endif
 
diff --git a/xmlsecurity/source/component/documentdigitalsignatures.cxx b/xmlsecurity/source/component/documentdigitalsignatures.cxx
index 0f6d9e909035..2eeb6d9d13d8 100644
--- a/xmlsecurity/source/component/documentdigitalsignatures.cxx
+++ b/xmlsecurity/source/component/documentdigitalsignatures.cxx
@@ -649,17 +649,17 @@ DocumentDigitalSignatures::chooseCertificatesImpl(std::map<OUString, OUString>&
             xSecContexts.push_back(aSignatureManager.getGpgSecurityContext());
     }
 
-    ScopedVclPtrInstance< CertificateChooser > aChooser(nullptr, mxCtx, xSecContexts, eAction);
+    CertificateChooser aChooser(Application::GetFrameWeld(mxParentWindow), mxCtx, xSecContexts, eAction);
 
     uno::Sequence< Reference< css::security::XCertificate > > xCerts(1);
     xCerts[0] = Reference< css::security::XCertificate >(nullptr);
 
-    if (aChooser->Execute() != RET_OK)
+    if (aChooser.run() != RET_OK)
         return xCerts;
 
-    xCerts = aChooser->GetSelectedCertificates();
-    rProperties["Description"] = aChooser->GetDescription();
-    rProperties["Usage"] = aChooser->GetUsageText();
+    xCerts = aChooser.GetSelectedCertificates();
+    rProperties["Description"] = aChooser.GetDescription();
+    rProperties["Usage"] = aChooser.GetUsageText();
 
     return xCerts;
 }
diff --git a/xmlsecurity/source/dialogs/certificatechooser.cxx b/xmlsecurity/source/dialogs/certificatechooser.cxx
index 61ce81f135db..67bc31cf3dd0 100644
--- a/xmlsecurity/source/dialogs/certificatechooser.cxx
+++ b/xmlsecurity/source/dialogs/certificatechooser.cxx
@@ -32,68 +32,53 @@
 #include <unotools/datetime.hxx>
 #include <unotools/useroptions.hxx>
 
+#include <resourcemanager.hxx>
+#include <strings.hrc>
+
 using namespace comphelper;
 using namespace css;
 
-CertificateChooser::CertificateChooser(vcl::Window* _pParent,
+CertificateChooser::CertificateChooser(weld::Window* _pParent,
                                        uno::Reference<uno::XComponentContext> const & _rxCtx,
                                        std::vector< css::uno::Reference< css::xml::crypto::XXMLSecurityContext > > const & rxSecurityContexts,
                                        UserAction eAction)
-    : ModalDialog(_pParent, "SelectCertificateDialog", "xmlsec/ui/selectcertificatedialog.ui"),
-    mvUserData(),
-    meAction( eAction )
+    : GenericDialogController(_pParent, "xmlsec/ui/selectcertificatedialog.ui", "SelectCertificateDialog")
+    , mvUserData()
+    , meAction(eAction)
+    , m_xFTSign(m_xBuilder->weld_label("sign"))
+    , m_xFTEncrypt(m_xBuilder->weld_label("encrypt"))
+    , m_xCertLB(m_xBuilder->weld_tree_view("signatures"))
+    , m_xViewBtn(m_xBuilder->weld_button("viewcert"))
+    , m_xOKBtn(m_xBuilder->weld_button("ok"))
+    , m_xFTDescription(m_xBuilder->weld_label("description-label"))
+    , m_xDescriptionED(m_xBuilder->weld_entry("description"))
 {
-    get(m_pFTSign, "sign");
-    get(m_pFTEncrypt, "encrypt");
-    get(m_pOKBtn, "ok");
-    get(m_pViewBtn, "viewcert");
-    get(m_pFTDescription, "description-label");
-    get(m_pDescriptionED, "description");
-
-    Size aControlSize(475, 122);
-    const long nControlWidth = aControlSize.Width();
-    aControlSize = LogicToPixel(aControlSize, MapMode(MapUnit::MapAppFont));
-    SvSimpleTableContainer *pSignatures = get<SvSimpleTableContainer>("signatures");
-    pSignatures->set_width_request(aControlSize.Width());
-    pSignatures->set_height_request(aControlSize.Height());
-
-    m_pCertLB = VclPtr<SvSimpleTable>::Create(*pSignatures);
-    static long nTabs[] = { 0, 20*nControlWidth/100, 50*nControlWidth/100, 60*nControlWidth/100, 70*nControlWidth/100  };
-    m_pCertLB->SetTabs( SAL_N_ELEMENTS(nTabs), nTabs );
-    m_pCertLB->InsertHeaderEntry(get<FixedText>("issuedto")->GetText() + "\t" + get<FixedText>("issuedby")->GetText()
-        + "\t" + get<FixedText>("type")->GetText() + "\t" + get<FixedText>("expiration")->GetText()
-        + "\t" + get<FixedText>("usage")->GetText());
-    m_pCertLB->SetSelectHdl( LINK( this, CertificateChooser, CertificateHighlightHdl ) );
-    m_pCertLB->SetDoubleClickHdl( LINK( this, CertificateChooser, CertificateSelectHdl ) );
-    m_pViewBtn->SetClickHdl( LINK( this, CertificateChooser, ViewButtonHdl ) );
+    auto nControlWidth = m_xCertLB->get_approximate_digit_width() * 105;
+    m_xCertLB->set_size_request(nControlWidth, m_xCertLB->get_height_rows(12));
+
+    std::vector<int> aWidths;
+    aWidths.push_back(30*nControlWidth/100);
+    aWidths.push_back(30*nControlWidth/100);
+    aWidths.push_back(10*nControlWidth/100);
+    aWidths.push_back(20*nControlWidth/100);
+    m_xCertLB->set_column_fixed_widths(aWidths);
+    m_xCertLB->connect_changed( LINK( this, CertificateChooser, CertificateHighlightHdl ) );
+    m_xCertLB->connect_row_activated( LINK( this, CertificateChooser, CertificateSelectHdl ) );
+    m_xViewBtn->connect_clicked( LINK( this, CertificateChooser, ViewButtonHdl ) );
 
     mxCtx = _rxCtx;
     mxSecurityContexts = rxSecurityContexts;
     mbInitialized = false;
 
     // disable buttons
-    CertificateHighlightHdl( nullptr );
+    CertificateHighlightHdl(*m_xCertLB);
 }
 
 CertificateChooser::~CertificateChooser()
 {
-    disposeOnce();
 }
 
-void CertificateChooser::dispose()
-{
-    m_pFTSign.clear();
-    m_pFTEncrypt.clear();
-    m_pCertLB.disposeAndClear();
-    m_pViewBtn.clear();
-    m_pOKBtn.clear();
-    m_pFTDescription.clear();
-    m_pDescriptionED.clear();
-    mvUserData.clear();
-    ModalDialog::dispose();
-}
-
-short CertificateChooser::Execute()
+short CertificateChooser::run()
 {
     // #i48432#
     // We can't check for personal certificates before raising this dialog,
@@ -108,25 +93,18 @@ short CertificateChooser::Execute()
     // Problem: This Dialog should be visible right now, and the parent should not be accessible.
     // Show, Update, DisableInput...
 
-    vcl::Window* pMe = this;
-    vcl::Window* pParent = GetParent();
-    if ( pParent )
-        pParent->EnableInput( false );
-    pMe->Show();
-    pMe->Update();
+    m_xDialog->show();
     ImplInitialize();
-    if ( pParent )
-        pParent->EnableInput();
-    return ModalDialog::Execute();
+    return GenericDialogController::run();
 }
 
-void CertificateChooser::HandleOneUsageBit(OUString& string, int& bits, int bit, const char *name)
+void CertificateChooser::HandleOneUsageBit(OUString& string, int& bits, int bit, const char *pResId)
 {
     if (bits & bit)
     {
         if (!string.isEmpty())
             string += ", ";
-        string += get<FixedText>(OString("STR_") + name)->GetText();
+        string += XsResId(pResId);
         bits &= ~bit;
     }
 }
@@ -135,14 +113,14 @@ OUString CertificateChooser::UsageInClearText(int bits)
 {
     OUString result;
 
-    HandleOneUsageBit(result, bits, 0x80, "DIGITAL_SIGNATURE");
-    HandleOneUsageBit(result, bits, 0x40, "NON_REPUDIATION");
-    HandleOneUsageBit(result, bits, 0x20, "KEY_ENCIPHERMENT");
-    HandleOneUsageBit(result, bits, 0x10, "DATA_ENCIPHERMENT");
-    HandleOneUsageBit(result, bits, 0x08, "KEY_AGREEMENT");
-    HandleOneUsageBit(result, bits, 0x04, "KEY_CERT_SIGN");
-    HandleOneUsageBit(result, bits, 0x02, "CRL_SIGN");
-    HandleOneUsageBit(result, bits, 0x01, "ENCIPHER_ONLY");
+    HandleOneUsageBit(result, bits, 0x80, STR_DIGITAL_SIGNATURE);
+    HandleOneUsageBit(result, bits, 0x40, STR_NON_REPUDIATION);
+    HandleOneUsageBit(result, bits, 0x20, STR_KEY_ENCIPHERMENT);
+    HandleOneUsageBit(result, bits, 0x10, STR_DATA_ENCIPHERMENT);
+    HandleOneUsageBit(result, bits, 0x08, STR_KEY_AGREEMENT);
+    HandleOneUsageBit(result, bits, 0x04, STR_KEY_CERT_SIGN);
+    HandleOneUsageBit(result, bits, 0x02, STR_CRL_SIGN);
+    HandleOneUsageBit(result, bits, 0x01, STR_ENCIPHER_ONLY);
 
     // Check for mystery leftover bits
     if (bits != 0)
@@ -165,23 +143,23 @@ void CertificateChooser::ImplInitialize()
     switch (meAction)
     {
         case UserAction::Sign:
-            m_pFTSign->Show();
-            m_pOKBtn->SetText( get<FixedText>("str_sign")->GetText() );
+            m_xFTSign->show();
+            m_xOKBtn->set_label(XsResId(STR_SIGN));
             msPreferredKey = aUserOpts.GetSigningKey();
             break;
 
         case UserAction::SelectSign:
-            m_pFTSign->Show();
-            m_pOKBtn->SetText( get<FixedText>("str_selectsign")->GetText() );
+            m_xFTSign->show();
+            m_xOKBtn->set_label(XsResId(STR_SELECTSIGN));
             msPreferredKey = aUserOpts.GetSigningKey();
             break;
 
         case UserAction::Encrypt:
-            m_pFTEncrypt->Show();
-            m_pFTDescription->Hide();
-            m_pDescriptionED->Hide();
-            m_pCertLB->SetSelectionMode( SelectionMode::Multiple );
-            m_pOKBtn->SetText( get<FixedText>("str_encrypt")->GetText() );
+            m_xFTEncrypt->show();
+            m_xFTDescription->hide();
+            m_xDescriptionED->hide();
+            m_xCertLB->set_selection_mode(SelectionMode::Multiple);
+            m_xOKBtn->set_label(XsResId(STR_ENCRYPT));
             msPreferredKey = aUserOpts.GetEncryptionKey();
             break;
 
@@ -232,19 +210,24 @@ void CertificateChooser::ImplInitialize()
             mvUserData.push_back(userData);
 
             OUString sIssuer = xmlsec::GetContentPart( xCerts[ nC ]->getIssuerName() );
-            SvTreeListEntry* pEntry = m_pCertLB->InsertEntry( xmlsec::GetContentPart( xCerts[ nC ]->getSubjectName() )
-                + "\t" + sIssuer
-                + "\t" + xmlsec::GetCertificateKind( xCerts[ nC ]->getCertificateKind() )
-                + "\t" + utl::GetDateString( xCerts[ nC ]->getNotValidAfter() )
-                + "\t" + UsageInClearText( xCerts[ nC ]->getCertificateUsage() ) );
-            pEntry->SetUserData( userData.get() );
+
+            m_xCertLB->insert(nullptr, -1, nullptr, nullptr,
+                              nullptr, nullptr, nullptr, false);
+            int nRow = m_xCertLB->n_children() - 1;
+            m_xCertLB->set_text(nRow, xmlsec::GetContentPart(xCerts[nC]->getSubjectName()), 0);
+            m_xCertLB->set_text(nRow, sIssuer, 1);
+            m_xCertLB->set_text(nRow, xmlsec::GetCertificateKind(xCerts[nC]->getCertificateKind()), 2);
+            m_xCertLB->set_text(nRow, utl::GetDateString(xCerts[nC]->getNotValidAfter()), 3);
+            m_xCertLB->set_text(nRow, UsageInClearText(xCerts[nC]->getCertificateUsage()), 4);
+            OUString sId(OUString::number(reinterpret_cast<sal_Int64>(userData.get())));
+            m_xCertLB->set_id(nRow, sId);
 
 #if HAVE_FEATURE_GPGME
             // only GPG has preferred keys
             if ( sIssuer == msPreferredKey )
             {
                 if ( meAction == UserAction::Sign || meAction == UserAction::SelectSign )
-                    m_pCertLB->Select( pEntry );
+                    m_xCertLB->select(nRow);
                 else if ( meAction == UserAction::Encrypt &&
                           aUserOpts.GetEncryptToSelf() )
                     mxEncryptToSelf = xCerts[nC];
@@ -254,32 +237,28 @@ void CertificateChooser::ImplInitialize()
     }
 
     // enable/disable buttons
-    CertificateHighlightHdl( nullptr );
+    CertificateHighlightHdl(*m_xCertLB);
     mbInitialized = true;
 }
 
-
 uno::Sequence<uno::Reference< css::security::XCertificate > > CertificateChooser::GetSelectedCertificates()
 {
     std::vector< uno::Reference< css::security::XCertificate > > aRet;
-    SvTreeListEntry* pSel = m_pCertLB->FirstSelected();
-
     if (meAction == UserAction::Encrypt)
     {
         // for encryption, multiselection is enabled
-        while(pSel)
-        {
-            UserData* userData = static_cast<UserData*>(pSel->GetUserData());
+        m_xCertLB->selected_foreach([this, &aRet](weld::TreeIter& rEntry){
+            UserData* userData = reinterpret_cast<UserData*>(m_xCertLB->get_id(rEntry).toInt64());
             aRet.push_back( userData->xCertificate );
-            pSel = m_pCertLB->NextSelected(pSel);
-        }
+        });
     }
     else
     {
         uno::Reference< css::security::XCertificate > xCert;
-        if( pSel )
+        int nSel = m_xCertLB->get_selected_index();
+        if (nSel != -1)
         {
-            UserData* userData = static_cast<UserData*>(pSel->GetUserData());
+            UserData* userData = reinterpret_cast<UserData*>(m_xCertLB->get_id(nSel).toInt64());
             xCert = userData->xCertificate;
         }
         aRet.push_back( xCert );
@@ -295,18 +274,18 @@ uno::Sequence<uno::Reference< css::security::XCertificate > > CertificateChooser
 
 uno::Reference<xml::crypto::XXMLSecurityContext> CertificateChooser::GetSelectedSecurityContext()
 {
-    SvTreeListEntry* pSel = m_pCertLB->FirstSelected();
-    if( !pSel )
+    int nSel = m_xCertLB->get_selected_index();
+    if (nSel == -1)
         return uno::Reference<xml::crypto::XXMLSecurityContext>();
 
-    UserData* userData = static_cast<UserData*>(pSel->GetUserData());
+    UserData* userData = reinterpret_cast<UserData*>(m_xCertLB->get_id(nSel).toInt64());
     uno::Reference<xml::crypto::XXMLSecurityContext> xCert = userData->xSecurityContext;
     return xCert;
 }
 
 OUString CertificateChooser::GetDescription()
 {
-    return m_pDescriptionED->GetText();
+    return m_xDescriptionED->get_text();
 }
 
 OUString CertificateChooser::GetUsageText()
@@ -317,37 +296,36 @@ OUString CertificateChooser::GetUsageText()
         UsageInClearText(xCerts[0]->getCertificateUsage()) : OUString();
 }
 
-IMPL_LINK_NOARG(CertificateChooser, CertificateHighlightHdl, SvTreeListBox*, void)
+IMPL_LINK_NOARG(CertificateChooser, CertificateHighlightHdl, weld::TreeView&, void)
 {
-    bool bEnable = m_pCertLB->GetSelectionCount() > 0;
-    m_pViewBtn->Enable( bEnable );
-    m_pOKBtn->Enable( bEnable );
-    m_pDescriptionED->Enable(bEnable);
+    bool bEnable = m_xCertLB->get_selected_index() != -1;
+    m_xViewBtn->set_sensitive(bEnable);
+    m_xOKBtn->set_sensitive(bEnable);
+    m_xDescriptionED->set_sensitive(bEnable);
 }
 
-IMPL_LINK_NOARG(CertificateChooser, CertificateSelectHdl, SvTreeListBox*, bool)
+IMPL_LINK_NOARG(CertificateChooser, CertificateSelectHdl, weld::TreeView&, void)
 {
-    EndDialog( RET_OK );
-    return false;
+    m_xDialog->response(RET_OK);
 }
 
-IMPL_LINK_NOARG(CertificateChooser, ViewButtonHdl, Button*, void)
+IMPL_LINK_NOARG(CertificateChooser, ViewButtonHdl, weld::Button&, void)
 {
     ImplShowCertificateDetails();
 }
 
 void CertificateChooser::ImplShowCertificateDetails()
 {
-    SvTreeListEntry* pSel = m_pCertLB->FirstSelected();
-    if( !pSel )
+    int nSel = m_xCertLB->get_selected_index();
+    if (nSel == -1)
         return;
 
-    UserData* userData = static_cast<UserData*>(pSel->GetUserData());
+    UserData* userData = reinterpret_cast<UserData*>(m_xCertLB->get_id(nSel).toInt64());
 
     if (!userData->xSecurityEnvironment.is() || !userData->xCertificate.is())
         return;
 
-    CertificateViewer aViewer(GetFrameWeld(), userData->xSecurityEnvironment, userData->xCertificate, true, this);
+    CertificateViewer aViewer(m_xDialog.get(), userData->xSecurityEnvironment, userData->xCertificate, true, this);
     aViewer.run();
 }
 
diff --git a/xmlsecurity/source/dialogs/certificateviewer.cxx b/xmlsecurity/source/dialogs/certificateviewer.cxx
index 501f59296b47..7bc6b03ff28d 100644
--- a/xmlsecurity/source/dialogs/certificateviewer.cxx
+++ b/xmlsecurity/source/dialogs/certificateviewer.cxx
@@ -224,7 +224,7 @@ CertificateViewerDetailsTP::CertificateViewerDetailsTP(weld::Container* pParent,
     CertificateChooser* pChooser = mpDlg->GetParentChooser();
     if (pChooser)
     {
-        aLBEntry = pChooser->UsageInClearText( mpDlg->mxCert->getCertificateUsage() );
+        aLBEntry = CertificateChooser::UsageInClearText( mpDlg->mxCert->getCertificateUsage() );
         InsertElement( XsResId( STR_USE ), aLBEntry, aLBEntry );
     }
 
diff --git a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx
index 762bcc58c878..dd93f64b55d9 100644
--- a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx
+++ b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx
@@ -404,12 +404,12 @@ IMPL_LINK_NOARG(DigitalSignaturesDialog, AddButtonHdl, Button*, void)
         if (DocumentSignatureHelper::CanSignWithGPG(maSignatureManager.mxStore, m_sODFVersion))
             xSecContexts.push_back(maSignatureManager.getGpgSecurityContext());
 
-        ScopedVclPtrInstance< CertificateChooser > aChooser( this, mxCtx, xSecContexts, UserAction::Sign );
-        if ( aChooser->Execute() == RET_OK )
+        CertificateChooser aChooser(GetFrameWeld(), mxCtx, xSecContexts, UserAction::Sign);
+        if (aChooser.run() == RET_OK)
         {
             sal_Int32 nSecurityId;
-            if (!maSignatureManager.add(aChooser->GetSelectedCertificates()[0], aChooser->GetSelectedSecurityContext(),
-                                        aChooser->GetDescription(), nSecurityId, m_bAdESCompliant))
+            if (!maSignatureManager.add(aChooser.GetSelectedCertificates()[0], aChooser.GetSelectedSecurityContext(),
+                                        aChooser.GetDescription(), nSecurityId, m_bAdESCompliant))
                 return;
             mbSignaturesChanged = true;
 
diff --git a/xmlsecurity/uiconfig/ui/selectcertificatedialog.ui b/xmlsecurity/uiconfig/ui/selectcertificatedialog.ui
index 6bbc37546af4..f44d0e58f4da 100644
--- a/xmlsecurity/uiconfig/ui/selectcertificatedialog.ui
+++ b/xmlsecurity/uiconfig/ui/selectcertificatedialog.ui
@@ -2,12 +2,28 @@
 <!-- Generated with glade 3.18.3 -->
 <interface domain="xsc">
   <requires lib="gtk+" version="3.18"/>
-  <requires lib="LibreOffice" version="1.0"/>
+  <object class="GtkTreeStore" id="liststore3">
+    <columns>
+      <!-- column-name text -->
+      <column type="gchararray"/>
+      <!-- column-name text2 -->
+      <column type="gchararray"/>
+      <!-- column-name text3 -->
+      <column type="gchararray"/>
+      <!-- column-name text4 -->
+      <column type="gchararray"/>
+      <!-- column-name text5 -->
+      <column type="gchararray"/>
+      <!-- column-name id -->
+      <column type="gchararray"/>
+    </columns>
+  </object>
   <object class="GtkDialog" id="SelectCertificateDialog">
     <property name="can_focus">False</property>
     <property name="border_width">6</property>
     <property name="title" translatable="yes" context="selectcertificatedialog|SelectCertificateDialog">Select Certificate</property>
     <property name="resizable">False</property>
+    <property name="modal">True</property>
     <property name="type_hint">dialog</property>
     <child internal-child="vbox">
       <object class="GtkBox" id="dialog-vbox1">
@@ -80,132 +96,6 @@
             <property name="row_spacing">12</property>
             <property name="column_spacing">12</property>
             <child>
-              <object class="GtkGrid" id="grid2">
-                <property name="can_focus">False</property>
-                <property name="no_show_all">True</property>
-                <property name="hexpand">True</property>
-                <property name="column_spacing">12</property>
-                <child>
-                  <object class="GtkLabel" id="issuedto">
-                    <property name="can_focus">False</property>
-                    <property name="hexpand">True</property>
-                    <property name="label" translatable="yes" context="selectcertificatedialog|issuedto">Issued to</property>
-                  </object>
-                  <packing>
-                    <property name="left_attach">0</property>
-                    <property name="top_attach">0</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkLabel" id="issuedby">
-                    <property name="can_focus">False</property>
-                    <property name="hexpand">True</property>
-                    <property name="label" translatable="yes" context="selectcertificatedialog|issuedby">Issued by</property>
-                  </object>
-                  <packing>
-                    <property name="left_attach">1</property>
-                    <property name="top_attach">0</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkLabel" id="usage">
-                    <property name="can_focus">False</property>
-                    <property name="hexpand">True</property>
-                    <property name="label" translatable="yes" context="selectcertificatedialog|usage">Certificate usage</property>
-                  </object>
-                  <packing>
-                    <property name="left_attach">2</property>
-                    <property name="top_attach">0</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkLabel" id="expiration">
-                    <property name="can_focus">False</property>
-                    <property name="hexpand">True</property>
-                    <property name="label" translatable="yes" context="selectcertificatedialog|expiration">Expiration date</property>
-                  </object>
-                  <packing>
-                    <property name="left_attach">3</property>
-                    <property name="top_attach">0</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkLabel" id="type">
-                    <property name="can_focus">False</property>
-                    <property name="hexpand">True</property>
-                    <property name="label" translatable="yes" context="selectcertificatedialog|type">Type</property>
-                  </object>
-                  <packing>
-                    <property name="left_attach">4</property>
-                    <property name="top_attach">0</property>
-                  </packing>
-                </child>
-                <!-- Just for localisation -->
-                <child>
-                  <object class="GtkLabel" id="STR_DIGITAL_SIGNATURE">
-                    <property name="can_focus">False</property>
-                    <property name="hexpand">True</property>
-                    <property name="label" translatable="yes" context="selectcertificatedialog|STR_DIGITAL_SIGNATURE">Digital signature</property>
-                  </object>
-                  <object class="GtkLabel" id="STR_NON_REPUDIATION">
-                    <property name="can_focus">False</property>
-                    <property name="hexpand">True</property>
-                    <property name="label" translatable="yes" context="selectcertificatedialog|STR_NON_REPUDIATION">Non-repudiation</property>
-                  </object>
-                  <object class="GtkLabel" id="STR_KEY_ENCIPHERMENT">
-                    <property name="can_focus">False</property>
-                    <property name="hexpand">True</property>
-                    <property name="label" translatable="yes" context="selectcertificatedialog|STR_KEY_ENCIPHERMENT">Key encipherment</property>
-                  </object>
-                  <object class="GtkLabel" id="STR_DATA_ENCIPHERMENT">
-                    <property name="can_focus">False</property>
-                    <property name="hexpand">True</property>
-                    <property name="label" translatable="yes" context="selectcertificatedialog|STR_DATA_ENCIPHERMENT">Data encipherment</property>
-                  </object>
-                  <object class="GtkLabel" id="STR_KEY_AGREEMENT">
-                    <property name="can_focus">False</property>
-                    <property name="hexpand">True</property>
-                    <property name="label" translatable="yes" context="selectcertificatedialog|STR_KEY_AGREEMENT">Key Agreement</property>
-                  </object>
-                  <object class="GtkLabel" id="STR_KEY_CERT_SIGN">
-                    <property name="can_focus">False</property>
-                    <property name="hexpand">True</property>
-                    <property name="label" translatable="yes" context="selectcertificatedialog|STR_KEY_CERT_SIGN">Certificate signature verification</property>
-                  </object>
-                  <object class="GtkLabel" id="STR_CRL_SIGN">
-                    <property name="can_focus">False</property>
-                    <property name="hexpand">True</property>
-                    <property name="label" translatable="yes" context="selectcertificatedialog|STR_CRL_SIGN">CRL signature verification</property>
-                  </object>
-                  <object class="GtkLabel" id="STR_ENCIPHER_ONLY">
-                    <property name="can_focus">False</property>
-                    <property name="hexpand">True</property>
-                    <property name="label" translatable="yes" context="selectcertificatedialog|STR_ENCIPHER_ONLY">Only for encipherment</property>
-                  </object>
-                  <!-- different prefix, STR_ is (mis)used in the code to map certificate usage flags to strings -->
-                  <object class="GtkLabel" id="str_sign">
-                    <property name="can_focus">False</property>
-                    <property name="hexpand">True</property>
-                    <property name="label" translatable="yes" context="selectcertificatedialog|str_sign">Sign</property>
-                  </object>
-                  <object class="GtkLabel" id="str_selectsign">
-                    <property name="can_focus">False</property>
-                    <property name="hexpand">True</property>
-                    <property name="label" translatable="yes" context="selectcertificatedialog|str_selectsign">Select</property>
-                  </object>
-                  <object class="GtkLabel" id="str_encrypt">
-                    <property name="can_focus">False</property>
-                    <property name="hexpand">True</property>
-                    <property name="label" translatable="yes" context="selectcertificatedialog|str_encrypt">Encrypt</property>
-                  </object>
-                </child>
-              </object>
-              <packing>
-                <property name="left_attach">0</property>
-                <property name="top_attach">1</property>
-              </packing>
-            </child>
-            <child>
               <object class="GtkLabel" id="sign">
                 <property name="visible">False</property>
                 <property name="can_focus">False</property>
@@ -232,13 +122,91 @@
               </packing>
             </child>
             <child>
-              <object class="svtlo-SvSimpleTableContainer" id="signatures">
+              <object class="GtkScrolledWindow">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="hexpand">True</property>
                 <property name="vexpand">True</property>
-                <child internal-child="selection">
-                  <object class="GtkTreeSelection" id="Simple Table Container-selection1"/>
+                <property name="shadow_type">in</property>
+                <child>
+                  <object class="GtkTreeView" id="signatures">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">True</property>
+                    <property name="hexpand">True</property>
+                    <property name="vexpand">True</property>
+                    <property name="model">liststore3</property>
+                    <property name="search_column">0</property>
+                    <property name="show_expanders">False</property>
+                    <child internal-child="selection">
+                      <object class="GtkTreeSelection" id="Macro Library List-selection2"/>
+                    </child>
+                    <child>
+                      <object class="GtkTreeViewColumn" id="treeviewcolumn3">
+                        <property name="resizable">True</property>
+                        <property name="spacing">6</property>
+                        <property name="title" translatable="yes" context="selectcertificatedialog|issuedto">Issued to</property>
+                        <child>
+                          <object class="GtkCellRendererText" id="cellrenderer1"/>
+                          <attributes>
+                            <attribute name="text">0</attribute>
+                          </attributes>
+                        </child>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkTreeViewColumn" id="treeviewcolumn4">
+                        <property name="resizable">True</property>
+                        <property name="spacing">6</property>
+                        <property name="title" translatable="yes" context="selectcertificatedialog|issuedby">Issued by</property>
+                        <child>
+                          <object class="GtkCellRendererText" id="cellrenderer2"/>
+                          <attributes>
+                            <attribute name="text">1</attribute>
+                          </attributes>
+                        </child>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkTreeViewColumn" id="treeviewcolumn5">
+                        <property name="resizable">True</property>
+                        <property name="spacing">6</property>
+                        <property name="title" translatable="yes" context="selectcertificatedialog|type">Type</property>
+                        <child>
+                          <object class="GtkCellRendererText" id="cellrenderer3"/>
+                          <attributes>
+                            <attribute name="text">2</attribute>
+                          </attributes>
+                        </child>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkTreeViewColumn" id="treeviewcolumn6">
+                        <property name="resizable">True</property>
+                        <property name="spacing">6</property>
+                        <property name="title" translatable="yes" context="selectcertificatedialog|expiration">Expiration date</property>
+                        <child>
+                          <object class="GtkCellRendererText" id="cellrenderer4"/>
+                          <attributes>
+                            <attribute name="text">3</attribute>
+                          </attributes>
+                        </child>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkTreeViewColumn" id="treeviewcolumn7">
+                        <property name="resizable">True</property>
+                        <property name="spacing">6</property>
+                        <property name="title" translatable="yes" context="selectcertificatedialog|usage">Certificate usage</property>
+                        <child>
+                          <object class="GtkCellRendererText" id="cellrenderer5"/>
+                          <attributes>
+                            <attribute name="text">4</attribute>
+                          </attributes>
+                        </child>
+                      </object>
+                    </child>
+                  </object>
                 </child>
               </object>
               <packing>


More information about the Libreoffice-commits mailing list