Index: txtdb/nada3/Second-sheet.dat ================================================================== --- txtdb/nada3/Second-sheet.dat +++ txtdb/nada3/Second-sheet.dat @@ -7,10 +7,13 @@ V17 + [A1] V8 Z V17 = +# +# Just a test really +# V1 X V3 X V5 Y V7 Y V10 Z @@ -22,9 +25,12 @@ [3] V2 John, V6 Tom V8 Fred V17 ~ +# +# a deeply held belief is a danger to sanity +# V4 X row-11 Z row-18 B Index: txtdb/nada3/sxml/Second-sheet.sxml ================================================================== --- txtdb/nada3/sxml/Second-sheet.sxml +++ txtdb/nada3/sxml/Second-sheet.sxml @@ -8,11 +8,11 @@ (HideColHeader "0") (GridColor "0:0:0") (DisplayOutlines "1") (DisplayFormulas "0")) (http://www.gnumeric.org/v10.dtd:MaxCol "3") - (http://www.gnumeric.org/v10.dtd:MaxRow "19") + (http://www.gnumeric.org/v10.dtd:MaxRow "21") (http://www.gnumeric.org/v10.dtd:Zoom "1") (http://www.gnumeric.org/v10.dtd:Names (http://www.gnumeric.org/v10.dtd:Name (http://www.gnumeric.org/v10.dtd:name "Print_Area") (http://www.gnumeric.org/v10.dtd:value "#REF!") @@ -149,11 +149,11 @@ (Script "0") (Italic "0") (Bold "0")) "Sans"))) (http://www.gnumeric.org/v10.dtd:StyleRegion - (@ (startRow "16") (startCol "3") (endRow "17") (endCol "3")) + (@ (startRow "16") (startCol "3") (endRow "18") (endCol "3")) (http://www.gnumeric.org/v10.dtd:Style (@ (WrapText "0") (VAlign "2") (ShrinkToFit "0") (Shade "0") @@ -173,11 +173,11 @@ (Script "0") (Italic "0") (Bold "0")) "Sans"))) (http://www.gnumeric.org/v10.dtd:StyleRegion - (@ (startRow "18") (startCol "3") (endRow "18") (endCol "3")) + (@ (startRow "19") (startCol "3") (endRow "19") (endCol "3")) (http://www.gnumeric.org/v10.dtd:Style (@ (WrapText "0") (VAlign "2") (ShrinkToFit "0") (Shade "1") @@ -197,11 +197,11 @@ (Script "0") (Italic "0") (Bold "0")) "Sans"))) (http://www.gnumeric.org/v10.dtd:StyleRegion - (@ (startRow "19") (startCol "3") (endRow "31") (endCol "3")) + (@ (startRow "20") (startCol "3") (endRow "31") (endCol "3")) (http://www.gnumeric.org/v10.dtd:Style (@ (WrapText "0") (VAlign "2") (ShrinkToFit "0") (Shade "0") @@ -295,20 +295,24 @@ (Bold "0")) "Sans")))) (http://www.gnumeric.org/v10.dtd:Cols (@ (DefaultSizePts "48")) (http://www.gnumeric.org/v10.dtd:ColInfo (@ (Unit "64.01") (No "0"))) + (http://www.gnumeric.org/v10.dtd:ColInfo (@ (Unit "48") (No "1"))) + (http://www.gnumeric.org/v10.dtd:ColInfo + (@ (Unit "99") (No "2") (HardSize "1"))) (http://www.gnumeric.org/v10.dtd:ColInfo - (@ (Unit "48") (No "1") (Count "3")))) + (@ (Unit "227.2") (No "3") (HardSize "1")))) (http://www.gnumeric.org/v10.dtd:Rows (@ (DefaultSizePts "12.1")) (http://www.gnumeric.org/v10.dtd:RowInfo - (@ (Unit "13.5") (No "0") (Count "20")))) + (@ (Unit "13.5") (No "0") (Count "21"))) + (http://www.gnumeric.org/v10.dtd:RowInfo (@ (Unit "12.1") (No "21")))) (http://www.gnumeric.org/v10.dtd:Selections - (@ (CursorRow "0") (CursorCol "0")) + (@ (CursorRow "11") (CursorCol "3")) (http://www.gnumeric.org/v10.dtd:Selection - (@ (startRow "0") (startCol "0") (endRow "0") (endCol "0")))) + (@ (startRow "11") (startCol "3") (endRow "11") (endCol "3")))) (http://www.gnumeric.org/v10.dtd:SheetLayout (@ (TopLeft "A1"))) (http://www.gnumeric.org/v10.dtd:Solver (@ (ProgramR "0") (ProblemType "0") (NonNeg "1") Index: txtdb/nada3/sxml/sheets.sxml ================================================================== --- txtdb/nada3/sxml/sheets.sxml +++ txtdb/nada3/sxml/sheets.sxml @@ -26,13 +26,13 @@ (http://www.gnumeric.org/v10.dtd:name "WorkbookView::is_protected") (http://www.gnumeric.org/v10.dtd:value "FALSE"))) (urn:oasis:names:tc:opendocument:xmlns:office:1.0:document-meta (@ (urn:oasis:names:tc:opendocument:xmlns:office:1.0:version "1.2")) (urn:oasis:names:tc:opendocument:xmlns:office:1.0:meta - (http://purl.org/dc/elements/1.1/:date "2013-07-19T05:53:19Z") + (http://purl.org/dc/elements/1.1/:date "2013-07-26T04:34:47Z") (urn:oasis:names:tc:opendocument:xmlns:meta:1.0:creation-date - "2013-07-19T05:52:56Z"))) + "2013-07-26T04:34:08Z"))) (http://www.gnumeric.org/v10.dtd:Calculation (@ (MaxIterations "100") (ManualRecalc "0") (IterationTolerance "0.001") (FloatRadix "2") @@ -54,6 +54,6 @@ (http://www.gnumeric.org/v10.dtd:SheetName (@ (http://www.gnumeric.org/v10.dtd:Rows "65536") (http://www.gnumeric.org/v10.dtd:Cols "256")) "RunsToLock")) (http://www.gnumeric.org/v10.dtd:Geometry (@ (Width "1440") (Height "647"))) - (http://www.gnumeric.org/v10.dtd:UIData (@ (SelectedTab "2")))) + (http://www.gnumeric.org/v10.dtd:UIData (@ (SelectedTab "1")))) Index: txtdb/txtdb.scm ================================================================== --- txtdb/txtdb.scm +++ txtdb/txtdb.scm @@ -64,11 +64,12 @@ (define (string->safe-filename str) (string-substitute (regexp " ") "_" str #t)) (define (sheet->refdb dat targdir) - (let* ((sheet-name (car (find-section dat 'http://www.gnumeric.org/v10.dtd:Name))) + (let* ((comment-rx (regexp "^#CMNT\\d+\\s*")) + (sheet-name (car (find-section dat 'http://www.gnumeric.org/v10.dtd:Name))) ;; (safe-name (string->safe-filename sheet-name)) (cells (find-section dat 'http://www.gnumeric.org/v10.dtd:Cells)) (remaining (remove-section (remove-section dat 'http://www.gnumeric.org/v10.dtd:Name) 'http://www.gnumeric.org/v10.dtd:Cells)) (rownums (make-hash-table)) ;; num -> name @@ -103,11 +104,15 @@ (with-output-to-file (conc targdir "/" sheet-name ".dat") (lambda () (for-each (lambda (colname) (print "[" colname "]") (for-each (lambda (row) - (print (car row) " " (cadr row))) + (let ((key (car row)) + (val (cadr row))) + (if (string-search comment-rx key) + (print val) + (print key " " val)))) (reverse (hash-table-ref cols colname))) (print)) (sort (hash-table-keys cols)(lambda (a b) (let ((colnum-a (assoc a ref-colnums)) (colnum-b (assoc b ref-colnums))) @@ -181,25 +186,30 @@ (define (hash-table-reverse-lookup ht val) (hash-table-fold ht (lambda (k v res)(if (equal? v val) k res)) #f)) (define (read-dat fname) - (let ((section-rx (regexp "^\\[(.*)\\]\\s*$")) - (comment-rx (regexp "^#.*")) ;; This means a cell name cannot start with # - (cell-rx (regexp "^(\\S+) (.*)$")) ;; One space only for the cellname content separator - (blank-rx (regexp "^\\s*$")) - (inp (open-input-file fname))) + (let ((section-rx (regexp "^\\[(.*)\\]\\s*$")) + (comment-rx (regexp "^#.*")) ;; This means a cell name cannot start with # + (cell-rx (regexp "^(\\S+) (.*)$")) ;; One space only for the cellname content separator + (blank-rx (regexp "^\\s*$")) + (inp (open-input-file fname)) + (cmnt-indx (make-hash-table))) (let loop ((inl (read-line inp)) (section #f) (res '())) (if (eof-object? inl) (begin (close-input-port inp) (reverse res)) (regex-case inl - (comment-rx _ (loop (read-line inp) section res)) + (comment-rx _ (let ((curr-indx (+ 1 (hash-table-ref/default cmnt-indx section 0)))) + (hash-table-set! cmnt-indx section curr-indx) + (loop (read-line inp) + section + (cons (list (conc "#CMNT" curr-indx) section inl) res)))) (blank-rx _ (loop (read-line inp) section res)) (section-rx (x sname) (loop (read-line inp) sname res)) (cell-rx (x k v) (loop (read-line inp) @@ -342,34 +352,36 @@ #f))) ;; call with proc = car to get row names ;; call with proc = cadr to get col names (define (get-rowcol-names path sheet proc) - (let ((fname (conc path "/" sheet ".dat"))) + (let ((fname (conc path "/" sheet ".dat")) + (cmnt-rx (regexp "^#CMNT\\d+\\s*"))) (if (file-exists? fname) (let ((dat (read-dat fname))) (if (null? dat) '() (let loop ((hed (car dat)) (tal (cdr dat)) (res '())) (let* ((row-name (proc hed)) - (newres (if (not (member row-name res)) + (newres (if (and (not (member row-name res)) + (not (string-search cmnt-rx row-name))) (cons row-name res) res))) (if (null? tal) (reverse newres) (loop (car tal)(cdr tal) newres)))))) '()))) -(define (get-col-names path sheet) - (let ((fname (conc path "/" sheet ".dat"))) - (if (file-exists? fname) - (let ((dat (read-dat fname))) - (if (null? dat) - #f - (map cadr dat)))))) +;; (define (get-col-names path sheet) +;; (let ((fname (conc path "/" sheet ".dat"))) +;; (if (file-exists? fname) +;; (let ((dat (read-dat fname))) +;; (if (null? dat) +;; #f +;; (map cadr dat)))))) (define (edit-refdb path) (let* ((dbname (pathname-strip-directory path)) (tmpf (conc (create-temporary-file dbname) ".gnumeric"))) (if (file-exists? (conc path "/sheet-names.cfg"))