xlnt/source/styles/style.cpp

88 lines
1.5 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
std::size_t style::hash() const
{
2015-10-21 01:53:47 +08:00
/*
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);
2015-10-21 01:53:47 +08:00
*/
std::size_t seed = 100;
hash_combine(seed, number_format_.hash());
2015-10-19 03:30:46 +08:00
return seed;
}
2015-10-21 01:53:47 +08:00
const number_format style::get_number_format() const
{
2015-10-21 01:53:47 +08:00
return number_format_;
}
2015-10-19 03:30:46 +08:00
2015-10-21 01:53:47 +08:00
const border style::get_border() const
{
2015-10-21 01:53:47 +08:00
return border_;
}
2015-10-21 01:53:47 +08:00
const alignment style::get_alignment() const
2015-10-19 03:30:46 +08:00
{
2015-10-21 01:53:47 +08:00
return alignment_;
2015-10-19 03:30:46 +08:00
}
2015-10-21 01:53:47 +08:00
const fill style::get_fill() const
{
2015-10-21 01:53:47 +08:00
return fill_;
}
2015-10-21 01:53:47 +08:00
const font style::get_font() const
{
2015-10-21 01:53:47 +08:00
return font_;
}
2015-10-21 01:53:47 +08:00
const protection style::get_protection() const
{
2015-10-21 01:53:47 +08:00
return protection_;
}
2015-10-19 03:30:46 +08:00
bool style::pivot_button() const
{
2015-10-21 01:53:47 +08:00
return pivot_button_;
}
2015-10-19 03:30:46 +08:00
bool style::quote_prefix() const
{
2015-10-21 01:53:47 +08:00
return quote_prefix_;
}
} // namespace xlnt