static void gnc_template_register_save_xfrm_cell (BasicCell * cell, gpointer save_data, gpointer user_data) { SRSaveData *sd = save_data; SplitRegister *reg = user_data; SRInfo *info = gnc_split_register_get_info (reg); Account *template_acc; const GncGUID *acctGUID; kvp_frame *kvpf; Account *acct; g_return_if_fail (gnc_basic_cell_has_name (cell, XFRM_CELL)); /* save the account GncGUID into the kvp_data. */ acct = gnc_split_register_get_account (reg, XFRM_CELL); if (!acct) { PERR ("unknown account"); return; } acctGUID = xaccAccountGetGUID (acct); kvpf = xaccSplitGetSlots (sd->split); kvp_frame_set_slot_path (kvpf, kvp_value_new_guid(acctGUID), GNC_SX_ID, GNC_SX_ACCOUNT, NULL); template_acc = xaccAccountLookup (&info->template_account, gnc_get_current_book ()); /* set the actual account to the fake account for these templates */ xaccAccountInsertSplit (template_acc, sd->split); }
static void gnc_split_register_save_mxfrm_cell (BasicCell * cell, gpointer save_data, gpointer user_data) { SRSaveData *sd = save_data; SplitRegister *reg = user_data; Split * other_split; g_return_if_fail (gnc_basic_cell_has_name (cell, MXFRM_CELL)); other_split = xaccSplitGetOtherSplit (sd->split); /* other_split may be null for two very different reasons: * (1) the parent transaction has three or more splits in it, * and so the "other" split is ambiguous, and thus null. * (2) the parent transaction has only this one split as a child. * and "other" is null because there is no other. * * In the case (2), we want to create the other split, so that * the user's request to transfer actually works out. */ if (!other_split) { other_split = xaccTransGetSplit (sd->trans, 1); if (!other_split) { other_split = xaccMallocSplit (gnc_get_current_book ()); xaccTransAppendSplit (sd->trans, other_split); } } if (other_split) { Account *old_acc; Account *new_acc; /* Do some reparenting. Insertion into new account * will automatically delete from the old account. */ old_acc = xaccSplitGetAccount (other_split); new_acc = gnc_split_register_get_account (reg, MXFRM_CELL); if ((new_acc != NULL) && (old_acc != new_acc)) xaccAccountInsertSplit (new_acc, other_split); } }
/* OK, the handling of transfers gets complicated because it depends * on what was displayed to the user. For a multi-line display, we * just reparent the indicated split. For a two-line display, we want * to reparent the "other" split, but only if there is one. XFRM is * the straight split, MXFRM is the mirrored split. */ static void gnc_split_register_save_xfrm_cell (BasicCell * cell, gpointer save_data, gpointer user_data) { SRSaveData *sd = save_data; SplitRegister *reg = user_data; Account *old_acc; Account *new_acc; g_return_if_fail (gnc_basic_cell_has_name (cell, XFRM_CELL)); old_acc = xaccSplitGetAccount (sd->split); new_acc = gnc_split_register_get_account (reg, XFRM_CELL); if ((new_acc != NULL) && (old_acc != new_acc)) xaccAccountInsertSplit (new_acc, sd->split); }