Update pane struct to match spec

Fixes #388
This commit is contained in:
snippet 2022-11-22 17:54:43 +11:00
parent f0801fb7c7
commit e61f807dfd
2 changed files with 20 additions and 13 deletions

View File

@ -53,6 +53,7 @@ enum class XLNT_API pane_corner
/// <summary>
/// A fixed portion of a worksheet.
/// Implements section 3.3.1.64 of ECMA 376 - Worksheet view pane
/// </summary>
struct XLNT_API pane
{
@ -64,22 +65,22 @@ struct XLNT_API pane
/// <summary>
/// The state of the pane
/// </summary>
pane_state state = pane_state::split;
optional<pane_state> state = pane_state::split;
/// <summary>
/// The pane which contains the active cell
/// </summary>
pane_corner active_pane = pane_corner::top_left;
optional<pane_corner> active_pane = pane_corner::top_left;
/// <summary>
/// The row where the split should take place
/// </summary>
row_t y_split = 1;
optional<double> y_split = 0.0;
/// <summary>
/// The column where the split should take place
/// </summary>
column_t x_split = 1;
optional<double> x_split = 0.0;
/// <summary>
/// Returns true if this pane is equal to rhs based on its top-left cell, state,

View File

@ -2399,25 +2399,31 @@ void xlsx_producer::write_worksheet(const relationship &rel)
{
write_attribute("topLeftCell", current_pane.top_left_cell.get().to_string());
}
if (current_pane.x_split + 1 == current_pane.top_left_cell.get().column())
if (current_pane.x_split.is_set())
{
write_attribute("xSplit", current_pane.x_split.index);
write_attribute("xSplit", current_pane.x_split.get());
}
if (current_pane.y_split + 1 == current_pane.top_left_cell.get().row())
if (current_pane.x_split.is_set())
{
write_attribute("ySplit", current_pane.y_split);
write_attribute("ySplit", current_pane.y_split.get());
}
if (current_pane.active_pane != pane_corner::top_left)
if (current_pane.active_pane.is_set())
{
write_attribute("activePane", current_pane.active_pane);
if (current_pane.active_pane.get() != pane_corner::top_left)
{
write_attribute("activePane", current_pane.active_pane.get());
}
}
if (current_pane.state != pane_state::split)
if (current_pane.state.is_set())
{
write_attribute("state", current_pane.state);
if (current_pane.state.get() != pane_state::split)
{
write_attribute("state", current_pane.state.get());
}
}
write_end_element(xmlns, "pane");