diff options
author | Tor Lillqvist <tml@collabora.com> | 2015-02-16 14:02:23 +0200 |
---|---|---|
committer | Tor Lillqvist <tml@collabora.com> | 2015-02-17 10:45:47 +0200 |
commit | 24ad0629ae9edad83514e329e7173b94a8680ea6 (patch) | |
tree | 7a82e12b591c5f8b07d36e1abca34ec31017252a /cui/source/options | |
parent | Bin some superfluous vertical whitespace (diff) | |
download | core-24ad0629ae9edad83514e329e7173b94a8680ea6.tar.gz core-24ad0629ae9edad83514e329e7173b94a8680ea6.zip |
tdf#88427: Add GUI to enter and maintain a list of Time Stamping Authorities
It is just a simple list of entered URLs, accessed from the Security page. No
sanity checks for now. No selection of a "default" one for now. Implementation
is much simpler this way. The actual selection of one TSA (or none) is done
when exporting to PDF.
Change-Id: I0392eabc9b9629a6f0a767d1b2337622a61c120f
Diffstat (limited to 'cui/source/options')
-rw-r--r-- | cui/source/options/optinet2.cxx | 18 | ||||
-rw-r--r-- | cui/source/options/optinet2.hxx | 6 | ||||
-rw-r--r-- | cui/source/options/tsaurls.cxx | 120 | ||||
-rw-r--r-- | cui/source/options/tsaurls.hxx | 40 |
4 files changed, 182 insertions, 2 deletions
diff --git a/cui/source/options/optinet2.cxx b/cui/source/options/optinet2.cxx index e7cd019bc665..50e853008ad7 100644 --- a/cui/source/options/optinet2.cxx +++ b/cui/source/options/optinet2.cxx @@ -85,6 +85,7 @@ #include "securityoptions.hxx" #include "webconninfo.hxx" #include "certpath.hxx" +#include "tsaurls.hxx" using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -601,6 +602,8 @@ SvxSecurityTabPage::SvxSecurityTabPage(vcl::Window* pParent, const SfxItemSet& r get(m_pMacroSecPB, "macro"); get(m_pCertFrame, "certificatepath"); get(m_pCertPathPB, "cert"); + get(m_pTSAURLsFrame, "tsaurls"); + get(m_pTSAURLsPB, "tsas"); m_sPasswordStoringDeactivateStr = get<FixedText>("nopasswordsave")->GetText(); InitControls(); @@ -612,6 +615,7 @@ SvxSecurityTabPage::SvxSecurityTabPage(vcl::Window* pParent, const SfxItemSet& r m_pShowConnectionsPB->SetClickHdl( LINK( this, SvxSecurityTabPage, ShowPasswordsHdl ) ); m_pMacroSecPB->SetClickHdl( LINK( this, SvxSecurityTabPage, MacroSecPBHdl ) ); m_pCertPathPB->SetClickHdl( LINK( this, SvxSecurityTabPage, CertPathPBHdl ) ); + m_pTSAURLsPB->SetClickHdl( LINK( this, SvxSecurityTabPage, TSAURLsPBHdl ) ); ActivatePage( rSet ); } @@ -782,6 +786,20 @@ IMPL_LINK_NOARG(SvxSecurityTabPage, CertPathPBHdl) return 0; } +IMPL_LINK_NOARG(SvxSecurityTabPage, TSAURLsPBHdl) +{ + // Unlike the mpCertPathDlg, we *don't* keep the same dialog object around between + // invocations. Seems clearer to my little brain that way. + + TSAURLsDialog* pTSAURLsDlg = new TSAURLsDialog(this); + + pTSAURLsDlg->Execute(); + + delete pTSAURLsDlg; + + return 0; +} + IMPL_LINK_NOARG(SvxSecurityTabPage, MacroSecPBHdl) { try diff --git a/cui/source/options/optinet2.hxx b/cui/source/options/optinet2.hxx index c7d81b756f12..5bb9c0547160 100644 --- a/cui/source/options/optinet2.hxx +++ b/cui/source/options/optinet2.hxx @@ -123,9 +123,7 @@ protected: // class SvxSecurityTabPage --------------------------------------------- class SvtSecurityOptions; - class CertPathDialog; - class SvxSecurityTabPage : public SfxTabPage { using TabPage::ActivatePage; @@ -147,6 +145,9 @@ private: VclContainer* m_pCertFrame; PushButton* m_pCertPathPB; + VclContainer* m_pTSAURLsFrame; + PushButton* m_pTSAURLsPB; + SvtSecurityOptions* mpSecOptions; svx::SecurityOptionsDialog* mpSecOptDlg; @@ -161,6 +162,7 @@ private: DECL_LINK(ShowPasswordsHdl, void *); DECL_LINK(MacroSecPBHdl, void* ); DECL_LINK(CertPathPBHdl, void* ); + DECL_LINK(TSAURLsPBHdl, void* ); void InitControls(); diff --git a/cui/source/options/tsaurls.cxx b/cui/source/options/tsaurls.cxx new file mode 100644 index 000000000000..9db380135ed7 --- /dev/null +++ b/cui/source/options/tsaurls.cxx @@ -0,0 +1,120 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <officecfg/Office/Common.hxx> +#include <svx/svxdlg.hxx> +#include <cuires.hrc> + +#include "tsaurls.hxx" + +#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp> + +using namespace ::com::sun::star; + +TSAURLsDialog::TSAURLsDialog(vcl::Window* pParent) + : ModalDialog(pParent, "TSAURLDialog", "cui/ui/tsaurldialog.ui") +{ + get(m_pAddBtn, "add"); + get(m_pDeleteBtn, "delete"); + get(m_pOKBtn, "ok"); + get(m_pURLListBox, "urls"); + + m_pURLListBox->SetDropDownLineCount(8); + m_pURLListBox->set_width_request(m_pURLListBox->approximate_char_width() * 32); + m_pOKBtn->Disable(); + + m_pAddBtn->SetClickHdl( LINK( this, TSAURLsDialog, AddHdl_Impl ) ); + m_pDeleteBtn->SetClickHdl( LINK( this, TSAURLsDialog, DeleteHdl_Impl ) ); + m_pOKBtn->SetClickHdl( LINK( this, TSAURLsDialog, OKHdl_Impl ) ); + + try + { + css::uno::Sequence<OUString> aUserSetTSAURLs(officecfg::Office::Common::Security::Scripting::TSAURLs::get()); + + for (auto i = aUserSetTSAURLs.begin(); i != aUserSetTSAURLs.end(); ++i) + { + AddTSAURL(*i); + } + } + catch (const uno::Exception &e) + { + SAL_WARN("cui.options", "TSAURLsDialog::TSAURLsDialog(): caught exception" << e.Message); + } +} + +IMPL_LINK_NOARG(TSAURLsDialog, OKHdl_Impl) +{ + std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create()); + + css::uno::Sequence<OUString> aNewValue(m_aURLs.size()); + size_t n(0); + + for (auto i = m_aURLs.cbegin(); i != m_aURLs.cend(); ++i) + aNewValue[n++] = *i; + officecfg::Office::Common::Security::Scripting::TSAURLs::set(aNewValue, batch); + batch->commit(); + + EndDialog(RET_OK); + + return 0; +} + +TSAURLsDialog::~TSAURLsDialog() +{ +} + +void TSAURLsDialog::AddTSAURL(const OUString& rURL) +{ + m_aURLs.insert(rURL); + + m_pURLListBox->SetUpdateMode(false); + m_pURLListBox->Clear(); + + for (auto i = m_aURLs.cbegin(); i != m_aURLs.cend(); ++i) + { + m_pURLListBox->InsertEntry(*i); + } + + m_pURLListBox->SetUpdateMode(true); +} + +IMPL_LINK_NOARG(TSAURLsDialog, AddHdl_Impl) +{ + OUString aURL; + OUString aDesc( get<FixedText>("enteraurl")->GetText() ); + + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + boost::scoped_ptr<AbstractSvxNameDialog> pDlg(pFact->CreateSvxNameDialog( m_pAddBtn, aURL, aDesc)); + + if ( pDlg->Execute() == RET_OK ) + { + pDlg->GetName( aURL ); + + AddTSAURL(aURL); + m_pOKBtn->Enable(); + } + + return 0; +} + +IMPL_LINK_NOARG(TSAURLsDialog, DeleteHdl_Impl) +{ + sal_Int32 nSel = m_pURLListBox->GetSelectEntryPos(); + + if (nSel == LISTBOX_ENTRY_NOTFOUND) + return 0; + + m_aURLs.erase(m_pURLListBox->GetEntry(nSel)); + m_pURLListBox->RemoveEntry(nSel); + m_pOKBtn->Enable(); + + return 0; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cui/source/options/tsaurls.hxx b/cui/source/options/tsaurls.hxx new file mode 100644 index 000000000000..aba749181ac5 --- /dev/null +++ b/cui/source/options/tsaurls.hxx @@ -0,0 +1,40 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_CUI_SOURCE_OPTIONS_TSAURLS_HXX +#define INCLUDED_CUI_SOURCE_OPTIONS_TSAURLS_HXX + +#include <vcl/lstbox.hxx> +#include <vcl/button.hxx> + +class TSAURLsDialog : public ModalDialog +{ +private: + ListBox* m_pURLListBox; + PushButton* m_pAddBtn; + PushButton* m_pDeleteBtn; + OKButton* m_pOKBtn; + + DECL_LINK(AddHdl_Impl, void *); + DECL_LINK(DeleteHdl_Impl, void *); + DECL_LINK(OKHdl_Impl, void *); + + std::set<OUString> m_aURLs; + + void AddTSAURL(const OUString &rURL); + +public: + TSAURLsDialog(vcl::Window* pParent); + virtual ~TSAURLsDialog(); + +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |