Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
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"
30 :
31 : #include "dbaccess_helpid.hrc"
32 : #include "dbu_dlg.hrc"
33 :
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>
48 :
49 : namespace dbaui
50 : {
51 :
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;
58 :
59 0 : OCommonBehaviourTabPage::OCommonBehaviourTabPage(vcl::Window* pParent, const OString& rId,
60 : const OUString& rUIXMLDescription, const SfxItemSet& _rCoreAttrs,
61 : sal_uInt32 nControlFlags)
62 :
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)
74 0 : ,m_bDelete(false)
75 : {
76 :
77 0 : if ((m_nControlFlags & CBTP_USE_OPTIONS) == CBTP_USE_OPTIONS)
78 : {
79 0 : m_pOptionsLabel = get<FixedText>("optionslabel");
80 0 : m_pOptionsLabel->Show();
81 0 : m_pOptions = get<Edit>("options");
82 0 : m_pOptions->Show();
83 0 : m_pOptions->SetModifyHdl(getControlModifiedLink());
84 : }
85 :
86 0 : if ((m_nControlFlags & CBTP_USE_CHARSET) == CBTP_USE_CHARSET)
87 : {
88 0 : FixedText* pDataConvertLabel = get<FixedText>("charsetheader");
89 0 : pDataConvertLabel->Show();
90 0 : m_pCharsetLabel = get<FixedText>("charsetlabel");
91 0 : m_pCharsetLabel->Show();
92 0 : m_pCharset = get<CharSetListBox>("charset");
93 0 : m_pCharset->Show();
94 0 : m_pCharset->SetSelectHdl(getControlModifiedLink());
95 : }
96 0 : }
97 :
98 0 : OCommonBehaviourTabPage::~OCommonBehaviourTabPage()
99 : {
100 0 : if(m_bDelete)
101 : {
102 0 : DELETEZ(m_pOptionsLabel);
103 0 : DELETEZ(m_pOptions);
104 :
105 0 : DELETEZ(m_pCharsetLabel);
106 0 : DELETEZ(m_pCharset);
107 :
108 0 : DELETEZ(m_pAutoIncrementLabel);
109 0 : DELETEZ(m_pAutoIncrement);
110 :
111 0 : DELETEZ(m_pAutoRetrievingEnabled);
112 0 : DELETEZ(m_pAutoRetrievingLabel);
113 0 : DELETEZ(m_pAutoRetrieving);
114 : }
115 :
116 0 : }
117 :
118 0 : void OCommonBehaviourTabPage::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
119 : {
120 0 : if ((m_nControlFlags & CBTP_USE_OPTIONS) == CBTP_USE_OPTIONS)
121 : {
122 0 : _rControlList.push_back(new ODisableWrapper<FixedText>(m_pOptionsLabel));
123 : }
124 :
125 0 : if ((m_nControlFlags & CBTP_USE_CHARSET) == CBTP_USE_CHARSET)
126 : {
127 0 : _rControlList.push_back(new ODisableWrapper<FixedText>(m_pCharsetLabel));
128 : }
129 0 : }
130 0 : void OCommonBehaviourTabPage::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
131 : {
132 0 : if ((m_nControlFlags & CBTP_USE_OPTIONS) == CBTP_USE_OPTIONS)
133 0 : _rControlList.push_back(new OSaveValueWrapper<Edit>(m_pOptions));
134 :
135 0 : if ((m_nControlFlags & CBTP_USE_CHARSET) == CBTP_USE_CHARSET)
136 0 : _rControlList.push_back(new OSaveValueWrapper<ListBox>(m_pCharset));
137 0 : }
138 :
139 0 : void OCommonBehaviourTabPage::implInitControls(const SfxItemSet& _rSet, bool _bSaveValue)
140 : {
141 : // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
142 : bool bValid, bReadonly;
143 0 : getFlags(_rSet, bValid, bReadonly);
144 :
145 : // collect the items
146 0 : SFX_ITEMSET_GET(_rSet, pOptionsItem, SfxStringItem, DSID_ADDITIONALOPTIONS, true);
147 0 : SFX_ITEMSET_GET(_rSet, pCharsetItem, SfxStringItem, DSID_CHARSET, true);
148 :
149 : // forward the values to the controls
150 0 : if (bValid)
151 : {
152 0 : if ((m_nControlFlags & CBTP_USE_OPTIONS) == CBTP_USE_OPTIONS)
153 : {
154 0 : m_pOptions->SetText(pOptionsItem->GetValue());
155 0 : m_pOptions->ClearModifyFlag();
156 : }
157 :
158 0 : if ((m_nControlFlags & CBTP_USE_CHARSET) == CBTP_USE_CHARSET)
159 : {
160 0 : m_pCharset->SelectEntryByIanaName( pCharsetItem->GetValue() );
161 : }
162 : }
163 0 : OGenericAdministrationPage::implInitControls(_rSet, _bSaveValue);
164 0 : }
165 :
166 0 : bool OCommonBehaviourTabPage::FillItemSet(SfxItemSet* _rSet)
167 : {
168 0 : bool bChangedSomething = false;
169 :
170 0 : if ((m_nControlFlags & CBTP_USE_OPTIONS) == CBTP_USE_OPTIONS)
171 : {
172 0 : fillString(*_rSet,m_pOptions,DSID_ADDITIONALOPTIONS,bChangedSomething);
173 : }
174 :
175 0 : if ((m_nControlFlags & CBTP_USE_CHARSET) == CBTP_USE_CHARSET)
176 : {
177 0 : if ( m_pCharset->StoreSelectedCharSet( *_rSet, DSID_CHARSET ) )
178 0 : bChangedSomething = true;
179 : }
180 :
181 0 : return bChangedSomething;
182 : }
183 :
184 : // ODbaseDetailsPage
185 0 : ODbaseDetailsPage::ODbaseDetailsPage( vcl::Window* pParent, const SfxItemSet& _rCoreAttrs )
186 0 : :OCommonBehaviourTabPage(pParent, "DbasePage", "dbaccess/ui/dbasepage.ui", _rCoreAttrs, CBTP_USE_CHARSET)
187 : {
188 0 : get(m_pShowDeleted, "showDelRowsCheckbutton");
189 0 : get(m_pFT_Message, "specMessageLabel");
190 0 : get(m_pIndexes, "indiciesButton");
191 0 : set_height_request(300);
192 :
193 0 : m_pIndexes->SetClickHdl(LINK(this, ODbaseDetailsPage, OnButtonClicked));
194 0 : m_pShowDeleted->SetClickHdl(LINK(this, ODbaseDetailsPage, OnButtonClicked));
195 0 : }
196 :
197 0 : ODbaseDetailsPage::~ODbaseDetailsPage()
198 : {
199 :
200 0 : }
201 :
202 0 : SfxTabPage* ODriversSettings::CreateDbase( vcl::Window* pParent, const SfxItemSet* _rAttrSet )
203 : {
204 0 : return ( new ODbaseDetailsPage( pParent, *_rAttrSet ) );
205 : }
206 :
207 0 : void ODbaseDetailsPage::implInitControls(const SfxItemSet& _rSet, bool _bSaveValue)
208 : {
209 : // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
210 : bool bValid, bReadonly;
211 0 : getFlags(_rSet, bValid, bReadonly);
212 :
213 : // get the DSN string (needed for the index dialog)
214 0 : SFX_ITEMSET_GET(_rSet, pUrlItem, SfxStringItem, DSID_CONNECTURL, true);
215 0 : SFX_ITEMSET_GET(_rSet, pTypesItem, DbuTypeCollectionItem, DSID_TYPECOLLECTION, true);
216 0 : ::dbaccess::ODsnTypeCollection* pTypeCollection = pTypesItem ? pTypesItem->getCollection() : NULL;
217 0 : if (pTypeCollection && pUrlItem && pUrlItem->GetValue().getLength())
218 0 : m_sDsn = pTypeCollection->cutPrefix(pUrlItem->GetValue());
219 :
220 : // get the other relevant items
221 0 : SFX_ITEMSET_GET(_rSet, pDeletedItem, SfxBoolItem, DSID_SHOWDELETEDROWS, true);
222 :
223 0 : if ( bValid )
224 : {
225 0 : m_pShowDeleted->Check( pDeletedItem->GetValue() );
226 0 : m_pFT_Message->Show(m_pShowDeleted->IsChecked());
227 : }
228 :
229 0 : OCommonBehaviourTabPage::implInitControls(_rSet, _bSaveValue);
230 0 : }
231 :
232 0 : bool ODbaseDetailsPage::FillItemSet( SfxItemSet* _rSet )
233 : {
234 0 : bool bChangedSomething = OCommonBehaviourTabPage::FillItemSet(_rSet);
235 :
236 0 : fillBool(*_rSet,m_pShowDeleted,DSID_SHOWDELETEDROWS,bChangedSomething);
237 0 : return bChangedSomething;
238 : }
239 :
240 0 : IMPL_LINK( ODbaseDetailsPage, OnButtonClicked, Button*, pButton )
241 : {
242 0 : if (m_pIndexes == pButton)
243 : {
244 0 : ODbaseIndexDialog aIndexDialog(this, m_sDsn);
245 0 : aIndexDialog.Execute();
246 : }
247 : else
248 : {
249 0 : m_pFT_Message->Show(m_pShowDeleted->IsChecked());
250 : // it was one of the checkboxes -> we count as modified from now on
251 0 : callModifiedHdl();
252 : }
253 :
254 0 : return 0;
255 : }
256 :
257 : // OAdoDetailsPage
258 0 : OAdoDetailsPage::OAdoDetailsPage( vcl::Window* pParent, const SfxItemSet& _rCoreAttrs )
259 0 : :OCommonBehaviourTabPage(pParent, "AutoCharset", "dbaccess/ui/autocharsetpage.ui", _rCoreAttrs, CBTP_USE_CHARSET )
260 : {
261 :
262 0 : }
263 :
264 0 : OAdoDetailsPage::~OAdoDetailsPage()
265 : {
266 :
267 0 : }
268 0 : SfxTabPage* ODriversSettings::CreateAdo( vcl::Window* pParent, const SfxItemSet* _rAttrSet )
269 : {
270 0 : return ( new OAdoDetailsPage( pParent, *_rAttrSet ) );
271 : }
272 :
273 : // OOdbcDetailsPage
274 0 : OOdbcDetailsPage::OOdbcDetailsPage( vcl::Window* pParent, const SfxItemSet& _rCoreAttrs )
275 0 : :OCommonBehaviourTabPage(pParent, "ODBC", "dbaccess/ui/odbcpage.ui", _rCoreAttrs, CBTP_USE_CHARSET | CBTP_USE_OPTIONS)
276 : {
277 0 : get(m_pUseCatalog, "useCatalogCheckbutton");
278 0 : m_pUseCatalog->SetToggleHdl(getControlModifiedLink());
279 0 : }
280 :
281 0 : SfxTabPage* ODriversSettings::CreateODBC( vcl::Window* pParent, const SfxItemSet* _rAttrSet )
282 : {
283 0 : return ( new OOdbcDetailsPage( pParent, *_rAttrSet ) );
284 : }
285 :
286 0 : bool OOdbcDetailsPage::FillItemSet( SfxItemSet* _rSet )
287 : {
288 0 : bool bChangedSomething = OCommonBehaviourTabPage::FillItemSet(_rSet);
289 0 : fillBool(*_rSet,m_pUseCatalog,DSID_USECATALOG,bChangedSomething);
290 0 : return bChangedSomething;
291 : }
292 0 : void OOdbcDetailsPage::implInitControls(const SfxItemSet& _rSet, bool _bSaveValue)
293 : {
294 : // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
295 : bool bValid, bReadonly;
296 0 : getFlags(_rSet, bValid, bReadonly);
297 :
298 0 : SFX_ITEMSET_GET(_rSet, pUseCatalogItem, SfxBoolItem, DSID_USECATALOG, true);
299 :
300 0 : if ( bValid )
301 0 : m_pUseCatalog->Check(pUseCatalogItem->GetValue());
302 :
303 0 : OCommonBehaviourTabPage::implInitControls(_rSet, _bSaveValue);
304 0 : }
305 : // OOdbcDetailsPage
306 0 : OUserDriverDetailsPage::OUserDriverDetailsPage( vcl::Window* pParent, const SfxItemSet& _rCoreAttrs )
307 : : OCommonBehaviourTabPage(pParent, "UserDetailsPage", "dbaccess/ui/userdetailspage.ui", _rCoreAttrs,
308 0 : CBTP_USE_CHARSET | CBTP_USE_OPTIONS)
309 : {
310 0 : get(m_pFTHostname, "hostnameft");
311 0 : get(m_pEDHostname, "hostname");
312 0 : get(m_pPortNumber, "portnumberft");
313 0 : get(m_pNFPortNumber, "portnumber");
314 0 : m_pNFPortNumber->SetUseThousandSep(false);
315 0 : get(m_pUseCatalog, "usecatalog");
316 0 : m_pUseCatalog->SetToggleHdl(getControlModifiedLink());
317 0 : }
318 :
319 0 : SfxTabPage* ODriversSettings::CreateUser( vcl::Window* pParent, const SfxItemSet* _rAttrSet )
320 : {
321 0 : return ( new OUserDriverDetailsPage( pParent, *_rAttrSet ) );
322 : }
323 :
324 0 : bool OUserDriverDetailsPage::FillItemSet( SfxItemSet* _rSet )
325 : {
326 0 : bool bChangedSomething = OCommonBehaviourTabPage::FillItemSet(_rSet);
327 :
328 0 : fillInt32(*_rSet,m_pNFPortNumber,DSID_CONN_PORTNUMBER,bChangedSomething);
329 0 : fillString(*_rSet,m_pEDHostname,DSID_CONN_HOSTNAME,bChangedSomething);
330 0 : fillBool(*_rSet,m_pUseCatalog,DSID_USECATALOG,bChangedSomething);
331 :
332 0 : return bChangedSomething;
333 : }
334 0 : void OUserDriverDetailsPage::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
335 : {
336 0 : OCommonBehaviourTabPage::fillControls(_rControlList);
337 0 : _rControlList.push_back(new OSaveValueWrapper<Edit>(m_pEDHostname));
338 0 : _rControlList.push_back(new OSaveValueWrapper<CheckBox>(m_pUseCatalog));
339 0 : _rControlList.push_back(new OSaveValueWrapper<NumericField>(m_pNFPortNumber));
340 0 : }
341 0 : void OUserDriverDetailsPage::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
342 : {
343 0 : OCommonBehaviourTabPage::fillWindows(_rControlList);
344 0 : _rControlList.push_back(new ODisableWrapper<FixedText>(m_pFTHostname));
345 0 : _rControlList.push_back(new ODisableWrapper<FixedText>(m_pPortNumber));
346 0 : }
347 0 : void OUserDriverDetailsPage::implInitControls(const SfxItemSet& _rSet, bool _bSaveValue)
348 : {
349 : // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
350 : bool bValid, bReadonly;
351 0 : getFlags(_rSet, bValid, bReadonly);
352 :
353 0 : SFX_ITEMSET_GET(_rSet, pUseCatalogItem, SfxBoolItem, DSID_USECATALOG, true);
354 0 : SFX_ITEMSET_GET(_rSet, pHostName, SfxStringItem, DSID_CONN_HOSTNAME, true);
355 0 : SFX_ITEMSET_GET(_rSet, pPortNumber, SfxInt32Item, DSID_CONN_PORTNUMBER, true);
356 :
357 0 : if ( bValid )
358 : {
359 0 : m_pEDHostname->SetText(pHostName->GetValue());
360 0 : m_pEDHostname->ClearModifyFlag();
361 :
362 0 : m_pNFPortNumber->SetValue(pPortNumber->GetValue());
363 0 : m_pNFPortNumber->ClearModifyFlag();
364 :
365 0 : m_pUseCatalog->Check(pUseCatalogItem->GetValue());
366 : }
367 :
368 0 : OCommonBehaviourTabPage::implInitControls(_rSet, _bSaveValue);
369 0 : }
370 : // OMySQLODBCDetailsPage
371 0 : OMySQLODBCDetailsPage::OMySQLODBCDetailsPage( vcl::Window* pParent, const SfxItemSet& _rCoreAttrs )
372 0 : :OCommonBehaviourTabPage(pParent, "AutoCharset", "dbaccess/ui/autocharsetpage.ui", _rCoreAttrs, CBTP_USE_CHARSET )
373 : {
374 0 : }
375 :
376 0 : SfxTabPage* ODriversSettings::CreateMySQLODBC( vcl::Window* pParent, const SfxItemSet* _rAttrSet )
377 : {
378 0 : return ( new OMySQLODBCDetailsPage( pParent, *_rAttrSet ) );
379 : }
380 :
381 : // OMySQLJDBCDetailsPage
382 0 : OGeneralSpecialJDBCDetailsPage::OGeneralSpecialJDBCDetailsPage( vcl::Window* pParent, const SfxItemSet& _rCoreAttrs ,sal_uInt16 _nPortId, bool bShowSocket )
383 : :OCommonBehaviourTabPage(pParent, "GeneralSpecialJDBCDetails", "dbaccess/ui/generalspecialjdbcdetailspage.ui", _rCoreAttrs, CBTP_USE_CHARSET)
384 : ,m_nPortId(_nPortId)
385 0 : ,m_bUseClass(true)
386 : {
387 0 : get(m_pEDHostname, "hostNameEntry");
388 0 : get(m_pNFPortNumber, "portNumberSpinbutton");
389 0 : m_pNFPortNumber->SetUseThousandSep(false);
390 0 : get(m_pFTSocket, "socketLabel");
391 0 : get(m_pEDSocket, "socketEntry");
392 0 : get(m_pFTDriverClass, "driverClassLabel");
393 0 : get(m_pEDDriverClass, "jdbcDriverClassEntry");
394 0 : get(m_pTestJavaDriver, "testDriverClassButton");
395 :
396 0 : SFX_ITEMSET_GET(_rCoreAttrs, pUrlItem, SfxStringItem, DSID_CONNECTURL, true);
397 0 : SFX_ITEMSET_GET(_rCoreAttrs, pTypesItem, DbuTypeCollectionItem, DSID_TYPECOLLECTION, true);
398 0 : ::dbaccess::ODsnTypeCollection* pTypeCollection = pTypesItem ? pTypesItem->getCollection() : NULL;
399 0 : if (pTypeCollection && pUrlItem && pUrlItem->GetValue().getLength() )
400 : {
401 0 : m_sDefaultJdbcDriverName = pTypeCollection->getJavaDriverClass(pUrlItem->GetValue());
402 : }
403 0 : if ( m_sDefaultJdbcDriverName.getLength() )
404 : {
405 0 : m_pEDDriverClass->SetModifyHdl(getControlModifiedLink());
406 0 : m_pEDDriverClass->SetModifyHdl(LINK(this, OGeneralSpecialJDBCDetailsPage, OnEditModified));
407 0 : m_pTestJavaDriver->SetClickHdl(LINK(this,OGeneralSpecialJDBCDetailsPage,OnTestJavaClickHdl));
408 : }
409 : else
410 : {
411 0 : m_bUseClass = false;
412 0 : m_pFTDriverClass->Show(false);
413 0 : m_pEDDriverClass->Show(false);
414 0 : m_pTestJavaDriver->Show(false);
415 : }
416 :
417 0 : m_pFTSocket->Show(bShowSocket && !m_bUseClass);
418 0 : m_pEDSocket->Show(bShowSocket && !m_bUseClass);
419 :
420 0 : m_pEDHostname->SetModifyHdl(getControlModifiedLink());
421 0 : m_pNFPortNumber->SetModifyHdl(getControlModifiedLink());
422 0 : m_pEDSocket->SetModifyHdl(getControlModifiedLink());
423 0 : }
424 :
425 0 : bool OGeneralSpecialJDBCDetailsPage::FillItemSet( SfxItemSet* _rSet )
426 : {
427 0 : bool bChangedSomething = OCommonBehaviourTabPage::FillItemSet(_rSet);
428 0 : if ( m_bUseClass )
429 0 : fillString(*_rSet,m_pEDDriverClass,DSID_JDBCDRIVERCLASS,bChangedSomething);
430 0 : fillString(*_rSet,m_pEDHostname,DSID_CONN_HOSTNAME,bChangedSomething);
431 0 : fillString(*_rSet,m_pEDSocket,DSID_CONN_SOCKET,bChangedSomething);
432 0 : fillInt32(*_rSet,m_pNFPortNumber,m_nPortId,bChangedSomething );
433 :
434 0 : return bChangedSomething;
435 : }
436 0 : void OGeneralSpecialJDBCDetailsPage::implInitControls(const SfxItemSet& _rSet, bool _bSaveValue)
437 : {
438 : // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
439 : bool bValid, bReadonly;
440 0 : getFlags(_rSet, bValid, bReadonly);
441 :
442 0 : SFX_ITEMSET_GET(_rSet, pDrvItem, SfxStringItem, DSID_JDBCDRIVERCLASS, true);
443 0 : SFX_ITEMSET_GET(_rSet, pHostName, SfxStringItem, DSID_CONN_HOSTNAME, true);
444 0 : SFX_ITEMSET_GET(_rSet, pPortNumber, SfxInt32Item, m_nPortId, true);
445 0 : SFX_ITEMSET_GET(_rSet, pSocket, SfxStringItem, DSID_CONN_SOCKET, true);
446 :
447 0 : if ( bValid )
448 : {
449 0 : if ( m_bUseClass )
450 : {
451 0 : m_pEDDriverClass->SetText(pDrvItem->GetValue());
452 0 : m_pEDDriverClass->ClearModifyFlag();
453 : }
454 :
455 0 : m_pEDHostname->SetText(pHostName->GetValue());
456 0 : m_pEDHostname->ClearModifyFlag();
457 :
458 0 : m_pNFPortNumber->SetValue(pPortNumber->GetValue());
459 0 : m_pNFPortNumber->ClearModifyFlag();
460 :
461 0 : m_pEDSocket->SetText(pSocket->GetValue());
462 0 : m_pEDSocket->ClearModifyFlag();
463 : }
464 :
465 0 : OCommonBehaviourTabPage::implInitControls(_rSet, _bSaveValue);
466 :
467 : // to get the correcxt value when saveValue was called by base class
468 0 : if ( m_bUseClass && m_pEDDriverClass->GetText().trim().isEmpty() )
469 : {
470 0 : m_pEDDriverClass->SetText(m_sDefaultJdbcDriverName);
471 0 : m_pEDDriverClass->SetModifyFlag();
472 : }
473 0 : }
474 0 : IMPL_LINK(OGeneralSpecialJDBCDetailsPage, OnTestJavaClickHdl, PushButton*, /*_pButton*/)
475 : {
476 : OSL_ENSURE(m_pAdminDialog,"No Admin dialog set! ->GPF");
477 : OSL_ENSURE(m_bUseClass,"Who called me?");
478 :
479 0 : bool bSuccess = false;
480 : #if HAVE_FEATURE_JAVA
481 : try
482 : {
483 0 : if ( !m_pEDDriverClass->GetText().trim().isEmpty() )
484 : {
485 : // TODO change jvmaccess
486 0 : ::rtl::Reference< jvmaccess::VirtualMachine > xJVM = ::connectivity::getJavaVM( m_pAdminDialog->getORB() );
487 0 : m_pEDDriverClass->SetText(m_pEDDriverClass->GetText().trim()); // fdo#68341
488 0 : bSuccess = ::connectivity::existsJavaClassByName(xJVM,m_pEDDriverClass->GetText());
489 : }
490 : }
491 0 : catch(Exception&)
492 : {
493 : }
494 : #endif
495 0 : const sal_uInt16 nMessage = bSuccess ? STR_JDBCDRIVER_SUCCESS : STR_JDBCDRIVER_NO_SUCCESS;
496 0 : const OSQLMessageBox::MessageType mt = bSuccess ? OSQLMessageBox::Info : OSQLMessageBox::Error;
497 0 : OSQLMessageBox aMsg( this, OUString( ModuleRes( nMessage ) ), OUString(), WB_OK | WB_DEF_OK, mt );
498 0 : aMsg.Execute();
499 0 : return 0L;
500 : }
501 0 : IMPL_LINK(OGeneralSpecialJDBCDetailsPage, OnEditModified, Edit*, _pEdit)
502 : {
503 0 : if ( m_bUseClass && _pEdit == m_pEDDriverClass )
504 0 : m_pTestJavaDriver->Enable( !m_pEDDriverClass->GetText().trim().isEmpty() );
505 :
506 : // tell the listener we were modified
507 0 : callModifiedHdl();
508 0 : return 0L;
509 : }
510 :
511 : // MySQLNativePage
512 0 : MySQLNativePage::MySQLNativePage( vcl::Window* pParent, const SfxItemSet& _rCoreAttrs )
513 : :OCommonBehaviourTabPage(pParent, "MysqlNativePage", "dbaccess/ui/mysqlnativepage.ui", _rCoreAttrs, CBTP_USE_CHARSET )
514 0 : ,m_aMySQLSettings ( *get<VclVBox>("MySQLSettingsContainer"), getControlModifiedLink() )
515 : {
516 0 : get(m_pSeparator1, "connectionheader");
517 0 : get(m_pSeparator2, "userheader");
518 0 : get(m_pUserNameLabel, "usernamelabel");
519 0 : get(m_pUserName, "username");
520 0 : get(m_pPasswordRequired, "passwordrequired");
521 :
522 0 : m_pUserName->SetModifyHdl(getControlModifiedLink());
523 :
524 0 : m_aMySQLSettings.Show();
525 0 : }
526 :
527 0 : void MySQLNativePage::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
528 : {
529 0 : OCommonBehaviourTabPage::fillControls( _rControlList );
530 0 : m_aMySQLSettings.fillControls( _rControlList );
531 :
532 0 : _rControlList.push_back(new OSaveValueWrapper<Edit>(m_pUserName));
533 0 : _rControlList.push_back(new OSaveValueWrapper<CheckBox>(m_pPasswordRequired));
534 0 : }
535 0 : void MySQLNativePage::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
536 : {
537 0 : OCommonBehaviourTabPage::fillWindows( _rControlList );
538 0 : m_aMySQLSettings.fillWindows( _rControlList);
539 :
540 0 : _rControlList.push_back(new ODisableWrapper<FixedText>(m_pSeparator1));
541 0 : _rControlList.push_back(new ODisableWrapper<FixedText>(m_pSeparator2));
542 0 : _rControlList.push_back(new ODisableWrapper<FixedText>(m_pUserNameLabel));
543 0 : }
544 :
545 0 : bool MySQLNativePage::FillItemSet( SfxItemSet* _rSet )
546 : {
547 0 : bool bChangedSomething = OCommonBehaviourTabPage::FillItemSet( _rSet );
548 :
549 0 : bChangedSomething |= m_aMySQLSettings.FillItemSet( _rSet );
550 :
551 0 : if ( m_pUserName->IsValueChangedFromSaved() )
552 : {
553 0 : _rSet->Put( SfxStringItem( DSID_USER, m_pUserName->GetText() ) );
554 0 : _rSet->Put( SfxStringItem( DSID_PASSWORD, OUString()));
555 0 : bChangedSomething = true;
556 : }
557 0 : fillBool(*_rSet,m_pPasswordRequired,DSID_PASSWORDREQUIRED,bChangedSomething);
558 :
559 0 : return bChangedSomething;
560 : }
561 0 : void MySQLNativePage::implInitControls(const SfxItemSet& _rSet, bool _bSaveValue)
562 : {
563 : // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
564 : bool bValid, bReadonly;
565 0 : getFlags(_rSet, bValid, bReadonly);
566 :
567 0 : m_aMySQLSettings.implInitControls( _rSet );
568 :
569 0 : SFX_ITEMSET_GET(_rSet, pUidItem, SfxStringItem, DSID_USER, true);
570 0 : SFX_ITEMSET_GET(_rSet, pAllowEmptyPwd, SfxBoolItem, DSID_PASSWORDREQUIRED, true);
571 :
572 0 : if ( bValid )
573 : {
574 0 : m_pUserName->SetText(pUidItem->GetValue());
575 0 : m_pUserName->ClearModifyFlag();
576 0 : m_pPasswordRequired->Check(pAllowEmptyPwd->GetValue());
577 : }
578 :
579 0 : OCommonBehaviourTabPage::implInitControls(_rSet, _bSaveValue);
580 0 : }
581 :
582 0 : SfxTabPage* ODriversSettings::CreateMySQLJDBC( vcl::Window* pParent, const SfxItemSet* _rAttrSet )
583 : {
584 0 : return ( new OGeneralSpecialJDBCDetailsPage( pParent, *_rAttrSet,DSID_MYSQL_PORTNUMBER ) );
585 : }
586 0 : SfxTabPage* ODriversSettings::CreateMySQLNATIVE( vcl::Window* pParent, const SfxItemSet* _rAttrSet )
587 : {
588 0 : return ( new MySQLNativePage( pParent, *_rAttrSet ) );
589 : }
590 :
591 0 : SfxTabPage* ODriversSettings::CreateOracleJDBC( vcl::Window* pParent, const SfxItemSet* _rAttrSet )
592 : {
593 0 : return ( new OGeneralSpecialJDBCDetailsPage( pParent, *_rAttrSet,DSID_ORACLE_PORTNUMBER, false) );
594 : }
595 :
596 : // OLDAPDetailsPage
597 0 : OLDAPDetailsPage::OLDAPDetailsPage( vcl::Window* pParent, const SfxItemSet& _rCoreAttrs )
598 0 : :OCommonBehaviourTabPage(pParent, "LDAP", "dbaccess/ui/ldappage.ui", _rCoreAttrs, 0)
599 : {
600 0 : get(m_pETBaseDN, "baseDNEntry");
601 0 : get(m_pCBUseSSL, "useSSLCheckbutton");
602 0 : get(m_pNFPortNumber, "portNumberSpinbutton");
603 0 : m_pNFPortNumber->SetUseThousandSep(false);
604 0 : get(m_pNFRowCount, "LDAPRowCountspinbutton");
605 :
606 0 : m_pETBaseDN->SetModifyHdl(getControlModifiedLink());
607 0 : m_pCBUseSSL->SetToggleHdl(getControlModifiedLink());
608 0 : m_pNFPortNumber->SetModifyHdl(getControlModifiedLink());
609 0 : m_pNFRowCount->SetModifyHdl(getControlModifiedLink());
610 :
611 0 : m_pNFRowCount->SetUseThousandSep(false);
612 0 : m_iNormalPort = 389;
613 0 : m_iSSLPort = 636;
614 0 : m_pCBUseSSL->SetClickHdl(LINK(this, OLDAPDetailsPage,OnCheckBoxClick));
615 0 : }
616 :
617 0 : SfxTabPage* ODriversSettings::CreateLDAP( vcl::Window* pParent, const SfxItemSet* _rAttrSet )
618 : {
619 0 : return ( new OLDAPDetailsPage( pParent, *_rAttrSet ) );
620 : }
621 :
622 0 : bool OLDAPDetailsPage::FillItemSet( SfxItemSet* _rSet )
623 : {
624 0 : bool bChangedSomething = OCommonBehaviourTabPage::FillItemSet(_rSet);
625 :
626 0 : fillString(*_rSet,m_pETBaseDN,DSID_CONN_LDAP_BASEDN,bChangedSomething);
627 0 : fillInt32(*_rSet,m_pNFPortNumber,DSID_CONN_LDAP_PORTNUMBER,bChangedSomething);
628 0 : fillInt32(*_rSet,m_pNFRowCount,DSID_CONN_LDAP_ROWCOUNT,bChangedSomething);
629 0 : fillBool(*_rSet,m_pCBUseSSL,DSID_CONN_LDAP_USESSL,bChangedSomething);
630 0 : return bChangedSomething;
631 : }
632 0 : IMPL_LINK( OLDAPDetailsPage, OnCheckBoxClick, CheckBox*, pCheckBox )
633 : {
634 0 : callModifiedHdl();
635 0 : if ( pCheckBox == m_pCBUseSSL)
636 : {
637 0 : if ( m_pCBUseSSL->IsChecked() )
638 : {
639 0 : m_iNormalPort = static_cast<sal_Int32>(m_pNFPortNumber->GetValue());
640 0 : m_pNFPortNumber->SetValue(m_iSSLPort);
641 : }
642 : else
643 : {
644 0 : m_iSSLPort = static_cast<sal_Int32>(m_pNFPortNumber->GetValue());
645 0 : m_pNFPortNumber->SetValue(m_iNormalPort);
646 : }
647 : }
648 0 : return 0;
649 : }
650 :
651 0 : void OLDAPDetailsPage::implInitControls(const SfxItemSet& _rSet, bool _bSaveValue)
652 : {
653 : // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
654 : bool bValid, bReadonly;
655 0 : getFlags(_rSet, bValid, bReadonly);
656 :
657 0 : SFX_ITEMSET_GET(_rSet, pBaseDN, SfxStringItem, DSID_CONN_LDAP_BASEDN, true);
658 0 : SFX_ITEMSET_GET(_rSet, pUseSSL, SfxBoolItem, DSID_CONN_LDAP_USESSL, true);
659 0 : SFX_ITEMSET_GET(_rSet, pPortNumber, SfxInt32Item, DSID_CONN_LDAP_PORTNUMBER, true);
660 0 : SFX_ITEMSET_GET(_rSet, pRowCount, SfxInt32Item, DSID_CONN_LDAP_ROWCOUNT, true);
661 :
662 0 : if ( bValid )
663 : {
664 0 : m_pETBaseDN->SetText(pBaseDN->GetValue());
665 0 : m_pNFPortNumber->SetValue(pPortNumber->GetValue());
666 0 : m_pNFRowCount->SetValue(pRowCount->GetValue());
667 0 : m_pCBUseSSL->Check(pUseSSL->GetValue());
668 : }
669 :
670 0 : OCommonBehaviourTabPage::implInitControls(_rSet, _bSaveValue);
671 0 : }
672 :
673 : // OTextDetailsPage
674 0 : OTextDetailsPage::OTextDetailsPage( vcl::Window* pParent, const SfxItemSet& _rCoreAttrs )
675 0 : :OCommonBehaviourTabPage(pParent, "EmptyPage", "dbaccess/ui/emptypage.ui", _rCoreAttrs, 0)
676 : {
677 :
678 0 : m_pTextConnectionHelper = new OTextConnectionHelper( get<VclVBox>("EmptyPage"), TC_EXTENSION | TC_HEADER | TC_SEPARATORS | TC_CHARSET );
679 0 : }
680 :
681 0 : OTextDetailsPage::~OTextDetailsPage()
682 : {
683 0 : DELETEZ(m_pTextConnectionHelper);
684 :
685 0 : }
686 :
687 0 : SfxTabPage* ODriversSettings::CreateText( vcl::Window* pParent, const SfxItemSet* _rAttrSet )
688 : {
689 0 : return ( new OTextDetailsPage( pParent, *_rAttrSet ) );
690 : }
691 0 : void OTextDetailsPage::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
692 : {
693 0 : OCommonBehaviourTabPage::fillControls(_rControlList);
694 0 : m_pTextConnectionHelper->fillControls(_rControlList);
695 :
696 0 : }
697 0 : void OTextDetailsPage::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
698 : {
699 0 : OCommonBehaviourTabPage::fillWindows(_rControlList);
700 0 : m_pTextConnectionHelper->fillWindows(_rControlList);
701 :
702 0 : }
703 0 : void OTextDetailsPage::implInitControls(const SfxItemSet& _rSet, bool _bSaveValue)
704 : {
705 : // first check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
706 : bool bValid, bReadonly;
707 0 : getFlags(_rSet, bValid, bReadonly);
708 :
709 0 : m_pTextConnectionHelper->implInitControls(_rSet, bValid);
710 0 : OCommonBehaviourTabPage::implInitControls(_rSet, _bSaveValue);
711 0 : }
712 :
713 0 : bool OTextDetailsPage::FillItemSet( SfxItemSet* rSet )
714 : {
715 0 : bool bChangedSomething = OCommonBehaviourTabPage::FillItemSet(rSet);
716 0 : bChangedSomething = m_pTextConnectionHelper->FillItemSet(*rSet, bChangedSomething);
717 0 : return bChangedSomething;
718 : }
719 :
720 0 : bool OTextDetailsPage::prepareLeave()
721 : {
722 0 : return m_pTextConnectionHelper->prepareLeave();
723 : }
724 :
725 0 : SfxTabPage* ODriversSettings::CreateGeneratedValuesPage( vcl::Window* _pParent, const SfxItemSet* _rAttrSet )
726 : {
727 0 : return new GeneratedValuesPage( _pParent, *_rAttrSet );
728 : }
729 :
730 0 : SfxTabPage* ODriversSettings::CreateSpecialSettingsPage( vcl::Window* _pParent, const SfxItemSet* _rAttrSet )
731 : {
732 0 : OUString eType = ODbDataSourceAdministrationHelper::getDatasourceType( *_rAttrSet );
733 0 : DataSourceMetaData aMetaData( eType );
734 0 : return new SpecialSettingsPage( _pParent, *_rAttrSet, aMetaData );
735 : }
736 72 : } // namespace dbaui
737 :
738 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|