diff options
Diffstat (limited to 'xmlsecurity')
-rw-r--r-- | xmlsecurity/inc/certificatechooser.hxx | 18 | ||||
-rw-r--r-- | xmlsecurity/source/component/documentdigitalsignatures.cxx | 10 | ||||
-rw-r--r-- | xmlsecurity/source/dialogs/certificatechooser.cxx | 14 | ||||
-rw-r--r-- | xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx | 8 | ||||
-rw-r--r-- | xmlsecurity/uiconfig/ui/selectcertificatedialog.ui | 68 |
5 files changed, 89 insertions, 29 deletions
diff --git a/xmlsecurity/inc/certificatechooser.hxx b/xmlsecurity/inc/certificatechooser.hxx index 8b1f5563d85f..4279781f6fa3 100644 --- a/xmlsecurity/inc/certificatechooser.hxx +++ b/xmlsecurity/inc/certificatechooser.hxx @@ -51,6 +51,8 @@ enum class UserAction class CertificateChooser final : public weld::GenericDialogController { private: + static inline CertificateChooser* mxInstance = nullptr; + std::vector< css::uno::Reference< css::xml::crypto::XXMLSecurityContext > > mxSecurityContexts; std::vector<std::shared_ptr<UserData>> mvUserData; @@ -67,11 +69,12 @@ private: std::unique_ptr<weld::Label> m_xFTDescription; std::unique_ptr<weld::Entry> m_xDescriptionED; std::unique_ptr<weld::Entry> m_xSearchBox; + std::unique_ptr<weld::Button> m_xReloadBtn; std::unordered_map<css::uno::Reference< css::xml::crypto::XXMLSecurityContext>, css::uno::Sequence< css::uno::Reference< css::security::XCertificate > > > xMemCerts; - + DECL_LINK(ReloadButtonHdl, weld::Button&, void); DECL_LINK(ViewButtonHdl, weld::Button&, void); DECL_LINK(CertificateHighlightHdl, weld::TreeView&, void); DECL_LINK(CertificateSelectHdl, weld::TreeView&, bool); @@ -79,7 +82,8 @@ private: void ImplShowCertificateDetails(); void ImplInitialize(bool mbSearch = false); - + void ImplReloadCertificates(); + void ImplSecCtxToCerts(SvtUserOptions &aUserOpts, bool bOnlyReload); static void HandleOneUsageBit(OUString& string, int& bits, int bit, TranslateId name); public: @@ -88,6 +92,16 @@ public: UserAction eAction); virtual ~CertificateChooser() override; + static CertificateChooser* getInstance(weld::Window* _pParent, + std::vector< css::uno::Reference< css::xml::crypto::XXMLSecurityContext > > && rxSecurityContexts, + UserAction eAction) { + if (!mxInstance) + { + mxInstance = new CertificateChooser(_pParent, std::move(rxSecurityContexts), eAction); + } + return mxInstance; + } + short run() override; css::uno::Sequence<css::uno::Reference< css::security::XCertificate > > GetSelectedCertificates(); diff --git a/xmlsecurity/source/component/documentdigitalsignatures.cxx b/xmlsecurity/source/component/documentdigitalsignatures.cxx index 0fd029fc2d81..4ad63b36ed0b 100644 --- a/xmlsecurity/source/component/documentdigitalsignatures.cxx +++ b/xmlsecurity/source/component/documentdigitalsignatures.cxx @@ -709,14 +709,14 @@ DocumentDigitalSignatures::chooseCertificatesImpl(std::map<OUString, OUString>& xSecContexts.push_back(aSignatureManager.getGpgSecurityContext()); } - CertificateChooser aChooser(Application::GetFrameWeld(mxParentWindow), std::move(xSecContexts), eAction); + CertificateChooser* aChooser = CertificateChooser::getInstance(Application::GetFrameWeld(mxParentWindow), std::move(xSecContexts), eAction); - if (aChooser.run() != RET_OK) + if (aChooser->run() != RET_OK) return { Reference< css::security::XCertificate >(nullptr) }; - uno::Sequence< Reference< css::security::XCertificate > > xCerts = aChooser.GetSelectedCertificates(); - rProperties["Description"] = aChooser.GetDescription(); - rProperties["Usage"] = aChooser.GetUsageText(); + uno::Sequence< Reference< css::security::XCertificate > > 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 be3e88f9d453..a7ff02f1a583 100644 --- a/xmlsecurity/source/dialogs/certificatechooser.cxx +++ b/xmlsecurity/source/dialogs/certificatechooser.cxx @@ -52,6 +52,7 @@ CertificateChooser::CertificateChooser(weld::Window* _pParent, , m_xFTDescription(m_xBuilder->weld_label("description-label")) , m_xDescriptionED(m_xBuilder->weld_entry("description")) , m_xSearchBox(m_xBuilder->weld_entry("searchbox")) + , m_xReloadBtn(m_xBuilder->weld_button("reloadcert")) { auto nControlWidth = m_xCertLB->get_approximate_digit_width() * 105; m_xCertLB->set_size_request(nControlWidth, m_xCertLB->get_height_rows(12)); @@ -61,6 +62,7 @@ CertificateChooser::CertificateChooser(weld::Window* _pParent, m_xCertLB->connect_row_activated( LINK( this, CertificateChooser, CertificateSelectHdl ) ); m_xViewBtn->connect_clicked( LINK( this, CertificateChooser, ViewButtonHdl ) ); m_xSearchBox->connect_changed(LINK(this, CertificateChooser, SearchModifyHdl)); + m_xReloadBtn->connect_clicked( LINK( this, CertificateChooser, ReloadButtonHdl ) ); mxSecurityContexts = std::move(rxSecurityContexts); mbInitialized = false; @@ -313,6 +315,18 @@ OUString CertificateChooser::GetUsageText() UsageInClearText(xCerts[0]->getCertificateUsage()) : OUString(); } +void CertificateChooser::ImplReloadCertificates() +{ + xMemCerts.clear(); +} + +IMPL_LINK_NOARG(CertificateChooser, ReloadButtonHdl, weld::Button&, void) +{ + ImplReloadCertificates(); + mbInitialized = false; + ImplInitialize(); +} + IMPL_LINK_NOARG(CertificateChooser, SearchModifyHdl, weld::Entry&, void) { ImplInitialize(true); diff --git a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx index 4e29cbf836d2..5a7f16faf64b 100644 --- a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx +++ b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx @@ -412,12 +412,12 @@ IMPL_LINK_NOARG(DigitalSignaturesDialog, AddButtonHdl, weld::Button&, void) if (DocumentSignatureHelper::CanSignWithGPG(maSignatureManager.getStore(), m_sODFVersion)) xSecContexts.push_back(maSignatureManager.getGpgSecurityContext()); - CertificateChooser aChooser(m_xDialog.get(), std::move(xSecContexts), UserAction::Sign); - if (aChooser.run() == RET_OK) + CertificateChooser* aChooser = CertificateChooser::getInstance(m_xDialog.get(), std::move(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 e476a7ddd61a..aae6bd44024f 100644 --- a/xmlsecurity/uiconfig/ui/selectcertificatedialog.ui +++ b/xmlsecurity/uiconfig/ui/selectcertificatedialog.ui @@ -193,24 +193,6 @@ </packing> </child> <child> - <object class="GtkButton" id="viewcert"> - <property name="label" translatable="yes" context="selectcertificatedialog|viewcert">View Certificate...</property> - <property name="visible">True</property> - <property name="can-focus">True</property> - <property name="receives-default">True</property> - <property name="halign">end</property> - <child internal-child="accessible"> - <object class="AtkObject" id="viewcert-atkobject"> - <property name="AtkObject::accessible-description" translatable="yes" context="selectcertificatedialog|extended_tip|viewcert">Opens the View Certificate dialog where you can examine the selected certificate.</property> - </object> - </child> - </object> - <packing> - <property name="left-attach">0</property> - <property name="top-attach">4</property> - </packing> - </child> - <child> <object class="GtkEntry" id="searchbox"> <property name="visible">True</property> <property name="can-focus">True</property> @@ -269,6 +251,56 @@ <property name="top-attach">5</property> </packing> </child> + <child> + <object class="GtkBox"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="halign">end</property> + <property name="spacing">12</property> + <child> + <object class="GtkButton" id="viewcert"> + <property name="label" translatable="yes" context="selectcertificatedialog|viewcert">View Certificate...</property> + <property name="visible">True</property> + <property name="can-focus">True</property> + <property name="receives-default">True</property> + <property name="halign">end</property> + <child internal-child="accessible"> + <object class="AtkObject" id="viewcert-atkobject"> + <property name="AtkObject::accessible-description" translatable="yes" context="selectcertificatedialog|extended_tip|viewcert">Opens the View Certificate dialog where you can examine the selected certificate.</property> + </object> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkButton" id="reloadcert"> + <property name="label" translatable="yes" context="selectcertificatedialog|reloadcert">Reload Certificates</property> + <property name="visible">True</property> + <property name="can-focus">True</property> + <property name="receives-default">True</property> + <property name="halign">end</property> + <child internal-child="accessible"> + <object class="AtkObject" id="reloadcert-atkobject"> + <property name="AtkObject::accessible-description" translatable="yes" context="selectcertificatedialog|extended_tip|reloadcert">Reload the list of certificates.</property> + </object> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="left-attach">0</property> + <property name="top-attach">4</property> + </packing> + </child> </object> <packing> <property name="expand">True</property> |