Orcus
sheet.hpp
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This Source Code Form is subject to the terms of the Mozilla Public
4  * License, v. 2.0. If a copy of the MPL was not distributed with this
5  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
6  */
7 
8 #ifndef INCLUDED_ORCUS_SPREADSHEET_ODSTABLE_HPP
9 #define INCLUDED_ORCUS_SPREADSHEET_ODSTABLE_HPP
10 
11 #include "orcus/spreadsheet/import_interface.hpp"
12 #include "orcus/spreadsheet/export_interface.hpp"
13 #include "orcus/env.hpp"
14 
15 #include <ostream>
16 #include <ixion/address.hpp>
17 
18 namespace orcus {
19 
20 class pstring;
21 
22 namespace spreadsheet {
23 
24 class document;
25 class sheet_range;
26 struct sheet_impl;
27 struct auto_filter_t;
28 
33 class ORCUS_SPM_DLLPUBLIC sheet : public iface::import_sheet, public iface::export_sheet
34 {
35  friend struct sheet_impl;
36 
37  static const row_t max_row_limit;
38  static const col_t max_col_limit;
39 
40 public:
41  sheet(document& doc, sheet_t sheet_index, row_t row_size, col_t col_size);
42  virtual ~sheet();
43 
44  // Import methods
45 
46  virtual iface::import_sheet_properties* get_sheet_properties();
47  virtual iface::import_data_table* get_data_table();
48  virtual iface::import_table* get_table();
49  virtual iface::import_auto_filter* get_auto_filter();
50 
51  virtual void set_auto(row_t row, col_t col, const char* p, size_t n);
52  virtual void set_string(row_t row, col_t col, size_t sindex);
53  virtual void set_value(row_t row, col_t col, double value);
54  virtual void set_bool(row_t row, col_t col, bool value);
55  virtual void set_date_time(row_t row, col_t col, int year, int month, int day, int hour, int minute, double second);
56  virtual void set_format(row_t row, col_t col, size_t index);
57  virtual void set_format(row_t row_start, col_t col_start, row_t row_end, col_t col_end, size_t index);
58  virtual void set_formula(row_t row, col_t col, formula_grammar_t grammar, const char* p, size_t n);
59  virtual void set_shared_formula(
60  row_t row, col_t col, formula_grammar_t grammar, size_t sindex,
61  const char* p_formula, size_t n_formula, const char* p_range, size_t n_range);
62  virtual void set_shared_formula(
63  row_t row, col_t col, formula_grammar_t grammar, size_t sindex,
64  const char* p_formula, size_t n_formula);
65  virtual void set_shared_formula(row_t row, col_t col, size_t sindex);
66  virtual void set_formula_result(row_t row, col_t col, double value);
67  virtual void set_formula_result(row_t row, col_t col, const char* p, size_t n);
68  virtual void set_array_formula(row_t, col_t, formula_grammar_t,
69  const char*, size_t, row_t, col_t);
70  virtual void set_array_formula(row_t, col_t, formula_grammar_t,
71  const char*, size_t, const char*, size_t);
72 
73  // Export methods
74 
75  virtual void write_string(std::ostream& os, row_t row, col_t col) const;
76 
77  void set_col_width(col_t col, col_width_t width);
78  col_width_t get_col_width(col_t col, col_t* col_start, col_t* col_end) const;
79 
80  void set_col_hidden(col_t col, bool hidden);
81 
82  void set_row_height(row_t row, row_height_t height);
83  row_height_t get_row_height(row_t row, row_t* row_start, row_t* row_end) const;
84 
85  void set_row_hidden(row_t row, bool hidden);
86 
87  void set_merge_cell_range(const char* p_ref, size_t p_ref_len);
88 
89  size_t get_string_identifier(row_t row, col_t col) const;
90 
91  auto_filter_t* get_auto_filter_data();
92  const auto_filter_t* get_auto_filter_data() const;
93  void set_auto_filter_data(auto_filter_t* p);
94 
95  // Sheet dimension methods
96 
104  ixion::abs_range_t get_data_range() const;
105 
117  sheet_range get_sheet_range(
118  row_t row_start, col_t col_start, row_t row_end, col_t col_end) const;
119 
120  row_t row_size() const;
121  col_t col_size() const;
122  sheet_t get_index() const;
123 
124  void finalize();
125 
126  void dump_flat(std::ostream& os) const;
127  void dump_check(std::ostream& os, const pstring& sheet_name) const;
128  void dump_html(const ::std::string& filepath) const;
129  void dump_json(const ::std::string& filepath) const;
130 
134  size_t get_cell_format(row_t row, col_t col) const;
135 
136 private:
137  sheet_impl* mp_impl;
138 };
139 
140 }}
141 
142 #endif
143 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition: import_interface.hpp:426
Definition: pstring.hpp:24
Definition: document.hpp:45
Definition: import_interface.hpp:209
Definition: sheet.hpp:33
Definition: import_interface.hpp:167
Definition: export_interface.hpp:18
Definition: import_interface.hpp:193
Definition: import_interface.hpp:389
Definition: sheet_range.hpp:27
Definition: auto_filter.hpp:38
Definition: base64.hpp:15