mirror of
https://github.com/tfussell/xlnt.git
synced 2024-03-22 13:11:17 +08:00
work on round-tripping for #230
This commit is contained in:
parent
617f7a2525
commit
50850ffb8a
|
@ -63,7 +63,7 @@ public:
|
|||
/// to true, determines whether the alignment should be enabled for cells using
|
||||
/// this format.
|
||||
/// </summary>
|
||||
format alignment(const xlnt::alignment &new_alignment, bool applied = true);
|
||||
format alignment(const xlnt::alignment &new_alignment, optional<bool> applied = {});
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the alignment of this format should be applied to cells
|
||||
|
@ -81,7 +81,7 @@ public:
|
|||
/// to true, determines whether the border should be enabled for cells using
|
||||
/// this format.
|
||||
/// </summary>
|
||||
format border(const xlnt::border &new_border, bool applied = true);
|
||||
format border(const xlnt::border &new_border, optional<bool> applied = {});
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the border set for this format should be applied to cells using the format.
|
||||
|
@ -98,7 +98,7 @@ public:
|
|||
/// to true, determines whether the border should be enabled for cells using
|
||||
/// this format.
|
||||
/// </summary>
|
||||
format fill(const xlnt::fill &new_fill, bool applied = true);
|
||||
format fill(const xlnt::fill &new_fill, optional<bool> applied = {});
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the fill set for this format should be applied to cells using the format.
|
||||
|
@ -115,7 +115,7 @@ public:
|
|||
/// to true, determines whether the font should be enabled for cells using
|
||||
/// this format.
|
||||
/// </summary>
|
||||
format font(const xlnt::font &new_font, bool applied = true);
|
||||
format font(const xlnt::font &new_font, optional<bool> applied = {});
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the font set for this format should be applied to cells using the format.
|
||||
|
@ -132,7 +132,7 @@ public:
|
|||
/// to true, determines whether the number format should be enabled for cells using
|
||||
/// this format.
|
||||
/// </summary>
|
||||
format number_format(const xlnt::number_format &new_number_format, bool applied = true);
|
||||
format number_format(const xlnt::number_format &new_number_format, optional<bool> applied = {});
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the number_format set for this format should be applied to cells using the format.
|
||||
|
@ -154,7 +154,7 @@ public:
|
|||
/// to true, determines whether the protection should be enabled for cells using
|
||||
/// this format.
|
||||
/// </summary>
|
||||
format protection(const xlnt::protection &new_protection, bool applied = true);
|
||||
format protection(const xlnt::protection &new_protection, optional<bool> applied = {});
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the pivot table interface is enabled for this format.
|
||||
|
|
|
@ -123,7 +123,7 @@ public:
|
|||
/// to true, determines whether the alignment should be enabled for cells using
|
||||
/// this style.
|
||||
/// </summary>
|
||||
style alignment(const xlnt::alignment &new_alignment, bool applied = true);
|
||||
style alignment(const xlnt::alignment &new_alignment, optional<bool> applied = {});
|
||||
|
||||
/// <summary>
|
||||
/// Returns the border of this style.
|
||||
|
@ -140,7 +140,7 @@ public:
|
|||
/// to true, determines whether the border should be enabled for cells using
|
||||
/// this style.
|
||||
/// </summary>
|
||||
style border(const xlnt::border &new_border, bool applied = true);
|
||||
style border(const xlnt::border &new_border, optional<bool> applied = {});
|
||||
|
||||
/// <summary>
|
||||
/// Returns the fill of this style.
|
||||
|
@ -157,7 +157,7 @@ public:
|
|||
/// to true, determines whether the border should be enabled for cells using
|
||||
/// this style.
|
||||
/// </summary>
|
||||
style fill(const xlnt::fill &new_fill, bool applied = true);
|
||||
style fill(const xlnt::fill &new_fill, optional<bool> applied = {});
|
||||
|
||||
/// <summary>
|
||||
/// Returns the font of this style.
|
||||
|
@ -174,7 +174,7 @@ public:
|
|||
/// to true, determines whether the font should be enabled for cells using
|
||||
/// this style.
|
||||
/// </summary>
|
||||
style font(const xlnt::font &new_font, bool applied = true);
|
||||
style font(const xlnt::font &new_font, optional<bool> applied = {});
|
||||
|
||||
/// <summary>
|
||||
/// Returns the number_format of this style.
|
||||
|
@ -191,7 +191,7 @@ public:
|
|||
/// to true, determines whether the number format should be enabled for cells using
|
||||
/// this style.
|
||||
/// </summary>
|
||||
style number_format(const xlnt::number_format &new_number_format, bool applied = true);
|
||||
style number_format(const xlnt::number_format &new_number_format, optional<bool> applied = {});
|
||||
|
||||
/// <summary>
|
||||
/// Returns the protection of this style.
|
||||
|
@ -208,7 +208,7 @@ public:
|
|||
/// to true, determines whether the protection should be enabled for cells using
|
||||
/// this style.
|
||||
/// </summary>
|
||||
style protection(const xlnt::protection &new_protection, bool applied = true);
|
||||
style protection(const xlnt::protection &new_protection, optional<bool> applied = {});
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the pivot table interface is enabled for this style.
|
||||
|
|
|
@ -47,7 +47,7 @@ public:
|
|||
/// <summary>
|
||||
/// Constructs this optional with a value.
|
||||
/// </summary>
|
||||
explicit optional(const T &value) : has_value_(true), value_(value)
|
||||
optional(const T &value) : has_value_(true), value_(value)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -126,7 +126,7 @@ public:
|
|||
bool operator==(const optional<T> &other) const
|
||||
{
|
||||
return has_value_ == other.has_value_
|
||||
&& (!has_value_ || (has_value_ && value_ == other.value_));
|
||||
&& (!has_value_ || value_ == other.value_);
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -633,37 +633,37 @@ XLNT_API timedelta cell::value() const
|
|||
void cell::alignment(const class alignment &alignment_)
|
||||
{
|
||||
auto new_format = has_format() ? modifiable_format() : workbook().create_format();
|
||||
format(new_format.alignment(alignment_, true));
|
||||
format(new_format.alignment(alignment_, optional<bool>(true)));
|
||||
}
|
||||
|
||||
void cell::border(const class border &border_)
|
||||
{
|
||||
auto new_format = has_format() ? modifiable_format() : workbook().create_format();
|
||||
format(new_format.border(border_, true));
|
||||
format(new_format.border(border_, optional<bool>(true)));
|
||||
}
|
||||
|
||||
void cell::fill(const class fill &fill_)
|
||||
{
|
||||
auto new_format = has_format() ? modifiable_format() : workbook().create_format();
|
||||
format(new_format.fill(fill_, true));
|
||||
format(new_format.fill(fill_, optional<bool>(true)));
|
||||
}
|
||||
|
||||
void cell::font(const class font &font_)
|
||||
{
|
||||
auto new_format = has_format() ? modifiable_format() : workbook().create_format();
|
||||
format(new_format.font(font_, true));
|
||||
format(new_format.font(font_, optional<bool>(true)));
|
||||
}
|
||||
|
||||
void cell::number_format(const class number_format &number_format_)
|
||||
{
|
||||
auto new_format = has_format() ? modifiable_format() : workbook().create_format();
|
||||
format(new_format.number_format(number_format_, true));
|
||||
format(new_format.number_format(number_format_, optional<bool>(true)));
|
||||
}
|
||||
|
||||
void cell::protection(const class protection &protection_)
|
||||
{
|
||||
auto new_format = has_format() ? modifiable_format() : workbook().create_format();
|
||||
format(new_format.protection(protection_, true));
|
||||
format(new_format.protection(protection_, optional<bool>(true)));
|
||||
}
|
||||
|
||||
template <>
|
||||
|
|
|
@ -30,22 +30,22 @@ struct format_impl
|
|||
std::size_t id;
|
||||
|
||||
optional<std::size_t> alignment_id;
|
||||
bool alignment_applied = false;
|
||||
optional<bool> alignment_applied;
|
||||
|
||||
optional<std::size_t> border_id;
|
||||
bool border_applied = false;
|
||||
optional<bool> border_applied;
|
||||
|
||||
optional<std::size_t> fill_id;
|
||||
bool fill_applied = false;
|
||||
optional<bool> fill_applied;
|
||||
|
||||
optional<std::size_t> font_id;
|
||||
bool font_applied = false;
|
||||
optional<bool> font_applied;
|
||||
|
||||
optional<std::size_t> number_format_id;
|
||||
bool number_format_applied = false;
|
||||
optional<bool> number_format_applied;
|
||||
|
||||
optional<std::size_t> protection_id;
|
||||
bool protection_applied = false;
|
||||
optional<bool> protection_applied;
|
||||
|
||||
bool pivot_button_ = false;
|
||||
bool quote_prefix_ = false;
|
||||
|
|
|
@ -32,22 +32,22 @@ struct style_impl
|
|||
optional<std::size_t> outline_style;
|
||||
|
||||
optional<std::size_t> alignment_id;
|
||||
bool alignment_applied = false;
|
||||
optional<bool> alignment_applied;
|
||||
|
||||
optional<std::size_t> border_id;
|
||||
bool border_applied = false;
|
||||
optional<bool> border_applied;
|
||||
|
||||
optional<std::size_t> fill_id;
|
||||
bool fill_applied = false;
|
||||
optional<bool> fill_applied;
|
||||
|
||||
optional<std::size_t> font_id;
|
||||
bool font_applied = false;
|
||||
optional<bool> font_applied;
|
||||
|
||||
optional<std::size_t> number_format_id;
|
||||
bool number_format_applied = false;
|
||||
optional<bool> number_format_applied;
|
||||
|
||||
optional<std::size_t> protection_id;
|
||||
bool protection_applied = false;
|
||||
optional<bool> protection_applied;
|
||||
|
||||
bool pivot_button_ = false;
|
||||
bool quote_prefix_ = false;
|
||||
|
|
|
@ -430,7 +430,7 @@ struct stylesheet
|
|||
return find_or_create(new_format);
|
||||
}
|
||||
|
||||
format_impl *find_or_create_with(format_impl *pattern, const alignment &new_alignment, bool applied)
|
||||
format_impl *find_or_create_with(format_impl *pattern, const alignment &new_alignment, optional<bool> applied)
|
||||
{
|
||||
format_impl new_format = *pattern;
|
||||
new_format.alignment_id = find_or_add(alignments, new_alignment);
|
||||
|
@ -439,7 +439,7 @@ struct stylesheet
|
|||
return find_or_create(new_format);
|
||||
}
|
||||
|
||||
format_impl *find_or_create_with(format_impl *pattern, const border &new_border, bool applied)
|
||||
format_impl *find_or_create_with(format_impl *pattern, const border &new_border, optional<bool> applied)
|
||||
{
|
||||
format_impl new_format = *pattern;
|
||||
new_format.border_id = find_or_add(borders, new_border);
|
||||
|
@ -448,7 +448,7 @@ struct stylesheet
|
|||
return find_or_create(new_format);
|
||||
}
|
||||
|
||||
format_impl *find_or_create_with(format_impl *pattern, const fill &new_fill, bool applied)
|
||||
format_impl *find_or_create_with(format_impl *pattern, const fill &new_fill, optional<bool> applied)
|
||||
{
|
||||
format_impl new_format = *pattern;
|
||||
new_format.fill_id = find_or_add(fills, new_fill);
|
||||
|
@ -457,7 +457,7 @@ struct stylesheet
|
|||
return find_or_create(new_format);
|
||||
}
|
||||
|
||||
format_impl *find_or_create_with(format_impl *pattern, const font &new_font, bool applied)
|
||||
format_impl *find_or_create_with(format_impl *pattern, const font &new_font, optional<bool> applied)
|
||||
{
|
||||
format_impl new_format = *pattern;
|
||||
new_format.font_id = find_or_add(fonts, new_font);
|
||||
|
@ -466,7 +466,7 @@ struct stylesheet
|
|||
return find_or_create(new_format);
|
||||
}
|
||||
|
||||
format_impl *find_or_create_with(format_impl *pattern, const number_format &new_number_format, bool applied)
|
||||
format_impl *find_or_create_with(format_impl *pattern, const number_format &new_number_format, optional<bool> applied)
|
||||
{
|
||||
format_impl new_format = *pattern;
|
||||
if (new_number_format.id() >= 164)
|
||||
|
@ -479,7 +479,7 @@ struct stylesheet
|
|||
return find_or_create(new_format);
|
||||
}
|
||||
|
||||
format_impl *find_or_create_with(format_impl *pattern, const protection &new_protection, bool applied)
|
||||
format_impl *find_or_create_with(format_impl *pattern, const protection &new_protection, optional<bool> applied)
|
||||
{
|
||||
format_impl new_format = *pattern;
|
||||
new_format.protection_id = find_or_add(protections, new_protection);
|
||||
|
|
|
@ -1296,39 +1296,45 @@ void xlsx_producer::write_styles(const relationship & /*rel*/)
|
|||
}
|
||||
|
||||
if (current_style_impl.number_format_id.is_set()
|
||||
&& !current_style_impl.number_format_applied)
|
||||
&& current_style_impl.number_format_applied.is_set())
|
||||
{
|
||||
write_attribute("applyNumberFormat", write_bool(false));
|
||||
write_attribute("applyNumberFormat",
|
||||
write_bool(current_style_impl.number_format_applied.get()));
|
||||
}
|
||||
|
||||
if (current_style_impl.fill_id.is_set()
|
||||
&& !current_style_impl.fill_applied)
|
||||
&& current_style_impl.fill_applied.is_set())
|
||||
{
|
||||
write_attribute("applyFill", write_bool(false));
|
||||
write_attribute("applyFill",
|
||||
write_bool(current_style_impl.fill_applied.get()));
|
||||
}
|
||||
|
||||
if (current_style_impl.font_id.is_set()
|
||||
&& !current_style_impl.font_applied)
|
||||
&& current_style_impl.font_applied.is_set())
|
||||
{
|
||||
write_attribute("applyFont", write_bool(false));
|
||||
write_attribute("applyFont",
|
||||
write_bool(current_style_impl.font_applied.get()));
|
||||
}
|
||||
|
||||
if (current_style_impl.border_id.is_set()
|
||||
&& !current_style_impl.border_applied)
|
||||
&& current_style_impl.border_applied.is_set())
|
||||
{
|
||||
write_attribute("applyBorder", write_bool(false));
|
||||
write_attribute("applyBorder",
|
||||
write_bool(current_style_impl.border_applied.get()));
|
||||
}
|
||||
|
||||
if (current_style_impl.alignment_id.is_set()
|
||||
&& !current_style_impl.alignment_applied)
|
||||
&& current_style_impl.alignment_applied.is_set())
|
||||
{
|
||||
write_attribute("applyAlignment", write_bool(false));
|
||||
write_attribute("applyAlignment",
|
||||
write_bool(current_style_impl.alignment_applied.get()));
|
||||
}
|
||||
|
||||
if (current_style_impl.protection_id.is_set()
|
||||
&& !current_style_impl.protection_applied)
|
||||
&& current_style_impl.protection_applied.is_set())
|
||||
{
|
||||
write_attribute("applyProtection", write_bool(false));
|
||||
write_attribute("applyProtection",
|
||||
write_bool(current_style_impl.protection_applied.get()));
|
||||
}
|
||||
|
||||
if (current_style_impl.pivot_button_)
|
||||
|
@ -1405,47 +1411,66 @@ void xlsx_producer::write_styles(const relationship & /*rel*/)
|
|||
{
|
||||
write_start_element(xmlns, "xf");
|
||||
|
||||
write_attribute("numFmtId", current_format_impl.number_format_id.get());
|
||||
write_attribute("fontId", current_format_impl.font_id.get());
|
||||
if (current_format_impl.number_format_id.is_set())
|
||||
{
|
||||
write_attribute("numFmtId", current_format_impl.number_format_id.get());
|
||||
}
|
||||
|
||||
write_attribute("fillId", current_format_impl.fill_id.get());
|
||||
if (current_format_impl.font_id.is_set())
|
||||
{
|
||||
write_attribute("fontId", current_format_impl.font_id.get());
|
||||
}
|
||||
|
||||
write_attribute("borderId", current_format_impl.border_id.get());
|
||||
if (current_format_impl.fill_id.is_set())
|
||||
{
|
||||
write_attribute("fillId", current_format_impl.fill_id.get());
|
||||
}
|
||||
|
||||
if (current_format_impl.border_id.is_set())
|
||||
{
|
||||
write_attribute("borderId", current_format_impl.border_id.get());
|
||||
}
|
||||
|
||||
if (current_format_impl.number_format_id.is_set()
|
||||
&& !current_format_impl.number_format_applied)
|
||||
&& current_format_impl.number_format_applied.is_set())
|
||||
{
|
||||
write_attribute("applyNumberFormat", write_bool(false));
|
||||
write_attribute("applyNumberFormat",
|
||||
write_bool(current_format_impl.number_format_applied.get()));
|
||||
}
|
||||
|
||||
if (current_format_impl.fill_id.is_set()
|
||||
&& !current_format_impl.fill_applied)
|
||||
&& current_format_impl.fill_applied.is_set())
|
||||
{
|
||||
write_attribute("applyFill", write_bool(false));
|
||||
write_attribute("applyFill",
|
||||
write_bool(current_format_impl.fill_applied.get()));
|
||||
}
|
||||
|
||||
if (current_format_impl.font_id.is_set()
|
||||
&& !current_format_impl.font_applied)
|
||||
&& current_format_impl.font_applied.is_set())
|
||||
{
|
||||
write_attribute("applyFont", write_bool(false));
|
||||
write_attribute("applyFont",
|
||||
write_bool(current_format_impl.font_applied.get()));
|
||||
}
|
||||
|
||||
if (current_format_impl.border_id.is_set()
|
||||
&& !current_format_impl.border_applied)
|
||||
&& current_format_impl.border_applied.is_set())
|
||||
{
|
||||
write_attribute("applyBorder", write_bool(false));
|
||||
write_attribute("applyBorder",
|
||||
write_bool(current_format_impl.border_applied.get()));
|
||||
}
|
||||
|
||||
if (current_format_impl.alignment_id.is_set()
|
||||
&& !current_format_impl.alignment_applied)
|
||||
&& current_format_impl.alignment_applied.is_set())
|
||||
{
|
||||
write_attribute("applyAlignment", write_bool(false));
|
||||
write_attribute("applyAlignment",
|
||||
write_bool(current_format_impl.alignment_applied.get()));
|
||||
}
|
||||
|
||||
if (current_format_impl.protection_id.is_set()
|
||||
&& !current_format_impl.protection_applied)
|
||||
&& current_format_impl.protection_applied.is_set())
|
||||
{
|
||||
write_attribute("applyProtection", write_bool(false));
|
||||
write_attribute("applyProtection",
|
||||
write_bool(current_format_impl.protection_applied.get()));
|
||||
}
|
||||
|
||||
if (current_format_impl.pivot_button_)
|
||||
|
@ -1469,16 +1494,16 @@ void xlsx_producer::write_styles(const relationship & /*rel*/)
|
|||
|
||||
write_start_element(xmlns, "alignment");
|
||||
|
||||
if (current_alignment.vertical().is_set())
|
||||
{
|
||||
write_attribute("vertical", current_alignment.vertical().get());
|
||||
}
|
||||
|
||||
if (current_alignment.horizontal().is_set())
|
||||
{
|
||||
write_attribute("horizontal", current_alignment.horizontal().get());
|
||||
}
|
||||
|
||||
if (current_alignment.vertical().is_set())
|
||||
{
|
||||
write_attribute("vertical", current_alignment.vertical().get());
|
||||
}
|
||||
|
||||
if (current_alignment.rotation().is_set())
|
||||
{
|
||||
write_attribute("textRotation", current_alignment.rotation().get());
|
||||
|
|
|
@ -72,7 +72,7 @@ std::size_t theme_color::index() const
|
|||
|
||||
std::string rgb_color::hex_string() const
|
||||
{
|
||||
static const char *digits = "0123456789abcdef";
|
||||
static const char *digits = "0123456789ABCDEF";
|
||||
std::string hex_string(8, '0');
|
||||
auto out_iter = hex_string.begin();
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ xlnt::alignment format::alignment() const
|
|||
return d_->parent->alignments.at(d_->alignment_id.get());
|
||||
}
|
||||
|
||||
format format::alignment(const xlnt::alignment &new_alignment, bool applied)
|
||||
format format::alignment(const xlnt::alignment &new_alignment, optional<bool> applied)
|
||||
{
|
||||
d_ = d_->parent->find_or_create_with(d_, new_alignment, applied);
|
||||
return format(d_);
|
||||
|
@ -92,7 +92,7 @@ xlnt::border format::border() const
|
|||
return d_->parent->borders.at(d_->border_id.get());
|
||||
}
|
||||
|
||||
format format::border(const xlnt::border &new_border, bool applied)
|
||||
format format::border(const xlnt::border &new_border, optional<bool> applied)
|
||||
{
|
||||
d_ = d_->parent->find_or_create_with(d_, new_border, applied);
|
||||
return format(d_);
|
||||
|
@ -103,7 +103,7 @@ xlnt::fill format::fill() const
|
|||
return d_->parent->fills.at(d_->fill_id.get());
|
||||
}
|
||||
|
||||
format format::fill(const xlnt::fill &new_fill, bool applied)
|
||||
format format::fill(const xlnt::fill &new_fill, optional<bool> applied)
|
||||
{
|
||||
d_ = d_->parent->find_or_create_with(d_, new_fill, applied);
|
||||
return format(d_);
|
||||
|
@ -114,7 +114,7 @@ xlnt::font format::font() const
|
|||
return d_->parent->fonts.at(d_->font_id.get());
|
||||
}
|
||||
|
||||
format format::font(const xlnt::font &new_font, bool applied)
|
||||
format format::font(const xlnt::font &new_font, optional<bool> applied)
|
||||
{
|
||||
d_ = d_->parent->find_or_create_with(d_, new_font, applied);
|
||||
return format(d_);
|
||||
|
@ -131,7 +131,7 @@ xlnt::number_format format::number_format() const
|
|||
[&](const xlnt::number_format nf) { return nf.id() == d_->number_format_id.get(); });
|
||||
}
|
||||
|
||||
format format::number_format(const xlnt::number_format &new_number_format, bool applied)
|
||||
format format::number_format(const xlnt::number_format &new_number_format, optional<bool> applied)
|
||||
{
|
||||
auto copy = new_number_format;
|
||||
|
||||
|
@ -150,7 +150,7 @@ xlnt::protection format::protection() const
|
|||
return d_->parent->protections.at(d_->protection_id.get());
|
||||
}
|
||||
|
||||
format format::protection(const xlnt::protection &new_protection, bool applied)
|
||||
format format::protection(const xlnt::protection &new_protection, optional<bool> applied)
|
||||
{
|
||||
d_ = d_->parent->find_or_create_with(d_, new_protection, applied);
|
||||
return format(d_);
|
||||
|
@ -158,32 +158,44 @@ format format::protection(const xlnt::protection &new_protection, bool applied)
|
|||
|
||||
bool format::alignment_applied() const
|
||||
{
|
||||
return d_->alignment_applied;
|
||||
return d_->alignment_applied.is_set()
|
||||
? d_->alignment_applied.get()
|
||||
: d_->alignment_id.is_set();
|
||||
}
|
||||
|
||||
bool format::border_applied() const
|
||||
{
|
||||
return d_->border_applied;
|
||||
return d_->border_applied.is_set()
|
||||
? d_->border_applied.get()
|
||||
: d_->border_id.is_set();
|
||||
}
|
||||
|
||||
bool format::fill_applied() const
|
||||
{
|
||||
return d_->fill_applied;
|
||||
return d_->fill_applied.is_set()
|
||||
? d_->fill_applied.get()
|
||||
: d_->fill_id.is_set();
|
||||
}
|
||||
|
||||
bool format::font_applied() const
|
||||
{
|
||||
return d_->font_applied;
|
||||
return d_->font_applied.is_set()
|
||||
? d_->font_applied.get()
|
||||
: d_->font_id.is_set();
|
||||
}
|
||||
|
||||
bool format::number_format_applied() const
|
||||
{
|
||||
return d_->number_format_applied;
|
||||
return d_->number_format_applied.is_set()
|
||||
? d_->number_format_applied.get()
|
||||
: d_->number_format_id.is_set();
|
||||
}
|
||||
|
||||
bool format::protection_applied() const
|
||||
{
|
||||
return d_->protection_applied;
|
||||
return d_->protection_applied.is_set()
|
||||
? d_->protection_applied.get()
|
||||
: d_->protection_id.is_set();
|
||||
}
|
||||
|
||||
bool format::pivot_button() const
|
||||
|
|
|
@ -92,12 +92,7 @@ xlnt::alignment style::alignment() const
|
|||
return d_->parent->alignments.at(d_->alignment_id.get());
|
||||
}
|
||||
|
||||
bool style::alignment_applied() const
|
||||
{
|
||||
return d_->alignment_applied;
|
||||
}
|
||||
|
||||
style style::alignment(const xlnt::alignment &new_alignment, bool applied)
|
||||
style style::alignment(const xlnt::alignment &new_alignment, optional<bool> applied)
|
||||
{
|
||||
d_->alignment_id = d_->parent->find_or_add(d_->parent->alignments, new_alignment);
|
||||
d_->alignment_applied = applied;
|
||||
|
@ -110,12 +105,7 @@ xlnt::border style::border() const
|
|||
return d_->parent->borders.at(d_->border_id.get());
|
||||
}
|
||||
|
||||
bool style::border_applied() const
|
||||
{
|
||||
return d_->border_applied;
|
||||
}
|
||||
|
||||
style style::border(const xlnt::border &new_border, bool applied)
|
||||
style style::border(const xlnt::border &new_border, optional<bool> applied)
|
||||
{
|
||||
d_->border_id = d_->parent->find_or_add(d_->parent->borders, new_border);
|
||||
d_->border_applied = applied;
|
||||
|
@ -128,12 +118,7 @@ xlnt::fill style::fill() const
|
|||
return d_->parent->fills.at(d_->fill_id.get());
|
||||
}
|
||||
|
||||
bool style::fill_applied() const
|
||||
{
|
||||
return d_->fill_applied;
|
||||
}
|
||||
|
||||
style style::fill(const xlnt::fill &new_fill, bool applied)
|
||||
style style::fill(const xlnt::fill &new_fill, optional<bool> applied)
|
||||
{
|
||||
d_->fill_id = d_->parent->find_or_add(d_->parent->fills, new_fill);
|
||||
d_->fill_applied = applied;
|
||||
|
@ -146,12 +131,7 @@ xlnt::font style::font() const
|
|||
return d_->parent->fonts.at(d_->font_id.get());
|
||||
}
|
||||
|
||||
bool style::font_applied() const
|
||||
{
|
||||
return d_->font_applied;
|
||||
}
|
||||
|
||||
style style::font(const xlnt::font &new_font, bool applied)
|
||||
style style::font(const xlnt::font &new_font, optional<bool> applied)
|
||||
{
|
||||
d_->font_id = d_->parent->find_or_add(d_->parent->fonts, new_font);
|
||||
d_->font_applied = applied;
|
||||
|
@ -172,12 +152,7 @@ xlnt::number_format style::number_format() const
|
|||
return *match;
|
||||
}
|
||||
|
||||
bool style::number_format_applied() const
|
||||
{
|
||||
return d_->number_format_applied;
|
||||
}
|
||||
|
||||
style style::number_format(const xlnt::number_format &new_number_format, bool applied)
|
||||
style style::number_format(const xlnt::number_format &new_number_format, optional<bool> applied)
|
||||
{
|
||||
auto copy = new_number_format;
|
||||
|
||||
|
@ -203,12 +178,7 @@ xlnt::protection style::protection() const
|
|||
return d_->parent->protections.at(d_->protection_id.get());
|
||||
}
|
||||
|
||||
bool style::protection_applied() const
|
||||
{
|
||||
return d_->protection_applied;
|
||||
}
|
||||
|
||||
style style::protection(const xlnt::protection &new_protection, bool applied)
|
||||
style style::protection(const xlnt::protection &new_protection, optional<bool> applied)
|
||||
{
|
||||
d_->protection_id = d_->parent->find_or_add(d_->parent->protections, new_protection);
|
||||
d_->protection_applied = applied;
|
||||
|
@ -216,6 +186,48 @@ style style::protection(const xlnt::protection &new_protection, bool applied)
|
|||
return *this;
|
||||
}
|
||||
|
||||
bool style::alignment_applied() const
|
||||
{
|
||||
return d_->alignment_applied.is_set()
|
||||
? d_->alignment_applied.get()
|
||||
: d_->alignment_id.is_set();
|
||||
}
|
||||
|
||||
bool style::border_applied() const
|
||||
{
|
||||
return d_->border_applied.is_set()
|
||||
? d_->border_applied.get()
|
||||
: d_->border_id.is_set();
|
||||
}
|
||||
|
||||
bool style::fill_applied() const
|
||||
{
|
||||
return d_->fill_applied.is_set()
|
||||
? d_->fill_applied.get()
|
||||
: d_->fill_id.is_set();
|
||||
}
|
||||
|
||||
bool style::font_applied() const
|
||||
{
|
||||
return d_->font_applied.is_set()
|
||||
? d_->font_applied.get()
|
||||
: d_->font_id.is_set();
|
||||
}
|
||||
|
||||
bool style::number_format_applied() const
|
||||
{
|
||||
return d_->number_format_applied.is_set()
|
||||
? d_->number_format_applied.get()
|
||||
: d_->number_format_id.is_set();
|
||||
}
|
||||
|
||||
bool style::protection_applied() const
|
||||
{
|
||||
return d_->protection_applied.is_set()
|
||||
? d_->protection_applied.get()
|
||||
: d_->protection_id.is_set();
|
||||
}
|
||||
|
||||
bool style::pivot_button() const
|
||||
{
|
||||
return d_->pivot_button_;
|
||||
|
|
|
@ -464,16 +464,16 @@ workbook workbook::empty()
|
|||
stylesheet.fonts.push_back(default_font);
|
||||
|
||||
wb.create_builtin_style(0)
|
||||
.border(default_border, true)
|
||||
.fill(default_fill, true)
|
||||
.font(default_font, true)
|
||||
.number_format(xlnt::number_format::general(), true);
|
||||
.border(default_border)
|
||||
.fill(default_fill)
|
||||
.font(default_font)
|
||||
.number_format(xlnt::number_format::general());
|
||||
|
||||
wb.create_format(true)
|
||||
.border(default_border, true)
|
||||
.fill(default_fill, true)
|
||||
.font(default_font, true)
|
||||
.number_format(xlnt::number_format::general(), true)
|
||||
.border(default_border)
|
||||
.fill(default_fill)
|
||||
.font(default_font)
|
||||
.number_format(xlnt::number_format::general())
|
||||
.style("Normal");
|
||||
|
||||
xlnt::calculation_properties calc_props;
|
||||
|
|
|
@ -41,16 +41,16 @@ public:
|
|||
{
|
||||
const std::vector<std::pair<xlnt::color, std::string>> known_colors
|
||||
{
|
||||
{ xlnt::color::black(), "ff000000" },
|
||||
{ xlnt::color::white(), "ffffffff" },
|
||||
{ xlnt::color::red(), "ffff0000" },
|
||||
{ xlnt::color::darkred(), "ff8b0000" },
|
||||
{ xlnt::color::blue(), "ff0000ff" },
|
||||
{ xlnt::color::darkblue(), "ff00008b" },
|
||||
{ xlnt::color::green(), "ff00ff00" },
|
||||
{ xlnt::color::darkgreen(), "ff008b00" },
|
||||
{ xlnt::color::yellow(), "ffffff00" },
|
||||
{ xlnt::color::darkyellow(), "ffcccc00" }
|
||||
{ xlnt::color::black(), "FF000000" },
|
||||
{ xlnt::color::white(), "FFFFFFFF" },
|
||||
{ xlnt::color::red(), "FFFF0000" },
|
||||
{ xlnt::color::darkred(), "FF8B0000" },
|
||||
{ xlnt::color::blue(), "FF0000FF" },
|
||||
{ xlnt::color::darkblue(), "FF00008B" },
|
||||
{ xlnt::color::green(), "FF00FF00" },
|
||||
{ xlnt::color::darkgreen(), "FF008B00" },
|
||||
{ xlnt::color::yellow(), "FFFFFF00" },
|
||||
{ xlnt::color::darkyellow(), "FFCCCC00" }
|
||||
};
|
||||
|
||||
for (auto pair : known_colors)
|
||||
|
|
|
@ -215,15 +215,12 @@ public:
|
|||
.scheme("minor")
|
||||
.underline(xlnt::font::underline_style::single);
|
||||
auto hyperlink_style = wb.create_builtin_style(8);
|
||||
hyperlink_style.font(hyperlink_font, true);
|
||||
hyperlink_style.font(hyperlink_font);
|
||||
hyperlink_style.number_format(hyperlink_style.number_format(), false);
|
||||
hyperlink_style.fill(hyperlink_style.fill(), false);
|
||||
hyperlink_style.border(hyperlink_style.border(), false);
|
||||
auto hyperlink_format = wb.create_format();
|
||||
hyperlink_format.font(hyperlink_font, true);
|
||||
hyperlink_format.number_format(hyperlink_format.number_format(), true);
|
||||
hyperlink_format.fill(hyperlink_format.fill(), true);
|
||||
hyperlink_format.border(hyperlink_format.border(), true);
|
||||
hyperlink_format.font(hyperlink_font);
|
||||
hyperlink_format.style(hyperlink_style);
|
||||
|
||||
sheet1.cell("A4").hyperlink("https://microsoft.com/", "hyperlink1");
|
||||
|
|
Loading…
Reference in New Issue
Block a user