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
|
2014-05-31 06:42:25 +08:00
|
|
|
#pragma once
|
|
|
|
|
2016-08-03 12:12:18 +08:00
|
|
|
#include <list>
|
2016-08-06 22:40:17 +08:00
|
|
|
#include <string>
|
|
|
|
#include <unordered_map>
|
2014-05-31 06:42:25 +08:00
|
|
|
#include <vector>
|
|
|
|
|
2017-04-21 02:03:03 +08:00
|
|
|
#include <detail/implementations/stylesheet.hpp>
|
|
|
|
#include <detail/implementations/worksheet_impl.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/packaging/manifest.hpp>
|
2016-08-03 12:12:18 +08:00
|
|
|
#include <xlnt/utils/datetime.hpp>
|
2017-01-16 08:08:57 +08:00
|
|
|
#include <xlnt/utils/variant.hpp>
|
2016-12-24 23:04:57 +08:00
|
|
|
#include <xlnt/workbook/calculation_properties.hpp>
|
2016-05-16 03:03:02 +08:00
|
|
|
#include <xlnt/workbook/theme.hpp>
|
2016-08-14 02:45:26 +08:00
|
|
|
#include <xlnt/workbook/workbook_view.hpp>
|
2016-05-16 03:03:02 +08:00
|
|
|
#include <xlnt/worksheet/range.hpp>
|
|
|
|
#include <xlnt/worksheet/range_reference.hpp>
|
|
|
|
#include <xlnt/worksheet/sheet_view.hpp>
|
|
|
|
|
2014-05-30 08:52:14 +08:00
|
|
|
namespace xlnt {
|
2014-05-31 06:42:25 +08:00
|
|
|
namespace detail {
|
2014-05-30 08:52:14 +08:00
|
|
|
|
2016-05-16 03:03:02 +08:00
|
|
|
struct worksheet_impl;
|
|
|
|
|
2014-05-30 08:52:14 +08:00
|
|
|
struct workbook_impl
|
|
|
|
{
|
2018-07-23 11:51:33 +08:00
|
|
|
workbook_impl() : base_date_(calendar::windows_1900)
|
|
|
|
{
|
|
|
|
}
|
2015-11-01 22:43:01 +08:00
|
|
|
|
|
|
|
workbook_impl(const workbook_impl &other)
|
2015-10-15 06:05:13 +08:00
|
|
|
: active_sheet_index_(other.active_sheet_index_),
|
2015-11-01 22:43:01 +08:00
|
|
|
worksheets_(other.worksheets_),
|
2018-02-08 16:52:10 +08:00
|
|
|
shared_strings_ids_(other.shared_strings_ids_),
|
2018-07-23 11:51:33 +08:00
|
|
|
shared_strings_values_(other.shared_strings_values_),
|
2016-06-11 01:40:50 +08:00
|
|
|
stylesheet_(other.stylesheet_),
|
2016-08-12 12:22:14 +08:00
|
|
|
manifest_(other.manifest_),
|
2017-02-25 22:55:11 +08:00
|
|
|
theme_(other.theme_),
|
|
|
|
core_properties_(other.core_properties_),
|
|
|
|
extended_properties_(other.extended_properties_),
|
|
|
|
custom_properties_(other.custom_properties_),
|
|
|
|
view_(other.view_),
|
|
|
|
code_name_(other.code_name_),
|
|
|
|
file_version_(other.file_version_)
|
2015-10-15 06:05:13 +08:00
|
|
|
{
|
|
|
|
}
|
2015-11-01 22:43:01 +08:00
|
|
|
|
2014-07-24 08:51:28 +08:00
|
|
|
workbook_impl &operator=(const workbook_impl &other)
|
|
|
|
{
|
|
|
|
active_sheet_index_ = other.active_sheet_index_;
|
|
|
|
worksheets_.clear();
|
|
|
|
std::copy(other.worksheets_.begin(), other.worksheets_.end(), back_inserter(worksheets_));
|
2018-07-23 11:51:33 +08:00
|
|
|
shared_strings_ids_ = other.shared_strings_ids_;
|
|
|
|
shared_strings_values_ = other.shared_strings_values_;
|
|
|
|
theme_ = other.theme_;
|
2015-10-30 01:46:56 +08:00
|
|
|
manifest_ = other.manifest_;
|
2015-11-01 22:43:01 +08:00
|
|
|
|
2018-07-23 11:51:33 +08:00
|
|
|
sheet_title_rel_id_map_ = other.sheet_title_rel_id_map_;
|
2020-08-25 13:32:21 +08:00
|
|
|
sheet_hidden_ = other.sheet_hidden_;
|
2018-07-23 11:51:33 +08:00
|
|
|
view_ = other.view_;
|
|
|
|
code_name_ = other.code_name_;
|
|
|
|
file_version_ = other.file_version_;
|
2016-08-14 02:45:26 +08:00
|
|
|
|
2017-02-25 22:55:11 +08:00
|
|
|
core_properties_ = other.core_properties_;
|
|
|
|
extended_properties_ = other.extended_properties_;
|
|
|
|
custom_properties_ = other.custom_properties_;
|
|
|
|
|
2015-10-15 06:05:13 +08:00
|
|
|
return *this;
|
2014-07-24 08:51:28 +08:00
|
|
|
}
|
2014-07-25 05:31:46 +08:00
|
|
|
|
2018-07-03 10:05:07 +08:00
|
|
|
bool operator==(const workbook_impl &other)
|
|
|
|
{
|
|
|
|
return active_sheet_index_ == other.active_sheet_index_
|
|
|
|
&& worksheets_ == other.worksheets_
|
2018-07-23 12:07:31 +08:00
|
|
|
&& shared_strings_ids_ == other.shared_strings_ids_
|
2018-07-03 10:05:07 +08:00
|
|
|
&& stylesheet_ == other.stylesheet_
|
|
|
|
&& base_date_ == other.base_date_
|
|
|
|
&& title_ == other.title_
|
|
|
|
&& manifest_ == other.manifest_
|
|
|
|
&& theme_ == other.theme_
|
|
|
|
&& images_ == other.images_
|
|
|
|
&& core_properties_ == other.core_properties_
|
|
|
|
&& extended_properties_ == other.extended_properties_
|
|
|
|
&& custom_properties_ == other.custom_properties_
|
|
|
|
&& sheet_title_rel_id_map_ == other.sheet_title_rel_id_map_
|
2020-08-25 13:32:21 +08:00
|
|
|
&& sheet_hidden_ == other.sheet_hidden_
|
2018-07-03 10:05:07 +08:00
|
|
|
&& view_ == other.view_
|
|
|
|
&& code_name_ == other.code_name_
|
|
|
|
&& file_version_ == other.file_version_
|
|
|
|
&& calculation_properties_ == other.calculation_properties_
|
|
|
|
&& abs_path_ == other.abs_path_
|
|
|
|
&& arch_id_flags_ == other.arch_id_flags_
|
|
|
|
&& extensions_ == other.extensions_;
|
|
|
|
}
|
|
|
|
|
2016-12-02 21:37:50 +08:00
|
|
|
optional<std::size_t> active_sheet_index_;
|
|
|
|
|
2016-08-03 12:12:18 +08:00
|
|
|
std::list<worksheet_impl> worksheets_;
|
2018-02-08 16:52:10 +08:00
|
|
|
std::unordered_map<rich_text, std::size_t, rich_text_hash> shared_strings_ids_;
|
2020-08-25 15:08:20 +08:00
|
|
|
std::vector<rich_text> shared_strings_values_;
|
2015-11-01 22:43:01 +08:00
|
|
|
|
2016-12-02 21:37:50 +08:00
|
|
|
optional<stylesheet> stylesheet_;
|
2015-11-01 22:43:01 +08:00
|
|
|
|
2016-12-02 21:37:50 +08:00
|
|
|
calendar base_date_;
|
|
|
|
optional<std::string> title_;
|
2018-07-23 11:51:33 +08:00
|
|
|
|
2015-10-30 01:46:56 +08:00
|
|
|
manifest manifest_;
|
2016-12-02 21:37:50 +08:00
|
|
|
optional<theme> theme_;
|
|
|
|
std::unordered_map<std::string, std::vector<std::uint8_t>> images_;
|
|
|
|
|
2017-02-18 13:11:06 +08:00
|
|
|
std::vector<std::pair<xlnt::core_property, variant>> core_properties_;
|
|
|
|
std::vector<std::pair<xlnt::extended_property, variant>> extended_properties_;
|
|
|
|
std::vector<std::pair<std::string, variant>> custom_properties_;
|
2016-08-06 22:40:17 +08:00
|
|
|
|
2018-07-23 11:51:33 +08:00
|
|
|
std::unordered_map<std::string, std::string> sheet_title_rel_id_map_;
|
2020-08-25 13:32:21 +08:00
|
|
|
std::vector<bool> sheet_hidden_;
|
2016-08-14 02:45:26 +08:00
|
|
|
|
2016-12-02 21:37:50 +08:00
|
|
|
optional<workbook_view> view_;
|
|
|
|
optional<std::string> code_name_;
|
2016-08-14 02:45:26 +08:00
|
|
|
|
2020-08-25 13:32:21 +08:00
|
|
|
struct file_version_t
|
|
|
|
{
|
|
|
|
std::string app_name;
|
2021-01-04 08:04:41 +08:00
|
|
|
std::size_t last_edited;
|
|
|
|
std::size_t lowest_edited;
|
|
|
|
std::size_t rup_build;
|
|
|
|
|
|
|
|
file_version_t(): last_edited(0), lowest_edited(0), rup_build(0) {
|
|
|
|
|
|
|
|
}
|
2018-07-03 10:05:07 +08:00
|
|
|
|
|
|
|
bool operator==(const file_version_t& rhs) const
|
|
|
|
{
|
|
|
|
return app_name == rhs.app_name
|
|
|
|
&& last_edited == rhs.last_edited
|
|
|
|
&& lowest_edited == rhs.lowest_edited
|
|
|
|
&& rup_build == rhs.rup_build;
|
|
|
|
}
|
2020-08-25 13:32:21 +08:00
|
|
|
};
|
2018-07-23 11:51:33 +08:00
|
|
|
|
2016-12-02 21:37:50 +08:00
|
|
|
optional<file_version_t> file_version_;
|
2016-12-24 23:04:57 +08:00
|
|
|
optional<calculation_properties> calculation_properties_;
|
2018-05-29 11:13:57 +08:00
|
|
|
optional<std::string> abs_path_;
|
|
|
|
optional<std::size_t> arch_id_flags_;
|
2018-06-23 15:08:39 +08:00
|
|
|
optional<ext_list> extensions_;
|
2014-05-30 08:52:14 +08:00
|
|
|
};
|
|
|
|
|
2014-05-31 06:42:25 +08:00
|
|
|
} // namespace detail
|
2014-05-30 08:52:14 +08:00
|
|
|
} // namespace xlnt
|