Megatest

Diff
Login

Differences From Artifact [1a2ebfec3c]:

To Artifact [6e104f5f8a]:


130
131
132
133
134
135
136
137

138
139
140
141
142
143
144
145
146
147
148
149



150
151
152
153

154
155
156
157
158
159









160
161
162
163
164
165
166
130
131
132
133
134
135
136

137
138
139
140
141
142
143
144
145




146
147
148
149
150
151

152
153
154
155



156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171







-
+








-
-
-
-
+
+
+



-
+



-
-
-
+
+
+
+
+
+
+
+
+








;; sheetdat is '("sheetname" (r1c1 r2c2 ...)(r2c1 r2c2 ...) ...)
(define (ods:sheet sheetdat)
  (let ((name (car sheetdat))
	(rows (cdr sheetdat)))
    (conc "<table:table table:name=\"" name "\" table:style-name=\"ta1\" table:print=\"false\">\n"
	  (conc (ods:column)
		(apply conc (map ods:row rows)))
		(string-join (map ods:row rows) ""))
	  "</table:table>")))

;; seems to be called once at top of each sheet, i.e. a column of rows
(define (ods:column)
  "<table:table-column table:style-name=\"co1\" table:number-columns-repeated=\"2\" table:default-cell-style-name=\"Default\"/>\n")

;; cells is a list of <table:table-cell ..> ... </table:table-cell>
(define (ods:row cells)
  (apply conc
	 (cons "<table:table-row table:style-name=\"ro1\">\n"
	       (append (map ods:cell cells)
		       (list "</table:table-row>\n")))))
  (conc	 "<table:table-row table:style-name=\"ro1\">\n"
	 (string-join (map ods:cell cells) "")
	 "</table:table-row>\n"))

;; types are "string" or "float"
(define (ods:cell value)
  (let ((type (cond
  (let* ((type (cond
	       ((string? value) "string")
	       ((symbol? value) "string")
	       ((number? value) "float")
	       (else "string"))))
    (conc "<table:table-cell office:value-type=\"" type "\">" "\n"
	  "<text:p>" value "</text:p>" "\n"
	       (else #f)))
	(tmpval (if (symbol? value)
		    (symbol->string value) 
		    (if type value ""))) ;; convert everything else to an empty string
	(escval (if (string? tmpval)(string-substitute (regexp "<") "&lt;" (string-substitute (regexp ">") "&gt;" tmpval)) tmpval)))
    (conc "<table:table-cell office:value-type=\"" (if type type "string") "\""
	  (if (equal? type "float")(conc " office:value=\"" value "\"") "")
	  ">\n"
	  "<text:p>" escval "</text:p>" "\n"
	  "</table:table-cell>" "\n")))

;; create the directories
(define (ods:construct-dir path)
  (for-each 
   (lambda (subdir)
     (system (conc "mkdir -p "  path "/" subdir)))
201
202
203
204
205
206
207
208

209
206
207
208
209
210
211
212

213
214







-
+

	    (ods:add-non-content-files path)
	    (ods:make-thumbnail path)
	    (map display ods:content-header)
	    ;; process each sheet
	    (map print 
		 (map ods:sheet data))
	    (map display ods:content-footer)))
	(system (conc "cd " path "; zip " fname " -n mimetype mimetype `find . |grep -v mimetype`")))))
	(system (conc "cd " path "; zip " fname " -n mimetype mimetype `find . |grep -v mimetype` > /dev/null")))))