Add saving of reports.

2004-06-18  Christian Stimming  <stimming@tuhh.de>

	* src/scm/main-window.scm, src/scm/main.scm: Added example Menu
	item "File -> Save all reports" that will call the new report
	saving function for all reports. Reports are appended to
	~/.gnucash/saved-reports-1.8 . This would need more work so that
	not all reports are saved but only the currently selected one --
	any volunteer may feel free to add that.

	* src/report/report-system/report.scm, report-system.scm: Added
	gnc:report-generate-saved-forms that will generate the scheme code
	necessary to create a new report from the saved options of an old
	report (merged from 1-8-branch).


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@10074 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Christian Stimming 2004-06-21 20:25:12 +00:00
parent 77ca4e7afa
commit 3bdddcdf64
5 changed files with 69 additions and 0 deletions

View File

@ -1,3 +1,17 @@
2004-06-18 Christian Stimming <stimming@tuhh.de>
* src/scm/main-window.scm, src/scm/main.scm: Added example Menu
item "File -> Save all reports" that will call the new report
saving function for all reports. Reports are appended to
~/.gnucash/saved-reports-1.8 . This would need more work so that
not all reports are saved but only the currently selected one --
any volunteer may feel free to add that.
* src/report/report-system/report.scm, report-system.scm: Added
gnc:report-generate-saved-forms that will generate the scheme code
necessary to create a new report from the saved options of an old
report (merged from 1-8-branch).
2004-06-18 Derek Atkins <derek@ihtfp.com>
* src/scm/paths.scm: create gnc:current-saved-reports, as

View File

@ -105,6 +105,7 @@
(export *gnc:_reports_*)
(export gnc:report-template-new-options/name)
(export gnc:report-template-menu-name/name)
(export gnc:report-template-renderer/name)
(export gnc:report-template-new-options)
(export gnc:report-template-version)
(export gnc:report-template-name)
@ -146,6 +147,7 @@
(export gnc:find-report)
(export gnc:find-report-template)
(export gnc:report-generate-restore-forms)
(export gnc:report-generate-saved-forms)
(export gnc:report-render-html)
(export gnc:report-run)
(export gnc:report-templates-for-each)

View File

@ -135,6 +135,12 @@
(gnc:report-template-name templ))
#f)))
(define (gnc:report-template-renderer/name template-name)
(let ((templ (hash-ref *gnc:_report-templates_* template-name)))
(if templ
(gnc:report-template-renderer templ)
#f)))
(define (gnc:report-template-new-options report-template)
(let ((generator (gnc:report-template-options-generator report-template))
(namer
@ -353,6 +359,31 @@
#f " (gnc:restore-report ~S ~S options))\n"
(gnc:report-id report) (gnc:report-type report))))
(define (gnc:report-generate-saved-forms report)
;; clean up the options if necessary. this is only needed
;; in special cases.
(let* ((template
(hash-ref *gnc:_report-templates_*
(gnc:report-type report)))
(thunk (gnc:report-template-options-cleanup-cb template)))
(if thunk
(thunk report)))
;; save them
(string-append
";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n"
(simple-format #f ";; Options for saved report ~S, based on template ~S\n"
(gnc:report-name report) (gnc:report-type report))
(simple-format
#f "(let ()\n (define (options-gen)\n (let ((options (gnc:report-template-new-options/name ~S)))\n"
(gnc:report-type report))
(gnc:generate-restore-forms (gnc:report-options report) "options")
" options))\n"
(simple-format
#f " (gnc:define-report \n 'version 1\n 'name ~S\n 'options-generator options-gen\n 'renderer (gnc:report-template-renderer/name ~S)))\n\n"
(gnc:report-name report)
(gnc:report-type report))))
(define (gnc:report-render-html report headers?)
(if (and (not (gnc:report-dirty? report))
(gnc:report-ctext report))

View File

@ -162,6 +162,18 @@ the account instead of opening a register.") #f))
(force-output)))
(gnc:mdi-save (gnc:mdi-get-current) book-url)))))
(define (gnc:main-window-save-report)
(let ((conf-file-name gnc:current-saved-reports))
;;(display conf-file-name)
(with-output-to-port (open-file conf-file-name "a")
(lambda ()
(hash-fold
(lambda (k v p)
(display
(gnc:report-generate-saved-forms v)))
#t *gnc:_reports_*)
(force-output)))))
(define (gnc:main-window-book-close-handler session)
(gnc:main-window-save-state session)

View File

@ -78,6 +78,7 @@
(export gnc:make-new-acct-tree-window)
(export gnc:free-acct-tree-window)
(export gnc:main-window-save-state)
(export gnc:main-window-save-report)
;; from printing/print-check.scm
(export make-print-check-format)
@ -508,6 +509,15 @@ string and 'directories' must be a list of strings."
(lambda ()
(gnc:main-window-open-report (gnc:make-welcome-report) #f))))
;; The "save current report" entry
(gnc:add-extension
(gnc:make-menu-item
(N_ "_Save all current reports")
(N_ "Save all the current report in ~/.gnucash/saved-reports-1.8 so that they are accessible as menu entries in the report menu. Effects are only visible at next startup of gnucash.")
(list gnc:window-name-main "_File" "_Export")
(lambda ()
(gnc:main-window-save-report))))
(gnc:hook-run-danglers gnc:*startup-hook*)
(if (gnc:config-var-value-get gnc:*loglevel*)