From bb48738c4111f5f4e2faa40fe67ae1b8b9d7c2eb Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Wed, 29 Nov 2017 15:51:39 +0100 Subject: Rework on the Sheet.ml API : removed low level functions, made the sheet mutable --- src/odf/odf.ml | 2 +- src/odf/odfLoader.ml | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src/odf') diff --git a/src/odf/odf.ml b/src/odf/odf.ml index 176e70a..1db9d4b 100755 --- a/src/odf/odf.ml +++ b/src/odf/odf.ml @@ -210,7 +210,7 @@ let save sheet file = begin Xmlm.output output (`El_start (NS.table_node, [])); Xmlm.output output (`El_start (NS.table_row_node, [])); - ignore (Sheet.Raw.fold (f output) (1,1) sheet); + ignore (Sheet.fold (f output) (1,1) sheet); Xmlm.output output `El_end; Xmlm.output output `El_end; diff --git a/src/odf/odfLoader.ml b/src/odf/odfLoader.ml index 93a6c62..280e6bd 100755 --- a/src/odf/odfLoader.ml +++ b/src/odf/odfLoader.ml @@ -83,7 +83,7 @@ let build_p (attributes:Xmlm.attribute list) = begin function end -let build_row (sheet:Sheet.Raw.t ref) (row_num:int ref) catalog (attributes:Xmlm.attribute list) (childs:tree list) = begin +let build_row (sheet:Sheet.t) (row_num:int ref) (attributes:Xmlm.attribute list) (childs:tree list) = begin let repetition = try int_of_string @@ List.assoc (NS.table, "number-rows-repeated") attributes @@ -94,7 +94,7 @@ let build_row (sheet:Sheet.Raw.t ref) (row_num:int ref) catalog (attributes:Xmlm List.iter (function | Cell cell -> for i = 1 to cell.repetition do - sheet := snd @@ Sheet.Raw.add (!cell_num, !row_num) cell.expression catalog !sheet; + ignore @@ Sheet.add ~history:false cell.expression (!cell_num, !row_num) sheet; cell_num := !cell_num + cell.cell_width done; | _ -> () @@ -109,13 +109,13 @@ let data str = Data str let load catalog source = begin (* Mutable datas *) - let sheet = ref Sheet.Raw.empty in + let sheet = Sheet.create catalog in let cache = Hashtbl.create 10 in let table = Base.String_dict.of_alist_exn [ ((NS.text ^ "p"), build_p); ((NS.table ^ "table-cell"), build_cell cache); - ((NS.table ^ "table-row"), build_row sheet (ref 1) catalog) + ((NS.table ^ "table-row"), build_row sheet (ref 1)) ] in let el (((ns, name), attributes):Xmlm.tag) childs = begin @@ -125,6 +125,6 @@ let load catalog source = begin end in match Xmlm.input_doc_tree ~el ~data source with - | _, Unit -> !sheet + | _, Unit -> sheet | _ -> raise Not_found end -- cgit v1.2.3