"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "gnucash/report/reports/standard/view-column.scm" between
gnucash-5.0.tar.bz2 and gnucash-5.1.tar.bz2

About: GnuCash is personal and small-business financial-accounting software.

view-column.scm  (gnucash-5.0.tar.bz2):view-column.scm  (gnucash-5.1.tar.bz2)
skipping to change at line 53 skipping to change at line 53
(gnc-register-number-range-option options (gnc-register-number-range-option options
(N_ "General") (N_ "Number of columns") "a" (N_ "General") (N_ "Number of columns") "a"
(N_ "Number of columns before wrapping to a new row.") (N_ "Number of columns before wrapping to a new row.")
1 0 20 1) 1 0 20 1)
options)) options))
(define (render-view report) (define (render-view report)
(let* ((view-doc (gnc:make-html-document)) (let* ((view-doc (gnc:make-html-document))
(options (gnc:report-options report)) (options (gnc:report-options report))
(reports (gnc-optiondb-lookup-value options "__general" "report-list")) (reports (gnc-optiondb-lookup-value options "__general" "report-list"))
(table-width (table-width
(gnc-optiondb-lookup-value options (N_ "General") (N_ "Number of column (gnc-optiondb-lookup-value options (N_ "General") (N_ "Number of colum
s"))) ns")))
(column-allocs (make-hash-table 11)) (column-allocs (make-hash-table 11))
(column-tab (gnc:make-html-table)) (column-tab (gnc:make-html-table))
(current-row '()) (current-row '())
(current-width 0) (current-width 0)
(current-row-num 0)) (current-row-num 0))
;; we really would rather do something smart here with the ;; we really would rather do something smart here with the
;; report's cached text if possible. For the moment, we'll have ;; report's cached text if possible. For the moment, we'll have
;; to rerun every report, every time... FIXME ;; to rerun every report, every time... FIXME
(for-each (for-each
(lambda (report-info) (lambda (report-info)
;; run the report renderer, pick out the document style table ;; run the report renderer, pick out the document style table
;; and objects from the returned document, then make a new ;; and objects from the returned document, then make a new
;; HTML table cell with those objects as content and append ;; HTML table cell with those objects as content and append
;; it to the table. The weird stuff with the column-allocs ;; it to the table. The weird stuff with the column-allocs
;; hash is an attempt to compute how many columnc are ;; hash is an attempt to compute how many columnc are
;; actually used in a row; items with non-1 rowspans will take ;; actually used in a row; items with non-1 rowspans will take
;; up cells in the row without actually being in the row. ;; up cells in the row without actually being in the row.
(let* ((subreport (gnc-report-find (car report-info))) (let* ((subreport (gnc-report-find (car report-info)))
(colspan (cadr report-info)) (colspan (cadr report-info))
(rowspan (caddr report-info)) (rowspan (caddr report-info))
(toplevel-cell (gnc:make-html-table-cell/size rowspan colspan)) (toplevel-cell (gnc:make-html-table-cell/size rowspan colspan))
(report-table (gnc:make-html-table)) (report-table (gnc:make-html-table))
(contents-cell (gnc:make-html-table-cell))) (contents-cell (gnc:make-html-table-cell)))
;; set the report's style properly ... this way it will ;; set the report's style properly ... this way it will
;; also get marked as dirty when the stylesheet is edited. ;; also get marked as dirty when the stylesheet is edited.
(gnc:report-set-stylesheet! (gnc:report-set-stylesheet!
subreport (gnc:report-stylesheet report)) subreport (gnc:report-stylesheet report))
;; render the report body ... capture error if report crashes. ;; render the report body ... capture error if report crashes.
(gnc:html-table-cell-append-objects! (gnc:html-table-cell-append-objects!
contents-cell contents-cell
(match (gnc:apply-with-error-handling (match (gnc:apply-with-error-handling
(lambda () (gnc:report-render-html subreport #f)) '()) (lambda () (gnc:report-render-html subreport #f)) '())
((html #f) html) ((html #f) html)
((_ captured-error) ((_ captured-error)
(gnc:make-html-text (gnc:make-html-text
(gnc:html-markup-h3 (G_ "Report error")) (gnc:html-markup-h3 (G_ "Report error"))
(G_ "An error occurred while running the report.") (G_ "An error occurred while running the report.")
(gnc:html-markup "pre" captured-error))))) (gnc:html-markup "pre" captured-error)))))
;; increment the alloc number for each occupied row ;; increment the alloc number for each occupied row
(let loop ((row current-row-num)) (let loop ((row current-row-num))
(let ((allocation (hash-ref column-allocs row 0))) (let ((allocation (hash-ref column-allocs row 0)))
(hash-set! column-allocs row (+ colspan allocation)) (hash-set! column-allocs row (+ colspan allocation))
(if (< (+ 1 (- row current-row-num)) rowspan) (if (< (+ 1 (- row current-row-num)) rowspan)
(loop (+ 1 row))))) (loop (+ 1 row)))))
(gnc:html-table-cell-set-style! (gnc:html-table-cell-set-style!
toplevel-cell "td" toplevel-cell "td"
'attribute (list "valign" "top") 'attribute (list "valign" "top")
'inheritable? #f) 'inheritable? #f)
;; put the report in the contents-cell ;; put the report in the contents-cell
(gnc:html-table-append-row! report-table (list contents-cell)) (gnc:html-table-append-row! report-table (list contents-cell))
;; and a parameter editor link ;; and a parameter editor link
(gnc:html-table-append-row! (gnc:html-table-append-row!
report-table report-table
(list (gnc:make-html-text (list (gnc:make-html-text
(gnc:html-markup-anchor (gnc:html-markup-anchor
(gnc-build-url (gnc-build-url
URL-TYPE-OPTIONS URL-TYPE-OPTIONS
(format #f "report-id=~a" (car report-info)) (format #f "report-id=~a" (car report-info))
"") "")
(G_ "Edit Options")) (G_ "Edit Options"))
" " " "
(gnc:html-markup-anchor (gnc:html-markup-anchor
(gnc-build-url (gnc-build-url
URL-TYPE-REPORT URL-TYPE-REPORT
(format #f "id=~a" (car report-info)) (format #f "id=~a" (car report-info))
"") "")
(G_ "Single Report"))))) (G_ "Single Report")))))
;; add the report-table to the toplevel-cell ;; add the report-table to the toplevel-cell
(gnc:html-table-cell-append-objects! (gnc:html-table-cell-append-objects!
toplevel-cell report-table) toplevel-cell report-table)
(set! current-row (append current-row (list toplevel-cell))) (set! current-row (append current-row (list toplevel-cell)))
(set! current-width (+ current-width colspan)) (set! current-width (+ current-width colspan))
(if (>= current-width table-width) (if (>= current-width table-width)
(begin (begin
(gnc:html-table-append-row! column-tab current-row) (gnc:html-table-append-row! column-tab current-row)
;; cells above with non-1 rowspan can force 'pre-allocation' ;; cells above with non-1 rowspan can force 'pre-allocation'
;; of space on this row ;; of space on this row
(set! current-row-num (+ 1 current-row-num)) (set! current-row-num (+ 1 current-row-num))
(set! current-width (hash-ref column-allocs current-row-num)) (set! current-width (hash-ref column-allocs current-row-num))
(if (not current-width) (set! current-width 0)) (if (not current-width) (set! current-width 0))
(set! current-row '()))))) (set! current-row '())))))
reports) reports)
(if (not (null? current-row)) (if (not (null? current-row))
(gnc:html-table-append-row! column-tab current-row)) (gnc:html-table-append-row! column-tab current-row))
;; make sure the table is nice and big ;; make sure the table is nice and big
(gnc:html-table-set-style! (gnc:html-table-set-style!
column-tab "table" column-tab "table"
'attribute (list "width" "100%")) 'attribute (list "width" "100%"))
(gnc:html-document-add-object! view-doc column-tab) (gnc:html-document-add-object! view-doc column-tab)
;; and we're done. ;; and we're done.
view-doc)) view-doc))
(define (options-changed-cb report) (define (options-changed-cb report)
(let* ((options (gnc:report-options report)) (let* ((options (gnc:report-options report))
(reports (reports
(gnc-optiondb-lookup-value options "__general" "report-list"))) (gnc-optiondb-lookup-value options "__general" "report-list")))
(for-each (for-each
(lambda (child) (lambda (child)
(gnc:report-set-dirty?! (gnc-report-find (car child)) #t)) (gnc:report-set-dirty?! (gnc-report-find (car child)) #t))
reports))) reports)))
(define (cleanup-options report) (define (cleanup-options report)
(let* ((options (gnc:report-options report)) (let* ((options (gnc:report-options report))
(report-opt (gnc-lookup-option options "__general" "report-list"))) (report-opt (gnc-lookup-option options "__general" "report-list")))
(let loop ((reports (GncOption-get-value report-opt)) (new-reports '())) (let loop ((reports (GncOption-get-value report-opt)) (new-reports '()))
(match reports (match reports
(() (GncOption-set-value report-opt (reverse new-reports))) (() (GncOption-set-value report-opt (reverse new-reports)))
(((child rowspan colspan _) . rest) (((child rowspan colspan _) . rest)
(loop rest (cons (list child rowspan colspan #f) new-reports))))))) (loop rest (cons (list child rowspan colspan #f) new-reports)))))))
;; define the view now. ;; define the view now.
(gnc:define-report (gnc:define-report
'version 1 'version 1
'name (N_ "Multicolumn View") 'name (N_ "Multicolumn View")
 End of changes. 7 change blocks. 
73 lines changed or deleted 73 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)