merge the formfield patch from ooo-build
[ooovba.git] / dbaccess / source / ui / dlg / TextConnectionHelper.cxx
blobe933b0617b5c7cdff3e50e1f63691899ca8d73ca
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: TextConnectionHelper.cxx,v $
10 * $Revision: 1.15 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 // MARKER(update_precomp.py): autogen include statement, do not remove
31 #include "precompiled_dbaccess.hxx"
32 #ifndef _DBAUI_MODULE_DBU_HXX_
33 #include "moduledbu.hxx"
34 #endif
36 #ifndef DBAUI_TEXTCONNECTIONHELPER_HXX
37 #include "TextConnectionHelper.hxx"
38 #endif
40 #ifndef _DBAUI_SQLMESSAGE_HXX_
41 #include "sqlmessage.hxx"
42 #endif
43 #ifndef _DBU_DLG_HRC_
44 #include "dbu_dlg.hrc"
45 #endif
46 #ifndef _DBU_RESOURCE_HRC_
47 #include "dbu_resource.hrc"
48 #endif
49 #ifndef _DBAUI_AUTOCONTROLS_HRC_
50 #include "AutoControls.hrc"
51 #endif
53 #ifndef _SFXITEMSET_HXX
54 #include <svtools/itemset.hxx>
55 #endif
56 #ifndef _SFXSTRITEM_HXX
57 #include <svtools/stritem.hxx>
58 #endif
59 #ifndef _SFXENUMITEM_HXX
60 #include <svtools/eitem.hxx>
61 #endif
62 #ifndef _SFXINTITEM_HXX
63 #include <svtools/intitem.hxx>
64 #endif
65 #ifndef _DBAUI_DATASOURCEITEMS_HXX_
66 #include "dsitems.hxx"
67 #endif
68 #ifndef _DBAUI_DBFINDEX_HXX_
69 #include "dbfindex.hxx"
70 #endif
71 #ifndef _DBA_DBACCESS_HELPID_HRC_
72 #include "dbaccess_helpid.hrc"
73 #endif
74 #ifndef _DBAUI_LOCALRESACCESS_HXX_
75 #include "localresaccess.hxx"
76 #endif
77 #ifndef _SV_MSGBOX_HXX
78 #include <vcl/msgbox.hxx>
79 #endif
80 #ifndef _SV_MNEMONIC_HXX
81 #include <vcl/mnemonic.hxx>
82 #endif
83 #ifndef _SVTOOLS_CJKOPTIONS_HXX
84 #include <svtools/cjkoptions.hxx>
85 #endif
86 #include <jvmaccess/virtualmachine.hxx>
87 #ifndef _DBAUI_ADASTAT_HXX_
88 #include "AdabasStat.hxx"
89 #endif
90 #ifndef _CONNECTIVITY_COMMONTOOLS_HXX_
91 #include <connectivity/CommonTools.hxx>
92 #endif
93 #ifndef DBAUI_DRIVERSETTINGS_HXX
94 #include "DriverSettings.hxx"
95 #endif
96 #ifndef _DBAUI_DBADMIN_HXX_
97 #include "dbadmin.hxx"
98 #endif
99 #ifndef _COMPHELPER_TYPES_HXX_
100 #include <comphelper/types.hxx>
101 #endif
103 #ifndef _COM_SUN_STAR_UI_DIALOGS_XFOLDERPICKER_HPP_
104 #include <com/sun/star/ui/dialogs/XFolderPicker.hpp>
105 #endif
106 // #106016# ------------------------------------
107 #ifndef _COM_SUN_STAR_TASK_XINTERACTIONHANDLER_HPP_
108 #include <com/sun/star/task/XInteractionHandler.hpp>
109 #endif
111 #ifndef SVTOOLS_FILENOTATION_HXX_
112 #include <svtools/filenotation.hxx>
113 #endif
115 #ifndef _UNOTOOLS_LOCALFILEHELPER_HXX
116 #include <unotools/localfilehelper.hxx>
117 #endif
118 #ifndef _UNOTOOLS_UCBHELPER_HXX
119 #include <unotools/ucbhelper.hxx>
120 #endif
121 #ifndef _UCBHELPER_COMMANDENVIRONMENT_HXX
122 #include <ucbhelper/commandenvironment.hxx>
123 #endif
124 #ifndef DBAUI_FILEPICKER_INTERACTION_HXX
125 #include "finteraction.hxx"
126 #endif
127 #ifndef _CONNECTIVITY_COMMONTOOLS_HXX_
128 #include <connectivity/CommonTools.hxx>
129 #endif
131 #ifndef DBAUI_DBSETUPCONNECTIONPAGES_HXX
132 #include "DBSetupConnectionPages.hxx"
133 #endif
135 #ifndef _DBU_DLG_HRC_
136 #include "dbu_dlg.hrc"
137 #endif
139 #ifndef _DBA_DBACCESS_HELPID_HRC_
140 #include "dbaccess_helpid.hrc"
141 #endif
143 #ifndef INCLUDED_SVTOOLS_PATHOPTIONS_HXX
144 #include <svtools/pathoptions.hxx>
145 #endif
147 #ifndef SVTOOLS_INC_ROADMAPWIZARD_HXX
148 #include <svtools/roadmapwizard.hxx>
149 #endif
152 namespace dbaui
155 //========================================================================
156 //= OTextConnectionPageSetup
157 //========================================================================
158 DBG_NAME(OTextConnectionHelper)
159 //------------------------------------------------------------------------
160 OTextConnectionHelper::OTextConnectionHelper( Window* pParent, const short _nAvailableSections )
161 :Control( pParent, WB_DIALOGCONTROL )
162 ,m_aFTExtensionHeader (this, ModuleRes(FT_AUTOEXTENSIONHEADER))
163 ,m_aRBAccessTextFiles (this, ModuleRes(RB_AUTOACCESSCTEXTFILES))
164 ,m_aRBAccessCSVFiles (this, ModuleRes(RB_AUTOACCESSCCSVFILES))
165 ,m_aRBAccessOtherFiles (this, ModuleRes(RB_AUTOACCESSOTHERS))
166 ,m_aETOwnExtension (this, ModuleRes(ET_AUTOOWNEXTENSION))
167 ,m_aFTExtensionExample (this, ModuleRes(FT_AUTOOWNEXTENSIONAPPENDIX))
168 ,m_aLineFormat (this, ModuleRes(FL_AUTOSEPARATOR2))
169 ,m_aFieldSeparatorLabel (this, ModuleRes(FT_AUTOFIELDSEPARATOR))
170 ,m_aFieldSeparator (this, ModuleRes(CM_AUTOFIELDSEPARATOR))
171 ,m_aTextSeparatorLabel (this, ModuleRes(FT_AUTOTEXTSEPARATOR))
172 ,m_aTextSeparator (this, ModuleRes(CM_AUTOTEXTSEPARATOR))
173 ,m_aDecimalSeparatorLabel (this, ModuleRes(FT_AUTODECIMALSEPARATOR))
174 ,m_aDecimalSeparator (this, ModuleRes(CM_AUTODECIMALSEPARATOR))
175 ,m_aThousandsSeparatorLabel (this, ModuleRes(FT_AUTOTHOUSANDSSEPARATOR))
176 ,m_aThousandsSeparator (this, ModuleRes(CM_AUTOTHOUSANDSSEPARATOR))
177 ,m_aRowHeader (this, ModuleRes(CB_AUTOHEADER))
178 ,m_aCharSetHeader (this, ModuleRes(FL_DATACONVERT))
179 ,m_aCharSetLabel (this, ModuleRes(FT_CHARSET))
180 ,m_aCharSet (this, ModuleRes(LB_CHARSET))
181 ,m_aFieldSeparatorList (ModuleRes(STR_AUTOFIELDSEPARATORLIST))
182 ,m_aTextSeparatorList (ModuleRes(STR_AUTOTEXTSEPARATORLIST))
183 ,m_aTextNone (ModuleRes(STR_AUTOTEXT_FIELD_SEP_NONE))
184 ,m_nAvailableSections( _nAvailableSections )
186 DBG_CTOR(OTextConnectionHelper,NULL);
188 xub_StrLen nCnt = m_aFieldSeparatorList.GetTokenCount( '\t' );
189 xub_StrLen i;
191 for( i = 0 ; i < nCnt ; i += 2 )
192 m_aFieldSeparator.InsertEntry( m_aFieldSeparatorList.GetToken( i, '\t' ) );
194 nCnt = m_aTextSeparatorList.GetTokenCount( '\t' );
195 for( i=0 ; i<nCnt ; i+=2 )
196 m_aTextSeparator.InsertEntry( m_aTextSeparatorList.GetToken( i, '\t' ) );
197 m_aTextSeparator.InsertEntry(m_aTextNone);
199 // set the modify handlers
200 m_aFieldSeparator.SetUpdateDataHdl(getControlModifiedLink());
201 m_aFieldSeparator.SetSelectHdl(getControlModifiedLink());
202 m_aTextSeparator.SetUpdateDataHdl(getControlModifiedLink());
203 m_aTextSeparator.SetSelectHdl(getControlModifiedLink());
204 m_aCharSet.SetSelectHdl(getControlModifiedLink());
206 m_aFieldSeparator.SetModifyHdl(getControlModifiedLink());
207 m_aTextSeparator.SetModifyHdl(getControlModifiedLink());
208 m_aDecimalSeparator.SetModifyHdl(getControlModifiedLink());
209 m_aThousandsSeparator.SetModifyHdl(getControlModifiedLink());
210 m_aETOwnExtension.SetModifyHdl(LINK(this, OTextConnectionHelper, OnEditModified));
211 m_aRBAccessTextFiles.SetToggleHdl(LINK(this, OTextConnectionHelper, OnSetExtensionHdl));
212 m_aRBAccessCSVFiles.SetToggleHdl(LINK(this, OTextConnectionHelper, OnSetExtensionHdl));
213 m_aRBAccessOtherFiles.SetToggleHdl(LINK(this, OTextConnectionHelper, OnSetExtensionHdl));
214 m_aRBAccessCSVFiles.Check(sal_True);
216 struct SectionDescriptor
218 short nFlag;
219 Window* pFirstControl;
220 } aSections[] = {
221 { TC_EXTENSION, &m_aFTExtensionHeader },
222 { TC_SEPARATORS, &m_aLineFormat },
223 { TC_HEADER, &m_aRowHeader },
224 { TC_CHARSET, &m_aCharSetHeader },
225 { 0, NULL }
228 for ( size_t section=0; section < sizeof( aSections ) / sizeof( aSections[0] ) - 1; ++section )
230 if ( ( m_nAvailableSections & aSections[section].nFlag ) != 0 )
232 // the section is visible, no need to do anything here
233 continue;
236 Window* pThisSection = aSections[section].pFirstControl;
237 Window* pNextSection = aSections[section+1].pFirstControl;
239 // hide all elements from this section
240 Window* pControl = pThisSection;
241 while ( ( pControl != pNextSection ) && pControl )
243 Window* pRealWindow = pControl->GetWindow( WINDOW_CLIENT );
244 #if OSL_DEBUG_LEVEL > 0
245 String sWindowText( pRealWindow->GetText() );
246 (void)sWindowText;
247 #endif
248 pRealWindow->Hide();
249 pControl = pControl->GetWindow( WINDOW_NEXT );
252 // move all controls in following sections up
253 if ( !pNextSection )
254 continue;
255 const long nThisSectionStart = pThisSection->GetPosPixel().Y();
256 const long nNextSectionStart = pNextSection->GetPosPixel().Y();
257 const long nMoveOffset( nThisSectionStart - nNextSectionStart );
258 while ( pControl )
260 Point aPos = pControl->GetPosPixel();
261 aPos.Move( 0, nMoveOffset );
262 pControl->SetPosPixel( aPos );
263 pControl = pControl->GetWindow( WINDOW_NEXT );
267 Rectangle aControlRectUnion;
268 for ( Window* pControl = aSections[0].pFirstControl;
269 pControl != NULL;
270 pControl = pControl->GetWindow( WINDOW_NEXT )
273 aControlRectUnion = aControlRectUnion.Union( Rectangle( pControl->GetPosPixel(), pControl->GetSizePixel() ) );
276 // need some adjustments to the positions, since the resource-specified
277 // positions for the control were relative to *our* parent, while by now
278 // the controls have |this| as parent.
280 // first, move ourself to the upper left of the area occupied by all controls
281 SetPosPixel( aControlRectUnion.TopLeft() );
283 // then, compensate in the control positions, by moving them the up/left
284 for ( Window* pControl = aSections[0].pFirstControl;
285 pControl != NULL;
286 pControl = pControl->GetWindow( WINDOW_NEXT )
289 Point aPos( pControl->GetPosPixel() );
290 aPos.Move( -aControlRectUnion.Left(), -aControlRectUnion.Top() );
291 pControl->SetPosPixel( aPos );
293 // while we are here ... the controls should not have an own background
294 // (this would not be needed when our outer dialog were also the parent
295 // of the controls)
296 pControl->SetBackground();
299 // now, change our own size so all controls fit
300 SetSizePixel( aControlRectUnion.GetSize() );
302 SetBackground();
303 Show();
306 // -----------------------------------------------------------------------
307 OTextConnectionHelper::~OTextConnectionHelper()
310 DBG_DTOR(OTextConnectionHelper,NULL);
314 // -----------------------------------------------------------------------
315 IMPL_LINK(OTextConnectionHelper, OnControlModified, Control*, /*EMPTYARG*/)
317 callModifiedHdl();
318 return 0L;
321 // -----------------------------------------------------------------------
322 IMPL_LINK(OTextConnectionHelper, OnEditModified, Edit*, /*_pEdit*/)
324 m_aGetExtensionHandler.Call(this);
325 return 0L;
329 IMPL_LINK(OTextConnectionHelper, OnSetExtensionHdl, RadioButton*, /*_pRadioButton*/)
331 sal_Bool bDoEnable = m_aRBAccessOtherFiles.IsChecked();
332 m_aETOwnExtension.Enable(bDoEnable);
333 m_aFTExtensionExample.Enable(bDoEnable);
334 m_aGetExtensionHandler.Call(this);
335 return 0L;
339 // -----------------------------------------------------------------------
340 void OTextConnectionHelper::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
342 _rControlList.push_back(new OSaveValueWrapper<ComboBox>(&m_aFieldSeparator));
343 _rControlList.push_back(new OSaveValueWrapper<ComboBox>(&m_aTextSeparator));
344 _rControlList.push_back(new OSaveValueWrapper<ComboBox>(&m_aDecimalSeparator));
345 _rControlList.push_back(new OSaveValueWrapper<ComboBox>(&m_aThousandsSeparator));
346 _rControlList.push_back(new OSaveValueWrapper<CheckBox>(&m_aRowHeader));
347 _rControlList.push_back(new OSaveValueWrapper<ListBox>(&m_aCharSet));
349 // -----------------------------------------------------------------------
350 void OTextConnectionHelper::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
352 _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFieldSeparatorLabel));
353 _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aTextSeparatorLabel));
354 _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aDecimalSeparatorLabel));
355 _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aThousandsSeparatorLabel));
356 _rControlList.push_back(new ODisableWrapper<FixedLine>(&m_aCharSetHeader));
357 _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aCharSetLabel));
358 _rControlList.push_back(new ODisableWrapper<ListBox>(&m_aCharSet));
361 // -----------------------------------------------------------------------
362 void OTextConnectionHelper::implInitControls(const SfxItemSet& _rSet, sal_Bool _bValid)
364 if ( !_bValid )
365 return;
367 SFX_ITEMSET_GET( _rSet, pDelItem, SfxStringItem, DSID_FIELDDELIMITER, sal_True );
368 SFX_ITEMSET_GET( _rSet, pStrItem, SfxStringItem, DSID_TEXTDELIMITER, sal_True );
369 SFX_ITEMSET_GET( _rSet, pDecdelItem, SfxStringItem, DSID_DECIMALDELIMITER, sal_True );
370 SFX_ITEMSET_GET( _rSet, pThodelItem, SfxStringItem, DSID_THOUSANDSDELIMITER, sal_True );
371 SFX_ITEMSET_GET( _rSet, pExtensionItem, SfxStringItem, DSID_TEXTFILEEXTENSION, sal_True );
372 SFX_ITEMSET_GET( _rSet, pCharsetItem, SfxStringItem, DSID_CHARSET, sal_True );
374 if ( ( m_nAvailableSections & TC_EXTENSION ) != 0 )
376 m_aOldExtension = pExtensionItem->GetValue();
377 SetExtension( m_aOldExtension );
380 if ( ( m_nAvailableSections & TC_HEADER ) != 0 )
382 SFX_ITEMSET_GET( _rSet, pHdrItem, SfxBoolItem, DSID_TEXTFILEHEADER, sal_True );
383 m_aRowHeader.Check( pHdrItem->GetValue() );
386 if ( ( m_nAvailableSections & TC_SEPARATORS ) != 0 )
388 SetSeparator( m_aFieldSeparator, m_aFieldSeparatorList, pDelItem->GetValue() );
389 SetSeparator( m_aTextSeparator, m_aTextSeparatorList, pStrItem->GetValue() );
390 m_aDecimalSeparator.SetText( pDecdelItem->GetValue() );
391 m_aThousandsSeparator.SetText( pThodelItem->GetValue() );
394 if ( ( m_nAvailableSections & TC_CHARSET ) != 0 )
396 m_aCharSet.SelectEntryByIanaName( pCharsetItem->GetValue() );
402 // -----------------------------------------------------------------------
403 sal_Bool OTextConnectionHelper::prepareLeave()
405 LocalResourceAccess aStringResAccess(PAGE_TEXT, RSC_TABPAGE);
406 // for accessing the strings which are local to our own resource block
407 String sExtension = GetExtension();
408 String aErrorText;
409 Control* pErrorWin = NULL;
410 // if (!m_aFieldSeparator.GetText().Len())
411 // bug (#42168) if this line is compiled under OS2 (in a product environent)
412 // -> use a temporary variable
413 String aDelText(m_aFieldSeparator.GetText());
414 if(!aDelText.Len())
415 { // Kein FeldTrenner
416 aErrorText = String(ModuleRes(STR_AUTODELIMITER_MISSING));
417 aErrorText.SearchAndReplaceAscii("#1",m_aFieldSeparatorLabel.GetText());
418 pErrorWin = &m_aFieldSeparator;
420 else if (!m_aDecimalSeparator.GetText().Len())
421 { // kein Decimaltrenner
422 aErrorText = String(ModuleRes(STR_AUTODELIMITER_MISSING));
423 aErrorText.SearchAndReplaceAscii("#1",m_aDecimalSeparatorLabel.GetText());
424 pErrorWin = &m_aDecimalSeparator;
426 else if (m_aTextSeparator.GetText() == m_aFieldSeparator.GetText())
427 { // Feld und TextTrenner duerfen nicht gleich sein
428 aErrorText = String(ModuleRes(STR_AUTODELIMITER_MUST_DIFFER));
429 aErrorText.SearchAndReplaceAscii("#1",m_aTextSeparatorLabel.GetText());
430 aErrorText.SearchAndReplaceAscii("#2",m_aFieldSeparatorLabel.GetText());
431 pErrorWin = &m_aTextSeparator;
433 else if (m_aDecimalSeparator.GetText() == m_aThousandsSeparator.GetText())
434 { // Tausender und DecimalTrenner duerfen nicht gleich sein
435 aErrorText = String(ModuleRes(STR_AUTODELIMITER_MUST_DIFFER));
436 aErrorText.SearchAndReplaceAscii("#1",m_aDecimalSeparatorLabel.GetText());
437 aErrorText.SearchAndReplaceAscii("#2",m_aThousandsSeparatorLabel.GetText());
438 pErrorWin = &m_aDecimalSeparator;
440 else if (m_aFieldSeparator.GetText() == m_aThousandsSeparator.GetText())
441 { // Tausender 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_aThousandsSeparatorLabel.GetText());
445 pErrorWin = &m_aFieldSeparator;
447 else if (m_aFieldSeparator.GetText() == m_aDecimalSeparator.GetText())
448 { // Zehner und FeldTrenner duerfen nicht gleich sein
449 aErrorText = String(ModuleRes(STR_AUTODELIMITER_MUST_DIFFER));
450 aErrorText.SearchAndReplaceAscii("#1",m_aFieldSeparatorLabel.GetText());
451 aErrorText.SearchAndReplaceAscii("#2",m_aDecimalSeparatorLabel.GetText());
452 pErrorWin = &m_aFieldSeparator;
454 else if (m_aTextSeparator.GetText() == m_aThousandsSeparator.GetText())
455 { // Tausender 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_aThousandsSeparatorLabel.GetText());
459 pErrorWin = &m_aTextSeparator;
461 else if (m_aTextSeparator.GetText() == m_aDecimalSeparator.GetText())
462 { // Zehner und TextTrenner duerfen nicht gleich sein
463 aErrorText = String(ModuleRes(STR_AUTODELIMITER_MUST_DIFFER));
464 aErrorText.SearchAndReplaceAscii("#1",m_aTextSeparatorLabel.GetText());
465 aErrorText.SearchAndReplaceAscii("#2",m_aDecimalSeparatorLabel.GetText());
466 pErrorWin = &m_aTextSeparator;
468 else if ((sExtension.Search('*') != STRING_NOTFOUND) || (sExtension.Search('?') != STRING_NOTFOUND))
470 aErrorText = String(ModuleRes(STR_AUTONO_WILDCARDS));
471 aErrorText.SearchAndReplaceAscii("#1",sExtension);
472 pErrorWin = &m_aETOwnExtension;
474 else
475 return sal_True;
476 ErrorBox(NULL, WB_OK, MnemonicGenerator::EraseAllMnemonicChars( aErrorText)).Execute();
477 pErrorWin->GrabFocus();
478 return 0;
482 // -----------------------------------------------------------------------
483 sal_Bool OTextConnectionHelper::FillItemSet( SfxItemSet& rSet, const sal_Bool _bChangedSomething )
485 sal_Bool bChangedSomething = _bChangedSomething;
487 if ( ( m_nAvailableSections & TC_EXTENSION ) != 0 )
489 String sExtension = GetExtension();
490 if( !m_aOldExtension.Equals( sExtension ) )
492 rSet.Put( SfxStringItem( DSID_TEXTFILEEXTENSION, sExtension ) );
493 bChangedSomething = sal_True;
497 if ( ( m_nAvailableSections & TC_HEADER ) != 0 )
499 if( (m_aRowHeader.GetState() != m_aRowHeader.GetSavedValue()) )
501 rSet.Put(SfxBoolItem(DSID_TEXTFILEHEADER, m_aRowHeader.IsChecked()));
502 bChangedSomething = sal_True;
506 if ( ( m_nAvailableSections & TC_SEPARATORS ) != 0 )
508 if( m_aFieldSeparator.GetText() != m_aFieldSeparator.GetSavedValue() )
510 rSet.Put( SfxStringItem(DSID_FIELDDELIMITER, GetSeparator( m_aFieldSeparator, m_aFieldSeparatorList) ) );
511 bChangedSomething = sal_True;
513 if( m_aTextSeparator.GetText() != m_aTextSeparator.GetSavedValue() )
515 rSet.Put( SfxStringItem(DSID_TEXTDELIMITER, GetSeparator( m_aTextSeparator, m_aTextSeparatorList) ) );
516 bChangedSomething = sal_True;
519 if( m_aDecimalSeparator.GetText() != m_aDecimalSeparator.GetSavedValue() )
521 rSet.Put( SfxStringItem(DSID_DECIMALDELIMITER, m_aDecimalSeparator.GetText().Copy(0, 1) ) );
522 bChangedSomething = sal_True;
524 if( m_aThousandsSeparator.GetText() != m_aThousandsSeparator.GetSavedValue() )
526 rSet.Put( SfxStringItem(DSID_THOUSANDSDELIMITER, m_aThousandsSeparator.GetText().Copy(0,1) ) );
527 bChangedSomething = sal_True;
531 if ( ( m_nAvailableSections & TC_CHARSET ) != 0 )
533 if ( m_aCharSet.StoreSelectedCharSet( rSet, DSID_CHARSET ) )
534 bChangedSomething = sal_True;
537 return bChangedSomething;
541 void OTextConnectionHelper::SetExtension(const String& _rVal)
543 if (_rVal.EqualsAscii("txt"))
544 m_aRBAccessTextFiles.Check(sal_True);
545 else if (_rVal.EqualsAscii( "csv" ))
546 m_aRBAccessCSVFiles.Check(sal_True);
547 else
549 m_aRBAccessOtherFiles.Check(sal_True);
550 m_aFTExtensionExample.SetText(_rVal);
555 String OTextConnectionHelper::GetExtension()
557 String sExtension;
558 if (m_aRBAccessTextFiles.IsChecked())
559 sExtension = String::CreateFromAscii("txt");
560 else if (m_aRBAccessCSVFiles.IsChecked())
561 sExtension = String::CreateFromAscii("csv");
562 else
564 sExtension = m_aETOwnExtension.GetText();
565 if ( sExtension.GetToken(0,'.').Equals('*') )
566 sExtension.Erase(0,2);
568 return sExtension;
572 //------------------------------------------------------------------------
573 String OTextConnectionHelper::GetSeparator( const ComboBox& rBox, const String& rList )
575 sal_Unicode nTok = '\t';
576 xub_StrLen nPos(rBox.GetEntryPos( rBox.GetText() ));
578 if( nPos == COMBOBOX_ENTRY_NOTFOUND )
579 return rBox.GetText().Copy(0);
581 if ( !( &m_aTextSeparator == &rBox && nPos == (rBox.GetEntryCount()-1) ) )
582 return String(
583 static_cast< sal_Unicode >(
584 rList.GetToken(((nPos*2)+1), nTok ).ToInt32()));
585 // somewhat strange ... translates for instance an "32" into " "
586 return String();
589 //------------------------------------------------------------------------
590 void OTextConnectionHelper::SetSeparator( ComboBox& rBox, const String& rList, const String& rVal )
592 char nTok = '\t';
593 xub_StrLen nCnt(rList.GetTokenCount( nTok ));
594 xub_StrLen i;
596 for( i=0 ; i<nCnt ; i+=2 )
598 String sTVal(
599 static_cast< sal_Unicode >(
600 rList.GetToken( (i+1), nTok ).ToInt32()));
602 if( sTVal == rVal )
604 rBox.SetText( rList.GetToken( i, nTok ) );
605 break;
609 if ( i >= nCnt )
611 if ( &m_aTextSeparator == &rBox && !rVal.Len() )
612 rBox.SetText(m_aTextNone);
613 else
614 rBox.SetText( rVal.Copy(0, 1) );
618 //.........................................................................
619 } // namespace dbaui
620 //.........................................................................