Gtk-WARNING gtktreestore.c:1047: Invalid column number 1 added to iter
[LibreOffice.git] / dbaccess / source / ui / dlg / detailpages.cxx
blob65af148913baf99503e9a880fd1d76c5f62cec52
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
21 #include <core_resource.hxx>
22 #include "detailpages.hxx"
23 #include <sqlmessage.hxx>
24 #include <dsmeta.hxx>
25 #include "advancedsettings.hxx"
26 #include "DbAdminImpl.hxx"
27 #include <dsitems.hxx>
28 #include "dbfindex.hxx"
29 #include "dsnItem.hxx"
31 #include <IItemSetHelper.hxx>
32 #include <strings.hrc>
34 #include <svl/itemset.hxx>
35 #include <svl/stritem.hxx>
36 #include <svl/eitem.hxx>
37 #include <svl/intitem.hxx>
38 #if HAVE_FEATURE_JAVA
39 #include <jvmaccess/virtualmachine.hxx>
40 #endif
41 #include <connectivity/CommonTools.hxx>
42 #include "DriverSettings.hxx"
44 namespace dbaui
47 using namespace ::com::sun::star::uno;
49 OCommonBehaviourTabPage::OCommonBehaviourTabPage(weld::Container* pPage, weld::DialogController* pController,
50 const OUString& rUIXMLDescription, const OUString& rId, const SfxItemSet& rCoreAttrs,
51 OCommonBehaviourTabPageFlags nControlFlags)
52 : OGenericAdministrationPage(pPage, pController, rUIXMLDescription, rId, rCoreAttrs)
53 , m_nControlFlags(nControlFlags)
55 if (m_nControlFlags & OCommonBehaviourTabPageFlags::UseOptions)
57 m_xOptionsLabel = m_xBuilder->weld_label(u"optionslabel"_ustr);
58 m_xOptionsLabel->show();
59 m_xOptions = m_xBuilder->weld_entry(u"options"_ustr);
60 m_xOptions->show();
61 m_xOptions->connect_changed(LINK(this,OGenericAdministrationPage,OnControlEntryModifyHdl));
64 if (m_nControlFlags & OCommonBehaviourTabPageFlags::UseCharset)
66 m_xDataConvertLabel = m_xBuilder->weld_label(u"charsetheader"_ustr);
67 m_xDataConvertLabel->show();
68 m_xCharsetLabel = m_xBuilder->weld_label(u"charsetlabel"_ustr);
69 m_xCharsetLabel->show();
70 m_xCharset.reset(new CharSetListBox(m_xBuilder->weld_combo_box(u"charset"_ustr)));
71 m_xCharset->show();
72 m_xCharset->connect_changed(LINK(this, OCommonBehaviourTabPage, CharsetSelectHdl));
76 IMPL_LINK_NOARG(OCommonBehaviourTabPage, CharsetSelectHdl, weld::ComboBox&, void)
78 callModifiedHdl();
81 OCommonBehaviourTabPage::~OCommonBehaviourTabPage()
83 m_xCharset.reset();
86 void OCommonBehaviourTabPage::fillWindows(std::vector< std::unique_ptr<ISaveValueWrapper> >& _rControlList)
88 if (m_nControlFlags & OCommonBehaviourTabPageFlags::UseOptions)
90 _rControlList.emplace_back(new ODisableWidgetWrapper<weld::Label>(m_xOptionsLabel.get()));
93 if (m_nControlFlags & OCommonBehaviourTabPageFlags::UseCharset)
95 _rControlList.emplace_back(new ODisableWidgetWrapper<weld::Label>(m_xCharsetLabel.get()));
99 void OCommonBehaviourTabPage::fillControls(std::vector< std::unique_ptr<ISaveValueWrapper> >& _rControlList)
101 if (m_nControlFlags & OCommonBehaviourTabPageFlags::UseOptions)
102 _rControlList.emplace_back(new OSaveValueWidgetWrapper<weld::Entry>(m_xOptions.get()));
104 if (m_nControlFlags & OCommonBehaviourTabPageFlags::UseCharset)
105 _rControlList.emplace_back(new OSaveValueWidgetWrapper<weld::ComboBox>(m_xCharset->get_widget()));
108 void OCommonBehaviourTabPage::implInitControls(const SfxItemSet& _rSet, bool _bSaveValue)
110 // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
111 bool bValid, bReadonly;
112 getFlags(_rSet, bValid, bReadonly);
114 // collect the items
115 const SfxStringItem* pOptionsItem = _rSet.GetItem<SfxStringItem>(DSID_ADDITIONALOPTIONS);
116 const SfxStringItem* pCharsetItem = _rSet.GetItem<SfxStringItem>(DSID_CHARSET);
118 // forward the values to the controls
119 if (bValid)
121 if (m_nControlFlags & OCommonBehaviourTabPageFlags::UseOptions)
123 m_xOptions->set_text(pOptionsItem->GetValue());
124 m_xOptions->save_value();
127 if (m_nControlFlags & OCommonBehaviourTabPageFlags::UseCharset)
129 m_xCharset->SelectEntryByIanaName( pCharsetItem->GetValue() );
132 OGenericAdministrationPage::implInitControls(_rSet, _bSaveValue);
135 bool OCommonBehaviourTabPage::FillItemSet(SfxItemSet* _rSet)
137 bool bChangedSomething = false;
139 if (m_nControlFlags & OCommonBehaviourTabPageFlags::UseOptions)
141 fillString(*_rSet,m_xOptions.get(),DSID_ADDITIONALOPTIONS,bChangedSomething);
144 if (m_nControlFlags & OCommonBehaviourTabPageFlags::UseCharset)
146 if ( m_xCharset->StoreSelectedCharSet( *_rSet, DSID_CHARSET ) )
147 bChangedSomething = true;
150 return bChangedSomething;
153 // ODbaseDetailsPage
154 ODbaseDetailsPage::ODbaseDetailsPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& _rCoreAttrs)
155 : OCommonBehaviourTabPage(pPage, pController, u"dbaccess/ui/dbasepage.ui"_ustr, u"DbasePage"_ustr,
156 _rCoreAttrs, OCommonBehaviourTabPageFlags::UseCharset)
157 , m_xShowDeleted(m_xBuilder->weld_check_button(u"showDelRowsCheckbutton"_ustr))
158 , m_xFT_Message(m_xBuilder->weld_label(u"specMessageLabel"_ustr))
159 , m_xIndexes(m_xBuilder->weld_button(u"indiciesButton"_ustr))
161 m_xIndexes->connect_clicked(LINK(this, ODbaseDetailsPage, OnButtonClicked));
162 m_xShowDeleted->connect_toggled(LINK(this, ODbaseDetailsPage, OnButtonToggled));
165 ODbaseDetailsPage::~ODbaseDetailsPage()
169 std::unique_ptr<SfxTabPage> ODriversSettings::CreateDbase(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* _rAttrSet)
171 return std::make_unique<ODbaseDetailsPage>(pPage, pController, *_rAttrSet);
174 void ODbaseDetailsPage::implInitControls(const SfxItemSet& _rSet, bool _bSaveValue)
176 // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
177 bool bValid, bReadonly;
178 getFlags(_rSet, bValid, bReadonly);
180 // get the DSN string (needed for the index dialog)
181 const SfxStringItem* pUrlItem = _rSet.GetItem<SfxStringItem>(DSID_CONNECTURL);
182 const DbuTypeCollectionItem* pTypesItem = _rSet.GetItem<DbuTypeCollectionItem>(DSID_TYPECOLLECTION);
183 ::dbaccess::ODsnTypeCollection* pTypeCollection = pTypesItem ? pTypesItem->getCollection() : nullptr;
184 if (pTypeCollection && pUrlItem && pUrlItem->GetValue().getLength())
185 m_sDsn = pTypeCollection->cutPrefix(pUrlItem->GetValue());
187 // get the other relevant items
188 const SfxBoolItem* pDeletedItem = _rSet.GetItem<SfxBoolItem>(DSID_SHOWDELETEDROWS);
190 if ( bValid )
192 m_xShowDeleted->set_active(pDeletedItem->GetValue());
193 m_xFT_Message->set_visible(m_xShowDeleted->get_active());
196 OCommonBehaviourTabPage::implInitControls(_rSet, _bSaveValue);
199 bool ODbaseDetailsPage::FillItemSet( SfxItemSet* _rSet )
201 bool bChangedSomething = OCommonBehaviourTabPage::FillItemSet(_rSet);
203 fillBool(*_rSet, m_xShowDeleted.get(), DSID_SHOWDELETEDROWS, false, bChangedSomething);
204 return bChangedSomething;
207 IMPL_LINK_NOARG(ODbaseDetailsPage, OnButtonClicked, weld::Button&, void)
209 ODbaseIndexDialog aIndexDialog(GetFrameWeld(), m_sDsn);
210 aIndexDialog.run();
213 IMPL_LINK_NOARG(ODbaseDetailsPage, OnButtonToggled, weld::Toggleable&, void)
215 m_xFT_Message->set_visible(m_xShowDeleted->get_active());
216 // it was the checkbox -> we count as modified from now on
217 callModifiedHdl();
221 // OAdoDetailsPage
222 OAdoDetailsPage::OAdoDetailsPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rCoreAttrs)
223 : OCommonBehaviourTabPage(pPage, pController, u"dbaccess/ui/autocharsetpage.ui"_ustr, u"AutoCharset"_ustr,
224 rCoreAttrs, OCommonBehaviourTabPageFlags::UseCharset )
229 std::unique_ptr<SfxTabPage> ODriversSettings::CreateAdo(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet)
231 return std::make_unique<OAdoDetailsPage>(pPage, pController, *rAttrSet);
234 // OOdbcDetailsPage
235 OOdbcDetailsPage::OOdbcDetailsPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rCoreAttrs)
236 : OCommonBehaviourTabPage(pPage, pController, u"dbaccess/ui/odbcpage.ui"_ustr, u"ODBC"_ustr, rCoreAttrs,
237 OCommonBehaviourTabPageFlags::UseCharset | OCommonBehaviourTabPageFlags::UseOptions)
238 , m_xUseCatalog(m_xBuilder->weld_check_button(u"useCatalogCheckbutton"_ustr))
240 m_xUseCatalog->connect_toggled(LINK(this, OGenericAdministrationPage, OnControlModifiedButtonClick));
243 OOdbcDetailsPage::~OOdbcDetailsPage()
247 std::unique_ptr<SfxTabPage> ODriversSettings::CreateODBC(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* pAttrSet)
249 return std::make_unique<OOdbcDetailsPage>(pPage, pController, *pAttrSet);
252 bool OOdbcDetailsPage::FillItemSet( SfxItemSet* _rSet )
254 bool bChangedSomething = OCommonBehaviourTabPage::FillItemSet(_rSet);
255 fillBool(*_rSet,m_xUseCatalog.get(),DSID_USECATALOG,false,bChangedSomething);
256 return bChangedSomething;
258 void OOdbcDetailsPage::implInitControls(const SfxItemSet& _rSet, bool _bSaveValue)
260 // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
261 bool bValid, bReadonly;
262 getFlags(_rSet, bValid, bReadonly);
264 const SfxBoolItem* pUseCatalogItem = _rSet.GetItem<SfxBoolItem>(DSID_USECATALOG);
266 if ( bValid )
267 m_xUseCatalog->set_active(pUseCatalogItem->GetValue());
269 OCommonBehaviourTabPage::implInitControls(_rSet, _bSaveValue);
271 // OOdbcDetailsPage
272 OUserDriverDetailsPage::OUserDriverDetailsPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rCoreAttrs)
273 : OCommonBehaviourTabPage(pPage, pController, u"dbaccess/ui/userdetailspage.ui"_ustr, u"UserDetailsPage"_ustr,
274 rCoreAttrs, OCommonBehaviourTabPageFlags::UseCharset | OCommonBehaviourTabPageFlags::UseOptions)
275 , m_xFTHostname(m_xBuilder->weld_label(u"hostnameft"_ustr))
276 , m_xEDHostname(m_xBuilder->weld_entry(u"hostname"_ustr))
277 , m_xPortNumber(m_xBuilder->weld_label(u"portnumberft"_ustr))
278 , m_xNFPortNumber(m_xBuilder->weld_spin_button(u"portnumber"_ustr))
279 , m_xUseCatalog(m_xBuilder->weld_check_button(u"usecatalog"_ustr))
281 m_xUseCatalog->connect_toggled(LINK(this, OGenericAdministrationPage, OnControlModifiedButtonClick));
284 OUserDriverDetailsPage::~OUserDriverDetailsPage()
288 std::unique_ptr<SfxTabPage> ODriversSettings::CreateUser(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* pAttrSet)
290 return std::make_unique<OUserDriverDetailsPage>(pPage, pController, *pAttrSet);
293 bool OUserDriverDetailsPage::FillItemSet( SfxItemSet* _rSet )
295 bool bChangedSomething = OCommonBehaviourTabPage::FillItemSet(_rSet);
297 fillInt32(*_rSet,m_xNFPortNumber.get(),DSID_CONN_PORTNUMBER,bChangedSomething);
298 fillString(*_rSet,m_xEDHostname.get(),DSID_CONN_HOSTNAME,bChangedSomething);
299 fillBool(*_rSet,m_xUseCatalog.get(),DSID_USECATALOG,false,bChangedSomething);
301 return bChangedSomething;
303 void OUserDriverDetailsPage::fillControls(std::vector< std::unique_ptr<ISaveValueWrapper> >& _rControlList)
305 OCommonBehaviourTabPage::fillControls(_rControlList);
306 _rControlList.emplace_back(new OSaveValueWidgetWrapper<weld::Entry>(m_xEDHostname.get()));
307 _rControlList.emplace_back(new OSaveValueWidgetWrapper<weld::Toggleable>(m_xUseCatalog.get()));
308 _rControlList.emplace_back(new OSaveValueWidgetWrapper<weld::SpinButton>(m_xNFPortNumber.get()));
310 void OUserDriverDetailsPage::fillWindows(std::vector< std::unique_ptr<ISaveValueWrapper> >& _rControlList)
312 OCommonBehaviourTabPage::fillWindows(_rControlList);
313 _rControlList.emplace_back(new ODisableWidgetWrapper<weld::Label>(m_xFTHostname.get()));
314 _rControlList.emplace_back(new ODisableWidgetWrapper<weld::Label>(m_xPortNumber.get()));
316 void OUserDriverDetailsPage::implInitControls(const SfxItemSet& _rSet, bool _bSaveValue)
318 // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
319 bool bValid, bReadonly;
320 getFlags(_rSet, bValid, bReadonly);
322 const SfxBoolItem* pUseCatalogItem = _rSet.GetItem<SfxBoolItem>(DSID_USECATALOG);
323 const SfxStringItem* pHostName = _rSet.GetItem<SfxStringItem>(DSID_CONN_HOSTNAME);
324 const SfxInt32Item* pPortNumber = _rSet.GetItem<SfxInt32Item>(DSID_CONN_PORTNUMBER);
326 if ( bValid )
328 m_xEDHostname->set_text(pHostName->GetValue());
329 m_xEDHostname->save_value();
331 m_xNFPortNumber->set_value(pPortNumber->GetValue());
332 m_xNFPortNumber->save_value();
334 m_xUseCatalog->set_active(pUseCatalogItem->GetValue());
337 OCommonBehaviourTabPage::implInitControls(_rSet, _bSaveValue);
339 // OMySQLODBCDetailsPage
340 OMySQLODBCDetailsPage::OMySQLODBCDetailsPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rCoreAttrs)
341 : OCommonBehaviourTabPage(pPage, pController, u"dbaccess/ui/autocharsetpage.ui"_ustr, u"AutoCharset"_ustr,
342 rCoreAttrs, OCommonBehaviourTabPageFlags::UseCharset )
346 std::unique_ptr<SfxTabPage> ODriversSettings::CreateMySQLODBC(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* pAttrSet)
348 return std::make_unique<OMySQLODBCDetailsPage>(pPage, pController, *pAttrSet);
351 // OMySQLJDBCDetailsPage
352 OGeneralSpecialJDBCDetailsPage::OGeneralSpecialJDBCDetailsPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rCoreAttrs ,sal_uInt16 _nPortId, bool bShowSocket)
353 : OCommonBehaviourTabPage(pPage, pController, u"dbaccess/ui/generalspecialjdbcdetailspage.ui"_ustr, u"GeneralSpecialJDBCDetails"_ustr,
354 rCoreAttrs, OCommonBehaviourTabPageFlags::UseCharset)
355 , m_nPortId(_nPortId)
356 , m_bUseClass(true)
357 , m_xEDHostname(m_xBuilder->weld_entry(u"hostNameEntry"_ustr))
358 , m_xNFPortNumber(m_xBuilder->weld_spin_button(u"portNumberSpinbutton"_ustr))
359 , m_xFTSocket(m_xBuilder->weld_label(u"socketLabel"_ustr))
360 , m_xEDSocket(m_xBuilder->weld_entry(u"socketEntry"_ustr))
361 , m_xFTDriverClass(m_xBuilder->weld_label(u"driverClassLabel"_ustr))
362 , m_xEDDriverClass(m_xBuilder->weld_entry(u"jdbcDriverClassEntry"_ustr))
363 , m_xTestJavaDriver(m_xBuilder->weld_button(u"testDriverClassButton"_ustr))
365 const SfxStringItem* pUrlItem = rCoreAttrs.GetItem<SfxStringItem>(DSID_CONNECTURL);
366 const DbuTypeCollectionItem* pTypesItem = rCoreAttrs.GetItem<DbuTypeCollectionItem>(DSID_TYPECOLLECTION);
367 ::dbaccess::ODsnTypeCollection* pTypeCollection = pTypesItem ? pTypesItem->getCollection() : nullptr;
368 if (pTypeCollection && pUrlItem && pUrlItem->GetValue().getLength() )
370 m_sDefaultJdbcDriverName = pTypeCollection->getJavaDriverClass(pUrlItem->GetValue());
372 if ( m_sDefaultJdbcDriverName.getLength() )
374 m_xEDDriverClass->connect_changed(LINK(this,OGenericAdministrationPage,OnControlEntryModifyHdl));
375 m_xTestJavaDriver->connect_clicked(LINK(this,OGeneralSpecialJDBCDetailsPage,OnTestJavaClickHdl));
377 else
379 m_bUseClass = false;
380 m_xFTDriverClass->hide();
381 m_xEDDriverClass->hide();
382 m_xTestJavaDriver->hide();
385 m_xFTSocket->set_visible(bShowSocket && !m_bUseClass);
386 m_xEDSocket->set_visible(bShowSocket && !m_bUseClass);
388 m_xEDHostname->connect_changed(LINK(this,OGenericAdministrationPage,OnControlEntryModifyHdl));
389 m_xNFPortNumber->connect_value_changed(LINK(this,OGenericAdministrationPage,OnControlSpinButtonModifyHdl));
390 m_xEDSocket->connect_changed(LINK(this,OGenericAdministrationPage,OnControlEntryModifyHdl));
393 OGeneralSpecialJDBCDetailsPage::~OGeneralSpecialJDBCDetailsPage()
397 bool OGeneralSpecialJDBCDetailsPage::FillItemSet( SfxItemSet* _rSet )
399 bool bChangedSomething = OCommonBehaviourTabPage::FillItemSet(_rSet);
400 if ( m_bUseClass )
401 fillString(*_rSet,m_xEDDriverClass.get(),DSID_JDBCDRIVERCLASS,bChangedSomething);
402 fillString(*_rSet,m_xEDHostname.get(),DSID_CONN_HOSTNAME,bChangedSomething);
403 fillString(*_rSet,m_xEDSocket.get(),DSID_CONN_SOCKET,bChangedSomething);
404 fillInt32(*_rSet,m_xNFPortNumber.get(),m_nPortId,bChangedSomething );
406 return bChangedSomething;
408 void OGeneralSpecialJDBCDetailsPage::implInitControls(const SfxItemSet& _rSet, bool _bSaveValue)
410 // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
411 bool bValid, bReadonly;
412 getFlags(_rSet, bValid, bReadonly);
414 const SfxStringItem* pDrvItem = _rSet.GetItem<SfxStringItem>(DSID_JDBCDRIVERCLASS);
415 const SfxStringItem* pHostName = _rSet.GetItem<SfxStringItem>(DSID_CONN_HOSTNAME);
416 const SfxInt32Item* pPortNumber = _rSet.GetItem<SfxInt32Item>(m_nPortId);
417 const SfxStringItem* pSocket = _rSet.GetItem<SfxStringItem>(DSID_CONN_SOCKET);
419 if ( bValid )
421 if ( m_bUseClass )
423 m_xEDDriverClass->set_text(pDrvItem->GetValue());
424 m_xEDDriverClass->save_value();
427 m_xEDHostname->set_text(pHostName->GetValue());
428 m_xEDHostname->save_value();
430 m_xNFPortNumber->set_value(pPortNumber->GetValue());
431 m_xNFPortNumber->save_value();
433 m_xEDSocket->set_text(pSocket->GetValue());
434 m_xEDSocket->save_value();
437 OCommonBehaviourTabPage::implInitControls(_rSet, _bSaveValue);
439 // to get the correct value when saveValue was called by base class
440 if ( m_bUseClass && o3tl::trim(m_xEDDriverClass->get_text()).empty() )
442 m_xEDDriverClass->set_text(m_sDefaultJdbcDriverName);
443 m_xEDDriverClass->save_value();
446 IMPL_LINK_NOARG(OGeneralSpecialJDBCDetailsPage, OnTestJavaClickHdl, weld::Button&, void)
448 assert(m_pAdminDialog && "No Admin dialog set! ->GPF");
449 OSL_ENSURE(m_bUseClass,"Who called me?");
451 bool bSuccess = false;
452 #if HAVE_FEATURE_JAVA
455 if (!o3tl::trim(m_xEDDriverClass->get_text()).empty())
457 // TODO change jvmaccess
458 ::rtl::Reference< jvmaccess::VirtualMachine > xJVM = ::connectivity::getJavaVM( m_pAdminDialog->getORB() );
459 m_xEDDriverClass->set_text(m_xEDDriverClass->get_text().trim()); // fdo#68341
460 bSuccess = ::connectivity::existsJavaClassByName(xJVM,m_xEDDriverClass->get_text());
463 catch(Exception&)
466 #endif
467 TranslateId pMessage = bSuccess ? STR_JDBCDRIVER_SUCCESS : STR_JDBCDRIVER_NO_SUCCESS;
468 const MessageType mt = bSuccess ? MessageType::Info : MessageType::Error;
469 OSQLMessageBox aMsg(GetFrameWeld(), DBA_RES(pMessage), OUString(), MessBoxStyle::Ok | MessBoxStyle::DefaultOk, mt);
470 aMsg.run();
473 void OGeneralSpecialJDBCDetailsPage::callModifiedHdl(weld::Widget* pControl)
475 if (m_bUseClass && pControl == m_xEDDriverClass.get())
476 m_xTestJavaDriver->set_sensitive(!o3tl::trim(m_xEDDriverClass->get_text()).empty());
478 // tell the listener we were modified
479 OGenericAdministrationPage::callModifiedHdl();
482 // MySQLNativePage
483 MySQLNativePage::MySQLNativePage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rCoreAttrs)
484 : OCommonBehaviourTabPage(pPage, pController, u"dbaccess/ui/mysqlnativepage.ui"_ustr, u"MysqlNativePage"_ustr, rCoreAttrs, OCommonBehaviourTabPageFlags::UseCharset)
485 , m_xMySQLSettingsContainer(m_xBuilder->weld_widget(u"MySQLSettingsContainer"_ustr))
486 , m_xMySQLSettings(new MySQLNativeSettings(m_xMySQLSettingsContainer.get(), LINK(this,OGenericAdministrationPage,OnControlModified)))
487 , m_xSeparator1(m_xBuilder->weld_label(u"connectionheader"_ustr))
488 , m_xSeparator2(m_xBuilder->weld_label(u"userheader"_ustr))
489 , m_xUserNameLabel(m_xBuilder->weld_label(u"usernamelabel"_ustr))
490 , m_xUserName(m_xBuilder->weld_entry(u"username"_ustr))
491 , m_xPasswordRequired(m_xBuilder->weld_check_button(u"passwordrequired"_ustr))
493 m_xUserName->connect_changed(LINK(this,OGenericAdministrationPage,OnControlEntryModifyHdl));
496 MySQLNativePage::~MySQLNativePage()
498 m_xMySQLSettings.reset();
501 void MySQLNativePage::fillControls(std::vector< std::unique_ptr<ISaveValueWrapper> >& _rControlList)
503 OCommonBehaviourTabPage::fillControls( _rControlList );
504 m_xMySQLSettings->fillControls( _rControlList );
506 _rControlList.emplace_back(new OSaveValueWidgetWrapper<weld::Entry>(m_xUserName.get()));
507 _rControlList.emplace_back(new OSaveValueWidgetWrapper<weld::Toggleable>(m_xPasswordRequired.get()));
510 void MySQLNativePage::fillWindows(std::vector< std::unique_ptr<ISaveValueWrapper> >& _rControlList)
512 OCommonBehaviourTabPage::fillWindows( _rControlList );
513 m_xMySQLSettings->fillWindows( _rControlList);
515 _rControlList.emplace_back(new ODisableWidgetWrapper<weld::Label>(m_xSeparator1.get()));
516 _rControlList.emplace_back(new ODisableWidgetWrapper<weld::Label>(m_xSeparator2.get()));
517 _rControlList.emplace_back(new ODisableWidgetWrapper<weld::Label>(m_xUserNameLabel.get()));
520 bool MySQLNativePage::FillItemSet( SfxItemSet* _rSet )
522 bool bChangedSomething = OCommonBehaviourTabPage::FillItemSet( _rSet );
524 bChangedSomething |= m_xMySQLSettings->FillItemSet( _rSet );
526 if (m_xUserName->get_value_changed_from_saved())
528 _rSet->Put( SfxStringItem( DSID_USER, m_xUserName->get_text() ) );
529 _rSet->Put( SfxStringItem( DSID_PASSWORD, OUString()));
530 bChangedSomething = true;
532 fillBool(*_rSet,m_xPasswordRequired.get(),DSID_PASSWORDREQUIRED,false,bChangedSomething);
534 return bChangedSomething;
536 void MySQLNativePage::implInitControls(const SfxItemSet& _rSet, bool _bSaveValue)
538 // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
539 bool bValid, bReadonly;
540 getFlags(_rSet, bValid, bReadonly);
542 m_xMySQLSettings->implInitControls( _rSet );
544 const SfxStringItem* pUidItem = _rSet.GetItem<SfxStringItem>(DSID_USER);
545 const SfxBoolItem* pAllowEmptyPwd = _rSet.GetItem<SfxBoolItem>(DSID_PASSWORDREQUIRED);
547 if ( bValid )
549 m_xUserName->set_text(pUidItem->GetValue());
550 m_xUserName->save_value();
551 m_xPasswordRequired->set_active(pAllowEmptyPwd->GetValue());
554 OCommonBehaviourTabPage::implInitControls(_rSet, _bSaveValue);
557 std::unique_ptr<SfxTabPage> ODriversSettings::CreateMySQLJDBC( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* _rAttrSet )
559 return std::make_unique<OGeneralSpecialJDBCDetailsPage>(pPage, pController, *_rAttrSet,DSID_MYSQL_PORTNUMBER);
562 std::unique_ptr<SfxTabPage> ODriversSettings::CreateMySQLNATIVE(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* pAttrSet)
564 return std::make_unique<MySQLNativePage>(pPage, pController, *pAttrSet);
567 std::unique_ptr<SfxTabPage> ODriversSettings::CreateOracleJDBC(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* _rAttrSet)
569 return std::make_unique<OGeneralSpecialJDBCDetailsPage>(pPage, pController, *_rAttrSet,DSID_ORACLE_PORTNUMBER, false);
572 // OLDAPDetailsPage
573 OLDAPDetailsPage::OLDAPDetailsPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rCoreAttrs)
574 : OCommonBehaviourTabPage(pPage, pController, u"dbaccess/ui/ldappage.ui"_ustr, u"LDAP"_ustr,
575 rCoreAttrs, OCommonBehaviourTabPageFlags::NONE)
576 , m_xETBaseDN(m_xBuilder->weld_entry(u"baseDNEntry"_ustr))
577 , m_xCBUseSSL(m_xBuilder->weld_check_button(u"useSSLCheckbutton"_ustr))
578 , m_xNFPortNumber(m_xBuilder->weld_spin_button(u"portNumberSpinbutton"_ustr))
579 , m_xNFRowCount(m_xBuilder->weld_spin_button(u"LDAPRowCountspinbutton"_ustr))
581 m_xETBaseDN->connect_changed(LINK(this,OGenericAdministrationPage,OnControlEntryModifyHdl));
582 m_xNFPortNumber->connect_value_changed(LINK(this,OGenericAdministrationPage,OnControlSpinButtonModifyHdl));
583 m_xNFRowCount->connect_value_changed(LINK(this,OGenericAdministrationPage,OnControlSpinButtonModifyHdl));
585 m_iNormalPort = 389;
586 m_iSSLPort = 636;
587 m_xCBUseSSL->connect_toggled(LINK(this, OLDAPDetailsPage, OnCheckBoxClick));
590 OLDAPDetailsPage::~OLDAPDetailsPage()
594 std::unique_ptr<SfxTabPage> ODriversSettings::CreateLDAP(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* _rAttrSet)
596 return std::make_unique<OLDAPDetailsPage>(pPage, pController, *_rAttrSet);
599 bool OLDAPDetailsPage::FillItemSet( SfxItemSet* _rSet )
601 bool bChangedSomething = OCommonBehaviourTabPage::FillItemSet(_rSet);
603 fillString(*_rSet,m_xETBaseDN.get(),DSID_CONN_LDAP_BASEDN,bChangedSomething);
604 fillInt32(*_rSet,m_xNFPortNumber.get(),DSID_CONN_LDAP_PORTNUMBER,bChangedSomething);
605 fillInt32(*_rSet,m_xNFRowCount.get(),DSID_CONN_LDAP_ROWCOUNT,bChangedSomething);
606 fillBool(*_rSet,m_xCBUseSSL.get(),DSID_CONN_LDAP_USESSL,false,bChangedSomething);
607 return bChangedSomething;
610 IMPL_LINK(OLDAPDetailsPage, OnCheckBoxClick, weld::Toggleable&, rCheckBox, void)
612 OnControlModifiedButtonClick(rCheckBox);
613 callModifiedHdl();
614 if (m_xCBUseSSL->get_active())
616 m_iNormalPort = m_xNFPortNumber->get_value();
617 m_xNFPortNumber->set_value(m_iSSLPort);
619 else
621 m_iSSLPort = m_xNFPortNumber->get_value();
622 m_xNFPortNumber->set_value(m_iNormalPort);
626 void OLDAPDetailsPage::implInitControls(const SfxItemSet& _rSet, bool _bSaveValue)
628 // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
629 bool bValid, bReadonly;
630 getFlags(_rSet, bValid, bReadonly);
632 const SfxStringItem* pBaseDN = _rSet.GetItem<SfxStringItem>(DSID_CONN_LDAP_BASEDN);
633 const SfxBoolItem* pUseSSL = _rSet.GetItem<SfxBoolItem>(DSID_CONN_LDAP_USESSL);
634 const SfxInt32Item* pPortNumber = _rSet.GetItem<SfxInt32Item>(DSID_CONN_LDAP_PORTNUMBER);
635 const SfxInt32Item* pRowCount = _rSet.GetItem<SfxInt32Item>(DSID_CONN_LDAP_ROWCOUNT);
637 if ( bValid )
639 m_xETBaseDN->set_text(pBaseDN->GetValue());
640 m_xNFPortNumber->set_value(pPortNumber->GetValue());
641 m_xNFRowCount->set_value(pRowCount->GetValue());
642 m_xCBUseSSL->set_active(pUseSSL->GetValue());
645 OCommonBehaviourTabPage::implInitControls(_rSet, _bSaveValue);
648 // OTextDetailsPage
649 OTextDetailsPage::OTextDetailsPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rCoreAttrs)
650 : OCommonBehaviourTabPage(pPage, pController, u"dbaccess/ui/emptypage.ui"_ustr, u"EmptyPage"_ustr, rCoreAttrs, OCommonBehaviourTabPageFlags::NONE)
651 , m_xTextConnectionHelper(new OTextConnectionHelper(m_xContainer.get(), TC_EXTENSION | TC_HEADER | TC_SEPARATORS | TC_CHARSET))
655 OTextDetailsPage::~OTextDetailsPage()
657 m_xTextConnectionHelper.reset();
660 std::unique_ptr<SfxTabPage> ODriversSettings::CreateText(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* pAttrSet)
662 return std::make_unique<OTextDetailsPage>(pPage, pController, *pAttrSet);
665 void OTextDetailsPage::fillControls(std::vector< std::unique_ptr<ISaveValueWrapper> >& _rControlList)
667 OCommonBehaviourTabPage::fillControls(_rControlList);
668 m_xTextConnectionHelper->fillControls(_rControlList);
671 void OTextDetailsPage::fillWindows(std::vector< std::unique_ptr<ISaveValueWrapper> >& _rControlList)
673 OCommonBehaviourTabPage::fillWindows(_rControlList);
674 m_xTextConnectionHelper->fillWindows(_rControlList);
677 void OTextDetailsPage::implInitControls(const SfxItemSet& _rSet, bool _bSaveValue)
679 // first check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
680 bool bValid, bReadonly;
681 getFlags(_rSet, bValid, bReadonly);
683 m_xTextConnectionHelper->implInitControls(_rSet, bValid);
684 OCommonBehaviourTabPage::implInitControls(_rSet, _bSaveValue);
687 bool OTextDetailsPage::FillItemSet( SfxItemSet* rSet )
689 bool bChangedSomething = OCommonBehaviourTabPage::FillItemSet(rSet);
690 bChangedSomething = m_xTextConnectionHelper->FillItemSet(*rSet, bChangedSomething);
691 return bChangedSomething;
694 bool OTextDetailsPage::prepareLeave()
696 return m_xTextConnectionHelper->prepareLeave();
699 std::unique_ptr<SfxTabPage> ODriversSettings::CreateGeneratedValuesPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* _rAttrSet)
701 return std::make_unique<GeneratedValuesPage>(pPage, pController, *_rAttrSet);
704 std::unique_ptr<SfxTabPage> ODriversSettings::CreateSpecialSettingsPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* _rAttrSet)
706 OUString eType = ODbDataSourceAdministrationHelper::getDatasourceType( *_rAttrSet );
707 DataSourceMetaData aMetaData( eType );
708 return std::make_unique<SpecialSettingsPage>(pPage, pController, *_rAttrSet, aMetaData);
710 } // namespace dbaui
712 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */