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