gnucash maint: Multiple changes pushed

Christopher Lam clam at code.gnucash.org
Tue Oct 8 17:46:52 EDT 2019


Updated	 via  https://github.com/Gnucash/gnucash/commit/f4794d51 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/7bb7d3cd (commit)
	from  https://github.com/Gnucash/gnucash/commit/f4379bbd (commit)



commit f4794d516ffa194dcf2fe4af9e4cd2ace2c30f65
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Wed Oct 9 05:40:00 2019 +0800

    [test-report-html] add tests for html-table-cell row/col modifiers

diff --git a/gnucash/report/report-system/test/test-report-html.scm b/gnucash/report/report-system/test/test-report-html.scm
index e4178e316..6c5a3e637 100644
--- a/gnucash/report/report-system/test/test-report-html.scm
+++ b/gnucash/report/report-system/test/test-report-html.scm
@@ -798,6 +798,40 @@ HTML Document Title</title></head><body></body>\n\
       )
     (test-end "HTML Table - Table Rendering")
 
+    (test-begin "html-table arbitrary row/col modification")
+    (let ((doc (gnc:make-html-document))
+          (table (gnc:make-html-table)))
+      (gnc:html-table-set-cell! table 0 0 "x")
+      (test-equal "html-table-set-cell! 0 0"
+        "<table><tbody><tr><td rowspan=\"1\" colspan=\"1\"><string> x</td>\n</tr>\n</tbody>\n</table>\n"
+        (string-concatenate
+         (gnc:html-document-tree-collapse
+          (gnc:html-table-render table doc))))
+
+      (gnc:html-table-set-cell! table 2 2 "y" "z")
+      (test-equal "html-table-set-cell! 2 2"
+        "<table><tbody><tr><td rowspan=\"1\" colspan=\"1\"><string> x</td>\n</tr>\n<tr></tr>\n<tr><td><string>  </td>\n<td><string>  </td>\n<td rowspan=\"1\" colspan=\"1\"><string> y<string> z</td>\n</tr>\n</tbody>\n</table>\n"
+        (string-concatenate
+         (gnc:html-document-tree-collapse
+          (gnc:html-table-render table doc))))
+
+      (let* ((table1 (gnc:make-html-table))
+             (cell (gnc:make-html-table-cell "ab")))
+        (gnc:html-table-set-cell! table1 1 4 cell)
+        (test-equal "html-table-set-cell! 1 4"
+          "<table><tbody><tr></tr>\n<tr><td><string>  </td>\n<td><string>  </td>\n<td><string>  </td>\n<td><string>  </td>\n<td rowspan=\"1\" colspan=\"1\"><string> ab</td>\n</tr>\n</tbody>\n</table>\n"
+          (string-concatenate
+           (gnc:html-document-tree-collapse
+            (gnc:html-table-render table1 doc))))
+
+        (gnc:html-table-set-cell/tag! table1 1 4 "tag" cell)
+        (test-equal "html-table-set-cell/tag! 1 4"
+          "<table><tbody><tr></tr>\n<tr><td><string>  </td>\n<td><string>  </td>\n<td><string>  </td>\n<td><string>  </td>\n<tag rowspan=\"1\" colspan=\"1\"><string> ab</tag>\n</tr>\n</tbody>\n</table>\n"
+          (string-concatenate
+           (gnc:html-document-tree-collapse
+            (gnc:html-table-render table1 doc))))))
+    (test-end "html-table arbitrary row/col modification")
+
     (test-begin "html-table-cell renderers")
     (let ((doc (gnc:make-html-document))
           (cell (gnc:make-html-table-cell 4)))

commit 7bb7d3cdd655d23c7af902e57aa6326df59933c1
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Mon Oct 7 23:18:34 2019 +0800

    [html-document] schemify gnc:html-document-tree-collapse
    
    this function is technically a flattening function, converted to
    classic scheme form. very efficient in time and space. it is used
    extensively in reports which are still running well, therefore no
    additional testing is required.

diff --git a/gnucash/report/report-system/html-document.scm b/gnucash/report/report-system/html-document.scm
index ecb045e2c..906ab30b8 100644
--- a/gnucash/report/report-system/html-document.scm
+++ b/gnucash/report/report-system/html-document.scm
@@ -105,20 +105,11 @@
        (apply gnc:make-html-data-style-info rest)
        (apply gnc:make-html-markup-style-info rest))))
 
-(define (gnc:html-document-tree-collapse tree)
-  (let ((retval '()))
-    (let loop ((lst tree))
-      (for-each
-       (lambda (elt)
-         (cond
-          ((string? elt)
-           (set! retval (cons elt retval)))
-          ((not (list? elt))
-           (set! retval (cons (object->string elt) retval)))
-          (else
-           (loop elt))))
-       lst))
-    retval))
+(define (gnc:html-document-tree-collapse . tree)
+  (let lp ((e tree) (accum '()))
+    (cond ((list? e) (fold lp accum e))
+          ((string? e) (cons e accum))
+          (else (cons (object->string e) accum)))))
 
 ;; first optional argument is "headers?"
 ;; returns the html document as a string, I think.



Summary of changes:
 gnucash/report/report-system/html-document.scm     | 19 ++++--------
 .../report/report-system/test/test-report-html.scm | 34 ++++++++++++++++++++++
 2 files changed, 39 insertions(+), 14 deletions(-)



More information about the gnucash-changes mailing list