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 "advancedsettings.hxx"
28 #include "advancedsettingsdlg.hxx"
29 #include "moduledbu.hxx"
30 #include "dsitems.hxx"
31 #include "DbAdminImpl.hxx"
32 #include "DriverSettings.hxx"
33 #include "optionalboolitem.hxx"
34 #include "dbu_resource.hrc"
35 #include "dbu_dlg.hrc"
36 #include "dbadmin.hrc"
37 #include "advancedsettings.hrc"
38 
39 /** === begin UNO includes === **/
40 /** === end UNO includes === **/
41 
42 #include <svl/eitem.hxx>
43 #include <svl/intitem.hxx>
44 #include <svl/stritem.hxx>
45 
46 #include <vcl/msgbox.hxx>
47 
48 //........................................................................
49 namespace dbaui
50 {
51 //........................................................................
52 
53     /** === begin UNO using === **/
54     using ::com::sun::star::uno::Reference;
55     using ::com::sun::star::lang::XMultiServiceFactory;
56     using ::com::sun::star::uno::Any;
57     using ::com::sun::star::beans::XPropertySet;
58     using ::com::sun::star::sdbc::XConnection;
59     using ::com::sun::star::sdbc::XDriver;
60     /** === end UNO using === **/
61 
62     //========================================================================
63     //= SpecialSettingsPage
64     //========================================================================
65     struct BooleanSettingDesc
66     {
67         CheckBox**  ppControl;          // the dialog's control which displays this setting
68         sal_uInt16      nControlResId;      // the resource ID to load the control from
69         sal_uInt16      nItemId;            // the ID of the item (in an SfxItemSet) which corresponds to this setting
70         bool        bInvertedDisplay;   // true if and only if the checkbox is checked when the item is sal_False, and vice versa
71     };
72 
73     //========================================================================
74     //= SpecialSettingsPage
75     //========================================================================
76     SpecialSettingsPage::SpecialSettingsPage( Window* pParent, const SfxItemSet& _rCoreAttrs, const DataSourceMetaData& _rDSMeta )
77         :OGenericAdministrationPage( pParent, ModuleRes( PAGE_ADVANCED_SETTINGS_SPECIAL ), _rCoreAttrs )
78         ,m_aTopLine( this, ModuleRes( FL_DATAHANDLING ) )
79         ,m_pIsSQL92Check( NULL )
80         ,m_pAppendTableAlias( NULL )
81         ,m_pAsBeforeCorrelationName( NULL )
82         ,m_pEnableOuterJoin( NULL )
83         ,m_pIgnoreDriverPrivileges( NULL )
84         ,m_pParameterSubstitution( NULL )
85         ,m_pSuppressVersionColumn( NULL )
86         ,m_pCatalog( NULL )
87         ,m_pSchema( NULL )
88         ,m_pIndexAppendix( NULL )
89         ,m_pDosLineEnds( NULL )
90         ,m_pCheckRequiredFields( NULL )
91         ,m_pIgnoreCurrency(NULL)
92         ,m_pEscapeDateTime(NULL)
93         ,m_pPrimaryKeySupport(NULL)
94         ,m_pRespectDriverResultSetType(NULL)
95         ,m_pBooleanComparisonModeLabel( NULL )
96         ,m_pBooleanComparisonMode( NULL )
97         ,m_pMaxRowScanLabel( NULL )
98         ,m_pMaxRowScan( NULL )
99         ,m_aControlDependencies()
100         ,m_aBooleanSettings()
101         ,m_bHasBooleanComparisonMode( _rDSMeta.getFeatureSet().has( DSID_BOOLEANCOMPARISON ) )
102         ,m_bHasMaxRowScan( _rDSMeta.getFeatureSet().has( DSID_MAX_ROW_SCAN ) )
103     {
104         impl_initBooleanSettings();
105 
106         const FeatureSet& rFeatures( _rDSMeta.getFeatureSet() );
107         // create all the check boxes for the boolean settings
108         for (   BooleanSettingDescs::const_iterator setting = m_aBooleanSettings.begin();
109                 setting != m_aBooleanSettings.end();
110                 ++setting
111              )
112         {
113             sal_uInt16 nItemId = setting->nItemId;
114             if ( rFeatures.has( nItemId ) )
115             {
116                 sal_uInt16 nResourceId = setting->nControlResId;
117                 (*setting->ppControl) = new CheckBox( this, ModuleRes( nResourceId ) );
118                 (*setting->ppControl)->SetClickHdl( getControlModifiedLink() );
119 
120                 // check whether this must be a tristate check box
121                 const SfxPoolItem& rItem = _rCoreAttrs.Get( nItemId );
122                 if ( rItem.ISA( OptionalBoolItem ) )
123                     (*setting->ppControl)->EnableTriState( sal_True );
124             }
125         }
126 
127         if ( m_pAsBeforeCorrelationName && m_pAppendTableAlias )
128             // make m_pAsBeforeCorrelationName depend on m_pAppendTableAlias
129             m_aControlDependencies.enableOnCheckMark( *m_pAppendTableAlias, *m_pAsBeforeCorrelationName );
130 
131         // move the controls to the appropriate positions
132         Point aPos( m_aTopLine.GetPosPixel() );
133         aPos.Move( 0, m_aTopLine.GetSizePixel().Height() );
134         Size aFirstDistance( LogicToPixel( Size( INDENTED_X, RELATED_CONTROLS ), MAP_APPFONT ) );
135         aPos.Move( aFirstDistance.Width(), aFirstDistance.Height() );
136 
137         Size aUnrelatedControls( LogicToPixel( Size( RELATED_CONTROLS, RELATED_CONTROLS ), MAP_APPFONT ) );
138 
139         for (   BooleanSettingDescs::const_iterator setting = m_aBooleanSettings.begin();
140                 setting != m_aBooleanSettings.end();
141                 ++setting
142              )
143         {
144             if ( !*setting->ppControl )
145                 continue;
146 
147             (*setting->ppControl)->SetPosPixel( aPos );
148             aPos.Move( 0, (*setting->ppControl)->GetSizePixel().Height() );
149             aPos.Move( 0, aUnrelatedControls.Height() );
150         }
151 
152         // create the controls for the boolean comparison mode
153         if ( m_bHasBooleanComparisonMode )
154         {
155             m_pBooleanComparisonModeLabel = new FixedText( this, ModuleRes( FT_BOOLEANCOMPARISON ) );
156             m_pBooleanComparisonMode = new ListBox( this, ModuleRes( LB_BOOLEANCOMPARISON ) );
157             m_pBooleanComparisonMode->SetDropDownLineCount( 4 );
158             m_pBooleanComparisonMode->SetSelectHdl( getControlModifiedLink() );
159 
160             Point aLabelPos( m_pBooleanComparisonModeLabel->GetPosPixel() );
161             Point aControlPos( m_pBooleanComparisonMode->GetPosPixel() );
162             long nMoveUp = aControlPos.Y() - aPos.Y();
163 
164             m_pBooleanComparisonModeLabel->SetPosPixel( Point( aLabelPos.X(), aLabelPos.Y() - nMoveUp ) );
165             m_pBooleanComparisonMode->SetPosPixel( Point( aControlPos.X(), aControlPos.Y() - nMoveUp ) );
166         }
167         // create the controls for the max row scan
168         if ( m_bHasMaxRowScan )
169         {
170             m_pMaxRowScanLabel = new FixedText( this, ModuleRes( FT_MAXROWSCAN ) );
171             m_pMaxRowScan = new NumericField( this, ModuleRes( NF_MAXROWSCAN ) );
172             m_pMaxRowScan->SetModifyHdl(getControlModifiedLink());
173             m_pMaxRowScan->SetUseThousandSep(sal_False);
174 
175             Point aLabelPos( m_pMaxRowScanLabel->GetPosPixel() );
176             Point aControlPos( m_pMaxRowScan->GetPosPixel() );
177             long nMoveUp = aControlPos.Y() - aPos.Y();
178 
179             m_pMaxRowScanLabel->SetPosPixel( Point( aLabelPos.X(), aLabelPos.Y() - nMoveUp ) );
180             m_pMaxRowScan->SetPosPixel( Point( aControlPos.X(), aControlPos.Y() - nMoveUp ) );
181         }
182 
183         FreeResource();
184     }
185 
186     // -----------------------------------------------------------------------
187     SpecialSettingsPage::~SpecialSettingsPage()
188     {
189         m_aControlDependencies.clear();
190 
191         DELETEZ( m_pIsSQL92Check );
192         DELETEZ( m_pAppendTableAlias );
193         DELETEZ( m_pAsBeforeCorrelationName );
194         DELETEZ( m_pParameterSubstitution );
195         DELETEZ( m_pIgnoreDriverPrivileges );
196         DELETEZ( m_pSuppressVersionColumn );
197         DELETEZ( m_pEnableOuterJoin );
198         DELETEZ( m_pCatalog );
199         DELETEZ( m_pSchema );
200         DELETEZ( m_pIndexAppendix );
201         DELETEZ( m_pDosLineEnds );
202         DELETEZ( m_pCheckRequiredFields );
203         DELETEZ( m_pIgnoreCurrency );
204         DELETEZ( m_pEscapeDateTime );
205         DELETEZ( m_pPrimaryKeySupport );
206         DELETEZ( m_pRespectDriverResultSetType );
207         DELETEZ( m_pBooleanComparisonModeLabel );
208         DELETEZ( m_pBooleanComparisonMode );
209         DELETEZ( m_pMaxRowScanLabel );
210         DELETEZ( m_pMaxRowScan );
211     }
212 
213     // -----------------------------------------------------------------------
214     void SpecialSettingsPage::impl_initBooleanSettings()
215     {
216         OSL_PRECOND( m_aBooleanSettings.empty(), "SpecialSettingsPage::impl_initBooleanSettings: called twice!" );
217 
218         // for easier maintainance, write the table in this form, then copy it to m_aBooleanSettings
219         BooleanSettingDesc aSettings[] = {
220             { &m_pIsSQL92Check,                 CB_SQL92CHECK,          DSID_SQL92CHECK,            false },
221             { &m_pAppendTableAlias,             CB_APPENDTABLEALIAS,    DSID_APPEND_TABLE_ALIAS,    false },
222             { &m_pAsBeforeCorrelationName,      CB_AS_BEFORE_CORR_NAME, DSID_AS_BEFORE_CORRNAME,    false },
223             { &m_pEnableOuterJoin,              CB_ENABLEOUTERJOIN,     DSID_ENABLEOUTERJOIN,       false },
224             { &m_pIgnoreDriverPrivileges,       CB_IGNOREDRIVER_PRIV,   DSID_IGNOREDRIVER_PRIV,     false },
225             { &m_pParameterSubstitution,        CB_PARAMETERNAMESUBST,  DSID_PARAMETERNAMESUBST,    false },
226             { &m_pSuppressVersionColumn,        CB_SUPPRESVERSIONCL,    DSID_SUPPRESSVERSIONCL,     true },
227             { &m_pCatalog,                      CB_CATALOG,             DSID_CATALOG,               false },
228             { &m_pSchema,                       CB_SCHEMA,              DSID_SCHEMA,                false },
229             { &m_pIndexAppendix,                CB_IGNOREINDEXAPPENDIX, DSID_INDEXAPPENDIX,         false },
230             { &m_pDosLineEnds,                  CB_DOSLINEENDS,         DSID_DOSLINEENDS,           false },
231             { &m_pCheckRequiredFields,          CB_CHECK_REQUIRED,      DSID_CHECK_REQUIRED_FIELDS, false },
232             { &m_pIgnoreCurrency,               CB_IGNORECURRENCY,      DSID_IGNORECURRENCY,        false },
233             { &m_pEscapeDateTime,               CB_ESCAPE_DATETIME,     DSID_ESCAPE_DATETIME,       false },
234             { &m_pPrimaryKeySupport,            CB_PRIMARY_KEY_SUPPORT, DSID_PRIMARY_KEY_SUPPORT,   false },
235             { &m_pRespectDriverResultSetType,   CB_RESPECTRESULTSETTYPE,DSID_RESPECTRESULTSETTYPE,  false },
236             { NULL,                         0,                      0,                          false }
237         };
238 
239         for ( const BooleanSettingDesc* pCopy = aSettings; pCopy->nItemId != 0; ++pCopy )
240         {
241             m_aBooleanSettings.push_back( *pCopy );
242         }
243     }
244 
245     // -----------------------------------------------------------------------
246     void SpecialSettingsPage::fillWindows( ::std::vector< ISaveValueWrapper* >& _rControlList )
247     {
248         if ( m_bHasBooleanComparisonMode )
249         {
250             _rControlList.push_back( new ODisableWrapper< FixedText >( m_pBooleanComparisonModeLabel ) );
251         }
252         if ( m_bHasMaxRowScan )
253         {
254             _rControlList.push_back( new ODisableWrapper< FixedText >( m_pMaxRowScanLabel ) );
255         }
256     }
257 
258     // -----------------------------------------------------------------------
259     void SpecialSettingsPage::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
260     {
261         for (   BooleanSettingDescs::const_iterator setting = m_aBooleanSettings.begin();
262                 setting != m_aBooleanSettings.end();
263                 ++setting
264              )
265         {
266             if ( *setting->ppControl )
267             {
268                 _rControlList.push_back( new OSaveValueWrapper< CheckBox >( *setting->ppControl ) );
269             }
270         }
271 
272         if ( m_bHasBooleanComparisonMode )
273             _rControlList.push_back( new OSaveValueWrapper< ListBox >( m_pBooleanComparisonMode ) );
274         if ( m_bHasMaxRowScan )
275             _rControlList.push_back(new OSaveValueWrapper<NumericField>(m_pMaxRowScan));
276     }
277 
278     // -----------------------------------------------------------------------
279     void SpecialSettingsPage::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue)
280     {
281         // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
282         sal_Bool bValid, bReadonly;
283         getFlags( _rSet, bValid, bReadonly );
284 
285         if ( !bValid )
286         {
287             OGenericAdministrationPage::implInitControls(_rSet, _bSaveValue);
288             return;
289         }
290 
291         // the boolean items
292         for (   BooleanSettingDescs::const_iterator setting = m_aBooleanSettings.begin();
293                 setting != m_aBooleanSettings.end();
294                 ++setting
295              )
296         {
297             if ( !*setting->ppControl )
298                 continue;
299 
300             ::boost::optional< bool > aValue;
301 
302             SFX_ITEMSET_GET( _rSet, pItem, SfxPoolItem, setting->nItemId, sal_True );
303             if ( pItem->ISA( SfxBoolItem ) )
304             {
305                 aValue.reset( PTR_CAST( SfxBoolItem, pItem )->GetValue() );
306             }
307             else if ( pItem->ISA( OptionalBoolItem ) )
308             {
309                 aValue = PTR_CAST( OptionalBoolItem, pItem )->GetFullValue();
310             }
311             else
312                 DBG_ERROR( "SpecialSettingsPage::implInitControls: unknown boolean item type!" );
313 
314             if ( !aValue )
315             {
316                 (*setting->ppControl)->SetState( STATE_DONTKNOW );
317             }
318             else
319             {
320                 sal_Bool bValue = *aValue;
321                 if ( setting->bInvertedDisplay )
322                     bValue = !bValue;
323                 (*setting->ppControl)->Check( bValue );
324             }
325         }
326 
327         // the non-boolean items
328         if ( m_bHasBooleanComparisonMode )
329         {
330             SFX_ITEMSET_GET( _rSet, pBooleanComparison, SfxInt32Item, DSID_BOOLEANCOMPARISON, sal_True );
331             m_pBooleanComparisonMode->SelectEntryPos( static_cast< sal_uInt16 >( pBooleanComparison->GetValue() ) );
332         }
333 
334         if ( m_bHasMaxRowScan )
335         {
336             SFX_ITEMSET_GET(_rSet, pMaxRowScan, SfxInt32Item, DSID_MAX_ROW_SCAN, sal_True);
337             m_pMaxRowScan->SetValue(pMaxRowScan->GetValue());
338         }
339 
340         OGenericAdministrationPage::implInitControls(_rSet, _bSaveValue);
341     }
342 
343     // -----------------------------------------------------------------------
344     sal_Bool SpecialSettingsPage::FillItemSet( SfxItemSet& _rSet )
345     {
346         sal_Bool bChangedSomething = sal_False;
347 
348         // the boolean items
349         for (   BooleanSettingDescs::const_iterator setting = m_aBooleanSettings.begin();
350                 setting != m_aBooleanSettings.end();
351                 ++setting
352              )
353         {
354             if ( !*setting->ppControl )
355                 continue;
356             fillBool( _rSet, *setting->ppControl, setting->nItemId, bChangedSomething, setting->bInvertedDisplay );
357         }
358 
359         // the non-boolean items
360         if ( m_bHasBooleanComparisonMode )
361         {
362             if ( m_pBooleanComparisonMode->GetSelectEntryPos() != m_pBooleanComparisonMode->GetSavedValue() )
363             {
364                 _rSet.Put( SfxInt32Item( DSID_BOOLEANCOMPARISON, m_pBooleanComparisonMode->GetSelectEntryPos() ) );
365                 bChangedSomething = sal_True;
366             }
367         }
368         if ( m_bHasMaxRowScan )
369         {
370             fillInt32(_rSet,m_pMaxRowScan,DSID_MAX_ROW_SCAN,bChangedSomething);
371         }
372         return bChangedSomething;
373     }
374 
375 	//========================================================================
376 	//= GeneratedValuesPage
377     //========================================================================
378     //------------------------------------------------------------------------
379 	GeneratedValuesPage::GeneratedValuesPage( Window* pParent, const SfxItemSet& _rCoreAttrs )
380 		:OGenericAdministrationPage(pParent, ModuleRes( PAGE_GENERATED_VALUES ), _rCoreAttrs)
381         ,m_aAutoFixedLine        ( this, ModuleRes( FL_SEPARATORAUTO ) )
382 		,m_aAutoRetrievingEnabled( this, ModuleRes( CB_RETRIEVE_AUTO ) )
383 		,m_aAutoIncrementLabel   ( this, ModuleRes( FT_AUTOINCREMENTVALUE ) )
384 		,m_aAutoIncrement        ( this, ModuleRes( ET_AUTOINCREMENTVALUE ) )
385 		,m_aAutoRetrievingLabel  ( this, ModuleRes( FT_RETRIEVE_AUTO ) )
386 		,m_aAutoRetrieving       ( this, ModuleRes( ET_RETRIEVE_AUTO ) )
387 	{
388 		m_aAutoRetrievingEnabled.SetClickHdl( getControlModifiedLink() );
389 		m_aAutoIncrement.SetModifyHdl( getControlModifiedLink() );
390 		m_aAutoRetrieving.SetModifyHdl( getControlModifiedLink() );
391 
392         m_aControlDependencies.enableOnCheckMark( m_aAutoRetrievingEnabled,
393             m_aAutoIncrementLabel, m_aAutoIncrement, m_aAutoRetrievingLabel, m_aAutoRetrieving );
394 
395         FreeResource();
396 	}
397 
398 	// -----------------------------------------------------------------------
399 	GeneratedValuesPage::~GeneratedValuesPage()
400 	{
401         m_aControlDependencies.clear();
402     }
403 
404 	// -----------------------------------------------------------------------
405 	void GeneratedValuesPage::fillWindows( ::std::vector< ISaveValueWrapper* >& _rControlList )
406 	{
407 		_rControlList.push_back( new ODisableWrapper< FixedLine >( &m_aAutoFixedLine ) );
408 		_rControlList.push_back( new ODisableWrapper< FixedText >( &m_aAutoIncrementLabel ) );
409 		_rControlList.push_back( new ODisableWrapper< FixedText >( &m_aAutoRetrievingLabel ) );
410 	}
411 
412     // -----------------------------------------------------------------------
413 	void GeneratedValuesPage::fillControls( ::std::vector< ISaveValueWrapper* >& _rControlList )
414 	{
415 		_rControlList.push_back( new OSaveValueWrapper< CheckBox >( &m_aAutoRetrievingEnabled ) );
416 		_rControlList.push_back( new OSaveValueWrapper< Edit >( &m_aAutoIncrement ) );
417 		_rControlList.push_back( new OSaveValueWrapper< Edit >( &m_aAutoRetrieving ) );
418     }
419 
420 	// -----------------------------------------------------------------------
421 	void GeneratedValuesPage::implInitControls( const SfxItemSet& _rSet, sal_Bool _bSaveValue )
422 	{
423 		// check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
424 		sal_Bool bValid, bReadonly;
425 		getFlags(_rSet, bValid, bReadonly);
426 
427 		// collect the items
428 		SFX_ITEMSET_GET(_rSet, pAutoIncrementItem, SfxStringItem, DSID_AUTOINCREMENTVALUE, sal_True);
429 		SFX_ITEMSET_GET(_rSet, pAutoRetrieveValueItem, SfxStringItem, DSID_AUTORETRIEVEVALUE, sal_True);
430 		SFX_ITEMSET_GET(_rSet, pAutoRetrieveEnabledItem, SfxBoolItem, DSID_AUTORETRIEVEENABLED, sal_True);
431 
432 		// forward the values to the controls
433 		if (bValid)
434 		{
435 			sal_Bool bEnabled = pAutoRetrieveEnabledItem->GetValue();
436 			m_aAutoRetrievingEnabled.Check( bEnabled );
437 
438 			m_aAutoIncrement.SetText( pAutoIncrementItem->GetValue() );
439 			m_aAutoIncrement.ClearModifyFlag();
440 			m_aAutoRetrieving.SetText( pAutoRetrieveValueItem->GetValue() );
441 			m_aAutoRetrieving.ClearModifyFlag();
442 		}
443 		OGenericAdministrationPage::implInitControls( _rSet, _bSaveValue );
444 	}
445 
446 	// -----------------------------------------------------------------------
447 	sal_Bool GeneratedValuesPage::FillItemSet(SfxItemSet& _rSet)
448 	{
449 		sal_Bool bChangedSomething = sal_False;
450 
451 		fillString( _rSet, &m_aAutoIncrement, DSID_AUTOINCREMENTVALUE, bChangedSomething );
452 		fillBool( _rSet, &m_aAutoRetrievingEnabled, DSID_AUTORETRIEVEENABLED, bChangedSomething );
453 		fillString( _rSet, &m_aAutoRetrieving, DSID_AUTORETRIEVEVALUE, bChangedSomething );
454 
455 		return bChangedSomething;
456 	}
457 
458 	//========================================================================
459 	//= AdvancedSettingsDialog
460     //========================================================================
461     //------------------------------------------------------------------------
462 	AdvancedSettingsDialog::AdvancedSettingsDialog( Window* _pParent, SfxItemSet* _pItems,
463         const Reference< XMultiServiceFactory >& _rxORB, const Any& _aDataSourceName )
464 		:SfxTabDialog(_pParent, ModuleRes(DLG_DATABASE_ADVANCED), _pItems)
465 		,m_pItemSet(_pItems)
466 	{
467 		m_pImpl = ::std::auto_ptr<ODbDataSourceAdministrationHelper>(new ODbDataSourceAdministrationHelper(_rxORB,_pParent,this));
468 		m_pImpl->setDataSourceOrName(_aDataSourceName);
469 		Reference< XPropertySet > xDatasource = m_pImpl->getCurrentDataSource();
470 		m_pImpl->translateProperties(xDatasource, *_pItems);
471 		SetInputSet(_pItems);
472 		// propagate this set as our new input set and reset the example set
473 		delete pExampleSet;
474 		pExampleSet = new SfxItemSet(*GetInputSetImpl());
475 
476 		const ::rtl::OUString eType = m_pImpl->getDatasourceType(*_pItems);
477 
478         DataSourceMetaData aMeta( eType );
479         const FeatureSet& rFeatures( aMeta.getFeatureSet() );
480 
481         // auto-generated values?
482         if ( rFeatures.supportsGeneratedValues() )
483 			AddTabPage( PAGE_GENERATED_VALUES, String( ModuleRes( STR_GENERATED_VALUE ) ), ODriversSettings::CreateGeneratedValuesPage, NULL );
484 
485         // any "special settings"?
486         if ( rFeatures.supportsAnySpecialSetting() )
487 			AddTabPage( PAGE_ADVANCED_SETTINGS_SPECIAL, String( ModuleRes( STR_DS_BEHAVIOUR ) ), ODriversSettings::CreateSpecialSettingsPage, NULL );
488 
489 		// remove the reset button - it's meaning is much too ambiguous in this dialog
490 		RemoveResetButton();
491 		FreeResource();
492 	}
493 
494 	// -----------------------------------------------------------------------
495 	AdvancedSettingsDialog::~AdvancedSettingsDialog()
496 	{
497 		SetInputSet(NULL);
498 		DELETEZ(pExampleSet);
499     }
500 
501     // -----------------------------------------------------------------------
502     bool AdvancedSettingsDialog::doesHaveAnyAdvancedSettings( const ::rtl::OUString& _sURL )
503     {
504         DataSourceMetaData aMeta( _sURL );
505         const FeatureSet& rFeatures( aMeta.getFeatureSet() );
506         if ( rFeatures.supportsGeneratedValues() || rFeatures.supportsAnySpecialSetting() )
507             return true;
508         return false;
509     }
510 
511     // -----------------------------------------------------------------------
512 	short AdvancedSettingsDialog::Execute()
513 	{
514 		short nRet = SfxTabDialog::Execute();
515 		if ( nRet == RET_OK )
516 		{
517 			pExampleSet->Put(*GetOutputItemSet());
518 			m_pImpl->saveChanges(*pExampleSet);
519 		}
520 		return nRet;
521 	}
522 
523 	//-------------------------------------------------------------------------
524 	void AdvancedSettingsDialog::PageCreated(sal_uInt16 _nId, SfxTabPage& _rPage)
525 	{
526 		// register ourself as modified listener
527 		static_cast<OGenericAdministrationPage&>(_rPage).SetServiceFactory(m_pImpl->getORB());
528 		static_cast<OGenericAdministrationPage&>(_rPage).SetAdminDialog(this,this);
529 
530 		AdjustLayout();
531 		Window *pWin = GetViewWindow();
532 		if(pWin)
533 			pWin->Invalidate();
534 
535 		SfxTabDialog::PageCreated(_nId, _rPage);
536 	}
537 
538 	// -----------------------------------------------------------------------------
539 	const SfxItemSet* AdvancedSettingsDialog::getOutputSet() const
540 	{
541 		return pExampleSet;
542 	}
543 
544 	// -----------------------------------------------------------------------------
545 	SfxItemSet* AdvancedSettingsDialog::getWriteOutputSet()
546 	{
547 		return pExampleSet;
548 	}
549 
550 	// -----------------------------------------------------------------------------
551 	::std::pair< Reference< XConnection >, sal_Bool > AdvancedSettingsDialog::createConnection()
552 	{
553 		return m_pImpl->createConnection();
554 	}
555 
556 	// -----------------------------------------------------------------------------
557 	Reference< XMultiServiceFactory > AdvancedSettingsDialog::getORB() const
558 	{
559 		return m_pImpl->getORB();
560 	}
561 
562 	// -----------------------------------------------------------------------------
563 	Reference< XDriver > AdvancedSettingsDialog::getDriver()
564 	{
565 		return m_pImpl->getDriver();
566 	}
567 
568 	// -----------------------------------------------------------------------------
569 	::rtl::OUString	AdvancedSettingsDialog::getDatasourceType(const SfxItemSet& _rSet) const
570 	{
571 		return m_pImpl->getDatasourceType(_rSet);
572 	}
573 
574 	// -----------------------------------------------------------------------------
575 	void AdvancedSettingsDialog::clearPassword()
576 	{
577 		m_pImpl->clearPassword();
578 	}
579 
580 	// -----------------------------------------------------------------------------
581 	void AdvancedSettingsDialog::setTitle(const ::rtl::OUString& _sTitle)
582 	{
583 		SetText(_sTitle);
584 	}
585 
586 	//-------------------------------------------------------------------------
587     void AdvancedSettingsDialog::enableConfirmSettings( bool _bEnable )
588     {
589         (void)_bEnable;
590     }
591 
592 	//-------------------------------------------------------------------------
593 	sal_Bool AdvancedSettingsDialog::saveDatasource()
594 	{
595 		return PrepareLeaveCurrentPage();
596 	}
597 
598 //........................................................................
599 } // namespace dbaui
600 //........................................................................
601