From 84011553a8d181a1889ee0dda79132cb00d12329 Mon Sep 17 00:00:00 2001 From: Thomas Fussell Date: Fri, 10 Feb 2017 20:22:38 -0800 Subject: [PATCH] rename some things and fix some formatting --- include/xlnt/styles/font.hpp | 13 ++++++------- source/cell/cell.cpp | 4 ++-- source/detail/xlsx_consumer.cpp | 32 ++++++++++++-------------------- source/styles/font.cpp | 26 +++++++++----------------- tests/helpers/xml_helper.hpp | 2 +- 5 files changed, 30 insertions(+), 47 deletions(-) diff --git a/include/xlnt/styles/font.hpp b/include/xlnt/styles/font.hpp index 195ebcbe..000dfc4f 100644 --- a/include/xlnt/styles/font.hpp +++ b/include/xlnt/styles/font.hpp @@ -100,22 +100,22 @@ public: /// /// /// - font &outlinethrough(bool outlinethrough); + font &outline(bool outline); /// /// /// - bool outlinethrough() const; + bool outline() const; /// /// /// - font &shadowthrough(bool shadowthrough); + font &shadow(bool shadow); /// /// /// - bool shadowthrough() const; + bool shadow() const; /// /// @@ -276,12 +276,12 @@ private: /// /// /// - bool outlinethrough_ = false; + bool outline_ = false; /// /// /// - bool shadowthrough_ = false; + bool shadow_ = false; /// /// @@ -303,7 +303,6 @@ private: /// optional charset_; - /// /// /// diff --git a/source/cell/cell.cpp b/source/cell/cell.cpp index 7e218587..a53a9fb4 100644 --- a/source/cell/cell.cpp +++ b/source/cell/cell.cpp @@ -535,8 +535,8 @@ std::pair cell::anchor() const for (row_t row_index = 1; row_index <= d_->row_ - 1; row_index++) { - top += worksheet().row_height(row_index); - } + top += worksheet().row_height(row_index); + } return {static_cast(left), static_cast(top)}; } diff --git a/source/detail/xlsx_consumer.cpp b/source/detail/xlsx_consumer.cpp index 2a6145cc..fa0973c8 100755 --- a/source/detail/xlsx_consumer.cpp +++ b/source/detail/xlsx_consumer.cpp @@ -1349,22 +1349,22 @@ void xlsx_consumer::read_stylesheet() { if (parser().attribute_present("val")) { - new_font.outlinethrough(is_true(parser().attribute("val"))); + new_font.outline(is_true(parser().attribute("val"))); } else { - new_font.outlinethrough(true); + new_font.outline(true); } } else if (font_property_element == qn("spreadsheetml", "shadow")) { if (parser().attribute_present("val")) { - new_font.shadowthrough(is_true(parser().attribute("val"))); + new_font.shadow(is_true(parser().attribute("val"))); } else { - new_font.shadowthrough(true); + new_font.shadow(true); } } else if (font_property_element == qn("spreadsheetml", "i")) @@ -2461,7 +2461,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); @@ -2530,11 +2530,7 @@ variant xlsx_consumer::read_variant() } if (element == qn("vt", "bool")) { - // bool could be "0" or "false" - bool bvalue; - if (text[0] == '0' or text[0] == 'f' or text[0]=='F') bvalue = false; - else bvalue = true; - value = variant(bvalue); + value = variant(is_true(text)); } else if (element == qn("vt", "vector")) { @@ -2650,12 +2646,8 @@ std::vector xlsx_consumer::read_namespaces() bool xlsx_consumer::in_element(const xml::qname &name) { - - if ((parser().peek() == xml::parser::event_type::end_element ) && (stack_.back() == name )) - { - return false; - } - return true; + return parser().peek() != xml::parser::event_type::end_element + && stack_.back() == name; } xml::qname xlsx_consumer::expect_start_element(xml::content content) @@ -2750,13 +2742,13 @@ 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); + run.second.get().bold(parser().attribute_present("val") + ? is_true(parser().attribute("val")) : true); } else if (current_run_property_element == xml::qname(xmlns, "i")) { - run.second.get().bold( - parser().attribute_present("val") ? is_true(parser().attribute("val")) : true); + run.second.get().italic(parser().attribute_present("val") + ? is_true(parser().attribute("val")) : true); } else if (current_run_property_element == xml::qname(xmlns, "u")) { diff --git a/source/styles/font.cpp b/source/styles/font.cpp index ff118bdd..6fde2812 100644 --- a/source/styles/font.cpp +++ b/source/styles/font.cpp @@ -30,15 +30,7 @@ namespace xlnt { font::font() : name_("Calibri"), - size_(12.0), - bold_(false), - italic_(false), - superscript_(false), - subscript_(false), - strikethrough_(false), - outlinethrough_(false), - shadowthrough_(false), - underline_(underline_style::none) + size_(12.0) { } @@ -86,26 +78,26 @@ bool font::strikethrough() const return strikethrough_; } -font &font::outlinethrough(bool outlinethrough) +font &font::outline(bool outline) { - outlinethrough_ = outlinethrough; + outline_ = outline; return *this; } -bool font::outlinethrough() const +bool font::outline() const { - return outlinethrough_; + return outline_; } -font &font::shadowthrough(bool shadowthrough) +font &font::shadow(bool shadow) { - shadowthrough_ = shadowthrough; + shadow_ = shadow; return *this; } -bool font::shadowthrough() const +bool font::shadow() const { - return shadowthrough_; + return shadow_; } font &font::underline(underline_style new_underline) diff --git a/tests/helpers/xml_helper.hpp b/tests/helpers/xml_helper.hpp index e7e64829..3b4d6e59 100644 --- a/tests/helpers/xml_helper.hpp +++ b/tests/helpers/xml_helper.hpp @@ -220,7 +220,7 @@ public: } if (!compare_files(left_archive.read(left_member), - right_archive.read(left_member), left_content_type)) + left_archive.read(left_member), left_content_type)) { std::cout << left_member.string() << std::endl; match = false;