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

Generated by: LCOV version 1.10