r18328 - gnucash/trunk/src/report - Add "file://" URL type to images in invoices. On win32, this at least allows the exported

Phil Longstaff plongstaff at code.gnucash.org
Sun Sep 20 20:51:20 EDT 2009


Author: plongstaff
Date: 2009-09-20 20:51:20 -0400 (Sun, 20 Sep 2009)
New Revision: 18328
Trac: http://svn.gnucash.org/trac/changeset/18328

Modified:
   gnucash/trunk/src/report/report-system/report-system.scm
   gnucash/trunk/src/report/report-system/report-utilities.scm
   gnucash/trunk/src/report/stylesheets/stylesheet-easy.scm
   gnucash/trunk/src/report/stylesheets/stylesheet-fancy.scm
Log:
Add "file://" URL type to images in invoices.  On win32, this at least allows the exported
invoice html to load in firefox.  It still doesn't fix it in webkit, for some reason.


Modified: gnucash/trunk/src/report/report-system/report-system.scm
===================================================================
--- gnucash/trunk/src/report/report-system/report-system.scm	2009-09-20 20:24:16 UTC (rev 18327)
+++ gnucash/trunk/src/report/report-system/report-system.scm	2009-09-21 00:51:20 UTC (rev 18328)
@@ -679,6 +679,7 @@
 (export gnc:get-assoc-account-balances)
 (export gnc:select-assoc-account-balance)
 (export gnc:get-assoc-account-balances-total)
+(export make-file-url)
 
 (load-from-path "commodity-utilities.scm")
 (load-from-path "html-barchart.scm")

Modified: gnucash/trunk/src/report/report-system/report-utilities.scm
===================================================================
--- gnucash/trunk/src/report/report-system/report-utilities.scm	2009-09-20 20:24:16 UTC (rev 18327)
+++ gnucash/trunk/src/report/report-system/report-utilities.scm	2009-09-21 00:51:20 UTC (rev 18328)
@@ -17,6 +17,8 @@
 ;; 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
 ;; Boston, MA  02110-1301,  USA       gnu at gnu.org
 
+(use-modules (srfi srfi-13))
+
 (define (list-ref-safe list elt)
   (if (> (length list) elt)
       (list-ref list elt)
@@ -967,3 +969,12 @@
         (total 'merge (car (cdr account-balance)) #f))
       account-balances)
     total))
+
+;; Adds "file://" to the beginning of a URL if it doesn't already exist
+;;
+;; @param url URL
+;; @return URL with "file://" as the URL type if it isn't already there
+(define (make-file-url url)
+  (if (string-prefix? "file://" url)
+     url
+     (string-append "file://" url)))

Modified: gnucash/trunk/src/report/stylesheets/stylesheet-easy.scm
===================================================================
--- gnucash/trunk/src/report/stylesheets/stylesheet-easy.scm	2009-09-20 20:24:16 UTC (rev 18327)
+++ gnucash/trunk/src/report/stylesheets/stylesheet-easy.scm	2009-09-21 00:51:20 UTC (rev 18328)
@@ -358,7 +358,7 @@
           (gnc:html-table-set-cell!
             t 0 0
             (gnc:make-html-text
-	      (gnc:html-markup-img logopixmap)))))
+	      (gnc:html-markup-img (make-file-url logopixmap))))))
       
       (if (and headpixmap (> (string-length headpixmap) 0))
         (begin
@@ -367,7 +367,7 @@
             (gnc:make-html-text 
                (string-append 
                  "<div align=\"" align "\">"
-                 "<img src=\"" headpixmap "\">"
+                 "<img src=\"" (make-file-url headpixmap) "\">"
                  "</div>")))
         )
         (gnc:html-table-set-cell!

Modified: gnucash/trunk/src/report/stylesheets/stylesheet-fancy.scm
===================================================================
--- gnucash/trunk/src/report/stylesheets/stylesheet-fancy.scm	2009-09-20 20:24:16 UTC (rev 18327)
+++ gnucash/trunk/src/report/stylesheets/stylesheet-fancy.scm	2009-09-21 00:51:20 UTC (rev 18328)
@@ -354,7 +354,7 @@
 	  (gnc:html-table-set-cell!
 	   t 0 0
            (gnc:make-html-text
-	    (gnc:html-markup-img logopixmap))) )
+	    (gnc:html-markup-img (make-file-url logopixmap)))) )
 
       (if (and headpixmap
 	       (not (string=? headpixmap "")))
@@ -367,7 +367,7 @@
 	      ;; (gnc:html-markup-img headpixmap)?
 	      (string-append
 	       "<div align=\"" align "\">"
-	       "<img src=\"" headpixmap "\">"
+	       "<img src=\"" (make-file-url headpixmap) "\">"
 	       "</div>")))
 	    )
 	  (gnc:html-table-set-cell!



More information about the gnucash-changes mailing list