LCOV - code coverage report
Current view: top level - dbaccess/source/ui/dlg - TextConnectionHelper.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 232 0.0 %
Date: 2014-04-14 Functions: 0 20 0.0 %
Legend: Lines: hit not hit

          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 <config_features.h>
      21             : 
      22             : #include "moduledbu.hxx"
      23             : #include "TextConnectionHelper.hxx"
      24             : #include "sqlmessage.hxx"
      25             : #include "dbu_dlg.hrc"
      26             : #include "dbu_resource.hrc"
      27             : #include "AutoControls.hrc"
      28             : #include <svl/itemset.hxx>
      29             : #include <svl/stritem.hxx>
      30             : #include <svl/eitem.hxx>
      31             : #include <svl/intitem.hxx>
      32             : #include "dsitems.hxx"
      33             : #include "dbfindex.hxx"
      34             : #include "dbaccess_helpid.hrc"
      35             : #include "localresaccess.hxx"
      36             : #include <vcl/msgbox.hxx>
      37             : #include <vcl/mnemonic.hxx>
      38             : #include <svl/cjkoptions.hxx>
      39             : #if HAVE_FEATURE_JAVA
      40             : #include <jvmaccess/virtualmachine.hxx>
      41             : #endif
      42             : #include <connectivity/CommonTools.hxx>
      43             : #include "DriverSettings.hxx"
      44             : #include "dbadmin.hxx"
      45             : #include <comphelper/string.hxx>
      46             : #include <comphelper/types.hxx>
      47             : #include <com/sun/star/task/XInteractionHandler.hpp>
      48             : #include <svl/filenotation.hxx>
      49             : #include <unotools/localfilehelper.hxx>
      50             : #include <unotools/ucbhelper.hxx>
      51             : #include <ucbhelper/commandenvironment.hxx>
      52             : #include "finteraction.hxx"
      53             : #include "DBSetupConnectionPages.hxx"
      54             : #include <unotools/pathoptions.hxx>
      55             : #include <svtools/roadmapwizard.hxx>
      56             : 
      57             : namespace dbaui
      58             : {
      59             : 
      60           0 :     OTextConnectionHelper::OTextConnectionHelper( Window* pParent, const short _nAvailableSections )
      61             :         :Control( pParent, WB_DIALOGCONTROL )
      62             :         ,m_aFTExtensionHeader       (this, ModuleRes(FT_AUTOEXTENSIONHEADER))
      63             :         ,m_aRBAccessTextFiles       (this, ModuleRes(RB_AUTOACCESSCTEXTFILES))
      64             :         ,m_aRBAccessCSVFiles        (this, ModuleRes(RB_AUTOACCESSCCSVFILES))
      65             :         ,m_aRBAccessOtherFiles      (this, ModuleRes(RB_AUTOACCESSOTHERS))
      66             :         ,m_aETOwnExtension          (this, ModuleRes(ET_AUTOOWNEXTENSION))
      67             :         ,m_aFTExtensionExample      (this, ModuleRes(FT_AUTOOWNEXTENSIONAPPENDIX))
      68             :         ,m_aLineFormat              (this, ModuleRes(FL_AUTOSEPARATOR2))
      69             :         ,m_aFieldSeparatorLabel     (this, ModuleRes(FT_AUTOFIELDSEPARATOR))
      70             :         ,m_aFieldSeparator          (this, ModuleRes(CM_AUTOFIELDSEPARATOR))
      71             :         ,m_aTextSeparatorLabel      (this, ModuleRes(FT_AUTOTEXTSEPARATOR))
      72             :         ,m_aTextSeparator           (this, ModuleRes(CM_AUTOTEXTSEPARATOR))
      73             :         ,m_aDecimalSeparatorLabel   (this, ModuleRes(FT_AUTODECIMALSEPARATOR))
      74             :         ,m_aDecimalSeparator        (this, ModuleRes(CM_AUTODECIMALSEPARATOR))
      75             :         ,m_aThousandsSeparatorLabel (this, ModuleRes(FT_AUTOTHOUSANDSSEPARATOR))
      76             :         ,m_aThousandsSeparator      (this, ModuleRes(CM_AUTOTHOUSANDSSEPARATOR))
      77             :         ,m_aRowHeader               (this, ModuleRes(CB_AUTOHEADER))
      78             :         ,m_aCharSetHeader           (this, ModuleRes(FL_DATACONVERT))
      79             :         ,m_aCharSetLabel            (this, ModuleRes(FT_CHARSET))
      80             :         ,m_aCharSet                 (this, ModuleRes(LB_CHARSET))
      81             :         ,m_aFieldSeparatorList      (ModuleRes(STR_AUTOFIELDSEPARATORLIST))
      82             :         ,m_aTextSeparatorList       (ModuleRes(STR_AUTOTEXTSEPARATORLIST))
      83             :         ,m_aTextNone                (ModuleRes(STR_AUTOTEXT_FIELD_SEP_NONE))
      84           0 :         ,m_nAvailableSections( _nAvailableSections )
      85             :     {
      86             : 
      87           0 :         sal_Int32 nCnt = comphelper::string::getTokenCount(m_aFieldSeparatorList, '\t');
      88             :         sal_Int32 i;
      89             : 
      90           0 :         for( i = 0 ; i < nCnt ; i += 2 )
      91           0 :             m_aFieldSeparator.InsertEntry( m_aFieldSeparatorList.getToken( i, '\t' ) );
      92             : 
      93           0 :         nCnt = comphelper::string::getTokenCount(m_aTextSeparatorList, '\t');
      94           0 :         for( i=0 ; i<nCnt ; i+=2 )
      95           0 :             m_aTextSeparator.InsertEntry( m_aTextSeparatorList.getToken( i, '\t' ) );
      96           0 :         m_aTextSeparator.InsertEntry(m_aTextNone);
      97             : 
      98             :         // set the modify handlers
      99           0 :         m_aFieldSeparator.SetUpdateDataHdl(getControlModifiedLink());
     100           0 :         m_aFieldSeparator.SetSelectHdl(getControlModifiedLink());
     101           0 :         m_aTextSeparator.SetUpdateDataHdl(getControlModifiedLink());
     102           0 :         m_aTextSeparator.SetSelectHdl(getControlModifiedLink());
     103           0 :         m_aCharSet.SetSelectHdl(getControlModifiedLink());
     104             : 
     105           0 :         m_aFieldSeparator.SetModifyHdl(getControlModifiedLink());
     106           0 :         m_aTextSeparator.SetModifyHdl(getControlModifiedLink());
     107           0 :         m_aDecimalSeparator.SetModifyHdl(getControlModifiedLink());
     108           0 :         m_aThousandsSeparator.SetModifyHdl(getControlModifiedLink());
     109           0 :         m_aETOwnExtension.SetModifyHdl(LINK(this, OTextConnectionHelper, OnEditModified));
     110           0 :            m_aRBAccessTextFiles.SetToggleHdl(LINK(this, OTextConnectionHelper, OnSetExtensionHdl));
     111           0 :            m_aRBAccessCSVFiles.SetToggleHdl(LINK(this, OTextConnectionHelper, OnSetExtensionHdl));
     112           0 :         m_aRBAccessOtherFiles.SetToggleHdl(LINK(this, OTextConnectionHelper, OnSetExtensionHdl));
     113           0 :         m_aRBAccessCSVFiles.Check(true);
     114             : 
     115             :         struct SectionDescriptor
     116             :         {
     117             :             short   nFlag;
     118             :             Window* pFirstControl;
     119             :         } aSections[] = {
     120             :             { TC_EXTENSION,     &m_aFTExtensionHeader },
     121             :             { TC_SEPARATORS,    &m_aLineFormat },
     122             :             { TC_HEADER,        &m_aRowHeader },
     123             :             { TC_CHARSET,       &m_aCharSetHeader },
     124             :             { 0, NULL }
     125           0 :         };
     126             : 
     127           0 :         for ( size_t section=0; section < sizeof( aSections ) / sizeof( aSections[0] ) - 1; ++section )
     128             :         {
     129           0 :             if ( ( m_nAvailableSections & aSections[section].nFlag ) != 0 )
     130             :             {
     131             :                 // the section is visible, no need to do anything here
     132           0 :                 continue;
     133             :             }
     134             : 
     135           0 :             Window* pThisSection = aSections[section].pFirstControl;
     136           0 :             Window* pNextSection = aSections[section+1].pFirstControl;
     137             : 
     138             :             // hide all elements from this section
     139           0 :             Window* pControl = pThisSection;
     140           0 :             while ( ( pControl != pNextSection ) && pControl )
     141             :             {
     142           0 :                 Window* pRealWindow = pControl->GetWindow( WINDOW_CLIENT );
     143             :             #if OSL_DEBUG_LEVEL > 0
     144             :                 OUString sWindowText( pRealWindow->GetText() );
     145             :                 (void)sWindowText;
     146             :             #endif
     147           0 :                 pRealWindow->Hide();
     148           0 :                 pControl = pControl->GetWindow( WINDOW_NEXT );
     149             :             }
     150             : 
     151             :             // move all controls in following sections up
     152           0 :             if ( !pNextSection )
     153           0 :                 continue;
     154           0 :             const long nThisSectionStart = pThisSection->GetPosPixel().Y();
     155           0 :             const long nNextSectionStart = pNextSection->GetPosPixel().Y();
     156           0 :             const long nMoveOffset( nThisSectionStart - nNextSectionStart );
     157           0 :             while ( pControl )
     158             :             {
     159           0 :                 Point aPos = pControl->GetPosPixel();
     160           0 :                 aPos.Move( 0, nMoveOffset );
     161           0 :                 pControl->SetPosPixel( aPos );
     162           0 :                 pControl = pControl->GetWindow( WINDOW_NEXT );
     163             :             }
     164             :         }
     165             : 
     166           0 :         Rectangle aControlRectUnion;
     167           0 :         for (   Window* pControl = aSections[0].pFirstControl;
     168             :                 pControl != NULL;
     169             :                 pControl = pControl->GetWindow( WINDOW_NEXT )
     170             :             )
     171             :         {
     172           0 :             aControlRectUnion = aControlRectUnion.Union( Rectangle( pControl->GetPosPixel(), pControl->GetSizePixel() ) );
     173             :         }
     174             : 
     175             :         // need some adjustments to the positions, since the resource-specified
     176             :         // positions for the control were relative to *our* parent, while by now
     177             :         // the controls have |this| as parent.
     178             : 
     179             :         // first, move ourself to the upper left of the area occupied by all controls
     180           0 :         SetPosPixel( aControlRectUnion.TopLeft() );
     181             : 
     182             :         // then, compensate in the control positions, by moving them the up/left
     183           0 :         for (   Window* pControl = aSections[0].pFirstControl;
     184             :                 pControl != NULL;
     185             :                 pControl = pControl->GetWindow( WINDOW_NEXT )
     186             :             )
     187             :         {
     188           0 :             Point aPos( pControl->GetPosPixel() );
     189           0 :             aPos.Move( -aControlRectUnion.Left(), -aControlRectUnion.Top() );
     190           0 :             pControl->SetPosPixel( aPos );
     191             : 
     192             :             // while we are here ... the controls should not have an own background
     193             :             // (this would not be needed when our outer dialog were also the parent
     194             :             // of the controls)
     195           0 :             pControl->SetBackground();
     196             :         }
     197             : 
     198             :         // now, change our own size so all controls fit
     199           0 :         SetSizePixel( aControlRectUnion.GetSize() );
     200             : 
     201           0 :         SetBackground();
     202           0 :         Show();
     203           0 :     }
     204             : 
     205           0 :     OTextConnectionHelper::~OTextConnectionHelper()
     206             :     {
     207             : 
     208           0 :     }
     209             : 
     210           0 :     IMPL_LINK(OTextConnectionHelper, OnControlModified, Control*, /*EMPTYARG*/)
     211             :     {
     212           0 :         callModifiedHdl();
     213           0 :         return 0L;
     214             :     }
     215             : 
     216           0 :     IMPL_LINK(OTextConnectionHelper, OnEditModified, Edit*, /*_pEdit*/)
     217             :     {
     218           0 :         m_aGetExtensionHandler.Call(this);
     219           0 :         return 0L;
     220             :     }
     221             : 
     222           0 :     IMPL_LINK(OTextConnectionHelper, OnSetExtensionHdl, RadioButton*, /*_pRadioButton*/)
     223             :     {
     224           0 :         sal_Bool bDoEnable = m_aRBAccessOtherFiles.IsChecked();
     225           0 :         m_aETOwnExtension.Enable(bDoEnable);
     226           0 :         m_aFTExtensionExample.Enable(bDoEnable);
     227           0 :         m_aGetExtensionHandler.Call(this);
     228           0 :         return 0L;
     229             :     }
     230             : 
     231           0 :     void OTextConnectionHelper::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
     232             :     {
     233           0 :         _rControlList.push_back(new OSaveValueWrapper<ComboBox>(&m_aFieldSeparator));
     234           0 :         _rControlList.push_back(new OSaveValueWrapper<ComboBox>(&m_aTextSeparator));
     235           0 :         _rControlList.push_back(new OSaveValueWrapper<ComboBox>(&m_aDecimalSeparator));
     236           0 :         _rControlList.push_back(new OSaveValueWrapper<ComboBox>(&m_aThousandsSeparator));
     237           0 :         _rControlList.push_back(new OSaveValueWrapper<CheckBox>(&m_aRowHeader));
     238           0 :         _rControlList.push_back(new OSaveValueWrapper<ListBox>(&m_aCharSet));
     239           0 :     }
     240             : 
     241           0 :     void OTextConnectionHelper::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
     242             :     {
     243           0 :         _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFieldSeparatorLabel));
     244           0 :         _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aTextSeparatorLabel));
     245           0 :         _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aDecimalSeparatorLabel));
     246           0 :         _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aThousandsSeparatorLabel));
     247           0 :         _rControlList.push_back(new ODisableWrapper<FixedLine>(&m_aCharSetHeader));
     248           0 :         _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aCharSetLabel));
     249           0 :         _rControlList.push_back(new ODisableWrapper<ListBox>(&m_aCharSet));
     250           0 :     }
     251             : 
     252           0 :     void OTextConnectionHelper::implInitControls(const SfxItemSet& _rSet, sal_Bool _bValid)
     253             :     {
     254           0 :         if ( !_bValid )
     255           0 :             return;
     256             : 
     257           0 :         SFX_ITEMSET_GET( _rSet, pDelItem, SfxStringItem, DSID_FIELDDELIMITER, true );
     258           0 :         SFX_ITEMSET_GET( _rSet, pStrItem, SfxStringItem, DSID_TEXTDELIMITER, true );
     259           0 :         SFX_ITEMSET_GET( _rSet, pDecdelItem, SfxStringItem, DSID_DECIMALDELIMITER, true );
     260           0 :         SFX_ITEMSET_GET( _rSet, pThodelItem, SfxStringItem, DSID_THOUSANDSDELIMITER, true );
     261           0 :         SFX_ITEMSET_GET( _rSet, pExtensionItem, SfxStringItem, DSID_TEXTFILEEXTENSION, true );
     262           0 :         SFX_ITEMSET_GET( _rSet, pCharsetItem, SfxStringItem, DSID_CHARSET, true );
     263             : 
     264           0 :         if ( ( m_nAvailableSections & TC_EXTENSION ) != 0 )
     265             :         {
     266           0 :             m_aOldExtension = pExtensionItem->GetValue();
     267           0 :             SetExtension( m_aOldExtension );
     268             :         }
     269             : 
     270           0 :         if ( ( m_nAvailableSections & TC_HEADER ) != 0 )
     271             :         {
     272           0 :             SFX_ITEMSET_GET( _rSet, pHdrItem, SfxBoolItem, DSID_TEXTFILEHEADER, true );
     273           0 :             m_aRowHeader.Check( pHdrItem->GetValue() );
     274             :         }
     275             : 
     276           0 :         if ( ( m_nAvailableSections & TC_SEPARATORS ) != 0 )
     277             :         {
     278           0 :             SetSeparator( m_aFieldSeparator, m_aFieldSeparatorList, pDelItem->GetValue() );
     279           0 :             SetSeparator( m_aTextSeparator, m_aTextSeparatorList, pStrItem->GetValue() );
     280           0 :             m_aDecimalSeparator.SetText( pDecdelItem->GetValue() );
     281           0 :             m_aThousandsSeparator.SetText( pThodelItem->GetValue() );
     282             :         }
     283             : 
     284           0 :         if ( ( m_nAvailableSections & TC_CHARSET ) != 0 )
     285             :         {
     286           0 :             m_aCharSet.SelectEntryByIanaName( pCharsetItem->GetValue() );
     287             :         }
     288             :     }
     289             : 
     290           0 :     sal_Bool OTextConnectionHelper::prepareLeave()
     291             :     {
     292           0 :         LocalResourceAccess aStringResAccess(PAGE_TEXT, RSC_TABPAGE);
     293             :             // for accessing the strings which are local to our own resource block
     294           0 :         OUString sExtension = GetExtension();
     295           0 :         OUString aErrorText;
     296           0 :         Control* pErrorWin = NULL;
     297           0 :         OUString aDelText(m_aFieldSeparator.GetText());
     298           0 :         if(aDelText.isEmpty())
     299             :         {   // No FieldSeparator
     300           0 :             aErrorText = ModuleRes(STR_AUTODELIMITER_MISSING);
     301           0 :             aErrorText = aErrorText.replaceFirst("#1",m_aFieldSeparatorLabel.GetText());
     302           0 :             pErrorWin = &m_aFieldSeparator;
     303             :         }
     304           0 :         else if (m_aDecimalSeparator.GetText().isEmpty())
     305             :         {   // No DecimalSeparator
     306           0 :             aErrorText = ModuleRes(STR_AUTODELIMITER_MISSING);
     307           0 :             aErrorText = aErrorText.replaceFirst("#1",m_aDecimalSeparatorLabel.GetText());
     308           0 :             pErrorWin = &m_aDecimalSeparator;
     309             :         }
     310           0 :         else if (m_aTextSeparator.GetText() == m_aFieldSeparator.GetText())
     311             :         {   // Field and TextSeparator must not be the same
     312           0 :             aErrorText = ModuleRes(STR_AUTODELIMITER_MUST_DIFFER);
     313           0 :             aErrorText = aErrorText.replaceFirst("#1",m_aTextSeparatorLabel.GetText());
     314           0 :             aErrorText = aErrorText.replaceFirst("#2",m_aFieldSeparatorLabel.GetText());
     315           0 :             pErrorWin = &m_aTextSeparator;
     316             :         }
     317           0 :         else if (m_aDecimalSeparator.GetText() == m_aThousandsSeparator.GetText())
     318             :         {   // Thousands and DecimalSeparator must not be the same
     319           0 :             aErrorText = ModuleRes(STR_AUTODELIMITER_MUST_DIFFER);
     320           0 :             aErrorText = aErrorText.replaceFirst("#1",m_aDecimalSeparatorLabel.GetText());
     321           0 :             aErrorText = aErrorText.replaceFirst("#2",m_aThousandsSeparatorLabel.GetText());
     322           0 :             pErrorWin = &m_aDecimalSeparator;
     323             :         }
     324           0 :         else if (m_aFieldSeparator.GetText() == m_aThousandsSeparator.GetText())
     325             :         {   // Thousands and FieldSeparator must not be the same
     326           0 :             aErrorText = ModuleRes(STR_AUTODELIMITER_MUST_DIFFER);
     327           0 :             aErrorText = aErrorText.replaceFirst("#1",m_aFieldSeparatorLabel.GetText());
     328           0 :             aErrorText = aErrorText.replaceFirst("#2",m_aThousandsSeparatorLabel.GetText());
     329           0 :             pErrorWin = &m_aFieldSeparator;
     330             :         }
     331           0 :         else if (m_aFieldSeparator.GetText() == m_aDecimalSeparator.GetText())
     332             :         {   // Tenner and FieldSeparator must not be the same
     333           0 :             aErrorText = ModuleRes(STR_AUTODELIMITER_MUST_DIFFER);
     334           0 :             aErrorText = aErrorText.replaceFirst("#1",m_aFieldSeparatorLabel.GetText());
     335           0 :             aErrorText = aErrorText.replaceFirst("#2",m_aDecimalSeparatorLabel.GetText());
     336           0 :             pErrorWin = &m_aFieldSeparator;
     337             :         }
     338           0 :         else if (m_aTextSeparator.GetText() == m_aThousandsSeparator.GetText())
     339             :         {   // Thousands and TextSeparator must not be the same
     340           0 :             aErrorText = ModuleRes(STR_AUTODELIMITER_MUST_DIFFER);
     341           0 :             aErrorText = aErrorText.replaceFirst("#1",m_aTextSeparatorLabel.GetText());
     342           0 :             aErrorText = aErrorText.replaceFirst("#2",m_aThousandsSeparatorLabel.GetText());
     343           0 :             pErrorWin = &m_aTextSeparator;
     344             :         }
     345           0 :         else if (m_aTextSeparator.GetText() == m_aDecimalSeparator.GetText())
     346             :         {   // Tenner and TextSeparator must not be the same
     347           0 :             aErrorText = ModuleRes(STR_AUTODELIMITER_MUST_DIFFER);
     348           0 :             aErrorText = aErrorText.replaceFirst("#1",m_aTextSeparatorLabel.GetText());
     349           0 :             aErrorText = aErrorText.replaceFirst("#2",m_aDecimalSeparatorLabel.GetText());
     350           0 :             pErrorWin = &m_aTextSeparator;
     351             :         }
     352           0 :         else if ((sExtension.indexOf('*') != -1) || (sExtension.indexOf('?') != -1))
     353             :         {
     354           0 :             aErrorText = ModuleRes(STR_AUTONO_WILDCARDS);
     355           0 :             aErrorText = aErrorText.replaceFirst("#1",sExtension);
     356           0 :             pErrorWin = &m_aETOwnExtension;
     357             :         }
     358             :         else
     359           0 :             return sal_True;
     360           0 :         ErrorBox(NULL, WB_OK, MnemonicGenerator::EraseAllMnemonicChars( aErrorText)).Execute();
     361           0 :         pErrorWin->GrabFocus();
     362           0 :         return 0;
     363             :     }
     364             : 
     365           0 :     sal_Bool OTextConnectionHelper::FillItemSet( SfxItemSet& rSet, const sal_Bool _bChangedSomething )
     366             :     {
     367           0 :         sal_Bool bChangedSomething = _bChangedSomething;
     368             : 
     369           0 :         if ( ( m_nAvailableSections & TC_EXTENSION ) != 0 )
     370             :         {
     371           0 :             OUString sExtension = GetExtension();
     372           0 :             if( m_aOldExtension != sExtension )
     373             :             {
     374           0 :                 rSet.Put( SfxStringItem( DSID_TEXTFILEEXTENSION, sExtension ) );
     375           0 :                 bChangedSomething = sal_True;
     376           0 :             }
     377             :         }
     378             : 
     379           0 :         if ( ( m_nAvailableSections & TC_HEADER ) != 0 )
     380             :         {
     381           0 :             if( (m_aRowHeader.GetState() != m_aRowHeader.GetSavedValue()) )
     382             :             {
     383           0 :                 rSet.Put(SfxBoolItem(DSID_TEXTFILEHEADER, m_aRowHeader.IsChecked()));
     384           0 :                 bChangedSomething = sal_True;
     385             :             }
     386             :         }
     387             : 
     388           0 :         if ( ( m_nAvailableSections & TC_SEPARATORS ) != 0 )
     389             :         {
     390           0 :             if( m_aFieldSeparator.GetText() != m_aFieldSeparator.GetSavedValue() )
     391             :             {
     392           0 :                 rSet.Put( SfxStringItem(DSID_FIELDDELIMITER, GetSeparator( m_aFieldSeparator, m_aFieldSeparatorList) ) );
     393           0 :                 bChangedSomething = sal_True;
     394             :             }
     395           0 :             if( m_aTextSeparator.GetText() != m_aTextSeparator.GetSavedValue() )
     396             :             {
     397           0 :                 rSet.Put( SfxStringItem(DSID_TEXTDELIMITER, GetSeparator( m_aTextSeparator, m_aTextSeparatorList) ) );
     398           0 :                 bChangedSomething = sal_True;
     399             :             }
     400             : 
     401           0 :             if( m_aDecimalSeparator.GetText() != m_aDecimalSeparator.GetSavedValue() )
     402             :             {
     403           0 :                 rSet.Put( SfxStringItem(DSID_DECIMALDELIMITER, m_aDecimalSeparator.GetText().copy(0, 1) ) );
     404           0 :                 bChangedSomething = sal_True;
     405             :             }
     406           0 :             if( m_aThousandsSeparator.GetText() != m_aThousandsSeparator.GetSavedValue() )
     407             :             {
     408           0 :                 rSet.Put( SfxStringItem(DSID_THOUSANDSDELIMITER, m_aThousandsSeparator.GetText().copy(0,1) ) );
     409           0 :                 bChangedSomething = sal_True;
     410             :             }
     411             :         }
     412             : 
     413           0 :         if ( ( m_nAvailableSections & TC_CHARSET ) != 0 )
     414             :         {
     415           0 :             if ( m_aCharSet.StoreSelectedCharSet( rSet, DSID_CHARSET ) )
     416           0 :                 bChangedSomething = sal_True;
     417             :         }
     418             : 
     419           0 :         return bChangedSomething;
     420             :     }
     421             : 
     422           0 :     void OTextConnectionHelper::SetExtension(const OUString& _rVal)
     423             :     {
     424           0 :         if (_rVal == "txt")
     425           0 :             m_aRBAccessTextFiles.Check(true);
     426           0 :         else if (_rVal == "csv")
     427           0 :             m_aRBAccessCSVFiles.Check(true);
     428             :         else
     429             :         {
     430           0 :             m_aRBAccessOtherFiles.Check(true);
     431           0 :             m_aFTExtensionExample.SetText(_rVal);
     432             :         }
     433           0 :     }
     434             : 
     435           0 :     OUString OTextConnectionHelper::GetExtension()
     436             :     {
     437           0 :         OUString sExtension;
     438           0 :         if (m_aRBAccessTextFiles.IsChecked())
     439           0 :             sExtension = "txt";
     440           0 :         else if (m_aRBAccessCSVFiles.IsChecked())
     441           0 :             sExtension = "csv";
     442             :         else
     443             :         {
     444           0 :             sExtension = m_aETOwnExtension.GetText();
     445           0 :             if ( comphelper::string::equals(sExtension.getToken(0,'.'), '*') )
     446           0 :                 sExtension = sExtension.copy(2);
     447             :         }
     448           0 :         return sExtension;
     449             :     }
     450             : 
     451           0 :     OUString OTextConnectionHelper::GetSeparator( const ComboBox& rBox, const OUString& rList )
     452             :     {
     453           0 :         sal_Unicode nTok = '\t';
     454           0 :         sal_Int32 nPos(rBox.GetEntryPos( rBox.GetText() ));
     455             : 
     456           0 :         if( nPos == COMBOBOX_ENTRY_NOTFOUND )
     457           0 :             return rBox.GetText().copy(0);
     458             : 
     459           0 :         if ( !( &m_aTextSeparator == &rBox && nPos == (rBox.GetEntryCount()-1) ) )
     460             :             return OUString(
     461           0 :                 static_cast< sal_Unicode >( rList.getToken((nPos*2)+1, nTok ).toInt32() ));
     462             :         // somewhat strange ... translates for instance an "32" into " "
     463           0 :         return OUString();
     464             :     }
     465             : 
     466           0 :     void OTextConnectionHelper::SetSeparator( ComboBox& rBox, const OUString& rList, const OUString& rVal )
     467             :     {
     468           0 :         char    nTok = '\t';
     469           0 :         sal_Int32   nCnt = comphelper::string::getTokenCount(rList, nTok);
     470             :         sal_Int32 i;
     471             : 
     472           0 :         for( i=0 ; i<nCnt ; i+=2 )
     473             :         {
     474             :             OUString  sTVal(
     475           0 :                 static_cast< sal_Unicode >( rList.getToken( (i+1), nTok ).toInt32() ));
     476             : 
     477           0 :             if( sTVal.equals(rVal) )
     478             :             {
     479           0 :                 rBox.SetText( rList.getToken( i, nTok ) );
     480           0 :                 break;
     481             :             }
     482           0 :         }
     483             : 
     484           0 :         if ( i >= nCnt )
     485             :         {
     486           0 :             if ( &m_aTextSeparator == &rBox && rVal.isEmpty() )
     487           0 :                 rBox.SetText(m_aTextNone);
     488             :             else
     489           0 :                 rBox.SetText( rVal.copy(0, 1) );
     490             :         }
     491           0 :     }
     492           0 : }
     493             : 
     494             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10