1b3f79822SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3b3f79822SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4b3f79822SAndrew Rist * or more contributor license agreements. See the NOTICE file 5b3f79822SAndrew Rist * distributed with this work for additional information 6b3f79822SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7b3f79822SAndrew Rist * to you under the Apache License, Version 2.0 (the 8b3f79822SAndrew Rist * "License"); you may not use this file except in compliance 9b3f79822SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11b3f79822SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13b3f79822SAndrew Rist * Unless required by applicable law or agreed to in writing, 14b3f79822SAndrew Rist * software distributed under the License is distributed on an 15b3f79822SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16b3f79822SAndrew Rist * KIND, either express or implied. See the License for the 17b3f79822SAndrew Rist * specific language governing permissions and limitations 18b3f79822SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20b3f79822SAndrew Rist *************************************************************/ 21b3f79822SAndrew Rist 22b3f79822SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_sc.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir 28cdf0e10cSrcweir 29cdf0e10cSrcweir #include "global.hxx" 30cdf0e10cSrcweir #include "scresid.hxx" 31cdf0e10cSrcweir #include "impex.hxx" 32cdf0e10cSrcweir #include "asciiopt.hxx" 33cdf0e10cSrcweir #include "asciiopt.hrc" 34cdf0e10cSrcweir #include <tools/debug.hxx> 35cdf0e10cSrcweir #include <rtl/tencinfo.h> 36cdf0e10cSrcweir #include <unotools/transliterationwrapper.hxx> 37cdf0e10cSrcweir // ause 38cdf0e10cSrcweir #include "editutil.hxx" 39cdf0e10cSrcweir 40cdf0e10cSrcweir // ============================================================================ 41cdf0e10cSrcweir 42cdf0e10cSrcweir static const sal_Char __FAR_DATA pStrFix[] = "FIX"; 43cdf0e10cSrcweir static const sal_Char __FAR_DATA pStrMrg[] = "MRG"; 44cdf0e10cSrcweir 45cdf0e10cSrcweir 46cdf0e10cSrcweir // ============================================================================ 47cdf0e10cSrcweir 48cdf0e10cSrcweir ScAsciiOptions::ScAsciiOptions() : 49cdf0e10cSrcweir bFixedLen ( sal_False ), 50cdf0e10cSrcweir aFieldSeps ( ';' ), 51cdf0e10cSrcweir bMergeFieldSeps ( sal_False ), 52cdf0e10cSrcweir bQuotedFieldAsText(false), 53cdf0e10cSrcweir bDetectSpecialNumber(false), 54cdf0e10cSrcweir cTextSep ( cDefaultTextSep ), 55cdf0e10cSrcweir eCharSet ( gsl_getSystemTextEncoding() ), 56cdf0e10cSrcweir eLang ( LANGUAGE_SYSTEM ), 57cdf0e10cSrcweir bCharSetSystem ( sal_False ), 58cdf0e10cSrcweir nStartRow ( 1 ), 59cdf0e10cSrcweir nInfoCount ( 0 ), 60cdf0e10cSrcweir pColStart ( NULL ), 61cdf0e10cSrcweir pColFormat ( NULL ) 62cdf0e10cSrcweir { 63cdf0e10cSrcweir } 64cdf0e10cSrcweir 65cdf0e10cSrcweir 66cdf0e10cSrcweir ScAsciiOptions::ScAsciiOptions(const ScAsciiOptions& rOpt) : 67cdf0e10cSrcweir bFixedLen ( rOpt.bFixedLen ), 68cdf0e10cSrcweir aFieldSeps ( rOpt.aFieldSeps ), 69cdf0e10cSrcweir bMergeFieldSeps ( rOpt.bMergeFieldSeps ), 70cdf0e10cSrcweir bQuotedFieldAsText(rOpt.bQuotedFieldAsText), 71cdf0e10cSrcweir bDetectSpecialNumber(rOpt.bDetectSpecialNumber), 72cdf0e10cSrcweir cTextSep ( rOpt.cTextSep ), 73cdf0e10cSrcweir eCharSet ( rOpt.eCharSet ), 74cdf0e10cSrcweir eLang ( rOpt.eLang ), 75cdf0e10cSrcweir bCharSetSystem ( rOpt.bCharSetSystem ), 76cdf0e10cSrcweir nStartRow ( rOpt.nStartRow ), 77cdf0e10cSrcweir nInfoCount ( rOpt.nInfoCount ) 78cdf0e10cSrcweir { 79cdf0e10cSrcweir if (nInfoCount) 80cdf0e10cSrcweir { 81cdf0e10cSrcweir pColStart = new xub_StrLen[nInfoCount]; 82cdf0e10cSrcweir pColFormat = new sal_uInt8[nInfoCount]; 83cdf0e10cSrcweir for (sal_uInt16 i=0; i<nInfoCount; i++) 84cdf0e10cSrcweir { 85cdf0e10cSrcweir pColStart[i] = rOpt.pColStart[i]; 86cdf0e10cSrcweir pColFormat[i] = rOpt.pColFormat[i]; 87cdf0e10cSrcweir } 88cdf0e10cSrcweir } 89cdf0e10cSrcweir else 90cdf0e10cSrcweir { 91cdf0e10cSrcweir pColStart = NULL; 92cdf0e10cSrcweir pColFormat = NULL; 93cdf0e10cSrcweir } 94cdf0e10cSrcweir } 95cdf0e10cSrcweir 96cdf0e10cSrcweir 97cdf0e10cSrcweir ScAsciiOptions::~ScAsciiOptions() 98cdf0e10cSrcweir { 99cdf0e10cSrcweir delete[] pColStart; 100cdf0e10cSrcweir delete[] pColFormat; 101cdf0e10cSrcweir } 102cdf0e10cSrcweir 103cdf0e10cSrcweir 104cdf0e10cSrcweir void ScAsciiOptions::SetColInfo( sal_uInt16 nCount, const xub_StrLen* pStart, const sal_uInt8* pFormat ) 105cdf0e10cSrcweir { 106cdf0e10cSrcweir delete[] pColStart; 107cdf0e10cSrcweir delete[] pColFormat; 108cdf0e10cSrcweir 109cdf0e10cSrcweir nInfoCount = nCount; 110cdf0e10cSrcweir 111cdf0e10cSrcweir if (nInfoCount) 112cdf0e10cSrcweir { 113cdf0e10cSrcweir pColStart = new xub_StrLen[nInfoCount]; 114cdf0e10cSrcweir pColFormat = new sal_uInt8[nInfoCount]; 115cdf0e10cSrcweir for (sal_uInt16 i=0; i<nInfoCount; i++) 116cdf0e10cSrcweir { 117cdf0e10cSrcweir pColStart[i] = pStart[i]; 118cdf0e10cSrcweir pColFormat[i] = pFormat[i]; 119cdf0e10cSrcweir } 120cdf0e10cSrcweir } 121cdf0e10cSrcweir else 122cdf0e10cSrcweir { 123cdf0e10cSrcweir pColStart = NULL; 124cdf0e10cSrcweir pColFormat = NULL; 125cdf0e10cSrcweir } 126cdf0e10cSrcweir } 127cdf0e10cSrcweir 128cdf0e10cSrcweir 129cdf0e10cSrcweir void ScAsciiOptions::SetColumnInfo( const ScCsvExpDataVec& rDataVec ) 130cdf0e10cSrcweir { 131cdf0e10cSrcweir delete[] pColStart; 132cdf0e10cSrcweir pColStart = NULL; 133cdf0e10cSrcweir delete[] pColFormat; 134cdf0e10cSrcweir pColFormat = NULL; 135cdf0e10cSrcweir 136cdf0e10cSrcweir nInfoCount = static_cast< sal_uInt16 >( rDataVec.size() ); 137cdf0e10cSrcweir if( nInfoCount ) 138cdf0e10cSrcweir { 139cdf0e10cSrcweir pColStart = new xub_StrLen[ nInfoCount ]; 140cdf0e10cSrcweir pColFormat = new sal_uInt8[ nInfoCount ]; 141cdf0e10cSrcweir for( sal_uInt16 nIx = 0; nIx < nInfoCount; ++nIx ) 142cdf0e10cSrcweir { 143cdf0e10cSrcweir pColStart[ nIx ] = rDataVec[ nIx ].mnIndex; 144cdf0e10cSrcweir pColFormat[ nIx ] = rDataVec[ nIx ].mnType; 145cdf0e10cSrcweir } 146cdf0e10cSrcweir } 147cdf0e10cSrcweir } 148cdf0e10cSrcweir 149cdf0e10cSrcweir 150cdf0e10cSrcweir ScAsciiOptions& ScAsciiOptions::operator=( const ScAsciiOptions& rCpy ) 151cdf0e10cSrcweir { 152cdf0e10cSrcweir SetColInfo( rCpy.nInfoCount, rCpy.pColStart, rCpy.pColFormat ); 153cdf0e10cSrcweir 154cdf0e10cSrcweir bFixedLen = rCpy.bFixedLen; 155cdf0e10cSrcweir aFieldSeps = rCpy.aFieldSeps; 156cdf0e10cSrcweir bMergeFieldSeps = rCpy.bMergeFieldSeps; 157cdf0e10cSrcweir bQuotedFieldAsText = rCpy.bQuotedFieldAsText; 158cdf0e10cSrcweir cTextSep = rCpy.cTextSep; 159cdf0e10cSrcweir eCharSet = rCpy.eCharSet; 160cdf0e10cSrcweir bCharSetSystem = rCpy.bCharSetSystem; 161cdf0e10cSrcweir nStartRow = rCpy.nStartRow; 162cdf0e10cSrcweir 163cdf0e10cSrcweir return *this; 164cdf0e10cSrcweir } 165cdf0e10cSrcweir 166cdf0e10cSrcweir 167cdf0e10cSrcweir sal_Bool ScAsciiOptions::operator==( const ScAsciiOptions& rCmp ) const 168cdf0e10cSrcweir { 169cdf0e10cSrcweir if ( bFixedLen == rCmp.bFixedLen && 170cdf0e10cSrcweir aFieldSeps == rCmp.aFieldSeps && 171cdf0e10cSrcweir bMergeFieldSeps == rCmp.bMergeFieldSeps && 172cdf0e10cSrcweir bQuotedFieldAsText == rCmp.bQuotedFieldAsText && 173cdf0e10cSrcweir cTextSep == rCmp.cTextSep && 174cdf0e10cSrcweir eCharSet == rCmp.eCharSet && 175cdf0e10cSrcweir bCharSetSystem == rCmp.bCharSetSystem && 176cdf0e10cSrcweir nStartRow == rCmp.nStartRow && 177cdf0e10cSrcweir nInfoCount == rCmp.nInfoCount ) 178cdf0e10cSrcweir { 179cdf0e10cSrcweir DBG_ASSERT( !nInfoCount || (pColStart && pColFormat && rCmp.pColStart && rCmp.pColFormat), 180cdf0e10cSrcweir "0-Zeiger in ScAsciiOptions" ); 181cdf0e10cSrcweir for (sal_uInt16 i=0; i<nInfoCount; i++) 182cdf0e10cSrcweir if ( pColStart[i] != rCmp.pColStart[i] || 183cdf0e10cSrcweir pColFormat[i] != rCmp.pColFormat[i] ) 184cdf0e10cSrcweir return sal_False; 185cdf0e10cSrcweir 186cdf0e10cSrcweir return sal_True; 187cdf0e10cSrcweir } 188cdf0e10cSrcweir return sal_False; 189cdf0e10cSrcweir } 190cdf0e10cSrcweir 191cdf0e10cSrcweir // 192cdf0e10cSrcweir // Der Options-String darf kein Semikolon mehr enthalten (wegen Pickliste) 193cdf0e10cSrcweir // darum ab Version 336 Komma stattdessen 194cdf0e10cSrcweir // 195cdf0e10cSrcweir 196cdf0e10cSrcweir 197cdf0e10cSrcweir void ScAsciiOptions::ReadFromString( const String& rString ) 198cdf0e10cSrcweir { 199cdf0e10cSrcweir xub_StrLen nCount = rString.GetTokenCount(','); 200cdf0e10cSrcweir String aToken; 201cdf0e10cSrcweir xub_StrLen nSub; 202cdf0e10cSrcweir xub_StrLen i; 203cdf0e10cSrcweir 204cdf0e10cSrcweir // 205cdf0e10cSrcweir // Feld-Trenner 206cdf0e10cSrcweir // 207cdf0e10cSrcweir 208cdf0e10cSrcweir if ( nCount >= 1 ) 209cdf0e10cSrcweir { 210cdf0e10cSrcweir bFixedLen = bMergeFieldSeps = sal_False; 211cdf0e10cSrcweir aFieldSeps.Erase(); 212cdf0e10cSrcweir 213cdf0e10cSrcweir aToken = rString.GetToken(0,','); 214cdf0e10cSrcweir if ( aToken.EqualsAscii(pStrFix) ) 215cdf0e10cSrcweir bFixedLen = sal_True; 216cdf0e10cSrcweir nSub = aToken.GetTokenCount('/'); 217cdf0e10cSrcweir for ( i=0; i<nSub; i++ ) 218cdf0e10cSrcweir { 219cdf0e10cSrcweir String aCode = aToken.GetToken( i, '/' ); 220cdf0e10cSrcweir if ( aCode.EqualsAscii(pStrMrg) ) 221cdf0e10cSrcweir bMergeFieldSeps = sal_True; 222cdf0e10cSrcweir else 223cdf0e10cSrcweir { 224cdf0e10cSrcweir sal_Int32 nVal = aCode.ToInt32(); 225cdf0e10cSrcweir if ( nVal ) 226cdf0e10cSrcweir aFieldSeps += (sal_Unicode) nVal; 227cdf0e10cSrcweir } 228cdf0e10cSrcweir } 229cdf0e10cSrcweir } 230cdf0e10cSrcweir 231cdf0e10cSrcweir // 232cdf0e10cSrcweir // Text-Trenner 233cdf0e10cSrcweir // 234cdf0e10cSrcweir 235cdf0e10cSrcweir if ( nCount >= 2 ) 236cdf0e10cSrcweir { 237cdf0e10cSrcweir aToken = rString.GetToken(1,','); 238cdf0e10cSrcweir sal_Int32 nVal = aToken.ToInt32(); 239cdf0e10cSrcweir cTextSep = (sal_Unicode) nVal; 240cdf0e10cSrcweir } 241cdf0e10cSrcweir 242cdf0e10cSrcweir // 243cdf0e10cSrcweir // Zeichensatz 244cdf0e10cSrcweir // 245cdf0e10cSrcweir 246cdf0e10cSrcweir if ( nCount >= 3 ) 247cdf0e10cSrcweir { 248cdf0e10cSrcweir aToken = rString.GetToken(2,','); 249cdf0e10cSrcweir eCharSet = ScGlobal::GetCharsetValue( aToken ); 250cdf0e10cSrcweir } 251cdf0e10cSrcweir 252cdf0e10cSrcweir // 253cdf0e10cSrcweir // Startzeile 254cdf0e10cSrcweir // 255cdf0e10cSrcweir 256cdf0e10cSrcweir if ( nCount >= 4 ) 257cdf0e10cSrcweir { 258cdf0e10cSrcweir aToken = rString.GetToken(3,','); 259cdf0e10cSrcweir nStartRow = aToken.ToInt32(); 260cdf0e10cSrcweir } 261cdf0e10cSrcweir 262cdf0e10cSrcweir // 263cdf0e10cSrcweir // Spalten-Infos 264cdf0e10cSrcweir // 265cdf0e10cSrcweir 266cdf0e10cSrcweir if ( nCount >= 5 ) 267cdf0e10cSrcweir { 268cdf0e10cSrcweir delete[] pColStart; 269cdf0e10cSrcweir delete[] pColFormat; 270cdf0e10cSrcweir 271cdf0e10cSrcweir aToken = rString.GetToken(4,','); 272cdf0e10cSrcweir nSub = aToken.GetTokenCount('/'); 273cdf0e10cSrcweir nInfoCount = nSub / 2; 274cdf0e10cSrcweir if (nInfoCount) 275cdf0e10cSrcweir { 276cdf0e10cSrcweir pColStart = new xub_StrLen[nInfoCount]; 277cdf0e10cSrcweir pColFormat = new sal_uInt8[nInfoCount]; 278cdf0e10cSrcweir for (sal_uInt16 nInfo=0; nInfo<nInfoCount; nInfo++) 279cdf0e10cSrcweir { 280cdf0e10cSrcweir pColStart[nInfo] = (xub_StrLen) aToken.GetToken( 2*nInfo, '/' ).ToInt32(); 281cdf0e10cSrcweir pColFormat[nInfo] = (sal_uInt8) aToken.GetToken( 2*nInfo+1, '/' ).ToInt32(); 282cdf0e10cSrcweir } 283cdf0e10cSrcweir } 284cdf0e10cSrcweir else 285cdf0e10cSrcweir { 286cdf0e10cSrcweir pColStart = NULL; 287cdf0e10cSrcweir pColFormat = NULL; 288cdf0e10cSrcweir } 289cdf0e10cSrcweir } 290cdf0e10cSrcweir 291cdf0e10cSrcweir // Language 292cdf0e10cSrcweir if (nCount >= 6) 293cdf0e10cSrcweir { 294cdf0e10cSrcweir aToken = rString.GetToken(5, ','); 295cdf0e10cSrcweir eLang = static_cast<LanguageType>(aToken.ToInt32()); 296cdf0e10cSrcweir } 297cdf0e10cSrcweir 298cdf0e10cSrcweir // Import quoted field as text. 299cdf0e10cSrcweir if (nCount >= 7) 300cdf0e10cSrcweir { 301cdf0e10cSrcweir aToken = rString.GetToken(6, ','); 302cdf0e10cSrcweir bQuotedFieldAsText = aToken.EqualsAscii("true") ? true : false; 303cdf0e10cSrcweir } 304cdf0e10cSrcweir 305*6ded66c8SMatthias Seidel // Detect special numbers. 306cdf0e10cSrcweir if (nCount >= 8) 307cdf0e10cSrcweir { 308cdf0e10cSrcweir aToken = rString.GetToken(7, ','); 309cdf0e10cSrcweir bDetectSpecialNumber = aToken.EqualsAscii("true") ? true : false; 310cdf0e10cSrcweir } 311cdf0e10cSrcweir else 312cdf0e10cSrcweir bDetectSpecialNumber = sal_True; // default of versions that didn't add the parameter 313cdf0e10cSrcweir 314cdf0e10cSrcweir // 9th token is used for "Save as shown" in export options 315cdf0e10cSrcweir } 316cdf0e10cSrcweir 317cdf0e10cSrcweir 318cdf0e10cSrcweir String ScAsciiOptions::WriteToString() const 319cdf0e10cSrcweir { 320cdf0e10cSrcweir String aOutStr; 321cdf0e10cSrcweir 322cdf0e10cSrcweir // 323cdf0e10cSrcweir // Feld-Trenner 324cdf0e10cSrcweir // 325cdf0e10cSrcweir 326cdf0e10cSrcweir if ( bFixedLen ) 327cdf0e10cSrcweir aOutStr.AppendAscii(pStrFix); 328cdf0e10cSrcweir else if ( !aFieldSeps.Len() ) 329cdf0e10cSrcweir aOutStr += '0'; 330cdf0e10cSrcweir else 331cdf0e10cSrcweir { 332cdf0e10cSrcweir xub_StrLen nLen = aFieldSeps.Len(); 333cdf0e10cSrcweir for (xub_StrLen i=0; i<nLen; i++) 334cdf0e10cSrcweir { 335cdf0e10cSrcweir if (i) 336cdf0e10cSrcweir aOutStr += '/'; 337cdf0e10cSrcweir aOutStr += String::CreateFromInt32(aFieldSeps.GetChar(i)); 338cdf0e10cSrcweir } 339cdf0e10cSrcweir if ( bMergeFieldSeps ) 340cdf0e10cSrcweir { 341cdf0e10cSrcweir aOutStr += '/'; 342cdf0e10cSrcweir aOutStr.AppendAscii(pStrMrg); 343cdf0e10cSrcweir } 344cdf0e10cSrcweir } 345cdf0e10cSrcweir 346cdf0e10cSrcweir aOutStr += ','; // Token-Ende 347cdf0e10cSrcweir 348cdf0e10cSrcweir // 349cdf0e10cSrcweir // Text-Trenner 350cdf0e10cSrcweir // 351cdf0e10cSrcweir 352cdf0e10cSrcweir aOutStr += String::CreateFromInt32(cTextSep); 353cdf0e10cSrcweir aOutStr += ','; // Token-Ende 354cdf0e10cSrcweir 355cdf0e10cSrcweir // 356cdf0e10cSrcweir // Zeichensatz 357cdf0e10cSrcweir // 358cdf0e10cSrcweir 359cdf0e10cSrcweir if ( bCharSetSystem ) // force "SYSTEM" 360cdf0e10cSrcweir aOutStr += ScGlobal::GetCharsetString( RTL_TEXTENCODING_DONTKNOW ); 361cdf0e10cSrcweir else 362cdf0e10cSrcweir aOutStr += ScGlobal::GetCharsetString( eCharSet ); 363cdf0e10cSrcweir aOutStr += ','; // Token-Ende 364cdf0e10cSrcweir 365cdf0e10cSrcweir // 366cdf0e10cSrcweir // Startzeile 367cdf0e10cSrcweir // 368cdf0e10cSrcweir 369cdf0e10cSrcweir aOutStr += String::CreateFromInt32(nStartRow); 370cdf0e10cSrcweir aOutStr += ','; // Token-Ende 371cdf0e10cSrcweir 372cdf0e10cSrcweir // 373cdf0e10cSrcweir // Spalten-Infos 374cdf0e10cSrcweir // 375cdf0e10cSrcweir 376cdf0e10cSrcweir DBG_ASSERT( !nInfoCount || (pColStart && pColFormat), "0-Zeiger in ScAsciiOptions" ); 377cdf0e10cSrcweir for (sal_uInt16 nInfo=0; nInfo<nInfoCount; nInfo++) 378cdf0e10cSrcweir { 379cdf0e10cSrcweir if (nInfo) 380cdf0e10cSrcweir aOutStr += '/'; 381cdf0e10cSrcweir aOutStr += String::CreateFromInt32(pColStart[nInfo]); 382cdf0e10cSrcweir aOutStr += '/'; 383cdf0e10cSrcweir aOutStr += String::CreateFromInt32(pColFormat[nInfo]); 384cdf0e10cSrcweir } 385cdf0e10cSrcweir 386cdf0e10cSrcweir // #i112025# the options string is used in macros and linked sheets, 387cdf0e10cSrcweir // so new options must be added at the end, to remain compatible 388cdf0e10cSrcweir 389cdf0e10cSrcweir aOutStr += ','; 390cdf0e10cSrcweir 391cdf0e10cSrcweir // Language 392cdf0e10cSrcweir aOutStr += String::CreateFromInt32(eLang); 393cdf0e10cSrcweir aOutStr += ','; 394cdf0e10cSrcweir 395cdf0e10cSrcweir // Import quoted field as text. 396cdf0e10cSrcweir aOutStr += String::CreateFromAscii(bQuotedFieldAsText ? "true" : "false"); 397cdf0e10cSrcweir aOutStr += ','; 398cdf0e10cSrcweir 399*6ded66c8SMatthias Seidel // Detect special numbers. 400cdf0e10cSrcweir aOutStr += String::CreateFromAscii(bDetectSpecialNumber ? "true" : "false"); 401cdf0e10cSrcweir 402cdf0e10cSrcweir // 9th token is used for "Save as shown" in export options 403cdf0e10cSrcweir 404cdf0e10cSrcweir return aOutStr; 405cdf0e10cSrcweir } 406cdf0e10cSrcweir 407cdf0e10cSrcweir #if 0 408cdf0e10cSrcweir // Code, um die Spalten-Liste aus einem Excel-kompatiblen String zu erzeugen: 409cdf0e10cSrcweir // (im Moment nicht benutzt) 410cdf0e10cSrcweir 411cdf0e10cSrcweir void ScAsciiOptions::InterpretColumnList( const String& rString ) 412cdf0e10cSrcweir { 413cdf0e10cSrcweir // Eingabe ist 1-basiert, pColStart fuer FixedLen ist 0-basiert 414cdf0e10cSrcweir 415cdf0e10cSrcweir // Kommas durch Semikolon ersetzen 416cdf0e10cSrcweir 417cdf0e10cSrcweir String aSemiStr = rString; 418cdf0e10cSrcweir sal_uInt16 nPos = 0; 419cdf0e10cSrcweir do 420cdf0e10cSrcweir nPos = aSemiStr.SearchAndReplace( ',', ';', nPos ); 421cdf0e10cSrcweir while ( nPos != STRING_NOTFOUND ); 422cdf0e10cSrcweir 423cdf0e10cSrcweir // Eintraege sortieren 424cdf0e10cSrcweir 425cdf0e10cSrcweir sal_uInt16 nCount = aSemiStr.GetTokenCount(); 426cdf0e10cSrcweir sal_uInt16* pTemp = new sal_uInt16[nCount+1]; 427cdf0e10cSrcweir pTemp[0] = 1; // erste Spalte faengt immer bei 1 an 428cdf0e10cSrcweir sal_uInt16 nFound = 1; 429cdf0e10cSrcweir sal_uInt16 i,j; 430cdf0e10cSrcweir for (i=0; i<nCount; i++) 431cdf0e10cSrcweir { 432cdf0e10cSrcweir sal_uInt16 nVal = (sal_uInt16) aSemiStr.GetToken(i); 433cdf0e10cSrcweir if (nVal) 434cdf0e10cSrcweir { 435cdf0e10cSrcweir sal_Bool bThere = sal_False; 436cdf0e10cSrcweir nPos = 0; 437cdf0e10cSrcweir for (j=0; j<nFound; j++) 438cdf0e10cSrcweir { 439cdf0e10cSrcweir if ( pTemp[j] == nVal ) 440cdf0e10cSrcweir bThere = sal_True; 441cdf0e10cSrcweir else if ( pTemp[j] < nVal ) 442cdf0e10cSrcweir nPos = j+1; 443cdf0e10cSrcweir } 444cdf0e10cSrcweir if ( !bThere ) 445cdf0e10cSrcweir { 446cdf0e10cSrcweir if ( nPos < nFound ) 447cdf0e10cSrcweir memmove( &pTemp[nPos+1], &pTemp[nPos], (nFound-nPos)*sizeof(sal_uInt16) ); 448cdf0e10cSrcweir pTemp[nPos] = nVal; 449cdf0e10cSrcweir ++nFound; 450cdf0e10cSrcweir } 451cdf0e10cSrcweir } 452cdf0e10cSrcweir } 453cdf0e10cSrcweir 454cdf0e10cSrcweir // Eintraege uebernehmen 455cdf0e10cSrcweir 456cdf0e10cSrcweir delete[] pColStart; 457cdf0e10cSrcweir delete[] pColFormat; 458cdf0e10cSrcweir nInfoCount = nFound; 459cdf0e10cSrcweir if (nInfoCount) 460cdf0e10cSrcweir { 461cdf0e10cSrcweir pColStart = new sal_uInt16[nInfoCount]; 462cdf0e10cSrcweir pColFormat = new sal_uInt8[nInfoCount]; 463cdf0e10cSrcweir for (i=0; i<nInfoCount; i++) 464cdf0e10cSrcweir { 465cdf0e10cSrcweir pColStart[i] = pTemp[i] - 1; 466cdf0e10cSrcweir pColFormat[i] = SC_COL_STANDARD; 467cdf0e10cSrcweir } 468cdf0e10cSrcweir } 469cdf0e10cSrcweir else 470cdf0e10cSrcweir { 471cdf0e10cSrcweir pColStart = NULL; 472cdf0e10cSrcweir pColFormat = NULL; 473cdf0e10cSrcweir } 474cdf0e10cSrcweir 475cdf0e10cSrcweir bFixedLen = sal_True; // sonst macht's keinen Sinn 476cdf0e10cSrcweir 477cdf0e10cSrcweir // aufraeumen 478cdf0e10cSrcweir 479cdf0e10cSrcweir delete[] pTemp; 480cdf0e10cSrcweir } 481cdf0e10cSrcweir #endif 482cdf0e10cSrcweir 483