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 "../env.hpp"
12 #include "types.hpp"
13 
14 #include <ostream>
15 #include <memory>
16 
17 #include <ixion/address.hpp>
18 #include <ixion/formula_tokens.hpp>
19 #include <ixion/formula_result.hpp>
20 
21 namespace orcus {
22 
23 struct date_time_t;
24 
25 namespace spreadsheet {
26 
27 class document;
28 struct auto_filter_t;
29 
30 namespace detail {
31 
32 struct sheet_impl;
33 
34 }
35 
40 class ORCUS_SPM_DLLPUBLIC sheet
41 {
42  friend class document;
43  friend struct detail::sheet_impl;
44 
45  static const row_t max_row_limit;
46  static const col_t max_col_limit;
47 
48 public:
49  sheet(document& doc, sheet_t sheet_index);
50  ~sheet() noexcept;
51 
52  void set_auto(row_t row, col_t col, std::string_view s);
53  void set_string(row_t row, col_t col, string_id_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_column_format(col_t col, col_t col_span, std::size_t index);
60  void set_row_format(row_t row, std::size_t index);
61 
62  void set_formula(row_t row, col_t col, const ixion::formula_tokens_store_ptr_t& tokens);
63  void set_formula(row_t row, col_t col, const ixion::formula_tokens_store_ptr_t& tokens, ixion::formula_result result);
64  void set_grouped_formula(const range_t& range, ixion::formula_tokens_t tokens);
65  void set_grouped_formula(const range_t& range, ixion::formula_tokens_t tokens, ixion::formula_result result);
66 
67  void set_col_width(col_t col, col_t col_span, col_width_t width);
68 
82  col_width_t get_col_width(col_t col, col_t* col_start, col_t* col_end) const;
83 
84  void set_col_hidden(col_t col, col_t col_span, bool hidden);
85  bool is_col_hidden(col_t col, col_t* col_start, col_t* col_end) const;
86 
87  void set_row_height(row_t row, row_height_t height);
88  row_height_t get_row_height(row_t row, row_t* row_start, row_t* row_end) const;
89 
90  void set_row_hidden(row_t row, bool hidden);
91  bool is_row_hidden(row_t row, row_t* row_start, row_t* row_end) const;
92 
93  void set_merge_cell_range(const range_t& range);
94 
95  void fill_down_cells(row_t src_row, col_t src_col, row_t range_size);
96 
105  range_t get_merge_cell_range(row_t row, col_t col) const;
106 
107  size_t get_string_identifier(row_t row, col_t col) const;
108 
109  auto_filter_t* get_auto_filter_data();
110  const auto_filter_t* get_auto_filter_data() const;
111  void set_auto_filter_data(auto_filter_t* p);
112 
113  // Sheet dimension methods
114 
122  ixion::abs_range_t get_data_range() const;
123 
124  sheet_t get_index() const;
125 
126  date_time_t get_date_time(row_t row, col_t col) const;
127 
128  void dump_flat(std::ostream& os) const;
129  void dump_check(std::ostream& os, std::string_view sheet_name) const;
130  void dump_html(std::ostream& os) const;
131  void dump_json(std::ostream& os) const;
132  void dump_csv(std::ostream& os) const;
133 
134  void dump_debug_state(const std::string& output_dir, std::string_view sheet_name) const;
135 
139  size_t get_cell_format(row_t row, col_t col) const;
140 
141 private:
142  void finalize_import();
143 
144  std::unique_ptr<detail::sheet_impl> mp_impl;
145 };
146 
147 }}
148 
149 #endif
150 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition: document.hpp:54
Definition: sheet.hpp:41
size_t get_cell_format(row_t row, col_t col) const
col_width_t get_col_width(col_t col, col_t *col_start, col_t *col_end) const
range_t get_merge_cell_range(row_t row, col_t col) const
ixion::abs_range_t get_data_range() const
Definition: tokens.hpp:30
Definition: types.hpp:528
Definition: auto_filter.hpp:46
Definition: types.hpp:600