29 #include <xlnt/xlnt_config.hpp> 30 #include <xlnt/cell/cell_reference.hpp> 31 #include <xlnt/worksheet/pane.hpp> 32 #include <xlnt/worksheet/range_reference.hpp> 33 #include <xlnt/utils/exceptions.hpp> 34 #include <xlnt/utils/optional.hpp> 54 : active_cell_(active_cell), sqref_({
range_reference(active_cell, active_cell)}), pane_(quadrant)
63 : active_cell_(active_cell), sqref_({selected}), pane_(quadrant)
72 return active_cell_.is_set();
80 return active_cell_.get();
96 return !sqref_.empty();
112 return sqref_.front();
118 const std::vector<range_reference>&
sqrefs()
const 134 void sqref(
const std::vector<range_reference> &ref)
144 void sqref(
const std::string &ref);
168 return active_cell_ == rhs.active_cell_
169 && sqref_ == rhs.sqref_
170 && pane_ == rhs.pane_;
183 std::vector<range_reference> sqref_;
void sqref(const range_reference &ref)
Sets the range encompassed by this selection.
Definition: selection.hpp:126
bool has_sqref() const
Returns true if this selection has a defined sqref.
Definition: selection.hpp:94
pane_corner pane() const
Returns the sheet quadrant of this selection.
Definition: selection.hpp:149
void pane(pane_corner corner)
Sets the sheet quadrant of this selection to corner.
Definition: selection.hpp:157
The selected area of a worksheet.
Definition: selection.hpp:41
Enumerates the possible types a cell can be determined by it's current value.
Definition: cell.hpp:37
const std::vector< range_reference > & sqrefs() const
Returns the range encompassed by this selection.
Definition: selection.hpp:118
selection(pane_corner quadrant, cell_reference active_cell, range_reference selected)
ctor with selected range sqref must contain active_cell
Definition: selection.hpp:62
An object used to refer to a cell. References have two parts, the column and the row. In Excel, the reference string A1 refers to the top-left-most cell. A cell_reference can be initialized from a string of this form or a 1-indexed ordered pair of the form column, row.
Definition: cell_reference.hpp:60
Exception when setting a class's attribute to an invalid value
Definition: exceptions.hpp:240
void active_cell(const cell_reference &ref)
Sets the active cell to that pointed to by ref.
Definition: selection.hpp:86
pane_corner
Enumeration of the four quadrants of a worksheet
Definition: pane.hpp:48
Many settings in xlnt are allowed to not have a value set. This class encapsulates a value which may ...
Definition: format.hpp:44
bool has_active_cell() const
Returns true if this selection has a defined active cell.
Definition: selection.hpp:70
bool operator==(const selection &rhs) const
Returns true if this selection is equal to rhs based on its active cell, sqref, and pane...
Definition: selection.hpp:166
selection(pane_corner quadrant, cell_reference active_cell)
ctor when no range selected sqref == active_cell
Definition: selection.hpp:53
A range_reference describes a rectangular area of a worksheet with positive width and height defined ...
Definition: range_reference.hpp:36
cell_reference active_cell() const
Returns the cell reference of the active cell.
Definition: selection.hpp:78
void sqref(const std::vector< range_reference > &ref)
Sets the range encompassed by this selection.
Definition: selection.hpp:134
XLNT_DEPRECATED range_reference sqref() const
Returns the range encompassed by this selection. If the range contains multiple (non-contiguous) regi...
Definition: selection.hpp:107