Bug 182128 Edit Card, Notes on several lines appear on one after export/import in text format (txt, tab, csv). r=Neil,sr=bienvenu

This commit is contained in:
bugzilla%standard8.demon.co.uk 2007-02-10 09:45:31 +00:00
Родитель 14281d618d
Коммит c8b56bd74b
3 изменённых файлов: 10 добавлений и 29 удалений

Просмотреть файл

@ -607,32 +607,17 @@ nsAddressBook::ExportDirectoryToDelimitedText(nsIAbDirectory *aDirectory, const
if (!needsQuotes && (newValue.FindChar(',') != kNotFound || newValue.FindChar('\x09') != kNotFound))
needsQuotes = PR_TRUE;
// Make sure we quote if containing CR/LF.
if (newValue.FindChar(nsCRT::CR) != kNotFound ||
newValue.FindChar(nsCRT::LF) != kNotFound)
needsQuotes = PR_TRUE;
if (needsQuotes)
{
newValue.Insert(NS_LITERAL_STRING("\""), 0);
newValue.AppendLiteral("\"");
}
// For notes, make sure CR/LF is converted to spaces
// to avoid creating multiple lines for a single card.
//
// the import code expects .txt, .tab, .csv files to
// have non-ASCII data in the system charset
//
// note, this means if you machine is set to US-ASCII
// but you have cards with Japanese characters
// you will lose data when exporting.
//
// the solution is to export / import as LDIF.
// non-ASCII data is treated as base64 encoded UTF-8 in LDIF
if (!strcmp(EXPORT_ATTRIBUTES_TABLE[i].abColName, kNotesColumn))
{
if (!newValue.IsEmpty())
{
newValue.ReplaceChar(nsCRT::CR, ' ');
newValue.ReplaceChar(nsCRT::LF, ' ');
}
}
rv = importService->SystemStringFromUnicode(newValue.get(), valueCStr);
if (NS_FAILED(rv)) {

Просмотреть файл

@ -47,6 +47,7 @@
#include "TextDebugLog.h"
#include "plstr.h"
#include "nsCRT.h"
#define kWhitespace " \t\b\r\n"
@ -163,7 +164,10 @@ nsresult nsTextAddress::ReadRecord(nsILineInputStream *aLineStream, nsCString &a
// Read the line and append it
rv = aLineStream->ReadLine(line, &more);
if (NS_SUCCEEDED(rv)) {
aLine += line;
if (!aLine.IsEmpty())
aLine.AppendLiteral(NS_LINEBREAK);
aLine.Append(line);
numQuotes += line.CountChar('"');
}
}
@ -360,13 +364,6 @@ PRBool nsTextAddress::GetField( const char *pLine, PRInt32 maxLen, PRInt32 index
return( result);
}
void nsTextAddress::SanitizeSingleLine( nsCString& val)
{
val.ReplaceSubstring( "\x0D\x0A", ", ");
val.ReplaceChar( 13, ' ');
val.ReplaceChar( 10, ' ');
}
nsresult nsTextAddress::DetermineDelim(nsIFile *aSrc)
{
nsCOMPtr<nsIInputStream> inputStream;

Просмотреть файл

@ -71,7 +71,6 @@ private:
nsresult ProcessLine(const char *pLine, PRInt32 len, nsString& errors);
static PRInt32 CountFields(const char *pLine, PRInt32 maxLen, char delim);
static void SanitizeSingleLine( nsCString& val);
static nsresult ReadRecord(nsILineInputStream *pSrc, nsCString &aLine, char delim, PRBool *aMore);
char m_delim;