set selection::sqref in freeze_panes

-- NOTE: It doesn't seem likely that these should be 'A1' in all cases (set to 'A1' because current tests demanded it). Purpose of this parameter needs clarification
-- NOTE: [xlnt::selection] needs appropriate ctor's once the purpose of the parameters can be clarified
This commit is contained in:
Crzyrndm 2018-06-16 18:34:40 +12:00
parent 4592b86746
commit 6f13002ac6
2 changed files with 21 additions and 15 deletions

View File

@ -290,13 +290,17 @@ void worksheet::freeze_panes(xlnt::cell top_left_cell)
void worksheet::freeze_panes(const cell_reference &ref)
{
if (ref == "A1")
{
unfreeze_panes();
return;
}
if (!has_view())
{
d_->views_.push_back(sheet_view());
}
auto &primary_view = d_->views_.front();
if (!primary_view.has_pane())
{
primary_view.pane(pane());
@ -307,38 +311,40 @@ void worksheet::freeze_panes(const cell_reference &ref)
primary_view.clear_selections();
primary_view.add_selection(selection());
if (ref == "A1")
primary_view.add_selection(selection());
if (ref.column() == "A") // no column is frozen
{
unfreeze_panes();
}
else if (ref.column() == "A")
{
primary_view.add_selection(selection());
primary_view.selection(0).pane(pane_corner::bottom_left);
primary_view.selection(0).sqref("A1");
primary_view.selection(0).active_cell(ref.make_offset(0, -1)); // cell above
primary_view.selection(1).pane(pane_corner::bottom_right);
primary_view.selection(1).sqref("A1");
primary_view.selection(1).active_cell(ref);
primary_view.pane().active_pane = pane_corner::bottom_left;
primary_view.pane().y_split = ref.row() - 1;
}
else if (ref.row() == 1)
else if (ref.row() == 1) // no row is frozen
{
primary_view.add_selection(selection());
primary_view.selection(0).pane(pane_corner::top_right);
primary_view.selection(0).sqref("A1");
primary_view.selection(0).active_cell(ref.make_offset(-1, 0)); // cell to the left
primary_view.selection(1).pane(pane_corner::bottom_right);
primary_view.selection(1).sqref("A1");
primary_view.selection(1).active_cell(ref);
primary_view.pane().active_pane = pane_corner::top_right;
primary_view.pane().x_split = ref.column_index() - 1;
}
else
else // column and row is frozen
{
primary_view.add_selection(selection());
primary_view.add_selection(selection());
primary_view.selection(0).pane(pane_corner::top_right);
primary_view.selection(0).sqref("A1");
primary_view.selection(0).active_cell(ref.make_offset(0, -1)); // cell above
primary_view.selection(1).pane(pane_corner::bottom_left);
primary_view.selection(1).sqref("A1");
primary_view.selection(1).active_cell(ref.make_offset(-1, 0)); // cell to the left
primary_view.selection(2).pane(pane_corner::bottom_right);
primary_view.selection(2).sqref("A1");
primary_view.selection(2).active_cell(ref);
primary_view.pane().active_pane = pane_corner::bottom_right;
primary_view.pane().x_split = ref.column_index() - 1;

View File

@ -495,7 +495,7 @@ public:
xlnt_assert_equals(view.selections().size(), 2);
xlnt_assert_equals(view.selections()[0].active_cell(), "A3");
xlnt_assert_equals(view.selections()[0].pane(), xlnt::pane_corner::bottom_left);
xlnt_assert_equals(view.selections()[0].sqref(), "A1");
xlnt_assert_equals(view.selections()[0].sqref(), "A1"); // TODO: document sqref and clarify whether 'A1' is the intended value here
xlnt_assert_equals(view.pane().active_pane, xlnt::pane_corner::bottom_left);
xlnt_assert_equals(view.pane().state, xlnt::pane_state::frozen);
xlnt_assert_equals(view.pane().top_left_cell.get(), "A4");
@ -512,7 +512,7 @@ public:
xlnt_assert_equals(view.selections().size(), 2);
xlnt_assert_equals(view.selections()[0].active_cell(), "C1");
xlnt_assert_equals(view.selections()[0].pane(), xlnt::pane_corner::top_right);
xlnt_assert_equals(view.selections()[0].sqref(), "A1");
xlnt_assert_equals(view.selections()[0].sqref(), "A1"); // TODO: document sqref and clarify whether 'A1' is the intended value here
xlnt_assert_equals(view.pane().active_pane, xlnt::pane_corner::top_right);
xlnt_assert_equals(view.pane().state, xlnt::pane_state::frozen);
xlnt_assert_equals(view.pane().top_left_cell.get(), "D1");
@ -531,7 +531,7 @@ public:
xlnt_assert_equals(view.selections()[1].pane(), xlnt::pane_corner::bottom_left);
xlnt_assert_equals(view.selections()[2].active_cell(), "D4");
xlnt_assert_equals(view.selections()[2].pane(), xlnt::pane_corner::bottom_right);
xlnt_assert_equals(view.selections()[2].sqref(), "A1");
xlnt_assert_equals(view.selections()[2].sqref(), "A1"); // TODO: document sqref and clarify whether 'A1' is the intended value here
xlnt_assert_equals(view.pane().active_pane, xlnt::pane_corner::bottom_right);
xlnt_assert_equals(view.pane().state, xlnt::pane_state::frozen);
xlnt_assert_equals(view.pane().top_left_cell.get(), "D4");