Orcus
document.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_DOCUMENT_HPP
9 #define INCLUDED_ORCUS_SPREADSHEET_DOCUMENT_HPP
10 
11 #include "orcus/env.hpp"
12 #include "orcus/interface.hpp"
13 #include "orcus/spreadsheet/types.hpp"
14 
15 #include <ostream>
16 #include <memory>
17 
18 namespace ixion {
19 
20 class formula_name_resolver;
21 class model_context;
22 struct abs_address_t;
23 
24 }
25 
26 namespace orcus {
27 
28 class string_pool;
29 struct date_time_t;
30 
31 namespace spreadsheet {
32 
33 class shared_strings;
34 class styles;
35 class pivot_collection;
36 class sheet;
37 class import_factory;
38 
39 struct document_config;
40 struct table_t;
41 
42 namespace detail {
43 
44 struct document_impl;
45 
46 }
47 
53 class ORCUS_SPM_DLLPUBLIC document : public orcus::iface::document_dumper
54 {
55  friend class sheet;
56  friend class import_factory;
57 
58 public:
59  document(const document&) = delete;
60  document& operator= (const document&) = delete;
61 
62  document(const range_size_t& sheet_size);
63  ~document();
64 
66  virtual void dump(dump_format_t format, const std::string& output) const override;
67 
69  virtual void dump_check(std::ostream& os) const override;
70 
71  shared_strings& get_shared_strings();
72  const shared_strings& get_shared_strings() const;
73 
74  styles& get_styles();
75  const styles& get_styles() const;
76 
77  pivot_collection& get_pivot_collection();
78  const pivot_collection& get_pivot_collection() const;
79 
80  sheet* append_sheet(std::string_view sheet_name);
81  sheet* get_sheet(std::string_view sheet_name);
82  const sheet* get_sheet(std::string_view sheet_name) const;
83  sheet* get_sheet(sheet_t sheet_pos);
84  const sheet* get_sheet(sheet_t sheet_pos) const;
85 
89  void clear();
90 
96 
97  sheet_t get_sheet_index(std::string_view name) const;
98  std::string_view get_sheet_name(sheet_t sheet_pos) const;
99 
100  range_size_t get_sheet_size() const;
101  void set_sheet_size(const range_size_t& sheet_size);
102  size_t get_sheet_count() const;
103 
104  void set_origin_date(int year, int month, int day);
105  date_time_t get_origin_date() const;
106 
107  void set_formula_grammar(formula_grammar_t grammar);
108  formula_grammar_t get_formula_grammar() const;
109 
110  const ixion::formula_name_resolver* get_formula_name_resolver(formula_ref_context_t cxt) const;
111 
112  ixion::model_context& get_model_context();
113  const ixion::model_context& get_model_context() const;
114 
115  const document_config& get_config() const;
116  void set_config(const document_config& cfg);
117 
118  string_pool& get_string_pool();
119  const string_pool& get_string_pool() const;
120 
130 
139  const table_t* get_table(std::string_view name) const;
140 
141 private:
142  void dump_flat(const std::string& outdir) const;
143  void dump_html(const ::std::string& outdir) const;
144  void dump_json(const ::std::string& outdir) const;
145  void dump_csv(const std::string& outdir) const;
146  void dump_debug_state(const std::string& outdir) const;
147 
148  void finalize_import();
149  void insert_dirty_cell(const ixion::abs_address_t& pos);
150 
151 private:
152  std::unique_ptr<detail::document_impl> mp_impl;
153 };
154 
155 }}
156 
157 #endif
158 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition: interface.hpp:64
Definition: document.hpp:54
virtual void dump_check(std::ostream &os) const override
void insert_table(table_t *p)
virtual void dump(dump_format_t format, const std::string &output) const override
const table_t * get_table(std::string_view name) const
Definition: factory.hpp:33
Definition: pivot.hpp:208
Definition: shared_strings.hpp:31
Definition: sheet.hpp:41
Definition: styles.hpp:189
Definition: string_pool.hpp:26
Definition: types.hpp:527
Definition: config.hpp:18
Definition: types.hpp:590
Definition: auto_filter.hpp:118