From 16f8c3223a21ccb7c4b0b8b7eff7f86db45843a5 Mon Sep 17 00:00:00 2001 From: Thomas Fussell Date: Sat, 26 Jul 2014 16:19:15 -0400 Subject: [PATCH] continue synchronizing tests and start implementing styles --- include/xlnt/cell/cell.hpp | 4 +- include/xlnt/cell/cell_reference.hpp | 2 + include/xlnt/cell/comment.hpp | 11 +- include/xlnt/cell/value.hpp | 1 + include/xlnt/styles/number_format.hpp | 3 + include/xlnt/styles/protection.hpp | 8 +- include/xlnt/styles/style.hpp | 3 +- include/xlnt/worksheet/worksheet.hpp | 2 + include/xlnt/writer/style_writer.hpp | 45 ++-- scripts/format_xml_string.py | 9 + source/cell.cpp | 54 +--- source/cell_reference.cpp | 5 + source/comment.cpp | 28 +-- source/detail/cell_impl.cpp | 6 +- source/detail/cell_impl.hpp | 4 +- source/detail/comment_impl.hpp | 24 -- source/detail/worksheet_impl.hpp | 1 - source/protection.cpp | 15 ++ source/style.cpp | 19 ++ source/style_writer.cpp | 26 ++ source/value.cpp | 23 ++ source/workbook.cpp | 30 ++- source/worksheet.cpp | 5 + tests/runner-autogen.cpp | 242 +++++++++++------- tests/test_cell.hpp | 14 -- tests/test_style.hpp | 349 +++++++++++++++++--------- tests/test_worksheet.hpp | 64 ++++- tests/test_write.hpp | 27 +- 28 files changed, 654 insertions(+), 370 deletions(-) create mode 100644 scripts/format_xml_string.py delete mode 100644 source/detail/comment_impl.hpp create mode 100644 source/protection.cpp create mode 100644 source/style.cpp diff --git a/include/xlnt/cell/cell.hpp b/include/xlnt/cell/cell.hpp index a0c3e9c5..6f6bc62b 100644 --- a/include/xlnt/cell/cell.hpp +++ b/include/xlnt/cell/cell.hpp @@ -86,6 +86,7 @@ public: bool has_style() const; style &get_style(); const style &get_style() const; + void set_style(const style &s); std::pair get_anchor() const; @@ -96,8 +97,7 @@ public: bool is_date() const; comment get_comment() const; - void set_comment(comment &comment); - void set_comment(comment &&comment); + void set_comment(const comment &comment); void clear_comment(); bool has_comment() const; diff --git a/include/xlnt/cell/cell_reference.hpp b/include/xlnt/cell/cell_reference.hpp index dc090c77..0e2014fb 100644 --- a/include/xlnt/cell/cell_reference.hpp +++ b/include/xlnt/cell/cell_reference.hpp @@ -94,6 +94,8 @@ public: std::string to_string() const; range_reference to_range() const; + range_reference operator,(const cell_reference &other) const; + bool operator==(const cell_reference &comparand) const; bool operator==(const std::string &reference_string) const { return *this == cell_reference(reference_string); } bool operator==(const char *reference_string) const { return *this == std::string(reference_string); } diff --git a/include/xlnt/cell/comment.hpp b/include/xlnt/cell/comment.hpp index b40b7b69..4166c07f 100644 --- a/include/xlnt/cell/comment.hpp +++ b/include/xlnt/cell/comment.hpp @@ -3,23 +3,20 @@ #include namespace xlnt { -namespace detail { -struct cell_impl; -struct comment_impl; -} // namespace detail class comment { public: + comment(); comment(const std::string &text, const std::string &author); ~comment(); + std::string get_text() const; std::string get_author() const; private: - friend class cell; - comment(detail::comment_impl *d); - detail::comment_impl *d_; + std::string text_; + std::string author_; }; } // namespace xlnt diff --git a/include/xlnt/cell/value.hpp b/include/xlnt/cell/value.hpp index ec313433..d80579b4 100644 --- a/include/xlnt/cell/value.hpp +++ b/include/xlnt/cell/value.hpp @@ -27,6 +27,7 @@ public: value(); value(value &&v); + value(const value &v); value(bool b); value(int8_t i); value(int16_t i); diff --git a/include/xlnt/styles/number_format.hpp b/include/xlnt/styles/number_format.hpp index 6e1ea1dd..4b1cd46a 100644 --- a/include/xlnt/styles/number_format.hpp +++ b/include/xlnt/styles/number_format.hpp @@ -89,6 +89,9 @@ public: static bool is_date_format(const std::string &format); static bool is_builtin(const std::string &format); + number_format() : format_code_(format::general), format_index_(0) {} + number_format(format code) : format_code_(code) {} + format get_format_code() const { return format_code_; } void set_format_code(format format_code) { format_code_ = format_code; } void set_format_code(const std::string &format_code) { custom_format_code_ = format_code; } diff --git a/include/xlnt/styles/protection.hpp b/include/xlnt/styles/protection.hpp index 8f3209d8..8a7b5944 100644 --- a/include/xlnt/styles/protection.hpp +++ b/include/xlnt/styles/protection.hpp @@ -35,8 +35,12 @@ public: unprotected }; - type locked; - type hidden; + protection(); + protection(type locked); + +private: + type locked_; + type hidden_; }; } // namespace xlnt diff --git a/include/xlnt/styles/style.hpp b/include/xlnt/styles/style.hpp index a84a6618..369ff1f0 100644 --- a/include/xlnt/styles/style.hpp +++ b/include/xlnt/styles/style.hpp @@ -37,6 +37,7 @@ class style { public: style(bool static_ = false) : static_(static_) {} + style(const style &rhs); style copy() const; @@ -60,8 +61,6 @@ public: void set_protection(protection protection); private: - style(const style &rhs); - bool static_ = false; font font_; fill fill_; diff --git a/include/xlnt/worksheet/worksheet.hpp b/include/xlnt/worksheet/worksheet.hpp index 139a91d2..1fec2d40 100644 --- a/include/xlnt/worksheet/worksheet.hpp +++ b/include/xlnt/worksheet/worksheet.hpp @@ -307,6 +307,8 @@ public: const range operator[](const range_reference &reference) const; range operator[](const std::string &range_string); const range operator[](const std::string &range_string) const; + range operator()(const cell_reference &top_left, const cell_reference &bottom_right); + const range operator()(const cell_reference &top_left, const cell_reference &bottom_right) const; // page page_setup &get_page_setup(); diff --git a/include/xlnt/writer/style_writer.hpp b/include/xlnt/writer/style_writer.hpp index 98419796..f9231f14 100644 --- a/include/xlnt/writer/style_writer.hpp +++ b/include/xlnt/writer/style_writer.hpp @@ -35,27 +35,28 @@ class workbook; class style_writer { - public: - style_writer(workbook &wb); - style_writer(const style_writer &); - style_writer &operator=(const style_writer &); - std::unordered_map get_style_by_hash() const; - std::string write_table() const; - - private: - std::vector