gnucash master: Multiple changes pushed
Geert Janssens
gjanssens at code.gnucash.org
Thu Feb 27 05:59:30 EST 2014
Updated via https://github.com/Gnucash/gnucash/commit/9f5d62d4 (commit)
via https://github.com/Gnucash/gnucash/commit/87c9a3ba (commit)
via https://github.com/Gnucash/gnucash/commit/e922616e (commit)
via https://github.com/Gnucash/gnucash/commit/94493e03 (commit)
from https://github.com/Gnucash/gnucash/commit/f0eca7f0 (commit)
commit 9f5d62d4f70403e17b55debf240e436a451d47eb
Author: Geert Janssens <janssens-geert at telenet.be>
Date: Thu Feb 27 11:19:11 2014 +0100
Some code refactoring to avoid duplication
diff --git a/src/report/report-system/report.scm b/src/report/report-system/report.scm
index 05a612b..254eed2 100644
--- a/src/report/report-system/report.scm
+++ b/src/report/report-system/report.scm
@@ -547,10 +547,8 @@
))
;; Generate guile code required to recreate embedded report instances
-(define (gnc:report-serialize-embedded options)
- (let*
- ((embedded-reports (gnc:report-embedded-list options))
- (result-string ""))
+(define (gnc:report-serialize-embedded embedded-reports)
+ (let* ((result-string ""))
(if embedded-reports
(for-each
(lambda (subreport-id)
@@ -564,8 +562,9 @@
embedded-reports))
result-string))
-(define (gnc:report-template-serialize-internal name type templ-name options embedded-serialized guid)
- (let ((result (string-append
+(define (gnc:report-template-serialize-internal name type templ-name options guid)
+ (let* ((embedded-serialized (gnc:report-serialize-embedded (gnc:report-embedded-list options)))
+ (result (string-append
";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n"
(format #f ";; Options for saved report ~S, based on template ~S\n"
name type)
@@ -605,9 +604,8 @@
(let* ((name (gnc:report-template-make-unique-name (gnc:report-name report)))
(type (gnc:report-type report))
(templ-name (gnc:report-template-name (hash-ref *gnc:_report-templates_* (gnc:report-type report))))
- (options (gnc:report-options report))
- (embedded-serialized (gnc:report-serialize-embedded options)))
- (gnc:report-template-serialize-internal name type templ-name options embedded-serialized #f)))
+ (options (gnc:report-options report)))
+ (gnc:report-template-serialize-internal name type templ-name options #f)))
;; Generate guile code required to recreate a report template
;; Note: multi column report templates encapsulate instantiated reports, not other report templates
@@ -619,9 +617,8 @@
(type (gnc:report-template-parent-type report-template))
(templ-name (gnc:report-template-name (hash-ref *gnc:_report-templates_* type)))
(options (gnc:report-template-new-options report-template))
- (embedded-serialized (gnc:report-serialize-embedded options))
(guid (gnc:report-template-report-guid report-template)))
- (gnc:report-template-serialize-internal name type templ-name options embedded-serialized guid)))
+ (gnc:report-template-serialize-internal name type templ-name options guid)))
(define gnc:current-saved-reports
(gnc-build-dotgnucash-path "saved-reports-2.4"))
commit 87c9a3ba677176ccc5e393a751561bebd814be60
Author: Geert Janssens <janssens-geert at telenet.be>
Date: Thu Feb 27 11:43:28 2014 +0100
Improve function names and comments to reduce ambibuity
diff --git a/src/report/report-gnome/gnc-plugin-page-report.c b/src/report/report-gnome/gnc-plugin-page-report.c
index aab54ef..9decd37 100644
--- a/src/report/report-gnome/gnc-plugin-page-report.c
+++ b/src/report/report-gnome/gnc-plugin-page-report.c
@@ -745,7 +745,7 @@ gnc_plugin_page_report_save_page (GncPluginPage *plugin_page,
return;
}
- gen_save_text = scm_c_eval_string("gnc:report-generate-restore-forms");
+ gen_save_text = scm_c_eval_string("gnc:report-serialize");
get_embedded_list = scm_c_eval_string("gnc:report-embedded-list");
get_options = scm_c_eval_string("gnc:report-options");
embedded = scm_call_1(get_embedded_list, scm_call_1(get_options, priv->cur_report));
diff --git a/src/report/report-system/report-system.scm b/src/report/report-system/report-system.scm
index 63a2004..357651a 100644
--- a/src/report/report-system/report-system.scm
+++ b/src/report/report-system/report-system.scm
@@ -164,8 +164,7 @@
(export gnc:delete-report)
(export gnc:rename-report)
(export gnc:find-report-template)
-(export gnc:report-generate-restore-forms)
-(export gnc:report-generate-saved-forms)
+(export gnc:report-serialize)
(export gnc:report-to-template-new)
(export gnc:report-to-template-update)
(export gnc:report-render-html)
diff --git a/src/report/report-system/report.scm b/src/report/report-system/report.scm
index 0058d44..05a612b 100644
--- a/src/report/report-system/report.scm
+++ b/src/report/report-system/report.scm
@@ -508,7 +508,9 @@
;; Load and save functions
-(define (gnc:report-generate-restore-forms report)
+
+;; Generate guile code required to recreate an instatiated report
+(define (gnc:report-serialize report)
;; clean up the options if necessary. this is only needed
;; in special cases.
(let* ((report-type (gnc:report-type report))
@@ -544,8 +546,8 @@
")"
))
-;; Loop over embedded reports and concat result of each gnc:report-generate-restore-forms
-(define (gnc:report-generate-options-embedded options)
+;; Generate guile code required to recreate embedded report instances
+(define (gnc:report-serialize-embedded options)
(let*
((embedded-reports (gnc:report-embedded-list options))
(result-string ""))
@@ -554,7 +556,7 @@
(lambda (subreport-id)
(let*
((subreport (gnc-report-find subreport-id))
- (subreport-options-text (gnc:report-generate-restore-forms subreport)))
+ (subreport-options-text (gnc:report-serialize subreport)))
(set! result-string (string-append
result-string
";;;; Options for embedded report\n"
@@ -562,7 +564,7 @@
embedded-reports))
result-string))
-(define (gnc:report-generate-saved-forms-string name type templ-name options embedded-options guid)
+(define (gnc:report-template-serialize-internal name type templ-name options embedded-serialized guid)
(let ((result (string-append
";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n"
(format #f ";; Options for saved report ~S, based on template ~S\n"
@@ -571,8 +573,8 @@
#f "(let ()\n (define (options-gen)\n (let ((options (gnc:report-template-new-options/report-guid ~S ~S)))\n"
type templ-name)
(gnc:generate-restore-forms options "options")
- (if embedded-options
- embedded-options
+ (if embedded-serialized
+ embedded-serialized
"")
" options))\n"
(format
@@ -589,7 +591,7 @@
;; Convert an instantiated report into a report template
;; and generate the guile code required to recreate this template
-(define (gnc:report-generate-saved-forms report)
+(define (gnc:report-template-serialize-from-report report)
;; clean up the options if necessary. this is only needed
;; in special cases.
(let* ((template
@@ -604,22 +606,22 @@
(type (gnc:report-type report))
(templ-name (gnc:report-template-name (hash-ref *gnc:_report-templates_* (gnc:report-type report))))
(options (gnc:report-options report))
- (embedded-options (gnc:report-generate-options-embedded options)))
- (gnc:report-generate-saved-forms-string name type templ-name options embedded-options #f)))
+ (embedded-serialized (gnc:report-serialize-embedded options)))
+ (gnc:report-template-serialize-internal name type templ-name options embedded-serialized #f)))
;; Generate guile code required to recreate a report template
;; Note: multi column report templates encapsulate instantiated reports, not other report templates
;; this means that the template recreation code must also contain the code to instantiate
;; these embedded report instances. This results in a mix of template and instatiated reports
;; in the saved reports file...
-(define (gnc:report-template-generate-saved-forms report-template)
+(define (gnc:report-template-serialize report-template)
(let* ((name (gnc:report-template-name report-template))
(type (gnc:report-template-parent-type report-template))
(templ-name (gnc:report-template-name (hash-ref *gnc:_report-templates_* type)))
(options (gnc:report-template-new-options report-template))
- (embedded-options (gnc:report-generate-options-embedded options))
+ (embedded-serialized (gnc:report-serialize-embedded options))
(guid (gnc:report-template-report-guid report-template)))
- (gnc:report-generate-saved-forms-string name type templ-name options embedded-options guid)))
+ (gnc:report-template-serialize-internal name type templ-name options embedded-serialized guid)))
(define gnc:current-saved-reports
(gnc-build-dotgnucash-path "saved-reports-2.4"))
@@ -648,7 +650,7 @@
(let* ((custom-template-id (gnc:report-custom-template report))
(overwrite-ok? (and (gnc:report-template-is-custom/template-guid? custom-template-id) overwrite?))
;; Generate a serialized report-template with a random guid
- (saved-form (gnc:report-generate-saved-forms report))
+ (saved-form (gnc:report-template-serialize-from-report report))
;; Immediatly evaluate the serialized report template to
;; - check if it's error free and can be deserialized
;; - load it into the runtime for immediate use by the user
@@ -695,7 +697,7 @@
(define (gnc:report-template-save-to-savefile report-template)
(let* ((report-port (gnc:open-saved-reports "a")))
(if report-port
- (let ((saved-form (gnc:report-template-generate-saved-forms report-template)))
+ (let ((saved-form (gnc:report-template-serialize report-template)))
(display saved-form report-port)
(close report-port)
#t)
commit e922616ef95b9d806913b4abb5eb69f973afabcd
Author: Geert Janssens <janssens-geert at telenet.be>
Date: Thu Feb 27 11:42:00 2014 +0100
Whitespace cleanup
diff --git a/src/report/report-system/report.scm b/src/report/report-system/report.scm
index 5390504..0058d44 100644
--- a/src/report/report-system/report.scm
+++ b/src/report/report-system/report.scm
@@ -529,7 +529,7 @@
;; Temporary check to make the new report saving code more or less backwards
;; compatible with older gnucash versions. This can be removed again in 2.8.
"(if (defined? 'gnc:restore-report-by-guid-with-custom-template)\n"
- ;; end of 2.6->2.4 compatibility code prefix.
+ ;; end of 2.6->2.4 compatibility code prefix.
(format
#f " (gnc:restore-report-by-guid-with-custom-template ~S ~S ~S ~S options)\n"
(gnc:report-id report) (gnc:report-type report)
@@ -566,7 +566,7 @@
(let ((result (string-append
";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n"
(format #f ";; Options for saved report ~S, based on template ~S\n"
- name type)
+ name type)
(format
#f "(let ()\n (define (options-gen)\n (let ((options (gnc:report-template-new-options/report-guid ~S ~S)))\n"
type templ-name)
@@ -579,8 +579,8 @@
#f " (gnc:define-report \n 'version 1\n 'name ~S\n 'report-guid ~S\n 'parent-type ~S\n 'options-generator options-gen\n 'menu-path (list gnc:menuname-custom)\n 'renderer (gnc:report-template-renderer/report-guid ~S ~S)))\n\n"
name
(if guid
- guid
- (guid-new-return)) ;; when saving a report, we need to create a guid for it for later reloading
+ guid
+ (guid-new-return)) ;; when saving a report, we need to create a guid for it for later reloading
type
type
templ-name))))
@@ -614,12 +614,11 @@
;; in the saved reports file...
(define (gnc:report-template-generate-saved-forms report-template)
(let* ((name (gnc:report-template-name report-template))
- (type (gnc:report-template-parent-type report-template))
- (templ-name (gnc:report-template-name (hash-ref *gnc:_report-templates_* type)))
- (options (gnc:report-template-new-options report-template))
- (embedded-options (gnc:report-generate-options-embedded options))
- (guid (gnc:report-template-report-guid report-template))
- )
+ (type (gnc:report-template-parent-type report-template))
+ (templ-name (gnc:report-template-name (hash-ref *gnc:_report-templates_* type)))
+ (options (gnc:report-template-new-options report-template))
+ (embedded-options (gnc:report-generate-options-embedded options))
+ (guid (gnc:report-template-report-guid report-template)))
(gnc:report-generate-saved-forms-string name type templ-name options embedded-options guid)))
(define gnc:current-saved-reports
commit 94493e038e61dfad54828ecf6e51519eee7bca07
Author: Geert Janssens <janssens-geert at telenet.be>
Date: Thu Feb 27 10:36:56 2014 +0100
Bug 724753 - Saved Multicolumn Report Error
diff --git a/src/report/report-gnome/gnc-plugin-page-report.c b/src/report/report-gnome/gnc-plugin-page-report.c
index 56141a8..aab54ef 100644
--- a/src/report/report-gnome/gnc-plugin-page-report.c
+++ b/src/report/report-gnome/gnc-plugin-page-report.c
@@ -724,6 +724,7 @@ gnc_plugin_page_report_save_page (GncPluginPage *plugin_page,
GncPluginPageReportPrivate *priv;
SCM gen_save_text, scm_text;
SCM get_embedded_list, embedded, item, tmp_report;
+ SCM get_options;
gint count, id;
gchar *text, *key_name;
@@ -746,7 +747,8 @@ gnc_plugin_page_report_save_page (GncPluginPage *plugin_page,
gen_save_text = scm_c_eval_string("gnc:report-generate-restore-forms");
get_embedded_list = scm_c_eval_string("gnc:report-embedded-list");
- embedded = scm_call_1(get_embedded_list, priv->cur_report);
+ get_options = scm_c_eval_string("gnc:report-options");
+ embedded = scm_call_1(get_embedded_list, scm_call_1(get_options, priv->cur_report));
count = scm_ilength(embedded);
while (count-- > 0)
{
diff --git a/src/report/report-system/report.scm b/src/report/report-system/report.scm
index 7d31bc6..5390504 100644
--- a/src/report/report-system/report.scm
+++ b/src/report/report-system/report.scm
@@ -545,9 +545,9 @@
))
;; Loop over embedded reports and concat result of each gnc:report-generate-restore-forms
-(define (gnc:report-generate-options-embedded report)
+(define (gnc:report-generate-options-embedded options)
(let*
- ((embedded-reports (gnc:report-embedded-list report))
+ ((embedded-reports (gnc:report-embedded-list options))
(result-string ""))
(if embedded-reports
(for-each
@@ -587,6 +587,8 @@
(gnc:debug result)
result))
+;; Convert an instantiated report into a report template
+;; and generate the guile code required to recreate this template
(define (gnc:report-generate-saved-forms report)
;; clean up the options if necessary. this is only needed
;; in special cases.
@@ -598,19 +600,24 @@
(thunk report)))
;; save them
- (let ((name (gnc:report-template-make-unique-name (gnc:report-name report)))
- (type (gnc:report-type report))
- (templ-name (gnc:report-template-name (hash-ref *gnc:_report-templates_* (gnc:report-type report))))
- (options (gnc:report-options report))
- (embedded-options (gnc:report-generate-options-embedded report)))
+ (let* ((name (gnc:report-template-make-unique-name (gnc:report-name report)))
+ (type (gnc:report-type report))
+ (templ-name (gnc:report-template-name (hash-ref *gnc:_report-templates_* (gnc:report-type report))))
+ (options (gnc:report-options report))
+ (embedded-options (gnc:report-generate-options-embedded options)))
(gnc:report-generate-saved-forms-string name type templ-name options embedded-options #f)))
+;; Generate guile code required to recreate a report template
+;; Note: multi column report templates encapsulate instantiated reports, not other report templates
+;; this means that the template recreation code must also contain the code to instantiate
+;; these embedded report instances. This results in a mix of template and instatiated reports
+;; in the saved reports file...
(define (gnc:report-template-generate-saved-forms report-template)
(let* ((name (gnc:report-template-name report-template))
(type (gnc:report-template-parent-type report-template))
(templ-name (gnc:report-template-name (hash-ref *gnc:_report-templates_* type)))
(options (gnc:report-template-new-options report-template))
- (embedded-options #f)
+ (embedded-options (gnc:report-generate-options-embedded options))
(guid (gnc:report-template-report-guid report-template))
)
(gnc:report-generate-saved-forms-string name type templ-name options embedded-options guid)))
@@ -781,9 +788,8 @@
*gnc:_report-templates_*))
;; return the list of reports embedded in the specified report
-(define (gnc:report-embedded-list report)
- (let* ((options (gnc:report-options report))
- (option (gnc:lookup-option options "__general" "report-list")))
+(define (gnc:report-embedded-list options)
+ (let* ((option (gnc:lookup-option options "__general" "report-list")))
(if option
(let ((opt-value (gnc:option-value option)))
(map (lambda (x) (car x)) opt-value))
Summary of changes:
src/report/report-gnome/gnc-plugin-page-report.c | 6 +-
src/report/report-system/report-system.scm | 3 +-
src/report/report-system/report.scm | 76 +++++++++++++-----------
3 files changed, 45 insertions(+), 40 deletions(-)
More information about the gnucash-changes
mailing list