summaryrefslogtreecommitdiffstats
path: root/src/spreadsheet/sheet_impl.cpp
blob: 1364e25fc61d6177e7073b5e10339b12e7475216 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

#include "sheet_impl.hpp"
#include "orcus/spreadsheet/document.hpp"

#include <ixion/model_context.hpp>

namespace orcus { namespace spreadsheet { namespace detail {

sheet_impl::sheet_impl(document& _doc, sheet& /*sh*/, sheet_t sheet_index) :
    doc(_doc),
    col_widths(0, doc.get_sheet_size().columns, get_default_column_width()),
    row_heights(0, doc.get_sheet_size().rows, get_default_row_height()),
    col_width_pos(col_widths.begin()),
    row_height_pos(row_heights.begin()),
    col_hidden(0, doc.get_sheet_size().columns, false),
    row_hidden(0, doc.get_sheet_size().rows, false),
    col_hidden_pos(col_hidden.begin()),
    row_hidden_pos(row_hidden.begin()),
    column_formats(0, doc.get_sheet_size().columns, 0),
    row_formats(0, doc.get_sheet_size().rows, 0),
    sheet_id(sheet_index) {}

sheet_impl::~sheet_impl() {}

const detail::merge_size* sheet_impl::get_merge_size(row_t row, col_t col) const
{
    detail::col_merge_size_type::const_iterator it_col = merge_ranges.find(col);
    if (it_col == merge_ranges.end())
        return nullptr;

    detail::merge_size_type& col_merge_sizes = *it_col->second;
    detail::merge_size_type::const_iterator it_row = col_merge_sizes.find(row);
    if (it_row == col_merge_sizes.end())
        return nullptr;

    return &it_row->second;
}

ixion::abs_range_t sheet_impl::get_data_range() const
{
    const ixion::model_context& cxt = doc.get_model_context();
    return cxt.get_data_range(sheet_id);
}

}}}

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */