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