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