1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
/* -*- 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>
#include <boost/scoped_ptr.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()
{
disposeOnce();
}
void TSAURLsDialog::dispose()
{
m_pAddBtn.clear();
m_pDeleteBtn.clear();
m_pOKBtn.clear();
m_pURLListBox.clear();
ModalDialog::dispose();
}
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: */
|