diff --git a/include/xlnt/cell/cell.hpp b/include/xlnt/cell/cell.hpp index 9ff5fb93..3670bd1e 100644 --- a/include/xlnt/cell/cell.hpp +++ b/include/xlnt/cell/cell.hpp @@ -54,6 +54,7 @@ class workbook; class worksheet; class xlsx_consumer; class xlsx_producer; +class phonetic_pr; struct date; struct datetime; @@ -501,6 +502,18 @@ public: /// void merged(bool merged); + // phonetics + + /// + /// Returns true if this cell is set to show phonetic information. + /// + bool phonetics_visible() const; + + /// + /// Enables the display of phonetic information on this cell. + /// + void show_phonetics(bool phonetics); + /// /// Returns the error string that is stored in this cell. /// diff --git a/source/cell/cell.cpp b/source/cell/cell.cpp index 5fcf6030..f63cb06f 100644 --- a/source/cell/cell.cpp +++ b/source/cell/cell.cpp @@ -56,6 +56,7 @@ #include #include #include +#include namespace { @@ -198,7 +199,7 @@ cell::cell(detail::cell_impl *d) bool cell::garbage_collectible() const { - return !(has_value() || is_merged() || has_formula() || has_format() || has_hyperlink()); + return !(has_value() || is_merged() || phonetics_visible() || has_formula() || has_format() || has_hyperlink()); } void cell::value(std::nullptr_t) @@ -329,6 +330,16 @@ bool cell::is_merged() const return d_->is_merged_; } +bool cell::phonetics_visible() const +{ + return d_->phonetics_visible_; +} + +void cell::show_phonetics(bool phonetics) +{ + d_->phonetics_visible_ = phonetics; +} + bool cell::is_date() const { return data_type() == type::number diff --git a/source/detail/implementations/cell_impl.cpp b/source/detail/implementations/cell_impl.cpp index 8be6324b..b5ac9ef4 100644 --- a/source/detail/implementations/cell_impl.cpp +++ b/source/detail/implementations/cell_impl.cpp @@ -35,6 +35,7 @@ cell_impl::cell_impl() column_(1), row_(1), is_merged_(false), + phonetics_visible_(false), value_numeric_(0) { } diff --git a/source/detail/implementations/cell_impl.hpp b/source/detail/implementations/cell_impl.hpp index 64756770..4d7bfc63 100644 --- a/source/detail/implementations/cell_impl.hpp +++ b/source/detail/implementations/cell_impl.hpp @@ -55,6 +55,7 @@ struct cell_impl row_t row_; bool is_merged_; + bool phonetics_visible_; rich_text value_text_; double value_numeric_; @@ -72,6 +73,7 @@ inline bool operator==(const cell_impl &lhs, const cell_impl &rhs) && lhs.column_ == rhs.column_ && lhs.row_ == rhs.row_ && lhs.is_merged_ == rhs.is_merged_ + && lhs.phonetics_visible_ == rhs.phonetics_visible_ && lhs.value_text_ == rhs.value_text_ && lhs.value_numeric_ == rhs.value_numeric_ && lhs.formula_ == rhs.formula_ diff --git a/tests/cell/cell_test_suite.cpp b/tests/cell/cell_test_suite.cpp index 272fb479..038fbe20 100644 --- a/tests/cell/cell_test_suite.cpp +++ b/tests/cell/cell_test_suite.cpp @@ -82,6 +82,7 @@ public: register_test(test_hyperlink); register_test(test_comment); register_test(test_copy_and_compare); + register_test(test_cell_phonetic_properties); } private: @@ -805,6 +806,19 @@ private: cell3 = cell2; xlnt_assert_equals(cell2, cell3); } + + void test_cell_phonetic_properties() + { + xlnt::workbook wb; + auto ws = wb.active_sheet(); + auto cell1 = ws.cell("A1"); + + xlnt_assert_equals(cell1.phonetics_visible(), false); + cell1.show_phonetics(true); + xlnt_assert_equals(cell1.phonetics_visible(), true); + cell1.show_phonetics(false); + xlnt_assert_equals(cell1.phonetics_visible(), false); + } }; static cell_test_suite x{}; \ No newline at end of file