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