/************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: asciiopt.cxx,v $ * $Revision: 1.25 $ * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License version 3 * only, as published by the Free Software Foundation. * * OpenOffice.org is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License version 3 for more details * (a copy is included in the LICENSE file that accompanied this code). * * You should have received a copy of the GNU Lesser General Public License * version 3 along with OpenOffice.org. If not, see * * for a copy of the LGPLv3 License. * ************************************************************************/ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sc.hxx" #include "global.hxx" #include "scresid.hxx" #include "impex.hxx" #include "asciiopt.hxx" #include "asciiopt.hrc" #include #include #include // ause #include "editutil.hxx" // ============================================================================ static const sal_Char __FAR_DATA pStrFix[] = "FIX"; static const sal_Char __FAR_DATA pStrMrg[] = "MRG"; // ============================================================================ ScAsciiOptions::ScAsciiOptions() : bFixedLen ( FALSE ), aFieldSeps ( ';' ), bMergeFieldSeps ( FALSE ), cTextSep ( cDefaultTextSep ), eCharSet ( gsl_getSystemTextEncoding() ), bCharSetSystem ( FALSE ), nStartRow ( 1 ), nInfoCount ( 0 ), pColStart ( NULL ), pColFormat ( NULL ) { } ScAsciiOptions::ScAsciiOptions(const ScAsciiOptions& rOpt) : bFixedLen ( rOpt.bFixedLen ), aFieldSeps ( rOpt.aFieldSeps ), bMergeFieldSeps ( rOpt.bMergeFieldSeps ), cTextSep ( rOpt.cTextSep ), eCharSet ( rOpt.eCharSet ), bCharSetSystem ( rOpt.bCharSetSystem ), nStartRow ( rOpt.nStartRow ), nInfoCount ( rOpt.nInfoCount ) { if (nInfoCount) { pColStart = new xub_StrLen[nInfoCount]; pColFormat = new BYTE[nInfoCount]; for (USHORT i=0; i( rDataVec.size() ); if( nInfoCount ) { pColStart = new xub_StrLen[ nInfoCount ]; pColFormat = new sal_uInt8[ nInfoCount ]; for( sal_uInt16 nIx = 0; nIx < nInfoCount; ++nIx ) { pColStart[ nIx ] = rDataVec[ nIx ].mnIndex; pColFormat[ nIx ] = rDataVec[ nIx ].mnType; } } } ScAsciiOptions& ScAsciiOptions::operator=( const ScAsciiOptions& rCpy ) { SetColInfo( rCpy.nInfoCount, rCpy.pColStart, rCpy.pColFormat ); bFixedLen = rCpy.bFixedLen; aFieldSeps = rCpy.aFieldSeps; bMergeFieldSeps = rCpy.bMergeFieldSeps; cTextSep = rCpy.cTextSep; eCharSet = rCpy.eCharSet; bCharSetSystem = rCpy.bCharSetSystem; nStartRow = rCpy.nStartRow; return *this; } BOOL ScAsciiOptions::operator==( const ScAsciiOptions& rCmp ) const { if ( bFixedLen == rCmp.bFixedLen && aFieldSeps == rCmp.aFieldSeps && bMergeFieldSeps == rCmp.bMergeFieldSeps && cTextSep == rCmp.cTextSep && eCharSet == rCmp.eCharSet && bCharSetSystem == rCmp.bCharSetSystem && nStartRow == rCmp.nStartRow && nInfoCount == rCmp.nInfoCount ) { DBG_ASSERT( !nInfoCount || (pColStart && pColFormat && rCmp.pColStart && rCmp.pColFormat), "0-Zeiger in ScAsciiOptions" ); for (USHORT i=0; i= 1 ) { bFixedLen = bMergeFieldSeps = FALSE; aFieldSeps.Erase(); aToken = rString.GetToken(0,','); if ( aToken.EqualsAscii(pStrFix) ) bFixedLen = TRUE; nSub = aToken.GetTokenCount('/'); for ( i=0; i= 2 ) { aToken = rString.GetToken(1,','); sal_Int32 nVal = aToken.ToInt32(); cTextSep = (sal_Unicode) nVal; } // // Zeichensatz // if ( nCount >= 3 ) { aToken = rString.GetToken(2,','); eCharSet = ScGlobal::GetCharsetValue( aToken ); } // // Startzeile // if ( nCount >= 4 ) { aToken = rString.GetToken(3,','); nStartRow = aToken.ToInt32(); } // // Spalten-Infos // if ( nCount >= 5 ) { delete[] pColStart; delete[] pColFormat; aToken = rString.GetToken(4,','); nSub = aToken.GetTokenCount('/'); nInfoCount = nSub / 2; if (nInfoCount) { pColStart = new xub_StrLen[nInfoCount]; pColFormat = new BYTE[nInfoCount]; for (USHORT nInfo=0; nInfo