1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_dbaccess.hxx"
26 
27 #include "detailpages.hxx"
28 #include "sqlmessage.hxx"
29 #include "dsmeta.hxx"
30 #include "advancedsettings.hxx"
31 #include "DbAdminImpl.hxx"
32 #include "dsitems.hxx"
33 #include "dbfindex.hxx"
34 #include "localresaccess.hxx"
35 #include "dsnItem.hxx"
36 
37 #include "dbaccess_helpid.hrc"
38 #include "dbu_dlg.hrc"
39 #include "dbadmin.hrc"
40 
41 #ifndef _SFXITEMSET_HXX
42 #include <svl/itemset.hxx>
43 #endif
44 #ifndef _SFXSTRITEM_HXX
45 #include <svl/stritem.hxx>
46 #endif
47 #ifndef _SFXENUMITEM_HXX
48 #include <svl/eitem.hxx>
49 #endif
50 #ifndef _SFXINTITEM_HXX
51 #include <svl/intitem.hxx>
52 #endif
53 #ifndef _SV_MSGBOX_HXX
54 #include <vcl/msgbox.hxx>
55 #endif
56 #ifndef _SV_MNEMONIC_HXX
57 #include <vcl/mnemonic.hxx>
58 #endif
59 #ifndef _SVTOOLS_CJKOPTIONS_HXX
60 #include <svl/cjkoptions.hxx>
61 #endif
62 #include <jvmaccess/virtualmachine.hxx>
63 #ifndef DBAUI_ADABASPAGE_HRC
64 #include "AdabasPage.hrc"
65 #endif
66 #ifndef _DBAUI_ADASTAT_HXX_
67 #include "AdabasStat.hxx"
68 #endif
69 #ifndef _CONNECTIVITY_COMMONTOOLS_HXX_
70 #include <connectivity/CommonTools.hxx>
71 #endif
72 #ifndef DBAUI_DRIVERSETTINGS_HXX
73 #include "DriverSettings.hxx"
74 #endif
75 #ifndef _DBAUI_DBADMIN_HXX_
76 #include "dbadmin.hxx"
77 #endif
78 #ifndef _COMPHELPER_TYPES_HXX_
79 #include <comphelper/types.hxx>
80 #endif
81 #include "AutoControls.hrc"
82 
83 //.........................................................................
84 namespace dbaui
85 {
86 //.........................................................................
87 
88 	using namespace ::com::sun::star::uno;
89 	using namespace ::com::sun::star::sdbc;
90 	using namespace ::com::sun::star::beans;
91 	using namespace ::com::sun::star::lang;
92 	using namespace ::com::sun::star::container;
93 	using namespace ::dbtools;
94 
95 	//========================================================================
96 	//= OCommonBehaviourTabPage
97     //========================================================================
DBG_NAME(OCommonBehaviourTabPage)98     DBG_NAME(OCommonBehaviourTabPage)
99     //------------------------------------------------------------------------
100 	OCommonBehaviourTabPage::OCommonBehaviourTabPage(Window* pParent, sal_uInt16 nResId, const SfxItemSet& _rCoreAttrs,
101 		sal_uInt32 nControlFlags,bool _bFreeResource)
102 
103 		:OGenericAdministrationPage(pParent, ModuleRes(nResId), _rCoreAttrs)
104 		,m_pOptionsLabel(NULL)
105 		,m_pOptions(NULL)
106 		,m_pDataConvertFixedLine(NULL)
107 		,m_pCharsetLabel(NULL)
108 		,m_pCharset(NULL)
109         ,m_pAutoFixedLine(NULL)
110 		,m_pAutoRetrievingEnabled(NULL)
111 		,m_pAutoIncrementLabel(NULL)
112 		,m_pAutoIncrement(NULL)
113 		,m_pAutoRetrievingLabel(NULL)
114 		,m_pAutoRetrieving(NULL)
115 		,m_nControlFlags(nControlFlags)
116 	{
117         DBG_CTOR(OCommonBehaviourTabPage,NULL);
118 
119 		if ((m_nControlFlags & CBTP_USE_OPTIONS) == CBTP_USE_OPTIONS)
120 		{
121 			m_pOptionsLabel = new FixedText(this, ModuleRes(FT_OPTIONS));
122 			m_pOptions = new Edit(this, ModuleRes(ET_OPTIONS));
123 			m_pOptions->SetModifyHdl(getControlModifiedLink());
124 		}
125 
126 		if ((m_nControlFlags & CBTP_USE_CHARSET) == CBTP_USE_CHARSET)
127 		{
128 			m_pDataConvertFixedLine = new FixedLine(this, ModuleRes(FL_DATACONVERT));
129 			m_pCharsetLabel = new FixedText(this, ModuleRes(FT_CHARSET));
130 			m_pCharset = new CharSetListBox(this, ModuleRes(LB_CHARSET));
131 			m_pCharset->SetSelectHdl(getControlModifiedLink());
132 		}
133 
134 		Window* pWindows[] = { 	m_pAutoRetrievingEnabled, m_pAutoFixedLine,
135 								m_pAutoIncrementLabel, m_pAutoIncrement,
136 								m_pAutoRetrievingLabel, m_pAutoRetrieving };
137 
138 		sal_Int32 nCount = sizeof(pWindows) / sizeof(pWindows[0]);
139 		for (sal_Int32 i=1; i < nCount; ++i)
140 		{
141 			if ( pWindows[i] )
142 			{
143 				Window* pPrev = pWindows[i-1];
144 				for (sal_Int32 j = i-1; pPrev == NULL && j >= 0 ; --j)
145 				{
146 					pPrev = pWindows[j];
147 				}
148 				if ( pPrev )
149 					pWindows[i]->SetZOrder(pPrev, WINDOW_ZORDER_BEHIND);
150 			}
151 		}
152 
153 		if ( _bFreeResource )
154 			FreeResource();
155 	}
156 
157 	// -----------------------------------------------------------------------
~OCommonBehaviourTabPage()158 	OCommonBehaviourTabPage::~OCommonBehaviourTabPage()
159 	{
160 		DELETEZ(m_pOptionsLabel);
161 		DELETEZ(m_pOptions);
162 
163 		DELETEZ(m_pDataConvertFixedLine);
164 		DELETEZ(m_pCharsetLabel);
165 		DELETEZ(m_pCharset);
166 
167 		DELETEZ(m_pAutoFixedLine);
168 		DELETEZ(m_pAutoIncrementLabel);
169 		DELETEZ(m_pAutoIncrement);
170 
171 		DELETEZ(m_pAutoRetrievingEnabled);
172 		DELETEZ(m_pAutoRetrievingLabel);
173 		DELETEZ(m_pAutoRetrieving);
174 
175         DBG_DTOR(OCommonBehaviourTabPage,NULL);
176     }
177 
178 	// -----------------------------------------------------------------------
fillWindows(::std::vector<ISaveValueWrapper * > & _rControlList)179 	void OCommonBehaviourTabPage::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
180 	{
181 		if ((m_nControlFlags & CBTP_USE_OPTIONS) == CBTP_USE_OPTIONS)
182 		{
183 			_rControlList.push_back(new ODisableWrapper<FixedText>(m_pOptionsLabel));
184 		}
185 
186 		if ((m_nControlFlags & CBTP_USE_CHARSET) == CBTP_USE_CHARSET)
187 		{
188 			_rControlList.push_back(new ODisableWrapper<FixedLine>(m_pDataConvertFixedLine));
189 			_rControlList.push_back(new ODisableWrapper<FixedText>(m_pCharsetLabel));
190 		}
191 	}
192 	// -----------------------------------------------------------------------
fillControls(::std::vector<ISaveValueWrapper * > & _rControlList)193 	void OCommonBehaviourTabPage::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
194 	{
195 		if ((m_nControlFlags & CBTP_USE_OPTIONS) == CBTP_USE_OPTIONS)
196 			_rControlList.push_back(new OSaveValueWrapper<Edit>(m_pOptions));
197 
198 		if ((m_nControlFlags & CBTP_USE_CHARSET) == CBTP_USE_CHARSET)
199 			_rControlList.push_back(new OSaveValueWrapper<ListBox>(m_pCharset));
200 	}
201 
202 	// -----------------------------------------------------------------------
implInitControls(const SfxItemSet & _rSet,sal_Bool _bSaveValue)203 	void OCommonBehaviourTabPage::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue)
204 	{
205 		// check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
206 		sal_Bool bValid, bReadonly;
207 		getFlags(_rSet, bValid, bReadonly);
208 
209 		// collect the items
210 		SFX_ITEMSET_GET(_rSet, pOptionsItem, SfxStringItem, DSID_ADDITIONALOPTIONS, sal_True);
211 		SFX_ITEMSET_GET(_rSet, pCharsetItem, SfxStringItem, DSID_CHARSET, sal_True);
212 
213 		// forward the values to the controls
214 		if (bValid)
215 		{
216 			if ((m_nControlFlags & CBTP_USE_OPTIONS) == CBTP_USE_OPTIONS)
217 			{
218 				m_pOptions->SetText(pOptionsItem->GetValue());
219 				m_pOptions->ClearModifyFlag();
220 			}
221 
222 			if ((m_nControlFlags & CBTP_USE_CHARSET) == CBTP_USE_CHARSET)
223 			{
224                 m_pCharset->SelectEntryByIanaName( pCharsetItem->GetValue() );
225 			}
226 		}
227 		OGenericAdministrationPage::implInitControls(_rSet, _bSaveValue);
228 	}
229 	// -----------------------------------------------------------------------
FillItemSet(SfxItemSet & _rSet)230 	sal_Bool OCommonBehaviourTabPage::FillItemSet(SfxItemSet& _rSet)
231 	{
232 		sal_Bool bChangedSomething = sal_False;
233 
234 		if ((m_nControlFlags & CBTP_USE_OPTIONS) == CBTP_USE_OPTIONS)
235 		{
236 			fillString(_rSet,m_pOptions,DSID_ADDITIONALOPTIONS,bChangedSomething);
237 		}
238 
239 		if ((m_nControlFlags & CBTP_USE_CHARSET) == CBTP_USE_CHARSET)
240 		{
241             if ( m_pCharset->StoreSelectedCharSet( _rSet, DSID_CHARSET ) )
242 				bChangedSomething = sal_True;
243 		}
244 
245 		return bChangedSomething;
246 	}
247 
248 	//========================================================================
249 	//= ODbaseDetailsPage
250 	//========================================================================
DBG_NAME(ODbaseDetailsPage)251     DBG_NAME(ODbaseDetailsPage)
252     //------------------------------------------------------------------------
253 	ODbaseDetailsPage::ODbaseDetailsPage( Window* pParent, const SfxItemSet& _rCoreAttrs )
254 		:OCommonBehaviourTabPage(pParent, PAGE_DBASE, _rCoreAttrs, CBTP_USE_CHARSET ,false)
255 		,m_aShowDeleted		(this, ModuleRes(CB_SHOWDELETEDROWS))
256 		,m_aFL_1			(this, ModuleRes( FL_SEPARATOR1) )
257 		,m_aFT_Message		(this, ModuleRes( FT_SPECIAL_MESSAGE) )
258 		,m_aIndexes			(this, ModuleRes(PB_INDICIES))
259 	{
260         DBG_CTOR(ODbaseDetailsPage,NULL);
261 
262 		m_aIndexes.SetClickHdl(LINK(this, ODbaseDetailsPage, OnButtonClicked));
263 		m_aShowDeleted.SetClickHdl(LINK(this, ODbaseDetailsPage, OnButtonClicked));
264 
265 		// correct the z-order which is mixed-up because the base class constructed some controls before we did
266 		m_pCharset->SetZOrder(&m_aShowDeleted, WINDOW_ZORDER_BEFOR);
267 
268 		FreeResource();
269 	}
270 
271 	// -----------------------------------------------------------------------
~ODbaseDetailsPage()272 	ODbaseDetailsPage::~ODbaseDetailsPage()
273 	{
274 
275         DBG_DTOR(ODbaseDetailsPage,NULL);
276     }
277 
278 	// -----------------------------------------------------------------------
CreateDbase(Window * pParent,const SfxItemSet & _rAttrSet)279 	SfxTabPage*	ODriversSettings::CreateDbase( Window* pParent,	const SfxItemSet& _rAttrSet )
280 	{
281 		return ( new ODbaseDetailsPage( pParent, _rAttrSet ) );
282 	}
283 
284 	// -----------------------------------------------------------------------
fillControls(::std::vector<ISaveValueWrapper * > & _rControlList)285 	void ODbaseDetailsPage::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
286 	{
287 		OCommonBehaviourTabPage::fillControls(_rControlList);
288 		_rControlList.push_back(new OSaveValueWrapper<CheckBox>(&m_aShowDeleted));
289 	}
290 	// -----------------------------------------------------------------------
fillWindows(::std::vector<ISaveValueWrapper * > & _rControlList)291 	void ODbaseDetailsPage::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
292 	{
293 		OCommonBehaviourTabPage::fillWindows(_rControlList);
294 		_rControlList.push_back(new ODisableWrapper<FixedLine>(&m_aFL_1));
295 		_rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFT_Message));
296 		_rControlList.push_back(new ODisableWrapper<PushButton>(&m_aIndexes));
297 	}
298 	// -----------------------------------------------------------------------
implInitControls(const SfxItemSet & _rSet,sal_Bool _bSaveValue)299 	void ODbaseDetailsPage::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue)
300 	{
301 		// check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
302 		sal_Bool bValid, bReadonly;
303 		getFlags(_rSet, bValid, bReadonly);
304 
305 		// get the DSN string (needed for the index dialog)
306 		SFX_ITEMSET_GET(_rSet, pUrlItem, SfxStringItem, DSID_CONNECTURL, sal_True);
307 		SFX_ITEMSET_GET(_rSet, pTypesItem, DbuTypeCollectionItem, DSID_TYPECOLLECTION, sal_True);
308 		::dbaccess::ODsnTypeCollection* pTypeCollection = pTypesItem ? pTypesItem->getCollection() : NULL;
309 		if (pTypeCollection && pUrlItem && pUrlItem->GetValue().Len())
310 			m_sDsn = pTypeCollection->cutPrefix(pUrlItem->GetValue());
311 
312 		// get the other relevant items
313 		SFX_ITEMSET_GET(_rSet, pDeletedItem, SfxBoolItem, DSID_SHOWDELETEDROWS, sal_True);
314 
315 		if ( bValid )
316 		{
317 			m_aShowDeleted.Check( pDeletedItem->GetValue() );
318 			m_aFT_Message.Show(m_aShowDeleted.IsChecked());
319 		}
320 
321 		OCommonBehaviourTabPage::implInitControls(_rSet, _bSaveValue);
322 	}
323 
324 	// -----------------------------------------------------------------------
FillItemSet(SfxItemSet & _rSet)325 	sal_Bool ODbaseDetailsPage::FillItemSet( SfxItemSet& _rSet )
326 	{
327 		sal_Bool bChangedSomething = OCommonBehaviourTabPage::FillItemSet(_rSet);
328 
329 		fillBool(_rSet,&m_aShowDeleted,DSID_SHOWDELETEDROWS,bChangedSomething);
330 		return bChangedSomething;
331 	}
332 
333 	//------------------------------------------------------------------------
IMPL_LINK(ODbaseDetailsPage,OnButtonClicked,Button *,pButton)334 	IMPL_LINK( ODbaseDetailsPage, OnButtonClicked, Button*, pButton )
335 	{
336 		if (&m_aIndexes == pButton)
337 		{
338 			ODbaseIndexDialog aIndexDialog(this, m_sDsn);
339 			aIndexDialog.Execute();
340 		}
341 		else
342 		{
343 			m_aFT_Message.Show(m_aShowDeleted.IsChecked());
344 			// it was one of the checkboxes -> we count as modified from now on
345 			callModifiedHdl();
346 		}
347 
348 		return 0;
349 	}
350 
351 	//========================================================================
352 	//= OAdoDetailsPage
353     //========================================================================
DBG_NAME(OAdoDetailsPage)354     DBG_NAME(OAdoDetailsPage)
355 	// -----------------------------------------------------------------------
356 	OAdoDetailsPage::OAdoDetailsPage( Window* pParent, const SfxItemSet& _rCoreAttrs )
357 		:OCommonBehaviourTabPage(pParent, PAGE_ADO, _rCoreAttrs, CBTP_USE_CHARSET )
358 	{
359         DBG_CTOR(OAdoDetailsPage,NULL);
360 
361 	}
362 
363 	// -----------------------------------------------------------------------
~OAdoDetailsPage()364 	OAdoDetailsPage::~OAdoDetailsPage()
365 	{
366 
367         DBG_DTOR(OAdoDetailsPage,NULL);
368     }
369 	// -----------------------------------------------------------------------
CreateAdo(Window * pParent,const SfxItemSet & _rAttrSet)370 	SfxTabPage*	ODriversSettings::CreateAdo( Window* pParent,	const SfxItemSet& _rAttrSet )
371 	{
372 		return ( new OAdoDetailsPage( pParent, _rAttrSet ) );
373 	}
374 
375 	// -----------------------------------------------------------------------
376 	//========================================================================
377 	//= OOdbcDetailsPage
378 	//========================================================================
OOdbcDetailsPage(Window * pParent,const SfxItemSet & _rCoreAttrs)379 	OOdbcDetailsPage::OOdbcDetailsPage( Window* pParent, const SfxItemSet& _rCoreAttrs )
380 		:OCommonBehaviourTabPage(pParent, PAGE_ODBC, _rCoreAttrs, CBTP_USE_CHARSET | CBTP_USE_OPTIONS,false)
381 		,m_aFL_1		(this, ModuleRes(FL_SEPARATOR1))
382 		,m_aUseCatalog	(this, ModuleRes(CB_USECATALOG))
383 	{
384 		m_aUseCatalog.SetToggleHdl(getControlModifiedLink());
385 		FreeResource();
386 
387 		Window* pWindows[] = {  m_pCharsetLabel, m_pCharset
388 								,m_pOptionsLabel,m_pOptions,&m_aUseCatalog
389 								};
390 
391 		sal_Int32 nCount = sizeof(pWindows) / sizeof(pWindows[0]);
392 		for (sal_Int32 i=1; i < nCount; ++i)
393 			pWindows[i]->SetZOrder(pWindows[i-1], WINDOW_ZORDER_BEHIND);
394 	}
395 
396 	// -----------------------------------------------------------------------
CreateODBC(Window * pParent,const SfxItemSet & _rAttrSet)397 	SfxTabPage*	ODriversSettings::CreateODBC( Window* pParent, const SfxItemSet& _rAttrSet )
398 	{
399 		return ( new OOdbcDetailsPage( pParent, _rAttrSet ) );
400 	}
401 
402 	// -----------------------------------------------------------------------
FillItemSet(SfxItemSet & _rSet)403 	sal_Bool OOdbcDetailsPage::FillItemSet( SfxItemSet& _rSet )
404 	{
405 		sal_Bool bChangedSomething = OCommonBehaviourTabPage::FillItemSet(_rSet);
406 		fillBool(_rSet,&m_aUseCatalog,DSID_USECATALOG,bChangedSomething);
407 		return bChangedSomething;
408 	}
409 	// -----------------------------------------------------------------------
fillControls(::std::vector<ISaveValueWrapper * > & _rControlList)410 	void OOdbcDetailsPage::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
411 	{
412 		OCommonBehaviourTabPage::fillControls(_rControlList);
413 		_rControlList.push_back(new OSaveValueWrapper<CheckBox>(&m_aUseCatalog));
414 	}
415 	// -----------------------------------------------------------------------
fillWindows(::std::vector<ISaveValueWrapper * > & _rControlList)416 	void OOdbcDetailsPage::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
417 	{
418 		OCommonBehaviourTabPage::fillWindows(_rControlList);
419 		_rControlList.push_back(new ODisableWrapper<FixedLine>(&m_aFL_1));
420 	}
421 	// -----------------------------------------------------------------------
implInitControls(const SfxItemSet & _rSet,sal_Bool _bSaveValue)422 	void OOdbcDetailsPage::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue)
423 	{
424 		// check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
425 		sal_Bool bValid, bReadonly;
426 		getFlags(_rSet, bValid, bReadonly);
427 
428 		SFX_ITEMSET_GET(_rSet, pUseCatalogItem, SfxBoolItem, DSID_USECATALOG, sal_True);
429 
430 		if ( bValid )
431 			m_aUseCatalog.Check(pUseCatalogItem->GetValue());
432 
433 		OCommonBehaviourTabPage::implInitControls(_rSet, _bSaveValue);
434 	}
435 	//========================================================================
436 	//= OOdbcDetailsPage
437 	//========================================================================
OUserDriverDetailsPage(Window * pParent,const SfxItemSet & _rCoreAttrs)438 	OUserDriverDetailsPage::OUserDriverDetailsPage( Window* pParent, const SfxItemSet& _rCoreAttrs )
439 		:OCommonBehaviourTabPage(pParent, PAGE_USERDRIVER, _rCoreAttrs,
440 		CBTP_USE_CHARSET | CBTP_USE_OPTIONS ,false)
441 		,m_aFTHostname		(this, ModuleRes(FT_HOSTNAME))
442 		,m_aEDHostname		(this, ModuleRes(ET_HOSTNAME))
443 		,m_aPortNumber		(this, ModuleRes(FT_PORTNUMBER))
444 		,m_aNFPortNumber	(this, ModuleRes(NF_PORTNUMBER))
445 		,m_aUseCatalog		(this, ModuleRes(CB_USECATALOG))
446 	{
447 		m_aUseCatalog.SetToggleHdl(getControlModifiedLink());
448 		FreeResource();
449 	}
450 
451 	// -----------------------------------------------------------------------
CreateUser(Window * pParent,const SfxItemSet & _rAttrSet)452 	SfxTabPage*	ODriversSettings::CreateUser( Window* pParent, const SfxItemSet& _rAttrSet )
453 	{
454 		return ( new OUserDriverDetailsPage( pParent, _rAttrSet ) );
455 	}
456 
457 	// -----------------------------------------------------------------------
FillItemSet(SfxItemSet & _rSet)458 	sal_Bool OUserDriverDetailsPage::FillItemSet( SfxItemSet& _rSet )
459 	{
460 		sal_Bool bChangedSomething = OCommonBehaviourTabPage::FillItemSet(_rSet);
461 
462 		fillInt32(_rSet,&m_aNFPortNumber,DSID_CONN_PORTNUMBER,bChangedSomething);
463 		fillString(_rSet,&m_aEDHostname,DSID_CONN_HOSTNAME,bChangedSomething);
464 		fillBool(_rSet,&m_aUseCatalog,DSID_USECATALOG,bChangedSomething);
465 
466 		return bChangedSomething;
467 	}
468 	// -----------------------------------------------------------------------
fillControls(::std::vector<ISaveValueWrapper * > & _rControlList)469 	void OUserDriverDetailsPage::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
470 	{
471 		OCommonBehaviourTabPage::fillControls(_rControlList);
472 		_rControlList.push_back(new OSaveValueWrapper<Edit>(&m_aEDHostname));
473 		_rControlList.push_back(new OSaveValueWrapper<CheckBox>(&m_aUseCatalog));
474 		_rControlList.push_back(new OSaveValueWrapper<NumericField>(&m_aNFPortNumber));
475 	}
476 	// -----------------------------------------------------------------------
fillWindows(::std::vector<ISaveValueWrapper * > & _rControlList)477 	void OUserDriverDetailsPage::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
478 	{
479 		OCommonBehaviourTabPage::fillWindows(_rControlList);
480 		_rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTHostname));
481 		_rControlList.push_back(new ODisableWrapper<FixedText>(&m_aPortNumber));
482 	}
483 	// -----------------------------------------------------------------------
implInitControls(const SfxItemSet & _rSet,sal_Bool _bSaveValue)484 	void OUserDriverDetailsPage::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue)
485 	{
486 		// check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
487 		sal_Bool bValid, bReadonly;
488 		getFlags(_rSet, bValid, bReadonly);
489 
490 		SFX_ITEMSET_GET(_rSet, pUseCatalogItem, SfxBoolItem, DSID_USECATALOG, sal_True);
491 		SFX_ITEMSET_GET(_rSet, pHostName, SfxStringItem, DSID_CONN_HOSTNAME, sal_True);
492 		SFX_ITEMSET_GET(_rSet, pPortNumber, SfxInt32Item, DSID_CONN_PORTNUMBER, sal_True);
493 
494 		if ( bValid )
495 		{
496 			m_aEDHostname.SetText(pHostName->GetValue());
497 			m_aEDHostname.ClearModifyFlag();
498 
499 			m_aNFPortNumber.SetValue(pPortNumber->GetValue());
500 			m_aNFPortNumber.ClearModifyFlag();
501 
502 			m_aUseCatalog.Check(pUseCatalogItem->GetValue());
503 		}
504 
505 		OCommonBehaviourTabPage::implInitControls(_rSet, _bSaveValue);
506 	}
507 	//========================================================================
508 	//= OMySQLODBCDetailsPage
509 	//========================================================================
OMySQLODBCDetailsPage(Window * pParent,const SfxItemSet & _rCoreAttrs)510 	OMySQLODBCDetailsPage::OMySQLODBCDetailsPage( Window* pParent, const SfxItemSet& _rCoreAttrs )
511 		:OCommonBehaviourTabPage(pParent, PAGE_MYSQL_ODBC, _rCoreAttrs, CBTP_USE_CHARSET )
512 	{
513 	}
514 
515 	// -----------------------------------------------------------------------
CreateMySQLODBC(Window * pParent,const SfxItemSet & _rAttrSet)516 	SfxTabPage*	ODriversSettings::CreateMySQLODBC( Window* pParent, const SfxItemSet& _rAttrSet )
517 	{
518 		return ( new OMySQLODBCDetailsPage( pParent, _rAttrSet ) );
519 	}
520 
521 	//========================================================================
522 	//= OMySQLJDBCDetailsPage
523 	//========================================================================
OGeneralSpecialJDBCDetailsPage(Window * pParent,sal_uInt16 _nResId,const SfxItemSet & _rCoreAttrs,sal_uInt16 _nPortId)524 	OGeneralSpecialJDBCDetailsPage::OGeneralSpecialJDBCDetailsPage( Window* pParent,sal_uInt16 _nResId, const SfxItemSet& _rCoreAttrs ,sal_uInt16 _nPortId)
525 		:OCommonBehaviourTabPage(pParent, _nResId, _rCoreAttrs, CBTP_USE_CHARSET ,false)
526 		,m_aFL_1			(this, ModuleRes( FL_SEPARATOR1) )
527 		,m_aFTHostname		(this, ModuleRes(FT_HOSTNAME))
528 		,m_aEDHostname		(this, ModuleRes(ET_HOSTNAME))
529 		,m_aPortNumber		(this, ModuleRes(FT_PORTNUMBER))
530 		,m_aNFPortNumber	(this, ModuleRes(NF_PORTNUMBER))
531         ,m_aFTSocket		(this, ModuleRes(FT_SOCKET))
532 		,m_aEDSocket		(this, ModuleRes(ET_SOCKET))
533 		,m_aFTDriverClass	(this, ModuleRes(FT_JDBCDRIVERCLASS))
534 		,m_aEDDriverClass	(this, ModuleRes(ET_JDBCDRIVERCLASS))
535 		,m_aTestJavaDriver	(this, ModuleRes(PB_TESTDRIVERCLASS))
536 		,m_nPortId(_nPortId)
537         ,m_bUseClass(true)
538 	{
539         SFX_ITEMSET_GET(_rCoreAttrs, pUrlItem, SfxStringItem, DSID_CONNECTURL, sal_True);
540         SFX_ITEMSET_GET(_rCoreAttrs, pTypesItem, DbuTypeCollectionItem, DSID_TYPECOLLECTION, sal_True);
541 	    ::dbaccess::ODsnTypeCollection* pTypeCollection = pTypesItem ? pTypesItem->getCollection() : NULL;
542 	    if (pTypeCollection && pUrlItem && pUrlItem->GetValue().Len() )
543         {
544             m_sDefaultJdbcDriverName = pTypeCollection->getJavaDriverClass(pUrlItem->GetValue());
545         }
546         if ( m_sDefaultJdbcDriverName.Len() )
547         {
548             m_aEDDriverClass.SetModifyHdl(getControlModifiedLink());
549             m_aEDDriverClass.SetModifyHdl(LINK(this, OGeneralSpecialJDBCDetailsPage, OnEditModified));
550 		    m_aTestJavaDriver.SetClickHdl(LINK(this,OGeneralSpecialJDBCDetailsPage,OnTestJavaClickHdl));
551         }
552         else
553         {
554             m_bUseClass = false;
555             m_aFTDriverClass.Show(sal_False);
556             m_aEDDriverClass.Show(sal_False);
557             m_aTestJavaDriver.Show(sal_False);
558         }
559 
560         m_aFTSocket.Show(PAGE_MYSQL_JDBC == _nResId && !m_bUseClass);
561         m_aEDSocket.Show(PAGE_MYSQL_JDBC == _nResId && !m_bUseClass);
562 
563 		m_aEDHostname.SetModifyHdl(getControlModifiedLink());
564 		m_aNFPortNumber.SetModifyHdl(getControlModifiedLink());
565         m_aEDSocket.SetModifyHdl(getControlModifiedLink());
566 
567 		Window* pWindows[] = {  &m_aFTHostname,&m_aEDHostname,
568 								&m_aPortNumber,&m_aNFPortNumber,&m_aFTSocket,&m_aEDSocket,
569 								&m_aFTDriverClass, &m_aEDDriverClass,&m_aTestJavaDriver,
570 								m_pCharsetLabel, m_pCharset};
571 
572 		sal_Int32 nCount = sizeof(pWindows) / sizeof(pWindows[0]);
573 		for (sal_Int32 i=1; i < nCount; ++i)
574 			pWindows[i]->SetZOrder(pWindows[i-1], WINDOW_ZORDER_BEHIND);
575 
576 		FreeResource();
577 	}
578 
579 	// -----------------------------------------------------------------------
fillControls(::std::vector<ISaveValueWrapper * > & _rControlList)580 	void OGeneralSpecialJDBCDetailsPage::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
581 	{
582 		OCommonBehaviourTabPage::fillControls(_rControlList);
583         if ( m_bUseClass )
584 		    _rControlList.push_back(new OSaveValueWrapper<Edit>(&m_aEDDriverClass));
585 		_rControlList.push_back(new OSaveValueWrapper<Edit>(&m_aEDHostname));
586 		_rControlList.push_back(new OSaveValueWrapper<NumericField>(&m_aNFPortNumber));
587         _rControlList.push_back(new OSaveValueWrapper<Edit>(&m_aEDSocket));
588 	}
589 	// -----------------------------------------------------------------------
fillWindows(::std::vector<ISaveValueWrapper * > & _rControlList)590 	void OGeneralSpecialJDBCDetailsPage::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
591 	{
592 		OCommonBehaviourTabPage::fillWindows(_rControlList);
593 		_rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTHostname));
594 		_rControlList.push_back(new ODisableWrapper<FixedText>(&m_aPortNumber));
595         _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTSocket));
596         if ( m_bUseClass )
597 		    _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTDriverClass));
598 		_rControlList.push_back(new ODisableWrapper<FixedLine>(&m_aFL_1));
599 	}
600 
601 	// -----------------------------------------------------------------------
FillItemSet(SfxItemSet & _rSet)602 	sal_Bool OGeneralSpecialJDBCDetailsPage::FillItemSet( SfxItemSet& _rSet )
603 	{
604 		sal_Bool bChangedSomething = OCommonBehaviourTabPage::FillItemSet(_rSet);
605         if ( m_bUseClass )
606 		    fillString(_rSet,&m_aEDDriverClass,DSID_JDBCDRIVERCLASS,bChangedSomething);
607 		fillString(_rSet,&m_aEDHostname,DSID_CONN_HOSTNAME,bChangedSomething);
608         fillString(_rSet,&m_aEDSocket,DSID_CONN_SOCKET,bChangedSomething);
609 		fillInt32(_rSet,&m_aNFPortNumber,m_nPortId,bChangedSomething );
610 
611 		return bChangedSomething;
612 	}
613 	// -----------------------------------------------------------------------
implInitControls(const SfxItemSet & _rSet,sal_Bool _bSaveValue)614 	void OGeneralSpecialJDBCDetailsPage::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue)
615 	{
616 		// check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
617 		sal_Bool bValid, bReadonly;
618 		getFlags(_rSet, bValid, bReadonly);
619 
620 		SFX_ITEMSET_GET(_rSet, pDrvItem, SfxStringItem, DSID_JDBCDRIVERCLASS, sal_True);
621 		SFX_ITEMSET_GET(_rSet, pHostName, SfxStringItem, DSID_CONN_HOSTNAME, sal_True);
622 		SFX_ITEMSET_GET(_rSet, pPortNumber, SfxInt32Item, m_nPortId, sal_True);
623         SFX_ITEMSET_GET(_rSet, pSocket, SfxStringItem, DSID_CONN_SOCKET, sal_True);
624 
625 		if ( bValid )
626 		{
627             if ( m_bUseClass )
628             {
629 			    m_aEDDriverClass.SetText(pDrvItem->GetValue());
630 			    m_aEDDriverClass.ClearModifyFlag();
631             }
632 
633 			m_aEDHostname.SetText(pHostName->GetValue());
634 			m_aEDHostname.ClearModifyFlag();
635 
636 			m_aNFPortNumber.SetValue(pPortNumber->GetValue());
637 			m_aNFPortNumber.ClearModifyFlag();
638 
639             m_aEDSocket.SetText(pSocket->GetValue());
640 			m_aEDSocket.ClearModifyFlag();
641 		}
642 
643 		OCommonBehaviourTabPage::implInitControls(_rSet, _bSaveValue);
644 
645 		// to get the correcxt value when saveValue was called by base class
646 		if ( m_bUseClass && !m_aEDDriverClass.GetText().Len() )
647 		{
648 			m_aEDDriverClass.SetText(m_sDefaultJdbcDriverName);
649 			m_aEDDriverClass.SetModifyFlag();
650 		}
651 	}
652 	// -----------------------------------------------------------------------
653 	IMPL_LINK(OGeneralSpecialJDBCDetailsPage, OnTestJavaClickHdl, PushButton*, /*_pButton*/)
654 	{
655 		OSL_ENSURE(m_pAdminDialog,"No Admin dialog set! ->GPF");
656         OSL_ENSURE(m_bUseClass,"Who called me?");
657 
658 		sal_Bool bSuccess = sal_False;
659 		try
660 		{
661 			if ( m_aEDDriverClass.GetText().Len() )
662 			{
663 // TODO chage jvmaccess
664 				::rtl::Reference< jvmaccess::VirtualMachine > xJVM = ::connectivity::getJavaVM(m_pAdminDialog->getORB());
665 				bSuccess = ::connectivity::existsJavaClassByName(xJVM,m_aEDDriverClass.GetText());
666 			}
667 		}
668 		catch(Exception&)
669 		{
670 		}
671 
672 		sal_uInt16 nMessage = bSuccess ? STR_JDBCDRIVER_SUCCESS : STR_JDBCDRIVER_NO_SUCCESS;
673 		OSQLMessageBox aMsg( this, String( ModuleRes( nMessage ) ), String() );
674 		aMsg.Execute();
675 		return 0L;
676 	}
677 	// -----------------------------------------------------------------------
IMPL_LINK(OGeneralSpecialJDBCDetailsPage,OnEditModified,Edit *,_pEdit)678 	IMPL_LINK(OGeneralSpecialJDBCDetailsPage, OnEditModified, Edit*, _pEdit)
679 	{
680 		if ( m_bUseClass && _pEdit == &m_aEDDriverClass )
681 			m_aTestJavaDriver.Enable( m_aEDDriverClass.GetText().Len() != 0 );
682 
683 		// tell the listener we were modified
684 		callModifiedHdl();
685 		return 0L;
686 	}
687 
688 	//========================================================================
689 	//= MySQLNativePage
690 	//========================================================================
MySQLNativePage(Window * pParent,const SfxItemSet & _rCoreAttrs)691 	MySQLNativePage::MySQLNativePage( Window* pParent, const SfxItemSet& _rCoreAttrs )
692 		:OCommonBehaviourTabPage(pParent, PAGE_MYSQL_NATIVE, _rCoreAttrs, CBTP_USE_CHARSET, false )
693 		,m_aSeparator1          ( this, ModuleRes( FL_SEPARATOR1) )
694         ,m_aMySQLSettings       ( *this, getControlModifiedLink() )
695         ,m_aSeparator2          ( this, ModuleRes(FL_SEPARATOR2))
696         ,m_aUserNameLabel       ( this, ModuleRes(FT_USERNAME))
697         ,m_aUserName            ( this, ModuleRes(ET_USERNAME))
698         ,m_aPasswordRequired    ( this, ModuleRes(CB_PASSWORD_REQUIRED))
699 	{
700         m_aUserName.SetModifyHdl(getControlModifiedLink());
701 
702 		Window* pWindows[] = {  &m_aMySQLSettings, &m_aSeparator2, &m_aUserNameLabel, &m_aUserName,
703                                 &m_aPasswordRequired, m_pCharsetLabel, m_pCharset};
704 		sal_Int32 nCount = sizeof(pWindows) / sizeof(pWindows[0]);
705 		for (sal_Int32 i=1; i < nCount; ++i)
706 			pWindows[i]->SetZOrder(pWindows[i-1], WINDOW_ZORDER_BEHIND);
707 
708         LayoutHelper::positionBelow( m_aSeparator1, m_aMySQLSettings, RelatedControls, 3 );
709         m_aMySQLSettings.Show();
710 
711 		FreeResource();
712 	}
713 
714 	// -----------------------------------------------------------------------
fillControls(::std::vector<ISaveValueWrapper * > & _rControlList)715 	void MySQLNativePage::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
716 	{
717 		OCommonBehaviourTabPage::fillControls( _rControlList );
718         m_aMySQLSettings.fillControls( _rControlList );
719 
720         _rControlList.push_back(new OSaveValueWrapper<Edit>(&m_aUserName));
721         _rControlList.push_back(new OSaveValueWrapper<CheckBox>(&m_aPasswordRequired));
722 	}
723 	// -----------------------------------------------------------------------
fillWindows(::std::vector<ISaveValueWrapper * > & _rControlList)724 	void MySQLNativePage::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
725 	{
726 		OCommonBehaviourTabPage::fillWindows( _rControlList );
727         m_aMySQLSettings.fillWindows( _rControlList);
728 
729 		_rControlList.push_back(new ODisableWrapper<FixedLine>(&m_aSeparator1));
730 		_rControlList.push_back(new ODisableWrapper<FixedLine>(&m_aSeparator2));
731         _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aUserNameLabel));
732 	}
733 
734 	// -----------------------------------------------------------------------
FillItemSet(SfxItemSet & _rSet)735 	sal_Bool MySQLNativePage::FillItemSet( SfxItemSet& _rSet )
736 	{
737 		sal_Bool bChangedSomething = OCommonBehaviourTabPage::FillItemSet( _rSet );
738 
739         bChangedSomething |= m_aMySQLSettings.FillItemSet( _rSet );
740 
741         if ( m_aUserName.GetText() != m_aUserName.GetSavedValue() )
742 		{
743 			_rSet.Put( SfxStringItem( DSID_USER, m_aUserName.GetText() ) );
744 			_rSet.Put( SfxStringItem( DSID_PASSWORD, String()));
745 			bChangedSomething = sal_True;
746 		}
747 		fillBool(_rSet,&m_aPasswordRequired,DSID_PASSWORDREQUIRED,bChangedSomething);
748 
749         return bChangedSomething;
750 	}
751 	// -----------------------------------------------------------------------
implInitControls(const SfxItemSet & _rSet,sal_Bool _bSaveValue)752 	void MySQLNativePage::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue)
753 	{
754 		// check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
755 		sal_Bool bValid, bReadonly;
756 		getFlags(_rSet, bValid, bReadonly);
757 
758         m_aMySQLSettings.implInitControls( _rSet );
759 
760 		SFX_ITEMSET_GET(_rSet, pUidItem, SfxStringItem, DSID_USER, sal_True);
761 		SFX_ITEMSET_GET(_rSet, pAllowEmptyPwd, SfxBoolItem, DSID_PASSWORDREQUIRED, sal_True);
762 
763 		if ( bValid )
764 		{
765             m_aUserName.SetText(pUidItem->GetValue());
766             m_aUserName.ClearModifyFlag();
767 			m_aPasswordRequired.Check(pAllowEmptyPwd->GetValue());
768 		}
769 
770 		OCommonBehaviourTabPage::implInitControls(_rSet, _bSaveValue);
771 	}
772 
773 	// -----------------------------------------------------------------------
CreateMySQLJDBC(Window * pParent,const SfxItemSet & _rAttrSet)774 	SfxTabPage*	ODriversSettings::CreateMySQLJDBC( Window* pParent, const SfxItemSet& _rAttrSet )
775 	{
776 		return ( new OGeneralSpecialJDBCDetailsPage( pParent,PAGE_MYSQL_JDBC, _rAttrSet,DSID_MYSQL_PORTNUMBER ) );
777 	}
778     // -----------------------------------------------------------------------
CreateMySQLNATIVE(Window * pParent,const SfxItemSet & _rAttrSet)779 	SfxTabPage*	ODriversSettings::CreateMySQLNATIVE( Window* pParent, const SfxItemSet& _rAttrSet )
780 	{
781 		return ( new MySQLNativePage( pParent, _rAttrSet ) );
782 	}
783 
784 	// -----------------------------------------------------------------------
CreateOracleJDBC(Window * pParent,const SfxItemSet & _rAttrSet)785 	SfxTabPage*	ODriversSettings::CreateOracleJDBC( Window* pParent, const SfxItemSet& _rAttrSet )
786 	{
787 		return ( new OGeneralSpecialJDBCDetailsPage( pParent,PAGE_ORACLE_JDBC, _rAttrSet,DSID_ORACLE_PORTNUMBER) );
788 	}
789 
790 
791 	//========================================================================
792 	//= OAdabasDetailsPage
793 	//========================================================================
OAdabasDetailsPage(Window * pParent,const SfxItemSet & _rCoreAttrs)794 	OAdabasDetailsPage::OAdabasDetailsPage( Window* pParent, const SfxItemSet& _rCoreAttrs )
795 		:OCommonBehaviourTabPage(pParent, PAGE_ADABAS, _rCoreAttrs, CBTP_USE_CHARSET ,false)
796 		,m_aFTHostname		(this, ModuleRes(FT_HOSTNAME))
797 		,m_aEDHostname		(this, ModuleRes(ET_HOSTNAME))
798 		,m_aFL_1			(this, ModuleRes( FL_SEPARATOR1) )
799 		,m_FT_CACHE_SIZE(		this, ModuleRes( FT_CACHE_SIZE		) )
800 		,m_NF_CACHE_SIZE(		this, ModuleRes( NF_CACHE_SIZE		) )
801 		,m_FT_DATA_INCREMENT(	this, ModuleRes( FT_DATA_INCREMENT	) )
802 		,m_NF_DATA_INCREMENT(	this, ModuleRes( NF_DATA_INCREMENT	) )
803 		,m_aFL_2(				this, ModuleRes( FL_SEPARATOR2		) )
804 		,m_FT_CTRLUSERNAME(		this, ModuleRes( FT_CTRLUSERNAME	) )
805 		,m_ET_CTRLUSERNAME(		this, ModuleRes( ET_CTRLUSERNAME	) )
806 		,m_FT_CTRLPASSWORD(		this, ModuleRes( FT_CTRLPASSWORD	) )
807 		,m_ET_CTRLPASSWORD(		this, ModuleRes( ET_CTRLPASSWORD	) )
808         ,m_CB_SHUTDB(			this, ModuleRes( CB_SHUTDB			) )
809 		,m_PB_STAT(				this, ModuleRes( PB_STAT			) )
810 	{
811 		m_aEDHostname.SetModifyHdl(getControlModifiedLink());
812 
813 		FreeResource();
814 
815 		m_PB_STAT.SetClickHdl(				LINK(this,OAdabasDetailsPage,PBClickHdl));
816 
817 		m_CB_SHUTDB.SetClickHdl(			LINK(this,OAdabasDetailsPage,AttributesChangedHdl));
818 		m_NF_CACHE_SIZE.SetModifyHdl(		LINK(this,OAdabasDetailsPage,AttributesChangedHdl));
819 		m_NF_DATA_INCREMENT.SetModifyHdl(	LINK(this,OAdabasDetailsPage,AttributesChangedHdl));
820 		m_ET_CTRLUSERNAME.SetModifyHdl(		LINK(this,OAdabasDetailsPage,AttributesChangedHdl));
821 		m_ET_CTRLPASSWORD.SetModifyHdl(		LINK(this,OAdabasDetailsPage,AttributesChangedHdl));
822 
823 		m_ET_CTRLUSERNAME.SetLoseFocusHdl(	LINK(this,OAdabasDetailsPage,LoseFocusHdl));
824 		m_ET_CTRLPASSWORD.SetLoseFocusHdl(	LINK(this,OAdabasDetailsPage,LoseFocusHdl));
825 
826 		m_NF_DATA_INCREMENT.SetMin(20);
827 		m_NF_DATA_INCREMENT.SetMax(LONG_MAX);
828 		m_NF_DATA_INCREMENT.SetValue(20);
829 		m_NF_DATA_INCREMENT.SetDecimalDigits(0);
830 
831 		m_NF_CACHE_SIZE.SetMin(4);
832 		m_NF_CACHE_SIZE.SetMax(LONG_MAX);
833 		m_NF_CACHE_SIZE.SetValue(4);
834 		m_NF_CACHE_SIZE.SetDecimalDigits(0);
835 
836 		Window* pWindows[] = {  &m_aFTHostname,&m_aEDHostname
837 								,&m_FT_CACHE_SIZE,&m_NF_CACHE_SIZE
838 								,&m_FT_DATA_INCREMENT,&m_NF_DATA_INCREMENT
839 								,&m_FT_CTRLUSERNAME,&m_ET_CTRLUSERNAME
840 								,&m_FT_CTRLPASSWORD,&m_ET_CTRLPASSWORD
841 								,&m_CB_SHUTDB
842 								,m_pCharsetLabel, m_pCharset,&m_PB_STAT};
843 
844 		sal_Int32 nCount = sizeof(pWindows) / sizeof(pWindows[0]);
845 		for (sal_Int32 i=1; i < nCount; ++i)
846 			pWindows[i]->SetZOrder(pWindows[i-1], WINDOW_ZORDER_BEHIND);
847 	}
848 
849 	// -----------------------------------------------------------------------
CreateAdabas(Window * pParent,const SfxItemSet & _rAttrSet)850 	SfxTabPage*	ODriversSettings::CreateAdabas( Window* pParent, const SfxItemSet& _rAttrSet )
851 	{
852 		return ( new OAdabasDetailsPage( pParent, _rAttrSet ) );
853 	}
854 
855 	// -----------------------------------------------------------------------
fillControls(::std::vector<ISaveValueWrapper * > & _rControlList)856 	void OAdabasDetailsPage::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
857 	{
858 		OCommonBehaviourTabPage::fillControls(_rControlList);
859 		_rControlList.push_back(new OSaveValueWrapper<Edit>(&m_aEDHostname));
860 		_rControlList.push_back(new OSaveValueWrapper<NumericField>(&m_NF_CACHE_SIZE));
861 		_rControlList.push_back(new OSaveValueWrapper<NumericField>(&m_NF_DATA_INCREMENT));
862 		_rControlList.push_back(new OSaveValueWrapper<Edit>(&m_ET_CTRLUSERNAME));
863 		_rControlList.push_back(new OSaveValueWrapper<Edit>(&m_ET_CTRLPASSWORD));
864 		_rControlList.push_back(new OSaveValueWrapper<CheckBox>(&m_CB_SHUTDB));
865 	}
866 	// -----------------------------------------------------------------------
fillWindows(::std::vector<ISaveValueWrapper * > & _rControlList)867 	void OAdabasDetailsPage::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
868 	{
869 		OCommonBehaviourTabPage::fillWindows(_rControlList);
870 		_rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTHostname));
871 		_rControlList.push_back(new ODisableWrapper<FixedLine>(&m_aFL_1));
872 		_rControlList.push_back(new ODisableWrapper<FixedText>(&m_FT_CACHE_SIZE));
873 		_rControlList.push_back(new ODisableWrapper<FixedText>(&m_FT_DATA_INCREMENT));
874 		_rControlList.push_back(new ODisableWrapper<FixedLine>(&m_aFL_2));
875 		_rControlList.push_back(new ODisableWrapper<FixedText>(&m_FT_CTRLUSERNAME));
876 		_rControlList.push_back(new ODisableWrapper<FixedText>(&m_FT_CTRLPASSWORD));
877 		_rControlList.push_back(new ODisableWrapper<PushButton>(&m_PB_STAT));
878 	}
879 	// -----------------------------------------------------------------------
implInitControls(const SfxItemSet & _rSet,sal_Bool _bSaveValue)880 	void OAdabasDetailsPage::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue)
881 	{
882 		// first check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
883 		sal_Bool bValid, bReadonly;
884 		getFlags(_rSet, bValid, bReadonly);
885 
886 		SFX_ITEMSET_GET(_rSet, pHostName, SfxStringItem, DSID_CONN_HOSTNAME, sal_True);
887 		SFX_ITEMSET_GET(_rSet, pCtrlUserItem, SfxStringItem, DSID_CONN_CTRLUSER, sal_True);
888 		SFX_ITEMSET_GET(_rSet, pCtrlPwdItem, SfxStringItem, DSID_CONN_CTRLPWD, sal_True);
889 		SFX_ITEMSET_GET(_rSet, pShutItem, SfxBoolItem, DSID_CONN_SHUTSERVICE, sal_True);
890 		SFX_ITEMSET_GET(_rSet, pIncItem, SfxInt32Item, DSID_CONN_DATAINC, sal_True);
891 		SFX_ITEMSET_GET(_rSet, pCacheItem, SfxInt32Item, DSID_CONN_CACHESIZE, sal_True);
892 		if ( bValid )
893 		{
894 			m_aEDHostname.SetText(pHostName->GetValue());
895 			m_aEDHostname.ClearModifyFlag();
896 			m_CB_SHUTDB.Check( pShutItem->GetValue() );
897 			m_NF_DATA_INCREMENT.SetValue( pIncItem->GetValue() );
898 			m_NF_CACHE_SIZE.SetValue( pCacheItem->GetValue() );
899 			m_ET_CTRLUSERNAME.SetText(pCtrlUserItem->GetValue());
900 			m_ET_CTRLPASSWORD.SetText(pCtrlPwdItem->GetValue());
901 			m_CB_SHUTDB.Enable(m_ET_CTRLUSERNAME.GetText().Len() && m_ET_CTRLPASSWORD.GetText().Len());
902 		}
903 
904 		OCommonBehaviourTabPage::implInitControls(_rSet, _bSaveValue);
905 	}
906 	// -----------------------------------------------------------------------
FillItemSet(SfxItemSet & _rSet)907 	sal_Bool OAdabasDetailsPage::FillItemSet( SfxItemSet& _rSet )
908 	{
909 		sal_Bool bChangedSomething = OCommonBehaviourTabPage::FillItemSet(_rSet);
910 
911 		fillString(_rSet,&m_aEDHostname,DSID_CONN_HOSTNAME,bChangedSomething);
912 		fillBool(_rSet,&m_CB_SHUTDB,DSID_CONN_SHUTSERVICE,bChangedSomething);
913 		fillInt32(_rSet,&m_NF_DATA_INCREMENT,DSID_CONN_DATAINC,bChangedSomething );
914 		fillInt32(_rSet,&m_NF_CACHE_SIZE,DSID_CONN_CACHESIZE,bChangedSomething );
915 		fillString(_rSet,&m_ET_CTRLUSERNAME,DSID_CONN_CTRLUSER,bChangedSomething );
916 		fillString(_rSet,&m_ET_CTRLPASSWORD,DSID_CONN_CTRLPWD,bChangedSomething );
917 
918 		return bChangedSomething;
919 	}
920 	//------------------------------------------------------------------------
IMPL_LINK(OAdabasDetailsPage,AttributesChangedHdl,void *,EMPTYARG)921 	IMPL_LINK( OAdabasDetailsPage, AttributesChangedHdl, void *, EMPTYARG )
922 	{
923 		m_CB_SHUTDB.Enable(m_ET_CTRLUSERNAME.GetText().Len() && m_ET_CTRLPASSWORD.GetText().Len());
924 		bAttrsChanged = sal_True;
925 		callModifiedHdl();
926 		return 0;
927 	}
928 	//------------------------------------------------------------------------
929 	IMPL_LINK( OAdabasDetailsPage, LoseFocusHdl, Edit *, /*pEdit*/ )
930 	{
931 		m_CB_SHUTDB.Enable(m_ET_CTRLUSERNAME.GetText().Len() && m_ET_CTRLPASSWORD.GetText().Len());
932 		return 0;
933 	}
934 	//------------------------------------------------------------------------
935 	IMPL_LINK( OAdabasDetailsPage, PBClickHdl, Button *, /*pButton*/ )
936 	{
937 		OSL_ENSURE(m_pAdminDialog,"No Admin dialog set! ->GPF");
938 		if ( m_pAdminDialog )
939 		{
940 			m_pAdminDialog->saveDatasource();
941 			try
942 			{
943 				Reference< XConnection > xConnection = m_pAdminDialog->createConnection().first;
944 				if ( xConnection.is() )
945 				{
946 					OAdabasStatistics aDlg(this,m_sUser,xConnection,m_pAdminDialog->getORB());
947 					aDlg.Execute();
948 					::comphelper::disposeComponent(xConnection);
949 				}
950 			}
951 			catch(Exception&)
952 			{
953 			}
954 		}
955 
956 		return 0;
957 	}
958 
959 
960 	//========================================================================
961 	//= OLDAPDetailsPage
962 	//========================================================================
OLDAPDetailsPage(Window * pParent,const SfxItemSet & _rCoreAttrs)963 	OLDAPDetailsPage::OLDAPDetailsPage( Window* pParent, const SfxItemSet& _rCoreAttrs )
964 		:OCommonBehaviourTabPage(pParent, PAGE_LDAP, _rCoreAttrs,0,false)
965 		,m_aFL_1			(this, ModuleRes( FL_SEPARATOR1) )
966 		,m_aBaseDN			(this, ModuleRes(FT_BASEDN))
967 		,m_aETBaseDN		(this, ModuleRes(ET_BASEDN))
968  		,m_aCBUseSSL        (this, ModuleRes(CB_USESSL))
969 		,m_aPortNumber		(this, ModuleRes(FT_PORTNUMBER))
970 		,m_aNFPortNumber	(this, ModuleRes(NF_PORTNUMBER))
971 		,m_aFTRowCount		(this, ModuleRes(FT_LDAPROWCOUNT))
972 		,m_aNFRowCount		(this, ModuleRes(NF_LDAPROWCOUNT))
973 	{
974 		m_aETBaseDN.SetModifyHdl(getControlModifiedLink());
975 		m_aCBUseSSL.SetToggleHdl(getControlModifiedLink());
976 		m_aNFPortNumber.SetModifyHdl(getControlModifiedLink());
977 		m_aNFRowCount.SetModifyHdl(getControlModifiedLink());
978 
979 		m_aNFRowCount.SetUseThousandSep(sal_False);
980 		m_iNormalPort = 389;
981 		m_iSSLPort    = 636;
982 		m_aCBUseSSL.SetClickHdl(LINK(this, OLDAPDetailsPage,OnCheckBoxClick));
983         FreeResource();
984 	}
985 
986 	// -----------------------------------------------------------------------
CreateLDAP(Window * pParent,const SfxItemSet & _rAttrSet)987 	SfxTabPage*	ODriversSettings::CreateLDAP( Window* pParent, const SfxItemSet& _rAttrSet )
988 	{
989 		return ( new OLDAPDetailsPage( pParent, _rAttrSet ) );
990 	}
991 
992 	// -----------------------------------------------------------------------
FillItemSet(SfxItemSet & _rSet)993 	sal_Bool OLDAPDetailsPage::FillItemSet( SfxItemSet& _rSet )
994 	{
995 		sal_Bool bChangedSomething = OCommonBehaviourTabPage::FillItemSet(_rSet);
996 
997 		fillString(_rSet,&m_aETBaseDN,DSID_CONN_LDAP_BASEDN,bChangedSomething);
998 		fillInt32(_rSet,&m_aNFPortNumber,DSID_CONN_LDAP_PORTNUMBER,bChangedSomething);
999 		fillInt32(_rSet,&m_aNFRowCount,DSID_CONN_LDAP_ROWCOUNT,bChangedSomething);
1000 		fillBool(_rSet,&m_aCBUseSSL,DSID_CONN_LDAP_USESSL,bChangedSomething);
1001 		return bChangedSomething;
1002 	}
1003 	//------------------------------------------------------------------------
IMPL_LINK(OLDAPDetailsPage,OnCheckBoxClick,CheckBox *,pCheckBox)1004 	IMPL_LINK( OLDAPDetailsPage, OnCheckBoxClick, CheckBox*, pCheckBox )
1005 	{
1006 		callModifiedHdl();
1007 		if ( pCheckBox == &m_aCBUseSSL)
1008 		{
1009 			if ( m_aCBUseSSL.IsChecked() )
1010 			{
1011 				m_iNormalPort = static_cast<sal_Int32>(m_aNFPortNumber.GetValue());
1012 				m_aNFPortNumber.SetValue(m_iSSLPort);
1013 			}
1014 			else
1015 			{
1016 				m_iSSLPort = static_cast<sal_Int32>(m_aNFPortNumber.GetValue());
1017 				m_aNFPortNumber.SetValue(m_iNormalPort);
1018 			}
1019 		}
1020 		return 0;
1021 	}
1022 
1023 	// -----------------------------------------------------------------------
fillControls(::std::vector<ISaveValueWrapper * > & _rControlList)1024 	void OLDAPDetailsPage::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
1025 	{
1026 		OCommonBehaviourTabPage::fillControls(_rControlList);
1027 		_rControlList.push_back(new OSaveValueWrapper<Edit>(&m_aETBaseDN));
1028 		_rControlList.push_back(new OSaveValueWrapper<CheckBox>(&m_aCBUseSSL));
1029 		_rControlList.push_back(new OSaveValueWrapper<NumericField>(&m_aNFPortNumber));
1030 		_rControlList.push_back(new OSaveValueWrapper<NumericField>(&m_aNFRowCount));
1031 	}
1032 	// -----------------------------------------------------------------------
fillWindows(::std::vector<ISaveValueWrapper * > & _rControlList)1033 	void OLDAPDetailsPage::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
1034 	{
1035 		OCommonBehaviourTabPage::fillWindows(_rControlList);
1036 		_rControlList.push_back(new ODisableWrapper<FixedText>(&m_aBaseDN));
1037 		_rControlList.push_back(new ODisableWrapper<FixedText>(&m_aPortNumber));
1038 		_rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTRowCount));
1039 		_rControlList.push_back(new ODisableWrapper<FixedLine>(&m_aFL_1));
1040 	}
1041 	// -----------------------------------------------------------------------
implInitControls(const SfxItemSet & _rSet,sal_Bool _bSaveValue)1042 	void OLDAPDetailsPage::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue)
1043 	{
1044 		// check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
1045 		sal_Bool bValid, bReadonly;
1046 		getFlags(_rSet, bValid, bReadonly);
1047 
1048 
1049 		SFX_ITEMSET_GET(_rSet, pBaseDN, SfxStringItem, DSID_CONN_LDAP_BASEDN, sal_True);
1050         SFX_ITEMSET_GET(_rSet, pUseSSL, SfxBoolItem, DSID_CONN_LDAP_USESSL, sal_True);
1051 		SFX_ITEMSET_GET(_rSet, pPortNumber, SfxInt32Item, DSID_CONN_LDAP_PORTNUMBER, sal_True);
1052 		SFX_ITEMSET_GET(_rSet, pRowCount, SfxInt32Item, DSID_CONN_LDAP_ROWCOUNT, sal_True);
1053 
1054 		if ( bValid )
1055 		{
1056 			m_aETBaseDN.SetText(pBaseDN->GetValue());
1057 			m_aNFPortNumber.SetValue(pPortNumber->GetValue());
1058 			m_aNFRowCount.SetValue(pRowCount->GetValue());
1059 			m_aCBUseSSL.Check(pUseSSL->GetValue());
1060 		}
1061 
1062 		OCommonBehaviourTabPage::implInitControls(_rSet, _bSaveValue);
1063 	}
1064 
1065 
1066 	//========================================================================
1067 	//= OTextDetailsPage
1068 	//========================================================================
DBG_NAME(OTextDetailsPage)1069     DBG_NAME(OTextDetailsPage)
1070     //------------------------------------------------------------------------
1071 	OTextDetailsPage::OTextDetailsPage( Window* pParent, const SfxItemSet& _rCoreAttrs )
1072 		:OCommonBehaviourTabPage(pParent, PAGE_TEXT, _rCoreAttrs, 0, false )
1073 	{
1074         DBG_CTOR(OTextDetailsPage,NULL);
1075 
1076         m_pTextConnectionHelper = new OTextConnectionHelper( this, TC_EXTENSION | TC_HEADER | TC_SEPARATORS | TC_CHARSET );
1077 		FreeResource();
1078 	}
1079 
1080 	// -----------------------------------------------------------------------
~OTextDetailsPage()1081 	OTextDetailsPage::~OTextDetailsPage()
1082 	{
1083         DELETEZ(m_pTextConnectionHelper);
1084 
1085         DBG_DTOR(OTextDetailsPage,NULL);
1086     }
1087 
1088 	// -----------------------------------------------------------------------
CreateText(Window * pParent,const SfxItemSet & _rAttrSet)1089 	SfxTabPage*	ODriversSettings::CreateText( Window* pParent,	const SfxItemSet& _rAttrSet )
1090 	{
1091 		return ( new OTextDetailsPage( pParent, _rAttrSet ) );
1092 	}
1093 	// -----------------------------------------------------------------------
fillControls(::std::vector<ISaveValueWrapper * > & _rControlList)1094 	void OTextDetailsPage::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
1095 	{
1096 		OCommonBehaviourTabPage::fillControls(_rControlList);
1097         m_pTextConnectionHelper->fillControls(_rControlList);
1098 
1099 	}
1100 	// -----------------------------------------------------------------------
fillWindows(::std::vector<ISaveValueWrapper * > & _rControlList)1101 	void OTextDetailsPage::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
1102 	{
1103 		OCommonBehaviourTabPage::fillWindows(_rControlList);
1104         m_pTextConnectionHelper->fillWindows(_rControlList);
1105 
1106 	}
1107 	// -----------------------------------------------------------------------
implInitControls(const SfxItemSet & _rSet,sal_Bool _bSaveValue)1108 	void OTextDetailsPage::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue)
1109 	{
1110 		// first check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
1111 		sal_Bool bValid, bReadonly;
1112 		getFlags(_rSet, bValid, bReadonly);
1113 
1114 		m_pTextConnectionHelper->implInitControls(_rSet, bValid);
1115 		OCommonBehaviourTabPage::implInitControls(_rSet, _bSaveValue);
1116 	}
1117 
1118 	// -----------------------------------------------------------------------
FillItemSet(SfxItemSet & rSet)1119 	sal_Bool OTextDetailsPage::FillItemSet( SfxItemSet& rSet )
1120 	{
1121 		sal_Bool bChangedSomething = OCommonBehaviourTabPage::FillItemSet(rSet);
1122 		bChangedSomething = m_pTextConnectionHelper->FillItemSet(rSet, bChangedSomething);
1123 		return bChangedSomething;
1124 	}
1125 
1126 	// -----------------------------------------------------------------------
prepareLeave()1127     sal_Bool OTextDetailsPage::prepareLeave()
1128     {
1129         return m_pTextConnectionHelper->prepareLeave();
1130     }
1131 
1132 	//------------------------------------------------------------------------
CreateGeneratedValuesPage(Window * _pParent,const SfxItemSet & _rAttrSet)1133 	SfxTabPage*	ODriversSettings::CreateGeneratedValuesPage( Window* _pParent, const SfxItemSet& _rAttrSet )
1134 	{
1135 		return new GeneratedValuesPage( _pParent, _rAttrSet );
1136 	}
1137 
1138     //------------------------------------------------------------------------
CreateSpecialSettingsPage(Window * _pParent,const SfxItemSet & _rAttrSet)1139 	SfxTabPage*	ODriversSettings::CreateSpecialSettingsPage( Window* _pParent, const SfxItemSet& _rAttrSet )
1140 	{
1141         ::rtl::OUString eType = ODbDataSourceAdministrationHelper::getDatasourceType( _rAttrSet );
1142         DataSourceMetaData aMetaData( eType );
1143 		return new SpecialSettingsPage(	_pParent, _rAttrSet, aMetaData );
1144 	}
1145 //.........................................................................
1146 }	// namespace dbaui
1147 //.........................................................................
1148