xlnt/source/style.cpp

93 lines
1.7 KiB
C++
Raw Normal View History

2015-10-19 03:30:46 +08:00
#include <xlnt/cell/cell.hpp>
2014-08-14 06:56:34 +08:00
#include <xlnt/styles/style.hpp>
2015-10-19 03:30:46 +08:00
#include "font.hpp"
#include "number_format.hpp"
#include "protection.hpp"
2015-10-19 03:30:46 +08:00
namespace {
2015-10-19 03:30:46 +08:00
template <class T>
void hash_combine(std::size_t& seed, const T& v)
{
2015-10-19 03:30:46 +08:00
std::hash<T> hasher;
seed ^= hasher(v) + 0x9e3779b9 + (seed<<6) + (seed>>2);
}
2015-10-19 03:30:46 +08:00
}
namespace xlnt {
style::style()
{
}
2015-10-19 03:30:46 +08:00
style::style(const style &other)
{
}
2015-10-19 03:30:46 +08:00
const cell style::get_parent() const
{
2015-10-19 03:30:46 +08:00
return cell(parent_);
}
2015-10-19 03:30:46 +08:00
std::size_t style::hash() const
{
2015-10-19 03:30:46 +08:00
std::size_t seed = 100;
std::hash<std::string> string_hash;
auto font_ = get_font();
hash_combine(seed, string_hash(font_.name_));
hash_combine(seed, font_.size_);
hash_combine(seed, static_cast<std::size_t>(font_.underline_));
std::size_t bools = font_.bold_;
bools = bools << 1 & font_.italic_;
bools = bools << 1 & font_.strikethrough_;
bools = bools << 1 & font_.superscript_;
bools = bools << 1 & font_.subscript_;
hash_combine(seed, bools);
return seed;
}
2015-10-19 03:30:46 +08:00
const number_format &style::get_number_format() const
{
2015-10-19 03:30:46 +08:00
return get_parent().get_number_format();
}
2015-10-19 03:30:46 +08:00
const border &style::get_border() const
{
2015-10-19 03:30:46 +08:00
return get_parent().get_border();
}
2015-10-19 03:30:46 +08:00
const alignment &style::get_alignment() const
{
return get_parent().get_alignment();
}
const fill &style::get_fill() const
{
2015-10-19 03:30:46 +08:00
return get_parent().get_fill();
}
2015-10-19 03:30:46 +08:00
const font &style::get_font() const
{
2015-10-19 03:30:46 +08:00
return get_parent().get_font();
}
2015-10-19 03:30:46 +08:00
const protection &style::get_protection() const
{
2015-10-19 03:30:46 +08:00
return get_parent().get_protection();
}
2015-10-19 03:30:46 +08:00
bool style::pivot_button() const
{
2015-10-19 03:30:46 +08:00
return get_parent().pivot_button();
}
2015-10-19 03:30:46 +08:00
bool style::quote_prefix() const
{
2015-10-19 03:30:46 +08:00
return get_parent().quote_prefix();
}
} // namespace xlnt