Fix budget report so that it uses stylesheet tags so that fonts can be controlled

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18213 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Phil Longstaff 2009-07-17 22:36:53 +00:00
parent 9d962c9774
commit fe0c1f1f85
3 changed files with 82 additions and 41 deletions

View File

@ -424,31 +424,69 @@
;; otherwise, append all remaining objects to the existing cell ;; otherwise, append all remaining objects to the existing cell
(define (gnc:html-table-set-cell! table row col . objects) (define (gnc:html-table-set-cell! table row col . objects)
(let ((rowdata #f) (let ((rowdata #f)
(row-loc #f) (row-loc #f)
(l (length (gnc:html-table-data table))) (l (length (gnc:html-table-data table)))
(objs (length objects)) (objs (length objects))
) )
;; ensure the row-data is there ;; ensure the row-data is there
(if (>= row l) (if (>= row l)
(begin (begin
(let loop ((i l)) (let loop ((i l))
(gnc:html-table-append-row! table (list)) (gnc:html-table-append-row! table (list))
(if (< i row) (if (< i row)
(loop (+ i 1)))) (loop (+ i 1))))
(set! l (gnc:html-table-num-rows table)) (set! l (gnc:html-table-num-rows table))
(set! row-loc (- (- l 1) row)) (set! row-loc (- (- l 1) row))
(set! rowdata (list))) (set! rowdata (list)))
(begin (begin
(set! row-loc (- (- l 1) row)) (set! row-loc (- (- l 1) row))
(set! rowdata (list-ref (gnc:html-table-data table) row-loc)))) (set! rowdata (list-ref (gnc:html-table-data table) row-loc))))
;; make a table-cell and set the data ;; make a table-cell and set the data
(let* ((tc (gnc:make-html-table-cell)) (let* ((tc (gnc:make-html-table-cell))
(first (car objects))) (first (car objects)))
(if (and (equal? objs 1) (gnc:html-table-cell? first)) (if (and (equal? objs 1) (gnc:html-table-cell? first))
(set! tc first) (set! tc first)
(apply gnc:html-table-cell-append-objects! tc objects) (apply gnc:html-table-cell-append-objects! tc objects)
) )
(set! rowdata (list-set-safe! rowdata col tc))
;; add the row-data back to the table
(gnc:html-table-set-data!
table (list-set-safe!
(gnc:html-table-data table)
row-loc rowdata)))))
;; if the 4th arg is a cell, overwrite the existing cell,
;; otherwise, append all remaining objects to the existing cell
(define (gnc:html-table-set-cell/tag! table row col tag . objects)
(let ((rowdata #f)
(row-loc #f)
(l (length (gnc:html-table-data table)))
(num-objs (length objects))
)
;; ensure the row-data is there
(if (>= row l)
(begin
(let loop ((i l))
(gnc:html-table-append-row! table (list))
(if (< i row)
(loop (+ i 1))))
(set! l (gnc:html-table-num-rows table))
(set! row-loc (- (- l 1) row))
(set! rowdata (list)))
(begin
(set! row-loc (- (- l 1) row))
(set! rowdata (list-ref (gnc:html-table-data table) row-loc))))
;; make a table-cell and set the data
(let* ((tc (gnc:make-html-table-cell))
(first (car objects)))
(if (and (equal? num-objs 1) (gnc:html-table-cell? first))
(set! tc first)
(apply gnc:html-table-cell-append-objects! tc objects)
)
(gnc:html-table-cell-set-tag! tc tag)
(set! rowdata (list-set-safe! rowdata col tc)) (set! rowdata (list-set-safe! rowdata col tc))
;; add the row-data back to the table ;; add the row-data back to the table

View File

@ -580,6 +580,7 @@
(export gnc:html-table-prepend-row!) (export gnc:html-table-prepend-row!)
(export gnc:html-table-get-cell) (export gnc:html-table-get-cell)
(export gnc:html-table-set-cell!) (export gnc:html-table-set-cell!)
(export gnc:html-table-set-cell/tag!)
(export gnc:html-table-append-column!) (export gnc:html-table-append-column!)
(export gnc:html-table-prepend-column!) (export gnc:html-table-prepend-column!)
(export gnc:html-table-merge) (export gnc:html-table-merge)

View File

@ -195,22 +195,22 @@
(set! act-total (gnc-numeric-add act-total act-numeric-val GNC-DENOM-AUTO GNC-RND-ROUND)) (set! act-total (gnc-numeric-add act-total act-numeric-val GNC-DENOM-AUTO GNC-RND-ROUND))
(if show-budget? (if show-budget?
(begin (begin
(gnc:html-table-set-cell! (gnc:html-table-set-cell/tag!
html-table rownum current-col bgt-val) html-table rownum current-col "number-cell" bgt-val)
(set! current-col (+ current-col 1)) (set! current-col (+ current-col 1))
) )
) )
(if show-actual? (if show-actual?
(begin (begin
(gnc:html-table-set-cell! (gnc:html-table-set-cell/tag!
html-table rownum current-col act-val) html-table rownum current-col "number-cell" act-val)
(set! current-col (+ current-col 1)) (set! current-col (+ current-col 1))
) )
) )
(if show-diff? (if show-diff?
(begin (begin
(gnc:html-table-set-cell! (gnc:html-table-set-cell/tag!
html-table rownum current-col dif-val) html-table rownum current-col "number-cell" dif-val)
(set! current-col (+ current-col 1)) (set! current-col (+ current-col 1))
) )
) )
@ -268,29 +268,30 @@
;; make the column headers ;; make the column headers
(while (< period num-periods) (while (< period num-periods)
(let* ((date (gnc-budget-get-period-start-date budget period))) (let* ((date (gnc-budget-get-period-start-date budget period)))
(gnc:html-table-set-cell! (gnc:html-table-set-cell/tag!
html-table 0 (if show-diff? (+ current-col 1) current-col) (gnc-print-date date)) html-table 0 (if show-diff? (+ current-col 1) current-col) "centered-label-cell"
(gnc-print-date date))
(if show-budget? (if show-budget?
(begin (begin
(gnc:html-table-set-cell! (gnc:html-table-set-cell/tag!
html-table 1 html-table 1 current-col "centered-label-cell"
current-col (_ "Bgt")) ;; Translators: Abbreviation for "Budget" (_ "Bgt")) ;; Translators: Abbreviation for "Budget"
(set! current-col (+ current-col 1)) (set! current-col (+ current-col 1))
) )
) )
(if show-actual? (if show-actual?
(begin (begin
(gnc:html-table-set-cell! (gnc:html-table-set-cell/tag!
html-table 1 html-table 1 current-col "centered-label-cell"
current-col (_ "Act")) ;; Translators: Abbreviation for "Actual" (_ "Act")) ;; Translators: Abbreviation for "Actual"
(set! current-col (+ current-col 1)) (set! current-col (+ current-col 1))
) )
) )
(if show-diff? (if show-diff?
(begin (begin
(gnc:html-table-set-cell! (gnc:html-table-set-cell/tag!
html-table 1 html-table 1 current-col "centered-label-cell"
current-col (_ "Diff")) ;; Translators: Abbrevation for "Difference" (_ "Diff")) ;; Translators: Abbrevation for "Difference"
(set! current-col (+ current-col 1)) (set! current-col (+ current-col 1))
) )
) )
@ -299,29 +300,30 @@
) )
(if show-totalcol? (if show-totalcol?
(begin (begin
(gnc:html-table-set-cell! (gnc:html-table-set-cell/tag!
html-table 0 (if show-diff? (+ current-col 1) current-col) "Total") html-table 0 (if show-diff? (+ current-col 1) current-col) "centered-label-cell"
"Total")
(if show-budget? (if show-budget?
(begin (begin
(gnc:html-table-set-cell! (gnc:html-table-set-cell/tag!
html-table 1 html-table 1 current-col "centered-label-cell"
current-col (_ "Bgt")) ;; Translators: Abbreviation for "Budget" (_ "Bgt")) ;; Translators: Abbreviation for "Budget"
(set! current-col (+ current-col 1)) (set! current-col (+ current-col 1))
) )
) )
(if show-actual? (if show-actual?
(begin (begin
(gnc:html-table-set-cell! (gnc:html-table-set-cell/tag!
html-table 1 html-table 1 current-col "centered-label-cell"
current-col (_ "Act")) ;; Translators: Abbreviation for "Actual" (_ "Act")) ;; Translators: Abbreviation for "Actual"
(set! current-col (+ current-col 1)) (set! current-col (+ current-col 1))
) )
) )
(if show-diff? (if show-diff?
(begin (begin
(gnc:html-table-set-cell! (gnc:html-table-set-cell/tag!
html-table 1 html-table 1 current-col "centered-label-cell"
current-col (_ "Diff")) ;; Translators: Abbrevation for "Difference" (_ "Diff")) ;; Translators: Abbrevation for "Difference"
(set! current-col (+ current-col 1)) (set! current-col (+ current-col 1))
) )
) )