2016-05-01 04:19:45 +08:00
|
|
|
// Copyright (c) 2014-2016 Thomas Fussell
|
|
|
|
// Copyright (c) 2010-2015 openpyxl
|
|
|
|
//
|
|
|
|
// 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
|
2016-05-15 01:57:07 +08:00
|
|
|
|
2016-05-01 04:19:45 +08:00
|
|
|
#include <xlnt/cell/cell.hpp>
|
|
|
|
#include <xlnt/styles/font.hpp>
|
2016-05-15 01:57:07 +08:00
|
|
|
#include <xlnt/styles/format.hpp>
|
2016-05-01 04:19:45 +08:00
|
|
|
#include <xlnt/styles/number_format.hpp>
|
|
|
|
#include <xlnt/styles/protection.hpp>
|
|
|
|
#include <xlnt/utils/hash_combine.hpp>
|
|
|
|
|
|
|
|
namespace xlnt {
|
|
|
|
|
2016-05-15 01:57:07 +08:00
|
|
|
format::format()
|
2016-05-15 23:51:32 +08:00
|
|
|
: formattable(),
|
|
|
|
parent_(nullptr),
|
|
|
|
named_style_name_("Normal")
|
2016-05-01 04:19:45 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-05-15 23:51:32 +08:00
|
|
|
format::format(const format &other)
|
|
|
|
: formattable(other),
|
|
|
|
parent_(other.parent_),
|
|
|
|
named_style_name_(other.named_style_name_)
|
2016-05-01 04:19:45 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-05-15 01:57:07 +08:00
|
|
|
format &format::operator=(const format &other)
|
2016-05-01 04:19:45 +08:00
|
|
|
{
|
2016-05-15 01:57:07 +08:00
|
|
|
formattable::operator=(other);
|
2016-05-14 02:40:17 +08:00
|
|
|
|
2016-05-01 04:19:45 +08:00
|
|
|
parent_ = other.parent_;
|
|
|
|
named_style_name_ = other.named_style_name_;
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2016-05-15 01:57:07 +08:00
|
|
|
std::string format::to_hash_string() const
|
2016-05-01 04:19:45 +08:00
|
|
|
{
|
2016-05-15 01:57:07 +08:00
|
|
|
auto hash_string = formattable::to_hash_string();
|
|
|
|
hash_string.append(":format:");
|
2016-05-01 04:19:45 +08:00
|
|
|
|
2016-05-04 03:37:34 +08:00
|
|
|
if (!named_style_name_.empty())
|
|
|
|
{
|
|
|
|
hash_string.append(named_style_name_);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
hash_string.append(":");
|
|
|
|
}
|
2016-05-01 04:19:45 +08:00
|
|
|
|
|
|
|
return hash_string;
|
|
|
|
}
|
|
|
|
|
2016-05-15 01:57:07 +08:00
|
|
|
void format::set_style(const std::string &style_name)
|
2016-05-04 03:37:34 +08:00
|
|
|
{
|
|
|
|
named_style_name_ = style_name;
|
|
|
|
}
|
|
|
|
|
2016-05-15 01:57:07 +08:00
|
|
|
bool format::has_style() const
|
|
|
|
{
|
|
|
|
return !named_style_name_.empty();
|
|
|
|
}
|
|
|
|
|
2016-05-15 23:51:32 +08:00
|
|
|
std::string format::get_style_name() const
|
|
|
|
{
|
|
|
|
return named_style_name_;
|
|
|
|
}
|
|
|
|
|
2016-05-01 04:19:45 +08:00
|
|
|
} // namespace xlnt
|