diff --git a/src/ct/ct_actions_format.cc b/src/ct/ct_actions_format.cc index 074e6c928..eeca20243 100644 --- a/src/ct/ct_actions_format.cc +++ b/src/ct/ct_actions_format.cc @@ -453,7 +453,7 @@ CtActions::text_view_n_buffer_codebox_proof CtActions::_get_text_view_n_buffer_c } if (CtTable* pTable = _table_in_use()) { return text_view_n_buffer_codebox_proof{ - &static_cast(pTable->get_table_matrix().at(pTable->current_row()).at(pTable->current_column()))->get_text_view(), + &pTable->curr_cell_text_view(), CtConst::PLAIN_TEXT_ID, nullptr, pTable}; diff --git a/src/ct/ct_table.cc b/src/ct/ct_table.cc index 16211b3d2..cc6f596e8 100644 --- a/src/ct/ct_table.cc +++ b/src/ct/ct_table.cc @@ -489,6 +489,11 @@ void CtTable::grab_focus() const static_cast(_tableMatrix.at(current_row()).at(current_column()))->get_text_view().grab_focus(); } +CtTextView& CtTable::curr_cell_text_view() const +{ + return static_cast(_tableMatrix.at(current_row()).at(current_column()))->get_text_view(); +} + void CtTable::_on_populate_popup_cell(Gtk::Menu* menu) { if (not _pCtMainWin->user_active()) return; diff --git a/src/ct/ct_table.h b/src/ct/ct_table.h index c1608a982..5995e15b2 100644 --- a/src/ct/ct_table.h +++ b/src/ct/ct_table.h @@ -179,7 +179,7 @@ class CtTable : public CtTableCommon CtAnchWidgType get_type() override { return CtAnchWidgType::Table; } std::shared_ptr get_state() override; - const CtTableMatrix& get_table_matrix() const { return _tableMatrix; } + CtTextView& curr_cell_text_view() const; void write_strings_matrix(std::vector>& rows) const override; size_t get_num_rows() const override { return _tableMatrix.size(); } diff --git a/tests/tests_read_write.cpp b/tests/tests_read_write.cpp index 84ac2cdfa..98c61df38 100644 --- a/tests/tests_read_write.cpp +++ b/tests/tests_read_write.cpp @@ -493,41 +493,18 @@ void TestCtApp::_assert_tree_data(CtMainWin* pWin) for (size_t i = 0; i < expected_column_widths.size(); ++i) { ASSERT_EQ(expected_column_widths.at(i), actual_column_widths.at(i)); } - const CtTableMatrix& tableMatrix = pTable->get_table_matrix(); + std::vector> rows; + pTable->write_strings_matrix(rows); // three rows - ASSERT_EQ(3, tableMatrix.size()); + ASSERT_EQ(3, rows.size()); // two columns - ASSERT_EQ(2, tableMatrix.at(0).size()); - { - CtTextCell* pCell = static_cast(tableMatrix.at(0).at(0)); - ASSERT_STREQ("h1", pCell->get_text_content().c_str()); - ASSERT_STREQ(CtConst::TABLE_CELL_TEXT_ID, pCell->get_syntax_highlighting().c_str()); - } - { - CtTextCell* pCell = static_cast(tableMatrix.at(0).at(1)); - ASSERT_STREQ("h2", pCell->get_text_content().c_str()); - ASSERT_STREQ(CtConst::TABLE_CELL_TEXT_ID, pCell->get_syntax_highlighting().c_str()); - } - { - CtTextCell* pCell = static_cast(tableMatrix.at(1).at(0)); - ASSERT_STREQ("йцукенгшщз", pCell->get_text_content().c_str()); - ASSERT_STREQ(CtConst::TABLE_CELL_TEXT_ID, pCell->get_syntax_highlighting().c_str()); - } - { - CtTextCell* pCell = static_cast(tableMatrix.at(1).at(1)); - ASSERT_STREQ("2", pCell->get_text_content().c_str()); - ASSERT_STREQ(CtConst::TABLE_CELL_TEXT_ID, pCell->get_syntax_highlighting().c_str()); - } - { - CtTextCell* pCell = static_cast(tableMatrix.at(2).at(0)); - ASSERT_STREQ("3", pCell->get_text_content().c_str()); - ASSERT_STREQ(CtConst::TABLE_CELL_TEXT_ID, pCell->get_syntax_highlighting().c_str()); - } - { - CtTextCell* pCell = static_cast(tableMatrix.at(2).at(1)); - ASSERT_STREQ("4", pCell->get_text_content().c_str()); - ASSERT_STREQ(CtConst::TABLE_CELL_TEXT_ID, pCell->get_syntax_highlighting().c_str()); - } + ASSERT_EQ(2, rows.at(0).size()); + ASSERT_STREQ("h1", rows.at(0).at(0).c_str()); + ASSERT_STREQ("h2", rows.at(0).at(1).c_str()); + ASSERT_STREQ("йцукенгшщз", rows.at(1).at(0).c_str()); + ASSERT_STREQ("2", rows.at(1).at(1).c_str()); + ASSERT_STREQ("3", rows.at(2).at(0).c_str()); + ASSERT_STREQ("4", rows.at(2).at(1).c_str()); } break; case CtAnchWidgType::TableLight: { //TODO