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 // MARKER(update_precomp.py): autogen include statement, do not remove
24 #include "precompiled_dbaccess.hxx"
25 #ifndef _DBAUI_MODULE_DBU_HXX_
26 #include "moduledbu.hxx"
27 #endif
28 
29 #ifndef DBAUI_TEXTCONNECTIONHELPER_HXX
30 #include "TextConnectionHelper.hxx"
31 #endif
32 
33 #ifndef _DBAUI_SQLMESSAGE_HXX_
34 #include "sqlmessage.hxx"
35 #endif
36 #ifndef _DBU_DLG_HRC_
37 #include "dbu_dlg.hrc"
38 #endif
39 #ifndef _DBU_RESOURCE_HRC_
40 #include "dbu_resource.hrc"
41 #endif
42 #ifndef _DBAUI_AUTOCONTROLS_HRC_
43 #include "AutoControls.hrc"
44 #endif
45 
46 #ifndef _SFXITEMSET_HXX
47 #include <svl/itemset.hxx>
48 #endif
49 #ifndef _SFXSTRITEM_HXX
50 #include <svl/stritem.hxx>
51 #endif
52 #ifndef _SFXENUMITEM_HXX
53 #include <svl/eitem.hxx>
54 #endif
55 #ifndef _SFXINTITEM_HXX
56 #include <svl/intitem.hxx>
57 #endif
58 #ifndef _DBAUI_DATASOURCEITEMS_HXX_
59 #include "dsitems.hxx"
60 #endif
61 #ifndef _DBAUI_DBFINDEX_HXX_
62 #include "dbfindex.hxx"
63 #endif
64 #ifndef _DBA_DBACCESS_HELPID_HRC_
65 #include "dbaccess_helpid.hrc"
66 #endif
67 #ifndef _DBAUI_LOCALRESACCESS_HXX_
68 #include "localresaccess.hxx"
69 #endif
70 #ifndef _SV_MSGBOX_HXX
71 #include <vcl/msgbox.hxx>
72 #endif
73 #ifndef _SV_MNEMONIC_HXX
74 #include <vcl/mnemonic.hxx>
75 #endif
76 #ifndef _SVTOOLS_CJKOPTIONS_HXX
77 #include <svl/cjkoptions.hxx>
78 #endif
79 #include <jvmaccess/virtualmachine.hxx>
80 #ifndef _DBAUI_ADASTAT_HXX_
81 #include "AdabasStat.hxx"
82 #endif
83 #ifndef _CONNECTIVITY_COMMONTOOLS_HXX_
84 #include <connectivity/CommonTools.hxx>
85 #endif
86 #ifndef DBAUI_DRIVERSETTINGS_HXX
87 #include "DriverSettings.hxx"
88 #endif
89 #ifndef _DBAUI_DBADMIN_HXX_
90 #include "dbadmin.hxx"
91 #endif
92 #ifndef _COMPHELPER_TYPES_HXX_
93 #include <comphelper/types.hxx>
94 #endif
95 
96 #ifndef _COM_SUN_STAR_UI_DIALOGS_XFOLDERPICKER_HPP_
97 #include <com/sun/star/ui/dialogs/XFolderPicker.hpp>
98 #endif
99 // #106016# ------------------------------------
100 #ifndef _COM_SUN_STAR_TASK_XINTERACTIONHANDLER_HPP_
101 #include <com/sun/star/task/XInteractionHandler.hpp>
102 #endif
103 
104 #ifndef SVTOOLS_FILENOTATION_HXX_
105 #include <svl/filenotation.hxx>
106 #endif
107 
108 #ifndef _UNOTOOLS_LOCALFILEHELPER_HXX
109 #include <unotools/localfilehelper.hxx>
110 #endif
111 #ifndef _UNOTOOLS_UCBHELPER_HXX
112 #include <unotools/ucbhelper.hxx>
113 #endif
114 #ifndef _UCBHELPER_COMMANDENVIRONMENT_HXX
115 #include <ucbhelper/commandenvironment.hxx>
116 #endif
117 #ifndef DBAUI_FILEPICKER_INTERACTION_HXX
118 #include "finteraction.hxx"
119 #endif
120 #ifndef _CONNECTIVITY_COMMONTOOLS_HXX_
121 #include <connectivity/CommonTools.hxx>
122 #endif
123 
124 #ifndef DBAUI_DBSETUPCONNECTIONPAGES_HXX
125 #include "DBSetupConnectionPages.hxx"
126 #endif
127 
128 #ifndef _DBU_DLG_HRC_
129 #include "dbu_dlg.hrc"
130 #endif
131 
132 #ifndef _DBA_DBACCESS_HELPID_HRC_
133 #include "dbaccess_helpid.hrc"
134 #endif
135 
136 #ifndef INCLUDED_SVTOOLS_PATHOPTIONS_HXX
137 #include <unotools/pathoptions.hxx>
138 #endif
139 
140 #ifndef SVTOOLS_INC_ROADMAPWIZARD_HXX
141 #include <svtools/roadmapwizard.hxx>
142 #endif
143 
144 
145 namespace dbaui
146 {
147 
148     //========================================================================
149 	//= OTextConnectionPageSetup
150 	//========================================================================
151 DBG_NAME(OTextConnectionHelper)
152 //------------------------------------------------------------------------
153 	OTextConnectionHelper::OTextConnectionHelper( Window* pParent, const short _nAvailableSections )
154 		:Control( pParent, WB_DIALOGCONTROL )
155         ,m_aFTExtensionHeader       (this, ModuleRes(FT_AUTOEXTENSIONHEADER))
156         ,m_aRBAccessTextFiles       (this, ModuleRes(RB_AUTOACCESSCTEXTFILES))
157         ,m_aRBAccessCSVFiles        (this, ModuleRes(RB_AUTOACCESSCCSVFILES))
158         ,m_aRBAccessOtherFiles      (this, ModuleRes(RB_AUTOACCESSOTHERS))
159         ,m_aETOwnExtension          (this, ModuleRes(ET_AUTOOWNEXTENSION))
160         ,m_aFTExtensionExample      (this, ModuleRes(FT_AUTOOWNEXTENSIONAPPENDIX))
161         ,m_aLineFormat				(this, ModuleRes(FL_AUTOSEPARATOR2))
162         ,m_aFieldSeparatorLabel		(this, ModuleRes(FT_AUTOFIELDSEPARATOR))
163 		,m_aFieldSeparator			(this, ModuleRes(CM_AUTOFIELDSEPARATOR))
164 		,m_aTextSeparatorLabel		(this, ModuleRes(FT_AUTOTEXTSEPARATOR))
165 		,m_aTextSeparator			(this, ModuleRes(CM_AUTOTEXTSEPARATOR))
166 		,m_aDecimalSeparatorLabel	(this, ModuleRes(FT_AUTODECIMALSEPARATOR))
167 		,m_aDecimalSeparator		(this, ModuleRes(CM_AUTODECIMALSEPARATOR))
168 		,m_aThousandsSeparatorLabel	(this, ModuleRes(FT_AUTOTHOUSANDSSEPARATOR))
169 		,m_aThousandsSeparator		(this, ModuleRes(CM_AUTOTHOUSANDSSEPARATOR))
170         ,m_aRowHeader               (this, ModuleRes(CB_AUTOHEADER))
171         ,m_aCharSetHeader           (this, ModuleRes(FL_DATACONVERT))
172         ,m_aCharSetLabel            (this, ModuleRes(FT_CHARSET))
173         ,m_aCharSet                 (this, ModuleRes(LB_CHARSET))
174 		,m_aFieldSeparatorList		(ModuleRes(STR_AUTOFIELDSEPARATORLIST))
175 		,m_aTextSeparatorList		(ModuleRes(STR_AUTOTEXTSEPARATORLIST))
176 		,m_aTextNone				(ModuleRes(STR_AUTOTEXT_FIELD_SEP_NONE))
177         ,m_nAvailableSections( _nAvailableSections )
178     {
179         DBG_CTOR(OTextConnectionHelper,NULL);
180 
181         xub_StrLen nCnt = m_aFieldSeparatorList.GetTokenCount( '\t' );
182 		xub_StrLen i;
183 
184 		for( i = 0 ; i < nCnt ; i += 2 )
185 			m_aFieldSeparator.InsertEntry( m_aFieldSeparatorList.GetToken( i, '\t' ) );
186 
187 		nCnt = m_aTextSeparatorList.GetTokenCount( '\t' );
188 		for( i=0 ; i<nCnt ; i+=2 )
189 			m_aTextSeparator.InsertEntry( m_aTextSeparatorList.GetToken( i, '\t' ) );
190 		m_aTextSeparator.InsertEntry(m_aTextNone);
191 
192 		// set the modify handlers
193 		m_aFieldSeparator.SetUpdateDataHdl(getControlModifiedLink());
194 		m_aFieldSeparator.SetSelectHdl(getControlModifiedLink());
195 		m_aTextSeparator.SetUpdateDataHdl(getControlModifiedLink());
196 		m_aTextSeparator.SetSelectHdl(getControlModifiedLink());
197 		m_aCharSet.SetSelectHdl(getControlModifiedLink());
198 
199 		m_aFieldSeparator.SetModifyHdl(getControlModifiedLink());
200 		m_aTextSeparator.SetModifyHdl(getControlModifiedLink());
201 		m_aDecimalSeparator.SetModifyHdl(getControlModifiedLink());
202 		m_aThousandsSeparator.SetModifyHdl(getControlModifiedLink());
203         m_aETOwnExtension.SetModifyHdl(LINK(this, OTextConnectionHelper, OnEditModified));
204    		m_aRBAccessTextFiles.SetToggleHdl(LINK(this, OTextConnectionHelper, OnSetExtensionHdl));
205    		m_aRBAccessCSVFiles.SetToggleHdl(LINK(this, OTextConnectionHelper, OnSetExtensionHdl));
206         m_aRBAccessOtherFiles.SetToggleHdl(LINK(this, OTextConnectionHelper, OnSetExtensionHdl));
207         m_aRBAccessCSVFiles.Check(sal_True);
208 
209         struct SectionDescriptor
210         {
211             short   nFlag;
212             Window* pFirstControl;
213         } aSections[] = {
214             { TC_EXTENSION,     &m_aFTExtensionHeader },
215             { TC_SEPARATORS,    &m_aLineFormat },
216             { TC_HEADER,        &m_aRowHeader },
217             { TC_CHARSET,       &m_aCharSetHeader },
218             { 0, NULL }
219         };
220 
221         for ( size_t section=0; section < sizeof( aSections ) / sizeof( aSections[0] ) - 1; ++section )
222         {
223             if ( ( m_nAvailableSections & aSections[section].nFlag ) != 0 )
224             {
225                 // the section is visible, no need to do anything here
226                 continue;
227             }
228 
229             Window* pThisSection = aSections[section].pFirstControl;
230             Window* pNextSection = aSections[section+1].pFirstControl;
231 
232             // hide all elements from this section
233             Window* pControl = pThisSection;
234             while ( ( pControl != pNextSection ) && pControl )
235             {
236                 Window* pRealWindow = pControl->GetWindow( WINDOW_CLIENT );
237             #if OSL_DEBUG_LEVEL > 0
238                 String sWindowText( pRealWindow->GetText() );
239                 (void)sWindowText;
240             #endif
241                 pRealWindow->Hide();
242                 pControl = pControl->GetWindow( WINDOW_NEXT );
243             }
244 
245             // move all controls in following sections up
246             if ( !pNextSection )
247                 continue;
248             const long nThisSectionStart = pThisSection->GetPosPixel().Y();
249             const long nNextSectionStart = pNextSection->GetPosPixel().Y();
250             const long nMoveOffset( nThisSectionStart - nNextSectionStart );
251             while ( pControl )
252             {
253                 Point aPos = pControl->GetPosPixel();
254                 aPos.Move( 0, nMoveOffset );
255                 pControl->SetPosPixel( aPos );
256                 pControl = pControl->GetWindow( WINDOW_NEXT );
257             }
258         }
259 
260         Rectangle aControlRectUnion;
261         for (   Window* pControl = aSections[0].pFirstControl;
262                 pControl != NULL;
263                 pControl = pControl->GetWindow( WINDOW_NEXT )
264             )
265         {
266             aControlRectUnion = aControlRectUnion.Union( Rectangle( pControl->GetPosPixel(), pControl->GetSizePixel() ) );
267         }
268 
269         // need some adjustments to the positions, since the resource-specified
270         // positions for the control were relative to *our* parent, while by now
271         // the controls have |this| as parent.
272 
273         // first, move ourself to the upper left of the area occupied by all controls
274         SetPosPixel( aControlRectUnion.TopLeft() );
275 
276         // then, compensate in the control positions, by moving them the up/left
277         for (   Window* pControl = aSections[0].pFirstControl;
278                 pControl != NULL;
279                 pControl = pControl->GetWindow( WINDOW_NEXT )
280             )
281         {
282             Point aPos( pControl->GetPosPixel() );
283             aPos.Move( -aControlRectUnion.Left(), -aControlRectUnion.Top() );
284             pControl->SetPosPixel( aPos );
285 
286             // while we are here ... the controls should not have an own background
287             // (this would not be needed when our outer dialog were also the parent
288             // of the controls)
289             pControl->SetBackground();
290         }
291 
292         // now, change our own size so all controls fit
293         SetSizePixel( aControlRectUnion.GetSize() );
294 
295         SetBackground();
296         Show();
297 	}
298 
299 	// -----------------------------------------------------------------------
300 	OTextConnectionHelper::~OTextConnectionHelper()
301 	{
302 
303         DBG_DTOR(OTextConnectionHelper,NULL);
304     }
305 
306 
307 	// -----------------------------------------------------------------------
308 	IMPL_LINK(OTextConnectionHelper, OnControlModified, Control*, /*EMPTYARG*/)
309 	{
310 		callModifiedHdl();
311 		return 0L;
312 	}
313 
314     // -----------------------------------------------------------------------
315 	IMPL_LINK(OTextConnectionHelper, OnEditModified, Edit*, /*_pEdit*/)
316 	{
317 		m_aGetExtensionHandler.Call(this);
318 		return 0L;
319 	}
320 
321 
322     IMPL_LINK(OTextConnectionHelper, OnSetExtensionHdl, RadioButton*, /*_pRadioButton*/)
323     {
324         sal_Bool bDoEnable = m_aRBAccessOtherFiles.IsChecked();
325         m_aETOwnExtension.Enable(bDoEnable);
326         m_aFTExtensionExample.Enable(bDoEnable);
327         m_aGetExtensionHandler.Call(this);
328         return 0L;
329     }
330 
331 
332     // -----------------------------------------------------------------------
333 	void OTextConnectionHelper::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
334 	{
335 		_rControlList.push_back(new OSaveValueWrapper<ComboBox>(&m_aFieldSeparator));
336 		_rControlList.push_back(new OSaveValueWrapper<ComboBox>(&m_aTextSeparator));
337 		_rControlList.push_back(new OSaveValueWrapper<ComboBox>(&m_aDecimalSeparator));
338 		_rControlList.push_back(new OSaveValueWrapper<ComboBox>(&m_aThousandsSeparator));
339         _rControlList.push_back(new OSaveValueWrapper<CheckBox>(&m_aRowHeader));
340         _rControlList.push_back(new OSaveValueWrapper<ListBox>(&m_aCharSet));
341 	}
342 	// -----------------------------------------------------------------------
343 	void OTextConnectionHelper::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
344 	{
345 		_rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFieldSeparatorLabel));
346 		_rControlList.push_back(new ODisableWrapper<FixedText>(&m_aTextSeparatorLabel));
347 		_rControlList.push_back(new ODisableWrapper<FixedText>(&m_aDecimalSeparatorLabel));
348 		_rControlList.push_back(new ODisableWrapper<FixedText>(&m_aThousandsSeparatorLabel));
349         _rControlList.push_back(new ODisableWrapper<FixedLine>(&m_aCharSetHeader));
350         _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aCharSetLabel));
351         _rControlList.push_back(new ODisableWrapper<ListBox>(&m_aCharSet));
352 	}
353 
354     // -----------------------------------------------------------------------
355 	void OTextConnectionHelper::implInitControls(const SfxItemSet& _rSet, sal_Bool _bValid)
356 	{
357         if ( !_bValid )
358             return;
359 
360 		SFX_ITEMSET_GET( _rSet, pDelItem, SfxStringItem, DSID_FIELDDELIMITER, sal_True );
361 		SFX_ITEMSET_GET( _rSet, pStrItem, SfxStringItem, DSID_TEXTDELIMITER, sal_True );
362 		SFX_ITEMSET_GET( _rSet, pDecdelItem, SfxStringItem, DSID_DECIMALDELIMITER, sal_True );
363 		SFX_ITEMSET_GET( _rSet, pThodelItem, SfxStringItem, DSID_THOUSANDSDELIMITER, sal_True );
364 		SFX_ITEMSET_GET( _rSet, pExtensionItem, SfxStringItem, DSID_TEXTFILEEXTENSION, sal_True );
365 		SFX_ITEMSET_GET( _rSet, pCharsetItem, SfxStringItem, DSID_CHARSET, sal_True );
366 
367         if ( ( m_nAvailableSections & TC_EXTENSION ) != 0 )
368         {
369             m_aOldExtension = pExtensionItem->GetValue();
370             SetExtension( m_aOldExtension );
371         }
372 
373         if ( ( m_nAvailableSections & TC_HEADER ) != 0 )
374         {
375         	SFX_ITEMSET_GET( _rSet, pHdrItem, SfxBoolItem, DSID_TEXTFILEHEADER, sal_True );
376 			m_aRowHeader.Check( pHdrItem->GetValue() );
377         }
378 
379         if ( ( m_nAvailableSections & TC_SEPARATORS ) != 0 )
380         {
381 		    SetSeparator( m_aFieldSeparator, m_aFieldSeparatorList, pDelItem->GetValue() );
382 		    SetSeparator( m_aTextSeparator, m_aTextSeparatorList, pStrItem->GetValue() );
383 		    m_aDecimalSeparator.SetText( pDecdelItem->GetValue() );
384 		    m_aThousandsSeparator.SetText( pThodelItem->GetValue() );
385         }
386 
387         if ( ( m_nAvailableSections & TC_CHARSET ) != 0 )
388         {
389             m_aCharSet.SelectEntryByIanaName( pCharsetItem->GetValue() );
390         }
391 	}
392 
393 
394 
395 	// -----------------------------------------------------------------------
396 	sal_Bool OTextConnectionHelper::prepareLeave()
397 	{
398 		LocalResourceAccess aStringResAccess(PAGE_TEXT, RSC_TABPAGE);
399 			// for accessing the strings which are local to our own resource block
400         String sExtension = GetExtension();
401 		String aErrorText;
402 		Control* pErrorWin = NULL;
403 		//	if (!m_aFieldSeparator.GetText().Len())
404 			// bug (#42168) if this line is compiled under OS2 (in a product environent)
405 			// -> use a temporary variable
406 		String aDelText(m_aFieldSeparator.GetText());
407 		if(!aDelText.Len())
408 		{	// Kein FeldTrenner
409 			aErrorText = String(ModuleRes(STR_AUTODELIMITER_MISSING));
410 			aErrorText.SearchAndReplaceAscii("#1",m_aFieldSeparatorLabel.GetText());
411 			pErrorWin = &m_aFieldSeparator;
412 		}
413 		else if (!m_aDecimalSeparator.GetText().Len())
414 		{	// kein Decimaltrenner
415 			aErrorText = String(ModuleRes(STR_AUTODELIMITER_MISSING));
416 			aErrorText.SearchAndReplaceAscii("#1",m_aDecimalSeparatorLabel.GetText());
417 			pErrorWin = &m_aDecimalSeparator;
418 		}
419 		else if (m_aTextSeparator.GetText() == m_aFieldSeparator.GetText())
420 		{	// Feld und TextTrenner duerfen nicht gleich sein
421 			aErrorText = String(ModuleRes(STR_AUTODELIMITER_MUST_DIFFER));
422 			aErrorText.SearchAndReplaceAscii("#1",m_aTextSeparatorLabel.GetText());
423 			aErrorText.SearchAndReplaceAscii("#2",m_aFieldSeparatorLabel.GetText());
424 			pErrorWin = &m_aTextSeparator;
425 		}
426 		else if (m_aDecimalSeparator.GetText() == m_aThousandsSeparator.GetText())
427 		{	// Tausender und DecimalTrenner duerfen nicht gleich sein
428 			aErrorText = String(ModuleRes(STR_AUTODELIMITER_MUST_DIFFER));
429 			aErrorText.SearchAndReplaceAscii("#1",m_aDecimalSeparatorLabel.GetText());
430 			aErrorText.SearchAndReplaceAscii("#2",m_aThousandsSeparatorLabel.GetText());
431 			pErrorWin = &m_aDecimalSeparator;
432 		}
433 		else if (m_aFieldSeparator.GetText() == m_aThousandsSeparator.GetText())
434 		{	// Tausender und FeldTrenner duerfen nicht gleich sein
435 			aErrorText = String(ModuleRes(STR_AUTODELIMITER_MUST_DIFFER));
436 			aErrorText.SearchAndReplaceAscii("#1",m_aFieldSeparatorLabel.GetText());
437 			aErrorText.SearchAndReplaceAscii("#2",m_aThousandsSeparatorLabel.GetText());
438 			pErrorWin = &m_aFieldSeparator;
439 		}
440 		else if (m_aFieldSeparator.GetText() == m_aDecimalSeparator.GetText())
441 		{	// Zehner und FeldTrenner duerfen nicht gleich sein
442 			aErrorText = String(ModuleRes(STR_AUTODELIMITER_MUST_DIFFER));
443 			aErrorText.SearchAndReplaceAscii("#1",m_aFieldSeparatorLabel.GetText());
444 			aErrorText.SearchAndReplaceAscii("#2",m_aDecimalSeparatorLabel.GetText());
445 			pErrorWin = &m_aFieldSeparator;
446 		}
447 		else if (m_aTextSeparator.GetText() == m_aThousandsSeparator.GetText())
448 		{	// Tausender und TextTrenner duerfen nicht gleich sein
449 			aErrorText = String(ModuleRes(STR_AUTODELIMITER_MUST_DIFFER));
450 			aErrorText.SearchAndReplaceAscii("#1",m_aTextSeparatorLabel.GetText());
451 			aErrorText.SearchAndReplaceAscii("#2",m_aThousandsSeparatorLabel.GetText());
452 			pErrorWin = &m_aTextSeparator;
453 		}
454 		else if (m_aTextSeparator.GetText() == m_aDecimalSeparator.GetText())
455 		{	// Zehner und TextTrenner duerfen nicht gleich sein
456 			aErrorText = String(ModuleRes(STR_AUTODELIMITER_MUST_DIFFER));
457 			aErrorText.SearchAndReplaceAscii("#1",m_aTextSeparatorLabel.GetText());
458 			aErrorText.SearchAndReplaceAscii("#2",m_aDecimalSeparatorLabel.GetText());
459 			pErrorWin = &m_aTextSeparator;
460 		}
461 		else if ((sExtension.Search('*') != STRING_NOTFOUND) || (sExtension.Search('?') != STRING_NOTFOUND))
462 		{
463 			aErrorText = String(ModuleRes(STR_AUTONO_WILDCARDS));
464 			aErrorText.SearchAndReplaceAscii("#1",sExtension);
465 			pErrorWin = &m_aETOwnExtension;
466 		}
467 		else
468 			return sal_True;
469 		ErrorBox(NULL, WB_OK, MnemonicGenerator::EraseAllMnemonicChars( aErrorText)).Execute();
470 		pErrorWin->GrabFocus();
471 		return 0;
472 	}
473 
474 
475 	// -----------------------------------------------------------------------
476 	sal_Bool OTextConnectionHelper::FillItemSet( SfxItemSet& rSet, const sal_Bool _bChangedSomething )
477 	{
478         sal_Bool bChangedSomething = _bChangedSomething;
479 
480         if ( ( m_nAvailableSections & TC_EXTENSION ) != 0 )
481         {
482             String sExtension = GetExtension();
483 		    if( !m_aOldExtension.Equals( sExtension ) )
484 		    {
485 			    rSet.Put( SfxStringItem( DSID_TEXTFILEEXTENSION, sExtension ) );
486 			    bChangedSomething = sal_True;
487 		    }
488         }
489 
490         if ( ( m_nAvailableSections & TC_HEADER ) != 0 )
491         {
492 		    if( (m_aRowHeader.GetState() != m_aRowHeader.GetSavedValue()) )
493 		    {
494 			    rSet.Put(SfxBoolItem(DSID_TEXTFILEHEADER, m_aRowHeader.IsChecked()));
495 			    bChangedSomething = sal_True;
496 		    }
497         }
498 
499         if ( ( m_nAvailableSections & TC_SEPARATORS ) != 0 )
500         {
501 		    if( m_aFieldSeparator.GetText() != m_aFieldSeparator.GetSavedValue() )
502 		    {
503 			    rSet.Put( SfxStringItem(DSID_FIELDDELIMITER, GetSeparator( m_aFieldSeparator, m_aFieldSeparatorList) ) );
504 			    bChangedSomething = sal_True;
505 		    }
506 		    if( m_aTextSeparator.GetText() != m_aTextSeparator.GetSavedValue() )
507 		    {
508 			    rSet.Put( SfxStringItem(DSID_TEXTDELIMITER, GetSeparator( m_aTextSeparator, m_aTextSeparatorList) ) );
509 			    bChangedSomething = sal_True;
510 		    }
511 
512 		    if( m_aDecimalSeparator.GetText() != m_aDecimalSeparator.GetSavedValue() )
513 		    {
514 			    rSet.Put( SfxStringItem(DSID_DECIMALDELIMITER, m_aDecimalSeparator.GetText().Copy(0, 1) ) );
515 			    bChangedSomething = sal_True;
516 		    }
517 		    if( m_aThousandsSeparator.GetText() != m_aThousandsSeparator.GetSavedValue() )
518 		    {
519 			    rSet.Put( SfxStringItem(DSID_THOUSANDSDELIMITER, m_aThousandsSeparator.GetText().Copy(0,1) ) );
520 			    bChangedSomething = sal_True;
521 		    }
522         }
523 
524         if ( ( m_nAvailableSections & TC_CHARSET ) != 0 )
525         {
526             if ( m_aCharSet.StoreSelectedCharSet( rSet, DSID_CHARSET ) )
527                 bChangedSomething = sal_True;
528         }
529 
530 		return bChangedSomething;
531 	}
532 
533 
534     void OTextConnectionHelper::SetExtension(const String& _rVal)
535     {
536         if (_rVal.EqualsAscii("txt"))
537             m_aRBAccessTextFiles.Check(sal_True);
538         else if (_rVal.EqualsAscii( "csv" ))
539             m_aRBAccessCSVFiles.Check(sal_True);
540         else
541         {
542             m_aRBAccessOtherFiles.Check(sal_True);
543             m_aFTExtensionExample.SetText(_rVal);
544         }
545     }
546 
547 
548     String OTextConnectionHelper::GetExtension()
549     {
550         String sExtension;
551         if (m_aRBAccessTextFiles.IsChecked())
552             sExtension = String::CreateFromAscii("txt");
553         else if (m_aRBAccessCSVFiles.IsChecked())
554             sExtension = String::CreateFromAscii("csv");
555         else
556         {
557             sExtension = m_aETOwnExtension.GetText();
558             if ( sExtension.GetToken(0,'.').Equals('*') )
559                 sExtension.Erase(0,2);
560         }
561         return sExtension;
562     }
563 
564 
565 	//------------------------------------------------------------------------
566 	String OTextConnectionHelper::GetSeparator( const ComboBox& rBox, const String& rList )
567 	{
568 		sal_Unicode	nTok = '\t';
569 		xub_StrLen	nPos(rBox.GetEntryPos( rBox.GetText() ));
570 
571 		if( nPos == COMBOBOX_ENTRY_NOTFOUND )
572 			return rBox.GetText().Copy(0);
573 
574 		if ( !( &m_aTextSeparator == &rBox && nPos == (rBox.GetEntryCount()-1) ) )
575 			return String(
576                 static_cast< sal_Unicode >(
577                     rList.GetToken(((nPos*2)+1), nTok ).ToInt32()));
578 		// somewhat strange ... translates for instance an "32" into " "
579 		return String();
580 	}
581 
582 	//------------------------------------------------------------------------
583 	void OTextConnectionHelper::SetSeparator( ComboBox& rBox, const String& rList, const String& rVal )
584 	{
585 		char	nTok = '\t';
586 		xub_StrLen	nCnt(rList.GetTokenCount( nTok ));
587 		xub_StrLen	i;
588 
589 		for( i=0 ; i<nCnt ; i+=2 )
590 		{
591 			String	sTVal(
592                 static_cast< sal_Unicode >(
593                     rList.GetToken( (i+1), nTok ).ToInt32()));
594 
595 			if( sTVal == rVal )
596 			{
597 				rBox.SetText( rList.GetToken( i, nTok ) );
598 				break;
599 			}
600 		}
601 
602 		if ( i >= nCnt )
603 		{
604 			if ( &m_aTextSeparator == &rBox && !rVal.Len() )
605 				rBox.SetText(m_aTextNone);
606 			else
607 				rBox.SetText( rVal.Copy(0, 1) );
608 		}
609 	}
610 
611 //.........................................................................
612 }	// namespace dbaui
613 //.........................................................................
614