mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 12:25:53 +00:00
Allow first line of cvs,txt or tab files to be skipped when importing address books, part of bug 180057. r=bienvenu,sr=neil,a=asa
This commit is contained in:
parent
bc88601141
commit
bc274c1b96
@ -49,5 +49,7 @@
|
||||
<!ENTITY fieldMapImport.down.accesskey "D">
|
||||
<!ENTITY fieldMapImport.fieldListTitle "Address Book fields">
|
||||
<!ENTITY fieldMapImport.dataTitle "Record data to import">
|
||||
<!ENTITY fieldMapImport.skipFirstRecord "First record contains field names">
|
||||
<!ENTITY fieldMapImport.skipFirstRecord.accessKey "F">
|
||||
|
||||
|
||||
|
@ -52,9 +52,16 @@ interface nsIMdbRow;
|
||||
interface nsIAbCard;
|
||||
|
||||
|
||||
[scriptable, uuid(1CEB9241-ADC1-11d3-A9C2-00A0CC26DA63)]
|
||||
[scriptable, uuid(0e376da3-e289-4d14-bdec-867764585eb7)]
|
||||
interface nsIImportFieldMap : nsISupports
|
||||
{
|
||||
/*
|
||||
Flag to indicate whether or not to skip the first record,
|
||||
for instance csv files often have field names as the first
|
||||
record
|
||||
*/
|
||||
attribute boolean skipFirstRecord;
|
||||
|
||||
readonly attribute long numMozFields;
|
||||
readonly attribute long mapSize;
|
||||
|
||||
|
@ -8,6 +8,7 @@ var gNextButton;
|
||||
var gMoveUpButton;
|
||||
var gMoveDownButton;
|
||||
var gListbox;
|
||||
var gSkipFirstRecordButton;
|
||||
|
||||
function OnLoadFieldMapImport()
|
||||
{
|
||||
@ -31,6 +32,11 @@ function OnLoadFieldMapImport()
|
||||
gPreviousButton = document.getElementById("previous");
|
||||
gNextButton = document.getElementById("next");
|
||||
gListbox = document.getElementById("fieldList");
|
||||
gSkipFirstRecordButton = document.getElementById("skipFirstRecord");
|
||||
|
||||
// Set the state of the skip first record button
|
||||
gSkipFirstRecordButton.checked = top.fieldMap.skipFirstRecord;
|
||||
|
||||
ListFields();
|
||||
Browse(1);
|
||||
gListbox.selectedItem = gListbox.getItemAtIndex(0);
|
||||
@ -165,6 +171,8 @@ function FieldImportOKButton()
|
||||
top.fieldMap.SetFieldActive( i, (on == "true"));
|
||||
}
|
||||
|
||||
top.fieldMap.skipFirstRecord = gSkipFirstRecordButton.checked;
|
||||
|
||||
top.dialogResult.ok = true;
|
||||
|
||||
return true;
|
||||
|
@ -61,6 +61,12 @@
|
||||
accesskey="&fieldMapImport.next.accesskey;"/>
|
||||
</hbox>
|
||||
|
||||
<hbox align="center">
|
||||
<checkbox id="skipFirstRecord"
|
||||
label="&fieldMapImport.skipFirstRecord;"
|
||||
accesskey="&fieldMapImport.skipFirstRecord.accessKey;"/>
|
||||
</hbox>
|
||||
|
||||
<separator class="thin"/>
|
||||
<description>&fieldMapImport.text;</description>
|
||||
<separator class="thin"/>
|
||||
|
@ -49,5 +49,7 @@
|
||||
<!ENTITY fieldMapImport.down.accesskey "D">
|
||||
<!ENTITY fieldMapImport.fieldListTitle "Address Book fields">
|
||||
<!ENTITY fieldMapImport.dataTitle "Record data to import">
|
||||
<!ENTITY fieldMapImport.skipFirstRecord "First record contains field names">
|
||||
<!ENTITY fieldMapImport.skipFirstRecord.accessKey "F">
|
||||
|
||||
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include "nsImportFieldMap.h"
|
||||
#include "nsImportStringBundle.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsISupportsObsolete.h"
|
||||
|
||||
#include "ImportDebug.h"
|
||||
|
||||
@ -68,6 +69,8 @@ NS_METHOD nsImportFieldMap::Create( nsISupports *aOuter, REFNSIID aIID, void **a
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS1(nsImportFieldMap, nsIImportFieldMap)
|
||||
|
||||
NS_IMPL_GETSET(nsImportFieldMap, SkipFirstRecord, PRBool, m_skipFirstRecord)
|
||||
|
||||
nsImportFieldMap::nsImportFieldMap()
|
||||
{
|
||||
m_numFields = 0;
|
||||
@ -76,6 +79,7 @@ nsImportFieldMap::nsImportFieldMap()
|
||||
m_allocated = 0;
|
||||
// need to init the description array
|
||||
m_mozFieldCount = 0;
|
||||
m_skipFirstRecord = false;
|
||||
nsIStringBundle *pBundle = nsImportStringBundle::GetStringBundleProxy();
|
||||
|
||||
nsString *pStr;
|
||||
|
@ -72,6 +72,7 @@ private:
|
||||
PRInt32 m_allocated;
|
||||
nsVoidArray m_descriptions;
|
||||
PRInt32 m_mozFieldCount;
|
||||
PRBool m_skipFirstRecord;
|
||||
};
|
||||
|
||||
|
||||
|
@ -88,6 +88,18 @@ nsresult nsTextAddress::ImportAddresses( PRBool *pAbort, const PRUnichar *pName,
|
||||
|
||||
PRInt32 loc;
|
||||
PRInt32 lineLen = 0;
|
||||
PRBool skipRecord = PR_FALSE;
|
||||
|
||||
rv = m_fieldMap->GetSkipFirstRecord(&skipRecord);
|
||||
if (NS_FAILED(rv)) {
|
||||
IMPORT_LOG0("*** Error checking to see if we should skip the first record\n");
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Skip the first record if the user has requested it.
|
||||
if (skipRecord)
|
||||
rv = ReadRecord( pSrc, pLine, kTextAddressBufferSz, m_delim, &lineLen);
|
||||
|
||||
while (!(*pAbort) && !eof && NS_SUCCEEDED( rv)) {
|
||||
rv = pSrc->Tell( &loc);
|
||||
if (NS_SUCCEEDED( rv) && pProgress)
|
||||
|
@ -773,6 +773,14 @@ NS_IMETHODIMP ImportAddressImpl::InitFieldMap(nsIFileSpec *location, nsIImportFi
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Now also get the last used skip first record value.
|
||||
PRBool skipFirstRecord = PR_FALSE;
|
||||
rv = prefs->GetBoolPref("mailnews.import.text.skipfirstrecord", &skipFirstRecord);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
fieldMap->SetSkipFirstRecord(skipFirstRecord);
|
||||
}
|
||||
}
|
||||
|
||||
return( NS_OK);
|
||||
@ -820,4 +828,12 @@ void ImportAddressImpl::SaveFieldMap( nsIImportFieldMap *pMap)
|
||||
rv = prefs->SetCharPref( "mailnews.import.text.fieldmap", str.get());
|
||||
}
|
||||
}
|
||||
|
||||
// Now also save last used skip first record value.
|
||||
PRBool skipFirstRecord = PR_FALSE;
|
||||
rv = pMap->GetSkipFirstRecord(&skipFirstRecord);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
prefs->SetBoolPref("mailnews.import.text.skipfirstrecord", skipFirstRecord);
|
||||
}
|
||||
}
|
||||
|
@ -641,6 +641,10 @@ pref("mail.password_protect_local_cache", false);
|
||||
// overridden by stand alone mail
|
||||
pref("mail.standalone", false);
|
||||
|
||||
// import option to skip the first record, recorded so that we can save
|
||||
// the users last used preference.
|
||||
pref("mailnews.import.text.skipfirstrecord", true);
|
||||
|
||||
#ifdef XP_WIN
|
||||
// Unread mail count timer. Value to be specified in seconds
|
||||
// default is 5 minutes, i.e., 5 * 60 seconds = 300
|
||||
|
Loading…
Reference in New Issue
Block a user