fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / dbaccess / source / ui / dlg / detailpages.cxx
blobb090ddc8df06be3485a7ad326d735f71097191e6
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_features.h>
21 #include "detailpages.hxx"
22 #include "sqlmessage.hxx"
23 #include "dsmeta.hxx"
24 #include "advancedsettings.hxx"
25 #include "DbAdminImpl.hxx"
26 #include "dsitems.hxx"
27 #include "dbfindex.hxx"
28 #include "localresaccess.hxx"
29 #include "dsnItem.hxx"
31 #include "dbaccess_helpid.hrc"
32 #include "dbu_dlg.hrc"
34 #include <svl/itemset.hxx>
35 #include <svl/stritem.hxx>
36 #include <svl/eitem.hxx>
37 #include <svl/intitem.hxx>
38 #include <vcl/msgbox.hxx>
39 #include <vcl/mnemonic.hxx>
40 #include <svl/cjkoptions.hxx>
41 #if HAVE_FEATURE_JAVA
42 #include <jvmaccess/virtualmachine.hxx>
43 #endif
44 #include <connectivity/CommonTools.hxx>
45 #include "DriverSettings.hxx"
46 #include "dbadmin.hxx"
47 #include <comphelper/types.hxx>
49 namespace dbaui
52 using namespace ::com::sun::star::uno;
53 using namespace ::com::sun::star::sdbc;
54 using namespace ::com::sun::star::beans;
55 using namespace ::com::sun::star::lang;
56 using namespace ::com::sun::star::container;
57 using namespace ::dbtools;
59 OCommonBehaviourTabPage::OCommonBehaviourTabPage(vcl::Window* pParent, const OString& rId,
60 const OUString& rUIXMLDescription, const SfxItemSet& _rCoreAttrs,
61 sal_uInt32 nControlFlags)
63 :OGenericAdministrationPage(pParent, rId, rUIXMLDescription, _rCoreAttrs)
64 ,m_pOptionsLabel(NULL)
65 ,m_pOptions(NULL)
66 ,m_pCharsetLabel(NULL)
67 ,m_pCharset(NULL)
68 ,m_pAutoRetrievingEnabled(NULL)
69 ,m_pAutoIncrementLabel(NULL)
70 ,m_pAutoIncrement(NULL)
71 ,m_pAutoRetrievingLabel(NULL)
72 ,m_pAutoRetrieving(NULL)
73 ,m_nControlFlags(nControlFlags)
76 if ((m_nControlFlags & CBTP_USE_OPTIONS) == CBTP_USE_OPTIONS)
78 m_pOptionsLabel = get<FixedText>("optionslabel");
79 m_pOptionsLabel->Show();
80 m_pOptions = get<Edit>("options");
81 m_pOptions->Show();
82 m_pOptions->SetModifyHdl(getControlModifiedLink());
85 if ((m_nControlFlags & CBTP_USE_CHARSET) == CBTP_USE_CHARSET)
87 FixedText* pDataConvertLabel = get<FixedText>("charsetheader");
88 pDataConvertLabel->Show();
89 m_pCharsetLabel = get<FixedText>("charsetlabel");
90 m_pCharsetLabel->Show();
91 m_pCharset = get<CharSetListBox>("charset");
92 m_pCharset->Show();
93 m_pCharset->SetSelectHdl(getControlModifiedLink());
97 OCommonBehaviourTabPage::~OCommonBehaviourTabPage()
99 disposeOnce();
102 void OCommonBehaviourTabPage::dispose()
104 m_pOptionsLabel.disposeAndClear();
105 m_pOptions.disposeAndClear();
106 m_pCharsetLabel.disposeAndClear();
107 m_pCharset.disposeAndClear();
108 m_pAutoIncrementLabel.disposeAndClear();
109 m_pAutoIncrement.disposeAndClear();
110 m_pAutoRetrievingEnabled.disposeAndClear();
111 m_pAutoRetrievingLabel.disposeAndClear();
112 m_pAutoRetrieving.disposeAndClear();
113 OGenericAdministrationPage::dispose();
116 void OCommonBehaviourTabPage::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
118 if ((m_nControlFlags & CBTP_USE_OPTIONS) == CBTP_USE_OPTIONS)
120 _rControlList.push_back(new ODisableWrapper<FixedText>(m_pOptionsLabel));
123 if ((m_nControlFlags & CBTP_USE_CHARSET) == CBTP_USE_CHARSET)
125 _rControlList.push_back(new ODisableWrapper<FixedText>(m_pCharsetLabel));
128 void OCommonBehaviourTabPage::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
130 if ((m_nControlFlags & CBTP_USE_OPTIONS) == CBTP_USE_OPTIONS)
131 _rControlList.push_back(new OSaveValueWrapper<Edit>(m_pOptions));
133 if ((m_nControlFlags & CBTP_USE_CHARSET) == CBTP_USE_CHARSET)
134 _rControlList.push_back(new OSaveValueWrapper<ListBox>(m_pCharset));
137 void OCommonBehaviourTabPage::implInitControls(const SfxItemSet& _rSet, bool _bSaveValue)
139 // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
140 bool bValid, bReadonly;
141 getFlags(_rSet, bValid, bReadonly);
143 // collect the items
144 SFX_ITEMSET_GET(_rSet, pOptionsItem, SfxStringItem, DSID_ADDITIONALOPTIONS, true);
145 SFX_ITEMSET_GET(_rSet, pCharsetItem, SfxStringItem, DSID_CHARSET, true);
147 // forward the values to the controls
148 if (bValid)
150 if ((m_nControlFlags & CBTP_USE_OPTIONS) == CBTP_USE_OPTIONS)
152 m_pOptions->SetText(pOptionsItem->GetValue());
153 m_pOptions->ClearModifyFlag();
156 if ((m_nControlFlags & CBTP_USE_CHARSET) == CBTP_USE_CHARSET)
158 m_pCharset->SelectEntryByIanaName( pCharsetItem->GetValue() );
161 OGenericAdministrationPage::implInitControls(_rSet, _bSaveValue);
164 bool OCommonBehaviourTabPage::FillItemSet(SfxItemSet* _rSet)
166 bool bChangedSomething = false;
168 if ((m_nControlFlags & CBTP_USE_OPTIONS) == CBTP_USE_OPTIONS)
170 fillString(*_rSet,m_pOptions,DSID_ADDITIONALOPTIONS,bChangedSomething);
173 if ((m_nControlFlags & CBTP_USE_CHARSET) == CBTP_USE_CHARSET)
175 if ( m_pCharset->StoreSelectedCharSet( *_rSet, DSID_CHARSET ) )
176 bChangedSomething = true;
179 return bChangedSomething;
182 // ODbaseDetailsPage
183 ODbaseDetailsPage::ODbaseDetailsPage( vcl::Window* pParent, const SfxItemSet& _rCoreAttrs )
184 :OCommonBehaviourTabPage(pParent, "DbasePage", "dbaccess/ui/dbasepage.ui", _rCoreAttrs, CBTP_USE_CHARSET)
186 get(m_pShowDeleted, "showDelRowsCheckbutton");
187 get(m_pFT_Message, "specMessageLabel");
188 get(m_pIndexes, "indiciesButton");
189 set_height_request(300);
191 m_pIndexes->SetClickHdl(LINK(this, ODbaseDetailsPage, OnButtonClicked));
192 m_pShowDeleted->SetClickHdl(LINK(this, ODbaseDetailsPage, OnButtonClicked));
195 ODbaseDetailsPage::~ODbaseDetailsPage()
197 disposeOnce();
200 void ODbaseDetailsPage::dispose()
202 m_pShowDeleted.clear();
203 m_pFT_Message.clear();
204 m_pIndexes.clear();
205 OCommonBehaviourTabPage::dispose();
208 VclPtr<SfxTabPage> ODriversSettings::CreateDbase( vcl::Window* pParent, const SfxItemSet* _rAttrSet )
210 return VclPtr<ODbaseDetailsPage>::Create( pParent, *_rAttrSet );
213 void ODbaseDetailsPage::implInitControls(const SfxItemSet& _rSet, bool _bSaveValue)
215 // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
216 bool bValid, bReadonly;
217 getFlags(_rSet, bValid, bReadonly);
219 // get the DSN string (needed for the index dialog)
220 SFX_ITEMSET_GET(_rSet, pUrlItem, SfxStringItem, DSID_CONNECTURL, true);
221 SFX_ITEMSET_GET(_rSet, pTypesItem, DbuTypeCollectionItem, DSID_TYPECOLLECTION, true);
222 ::dbaccess::ODsnTypeCollection* pTypeCollection = pTypesItem ? pTypesItem->getCollection() : NULL;
223 if (pTypeCollection && pUrlItem && pUrlItem->GetValue().getLength())
224 m_sDsn = pTypeCollection->cutPrefix(pUrlItem->GetValue());
226 // get the other relevant items
227 SFX_ITEMSET_GET(_rSet, pDeletedItem, SfxBoolItem, DSID_SHOWDELETEDROWS, true);
229 if ( bValid )
231 m_pShowDeleted->Check( pDeletedItem->GetValue() );
232 m_pFT_Message->Show(m_pShowDeleted->IsChecked());
235 OCommonBehaviourTabPage::implInitControls(_rSet, _bSaveValue);
238 bool ODbaseDetailsPage::FillItemSet( SfxItemSet* _rSet )
240 bool bChangedSomething = OCommonBehaviourTabPage::FillItemSet(_rSet);
242 fillBool(*_rSet,m_pShowDeleted,DSID_SHOWDELETEDROWS,bChangedSomething);
243 return bChangedSomething;
246 IMPL_LINK( ODbaseDetailsPage, OnButtonClicked, Button*, pButton )
248 if (m_pIndexes == pButton)
250 ScopedVclPtrInstance< ODbaseIndexDialog > aIndexDialog(this, m_sDsn);
251 aIndexDialog->Execute();
253 else
255 m_pFT_Message->Show(m_pShowDeleted->IsChecked());
256 // it was one of the checkboxes -> we count as modified from now on
257 callModifiedHdl();
260 return 0;
263 // OAdoDetailsPage
264 OAdoDetailsPage::OAdoDetailsPage( vcl::Window* pParent, const SfxItemSet& _rCoreAttrs )
265 :OCommonBehaviourTabPage(pParent, "AutoCharset", "dbaccess/ui/autocharsetpage.ui", _rCoreAttrs, CBTP_USE_CHARSET )
270 VclPtr<SfxTabPage> ODriversSettings::CreateAdo( vcl::Window* pParent, const SfxItemSet* _rAttrSet )
272 return VclPtr<OAdoDetailsPage>::Create( pParent, *_rAttrSet );
275 // OOdbcDetailsPage
276 OOdbcDetailsPage::OOdbcDetailsPage( vcl::Window* pParent, const SfxItemSet& _rCoreAttrs )
277 :OCommonBehaviourTabPage(pParent, "ODBC", "dbaccess/ui/odbcpage.ui", _rCoreAttrs, CBTP_USE_CHARSET | CBTP_USE_OPTIONS)
279 get(m_pUseCatalog, "useCatalogCheckbutton");
280 m_pUseCatalog->SetToggleHdl(getControlModifiedLink());
283 OOdbcDetailsPage::~OOdbcDetailsPage()
285 disposeOnce();
288 void OOdbcDetailsPage::dispose()
290 m_pUseCatalog.clear();
291 OCommonBehaviourTabPage::dispose();
294 VclPtr<SfxTabPage> ODriversSettings::CreateODBC( vcl::Window* pParent, const SfxItemSet* _rAttrSet )
296 return VclPtr<OOdbcDetailsPage>::Create( pParent, *_rAttrSet );
299 bool OOdbcDetailsPage::FillItemSet( SfxItemSet* _rSet )
301 bool bChangedSomething = OCommonBehaviourTabPage::FillItemSet(_rSet);
302 fillBool(*_rSet,m_pUseCatalog,DSID_USECATALOG,bChangedSomething);
303 return bChangedSomething;
305 void OOdbcDetailsPage::implInitControls(const SfxItemSet& _rSet, bool _bSaveValue)
307 // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
308 bool bValid, bReadonly;
309 getFlags(_rSet, bValid, bReadonly);
311 SFX_ITEMSET_GET(_rSet, pUseCatalogItem, SfxBoolItem, DSID_USECATALOG, true);
313 if ( bValid )
314 m_pUseCatalog->Check(pUseCatalogItem->GetValue());
316 OCommonBehaviourTabPage::implInitControls(_rSet, _bSaveValue);
318 // OOdbcDetailsPage
319 OUserDriverDetailsPage::OUserDriverDetailsPage( vcl::Window* pParent, const SfxItemSet& _rCoreAttrs )
320 : OCommonBehaviourTabPage(pParent, "UserDetailsPage", "dbaccess/ui/userdetailspage.ui", _rCoreAttrs,
321 CBTP_USE_CHARSET | CBTP_USE_OPTIONS)
323 get(m_pFTHostname, "hostnameft");
324 get(m_pEDHostname, "hostname");
325 get(m_pPortNumber, "portnumberft");
326 get(m_pNFPortNumber, "portnumber");
327 m_pNFPortNumber->SetUseThousandSep(false);
328 get(m_pUseCatalog, "usecatalog");
329 m_pUseCatalog->SetToggleHdl(getControlModifiedLink());
332 OUserDriverDetailsPage::~OUserDriverDetailsPage()
334 disposeOnce();
337 void OUserDriverDetailsPage::dispose()
339 m_pFTHostname.clear();
340 m_pEDHostname.clear();
341 m_pPortNumber.clear();
342 m_pNFPortNumber.clear();
343 m_pUseCatalog.clear();
344 OCommonBehaviourTabPage::dispose();
347 VclPtr<SfxTabPage> ODriversSettings::CreateUser( vcl::Window* pParent, const SfxItemSet* _rAttrSet )
349 return VclPtr<OUserDriverDetailsPage>::Create( pParent, *_rAttrSet );
352 bool OUserDriverDetailsPage::FillItemSet( SfxItemSet* _rSet )
354 bool bChangedSomething = OCommonBehaviourTabPage::FillItemSet(_rSet);
356 fillInt32(*_rSet,m_pNFPortNumber,DSID_CONN_PORTNUMBER,bChangedSomething);
357 fillString(*_rSet,m_pEDHostname,DSID_CONN_HOSTNAME,bChangedSomething);
358 fillBool(*_rSet,m_pUseCatalog,DSID_USECATALOG,bChangedSomething);
360 return bChangedSomething;
362 void OUserDriverDetailsPage::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
364 OCommonBehaviourTabPage::fillControls(_rControlList);
365 _rControlList.push_back(new OSaveValueWrapper<Edit>(m_pEDHostname));
366 _rControlList.push_back(new OSaveValueWrapper<CheckBox>(m_pUseCatalog));
367 _rControlList.push_back(new OSaveValueWrapper<NumericField>(m_pNFPortNumber));
369 void OUserDriverDetailsPage::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
371 OCommonBehaviourTabPage::fillWindows(_rControlList);
372 _rControlList.push_back(new ODisableWrapper<FixedText>(m_pFTHostname));
373 _rControlList.push_back(new ODisableWrapper<FixedText>(m_pPortNumber));
375 void OUserDriverDetailsPage::implInitControls(const SfxItemSet& _rSet, bool _bSaveValue)
377 // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
378 bool bValid, bReadonly;
379 getFlags(_rSet, bValid, bReadonly);
381 SFX_ITEMSET_GET(_rSet, pUseCatalogItem, SfxBoolItem, DSID_USECATALOG, true);
382 SFX_ITEMSET_GET(_rSet, pHostName, SfxStringItem, DSID_CONN_HOSTNAME, true);
383 SFX_ITEMSET_GET(_rSet, pPortNumber, SfxInt32Item, DSID_CONN_PORTNUMBER, true);
385 if ( bValid )
387 m_pEDHostname->SetText(pHostName->GetValue());
388 m_pEDHostname->ClearModifyFlag();
390 m_pNFPortNumber->SetValue(pPortNumber->GetValue());
391 m_pNFPortNumber->ClearModifyFlag();
393 m_pUseCatalog->Check(pUseCatalogItem->GetValue());
396 OCommonBehaviourTabPage::implInitControls(_rSet, _bSaveValue);
398 // OMySQLODBCDetailsPage
399 OMySQLODBCDetailsPage::OMySQLODBCDetailsPage( vcl::Window* pParent, const SfxItemSet& _rCoreAttrs )
400 :OCommonBehaviourTabPage(pParent, "AutoCharset", "dbaccess/ui/autocharsetpage.ui", _rCoreAttrs, CBTP_USE_CHARSET )
404 VclPtr<SfxTabPage> ODriversSettings::CreateMySQLODBC( vcl::Window* pParent, const SfxItemSet* _rAttrSet )
406 return VclPtr<OMySQLODBCDetailsPage>::Create( pParent, *_rAttrSet );
409 // OMySQLJDBCDetailsPage
410 OGeneralSpecialJDBCDetailsPage::OGeneralSpecialJDBCDetailsPage( vcl::Window* pParent, const SfxItemSet& _rCoreAttrs ,sal_uInt16 _nPortId, bool bShowSocket )
411 :OCommonBehaviourTabPage(pParent, "GeneralSpecialJDBCDetails", "dbaccess/ui/generalspecialjdbcdetailspage.ui", _rCoreAttrs, CBTP_USE_CHARSET)
412 ,m_nPortId(_nPortId)
413 ,m_bUseClass(true)
415 get(m_pEDHostname, "hostNameEntry");
416 get(m_pNFPortNumber, "portNumberSpinbutton");
417 m_pNFPortNumber->SetUseThousandSep(false);
418 get(m_pFTSocket, "socketLabel");
419 get(m_pEDSocket, "socketEntry");
420 get(m_pFTDriverClass, "driverClassLabel");
421 get(m_pEDDriverClass, "jdbcDriverClassEntry");
422 get(m_pTestJavaDriver, "testDriverClassButton");
424 SFX_ITEMSET_GET(_rCoreAttrs, pUrlItem, SfxStringItem, DSID_CONNECTURL, true);
425 SFX_ITEMSET_GET(_rCoreAttrs, pTypesItem, DbuTypeCollectionItem, DSID_TYPECOLLECTION, true);
426 ::dbaccess::ODsnTypeCollection* pTypeCollection = pTypesItem ? pTypesItem->getCollection() : NULL;
427 if (pTypeCollection && pUrlItem && pUrlItem->GetValue().getLength() )
429 m_sDefaultJdbcDriverName = pTypeCollection->getJavaDriverClass(pUrlItem->GetValue());
431 if ( m_sDefaultJdbcDriverName.getLength() )
433 m_pEDDriverClass->SetModifyHdl(getControlModifiedLink());
434 m_pEDDriverClass->SetModifyHdl(LINK(this, OGeneralSpecialJDBCDetailsPage, OnEditModified));
435 m_pTestJavaDriver->SetClickHdl(LINK(this,OGeneralSpecialJDBCDetailsPage,OnTestJavaClickHdl));
437 else
439 m_bUseClass = false;
440 m_pFTDriverClass->Show(false);
441 m_pEDDriverClass->Show(false);
442 m_pTestJavaDriver->Show(false);
445 m_pFTSocket->Show(bShowSocket && !m_bUseClass);
446 m_pEDSocket->Show(bShowSocket && !m_bUseClass);
448 m_pEDHostname->SetModifyHdl(getControlModifiedLink());
449 m_pNFPortNumber->SetModifyHdl(getControlModifiedLink());
450 m_pEDSocket->SetModifyHdl(getControlModifiedLink());
453 OGeneralSpecialJDBCDetailsPage::~OGeneralSpecialJDBCDetailsPage()
455 disposeOnce();
458 void OGeneralSpecialJDBCDetailsPage::dispose()
460 m_pEDHostname.clear();
461 m_pNFPortNumber.clear();
462 m_pFTSocket.clear();
463 m_pEDSocket.clear();
464 m_pFTDriverClass.clear();
465 m_pEDDriverClass.clear();
466 m_pTestJavaDriver.clear();
467 OCommonBehaviourTabPage::dispose();
470 bool OGeneralSpecialJDBCDetailsPage::FillItemSet( SfxItemSet* _rSet )
472 bool bChangedSomething = OCommonBehaviourTabPage::FillItemSet(_rSet);
473 if ( m_bUseClass )
474 fillString(*_rSet,m_pEDDriverClass,DSID_JDBCDRIVERCLASS,bChangedSomething);
475 fillString(*_rSet,m_pEDHostname,DSID_CONN_HOSTNAME,bChangedSomething);
476 fillString(*_rSet,m_pEDSocket,DSID_CONN_SOCKET,bChangedSomething);
477 fillInt32(*_rSet,m_pNFPortNumber,m_nPortId,bChangedSomething );
479 return bChangedSomething;
481 void OGeneralSpecialJDBCDetailsPage::implInitControls(const SfxItemSet& _rSet, bool _bSaveValue)
483 // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
484 bool bValid, bReadonly;
485 getFlags(_rSet, bValid, bReadonly);
487 SFX_ITEMSET_GET(_rSet, pDrvItem, SfxStringItem, DSID_JDBCDRIVERCLASS, true);
488 SFX_ITEMSET_GET(_rSet, pHostName, SfxStringItem, DSID_CONN_HOSTNAME, true);
489 SFX_ITEMSET_GET(_rSet, pPortNumber, SfxInt32Item, m_nPortId, true);
490 SFX_ITEMSET_GET(_rSet, pSocket, SfxStringItem, DSID_CONN_SOCKET, true);
492 if ( bValid )
494 if ( m_bUseClass )
496 m_pEDDriverClass->SetText(pDrvItem->GetValue());
497 m_pEDDriverClass->ClearModifyFlag();
500 m_pEDHostname->SetText(pHostName->GetValue());
501 m_pEDHostname->ClearModifyFlag();
503 m_pNFPortNumber->SetValue(pPortNumber->GetValue());
504 m_pNFPortNumber->ClearModifyFlag();
506 m_pEDSocket->SetText(pSocket->GetValue());
507 m_pEDSocket->ClearModifyFlag();
510 OCommonBehaviourTabPage::implInitControls(_rSet, _bSaveValue);
512 // to get the correcxt value when saveValue was called by base class
513 if ( m_bUseClass && m_pEDDriverClass->GetText().trim().isEmpty() )
515 m_pEDDriverClass->SetText(m_sDefaultJdbcDriverName);
516 m_pEDDriverClass->SetModifyFlag();
519 IMPL_LINK(OGeneralSpecialJDBCDetailsPage, OnTestJavaClickHdl, PushButton*, /*_pButton*/)
521 OSL_ENSURE(m_pAdminDialog,"No Admin dialog set! ->GPF");
522 OSL_ENSURE(m_bUseClass,"Who called me?");
524 bool bSuccess = false;
525 #if HAVE_FEATURE_JAVA
528 if ( !m_pEDDriverClass->GetText().trim().isEmpty() )
530 // TODO change jvmaccess
531 ::rtl::Reference< jvmaccess::VirtualMachine > xJVM = ::connectivity::getJavaVM( m_pAdminDialog->getORB() );
532 m_pEDDriverClass->SetText(m_pEDDriverClass->GetText().trim()); // fdo#68341
533 bSuccess = ::connectivity::existsJavaClassByName(xJVM,m_pEDDriverClass->GetText());
536 catch(Exception&)
539 #endif
540 const sal_uInt16 nMessage = bSuccess ? STR_JDBCDRIVER_SUCCESS : STR_JDBCDRIVER_NO_SUCCESS;
541 const OSQLMessageBox::MessageType mt = bSuccess ? OSQLMessageBox::Info : OSQLMessageBox::Error;
542 ScopedVclPtrInstance< OSQLMessageBox > aMsg( this, OUString( ModuleRes( nMessage ) ), OUString(), WB_OK | WB_DEF_OK, mt );
543 aMsg->Execute();
544 return 0L;
546 IMPL_LINK(OGeneralSpecialJDBCDetailsPage, OnEditModified, Edit*, _pEdit)
548 if ( m_bUseClass && _pEdit == m_pEDDriverClass )
549 m_pTestJavaDriver->Enable( !m_pEDDriverClass->GetText().trim().isEmpty() );
551 // tell the listener we were modified
552 callModifiedHdl();
553 return 0L;
556 // MySQLNativePage
557 MySQLNativePage::MySQLNativePage( vcl::Window* pParent, const SfxItemSet& _rCoreAttrs )
558 :OCommonBehaviourTabPage(pParent, "MysqlNativePage", "dbaccess/ui/mysqlnativepage.ui", _rCoreAttrs, CBTP_USE_CHARSET )
559 ,m_aMySQLSettings ( VclPtr<MySQLNativeSettings>::Create(*get<VclVBox>("MySQLSettingsContainer"), getControlModifiedLink()) )
561 get(m_pSeparator1, "connectionheader");
562 get(m_pSeparator2, "userheader");
563 get(m_pUserNameLabel, "usernamelabel");
564 get(m_pUserName, "username");
565 get(m_pPasswordRequired, "passwordrequired");
567 m_pUserName->SetModifyHdl(getControlModifiedLink());
569 m_aMySQLSettings->Show();
572 MySQLNativePage::~MySQLNativePage()
574 disposeOnce();
577 void MySQLNativePage::dispose()
579 m_aMySQLSettings.disposeAndClear();
580 m_pSeparator1.clear();
581 m_pSeparator2.clear();
582 m_pUserNameLabel.clear();
583 m_pUserName.clear();
584 m_pPasswordRequired.clear();
585 OCommonBehaviourTabPage::dispose();
588 void MySQLNativePage::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
590 OCommonBehaviourTabPage::fillControls( _rControlList );
591 m_aMySQLSettings->fillControls( _rControlList );
593 _rControlList.push_back(new OSaveValueWrapper<Edit>(m_pUserName));
594 _rControlList.push_back(new OSaveValueWrapper<CheckBox>(m_pPasswordRequired));
596 void MySQLNativePage::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
598 OCommonBehaviourTabPage::fillWindows( _rControlList );
599 m_aMySQLSettings->fillWindows( _rControlList);
601 _rControlList.push_back(new ODisableWrapper<FixedText>(m_pSeparator1));
602 _rControlList.push_back(new ODisableWrapper<FixedText>(m_pSeparator2));
603 _rControlList.push_back(new ODisableWrapper<FixedText>(m_pUserNameLabel));
606 bool MySQLNativePage::FillItemSet( SfxItemSet* _rSet )
608 bool bChangedSomething = OCommonBehaviourTabPage::FillItemSet( _rSet );
610 bChangedSomething |= m_aMySQLSettings->FillItemSet( _rSet );
612 if ( m_pUserName->IsValueChangedFromSaved() )
614 _rSet->Put( SfxStringItem( DSID_USER, m_pUserName->GetText() ) );
615 _rSet->Put( SfxStringItem( DSID_PASSWORD, OUString()));
616 bChangedSomething = true;
618 fillBool(*_rSet,m_pPasswordRequired,DSID_PASSWORDREQUIRED,bChangedSomething);
620 return bChangedSomething;
622 void MySQLNativePage::implInitControls(const SfxItemSet& _rSet, bool _bSaveValue)
624 // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
625 bool bValid, bReadonly;
626 getFlags(_rSet, bValid, bReadonly);
628 m_aMySQLSettings->implInitControls( _rSet );
630 SFX_ITEMSET_GET(_rSet, pUidItem, SfxStringItem, DSID_USER, true);
631 SFX_ITEMSET_GET(_rSet, pAllowEmptyPwd, SfxBoolItem, DSID_PASSWORDREQUIRED, true);
633 if ( bValid )
635 m_pUserName->SetText(pUidItem->GetValue());
636 m_pUserName->ClearModifyFlag();
637 m_pPasswordRequired->Check(pAllowEmptyPwd->GetValue());
640 OCommonBehaviourTabPage::implInitControls(_rSet, _bSaveValue);
643 VclPtr<SfxTabPage> ODriversSettings::CreateMySQLJDBC( vcl::Window* pParent, const SfxItemSet* _rAttrSet )
645 return VclPtr<OGeneralSpecialJDBCDetailsPage>::Create( pParent, *_rAttrSet,DSID_MYSQL_PORTNUMBER );
647 VclPtr<SfxTabPage> ODriversSettings::CreateMySQLNATIVE( vcl::Window* pParent, const SfxItemSet* _rAttrSet )
649 return VclPtr<MySQLNativePage>::Create( pParent, *_rAttrSet );
652 VclPtr<SfxTabPage> ODriversSettings::CreateOracleJDBC( vcl::Window* pParent, const SfxItemSet* _rAttrSet )
654 return VclPtr<OGeneralSpecialJDBCDetailsPage>::Create( pParent, *_rAttrSet,DSID_ORACLE_PORTNUMBER, false);
657 // OLDAPDetailsPage
658 OLDAPDetailsPage::OLDAPDetailsPage( vcl::Window* pParent, const SfxItemSet& _rCoreAttrs )
659 :OCommonBehaviourTabPage(pParent, "LDAP", "dbaccess/ui/ldappage.ui", _rCoreAttrs, 0)
661 get(m_pETBaseDN, "baseDNEntry");
662 get(m_pCBUseSSL, "useSSLCheckbutton");
663 get(m_pNFPortNumber, "portNumberSpinbutton");
664 m_pNFPortNumber->SetUseThousandSep(false);
665 get(m_pNFRowCount, "LDAPRowCountspinbutton");
667 m_pETBaseDN->SetModifyHdl(getControlModifiedLink());
668 m_pCBUseSSL->SetToggleHdl(getControlModifiedLink());
669 m_pNFPortNumber->SetModifyHdl(getControlModifiedLink());
670 m_pNFRowCount->SetModifyHdl(getControlModifiedLink());
672 m_pNFRowCount->SetUseThousandSep(false);
673 m_iNormalPort = 389;
674 m_iSSLPort = 636;
675 m_pCBUseSSL->SetClickHdl(LINK(this, OLDAPDetailsPage,OnCheckBoxClick));
678 OLDAPDetailsPage::~OLDAPDetailsPage()
680 disposeOnce();
683 void OLDAPDetailsPage::dispose()
685 m_pETBaseDN.clear();
686 m_pCBUseSSL.clear();
687 m_pNFPortNumber.clear();
688 m_pNFRowCount.clear();
689 OCommonBehaviourTabPage::dispose();
692 VclPtr<SfxTabPage> ODriversSettings::CreateLDAP( vcl::Window* pParent, const SfxItemSet* _rAttrSet )
694 return VclPtr<OLDAPDetailsPage>::Create( pParent, *_rAttrSet );
697 bool OLDAPDetailsPage::FillItemSet( SfxItemSet* _rSet )
699 bool bChangedSomething = OCommonBehaviourTabPage::FillItemSet(_rSet);
701 fillString(*_rSet,m_pETBaseDN,DSID_CONN_LDAP_BASEDN,bChangedSomething);
702 fillInt32(*_rSet,m_pNFPortNumber,DSID_CONN_LDAP_PORTNUMBER,bChangedSomething);
703 fillInt32(*_rSet,m_pNFRowCount,DSID_CONN_LDAP_ROWCOUNT,bChangedSomething);
704 fillBool(*_rSet,m_pCBUseSSL,DSID_CONN_LDAP_USESSL,bChangedSomething);
705 return bChangedSomething;
707 IMPL_LINK( OLDAPDetailsPage, OnCheckBoxClick, CheckBox*, pCheckBox )
709 callModifiedHdl();
710 if ( pCheckBox == m_pCBUseSSL)
712 if ( m_pCBUseSSL->IsChecked() )
714 m_iNormalPort = static_cast<sal_Int32>(m_pNFPortNumber->GetValue());
715 m_pNFPortNumber->SetValue(m_iSSLPort);
717 else
719 m_iSSLPort = static_cast<sal_Int32>(m_pNFPortNumber->GetValue());
720 m_pNFPortNumber->SetValue(m_iNormalPort);
723 return 0;
726 void OLDAPDetailsPage::implInitControls(const SfxItemSet& _rSet, bool _bSaveValue)
728 // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
729 bool bValid, bReadonly;
730 getFlags(_rSet, bValid, bReadonly);
732 SFX_ITEMSET_GET(_rSet, pBaseDN, SfxStringItem, DSID_CONN_LDAP_BASEDN, true);
733 SFX_ITEMSET_GET(_rSet, pUseSSL, SfxBoolItem, DSID_CONN_LDAP_USESSL, true);
734 SFX_ITEMSET_GET(_rSet, pPortNumber, SfxInt32Item, DSID_CONN_LDAP_PORTNUMBER, true);
735 SFX_ITEMSET_GET(_rSet, pRowCount, SfxInt32Item, DSID_CONN_LDAP_ROWCOUNT, true);
737 if ( bValid )
739 m_pETBaseDN->SetText(pBaseDN->GetValue());
740 m_pNFPortNumber->SetValue(pPortNumber->GetValue());
741 m_pNFRowCount->SetValue(pRowCount->GetValue());
742 m_pCBUseSSL->Check(pUseSSL->GetValue());
745 OCommonBehaviourTabPage::implInitControls(_rSet, _bSaveValue);
748 // OTextDetailsPage
749 OTextDetailsPage::OTextDetailsPage( vcl::Window* pParent, const SfxItemSet& _rCoreAttrs )
750 :OCommonBehaviourTabPage(pParent, "EmptyPage", "dbaccess/ui/emptypage.ui", _rCoreAttrs, 0)
753 m_pTextConnectionHelper = VclPtr<OTextConnectionHelper>::Create( get<VclVBox>("EmptyPage"), TC_EXTENSION | TC_HEADER | TC_SEPARATORS | TC_CHARSET );
756 OTextDetailsPage::~OTextDetailsPage()
758 disposeOnce();
761 void OTextDetailsPage::dispose()
763 m_pTextConnectionHelper.disposeAndClear();
764 OCommonBehaviourTabPage::dispose();
767 VclPtr<SfxTabPage> ODriversSettings::CreateText( vcl::Window* pParent, const SfxItemSet* _rAttrSet )
769 return VclPtr<OTextDetailsPage>::Create( pParent, *_rAttrSet );
771 void OTextDetailsPage::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
773 OCommonBehaviourTabPage::fillControls(_rControlList);
774 m_pTextConnectionHelper->fillControls(_rControlList);
777 void OTextDetailsPage::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
779 OCommonBehaviourTabPage::fillWindows(_rControlList);
780 m_pTextConnectionHelper->fillWindows(_rControlList);
783 void OTextDetailsPage::implInitControls(const SfxItemSet& _rSet, bool _bSaveValue)
785 // first check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
786 bool bValid, bReadonly;
787 getFlags(_rSet, bValid, bReadonly);
789 m_pTextConnectionHelper->implInitControls(_rSet, bValid);
790 OCommonBehaviourTabPage::implInitControls(_rSet, _bSaveValue);
793 bool OTextDetailsPage::FillItemSet( SfxItemSet* rSet )
795 bool bChangedSomething = OCommonBehaviourTabPage::FillItemSet(rSet);
796 bChangedSomething = m_pTextConnectionHelper->FillItemSet(*rSet, bChangedSomething);
797 return bChangedSomething;
800 bool OTextDetailsPage::prepareLeave()
802 return m_pTextConnectionHelper->prepareLeave();
805 VclPtr<SfxTabPage> ODriversSettings::CreateGeneratedValuesPage( vcl::Window* _pParent, const SfxItemSet* _rAttrSet )
807 return VclPtr<GeneratedValuesPage>::Create( _pParent, *_rAttrSet );
810 VclPtr<SfxTabPage> ODriversSettings::CreateSpecialSettingsPage( vcl::Window* _pParent, const SfxItemSet* _rAttrSet )
812 OUString eType = ODbDataSourceAdministrationHelper::getDatasourceType( *_rAttrSet );
813 DataSourceMetaData aMetaData( eType );
814 return VclPtr<SpecialSettingsPage>::Create( _pParent, *_rAttrSet, aMetaData );
816 } // namespace dbaui
818 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */