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 struct date_time_t;
22 
23 namespace spreadsheet {
24 
25 class document;
26 class sheet_range;
27 struct sheet_impl;
28 struct auto_filter_t;
29 
34 class ORCUS_SPM_DLLPUBLIC sheet : public iface::export_sheet
35 {
36  friend struct sheet_impl;
37 
38  static const row_t max_row_limit;
39  static const col_t max_col_limit;
40 
41 public:
42  sheet(document& doc, sheet_t sheet_index, row_t row_size, col_t col_size);
43  virtual ~sheet();
44 
45  // Import methods
46 
47  iface::import_sheet_properties* get_sheet_properties();
48  iface::import_data_table* get_data_table();
49  iface::import_table* get_table();
50  iface::import_auto_filter* get_auto_filter();
51 
52  void set_auto(row_t row, col_t col, const char* p, size_t n);
53  void set_string(row_t row, col_t col, size_t sindex);
54  void set_value(row_t row, col_t col, double value);
55  void set_bool(row_t row, col_t col, bool value);
56  void set_date_time(row_t row, col_t col, int year, int month, int day, int hour, int minute, double second);
57  void set_format(row_t row, col_t col, size_t index);
58  void set_format(row_t row_start, col_t col_start, row_t row_end, col_t col_end, size_t index);
59  void set_formula(row_t row, col_t col, formula_grammar_t grammar, const char* p, size_t n);
60  void set_shared_formula(
61  row_t row, col_t col, formula_grammar_t grammar, size_t sindex,
62  const char* p_formula, size_t n_formula, const char* p_range, size_t n_range);
63  void set_shared_formula(
64  row_t row, col_t col, formula_grammar_t grammar, size_t sindex,
65  const char* p_formula, size_t n_formula);
66  void set_shared_formula(row_t row, col_t col, size_t sindex);
67  void set_formula_result(row_t row, col_t col, double value);
68  void set_formula_result(row_t row, col_t col, const char* p, size_t n);
69  void set_array_formula(row_t, col_t, formula_grammar_t,
70  const char*, size_t, row_t, col_t);
71  void set_array_formula(row_t, col_t, formula_grammar_t,
72  const char*, size_t, const char*, size_t);
73 
74  // Export methods
75 
76  virtual void write_string(std::ostream& os, row_t row, col_t col) const;
77 
78  void set_col_width(col_t col, col_width_t width);
79  col_width_t get_col_width(col_t col, col_t* col_start, col_t* col_end) const;
80 
81  void set_col_hidden(col_t col, bool hidden);
82 
83  void set_row_height(row_t row, row_height_t height);
84  row_height_t get_row_height(row_t row, row_t* row_start, row_t* row_end) const;
85 
86  void set_row_hidden(row_t row, bool hidden);
87 
88  void set_merge_cell_range(const range_t& range);
89 
98  range_t get_merge_cell_range(row_t row, col_t col) const;
99 
100  size_t get_string_identifier(row_t row, col_t col) const;
101 
102  auto_filter_t* get_auto_filter_data();
103  const auto_filter_t* get_auto_filter_data() const;
104  void set_auto_filter_data(auto_filter_t* p);
105 
106  // Sheet dimension methods
107 
115  ixion::abs_range_t get_data_range() const;
116 
128  sheet_range get_sheet_range(
129  row_t row_start, col_t col_start, row_t row_end, col_t col_end) const;
130 
131  row_t row_size() const;
132  col_t col_size() const;
133  sheet_t get_index() const;
134 
135  date_time_t get_date_time(row_t row, col_t col) const;
136 
137  void finalize();
138 
139  void dump_flat(std::ostream& os) const;
140  void dump_check(std::ostream& os, const pstring& sheet_name) const;
141  void dump_html(std::ostream& os) const;
142  void dump_json(std::ostream& os) const;
143  void dump_csv(std::ostream& os) const;
144 
148  size_t get_cell_format(row_t row, col_t col) const;
149 
150 private:
151  sheet_impl* mp_impl;
152 };
153 
154 }}
155 
156 #endif
157 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition: pstring.hpp:24
Definition: types.hpp:118
Definition: document.hpp:47
Definition: import_interface.hpp:238
Definition: sheet.hpp:34
Definition: types.hpp:334
Definition: import_interface.hpp:174
Definition: export_interface.hpp:18
Definition: import_interface.hpp:222
Definition: import_interface.hpp:418
Definition: sheet_range.hpp:27
Definition: auto_filter.hpp:38
Definition: base64.hpp:15