fix conditional_format redefinition warning and don't try to write conditional formats for a worksheet without a stylesheet

This commit is contained in:
Thomas Fussell 2017-04-03 19:49:38 -04:00
parent d54ddea5cc
commit 116106d568
4 changed files with 5 additions and 3 deletions

View File

@ -173,7 +173,7 @@ public:
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
conditional_format conditional_format(const condition &when); xlnt::conditional_format conditional_format(const condition &when);
/// <summary> /// <summary>
/// Returns the first row or column in this range. /// Returns the first row or column in this range.

View File

@ -661,7 +661,7 @@ public:
/// <summary> /// <summary>
/// Creates a conditional format for the given range with the given condition. /// Creates a conditional format for the given range with the given condition.
/// </summary> /// </summary>
conditional_format conditional_format(const range_reference &ref, const condition &when); xlnt::conditional_format conditional_format(const range_reference &ref, const condition &when);
private: private:
friend class cell; friend class cell;

View File

@ -66,6 +66,7 @@ struct stylesheet
{ {
auto iter = format_impls.begin(); auto iter = format_impls.begin();
std::advance(iter, static_cast<std::list<format_impl>::difference_type>(index)); std::advance(iter, static_cast<std::list<format_impl>::difference_type>(index));
return xlnt::format(&*iter); return xlnt::format(&*iter);
} }
@ -497,6 +498,7 @@ struct stylesheet
void clear() void clear()
{ {
conditional_format_impls.clear();
format_impls.clear(); format_impls.clear();
style_impls.clear(); style_impls.clear();

View File

@ -2364,7 +2364,7 @@ void xlsx_producer::write_worksheet(const relationship &rel)
write_end_element(xmlns, "mergeCells"); write_end_element(xmlns, "mergeCells");
} }
// scope for conditional formatting production logic if (source_.impl().stylesheet_.is_set())
{ {
const auto &stylesheet = source_.impl().stylesheet_.get(); const auto &stylesheet = source_.impl().stylesheet_.get();
const auto &cf_impls = stylesheet.conditional_format_impls; const auto &cf_impls = stylesheet.conditional_format_impls;