mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Bug#119078: promote register parse errors to the user.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@13856 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
15
ChangeLog
15
ChangeLog
@@ -1,3 +1,18 @@
|
||||
2006-04-25 Joshua Sled <jsled@asynchronous.org>
|
||||
Bug#119078: promote register parse errors to the user.
|
||||
|
||||
* src/register/register-core/pricecell.c (gnc_price_cell_parse):
|
||||
Return error if cell text isn't parseable via expression parser.
|
||||
|
||||
* src/register/register-core/pricecell.c (gnc_price_cell_leave):
|
||||
* src/register/register-core/formulacell.c (gnc_formula_cell_leave):
|
||||
Promote error to UI if cell text isn't parseable.
|
||||
|
||||
* src/register/register-core/table-allgui.c (gnc_table_save_cells):
|
||||
* src/register/ledger-core/split-register-load.c
|
||||
(gnc_split_register_load): Don't -- seemingly unnecessarily --
|
||||
call [...]leave_update here.
|
||||
|
||||
2006-04-25 David Hampton <hampton@employees.org>
|
||||
|
||||
* src/gnome/gnc-plugin-page-register.c: Don't try to update the
|
||||
|
||||
@@ -259,7 +259,7 @@ gnc_split_register_load (SplitRegister *reg, GList * slist,
|
||||
|
||||
table = reg->table;
|
||||
|
||||
gnc_table_leave_update (table, table->current_cursor_loc);
|
||||
// gnc_table_leave_update (table, table->current_cursor_loc);
|
||||
|
||||
multi_line = (reg->style == REG_STYLE_JOURNAL);
|
||||
dynamic = (reg->style == REG_STYLE_AUTO_LEDGER);
|
||||
|
||||
@@ -21,8 +21,12 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
#include "gnc-exp-parser.h"
|
||||
#include "gnc-engine.h"
|
||||
#include "gnc-ui-util.h"
|
||||
#include "gnc-ui.h"
|
||||
|
||||
#include "basiccell.h"
|
||||
#include "formulacell.h"
|
||||
@@ -36,9 +40,7 @@ static gboolean gnc_formula_cell_enter( BasicCell *_cell,
|
||||
int *start_selection,
|
||||
int *end_selection );
|
||||
|
||||
#if 0
|
||||
static void gnc_formula_cell_leave( BasicCell *_cell );
|
||||
#endif
|
||||
|
||||
static void gnc_formula_cell_modify_verify( BasicCell *_cell,
|
||||
const char *change,
|
||||
@@ -73,6 +75,7 @@ gnc_formula_cell_init( FormulaCell *fc )
|
||||
fc->cell.enter_cell = gnc_formula_cell_enter;
|
||||
fc->cell.modify_verify = gnc_formula_cell_modify_verify;
|
||||
fc->cell.set_value = gnc_formula_cell_set_value_internal;
|
||||
fc->cell.leave_cell = gnc_formula_cell_leave;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -97,18 +100,26 @@ gnc_formula_cell_enter( BasicCell *_cell,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static
|
||||
void
|
||||
gnc_formula_cell_leave( BasicCell *_cell )
|
||||
static void
|
||||
gnc_formula_cell_leave(BasicCell *_cell)
|
||||
{
|
||||
char *str;
|
||||
FormulaCell *fc = (FormulaCell*)_cell;
|
||||
DEBUG( "leaving.." );
|
||||
str = fc->cell.value;
|
||||
{
|
||||
char *error_location = NULL;
|
||||
gnc_numeric amount;
|
||||
if (str != NULL
|
||||
&& strlen(str) != 0
|
||||
&& !gnc_exp_parser_parse(str, &amount, &error_location))
|
||||
{
|
||||
gnc_warning_dialog(NULL, _("An error occurred while processing %s."),
|
||||
str);//, (error_location - str));
|
||||
}
|
||||
}
|
||||
|
||||
gnc_basic_cell_set_value_internal( &fc->cell, str );
|
||||
}
|
||||
#endif
|
||||
|
||||
static
|
||||
void
|
||||
|
||||
@@ -35,12 +35,14 @@
|
||||
#include "config.h"
|
||||
|
||||
#include <glib.h>
|
||||
#include <glib/gi18n.h>
|
||||
#include <locale.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "gnc-exp-parser.h"
|
||||
#include "gnc-engine.h"
|
||||
#include "gnc-ui-util.h"
|
||||
#include "gnc-ui.h"
|
||||
|
||||
#include "basiccell.h"
|
||||
#include "pricecell.h"
|
||||
@@ -119,7 +121,7 @@ gnc_price_cell_modify_verify (BasicCell *_cell,
|
||||
cell->need_to_parse = TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
static gint
|
||||
gnc_price_cell_parse (PriceCell *cell, gboolean update_value)
|
||||
{
|
||||
const char *newval;
|
||||
@@ -127,41 +129,58 @@ gnc_price_cell_parse (PriceCell *cell, gboolean update_value)
|
||||
gnc_numeric amount;
|
||||
|
||||
if (!cell->need_to_parse)
|
||||
return;
|
||||
return -1;
|
||||
|
||||
oldval = cell->cell.value;
|
||||
if (oldval == NULL)
|
||||
oldval = "";
|
||||
|
||||
if (gnc_exp_parser_parse (cell->cell.value, &amount, NULL))
|
||||
{
|
||||
if (cell->fraction > 0)
|
||||
amount = gnc_numeric_convert (amount, cell->fraction, GNC_RND_ROUND);
|
||||
char *err_location = NULL;
|
||||
if (strlen(g_strstrip(cell->cell.value)) == 0)
|
||||
{
|
||||
cell->amount = gnc_numeric_zero ();
|
||||
}
|
||||
else if (gnc_exp_parser_parse (cell->cell.value, &amount, &err_location))
|
||||
{
|
||||
if (cell->fraction > 0)
|
||||
amount = gnc_numeric_convert (amount, cell->fraction, GNC_RND_ROUND);
|
||||
|
||||
cell->amount = amount;
|
||||
cell->amount = amount;
|
||||
}
|
||||
else
|
||||
{
|
||||
return (err_location - cell->cell.value);
|
||||
}
|
||||
}
|
||||
else
|
||||
cell->amount = gnc_numeric_zero ();
|
||||
|
||||
if (!update_value)
|
||||
return;
|
||||
return -1;
|
||||
|
||||
newval = gnc_price_cell_print_value (cell);
|
||||
|
||||
/* If they are identical do nothing */
|
||||
if (strcmp(newval, oldval) == 0)
|
||||
return;
|
||||
return -1;
|
||||
|
||||
/* Otherwise, change it */
|
||||
gnc_basic_cell_set_value_internal (&cell->cell, newval);
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_price_cell_leave (BasicCell *_cell)
|
||||
{
|
||||
gint error_position = -1;
|
||||
PriceCell *cell = (PriceCell *) _cell;
|
||||
|
||||
gnc_price_cell_parse (cell, TRUE);
|
||||
error_position = gnc_price_cell_parse (cell, TRUE);
|
||||
if (error_position != -1)
|
||||
{
|
||||
gnc_warning_dialog(NULL, _("An error occurred while processing %s."),
|
||||
cell->cell.value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
BasicCell *
|
||||
|
||||
@@ -564,7 +564,7 @@ gnc_table_save_cells (Table *table, gpointer save_data)
|
||||
if (gnc_table_model_read_only (table->model))
|
||||
return;
|
||||
|
||||
gnc_table_leave_update (table, table->current_cursor_loc);
|
||||
// gnc_table_leave_update (table, table->current_cursor_loc);
|
||||
|
||||
save_handler = gnc_table_model_get_pre_save_handler (table->model);
|
||||
if (save_handler)
|
||||
|
||||
Reference in New Issue
Block a user