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 #include <config_java.h>
22 #include "DBSetupConnectionPages.hxx"
23 #include <core_resource.hxx>
24 #include <sqlmessage.hxx>
25 #include <strings.hrc>
26 #include <svl/itemset.hxx>
27 #include <svl/stritem.hxx>
28 #include <svl/eitem.hxx>
29 #include <svl/intitem.hxx>
30 #include <dsitems.hxx>
31 #include "dsnItem.hxx"
34 #include <jvmaccess/virtualmachine.hxx>
37 #include <connectivity/CommonTools.hxx>
38 #include <dbwizsetup.hxx>
39 #include "TextConnectionHelper.hxx"
40 #include <osl/diagnose.h>
42 #include <IItemSetHelper.hxx>
43 #include <comphelper/string.hxx>
47 using namespace ::com::sun::star
;
49 std::unique_ptr
<OGenericAdministrationPage
> OTextConnectionPageSetup::CreateTextTabPage(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
& _rAttrSet
)
51 return std::make_unique
<OTextConnectionPageSetup
>(pPage
, pController
, _rAttrSet
);
54 // OTextConnectionPageSetup
55 OTextConnectionPageSetup::OTextConnectionPageSetup(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
& rCoreAttrs
)
56 : OConnectionTabPageSetup(pPage
, pController
, "dbaccess/ui/dbwiztextpage.ui", "DBWizTextPage",
57 rCoreAttrs
, STR_TEXT_HELPTEXT
, STR_TEXT_HEADERTEXT
, STR_TEXT_PATH_OR_FILE
)
58 , m_xSubContainer(m_xBuilder
->weld_widget("TextPageContainer"))
59 , m_xTextConnectionHelper(new OTextConnectionHelper(m_xSubContainer
.get(), TC_EXTENSION
| TC_SEPARATORS
))
61 m_xTextConnectionHelper
->SetClickHandler(LINK( this, OTextConnectionPageSetup
, ImplGetExtensionHdl
) );
64 OTextConnectionPageSetup::~OTextConnectionPageSetup()
66 m_xTextConnectionHelper
.reset();
69 IMPL_LINK_NOARG(OTextConnectionPageSetup
, ImplGetExtensionHdl
, OTextConnectionHelper
*, void)
71 SetRoadmapStateValue(!m_xTextConnectionHelper
->GetExtension().isEmpty() && OConnectionTabPageSetup::checkTestConnection());
75 bool OTextConnectionPageSetup::checkTestConnection()
77 bool bDoEnable
= OConnectionTabPageSetup::checkTestConnection();
78 bDoEnable
= !m_xTextConnectionHelper
->GetExtension().isEmpty() && bDoEnable
;
82 void OTextConnectionPageSetup::fillControls(std::vector
< std::unique_ptr
<ISaveValueWrapper
> >& _rControlList
)
84 OConnectionTabPageSetup::fillControls(_rControlList
);
85 m_xTextConnectionHelper
->fillControls(_rControlList
);
88 void OTextConnectionPageSetup::fillWindows(std::vector
< std::unique_ptr
<ISaveValueWrapper
> >& _rControlList
)
90 OConnectionTabPageSetup::fillWindows(_rControlList
);
91 m_xTextConnectionHelper
->fillWindows(_rControlList
);
94 void OTextConnectionPageSetup::implInitControls(const SfxItemSet
& _rSet
, bool _bSaveValue
)
96 // first check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
97 bool bValid
, bReadonly
;
98 getFlags(_rSet
, bValid
, bReadonly
);
99 OConnectionTabPageSetup::implInitControls( _rSet
, _bSaveValue
);
100 m_xTextConnectionHelper
->implInitControls(_rSet
, bValid
);
103 bool OTextConnectionPageSetup::FillItemSet( SfxItemSet
* _rSet
)
105 bool bChangedSomething
= OConnectionTabPageSetup::FillItemSet(_rSet
);
106 bChangedSomething
= m_xTextConnectionHelper
->FillItemSet(*_rSet
, bChangedSomething
);
107 return bChangedSomething
;
110 bool OTextConnectionPageSetup::prepareLeave()
112 return m_xTextConnectionHelper
->prepareLeave();
115 std::unique_ptr
<OGenericAdministrationPage
> OLDAPConnectionPageSetup::CreateLDAPTabPage( weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
& _rAttrSet
)
117 return std::make_unique
<OLDAPConnectionPageSetup
>(pPage
, pController
, _rAttrSet
);
121 OLDAPConnectionPageSetup::OLDAPConnectionPageSetup( weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
& _rCoreAttrs
)
122 : OGenericAdministrationPage(pPage
, pController
, "dbaccess/ui/ldapconnectionpage.ui", "LDAPConnectionPage", _rCoreAttrs
)
123 , m_xFTHelpText(m_xBuilder
->weld_label("helpLabel"))
124 , m_xFTHostServer(m_xBuilder
->weld_label("hostNameLabel"))
125 , m_xETHostServer(m_xBuilder
->weld_entry("hostNameEntry"))
126 , m_xFTBaseDN(m_xBuilder
->weld_label("baseDNLabel"))
127 , m_xETBaseDN(m_xBuilder
->weld_entry("baseDNEntry"))
128 , m_xFTPortNumber(m_xBuilder
->weld_label("portNumLabel"))
129 , m_xNFPortNumber(m_xBuilder
->weld_spin_button("portNumEntry"))
130 , m_xFTDefaultPortNumber(m_xBuilder
->weld_label("portNumDefLabel"))
131 , m_xCBUseSSL(m_xBuilder
->weld_check_button("useSSLCheckbutton"))
133 m_xETHostServer
->connect_changed(LINK(this, OGenericAdministrationPage
, OnControlEntryModifyHdl
));
134 m_xETBaseDN
->connect_changed(LINK(this, OGenericAdministrationPage
, OnControlEntryModifyHdl
));
135 m_xNFPortNumber
->connect_value_changed(LINK(this, OGenericAdministrationPage
, OnControlSpinButtonModifyHdl
));
136 m_xCBUseSSL
->connect_toggled( LINK(this, OGenericAdministrationPage
, OnControlModifiedButtonClick
) );
137 SetRoadmapStateValue(false);
140 OLDAPConnectionPageSetup::~OLDAPConnectionPageSetup()
144 bool OLDAPConnectionPageSetup::FillItemSet( SfxItemSet
* _rSet
)
146 bool bChangedSomething
= false;
147 fillString(*_rSet
,m_xETBaseDN
.get(),DSID_CONN_LDAP_BASEDN
, bChangedSomething
);
148 fillInt32(*_rSet
,m_xNFPortNumber
.get(),DSID_CONN_LDAP_PORTNUMBER
,bChangedSomething
);
150 if ( m_xETHostServer
->get_value_changed_from_saved() )
152 const DbuTypeCollectionItem
* pCollectionItem
= dynamic_cast<const DbuTypeCollectionItem
*>( _rSet
->GetItem(DSID_TYPECOLLECTION
) );
153 ::dbaccess::ODsnTypeCollection
* pCollection
= nullptr;
155 pCollection
= pCollectionItem
->getCollection();
156 OSL_ENSURE(pCollection
, "OLDAPConnectionPageSetup::FillItemSet : really need a DSN type collection !");
159 OUString sUrl
= pCollection
->getPrefix( u
"sdbc:address:ldap:") + m_xETHostServer
->get_text();
160 _rSet
->Put(SfxStringItem(DSID_CONNECTURL
, sUrl
));
161 bChangedSomething
= true;
165 fillBool(*_rSet
,m_xCBUseSSL
.get(),DSID_CONN_LDAP_USESSL
,false,bChangedSomething
);
166 return bChangedSomething
;
168 void OLDAPConnectionPageSetup::fillControls(std::vector
< std::unique_ptr
<ISaveValueWrapper
> >& _rControlList
)
170 _rControlList
.emplace_back(new OSaveValueWidgetWrapper
<weld::Entry
>(m_xETHostServer
.get()));
171 _rControlList
.emplace_back(new OSaveValueWidgetWrapper
<weld::Entry
>(m_xETBaseDN
.get()));
172 _rControlList
.emplace_back(new OSaveValueWidgetWrapper
<weld::SpinButton
>(m_xNFPortNumber
.get()));
173 _rControlList
.emplace_back(new OSaveValueWidgetWrapper
<weld::Toggleable
>(m_xCBUseSSL
.get()));
175 void OLDAPConnectionPageSetup::fillWindows(std::vector
< std::unique_ptr
<ISaveValueWrapper
> >& _rControlList
)
177 _rControlList
.emplace_back(new ODisableWidgetWrapper
<weld::Label
>(m_xFTHelpText
.get()));
178 _rControlList
.emplace_back(new ODisableWidgetWrapper
<weld::Label
>(m_xFTHostServer
.get()));
179 _rControlList
.emplace_back(new ODisableWidgetWrapper
<weld::Label
>(m_xFTBaseDN
.get()));
180 _rControlList
.emplace_back(new ODisableWidgetWrapper
<weld::Label
>(m_xFTPortNumber
.get()));
181 _rControlList
.emplace_back(new ODisableWidgetWrapper
<weld::Label
>(m_xFTDefaultPortNumber
.get()));
183 void OLDAPConnectionPageSetup::implInitControls(const SfxItemSet
& _rSet
, bool _bSaveValue
)
185 // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
186 bool bValid
, bReadonly
;
187 getFlags(_rSet
, bValid
, bReadonly
);
189 const SfxStringItem
* pBaseDN
= _rSet
.GetItem
<SfxStringItem
>(DSID_CONN_LDAP_BASEDN
);
190 const SfxInt32Item
* pPortNumber
= _rSet
.GetItem
<SfxInt32Item
>(DSID_CONN_LDAP_PORTNUMBER
);
194 m_xETBaseDN
->set_text(pBaseDN
->GetValue());
195 m_xNFPortNumber
->set_value(pPortNumber
->GetValue());
197 OGenericAdministrationPage::implInitControls(_rSet
, _bSaveValue
);
201 void OLDAPConnectionPageSetup::callModifiedHdl(weld::Widget
*)
203 bool bRoadmapState
= ((!m_xETHostServer
->get_text().isEmpty() ) && ( !m_xETBaseDN
->get_text().isEmpty() ) && (!m_xFTPortNumber
->get_label().isEmpty() ));
204 SetRoadmapStateValue(bRoadmapState
);
205 OGenericAdministrationPage::callModifiedHdl();
208 std::unique_ptr
<OMySQLIntroPageSetup
> OMySQLIntroPageSetup::CreateMySQLIntroTabPage(weld::Container
* pPage
, ODbTypeWizDialogSetup
* pController
, const SfxItemSet
& rAttrSet
)
210 return std::make_unique
<OMySQLIntroPageSetup
>(pPage
, pController
, rAttrSet
);
213 OMySQLIntroPageSetup::OMySQLIntroPageSetup(weld::Container
* pPage
, ODbTypeWizDialogSetup
* pController
, const SfxItemSet
& _rCoreAttrs
)
214 : OGenericAdministrationPage(pPage
, pController
, "dbaccess/ui/dbwizmysqlintropage.ui", "DBWizMysqlIntroPage", _rCoreAttrs
)
215 , m_xODBCDatabase(m_xBuilder
->weld_radio_button("odbc"))
216 , m_xJDBCDatabase(m_xBuilder
->weld_radio_button("jdbc"))
217 , m_xNATIVEDatabase(m_xBuilder
->weld_radio_button("directly"))
219 m_xODBCDatabase
->connect_toggled(LINK(this, OMySQLIntroPageSetup
, OnSetupModeSelected
));
220 m_xJDBCDatabase
->connect_toggled(LINK(this, OMySQLIntroPageSetup
, OnSetupModeSelected
));
221 m_xNATIVEDatabase
->connect_toggled(LINK(this, OMySQLIntroPageSetup
, OnSetupModeSelected
));
222 pController
->SetIntroPage(this);
225 OMySQLIntroPageSetup::~OMySQLIntroPageSetup()
229 IMPL_LINK_NOARG(OMySQLIntroPageSetup
, OnSetupModeSelected
, weld::Toggleable
&, void)
231 maClickHdl
.Call( this );
234 void OMySQLIntroPageSetup::implInitControls(const SfxItemSet
& _rSet
, bool /*_bSaveValue*/)
236 // show the "Connect directly" option only if the driver is installed
237 const DbuTypeCollectionItem
* pCollectionItem
= dynamic_cast<const DbuTypeCollectionItem
*>( _rSet
.GetItem(DSID_TYPECOLLECTION
) );
238 bool bHasMySQLNative
= ( pCollectionItem
!= nullptr ) && pCollectionItem
->getCollection()->hasDriver( "sdbc:mysql:mysqlc:" );
239 if ( bHasMySQLNative
)
240 m_xNATIVEDatabase
->show();
242 // if any of the options is checked, then there's nothing to do
243 if ( m_xODBCDatabase
->get_active() || m_xJDBCDatabase
->get_active() || m_xNATIVEDatabase
->get_active() )
246 // prefer "native" or "JDBC"
247 if ( bHasMySQLNative
)
248 m_xNATIVEDatabase
->set_active(true);
250 m_xJDBCDatabase
->set_active(true);
253 void OMySQLIntroPageSetup::fillControls(std::vector
< std::unique_ptr
<ISaveValueWrapper
> >& /*_rControlList*/)
257 void OMySQLIntroPageSetup::fillWindows(std::vector
< std::unique_ptr
<ISaveValueWrapper
> >& /*_rControlList*/)
261 bool OMySQLIntroPageSetup::FillItemSet(SfxItemSet
* /*_rSet*/)
263 OSL_FAIL("Who called me?! Please ask oj for more information.");
267 OMySQLIntroPageSetup::ConnectionType
OMySQLIntroPageSetup::getMySQLMode() const
269 if (m_xJDBCDatabase
->get_active())
271 else if (m_xNATIVEDatabase
->get_active())
277 // MySQLNativeSetupPage
278 MySQLNativeSetupPage::MySQLNativeSetupPage( weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
& rCoreAttrs
)
279 : OGenericAdministrationPage(pPage
, pController
, "dbaccess/ui/dbwizmysqlnativepage.ui", "DBWizMysqlNativePage", rCoreAttrs
)
280 , m_xHelpText(m_xBuilder
->weld_label("helptext"))
281 , m_xSettingsContainer(m_xBuilder
->weld_container("MySQLSettingsContainer"))
282 , m_xMySQLSettings(new MySQLNativeSettings(m_xSettingsContainer
.get(), LINK(this, OGenericAdministrationPage
, OnControlModified
)))
284 SetRoadmapStateValue(false);
287 MySQLNativeSetupPage::~MySQLNativeSetupPage()
289 m_xMySQLSettings
.reset();
292 std::unique_ptr
<OGenericAdministrationPage
> MySQLNativeSetupPage::Create(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
& rAttrSet
)
294 return std::make_unique
<MySQLNativeSetupPage
>(pPage
, pController
, rAttrSet
);
297 void MySQLNativeSetupPage::fillControls( std::vector
< std::unique_ptr
<ISaveValueWrapper
> >& _rControlList
)
299 m_xMySQLSettings
->fillControls( _rControlList
);
302 void MySQLNativeSetupPage::fillWindows(std::vector
<std::unique_ptr
<ISaveValueWrapper
>>& rControlList
)
304 rControlList
.emplace_back(new ODisableWidgetWrapper
<weld::Label
>(m_xHelpText
.get()));
305 m_xMySQLSettings
->fillWindows(rControlList
);
308 bool MySQLNativeSetupPage::FillItemSet( SfxItemSet
* _rSet
)
310 return m_xMySQLSettings
->FillItemSet( _rSet
);
313 void MySQLNativeSetupPage::implInitControls( const SfxItemSet
& _rSet
, bool _bSaveValue
)
315 m_xMySQLSettings
->implInitControls( _rSet
);
317 OGenericAdministrationPage::implInitControls( _rSet
, _bSaveValue
);
322 void MySQLNativeSetupPage::callModifiedHdl(weld::Widget
*)
324 SetRoadmapStateValue( m_xMySQLSettings
->canAdvance() );
326 OGenericAdministrationPage::callModifiedHdl();
329 // OMySQLJDBCConnectionPageSetup
330 OGeneralSpecialJDBCConnectionPageSetup::OGeneralSpecialJDBCConnectionPageSetup( weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
& _rCoreAttrs
,sal_uInt16 _nPortId
, TranslateId pDefaultPortResId
, TranslateId pHelpTextResId
, TranslateId pHeaderTextResId
, TranslateId pDriverClassId
)
331 : OGenericAdministrationPage(pPage
, pController
, "dbaccess/ui/specialjdbcconnectionpage.ui", "SpecialJDBCConnectionPage", _rCoreAttrs
)
332 , m_nPortId(_nPortId
)
333 , m_xHeaderText(m_xBuilder
->weld_label("header"))
334 , m_xFTHelpText(m_xBuilder
->weld_label("helpLabel"))
335 , m_xFTDatabasename(m_xBuilder
->weld_label("dbNameLabel"))
336 , m_xETDatabasename(m_xBuilder
->weld_entry("dbNameEntry"))
337 , m_xFTHostname(m_xBuilder
->weld_label("hostNameLabel"))
338 , m_xETHostname(m_xBuilder
->weld_entry("hostNameEntry"))
339 , m_xFTPortNumber(m_xBuilder
->weld_label("portNumLabel"))
340 , m_xFTDefaultPortNumber(m_xBuilder
->weld_label("portNumDefLabel"))
341 , m_xNFPortNumber(m_xBuilder
->weld_spin_button("portNumEntry"))
342 , m_xFTDriverClass(m_xBuilder
->weld_label("jdbcDriverLabel"))
343 , m_xETDriverClass(m_xBuilder
->weld_entry("jdbcDriverEntry"))
344 , m_xPBTestJavaDriver(m_xBuilder
->weld_button("testDriverButton"))
346 m_xFTDriverClass
->set_label(DBA_RES(pDriverClassId
));
348 m_xFTDefaultPortNumber
->set_label(DBA_RES(pDefaultPortResId
));
349 OUString sHelpText
= DBA_RES(pHelpTextResId
);
350 m_xFTHelpText
->set_label(sHelpText
);
351 //TODO this code snippet is redundant
352 m_xHeaderText
->set_label(DBA_RES(pHeaderTextResId
));
354 m_xETDatabasename
->connect_changed(LINK(this, OGenericAdministrationPage
, OnControlEntryModifyHdl
));
355 m_xETHostname
->connect_changed(LINK(this, OGenericAdministrationPage
, OnControlEntryModifyHdl
));
356 m_xNFPortNumber
->connect_value_changed(LINK(this, OGenericAdministrationPage
, OnControlSpinButtonModifyHdl
));
358 m_xETDriverClass
->connect_changed(LINK(this, OGenericAdministrationPage
, OnControlEntryModifyHdl
));
359 m_xPBTestJavaDriver
->connect_clicked(LINK(this,OGeneralSpecialJDBCConnectionPageSetup
,OnTestJavaClickHdl
));
361 const SfxStringItem
* pUrlItem
= _rCoreAttrs
.GetItem
<SfxStringItem
>(DSID_CONNECTURL
);
362 const DbuTypeCollectionItem
* pTypesItem
= _rCoreAttrs
.GetItem
<DbuTypeCollectionItem
>(DSID_TYPECOLLECTION
);
363 ::dbaccess::ODsnTypeCollection
* pTypeCollection
= pTypesItem
? pTypesItem
->getCollection() : nullptr;
364 if (pTypeCollection
&& pUrlItem
&& pUrlItem
->GetValue().getLength() )
366 m_sDefaultJdbcDriverName
= pTypeCollection
->getJavaDriverClass(pUrlItem
->GetValue());
369 SetRoadmapStateValue(false);
372 OGeneralSpecialJDBCConnectionPageSetup::~OGeneralSpecialJDBCConnectionPageSetup()
376 std::unique_ptr
<OGenericAdministrationPage
> OGeneralSpecialJDBCConnectionPageSetup::CreateMySQLJDBCTabPage( weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
& _rAttrSet
)
378 return std::make_unique
<OGeneralSpecialJDBCConnectionPageSetup
>(pPage
, pController
,
380 DSID_MYSQL_PORTNUMBER
,
382 STR_MYSQLJDBC_HELPTEXT
,
383 STR_MYSQLJDBC_HEADERTEXT
,
384 STR_MYSQL_DRIVERCLASSTEXT
);
387 std::unique_ptr
<OGenericAdministrationPage
> OGeneralSpecialJDBCConnectionPageSetup::CreateOracleJDBCTabPage( weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
& _rAttrSet
)
389 return std::make_unique
<OGeneralSpecialJDBCConnectionPageSetup
>(pPage
, pController
,
391 DSID_ORACLE_PORTNUMBER
,
394 STR_ORACLE_HEADERTEXT
,
395 STR_ORACLE_DRIVERCLASSTEXT
);
398 void OGeneralSpecialJDBCConnectionPageSetup::fillControls(std::vector
< std::unique_ptr
<ISaveValueWrapper
> >& _rControlList
)
400 _rControlList
.emplace_back(new OSaveValueWidgetWrapper
<weld::Entry
>(m_xETDatabasename
.get()));
401 _rControlList
.emplace_back(new OSaveValueWidgetWrapper
<weld::Entry
>(m_xETDriverClass
.get()));
402 _rControlList
.emplace_back(new OSaveValueWidgetWrapper
<weld::Entry
>(m_xETHostname
.get()));
403 _rControlList
.emplace_back(new OSaveValueWidgetWrapper
<weld::SpinButton
>(m_xNFPortNumber
.get()));
406 void OGeneralSpecialJDBCConnectionPageSetup::fillWindows(std::vector
< std::unique_ptr
<ISaveValueWrapper
> >& _rControlList
)
408 _rControlList
.emplace_back(new ODisableWidgetWrapper
<weld::Label
>(m_xFTHelpText
.get()));
409 _rControlList
.emplace_back(new ODisableWidgetWrapper
<weld::Label
>(m_xFTDatabasename
.get()));
410 _rControlList
.emplace_back(new ODisableWidgetWrapper
<weld::Label
>(m_xFTHostname
.get()));
411 _rControlList
.emplace_back(new ODisableWidgetWrapper
<weld::Label
>(m_xFTPortNumber
.get()));
412 _rControlList
.emplace_back(new ODisableWidgetWrapper
<weld::Label
>(m_xFTDefaultPortNumber
.get()));
413 _rControlList
.emplace_back(new ODisableWidgetWrapper
<weld::Label
>(m_xFTDriverClass
.get()));
416 bool OGeneralSpecialJDBCConnectionPageSetup::FillItemSet( SfxItemSet
* _rSet
)
418 bool bChangedSomething
= false;
419 fillString(*_rSet
,m_xETDriverClass
.get(),DSID_JDBCDRIVERCLASS
,bChangedSomething
);
420 fillString(*_rSet
,m_xETHostname
.get(),DSID_CONN_HOSTNAME
,bChangedSomething
);
421 fillString(*_rSet
,m_xETDatabasename
.get(),DSID_DATABASENAME
,bChangedSomething
);
422 fillInt32(*_rSet
,m_xNFPortNumber
.get(),m_nPortId
,bChangedSomething
);
423 return bChangedSomething
;
426 void OGeneralSpecialJDBCConnectionPageSetup::implInitControls(const SfxItemSet
& _rSet
, bool _bSaveValue
)
428 // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
429 bool bValid
, bReadonly
;
430 getFlags(_rSet
, bValid
, bReadonly
);
432 const SfxStringItem
* pDatabaseName
= _rSet
.GetItem
<SfxStringItem
>(DSID_DATABASENAME
);
433 const SfxStringItem
* pDrvItem
= _rSet
.GetItem
<SfxStringItem
>(DSID_JDBCDRIVERCLASS
);
434 const SfxStringItem
* pHostName
= _rSet
.GetItem
<SfxStringItem
>(DSID_CONN_HOSTNAME
);
435 const SfxInt32Item
* pPortNumber
= _rSet
.GetItem
<SfxInt32Item
>(m_nPortId
);
439 m_xETDatabasename
->set_text(pDatabaseName
->GetValue());
440 m_xETDatabasename
->save_value();
442 m_xETDriverClass
->set_text(pDrvItem
->GetValue());
443 m_xETDriverClass
->save_value();
445 m_xETHostname
->set_text(pHostName
->GetValue());
446 m_xETHostname
->save_value();
448 m_xNFPortNumber
->set_value(pPortNumber
->GetValue());
449 m_xNFPortNumber
->save_value();
451 OGenericAdministrationPage::implInitControls(_rSet
, _bSaveValue
);
453 // to get the correct value when saveValue was called by base class
454 if ( o3tl::trim(m_xETDriverClass
->get_text()).empty() )
456 m_xETDriverClass
->set_text(m_sDefaultJdbcDriverName
);
457 m_xETDriverClass
->save_value();
461 bool bRoadmapState
= ((!m_xETDatabasename
->get_text().isEmpty() ) && (!m_xETHostname
->get_text().isEmpty()) && (!m_xNFPortNumber
->get_text().isEmpty() ) && ( !m_xETDriverClass
->get_text().isEmpty() ));
462 SetRoadmapStateValue(bRoadmapState
);
465 IMPL_LINK_NOARG(OGeneralSpecialJDBCConnectionPageSetup
, OnTestJavaClickHdl
, weld::Button
&, void)
467 OSL_ENSURE(m_pAdminDialog
,"No Admin dialog set! ->GPF");
469 bool bSuccess
= false;
470 #if HAVE_FEATURE_JAVA
473 if ( !o3tl::trim(m_xETDriverClass
->get_text()).empty() )
475 // TODO change jvmaccess
476 ::rtl::Reference
< jvmaccess::VirtualMachine
> xJVM
= ::connectivity::getJavaVM( m_pAdminDialog
->getORB() );
477 m_xETDriverClass
->set_text(m_xETDriverClass
->get_text().trim()); // fdo#68341
478 bSuccess
= ::connectivity::existsJavaClassByName(xJVM
,m_xETDriverClass
->get_text());
481 catch(css::uno::Exception
&)
485 TranslateId pMessage
= bSuccess
? STR_JDBCDRIVER_SUCCESS
: STR_JDBCDRIVER_NO_SUCCESS
;
486 const MessageType mt
= bSuccess
? MessageType::Info
: MessageType::Error
;
487 OSQLMessageBox
aMsg(GetFrameWeld(), DBA_RES(pMessage
), OUString(), MessBoxStyle::Ok
| MessBoxStyle::DefaultOk
, mt
);
491 void OGeneralSpecialJDBCConnectionPageSetup::callModifiedHdl(weld::Widget
* pControl
)
493 if (pControl
== m_xETDriverClass
.get())
494 m_xPBTestJavaDriver
->set_sensitive( !o3tl::trim(m_xETDriverClass
->get_text()).empty() );
495 bool bRoadmapState
= ((!m_xETDatabasename
->get_text().isEmpty() ) && ( !m_xETHostname
->get_text().isEmpty() ) && (!m_xNFPortNumber
->get_text().isEmpty() ) && ( !o3tl::trim(m_xETDriverClass
->get_text()).empty() ));
496 SetRoadmapStateValue(bRoadmapState
);
497 OGenericAdministrationPage::callModifiedHdl();
500 std::unique_ptr
<OGenericAdministrationPage
> OJDBCConnectionPageSetup::CreateJDBCTabPage(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
& _rAttrSet
)
502 return std::make_unique
<OJDBCConnectionPageSetup
>(pPage
, pController
, _rAttrSet
);
505 // OPostgresConnectionPageSetup
506 OPostgresConnectionPageSetup::OPostgresConnectionPageSetup( weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
& _rCoreAttrs
,sal_uInt16 _nPortId
, TranslateId pDefaultPortResId
, TranslateId pHelpTextResId
, TranslateId pHeaderTextResId
, TranslateId pConnectionTextResId
)
507 : OGenericAdministrationPage(pPage
, pController
, "dbaccess/ui/postgrespage.ui", "SpecialPostgresPage", _rCoreAttrs
)
508 , m_nPortId(_nPortId
)
509 , m_xHeaderText(m_xBuilder
->weld_label("header"))
510 , m_xFTHelpText(m_xBuilder
->weld_label("helpLabel"))
511 , m_xFTDatabasename(m_xBuilder
->weld_label("dbNameLabel"))
512 , m_xETDatabasename(m_xBuilder
->weld_entry("dbNameEntry"))
513 , m_xFTHostname(m_xBuilder
->weld_label("hostNameLabel"))
514 , m_xETHostname(m_xBuilder
->weld_entry("hostNameEntry"))
515 , m_xFTPortNumber(m_xBuilder
->weld_label("portNumLabel"))
516 , m_xFTDefaultPortNumber(m_xBuilder
->weld_label("portNumDefLabel"))
517 , m_xNFPortNumber(m_xBuilder
->weld_spin_button("portNumEntry"))
518 , m_xFTConnection(m_xBuilder
->weld_label("connectionStringLabel"))
519 , m_xConnectionURL(new OConnectionURLEdit(m_xBuilder
->weld_entry("browseurl"), m_xBuilder
->weld_label("browselabel")))
520 // , m_pCollection(nullptr)
522 m_xFTConnection
->set_label(DBA_RES(pConnectionTextResId
));
523 m_xFTDefaultPortNumber
->set_label(DBA_RES(pDefaultPortResId
));
524 OUString sHelpText
= DBA_RES(pHelpTextResId
);
525 m_xFTHelpText
->set_label(sHelpText
);
526 //TODO this code snippet is redundant
527 m_xHeaderText
->set_label(DBA_RES(pHeaderTextResId
));
529 m_xETDatabasename
->connect_changed(LINK(this, OGenericAdministrationPage
, OnControlEntryModifyHdl
));
530 m_xETHostname
->connect_changed(LINK(this, OGenericAdministrationPage
, OnControlEntryModifyHdl
));
531 m_xNFPortNumber
->connect_value_changed(LINK(this, OGenericAdministrationPage
, OnControlSpinButtonModifyHdl
));
532 const DbuTypeCollectionItem
* pCollectionItem
= dynamic_cast<const DbuTypeCollectionItem
*>( _rCoreAttrs
.GetItem(DSID_TYPECOLLECTION
) );
534 m_pCollection
= pCollectionItem
->getCollection();
535 OSL_ENSURE(m_pCollection
, "OConnectionHelper::OConnectionHelper : really need a DSN type collection !");
536 m_xConnectionURL
->SetTypeCollection(m_pCollection
);
538 SetRoadmapStateValue(false);
541 OPostgresConnectionPageSetup::~OPostgresConnectionPageSetup()
545 std::unique_ptr
<OGenericAdministrationPage
> OPostgresConnectionPageSetup::CreatePostgresTabPage( weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
& _rAttrSet
)
547 return std::make_unique
<OPostgresConnectionPageSetup
>(pPage
, pController
,
549 DSID_POSTGRES_PORTNUMBER
,
550 STR_POSTGRES_DEFAULT
,
551 STR_POSTGRES_HELPTEXT
,
552 STR_POSTGRES_HEADERTEXT
,
556 void OPostgresConnectionPageSetup::fillControls(std::vector
< std::unique_ptr
<ISaveValueWrapper
> >& _rControlList
)
558 _rControlList
.emplace_back(new OSaveValueWidgetWrapper
<weld::Entry
>(m_xETDatabasename
.get()));
559 _rControlList
.emplace_back( new OSaveValueWidgetWrapper
<OConnectionURLEdit
>( m_xConnectionURL
.get() ) );
560 _rControlList
.emplace_back(new OSaveValueWidgetWrapper
<weld::Entry
>(m_xETHostname
.get()));
561 _rControlList
.emplace_back(new OSaveValueWidgetWrapper
<weld::SpinButton
>(m_xNFPortNumber
.get()));
564 bool OPostgresConnectionPageSetup::FillItemSet( SfxItemSet
* _rSet
)
566 bool bChangedSomething
= false;
567 fillString(*_rSet
,m_xConnectionURL
.get(), DSID_CONNECTURL
, bChangedSomething
);
568 fillString(*_rSet
,m_xETHostname
.get(),DSID_CONN_HOSTNAME
,bChangedSomething
);
569 fillString(*_rSet
,m_xETDatabasename
.get(),DSID_DATABASENAME
,bChangedSomething
);
570 fillInt32(*_rSet
,m_xNFPortNumber
.get(),m_nPortId
,bChangedSomething
);
571 return bChangedSomething
;
574 void OPostgresConnectionPageSetup::fillWindows(std::vector
< std::unique_ptr
<ISaveValueWrapper
> >& _rControlList
)
576 _rControlList
.emplace_back(new ODisableWidgetWrapper
<weld::Label
>(m_xFTHelpText
.get()));
577 _rControlList
.emplace_back(new ODisableWidgetWrapper
<weld::Label
>(m_xFTDatabasename
.get()));
578 _rControlList
.emplace_back(new ODisableWidgetWrapper
<weld::Label
>(m_xFTHostname
.get()));
579 _rControlList
.emplace_back(new ODisableWidgetWrapper
<weld::Label
>(m_xFTPortNumber
.get()));
580 _rControlList
.emplace_back(new ODisableWidgetWrapper
<weld::Label
>(m_xFTDefaultPortNumber
.get()));
581 _rControlList
.emplace_back(new ODisableWidgetWrapper
<weld::Label
>(m_xFTConnection
.get()));
584 void OPostgresConnectionPageSetup::implInitControls(const SfxItemSet
& _rSet
, bool _bSaveValue
)
586 // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
587 SetRoadmapStateValue(true);
588 bool bValid
, bReadonly
;
589 getFlags(_rSet
, bValid
, bReadonly
);
591 m_xFTConnection
->show();
592 m_xConnectionURL
->show();
593 m_xConnectionURL
->ShowPrefix( false);
595 const SfxStringItem
* pDatabaseName
= _rSet
.GetItem
<SfxStringItem
>(DSID_DATABASENAME
);
596 const SfxStringItem
* pUrlItem
= _rSet
.GetItem
<SfxStringItem
>(DSID_CONNECTURL
);
597 const SfxStringItem
* pHostName
= _rSet
.GetItem
<SfxStringItem
>(DSID_CONN_HOSTNAME
);
598 const SfxInt32Item
* pPortNumber
= _rSet
.GetItem
<SfxInt32Item
>(m_nPortId
);
602 m_xETDatabasename
->set_text(pDatabaseName
->GetValue());
603 m_xETDatabasename
->save_value();
605 OUString sUrl
= pUrlItem
->GetValue();
607 m_xConnectionURL
->save_value();
609 m_xETHostname
->set_text(pHostName
->GetValue());
610 m_xETHostname
->save_value();
612 m_xNFPortNumber
->set_value(pPortNumber
->GetValue());
613 m_xNFPortNumber
->save_value();
616 OGenericAdministrationPage::implInitControls(_rSet
, _bSaveValue
);
621 bool OPostgresConnectionPageSetup::commitPage( ::vcl::WizardTypes::CommitPageReason
/*_eReason*/ )
626 bool OPostgresConnectionPageSetup::commitURL()
628 OUString sURL
= m_xConnectionURL
->GetTextNoPrefix();
629 setURLNoPrefix(sURL
);
630 m_xConnectionURL
->SaveValueNoPrefix();
634 void OPostgresConnectionPageSetup::impl_setURL( std::u16string_view _rURL
, bool _bPrefix
)
636 OUString
sURL( comphelper::string::stripEnd(_rURL
, '*') );
637 OSL_ENSURE( m_pCollection
, "OConnectionHelper::impl_setURL: have no interpreter for the URLs!" );
639 m_xConnectionURL
->SetText( sURL
);
641 m_xConnectionURL
->SetTextNoPrefix( sURL
);
644 void OPostgresConnectionPageSetup::setURLNoPrefix( std::u16string_view _rURL
)
646 impl_setURL( _rURL
,false);
649 void OPostgresConnectionPageSetup::setURL( std::u16string_view _rURL
)
651 impl_setURL( _rURL
, true);
654 OUString
OPostgresConnectionPageSetup::getURLNoPrefix( ) const
656 return impl_getURL();
659 OUString
OPostgresConnectionPageSetup::impl_getURL() const
662 OUString sURL
= m_xConnectionURL
->GetTextNoPrefix();
663 OSL_ENSURE( m_pCollection
, "OConnectionHelper::impl_getURL: have no interpreter for the URLs!" );
667 IMPL_LINK_NOARG(OPostgresConnectionPageSetup
, OnEditModified
, weld::Entry
&, void)
669 SetRoadmapStateValue(true);
673 // OMySQLJDBCConnectionPageSetup
674 OJDBCConnectionPageSetup::OJDBCConnectionPageSetup(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
& rCoreAttrs
)
675 : OConnectionTabPageSetup(pPage
, pController
, "dbaccess/ui/jdbcconnectionpage.ui", "JDBCConnectionPage", rCoreAttrs
,
676 STR_JDBC_HELPTEXT
, STR_JDBC_HEADERTEXT
, STR_COMMONURL
)
677 , m_xFTDriverClass(m_xBuilder
->weld_label("jdbcLabel"))
678 , m_xETDriverClass(m_xBuilder
->weld_entry("jdbcEntry"))
679 , m_xPBTestJavaDriver(m_xBuilder
->weld_button("jdbcButton"))
681 m_xETDriverClass
->connect_changed(LINK(this, OJDBCConnectionPageSetup
, OnEditModified
));
682 m_xPBTestJavaDriver
->connect_clicked(LINK(this,OJDBCConnectionPageSetup
,OnTestJavaClickHdl
));
685 OJDBCConnectionPageSetup::~OJDBCConnectionPageSetup()
689 void OJDBCConnectionPageSetup::fillControls(std::vector
< std::unique_ptr
<ISaveValueWrapper
> >& _rControlList
)
691 _rControlList
.emplace_back(new OSaveValueWidgetWrapper
<weld::Entry
>(m_xETDriverClass
.get()));
694 void OJDBCConnectionPageSetup::fillWindows(std::vector
< std::unique_ptr
<ISaveValueWrapper
> >& _rControlList
)
696 _rControlList
.emplace_back(new ODisableWidgetWrapper
<weld::Label
>(m_xFTDriverClass
.get()));
699 bool OJDBCConnectionPageSetup::FillItemSet( SfxItemSet
* _rSet
)
701 bool bChangedSomething
= OConnectionTabPageSetup::FillItemSet(_rSet
);
702 fillString(*_rSet
,m_xETDriverClass
.get(),DSID_JDBCDRIVERCLASS
,bChangedSomething
);
703 return bChangedSomething
;
706 void OJDBCConnectionPageSetup::implInitControls(const SfxItemSet
& _rSet
, bool _bSaveValue
)
708 // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
709 bool bValid
, bReadonly
;
710 getFlags(_rSet
, bValid
, bReadonly
);
712 const SfxStringItem
* pDrvItem
= _rSet
.GetItem
<SfxStringItem
>(DSID_JDBCDRIVERCLASS
);
716 if ( !pDrvItem
->GetValue().getLength() )
718 OUString sDefaultJdbcDriverName
= m_pCollection
->getJavaDriverClass(m_eType
);
719 if ( !sDefaultJdbcDriverName
.isEmpty() )
721 m_xETDriverClass
->set_text(sDefaultJdbcDriverName
);
722 m_xETDriverClass
->save_value();
727 m_xETDriverClass
->set_text(pDrvItem
->GetValue());
728 m_xETDriverClass
->save_value();
731 bool bEnable
= pDrvItem
->GetValue().getLength() != 0;
732 m_xPBTestJavaDriver
->set_sensitive(bEnable
);
733 OConnectionTabPageSetup::implInitControls(_rSet
, _bSaveValue
);
735 SetRoadmapStateValue(checkTestConnection());
738 bool OJDBCConnectionPageSetup::checkTestConnection()
740 OSL_ENSURE(m_pAdminDialog
,"No Admin dialog set! ->GPF");
741 bool bEnableTestConnection
= !m_xConnectionURL
->get_visible() || !m_xConnectionURL
->GetTextNoPrefix().isEmpty();
742 bEnableTestConnection
= bEnableTestConnection
&& (!m_xETDriverClass
->get_text().isEmpty());
743 return bEnableTestConnection
;
746 IMPL_LINK_NOARG(OJDBCConnectionPageSetup
, OnTestJavaClickHdl
, weld::Button
&, void)
748 OSL_ENSURE(m_pAdminDialog
,"No Admin dialog set! ->GPF");
749 bool bSuccess
= false;
750 #if HAVE_FEATURE_JAVA
753 if ( !m_xETDriverClass
->get_text().isEmpty() )
755 // TODO change jvmaccess
756 ::rtl::Reference
< jvmaccess::VirtualMachine
> xJVM
= ::connectivity::getJavaVM( m_pAdminDialog
->getORB() );
757 m_xETDriverClass
->set_text(m_xETDriverClass
->get_text().trim()); // fdo#68341
758 bSuccess
= xJVM
.is() && ::connectivity::existsJavaClassByName(xJVM
,m_xETDriverClass
->get_text());
761 catch(css::uno::Exception
&)
765 TranslateId pMessage
= bSuccess
? STR_JDBCDRIVER_SUCCESS
: STR_JDBCDRIVER_NO_SUCCESS
;
766 const MessageType mt
= bSuccess
? MessageType::Info
: MessageType::Error
;
767 OSQLMessageBox
aMsg(GetFrameWeld(), DBA_RES(pMessage
), OUString(), MessBoxStyle::Ok
| MessBoxStyle::DefaultOk
, mt
);
771 IMPL_LINK(OJDBCConnectionPageSetup
, OnEditModified
, weld::Entry
&, rEdit
, void)
773 if (&rEdit
== m_xETDriverClass
.get())
774 m_xPBTestJavaDriver
->set_sensitive(!m_xETDriverClass
->get_text().isEmpty());
775 SetRoadmapStateValue(checkTestConnection());
776 // tell the listener we were modified
780 std::unique_ptr
<OGenericAdministrationPage
> OSpreadSheetConnectionPageSetup::CreateDocumentOrSpreadSheetTabPage(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
& _rAttrSet
)
782 return std::make_unique
<OSpreadSheetConnectionPageSetup
>(pPage
, pController
, _rAttrSet
);
785 OSpreadSheetConnectionPageSetup::OSpreadSheetConnectionPageSetup(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
& rCoreAttrs
)
786 : OConnectionTabPageSetup(pPage
, pController
, "dbaccess/ui/dbwizspreadsheetpage.ui", "DBWizSpreadsheetPage",
787 rCoreAttrs
, STR_SPREADSHEET_HELPTEXT
, STR_SPREADSHEET_HEADERTEXT
, STR_SPREADSHEETPATH
)
788 , m_xPasswordrequired(m_xBuilder
->weld_check_button("passwordrequired"))
790 m_xPasswordrequired
->connect_toggled(LINK(this, OGenericAdministrationPage
, OnControlModifiedButtonClick
));
793 OSpreadSheetConnectionPageSetup::~OSpreadSheetConnectionPageSetup()
797 void OSpreadSheetConnectionPageSetup::fillWindows(std::vector
< std::unique_ptr
<ISaveValueWrapper
> >& /*_rControlList*/)
801 void OSpreadSheetConnectionPageSetup::fillControls(std::vector
< std::unique_ptr
<ISaveValueWrapper
> >& _rControlList
)
803 OConnectionTabPageSetup::fillControls(_rControlList
);
804 _rControlList
.emplace_back(new OSaveValueWidgetWrapper
<weld::Toggleable
>(m_xPasswordrequired
.get()));
808 bool OSpreadSheetConnectionPageSetup::FillItemSet( SfxItemSet
* _rSet
)
810 bool bChangedSomething
= OConnectionTabPageSetup::FillItemSet(_rSet
);
811 fillBool(*_rSet
,m_xPasswordrequired
.get(),DSID_PASSWORDREQUIRED
,false,bChangedSomething
);
812 return bChangedSomething
;
815 std::unique_ptr
<OGenericAdministrationPage
> OAuthentificationPageSetup::CreateAuthentificationTabPage(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
& _rAttrSet
)
817 return std::make_unique
<OAuthentificationPageSetup
>(pPage
, pController
, _rAttrSet
);
820 OAuthentificationPageSetup::OAuthentificationPageSetup(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
& _rCoreAttrs
)
821 : OGenericAdministrationPage(pPage
, pController
, "dbaccess/ui/authentificationpage.ui", "AuthentificationPage", _rCoreAttrs
)
822 , m_xFTHelpText(m_xBuilder
->weld_label("helptext"))
823 , m_xFTUserName(m_xBuilder
->weld_label("generalUserNameLabel"))
824 , m_xETUserName(m_xBuilder
->weld_entry("generalUserNameEntry"))
825 , m_xCBPasswordRequired(m_xBuilder
->weld_check_button("passRequiredCheckbutton"))
826 , m_xPBTestConnection(m_xBuilder
->weld_button("testConnectionButton"))
828 m_xETUserName
->connect_changed(LINK(this,OGenericAdministrationPage
,OnControlEntryModifyHdl
));
829 m_xCBPasswordRequired
->connect_toggled(LINK(this,OGenericAdministrationPage
,OnControlModifiedButtonClick
));
830 m_xPBTestConnection
->connect_clicked(LINK(this,OGenericAdministrationPage
,OnTestConnectionButtonClickHdl
));
833 OAuthentificationPageSetup::~OAuthentificationPageSetup()
837 void OAuthentificationPageSetup::fillWindows(std::vector
< std::unique_ptr
<ISaveValueWrapper
> >& _rControlList
)
839 _rControlList
.emplace_back(new ODisableWidgetWrapper
<weld::Label
>(m_xFTHelpText
.get()));
840 _rControlList
.emplace_back(new ODisableWidgetWrapper
<weld::Label
>(m_xFTUserName
.get()));
841 _rControlList
.emplace_back(new ODisableWidgetWrapper
<weld::Button
>(m_xPBTestConnection
.get()));
844 void OAuthentificationPageSetup::fillControls(std::vector
< std::unique_ptr
<ISaveValueWrapper
> >& _rControlList
)
846 _rControlList
.emplace_back(new OSaveValueWidgetWrapper
<weld::Entry
>(m_xETUserName
.get()));
847 _rControlList
.emplace_back(new OSaveValueWidgetWrapper
<weld::Toggleable
>(m_xCBPasswordRequired
.get()));
850 void OAuthentificationPageSetup::implInitControls(const SfxItemSet
& _rSet
, bool /*_bSaveValue*/)
852 // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
853 bool bValid
, bReadonly
;
854 getFlags(_rSet
, bValid
, bReadonly
);
855 const SfxStringItem
* pUidItem
= _rSet
.GetItem
<SfxStringItem
>(DSID_USER
);
856 const SfxBoolItem
* pAllowEmptyPwd
= _rSet
.GetItem
<SfxBoolItem
>(DSID_PASSWORDREQUIRED
);
858 m_xETUserName
->set_text(pUidItem
->GetValue());
859 m_xCBPasswordRequired
->set_active(pAllowEmptyPwd
->GetValue());
861 m_xETUserName
->save_value();
864 bool OAuthentificationPageSetup::FillItemSet( SfxItemSet
* _rSet
)
866 bool bChangedSomething
= false;
868 if (m_xETUserName
->get_value_changed_from_saved())
870 _rSet
->Put(SfxStringItem(DSID_USER
, m_xETUserName
->get_text()));
871 _rSet
->Put(SfxStringItem(DSID_PASSWORD
, OUString()));
872 bChangedSomething
= true;
874 fillBool(*_rSet
, m_xCBPasswordRequired
.get(), DSID_PASSWORDREQUIRED
, false, bChangedSomething
);
875 return bChangedSomething
;
878 std::unique_ptr
<OGenericAdministrationPage
> OFinalDBPageSetup::CreateFinalDBTabPageSetup(weld::Container
* pPage
, ODbTypeWizDialogSetup
* pController
, const SfxItemSet
& _rAttrSet
)
880 return std::make_unique
<OFinalDBPageSetup
>(pPage
, pController
, _rAttrSet
);
883 OFinalDBPageSetup::OFinalDBPageSetup(weld::Container
* pPage
, ODbTypeWizDialogSetup
* pController
, const SfxItemSet
& _rCoreAttrs
)
884 : OGenericAdministrationPage(pPage
, pController
, "dbaccess/ui/finalpagewizard.ui", "PageFinal", _rCoreAttrs
)
885 , m_xFTFinalHeader(m_xBuilder
->weld_label("headerText"))
886 , m_xFTFinalHelpText(m_xBuilder
->weld_label("helpText"))
887 , m_xRBRegisterDataSource(m_xBuilder
->weld_radio_button("yesregister"))
888 , m_xRBDontregisterDataSource(m_xBuilder
->weld_radio_button("noregister"))
889 , m_xFTAdditionalSettings(m_xBuilder
->weld_label("additionalText"))
890 , m_xCBOpenAfterwards(m_xBuilder
->weld_check_button("openediting"))
891 , m_xCBStartTableWizard(m_xBuilder
->weld_check_button("usewizard"))
892 , m_xFTFinalText(m_xBuilder
->weld_label("finishText"))
894 m_xCBOpenAfterwards
->connect_toggled(LINK(this, OFinalDBPageSetup
, OnOpenSelected
));
895 m_xRBRegisterDataSource
->set_active(true);
896 pController
->SetFinalPage(this);
899 OFinalDBPageSetup::~OFinalDBPageSetup()
903 bool OFinalDBPageSetup::IsDatabaseDocumentToBeRegistered() const
905 return m_xRBRegisterDataSource
->get_active() && m_xRBRegisterDataSource
->get_sensitive();
908 bool OFinalDBPageSetup::IsDatabaseDocumentToBeOpened() const
910 return m_xCBOpenAfterwards
->get_active() && m_xCBOpenAfterwards
->get_sensitive();
913 bool OFinalDBPageSetup::IsTableWizardToBeStarted() const
915 return m_xCBStartTableWizard
->get_active() && m_xCBStartTableWizard
->get_sensitive();
918 void OFinalDBPageSetup::fillWindows(std::vector
< std::unique_ptr
<ISaveValueWrapper
> >& _rControlList
)
920 _rControlList
.emplace_back(new ODisableWidgetWrapper
<weld::Label
>(m_xFTFinalHeader
.get()));
921 _rControlList
.emplace_back(new ODisableWidgetWrapper
<weld::Label
>(m_xFTFinalHelpText
.get()));
922 _rControlList
.emplace_back(new ODisableWidgetWrapper
<weld::Label
>(m_xFTAdditionalSettings
.get()));
923 _rControlList
.emplace_back(new ODisableWidgetWrapper
<weld::Label
>(m_xFTFinalText
.get()));
926 void OFinalDBPageSetup::fillControls(std::vector
< std::unique_ptr
<ISaveValueWrapper
> >& _rControlList
)
928 _rControlList
.emplace_back(new OSaveValueWidgetWrapper
<weld::Toggleable
>(m_xCBOpenAfterwards
.get()));
929 _rControlList
.emplace_back(new OSaveValueWidgetWrapper
<weld::Toggleable
>(m_xCBStartTableWizard
.get()));
930 _rControlList
.emplace_back(new OSaveValueWidgetWrapper
<weld::Toggleable
>(m_xRBRegisterDataSource
.get()));
931 _rControlList
.emplace_back(new OSaveValueWidgetWrapper
<weld::Toggleable
>(m_xRBDontregisterDataSource
.get()));
934 void OFinalDBPageSetup::implInitControls(const SfxItemSet
& /*_rSet*/, bool /*_bSaveValue*/)
936 m_xCBOpenAfterwards
->set_active(true);
939 void OFinalDBPageSetup::enableTableWizardCheckBox( bool _bSupportsTableCreation
)
941 m_xCBStartTableWizard
->set_sensitive(_bSupportsTableCreation
);
944 bool OFinalDBPageSetup::FillItemSet( SfxItemSet
* /*_rSet*/ )
949 IMPL_LINK(OFinalDBPageSetup
, OnOpenSelected
, weld::Toggleable
&, rBox
, void)
951 m_xCBStartTableWizard
->set_sensitive(rBox
.get_sensitive() && rBox
.get_active());
957 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */