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/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #undef SC_DLLIMPLEMENTATION
22 #include <dapitype.hxx>
23 #include <comphelper/lok.hxx>
25 ScDataPilotSourceTypeDlg::ScDataPilotSourceTypeDlg(weld::Window
* pParent
, bool bEnableExternal
)
26 : GenericDialogController(pParent
, u
"modules/scalc/ui/selectsource.ui"_ustr
, u
"SelectSourceDialog"_ustr
)
27 , m_xBtnSelection(m_xBuilder
->weld_radio_button(u
"selection"_ustr
))
28 , m_xBtnNamedRange(m_xBuilder
->weld_radio_button(u
"namedrange"_ustr
))
29 , m_xBtnDatabase(m_xBuilder
->weld_radio_button(u
"database"_ustr
))
30 , m_xBtnExternal(m_xBuilder
->weld_radio_button(u
"external"_ustr
))
31 , m_xLbNamedRange(m_xBuilder
->weld_combo_box(u
"rangelb"_ustr
))
32 , m_xBtnOk(m_xBuilder
->weld_button(u
"ok"_ustr
)) // for LOK jsdialog
33 , m_xBtnCancel(m_xBuilder
->weld_button(u
"cancel"_ustr
)) // for LOK jsdialog
35 m_xBtnSelection
->connect_toggled( LINK(this, ScDataPilotSourceTypeDlg
, RadioClickHdl
) );
36 m_xBtnNamedRange
->connect_toggled( LINK(this, ScDataPilotSourceTypeDlg
, RadioClickHdl
) );
37 m_xBtnDatabase
->connect_toggled( LINK(this, ScDataPilotSourceTypeDlg
, RadioClickHdl
) );
38 m_xBtnExternal
->connect_toggled( LINK(this, ScDataPilotSourceTypeDlg
, RadioClickHdl
) );
40 m_xBtnOk
->connect_clicked( LINK(this, ScDataPilotSourceTypeDlg
, ResponseHdl
) );
41 m_xBtnCancel
->connect_clicked( LINK(this, ScDataPilotSourceTypeDlg
, ResponseHdl
) );
44 m_xBtnExternal
->set_sensitive(false);
46 m_xBtnSelection
->set_active(true);
48 // Disabled unless at least one named range exists.
49 m_xLbNamedRange
->set_sensitive(false);
50 m_xBtnNamedRange
->set_sensitive(false);
52 // Intentionally hide this button to see if anyone complains.
53 m_xBtnExternal
->hide();
55 if (comphelper::LibreOfficeKit::isActive())
56 m_xBtnDatabase
->hide();
59 IMPL_LINK(ScDataPilotSourceTypeDlg
, ResponseHdl
, weld::Button
&, rButton
, void)
61 if (&rButton
== m_xBtnOk
.get())
62 m_xDialog
->response(RET_OK
);
64 m_xDialog
->response(RET_CANCEL
);
67 ScDataPilotSourceTypeDlg::~ScDataPilotSourceTypeDlg()
71 bool ScDataPilotSourceTypeDlg::IsDatabase() const
73 return m_xBtnDatabase
->get_active();
76 bool ScDataPilotSourceTypeDlg::IsExternal() const
78 return m_xBtnExternal
->get_active();
81 bool ScDataPilotSourceTypeDlg::IsNamedRange() const
83 return m_xBtnNamedRange
->get_active();
86 OUString
ScDataPilotSourceTypeDlg::GetSelectedNamedRange() const
88 return m_xLbNamedRange
->get_active_text();
91 void ScDataPilotSourceTypeDlg::AppendNamedRange(const OUString
& rName
)
93 m_xLbNamedRange
->append_text(rName
);
94 if (m_xLbNamedRange
->get_count() == 1)
96 // Select position 0 only for the first time.
97 m_xLbNamedRange
->set_active(0);
98 m_xBtnNamedRange
->set_sensitive(true);
102 IMPL_LINK_NOARG(ScDataPilotSourceTypeDlg
, RadioClickHdl
, weld::Toggleable
&, void)
104 m_xLbNamedRange
->set_sensitive(m_xBtnNamedRange
->get_active());
107 ScDataPilotServiceDlg::ScDataPilotServiceDlg(weld::Window
* pParent
, const std::vector
<OUString
>& rServices
)
108 : GenericDialogController(pParent
, u
"modules/scalc/ui/dapiservicedialog.ui"_ustr
, u
"DapiserviceDialog"_ustr
)
109 , m_xLbService(m_xBuilder
->weld_combo_box(u
"service"_ustr
))
110 , m_xEdSource(m_xBuilder
->weld_entry(u
"source"_ustr
))
111 , m_xEdName(m_xBuilder
->weld_entry(u
"name"_ustr
))
112 , m_xEdUser(m_xBuilder
->weld_entry(u
"user"_ustr
))
113 , m_xEdPasswd(m_xBuilder
->weld_entry(u
"password"_ustr
))
115 for (const OUString
& aName
: rServices
)
117 m_xLbService
->append_text(aName
);
119 m_xLbService
->set_active(0);
122 ScDataPilotServiceDlg::~ScDataPilotServiceDlg()
126 OUString
ScDataPilotServiceDlg::GetServiceName() const
128 return m_xLbService
->get_active_text();
131 OUString
ScDataPilotServiceDlg::GetParSource() const
133 return m_xEdSource
->get_text();
136 OUString
ScDataPilotServiceDlg::GetParName() const
138 return m_xEdName
->get_text();
141 OUString
ScDataPilotServiceDlg::GetParUser() const
143 return m_xEdUser
->get_text();
146 OUString
ScDataPilotServiceDlg::GetParPass() const
148 return m_xEdPasswd
->get_text();
151 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */