From bf0d532b3d1cf17d5c6d516319cd71d15f223bc6 Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Mon, 27 Jun 2022 21:06:49 +0800 Subject: [PATCH] [trep-engine] refactor grid data structure functions trep will never insert more than 1 datum in a cell. --- gnucash/report/trep-engine.scm | 39 +++++++++++----------------------- 1 file changed, 12 insertions(+), 27 deletions(-) diff --git a/gnucash/report/trep-engine.scm b/gnucash/report/trep-engine.scm index ec21d6d78c..20d854de2b 100644 --- a/gnucash/report/trep-engine.scm +++ b/gnucash/report/trep-engine.scm @@ -1881,25 +1881,22 @@ be excluded from periodic reporting.") (lambda (cell) (cell-match? cell row col)) grid)) -(define (grid-del grid row col) - ;; grid filter - del all row/col - if #f then delete whole row/col - (filter - (lambda (cell) - (not (cell-match? cell row col))) - grid)) (define (grid-rows grid) (delete-duplicates (map (lambda (cell) (vector-ref cell 0)) grid))) (define (grid-cols grid) (delete-duplicates (map (lambda (cell) (vector-ref cell 1)) grid))) (define (grid-add grid row col data) - ;;misonomer - we don't 'add' to existing data, we delete old data - ;;stored at row/col and add again. this is fine because the grid - ;;should never have duplicate data in the trep. - (set! grid (grid-del grid row col)) - (set! grid (cons (vector row col data) grid)) - grid) -(define (grid->html-table grid list-of-rows list-of-cols) - (define row-average-enabled? (> (length list-of-cols) 1)) + ;; we don't need to check for duplicate cells in a row/col because + ;; in the trep it should never happen. + (cons (vector row col data) grid)) +(define (grid->html-table grid) + (define (html-table grid list-of-rows list-of-cols)))) + (gnc:html-document-add-object! document (grid->html-table grid))) (unless (and subtotal-table? (opt-val pagename-sorting optname-show-subtotals-only))