From 4ed8dae49c2f872a252ac276d8f11d69c8662244 Mon Sep 17 00:00:00 2001 From: Thomas Fussell Date: Sat, 18 Feb 2017 20:33:59 -0600 Subject: [PATCH] minor cleanup --- include/xlnt/styles/format.hpp | 14 ++++++++++++-- include/xlnt/styles/style.hpp | 14 ++++++++++++-- source/detail/format_impl.hpp | 5 ++--- source/detail/style_impl.hpp | 5 ++--- source/detail/xlsx_consumer.cpp | 17 +++++++---------- source/detail/xlsx_producer.cpp | 8 ++++---- source/styles/format.cpp | 20 ++++++++++++++++---- source/styles/style.cpp | 18 ++++++++++++++---- 8 files changed, 69 insertions(+), 32 deletions(-) diff --git a/include/xlnt/styles/format.hpp b/include/xlnt/styles/format.hpp index 079e0262..60b36ddc 100755 --- a/include/xlnt/styles/format.hpp +++ b/include/xlnt/styles/format.hpp @@ -192,12 +192,22 @@ public: /// /// /// - bool pivot_button_applied() const; + bool pivot_button() const; /// /// /// - bool quote_prefix_applied() const; + void pivot_button(bool show); + + /// + /// + /// + bool quote_prefix() const; + + /// + /// + /// + void quote_prefix(bool quote); // Style diff --git a/include/xlnt/styles/style.hpp b/include/xlnt/styles/style.hpp index c363c22b..4fa07d83 100755 --- a/include/xlnt/styles/style.hpp +++ b/include/xlnt/styles/style.hpp @@ -230,12 +230,22 @@ public: /// /// /// - bool pivot_button_applied() const; + bool pivot_button() const; /// /// /// - bool quote_prefix_applied() const; + void pivot_button(bool show); + + /// + /// + /// + bool quote_prefix() const; + + /// + /// + /// + void quote_prefix(bool quote); /// /// diff --git a/source/detail/format_impl.hpp b/source/detail/format_impl.hpp index 27a02e16..a62799b8 100755 --- a/source/detail/format_impl.hpp +++ b/source/detail/format_impl.hpp @@ -47,9 +47,8 @@ struct format_impl optional protection_id; bool protection_applied = false; - bool pivot_button_applied = false; - - bool quote_prefix_applied = false; + bool pivot_button_ = false; + bool quote_prefix_ = false; optional style; diff --git a/source/detail/style_impl.hpp b/source/detail/style_impl.hpp index 869fd73b..ccffa092 100755 --- a/source/detail/style_impl.hpp +++ b/source/detail/style_impl.hpp @@ -49,9 +49,8 @@ struct style_impl optional protection_id; bool protection_applied = false; - bool pivot_button_applied = false; - - bool quote_prefix_applied = false; + bool pivot_button_ = false; + bool quote_prefix_ = false; }; } // namespace detail diff --git a/source/detail/xlsx_consumer.cpp b/source/detail/xlsx_consumer.cpp index c88ffba3..ff0d224d 100755 --- a/source/detail/xlsx_consumer.cpp +++ b/source/detail/xlsx_consumer.cpp @@ -1521,12 +1521,9 @@ void xlsx_consumer::read_stylesheet() record.first.protection_applied = apply_protection_present && is_true(parser().attribute("applyProtection")); - auto pivot_button_present = parser().attribute_present("pivotButton"); - record.first.pivot_button_applied = pivot_button_present + record.first.pivot_button_ = parser().attribute_present("pivotButton") && is_true(parser().attribute("pivotButton")); - - auto quote_prefix_present = parser().attribute_present("quotePrefix"); - record.first.quote_prefix_applied = quote_prefix_present + record.first.quote_prefix_ = parser().attribute_present("quotePrefix") && is_true(parser().attribute("quotePrefix")); if (parser().attribute_present("xfId") && parser().name() == "cellXfs") @@ -1743,8 +1740,8 @@ void xlsx_consumer::read_stylesheet() new_format.number_format_applied = record.first.number_format_applied; new_format.protection_id = record.first.protection_id; new_format.protection_applied = record.first.protection_applied; - new_format.pivot_button_applied = record.first.pivot_button_applied; - new_format.quote_prefix_applied = record.first.quote_prefix_applied; + new_format.pivot_button_ = record.first.pivot_button_; + new_format.quote_prefix_ = record.first.quote_prefix_; } } @@ -2473,7 +2470,7 @@ void xlsx_consumer::read_comments(worksheet ws) expect_start_element(qn("spreadsheetml", "comment"), xml::content::complex); skip_attribute("shapeId"); - auto cell_ref = parser().attribute("ref"); + auto cell_ref = parser().attribute("ref"); auto author_id = parser().attribute("authorId"); expect_start_element(qn("spreadsheetml", "text"), xml::content::complex); @@ -2755,12 +2752,12 @@ rich_text xlsx_consumer::read_rich_text(const xml::qname &parent) else if (current_run_property_element == xml::qname(xmlns, "b")) { run.second.get().bold(parser().attribute_present("val") - ? is_true(parser().attribute("val")) : true); + ? is_true(parser().attribute("val")) : true); } else if (current_run_property_element == xml::qname(xmlns, "i")) { run.second.get().italic(parser().attribute_present("val") - ? is_true(parser().attribute("val")) : true); + ? is_true(parser().attribute("val")) : true); } else if (current_run_property_element == xml::qname(xmlns, "u")) { diff --git a/source/detail/xlsx_producer.cpp b/source/detail/xlsx_producer.cpp index f34644a9..d1ecf216 100755 --- a/source/detail/xlsx_producer.cpp +++ b/source/detail/xlsx_producer.cpp @@ -1175,12 +1175,12 @@ void xlsx_producer::write_styles(const relationship & /*rel*/) write_attribute("applyProtection", write_bool(true)); } - if (current_style_impl.pivot_button_applied) + if (current_style_impl.pivot_button_) { write_attribute("pivotButton", write_bool(true)); } - if (current_style_impl.quote_prefix_applied) + if (current_style_impl.quote_prefix_) { write_attribute("quotePrefix", write_bool(true)); } @@ -1293,12 +1293,12 @@ void xlsx_producer::write_styles(const relationship & /*rel*/) write_attribute("applyProtection", write_bool(true)); } - if (current_format_impl.pivot_button_applied) + if (current_format_impl.pivot_button_) { write_attribute("pivotButton", write_bool(true)); } - if (current_format_impl.quote_prefix_applied) + if (current_format_impl.quote_prefix_) { write_attribute("quotePrefix", write_bool(true)); } diff --git a/source/styles/format.cpp b/source/styles/format.cpp index 57588204..42a5e581 100755 --- a/source/styles/format.cpp +++ b/source/styles/format.cpp @@ -210,14 +210,26 @@ bool format::protection_applied() const { return d_->protection_applied; } -bool format::pivot_button_applied() const + +bool format::pivot_button() const { - return d_->pivot_button_applied; + return d_->pivot_button_; } -bool format::quote_prefix_applied() const +void format::pivot_button(bool show) { - return d_->quote_prefix_applied; + d_->pivot_button_ = show; } +bool format::quote_prefix() const +{ + return d_->quote_prefix_; +} + +void format::quote_prefix(bool quote) +{ + d_->quote_prefix_ = quote; +} + + } // namespace xlnt diff --git a/source/styles/style.cpp b/source/styles/style.cpp index 0b574630..d2632f6a 100755 --- a/source/styles/style.cpp +++ b/source/styles/style.cpp @@ -238,14 +238,24 @@ bool style::protection_applied() const return d_->protection_applied; } -bool style::pivot_button_applied() const +bool style::pivot_button() const { - return d_->pivot_button_applied; + return d_->pivot_button_; } -bool style::quote_prefix_applied() const +void style::pivot_button(bool show) { - return d_->quote_prefix_applied; + d_->pivot_button_ = show; +} + +bool style::quote_prefix() const +{ + return d_->quote_prefix_; +} + +void style::quote_prefix(bool quote) +{ + d_->quote_prefix_ = quote; } } // namespace xlnt