diff --git a/gnucash/import-export/customer-import/dialog-customer-import-gui.c b/gnucash/import-export/customer-import/dialog-customer-import-gui.c index 52937211b9..c2308de055 100644 --- a/gnucash/import-export/customer-import/dialog-customer-import-gui.c +++ b/gnucash/import-export/customer-import/dialog-customer-import-gui.c @@ -109,7 +109,7 @@ gnc_plugin_customer_import_showGUI(GtkWindow *parent) gtk_window_set_transient_for (GTK_WINDOW (gui->dialog), parent); - gui->regexp = g_string_new ( "^(?[^;]+);(?[^;]*);(?[^;]+);(?[^;]+);?(?[^;]*);?(?[^;]*);?(?[^;]*);?(?[^;]*);?(?[^;]*);?(?[^;]*);?(?[^;]*);?(?[^;]*);?(?[^;]*);?(?[^;]*);?(?[^;]*);?(?[^;]*);?(?[^;]*);?(?[^;]*)"); + gui->regexp = g_string_new ( "^(\\x{FEFF})?(?[^;]*);(?[^;]*);(?[^;]*);(?[^;]*);(?[^;]*);(?[^;]*);(?[^;]*);(?[^;]*);(?[^;]*);(?[^;]*);(?[^;]*);(?[^;]*);(?[^;]*);(?[^;]*);(?[^;]*);(?[^;]*);(?[^;]*);(?[^;]*);(?[^;]*)$"); gui->book = gnc_get_current_book(); // create model and bind to view @@ -284,7 +284,7 @@ void gnc_customer_import_gui_option1_cb (GtkWidget *widget, gpointer data) CustomerImportGui *gui = data; if (!gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(widget) )) return; - g_string_assign (gui->regexp, "^(?[^;]*);(?[^;]*);(?[^;]*);(?[^;]*);?(?[^;]*);?(?[^;]*);?(?[^;]*);?(?[^;]*);?(?[^;]*);?(?[^;]*);?(?[^;]*);?(?[^;]*);?(?[^;]*);?(?[^;]*);?(?[^;]*);?(?[^;]*);?(?[^;]*);(?[^;]*);(?[^;]*)"); //;(?[^;]*);(?[^;]*);(?[^;]*)$"); + g_string_assign (gui->regexp, "^(\\x{FEFF})?(?[^;]*);(?[^;]*);(?[^;]*);(?[^;]*);(?[^;]*);(?[^;]*);(?[^;]*);(?[^;]*);(?[^;]*);(?[^;]*);(?[^;]*);(?[^;]*);(?[^;]*);(?[^;]*);(?[^;]*);(?[^;]*);(?[^;]*);(?[^;]*);(?[^;]*)$"); gnc_customer_import_gui_filenameChanged_cb (gui->entryFilename, gui); } // Comma separated. @@ -293,7 +293,7 @@ void gnc_customer_import_gui_option2_cb (GtkWidget *widget, gpointer data) CustomerImportGui *gui = data; if (!gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(widget) )) return; - g_string_assign (gui->regexp, "^(?[^,]*),(?[^,]*),(?[^,]*),(?[^,]*),?(?[^,]*),?(?[^,]*),?(?[^,]*),?(?[^,]*),?(?[^,]*),?(?[^,]*),?(?[^,]*),?(?[^,]*),?(?[^,]*),?(?[^,]*),?(?[^,]*),?(?[^,]*),?(?[^,]*),(?[^,]*),(?[^,]*)"); //,(?[^,]*),(?[^,]*),(?[^,]*)$"); + g_string_assign (gui->regexp, "^(\\x{FEFF})?(?[^,]*),(?[^,]*),(?[^,]*),(?[^,]*),(?[^,]*),(?[^,]*),(?[^,]*),(?[^,]*),(?[^,]*),(?[^,]*),(?[^,]*),(?[^,]*),(?[^,]*),(?[^,]*),(?[^,]*),(?[^,]*),(?[^,]*),(?[^,]*),(?[^,]*)$"); gnc_customer_import_gui_filenameChanged_cb (gui->entryFilename, gui); } // Semicolon separated with quoted strings. @@ -302,8 +302,7 @@ void gnc_customer_import_gui_option3_cb (GtkWidget *widget, gpointer data) CustomerImportGui *gui = data; if (!gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(widget) )) return; - //g_string_assign (gui->regexp, "^((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\")$"); - g_string_assign (gui->regexp, "^((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\")$"); + g_string_assign (gui->regexp, "^(\\x{FEFF})?((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^;]*)|\"(?[^\"]*)\")$"); gnc_customer_import_gui_filenameChanged_cb (gui->entryFilename, gui); } // Comma separated with quoted strings. @@ -312,8 +311,7 @@ void gnc_customer_import_gui_option4_cb (GtkWidget *widget, gpointer data) CustomerImportGui *gui = data; if (!gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(widget) )) return; - //g_string_assign (gui->regexp, "^(?[^,]*),(?[^,]*),(?[^,]*),(?[^,]*),?(?[^,]*),?(?[^,]*),?(?[^,]*),?(?[^,]*),?(?[^,]*),?(?[^,]*),?(?[^,]*),?(?[^,]*),?(?[^,]*),?(?[^,]*),?(?[^,]*),?(?[^,]*),?(?[^,]*),(?[^,]*),(?[^,]*)"); //,(?[^,]*),(?[^,]*),(?[^,]*)$"); - g_string_assign (gui->regexp, "^((?[^\",]*)|\"(?[^\"]*)\"),((?[^\",]*)|\"(?[^\"]*)\"),((?[^\",]*)|\"(?[^\"]*)\"),((?[^\",]*)|\"(?[^\"]*)\"),((?[^\",]*)|\"(?[^\"]*)\"),((?[^\",]*)|\"(?[^\"]*)\"),((?[^\",]*)|\"(?[^\"]*)\"),((?[^\",]*)|\"(?[^\"]*)\"),((?[^\",]*)|\"(?[^\"]*)\"),((?[^\",]*)|\"(?[^\"]*)\"),((?[^\",]*)|\"(?[^\"]*)\"),((?[^\",]*)|\"(?[^\"]*)\"),((?[^\",]*)|\"(?[^\"]*)\"),((?[^\",]*)|\"(?[^\"]*)\"),((?[^\",]*)|\"(?[^\"]*)\"),((?[^\",]*)|\"(?[^\"]*)\"),((?[^\",]*)|\"(?[^\"]*)\"),((?[^\",]*)|\"(?[^\"]*)\"),((?[^\",]*)|\"(?[^\"]*)\")$"); + g_string_assign (gui->regexp, "^(\\x{FEFF})?((?[^\",]*)|\"(?[^\"]*)\"),((?[^\",]*)|\"(?[^\"]*)\"),((?[^\",]*)|\"(?[^\"]*)\"),((?[^\",]*)|\"(?[^\"]*)\"),((?[^\",]*)|\"(?[^\"]*)\"),((?[^\",]*)|\"(?[^\"]*)\"),((?[^\",]*)|\"(?[^\"]*)\"),((?[^\",]*)|\"(?[^\"]*)\"),((?[^\",]*)|\"(?[^\"]*)\"),((?[^\",]*)|\"(?[^\"]*)\"),((?[^\",]*)|\"(?[^\"]*)\"),((?[^\",]*)|\"(?[^\"]*)\"),((?[^\",]*)|\"(?[^\"]*)\"),((?[^\",]*)|\"(?[^\"]*)\"),((?[^\",]*)|\"(?[^\"]*)\"),((?[^\",]*)|\"(?[^\"]*)\"),((?[^\",]*)|\"(?[^\"]*)\"),((?[^\",]*)|\"(?[^\"]*)\"),((?[^\",]*)|\"(?[^\"]*)\")$"); gnc_customer_import_gui_filenameChanged_cb (gui->entryFilename, gui); } void gnc_customer_import_gui_option5_cb (GtkWidget *widget, gpointer data) diff --git a/gnucash/import-export/customer-import/dialog-customer-import.c b/gnucash/import-export/customer-import/dialog-customer-import.c index 758ce8c674..322a59de69 100644 --- a/gnucash/import-export/customer-import/dialog-customer-import.c +++ b/gnucash/import-export/customer-import/dialog-customer-import.c @@ -201,9 +201,7 @@ gnc_customer_import_fix_customers (GtkListStore *store, guint *fixed, guint *del { GtkTreeIter iter; gboolean valid; - gchar *company, *name, *addr1, *addr2, *addr3, *addr4, *phone, *fax, *email, - *notes, *shipname, *shipaddr1, *shipaddr2, *shipaddr3, *shipaddr4, - *shipphone, *shipfax, *shipemail; + gchar *company, *name, *addr1, *addr2, *addr3, *addr4; guint dummy; // allow the call to this function with only GtkListeStore* specified @@ -226,26 +224,17 @@ gnc_customer_import_fix_customers (GtkListStore *store, guint *fixed, guint *del CI_ADDR2, &addr2, CI_ADDR3, &addr3, CI_ADDR4, &addr4, - CI_PHONE, &phone, - CI_FAX, &fax, - CI_EMAIL, &email, - CI_NOTES, ¬es, - CI_SHIPNAME, &shipname, - CI_SHIPADDR1, &shipaddr1, - CI_SHIPADDR2, &shipaddr2, - CI_SHIPADDR3, &shipaddr3, - CI_SHIPADDR4, &shipaddr4, - CI_SHIPPHONE, &shipphone, - CI_SHIPFAX, &shipfax, - CI_SHIPEMAIL, &shipemail, -1); + // Company name is mandatory. + // If not provided, default the company name to the value of the field name. if (strlen(company) == 0) { + //But if the field name is also blank, then delete the row. if (strlen(name) == 0) { // no fix possible -> delete row - gtk_list_store_remove (store, &iter); + valid = gtk_list_store_remove (store, &iter); (*deleted)++; continue; } @@ -257,24 +246,21 @@ gnc_customer_import_fix_customers (GtkListStore *store, guint *fixed, guint *del } } + // At least one of the address fields must have a value. + // If not, then delete the row. + if (strlen(addr1) == 0 && strlen(addr2) == 0 && strlen(addr3) == 0 && strlen(addr4) == 0) + { + valid = gtk_list_store_remove (store, &iter); + (*deleted)++; + continue; + } + g_free (company); g_free (name); g_free (addr1); g_free (addr2); g_free (addr3); g_free (addr4); - g_free (phone); - g_free (fax); - g_free (email); - g_free (notes); - g_free (shipname); - g_free (shipaddr1); - g_free (shipaddr2); - g_free (shipaddr3); - g_free (shipaddr4); - g_free (shipphone); - g_free (shipfax); - g_free (shipemail); valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(store), &iter); }