LCOV - code coverage report
Current view: top level - dbaccess/source/ui/dlg - TextConnectionHelper.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 253 0.4 %
Date: 2015-06-13 12:38:46 Functions: 2 22 9.1 %
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 <svl/itemset.hxx>
      28             : #include <svl/stritem.hxx>
      29             : #include <svl/eitem.hxx>
      30             : #include <svl/intitem.hxx>
      31             : #include "dsitems.hxx"
      32             : #include "dbfindex.hxx"
      33             : #include "dbaccess_helpid.hrc"
      34             : #include "localresaccess.hxx"
      35             : #include <vcl/layout.hxx>
      36             : #include <vcl/mnemonic.hxx>
      37             : #include <svl/cjkoptions.hxx>
      38             : #if HAVE_FEATURE_JAVA
      39             : #include <jvmaccess/virtualmachine.hxx>
      40             : #endif
      41             : #include <connectivity/CommonTools.hxx>
      42             : #include "DriverSettings.hxx"
      43             : #include "dbadmin.hxx"
      44             : #include <comphelper/string.hxx>
      45             : #include <comphelper/types.hxx>
      46             : #include <com/sun/star/task/XInteractionHandler.hpp>
      47             : #include <svl/filenotation.hxx>
      48             : #include <unotools/localfilehelper.hxx>
      49             : #include <unotools/ucbhelper.hxx>
      50             : #include <ucbhelper/commandenvironment.hxx>
      51             : #include "finteraction.hxx"
      52             : #include "DBSetupConnectionPages.hxx"
      53             : #include <unotools/pathoptions.hxx>
      54             : #include <svtools/roadmapwizard.hxx>
      55             : 
      56             : namespace dbaui
      57             : {
      58             : 
      59           0 :     OTextConnectionHelper::OTextConnectionHelper( vcl::Window* pParent, const short _nAvailableSections )
      60             :         :TabPage(pParent, "TextPage", "dbaccess/ui/textpage.ui")
      61             :         ,m_aFieldSeparatorList      (ModuleRes(STR_AUTOFIELDSEPARATORLIST))
      62             :         ,m_aTextSeparatorList       (ModuleRes(STR_AUTOTEXTSEPARATORLIST))
      63             :         ,m_aTextNone                (ModuleRes(STR_AUTOTEXT_FIELD_SEP_NONE))
      64           0 :         ,m_nAvailableSections( _nAvailableSections )
      65             :     {
      66           0 :         get(m_pExtensionHeader, "extensionheader");
      67           0 :         get(m_pAccessTextFiles, "textfile");
      68           0 :         get(m_pAccessCSVFiles, "csvfile");
      69           0 :         get(m_pAccessOtherFiles, "custom");
      70           0 :         get(m_pOwnExtension, "extension");
      71           0 :         get(m_pExtensionExample, "example");
      72           0 :         get(m_pFormatHeader, "formatlabel");
      73           0 :         get(m_pFieldSeparatorLabel, "fieldlabel");
      74           0 :         get(m_pFieldSeparator, "fieldseparator");
      75           0 :         get(m_pTextSeparatorLabel, "textlabel");
      76           0 :         get(m_pTextSeparator, "textseparator");
      77           0 :         get(m_pDecimalSeparatorLabel, "decimallabel");
      78           0 :         get(m_pDecimalSeparator, "decimalseparator");
      79           0 :         get(m_pThousandsSeparatorLabel, "thousandslabel");
      80           0 :         get(m_pThousandsSeparator, "thousandsseparator");
      81           0 :         get(m_pRowHeader, "containsheaders");
      82           0 :         get(m_pCharSetHeader, "charsetheader");
      83           0 :         get(m_pCharSetLabel, "charsetlabel");
      84           0 :         get(m_pCharSet, "charset");
      85             : 
      86           0 :         sal_Int32 nCnt = comphelper::string::getTokenCount(m_aFieldSeparatorList, '\t');
      87             :         sal_Int32 i;
      88             : 
      89           0 :         for( i = 0 ; i < nCnt ; i += 2 )
      90           0 :             m_pFieldSeparator->InsertEntry( m_aFieldSeparatorList.getToken( i, '\t' ) );
      91             : 
      92           0 :         nCnt = comphelper::string::getTokenCount(m_aTextSeparatorList, '\t');
      93           0 :         for( i=0 ; i<nCnt ; i+=2 )
      94           0 :             m_pTextSeparator->InsertEntry( m_aTextSeparatorList.getToken( i, '\t' ) );
      95           0 :         m_pTextSeparator->InsertEntry(m_aTextNone);
      96             : 
      97             :         // set the modify handlers
      98           0 :         m_pFieldSeparator->SetUpdateDataHdl(getControlModifiedLink());
      99           0 :         m_pFieldSeparator->SetSelectHdl(getControlModifiedLink());
     100           0 :         m_pTextSeparator->SetUpdateDataHdl(getControlModifiedLink());
     101           0 :         m_pTextSeparator->SetSelectHdl(getControlModifiedLink());
     102           0 :         m_pCharSet->SetSelectHdl(getControlModifiedLink());
     103             : 
     104           0 :         m_pFieldSeparator->SetModifyHdl(getControlModifiedLink());
     105           0 :         m_pTextSeparator->SetModifyHdl(getControlModifiedLink());
     106           0 :         m_pDecimalSeparator->SetModifyHdl(getControlModifiedLink());
     107           0 :         m_pThousandsSeparator->SetModifyHdl(getControlModifiedLink());
     108           0 :         m_pOwnExtension->SetModifyHdl(LINK(this, OTextConnectionHelper, OnEditModified));
     109           0 :         m_pAccessTextFiles->SetToggleHdl(LINK(this, OTextConnectionHelper, OnSetExtensionHdl));
     110           0 :         m_pAccessCSVFiles->SetToggleHdl(LINK(this, OTextConnectionHelper, OnSetExtensionHdl));
     111           0 :         m_pAccessOtherFiles->SetToggleHdl(LINK(this, OTextConnectionHelper, OnSetExtensionHdl));
     112           0 :         m_pAccessCSVFiles->Check(true);
     113             : 
     114           0 :         struct SectionDescriptor
     115             :         {
     116             :             short   nFlag;
     117             :             VclPtr<vcl::Window> pFirstControl;
     118             :         } aSections[] = {
     119             :             { TC_EXTENSION,     m_pExtensionHeader },
     120             :             { TC_SEPARATORS,    m_pFormatHeader },
     121             :             { TC_HEADER,        m_pRowHeader },
     122             :             { TC_CHARSET,       m_pCharSetHeader },
     123             :             { 0, NULL }
     124           0 :         };
     125             : 
     126           0 :         for ( size_t section=0; section < sizeof( aSections ) / sizeof( aSections[0] ) - 1; ++section )
     127             :         {
     128           0 :             if ( ( m_nAvailableSections & aSections[section].nFlag ) != 0 )
     129             :             {
     130             :                 // the section is visible, no need to do anything here
     131           0 :                 continue;
     132             :             }
     133             : 
     134           0 :             vcl::Window* pThisSection = aSections[section].pFirstControl;
     135           0 :             vcl::Window* pNextSection = aSections[section+1].pFirstControl;
     136             : 
     137             :             // hide all elements from this section
     138           0 :             vcl::Window* pControl = pThisSection;
     139           0 :             while ( ( pControl != pNextSection ) && pControl )
     140             :             {
     141           0 :                 vcl::Window* pRealWindow = pControl->GetWindow( GetWindowType::Client );
     142             :             #if OSL_DEBUG_LEVEL > 0
     143             :                 OUString sWindowText( pRealWindow->GetText() );
     144             :                 (void)sWindowText;
     145             :             #endif
     146           0 :                 pRealWindow->Hide();
     147           0 :                 pControl = pControl->GetWindow( GetWindowType::Next );
     148             :             }
     149             :         }
     150             : 
     151           0 :         Show();
     152           0 :     }
     153             : 
     154           0 :     OTextConnectionHelper::~OTextConnectionHelper()
     155             :     {
     156           0 :         disposeOnce();
     157           0 :     }
     158             : 
     159           0 :     void OTextConnectionHelper::dispose()
     160             :     {
     161           0 :         m_pExtensionHeader.clear();
     162           0 :         m_pAccessTextFiles.clear();
     163           0 :         m_pAccessCSVFiles.clear();
     164           0 :         m_pAccessOtherFiles.clear();
     165           0 :         m_pOwnExtension.clear();
     166           0 :         m_pExtensionExample.clear();
     167           0 :         m_pFormatHeader.clear();
     168           0 :         m_pFieldSeparatorLabel.clear();
     169           0 :         m_pFieldSeparator.clear();
     170           0 :         m_pTextSeparatorLabel.clear();
     171           0 :         m_pTextSeparator.clear();
     172           0 :         m_pDecimalSeparatorLabel.clear();
     173           0 :         m_pDecimalSeparator.clear();
     174           0 :         m_pThousandsSeparatorLabel.clear();
     175           0 :         m_pThousandsSeparator.clear();
     176           0 :         m_pRowHeader.clear();
     177           0 :         m_pCharSetHeader.clear();
     178           0 :         m_pCharSetLabel.clear();
     179           0 :         m_pCharSet.clear();
     180           0 :         TabPage::dispose();
     181           0 :     }
     182             : 
     183           0 :     IMPL_LINK(OTextConnectionHelper, OnControlModified, Control*,)
     184             :     {
     185           0 :         callModifiedHdl();
     186           0 :         return 0L;
     187             :     }
     188             : 
     189           0 :     IMPL_LINK(OTextConnectionHelper, OnEditModified, Edit*, /*_pEdit*/)
     190             :     {
     191           0 :         m_aGetExtensionHandler.Call(this);
     192           0 :         return 0L;
     193             :     }
     194             : 
     195           0 :     IMPL_LINK(OTextConnectionHelper, OnSetExtensionHdl, RadioButton*, /*_pRadioButton*/)
     196             :     {
     197           0 :         bool bDoEnable = m_pAccessOtherFiles->IsChecked();
     198           0 :         m_pOwnExtension->Enable(bDoEnable);
     199           0 :         m_pExtensionExample->Enable(bDoEnable);
     200           0 :         m_aGetExtensionHandler.Call(this);
     201           0 :         return 0L;
     202             :     }
     203             : 
     204           0 :     void OTextConnectionHelper::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
     205             :     {
     206           0 :         _rControlList.push_back(new OSaveValueWrapper<ComboBox>(m_pFieldSeparator));
     207           0 :         _rControlList.push_back(new OSaveValueWrapper<ComboBox>(m_pTextSeparator));
     208           0 :         _rControlList.push_back(new OSaveValueWrapper<ComboBox>(m_pDecimalSeparator));
     209           0 :         _rControlList.push_back(new OSaveValueWrapper<ComboBox>(m_pThousandsSeparator));
     210           0 :         _rControlList.push_back(new OSaveValueWrapper<CheckBox>(m_pRowHeader));
     211           0 :         _rControlList.push_back(new OSaveValueWrapper<ListBox>(m_pCharSet));
     212           0 :     }
     213             : 
     214           0 :     void OTextConnectionHelper::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
     215             :     {
     216           0 :         _rControlList.push_back(new ODisableWrapper<FixedText>(m_pFieldSeparatorLabel));
     217           0 :         _rControlList.push_back(new ODisableWrapper<FixedText>(m_pTextSeparatorLabel));
     218           0 :         _rControlList.push_back(new ODisableWrapper<FixedText>(m_pDecimalSeparatorLabel));
     219           0 :         _rControlList.push_back(new ODisableWrapper<FixedText>(m_pThousandsSeparatorLabel));
     220           0 :         _rControlList.push_back(new ODisableWrapper<FixedText>(m_pCharSetHeader));
     221           0 :         _rControlList.push_back(new ODisableWrapper<FixedText>(m_pCharSetLabel));
     222           0 :         _rControlList.push_back(new ODisableWrapper<ListBox>(m_pCharSet));
     223           0 :     }
     224             : 
     225           0 :     void OTextConnectionHelper::implInitControls(const SfxItemSet& _rSet, bool _bValid)
     226             :     {
     227           0 :         if ( !_bValid )
     228           0 :             return;
     229             : 
     230           0 :         SFX_ITEMSET_GET( _rSet, pDelItem, SfxStringItem, DSID_FIELDDELIMITER, true );
     231           0 :         SFX_ITEMSET_GET( _rSet, pStrItem, SfxStringItem, DSID_TEXTDELIMITER, true );
     232           0 :         SFX_ITEMSET_GET( _rSet, pDecdelItem, SfxStringItem, DSID_DECIMALDELIMITER, true );
     233           0 :         SFX_ITEMSET_GET( _rSet, pThodelItem, SfxStringItem, DSID_THOUSANDSDELIMITER, true );
     234           0 :         SFX_ITEMSET_GET( _rSet, pExtensionItem, SfxStringItem, DSID_TEXTFILEEXTENSION, true );
     235           0 :         SFX_ITEMSET_GET( _rSet, pCharsetItem, SfxStringItem, DSID_CHARSET, true );
     236             : 
     237           0 :         if ( ( m_nAvailableSections & TC_EXTENSION ) != 0 )
     238             :         {
     239           0 :             m_aOldExtension = pExtensionItem->GetValue();
     240           0 :             SetExtension( m_aOldExtension );
     241             :         }
     242             : 
     243           0 :         if ( ( m_nAvailableSections & TC_HEADER ) != 0 )
     244             :         {
     245           0 :             SFX_ITEMSET_GET( _rSet, pHdrItem, SfxBoolItem, DSID_TEXTFILEHEADER, true );
     246           0 :             m_pRowHeader->Check( pHdrItem->GetValue() );
     247             :         }
     248             : 
     249           0 :         if ( ( m_nAvailableSections & TC_SEPARATORS ) != 0 )
     250             :         {
     251           0 :             SetSeparator( *m_pFieldSeparator, m_aFieldSeparatorList, pDelItem->GetValue() );
     252           0 :             SetSeparator( *m_pTextSeparator, m_aTextSeparatorList, pStrItem->GetValue() );
     253           0 :             m_pDecimalSeparator->SetText( pDecdelItem->GetValue() );
     254           0 :             m_pThousandsSeparator->SetText( pThodelItem->GetValue() );
     255             :         }
     256             : 
     257           0 :         if ( ( m_nAvailableSections & TC_CHARSET ) != 0 )
     258             :         {
     259           0 :             m_pCharSet->SelectEntryByIanaName( pCharsetItem->GetValue() );
     260             :         }
     261             :     }
     262             : 
     263           0 :     bool OTextConnectionHelper::prepareLeave()
     264             :     {
     265           0 :         OUString sExtension = GetExtension();
     266           0 :         OUString aErrorText;
     267           0 :         Control* pErrorWin = NULL;
     268           0 :         OUString aDelText(m_pFieldSeparator->GetText());
     269           0 :         if(aDelText.isEmpty())
     270             :         {   // No FieldSeparator
     271           0 :             aErrorText = ModuleRes(STR_AUTODELIMITER_MISSING);
     272           0 :             aErrorText = aErrorText.replaceFirst("#1",m_pFieldSeparatorLabel->GetText());
     273           0 :             pErrorWin = m_pFieldSeparator;
     274             :         }
     275           0 :         else if (m_pDecimalSeparator->GetText().isEmpty())
     276             :         {   // No DecimalSeparator
     277           0 :             aErrorText = ModuleRes(STR_AUTODELIMITER_MISSING);
     278           0 :             aErrorText = aErrorText.replaceFirst("#1",m_pDecimalSeparatorLabel->GetText());
     279           0 :             pErrorWin = m_pDecimalSeparator;
     280             :         }
     281           0 :         else if (m_pTextSeparator->GetText() == m_pFieldSeparator->GetText())
     282             :         {   // Field and TextSeparator must not be the same
     283           0 :             aErrorText = ModuleRes(STR_AUTODELIMITER_MUST_DIFFER);
     284           0 :             aErrorText = aErrorText.replaceFirst("#1",m_pTextSeparatorLabel->GetText());
     285           0 :             aErrorText = aErrorText.replaceFirst("#2",m_pFieldSeparatorLabel->GetText());
     286           0 :             pErrorWin = m_pTextSeparator;
     287             :         }
     288           0 :         else if (m_pDecimalSeparator->GetText() == m_pThousandsSeparator->GetText())
     289             :         {   // Thousands and DecimalSeparator must not be the same
     290           0 :             aErrorText = ModuleRes(STR_AUTODELIMITER_MUST_DIFFER);
     291           0 :             aErrorText = aErrorText.replaceFirst("#1",m_pDecimalSeparatorLabel->GetText());
     292           0 :             aErrorText = aErrorText.replaceFirst("#2",m_pThousandsSeparatorLabel->GetText());
     293           0 :             pErrorWin = m_pDecimalSeparator;
     294             :         }
     295           0 :         else if (m_pFieldSeparator->GetText() == m_pThousandsSeparator->GetText())
     296             :         {   // Thousands and FieldSeparator must not be the same
     297           0 :             aErrorText = ModuleRes(STR_AUTODELIMITER_MUST_DIFFER);
     298           0 :             aErrorText = aErrorText.replaceFirst("#1",m_pFieldSeparatorLabel->GetText());
     299           0 :             aErrorText = aErrorText.replaceFirst("#2",m_pThousandsSeparatorLabel->GetText());
     300           0 :             pErrorWin = m_pFieldSeparator;
     301             :         }
     302           0 :         else if (m_pFieldSeparator->GetText() == m_pDecimalSeparator->GetText())
     303             :         {   // Tenner and FieldSeparator must not be the same
     304           0 :             aErrorText = ModuleRes(STR_AUTODELIMITER_MUST_DIFFER);
     305           0 :             aErrorText = aErrorText.replaceFirst("#1",m_pFieldSeparatorLabel->GetText());
     306           0 :             aErrorText = aErrorText.replaceFirst("#2",m_pDecimalSeparatorLabel->GetText());
     307           0 :             pErrorWin = m_pFieldSeparator;
     308             :         }
     309           0 :         else if (m_pTextSeparator->GetText() == m_pThousandsSeparator->GetText())
     310             :         {   // Thousands and TextSeparator must not be the same
     311           0 :             aErrorText = ModuleRes(STR_AUTODELIMITER_MUST_DIFFER);
     312           0 :             aErrorText = aErrorText.replaceFirst("#1",m_pTextSeparatorLabel->GetText());
     313           0 :             aErrorText = aErrorText.replaceFirst("#2",m_pThousandsSeparatorLabel->GetText());
     314           0 :             pErrorWin = m_pTextSeparator;
     315             :         }
     316           0 :         else if (m_pTextSeparator->GetText() == m_pDecimalSeparator->GetText())
     317             :         {   // Tenner and TextSeparator must not be the same
     318           0 :             aErrorText = ModuleRes(STR_AUTODELIMITER_MUST_DIFFER);
     319           0 :             aErrorText = aErrorText.replaceFirst("#1",m_pTextSeparatorLabel->GetText());
     320           0 :             aErrorText = aErrorText.replaceFirst("#2",m_pDecimalSeparatorLabel->GetText());
     321           0 :             pErrorWin = m_pTextSeparator;
     322             :         }
     323           0 :         else if ((sExtension.indexOf('*') != -1) || (sExtension.indexOf('?') != -1))
     324             :         {
     325           0 :             aErrorText = ModuleRes(STR_AUTONO_WILDCARDS);
     326           0 :             aErrorText = aErrorText.replaceFirst("#1",sExtension);
     327           0 :             pErrorWin = m_pOwnExtension;
     328             :         }
     329             :         else
     330           0 :             return true;
     331           0 :         ScopedVclPtrInstance<MessageDialog>::Create(nullptr, MnemonicGenerator::EraseAllMnemonicChars(aErrorText))->Execute();
     332           0 :         pErrorWin->GrabFocus();
     333           0 :         return false;
     334             :     }
     335             : 
     336           0 :     bool OTextConnectionHelper::FillItemSet( SfxItemSet& rSet, const bool _bChangedSomething )
     337             :     {
     338           0 :         bool bChangedSomething = _bChangedSomething;
     339             : 
     340           0 :         if ( ( m_nAvailableSections & TC_EXTENSION ) != 0 )
     341             :         {
     342           0 :             OUString sExtension = GetExtension();
     343           0 :             if( m_aOldExtension != sExtension )
     344             :             {
     345           0 :                 rSet.Put( SfxStringItem( DSID_TEXTFILEEXTENSION, sExtension ) );
     346           0 :                 bChangedSomething = true;
     347           0 :             }
     348             :         }
     349             : 
     350           0 :         if ( ( m_nAvailableSections & TC_HEADER ) != 0 )
     351             :         {
     352           0 :             if( m_pRowHeader->IsValueChangedFromSaved() )
     353             :             {
     354           0 :                 rSet.Put(SfxBoolItem(DSID_TEXTFILEHEADER, m_pRowHeader->IsChecked()));
     355           0 :                 bChangedSomething = true;
     356             :             }
     357             :         }
     358             : 
     359           0 :         if ( ( m_nAvailableSections & TC_SEPARATORS ) != 0 )
     360             :         {
     361           0 :             if( m_pFieldSeparator->IsValueChangedFromSaved() )
     362             :             {
     363           0 :                 rSet.Put( SfxStringItem(DSID_FIELDDELIMITER, GetSeparator( *m_pFieldSeparator, m_aFieldSeparatorList) ) );
     364           0 :                 bChangedSomething = true;
     365             :             }
     366           0 :             if( m_pTextSeparator->IsValueChangedFromSaved() )
     367             :             {
     368           0 :                 rSet.Put( SfxStringItem(DSID_TEXTDELIMITER, GetSeparator( *m_pTextSeparator, m_aTextSeparatorList) ) );
     369           0 :                 bChangedSomething = true;
     370             :             }
     371             : 
     372           0 :             if( m_pDecimalSeparator->IsValueChangedFromSaved() )
     373             :             {
     374           0 :                 rSet.Put( SfxStringItem(DSID_DECIMALDELIMITER, m_pDecimalSeparator->GetText().copy(0, 1) ) );
     375           0 :                 bChangedSomething = true;
     376             :             }
     377           0 :             if( m_pThousandsSeparator->IsValueChangedFromSaved() )
     378             :             {
     379           0 :                 rSet.Put( SfxStringItem(DSID_THOUSANDSDELIMITER, m_pThousandsSeparator->GetText().copy(0,1) ) );
     380           0 :                 bChangedSomething = true;
     381             :             }
     382             :         }
     383             : 
     384           0 :         if ( ( m_nAvailableSections & TC_CHARSET ) != 0 )
     385             :         {
     386           0 :             if ( m_pCharSet->StoreSelectedCharSet( rSet, DSID_CHARSET ) )
     387           0 :                 bChangedSomething = true;
     388             :         }
     389             : 
     390           0 :         return bChangedSomething;
     391             :     }
     392             : 
     393           0 :     void OTextConnectionHelper::SetExtension(const OUString& _rVal)
     394             :     {
     395           0 :         if (_rVal == "txt")
     396           0 :             m_pAccessTextFiles->Check(true);
     397           0 :         else if (_rVal == "csv")
     398           0 :             m_pAccessCSVFiles->Check(true);
     399             :         else
     400             :         {
     401           0 :             m_pAccessOtherFiles->Check(true);
     402           0 :             m_pExtensionExample->SetText(_rVal);
     403             :         }
     404           0 :     }
     405             : 
     406           0 :     OUString OTextConnectionHelper::GetExtension()
     407             :     {
     408           0 :         OUString sExtension;
     409           0 :         if (m_pAccessTextFiles->IsChecked())
     410           0 :             sExtension = "txt";
     411           0 :         else if (m_pAccessCSVFiles->IsChecked())
     412           0 :             sExtension = "csv";
     413             :         else
     414             :         {
     415           0 :             sExtension = m_pOwnExtension->GetText();
     416           0 :             if ( comphelper::string::equals(sExtension.getToken(0,'.'), '*') )
     417           0 :                 sExtension = sExtension.copy(2);
     418             :         }
     419           0 :         return sExtension;
     420             :     }
     421             : 
     422           0 :     OUString OTextConnectionHelper::GetSeparator( const ComboBox& rBox, const OUString& rList )
     423             :     {
     424           0 :         sal_Unicode nTok = '\t';
     425           0 :         sal_Int32 nPos(rBox.GetEntryPos( rBox.GetText() ));
     426             : 
     427           0 :         if( nPos == COMBOBOX_ENTRY_NOTFOUND )
     428           0 :             return rBox.GetText().copy(0);
     429             : 
     430           0 :         if ( !( m_pTextSeparator == &rBox && nPos == (rBox.GetEntryCount()-1) ) )
     431             :             return OUString(
     432           0 :                 static_cast< sal_Unicode >( rList.getToken((nPos*2)+1, nTok ).toInt32() ));
     433             :         // somewhat strange ... translates for instance an "32" into " "
     434           0 :         return OUString();
     435             :     }
     436             : 
     437           0 :     void OTextConnectionHelper::SetSeparator( ComboBox& rBox, const OUString& rList, const OUString& rVal )
     438             :     {
     439           0 :         char    nTok = '\t';
     440           0 :         sal_Int32   nCnt = comphelper::string::getTokenCount(rList, nTok);
     441             :         sal_Int32 i;
     442             : 
     443           0 :         for( i=0 ; i<nCnt ; i+=2 )
     444             :         {
     445             :             OUString  sTVal(
     446           0 :                 static_cast< sal_Unicode >( rList.getToken( (i+1), nTok ).toInt32() ));
     447             : 
     448           0 :             if( sTVal.equals(rVal) )
     449             :             {
     450           0 :                 rBox.SetText( rList.getToken( i, nTok ) );
     451           0 :                 break;
     452             :             }
     453           0 :         }
     454             : 
     455           0 :         if ( i >= nCnt )
     456             :         {
     457           0 :             if ( m_pTextSeparator == &rBox && rVal.isEmpty() )
     458           0 :                 rBox.SetText(m_aTextNone);
     459             :             else
     460           0 :                 rBox.SetText( rVal.copy(0, 1) );
     461             :         }
     462           0 :     }
     463          36 : }
     464             : 
     465             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11