1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 #include <officecfg/Office/Common.hxx>
11 #include <svx/svxdlg.hxx>
14 #include "tsaurls.hxx"
16 #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
18 using namespace ::com::sun::star
;
20 TSAURLsDialog::TSAURLsDialog(vcl::Window
* pParent
)
21 : ModalDialog(pParent
, "TSAURLDialog", "cui/ui/tsaurldialog.ui")
23 get(m_pAddBtn
, "add");
24 get(m_pDeleteBtn
, "delete");
26 get(m_pURLListBox
, "urls");
28 m_pURLListBox
->SetDropDownLineCount(8);
29 m_pURLListBox
->set_width_request(m_pURLListBox
->approximate_char_width() * 32);
32 m_pAddBtn
->SetClickHdl( LINK( this, TSAURLsDialog
, AddHdl_Impl
) );
33 m_pDeleteBtn
->SetClickHdl( LINK( this, TSAURLsDialog
, DeleteHdl_Impl
) );
34 m_pOKBtn
->SetClickHdl( LINK( this, TSAURLsDialog
, OKHdl_Impl
) );
38 css::uno::Sequence
<OUString
> aUserSetTSAURLs(officecfg::Office::Common::Security::Scripting::TSAURLs::get());
40 for (auto i
= aUserSetTSAURLs
.begin(); i
!= aUserSetTSAURLs
.end(); ++i
)
45 catch (const uno::Exception
&e
)
47 SAL_WARN("cui.options", "TSAURLsDialog::TSAURLsDialog(): caught exception" << e
.Message
);
51 IMPL_LINK_NOARG(TSAURLsDialog
, OKHdl_Impl
)
53 std::shared_ptr
<comphelper::ConfigurationChanges
> batch(comphelper::ConfigurationChanges::create());
55 css::uno::Sequence
<OUString
> aNewValue(m_aURLs
.size());
58 for (auto i
= m_aURLs
.cbegin(); i
!= m_aURLs
.cend(); ++i
)
60 officecfg::Office::Common::Security::Scripting::TSAURLs::set(aNewValue
, batch
);
68 TSAURLsDialog::~TSAURLsDialog()
73 void TSAURLsDialog::dispose()
78 m_pURLListBox
.clear();
80 ModalDialog::dispose();
83 void TSAURLsDialog::AddTSAURL(const OUString
& rURL
)
87 m_pURLListBox
->SetUpdateMode(false);
88 m_pURLListBox
->Clear();
90 for (auto i
= m_aURLs
.cbegin(); i
!= m_aURLs
.cend(); ++i
)
92 m_pURLListBox
->InsertEntry(*i
);
95 m_pURLListBox
->SetUpdateMode(true);
98 IMPL_LINK_NOARG(TSAURLsDialog
, AddHdl_Impl
)
101 OUString
aDesc( get
<FixedText
>("enteraurl")->GetText() );
103 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
104 boost::scoped_ptr
<AbstractSvxNameDialog
> pDlg(pFact
->CreateSvxNameDialog( m_pAddBtn
, aURL
, aDesc
));
106 if ( pDlg
->Execute() == RET_OK
)
108 pDlg
->GetName( aURL
);
117 IMPL_LINK_NOARG(TSAURLsDialog
, DeleteHdl_Impl
)
119 sal_Int32 nSel
= m_pURLListBox
->GetSelectEntryPos();
121 if (nSel
== LISTBOX_ENTRY_NOTFOUND
)
124 m_aURLs
.erase(m_pURLListBox
->GetEntry(nSel
));
125 m_pURLListBox
->RemoveEntry(nSel
);
131 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */