From d39b7a107afb342ea7965723b6c847476f2f4511 Mon Sep 17 00:00:00 2001 From: Crzyrndm Date: Sat, 28 Jul 2018 13:55:56 +1200 Subject: [PATCH] comment default size only set in the overloads which can't set size - Debatable whether position should receive the same treatment --- source/cell/cell.cpp | 10 ++++++---- source/cell/comment.cpp | 6 +++++- tests/cell/cell_test_suite.cpp | 5 +++++ 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/source/cell/cell.cpp b/source/cell/cell.cpp index 667212d8..235928dd 100644 --- a/source/cell/cell.cpp +++ b/source/cell/cell.cpp @@ -964,13 +964,16 @@ class comment cell::comment() void cell::comment(const std::string &text, const std::string &author) { - comment(xlnt::comment(text, author)); + xlnt::comment tmp_comment(text, author); + tmp_comment.size(200, 100); + comment(tmp_comment); } void cell::comment(const std::string &text, const class font &comment_font, const std::string &author) { - xlnt::rich_text rich_comment_text(text, comment_font); - comment(xlnt::comment(rich_comment_text, author)); + xlnt::comment tmp_comment(xlnt::rich_text(text, comment_font), author); + tmp_comment.size(200, 100); + comment(tmp_comment); } void cell::comment(const class comment &new_comment) @@ -991,7 +994,6 @@ void cell::comment(const class comment &new_comment) cell_position.second += 5; d_->comment_.get()->position(cell_position.first, cell_position.second); - d_->comment_.get()->size(200, 100); worksheet().register_comments_in_manifest(); } diff --git a/source/cell/comment.cpp b/source/cell/comment.cpp index 16722d29..abd3bdb1 100644 --- a/source/cell/comment.cpp +++ b/source/cell/comment.cpp @@ -105,7 +105,11 @@ int comment::height() const bool comment::operator==(const comment &other) const { - return text_ == other.text_ && author_ == other.author_; + // not comparing top/left as this is set on a per cell basis + return text_ == other.text_ + && author_ == other.author_ + && width_ == other.width_ + && height_ == other.height_; } bool comment::operator!=(const comment &other) const diff --git a/tests/cell/cell_test_suite.cpp b/tests/cell/cell_test_suite.cpp index 510786b3..272fb479 100644 --- a/tests/cell/cell_test_suite.cpp +++ b/tests/cell/cell_test_suite.cpp @@ -774,6 +774,11 @@ private: cell.clear_comment(); xlnt_assert(!cell.has_comment()); xlnt_assert_throws(cell.comment(), xlnt::exception); + + xlnt::comment comment_with_size("test comment", "author"); + comment_with_size.size(1000, 30); + cell.comment(comment_with_size); + xlnt_assert_equals(cell.comment(), comment_with_size); } void test_copy_and_compare()