mirror of
https://github.com/tfussell/xlnt.git
synced 2024-03-22 13:11:17 +08:00
Added phonetics field visibility option on cells
This commit is contained in:
parent
10c5781e6d
commit
48a865cd66
|
@ -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:
|
|||
/// </summary>
|
||||
void merged(bool merged);
|
||||
|
||||
// phonetics
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if this cell is set to show phonetic information.
|
||||
/// </summary>
|
||||
bool phonetics_visible() const;
|
||||
|
||||
/// <summary>
|
||||
/// Enables the display of phonetic information on this cell.
|
||||
/// </summary>
|
||||
void show_phonetics(bool phonetics);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the error string that is stored in this cell.
|
||||
/// </summary>
|
||||
|
|
|
@ -56,6 +56,7 @@
|
|||
#include <xlnt/worksheet/column_properties.hpp>
|
||||
#include <xlnt/worksheet/row_properties.hpp>
|
||||
#include <xlnt/worksheet/worksheet.hpp>
|
||||
#include <xlnt/worksheet/phonetic_pr.hpp>
|
||||
|
||||
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
|
||||
|
|
|
@ -35,6 +35,7 @@ cell_impl::cell_impl()
|
|||
column_(1),
|
||||
row_(1),
|
||||
is_merged_(false),
|
||||
phonetics_visible_(false),
|
||||
value_numeric_(0)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -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_
|
||||
|
|
|
@ -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{};
|
Loading…
Reference in New Issue
Block a user