Spreadsheet Document

Document

class document : public orcus::iface::document_dumper

Internal document representation used only for testing the filters. It uses ixion’s model_context implementation to store raw cell values.

Public Functions

document(const document&)
document &operator=(const document&)
document(const range_size_t &sheet_size)
~document()
import_shared_strings *get_shared_strings()
const import_shared_strings *get_shared_strings() const
styles &get_styles()
const styles &get_styles() const
pivot_collection &get_pivot_collection()
const pivot_collection &get_pivot_collection() const
sheet *append_sheet(const pstring &sheet_name)
sheet *get_sheet(const pstring &sheet_name)
const sheet *get_sheet(const pstring &sheet_name) const
sheet *get_sheet(sheet_t sheet_pos)
const sheet *get_sheet(sheet_t sheet_pos) const
void clear()

Clear document content, to make it empty.

void recalc_formula_cells()

Calculate those formula cells that have been newly inserted and have not yet been calculated.

virtual void dump(dump_format_t format, const std::string &output) const
void dump_flat(const std::string &outdir) const

Dump document content to specified output directory.

void dump_html(const std::string &outdir) const

File name should not contain an extension. The final name will be [filename] + _ + [sheet name] + .html.

Parameters
  • filename: base file name

void dump_json(const std::string &outdir) const
void dump_csv(const std::string &outdir) const
virtual void dump_check(std::ostream &os) const

Dump document content to stdout in the special format used for content verification during unit test.

sheet_t get_sheet_index(const pstring &name) const
pstring get_sheet_name(sheet_t sheet_pos) const
range_size_t get_sheet_size() const
void set_sheet_size(const range_size_t &sheet_size)
size_t get_sheet_count() const
void set_origin_date(int year, int month, int day)
date_time_t get_origin_date() const
void set_formula_grammar(formula_grammar_t grammar)
formula_grammar_t get_formula_grammar() const
const ixion::formula_name_resolver *get_formula_name_resolver(formula_ref_context_t cxt) const
ixion::model_context &get_model_context()
const ixion::model_context &get_model_context() const
const document_config &get_config() const
void set_config(const document_config &cfg)
string_pool &get_string_pool()
void insert_table(table_t *p)

Insert a new table object into the document. The document will take ownership of the inserted object after the call. The object will get inserted only when there is no pre-existing table object of the same name. The object not being inserted will be deleted.

Parameters
  • p: table object to insert.

const table_t *get_table(const pstring &name) const
void finalize()

Sheet

class sheet

This class represents a single sheet instance in the internal document model.

Public Functions

sheet(document &doc, sheet_t sheet_index)
virtual ~sheet()
void set_auto(row_t row, col_t col, const char *p, size_t n)
void set_string(row_t row, col_t col, size_t sindex)
void set_value(row_t row, col_t col, double value)
void set_bool(row_t row, col_t col, bool value)
void set_date_time(row_t row, col_t col, int year, int month, int day, int hour, int minute, double second)
void set_format(row_t row, col_t col, size_t index)
void set_format(row_t row_start, col_t col_start, row_t row_end, col_t col_end, size_t index)
void set_formula(row_t row, col_t col, const ixion::formula_tokens_store_ptr_t &tokens)
void set_formula(row_t row, col_t col, const ixion::formula_tokens_store_ptr_t &tokens, ixion::formula_result result)
void set_grouped_formula(const range_t &range, ixion::formula_tokens_t tokens)
void set_grouped_formula(const range_t &range, ixion::formula_tokens_t tokens, ixion::formula_result result)
void set_col_width(col_t col, col_width_t width)
col_width_t get_col_width(col_t col, col_t *col_start, col_t *col_end) const
void set_col_hidden(col_t col, bool hidden)
bool is_col_hidden(col_t col, col_t *col_start, col_t *col_end) const
void set_row_height(row_t row, row_height_t height)
row_height_t get_row_height(row_t row, row_t *row_start, row_t *row_end) const
void set_row_hidden(row_t row, bool hidden)
bool is_row_hidden(row_t row, row_t *row_start, row_t *row_end) const
void set_merge_cell_range(const range_t &range)
void fill_down_cells(row_t src_row, col_t src_col, row_t range_size)
range_t get_merge_cell_range(row_t row, col_t col) const

Return the size of a merged cell range.

Return
merged cell range.
Parameters
  • row: row position of the upper-left cell.
  • col: column position of the upper-left cell.

size_t get_string_identifier(row_t row, col_t col) const
auto_filter_t *get_auto_filter_data()
const auto_filter_t *get_auto_filter_data() const
void set_auto_filter_data(auto_filter_t *p)
ixion::abs_range_t get_data_range() const

