2020-02-09 01:12:59 +08:00
|
|
|
// Copyright (c) 2014-2020 Thomas Fussell
|
2015-12-25 04:51:11 +08:00
|
|
|
//
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
// of this software and associated documentation files (the "Software"), to deal
|
|
|
|
// in the Software without restriction, including without limitation the rights
|
|
|
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
// copies of the Software, and to permit persons to whom the Software is
|
|
|
|
// furnished to do so, subject to the following conditions:
|
|
|
|
//
|
|
|
|
// The above copyright notice and this permission notice shall be included in
|
|
|
|
// all copies or substantial portions of the Software.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, WRISING FROM,
|
|
|
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
// THE SOFTWARE
|
|
|
|
//
|
|
|
|
// @license: http://www.opensource.org/licenses/mit-license.php
|
|
|
|
// @author: see AUTHORS file
|
2017-04-21 02:03:03 +08:00
|
|
|
|
2016-05-16 03:03:02 +08:00
|
|
|
#pragma once
|
|
|
|
|
2014-05-30 08:52:14 +08:00
|
|
|
#include <string>
|
|
|
|
#include <unordered_map>
|
|
|
|
#include <vector>
|
|
|
|
|
2018-10-05 21:30:54 +08:00
|
|
|
#include <xlnt/drawing/spreadsheet_drawing.hpp>
|
2018-06-23 15:08:39 +08:00
|
|
|
#include <xlnt/packaging/ext_list.hpp>
|
2016-05-16 03:03:02 +08:00
|
|
|
#include <xlnt/workbook/named_range.hpp>
|
2015-11-01 22:43:01 +08:00
|
|
|
#include <xlnt/worksheet/column_properties.hpp>
|
2016-12-10 08:18:50 +08:00
|
|
|
#include <xlnt/worksheet/header_footer.hpp>
|
2018-06-23 08:15:15 +08:00
|
|
|
#include <xlnt/worksheet/phonetic_pr.hpp>
|
2018-01-27 03:32:00 +08:00
|
|
|
#include <xlnt/worksheet/range.hpp>
|
|
|
|
#include <xlnt/worksheet/range_reference.hpp>
|
2015-11-01 22:43:01 +08:00
|
|
|
#include <xlnt/worksheet/row_properties.hpp>
|
2018-01-27 03:32:00 +08:00
|
|
|
#include <xlnt/worksheet/sheet_format_properties.hpp>
|
|
|
|
#include <xlnt/worksheet/sheet_view.hpp>
|
2018-06-24 10:01:27 +08:00
|
|
|
#include <xlnt/worksheet/print_options.hpp>
|
|
|
|
#include <xlnt/worksheet/sheet_pr.hpp>
|
2018-06-23 08:15:15 +08:00
|
|
|
#include <detail/implementations/cell_impl.hpp>
|
2015-11-01 22:43:01 +08:00
|
|
|
|
2014-05-31 06:42:25 +08:00
|
|
|
namespace xlnt {
|
|
|
|
|
2014-05-30 08:52:14 +08:00
|
|
|
class workbook;
|
|
|
|
|
2014-05-31 06:42:25 +08:00
|
|
|
namespace detail {
|
|
|
|
|
2014-05-30 08:52:14 +08:00
|
|
|
struct worksheet_impl
|
|
|
|
{
|
2016-07-27 08:13:09 +08:00
|
|
|
worksheet_impl(workbook *parent_workbook, std::size_t id, const std::string &title)
|
2016-07-17 03:57:50 +08:00
|
|
|
: parent_(parent_workbook),
|
2016-07-27 08:13:09 +08:00
|
|
|
id_(id),
|
2016-12-10 08:18:50 +08:00
|
|
|
title_(title)
|
2014-05-30 08:52:14 +08:00
|
|
|
{
|
|
|
|
}
|
2015-11-01 22:43:01 +08:00
|
|
|
|
2014-05-30 08:52:14 +08:00
|
|
|
worksheet_impl(const worksheet_impl &other)
|
|
|
|
{
|
|
|
|
*this = other;
|
|
|
|
}
|
2015-11-01 22:43:01 +08:00
|
|
|
|
2014-05-30 08:52:14 +08:00
|
|
|
void operator=(const worksheet_impl &other)
|
|
|
|
{
|
|
|
|
parent_ = other.parent_;
|
2016-12-10 08:18:50 +08:00
|
|
|
|
2016-07-27 08:13:09 +08:00
|
|
|
id_ = other.id_;
|
|
|
|
title_ = other.title_;
|
2018-01-27 03:32:00 +08:00
|
|
|
format_properties_ = other.format_properties_;
|
2015-10-29 03:08:54 +08:00
|
|
|
column_properties_ = other.column_properties_;
|
|
|
|
row_properties_ = other.row_properties_;
|
2014-05-30 08:52:14 +08:00
|
|
|
cell_map_ = other.cell_map_;
|
|
|
|
page_setup_ = other.page_setup_;
|
|
|
|
auto_filter_ = other.auto_filter_;
|
|
|
|
page_margins_ = other.page_margins_;
|
|
|
|
merged_cells_ = other.merged_cells_;
|
|
|
|
named_ranges_ = other.named_ranges_;
|
2018-06-23 08:15:15 +08:00
|
|
|
phonetic_properties_ = other.phonetic_properties_;
|
2014-07-21 21:34:57 +08:00
|
|
|
header_footer_ = other.header_footer_;
|
2016-03-08 15:45:35 +08:00
|
|
|
print_title_cols_ = other.print_title_cols_;
|
|
|
|
print_title_rows_ = other.print_title_rows_;
|
|
|
|
print_area_ = other.print_area_;
|
2016-12-02 21:37:50 +08:00
|
|
|
views_ = other.views_;
|
2016-12-23 07:57:22 +08:00
|
|
|
column_breaks_ = other.column_breaks_;
|
|
|
|
row_breaks_ = other.row_breaks_;
|
2018-06-23 15:08:39 +08:00
|
|
|
extension_list_ = other.extension_list_;
|
2018-06-24 10:01:27 +08:00
|
|
|
sheet_properties_ = other.sheet_properties_;
|
|
|
|
print_options_ = other.print_options_;
|
2018-01-27 03:32:00 +08:00
|
|
|
|
2018-07-29 07:31:38 +08:00
|
|
|
for (auto &cell : cell_map_)
|
2018-01-27 03:32:00 +08:00
|
|
|
{
|
2018-07-29 07:31:38 +08:00
|
|
|
cell.second.parent_ = this;
|
2018-01-27 03:32:00 +08:00
|
|
|
}
|
2014-05-30 08:52:14 +08:00
|
|
|
}
|
2015-11-01 22:43:01 +08:00
|
|
|
|
2014-05-30 08:52:14 +08:00
|
|
|
workbook *parent_;
|
2016-12-10 08:18:50 +08:00
|
|
|
|
2018-07-03 10:05:07 +08:00
|
|
|
bool operator==(const worksheet_impl& rhs) const
|
|
|
|
{
|
|
|
|
return id_ == rhs.id_
|
|
|
|
&& title_ == rhs.title_
|
|
|
|
&& format_properties_ == rhs.format_properties_
|
|
|
|
&& column_properties_ == rhs.column_properties_
|
|
|
|
&& row_properties_ == rhs.row_properties_
|
|
|
|
&& cell_map_ == rhs.cell_map_
|
|
|
|
&& page_setup_ == rhs.page_setup_
|
|
|
|
&& auto_filter_ == rhs.auto_filter_
|
|
|
|
&& page_margins_ == rhs.page_margins_
|
|
|
|
&& merged_cells_ == rhs.merged_cells_
|
|
|
|
&& named_ranges_ == rhs.named_ranges_
|
|
|
|
&& phonetic_properties_ == rhs.phonetic_properties_
|
|
|
|
&& header_footer_ == rhs.header_footer_
|
|
|
|
&& print_title_cols_ == rhs.print_title_cols_
|
|
|
|
&& print_title_rows_ == rhs.print_title_rows_
|
|
|
|
&& print_area_ == rhs.print_area_
|
|
|
|
&& views_ == rhs.views_
|
|
|
|
&& column_breaks_ == rhs.column_breaks_
|
|
|
|
&& row_breaks_ == rhs.row_breaks_
|
|
|
|
&& comments_ == rhs.comments_
|
|
|
|
&& print_options_ == rhs.print_options_
|
|
|
|
&& sheet_properties_ == rhs.sheet_properties_
|
|
|
|
&& extension_list_ == rhs.extension_list_;
|
|
|
|
}
|
|
|
|
|
2016-07-27 08:13:09 +08:00
|
|
|
std::size_t id_;
|
|
|
|
std::string title_;
|
2016-12-10 08:18:50 +08:00
|
|
|
|
2018-01-27 03:32:00 +08:00
|
|
|
sheet_format_properties format_properties_;
|
|
|
|
|
2015-10-29 03:08:54 +08:00
|
|
|
std::unordered_map<column_t, column_properties> column_properties_;
|
2014-06-05 06:42:17 +08:00
|
|
|
std::unordered_map<row_t, row_properties> row_properties_;
|
2016-12-10 08:18:50 +08:00
|
|
|
|
2018-07-29 07:31:38 +08:00
|
|
|
std::unordered_map<cell_reference, cell_impl> cell_map_;
|
2016-12-10 08:18:50 +08:00
|
|
|
|
|
|
|
optional<page_setup> page_setup_;
|
|
|
|
optional<range_reference> auto_filter_;
|
|
|
|
optional<page_margins> page_margins_;
|
2014-05-30 08:52:14 +08:00
|
|
|
std::vector<range_reference> merged_cells_;
|
2015-11-11 07:58:54 +08:00
|
|
|
std::unordered_map<std::string, named_range> named_ranges_;
|
2016-12-10 08:18:50 +08:00
|
|
|
|
2018-06-23 08:15:15 +08:00
|
|
|
optional<phonetic_pr> phonetic_properties_;
|
2016-12-10 08:18:50 +08:00
|
|
|
optional<header_footer> header_footer_;
|
|
|
|
|
2016-03-08 15:45:35 +08:00
|
|
|
std::string print_title_cols_;
|
|
|
|
std::string print_title_rows_;
|
2016-12-10 08:18:50 +08:00
|
|
|
|
|
|
|
optional<range_reference> print_area_;
|
|
|
|
|
2016-12-02 21:37:50 +08:00
|
|
|
std::vector<sheet_view> views_;
|
2016-12-23 07:57:22 +08:00
|
|
|
|
|
|
|
std::vector<column_t> column_breaks_;
|
|
|
|
std::vector<row_t> row_breaks_;
|
2017-09-09 07:41:34 +08:00
|
|
|
|
|
|
|
std::unordered_map<std::string, comment> comments_;
|
2018-06-24 10:01:27 +08:00
|
|
|
optional<print_options> print_options_;
|
|
|
|
optional<sheet_pr> sheet_properties_;
|
2018-06-23 15:08:39 +08:00
|
|
|
|
|
|
|
optional<ext_list> extension_list_;
|
2018-10-05 21:30:54 +08:00
|
|
|
|
|
|
|
std::string drawing_rel_id_;
|
|
|
|
optional<drawing::spreadsheet_drawing> drawing_;
|
2014-05-30 08:52:14 +08:00
|
|
|
};
|
|
|
|
|
2014-05-31 06:42:25 +08:00
|
|
|
} // namespace detail
|
|
|
|
} // namespace xlnt
|