Return the smallest range that contains all non-empty cells in this sheet. The top-left corner of the returned range is always column 0 and row 0.

Return
smallest range that contains all non-empty cells.

sheet_range get_sheet_range(row_t row_start, col_t col_start, row_t row_end, col_t col_end) const

Return a sheet range object that represents a sub-range within the sheet.

Return
sheet range object.
Parameters
  • row_start: start row position (0-based).
  • col_start: start column position (0-based).
  • row_end: end row position (0-based).
  • col_end: end column position (0-based).

sheet_t get_index() const
date_time_t get_date_time(row_t row, col_t col) const
void finalize()
void dump_flat(std::ostream &os) const
void dump_check(std::ostream &os, const pstring &sheet_name) const
void dump_html(std::ostream &os) const
void dump_json(std::ostream &os) const
void dump_csv(std::ostream &os) const
size_t get_cell_format(row_t row, col_t col) const

Get the cell format ID of specified cell.

Pivot Table

struct pivot_cache_record_value_t

Public Types

enum value_type

Values:

unknown = 0
boolean
date_time
character
numeric
blank
error
shared_item_index

Public Functions

pivot_cache_record_value_t()
pivot_cache_record_value_t(const char *cp, size_t cn)
pivot_cache_record_value_t(double v)
pivot_cache_record_value_t(size_t index)
bool operator==(const pivot_cache_record_value_t &other) const
bool operator!=(const pivot_cache_record_value_t &other) const

Public Members

value_type type
bool boolean
const char *p
size_t n
struct orcus::spreadsheet::pivot_cache_record_value_t::[anonymous]::[anonymous] character
int year
int month
int day
int hour
int minute
double second
struct orcus::spreadsheet::pivot_cache_record_value_t::[anonymous]::[anonymous] date_time
double numeric
size_t shared_item_index
union orcus::spreadsheet::pivot_cache_record_value_t::[anonymous] value
struct pivot_cache_item_t

Public Types

enum item_type

Values:

unknown = 0
boolean
date_time
character
numeric
blank
error

Public Functions

pivot_cache_item_t()
pivot_cache_item_t(const char *cp, size_t cn)
pivot_cache_item_t(double numeric)
pivot_cache_item_t(bool boolean)
pivot_cache_item_t(const date_time_t &date_time)
pivot_cache_item_t(error_value_t error)
pivot_cache_item_t(const pivot_cache_item_t &other)
pivot_cache_item_t(pivot_cache_item_t &&other)
bool operator<(const pivot_cache_item_t &other) const
bool operator==(const pivot_cache_item_t &other) const
pivot_cache_item_t &operator=(pivot_cache_item_t other)
void swap(pivot_cache_item_t &other)

Public Members

item_type type
const char *p
size_t n
struct orcus::spreadsheet::pivot_cache_item_t::[anonymous]::[anonymous] character
int year
int month
int day
int hour
int minute
double second
struct orcus::spreadsheet::pivot_cache_item_t::[anonymous]::[anonymous] date_time
double numeric
error_value_t error
bool boolean
union orcus::spreadsheet::pivot_cache_item_t::[anonymous] value
struct pivot_cache_group_data_t

Group data for a pivot cache field.

Public Functions

pivot_cache_group_data_t(size_t _base_field)
pivot_cache_group_data_t(const pivot_cache_group_data_t &other)
pivot_cache_group_data_t(pivot_cache_group_data_t &&other)
pivot_cache_group_data_t()

Public Members

pivot_cache_indices_t base_to_group_indices

Mapping of base field member indices to the group field item indices.

boost::optional<range_grouping_type> range_grouping
pivot_cache_items_t items

Individual items comprising the group.

size_t base_field

0-based index of the base field.

struct range_grouping_type

Public Functions

range_grouping_type()
range_grouping_type(const range_grouping_type &other)

Public Members

pivot_cache_group_by_t group_by = pivot_cache_group_by_t::range
bool auto_start = true
bool auto_end = true
double start = 0.0
double end = 0.0
double interval = 1.0
date_time_t start_date
date_time_t end_date
struct pivot_cache_field_t

Public Functions

pivot_cache_field_t()
pivot_cache_field_t(const pstring &_name)
pivot_cache_field_t(const pivot_cache_field_t &other)
pivot_cache_field_t(pivot_cache_field_t &&other)

Public Members

pstring name

Field name. It must be interned with the string pool belonging to the document.

pivot_cache_items_t items
boost::optional<double> min_value
boost::optional<double> max_value
boost::optional<date_time_t> min_date
boost::optional<date_time_t> max_date
std::unique_ptr<pivot_cache_group_data_t> group_data
class pivot_cache

Public Types

using fields_type = std::vector<pivot_cache_field_t>
using records_type = std::vector<pivot_cache_record_t>

Public Functions

pivot_cache(pivot_cache_id_t cache_id, string_pool &sp)
~pivot_cache()
void insert_fields(fields_type fields)

Bulk-insert all the fields in one step. Note that this will replace any pre-existing fields if any.

Parameters
  • fields: field instances to move into storage.

void insert_records(records_type record)
size_t get_field_count() const
const pivot_cache_field_t *get_field(size_t index) const

Retrieve a field data by its index.

Return
pointer to the field instance, or nullptr if the index is out-of-range.
Parameters
  • index: index of the field to retrieve.

pivot_cache_id_t get_id() const
const records_type &get_all_records() const
class pivot_collection

Public Functions

pivot_collection(document &doc)
~pivot_collection()
void insert_worksheet_cache(const pstring &sheet_name, const ixion::abs_range_t &range, std::unique_ptr<pivot_cache> &&cache)

Insert a new pivot cache associated with a worksheet source.

Parameters
  • sheet_name: name of the sheet where the source data is.
  • range: range of the source data. Note that the sheet indices are not used.
  • cache: pivot cache instance to store.

void insert_worksheet_cache(const pstring &table_name, std::unique_ptr<pivot_cache> &&cache)

Insert a new pivot cache associated with a table name.

Parameters
  • table_name: source table name.
  • cache: pivot cache instance to store.

size_t get_cache_count() const

Count the number of pivot caches currently stored.

Return
number of pivot caches currently stored in the document.

const pivot_cache *get_cache(const pstring &sheet_name, const ixion::abs_range_t &range) const
pivot_cache *get_cache(pivot_cache_id_t cache_id)
const pivot_cache *get_cache(pivot_cache_id_t cache_id) const

Import Factory

class import_factory : public orcus::spreadsheet::iface::import_factory

Public Functions

import_factory(document &doc)
import_factory(document &doc, view &view)
virtual ~import_factory()
virtual iface::import_global_settings *get_global_settings()
virtual iface::import_shared_strings *get_shared_strings()

Return
pointer to the shared strings instance. It may return NULL if the client app doesn’t support shared strings.

virtual iface::import_styles *get_styles()

Return
pointer to the styles instance. It may return NULL if the client app doesn’t support styles.

virtual iface::import_named_expression *get_named_expression()
virtual iface::import_reference_resolver *get_reference_resolver(formula_ref_context_t cxt)
virtual iface::import_pivot_cache_definition *create_pivot_cache_definition(orcus::spreadsheet::pivot_cache_id_t cache_id)

Create an interface for pivot cache definition import for a specified cache ID. In case a pivot cache alrady exists for the passed ID, the client app should overwrite the existing cache with a brand-new cache instance.

Return
pointer to the pivot cache interface instance. If may return NULL if the client app doesn’t support pivot tables.
Parameters
  • cache_id: numeric ID associated with the pivot cache.

virtual iface::import_pivot_cache_records *create_pivot_cache_records(orcus::spreadsheet::pivot_cache_id_t cache_id)

Create an interface for pivot cache records import for a specified cache ID.

Return
pointer to the pivot cache records interface instance. If may return nullptr if the client app doesn’t support pivot tables.
Parameters
  • cache_id: numeric ID associated with the pivot cache.

virtual iface::import_sheet *append_sheet(sheet_t sheet_index, const char *sheet_name, size_t sheet_name_length)

Append a sheet with specified sheet position index and name.

Return
pointer to the sheet instance. It may return nullptr if the client app fails to append a new sheet.
Parameters
  • sheet_index: position index of the sheet to be appended. It is 0-based i.e. the first sheet to be appended will have an index value of 0.
  • sheet_name: pointer to the first character in the buffer where the sheet name is stored.
  • sheet_name_length: length of the sheet name.

virtual iface::import_sheet *get_sheet(const char *sheet_name, size_t sheet_name_length)

Return
pointer to the sheet instance whose name matches the name passed to this method. It returns nullptr if no sheet instance exists by the specified name.

virtual iface::import_sheet *get_sheet(sheet_t sheet_index)

Retrieve sheet instance by specified numerical sheet index.

Return
pointer to the sheet instance, or nullptr if no sheet instance exists at specified sheet index position.
Parameters
  • sheet_index: sheet index

virtual void finalize()

This method is called at the end of import, to give the implementor a chance to perform post-processing if necessary.

void set_default_row_size(row_t row_size)
void set_default_column_size(col_t col_size)
void set_character_set(character_set_t charset)
character_set_t get_character_set() const
void set_recalc_formula_cells(bool b)

When setting this flag to true, those formula cells with no cached results will be re-calculated upon loading.

Parameters
  • b: value of this flag.

void set_formula_error_policy(formula_error_policy_t policy)