finish documenting all headers (well enough). closes #28

This commit is contained in:
Thomas Fussell 2017-03-30 23:52:57 -04:00
parent c3d9b85530
commit 83d2d18d1f
46 changed files with 1450 additions and 1155 deletions

File diff suppressed because it is too large Load Diff

View File

@ -42,7 +42,7 @@ class range_reference;
struct XLNT_API cell_reference_hash
{
/// <summary>
///
/// Returns a hash representing a particular cell_reference.
/// </summary>
std::size_t operator()(const cell_reference &k) const;
};
@ -58,12 +58,12 @@ class XLNT_API cell_reference
{
public:
/// <summary>
/// Split a coordinate string like "A1" into an equivalent pair like {"A", 1}.
/// Splits a coordinate string like "A1" into an equivalent pair like {"A", 1}.
/// </summary>
static std::pair<std::string, row_t> split_reference(const std::string &reference_string);
/// <summary>
/// Split a coordinate string like "A1" into an equivalent pair like {"A", 1}.
/// Splits a coordinate string like "A1" into an equivalent pair like {"A", 1}.
/// Reference parameters absolute_column and absolute_row will be set to true
/// if column part or row part are prefixed by a dollar-sign indicating they
/// are absolute, otherwise false.
@ -98,7 +98,7 @@ public:
// absoluteness
/// <summary>
/// Convert a coordinate to an absolute coordinate string (e.g. B12 -> $B$12)
/// Converts a coordinate to an absolute coordinate string (e.g. B12 -> $B$12)
/// Defaulting to true, absolute_column and absolute_row can optionally control
/// whether the resulting cell_reference has an absolute column (e.g. B12 -> $B12)
/// and absolute row (e.g. B12 -> B$12) respectively.
@ -113,23 +113,23 @@ public:
cell_reference &make_absolute(bool absolute_column = true, bool absolute_row = true);
/// <summary>
/// Return true if the reference refers to an absolute column, otherwise false.
/// Returns true if the reference refers to an absolute column, otherwise false.
/// </summary>
bool column_absolute() const;
/// <summary>
/// Make this reference have an absolute column if absolute_column is true,
/// Makes this reference have an absolute column if absolute_column is true,
/// otherwise not absolute.
/// </summary>
void column_absolute(bool absolute_column);
/// <summary>
/// Return true if the reference refers to an absolute row, otherwise false.
/// Returns true if the reference refers to an absolute row, otherwise false.
/// </summary>
bool row_absolute() const;
/// <summary>
/// Make this reference have an absolute row if absolute_row is true,
/// Makes this reference have an absolute row if absolute_row is true,
/// otherwise not absolute.
/// </summary>
void row_absolute(bool absolute_row);
@ -137,38 +137,38 @@ public:
// getters/setters
/// <summary>
/// Return a string that identifies the column of this reference
/// Returns a string that identifies the column of this reference
/// (e.g. second column from left is "B")
/// </summary>
column_t column() const;
/// <summary>
/// Set the column of this reference from a string that identifies a particular column.
/// Sets the column of this reference from a string that identifies a particular column.
/// </summary>
void column(const std::string &column_string);
/// <summary>
/// Return a 1-indexed numeric index of the column of this reference.
/// Returns a 1-indexed numeric index of the column of this reference.
/// </summary>
column_t::index_t column_index() const;
/// <summary>
/// Set the column of this reference from a 1-indexed number that identifies a particular column.
/// Sets the column of this reference from a 1-indexed number that identifies a particular column.
/// </summary>
void column_index(column_t column);
/// <summary>
/// Return a 1-indexed numeric index of the row of this reference.
/// Returns a 1-indexed numeric index of the row of this reference.
/// </summary>
row_t row() const;
/// <summary>
/// Set the row of this reference from a 1-indexed number that identifies a particular row.
/// Sets the row of this reference from a 1-indexed number that identifies a particular row.
/// </summary>
void row(row_t row);
/// <summary>
/// Return a cell_reference offset from this cell_reference by
/// Returns a cell_reference offset from this cell_reference by
/// the number of columns and rows specified by the parameters.
/// A negative value for column_offset or row_offset results
/// in a reference above or left of this cell_reference, respectively.
@ -176,12 +176,12 @@ public:
cell_reference make_offset(int column_offset, int row_offset) const;
/// <summary>
/// Return a string like "A1" for cell_reference(1, 1).
/// Returns a string like "A1" for cell_reference(1, 1).
/// </summary>
std::string to_string() const;
/// <summary>
/// Return a 1x1 range_reference containing only this cell_reference.
/// Returns a 1x1 range_reference containing only this cell_reference.
/// </summary>
range_reference to_range() const;
@ -195,37 +195,37 @@ public:
range_reference operator,(const cell_reference &other) const;
/// <summary>
/// Return true if this reference is identical to comparand including
/// Returns true if this reference is identical to comparand including
/// in absoluteness of column and row.
/// </summary>
bool operator==(const cell_reference &comparand) const;
/// <summary>
/// Construct a cell_reference from reference_string and return the result
/// Constructs a cell_reference from reference_string and return the result
/// of their comparison.
/// </summary>
bool operator==(const std::string &reference_string) const;
/// <summary>
/// Construct a cell_reference from reference_string and return the result
/// Constructs a cell_reference from reference_string and return the result
/// of their comparison.
/// </summary>
bool operator==(const char *reference_string) const;
/// <summary>
/// Return true if this reference is not identical to comparand including
/// Returns true if this reference is not identical to comparand including
/// in absoluteness of column and row.
/// </summary>
bool operator!=(const cell_reference &comparand) const;
/// <summary>
/// Construct a cell_reference from reference_string and return the result
/// Constructs a cell_reference from reference_string and return the result
/// of their comparison.
/// </summary>
bool operator!=(const std::string &reference_string) const;
/// <summary>
/// Construct a cell_reference from reference_string and return the result
/// Constructs a cell_reference from reference_string and return the result
/// of their comparison.
/// </summary>
bool operator!=(const char *reference_string) const;

View File

@ -52,27 +52,27 @@ public:
comment(const std::string &text, const std::string &author);
/// <summary>
/// Return the text that will be displayed for this comment.
/// Returns the text that will be displayed for this comment.
/// </summary>
rich_text text() const;
/// <summary>
/// Return the plain text that will be displayed for this comment without formatting information.
/// Returns the plain text that will be displayed for this comment without formatting information.
/// </summary>
std::string plain_text() const;
/// <summary>
/// Return the author of this comment.
/// Returns the author of this comment.
/// </summary>
std::string author() const;
/// <summary>
/// Make this comment only visible when the associated cell is hovered.
/// Makes this comment only visible when the associated cell is hovered.
/// </summary>
void hide();
/// <summary>
/// Make this comment always visible.
/// Makes this comment always visible.
/// </summary>
void show();
@ -82,7 +82,7 @@ public:
bool visible() const;
/// <summary>
/// Set the absolute position of this cell to the given coordinates.
/// Sets the absolute position of this cell to the given coordinates.
/// </summary>
void position(int left, int top);
@ -97,7 +97,7 @@ public:
int top() const;
/// <summary>
/// Set the size of the comment.
/// Sets the size of the comment.
/// </summary>
void size(int width, int height);
@ -112,9 +112,14 @@ public:
int height() const;
/// <summary>
/// Return true if both comments are equivalent.
/// Return true if this comment is equivalent to other.
/// </summary>
friend XLNT_API bool operator==(const comment &left, const comment &right);
bool operator==(const comment &other) const;
/// <summary>
/// Returns true if this comment is not equivalent to other.
/// </summary>
bool operator!=(const comment &other) const;
private:
/// <summary>

View File

@ -48,7 +48,7 @@ class XLNT_API column_t
{
public:
/// <summary>
///
/// Alias declaration for the internal numeric type of this column.
/// </summary>
using index_t = std::uint32_t;
@ -73,237 +73,207 @@ public:
static std::string column_string_from_index(index_t column_index);
/// <summary>
/// Default column_t is the first (left-most) column.
/// Default constructor. The column points to the "A" column.
/// </summary>
column_t();
/// <summary>
/// Construct a column from a number.
/// Constructs a column from a number.
/// </summary>
column_t(index_t column_index);
/// <summary>
/// Construct a column from a string.
/// Constructs a column from a string.
/// </summary>
column_t(const std::string &column_string);
/// <summary>
/// Construct a column from a string.
/// Constructs a column from a string.
/// </summary>
column_t(const char *column_string);
/// <summary>
/// Copy constructor
/// Copy constructor. Constructs a column by copying it from other.
/// </summary>
column_t(const column_t &other);
/// <summary>
/// Move constructor
/// Move constructor. Constructs a column by moving it from other.
/// </summary>
column_t(column_t &&other);
/// <summary>
/// Return a string representation of this column index.
/// Returns a string representation of this column index.
/// </summary>
std::string column_string() const;
/// <summary>
/// Set this column to be the same as rhs's and return reference to self.
/// Sets this column to be the same as rhs's and return reference to self.
/// </summary>
column_t &operator=(column_t rhs);
/// <summary>
/// Set this column to be equal to rhs and return reference to self.
/// Sets this column to be equal to rhs and return reference to self.
/// </summary>
column_t &operator=(const std::string &rhs);
/// <summary>
/// Set this column to be equal to rhs and return reference to self.
/// Sets this column to be equal to rhs and return reference to self.
/// </summary>
column_t &operator=(const char *rhs);
/// <summary>
/// Return true if this column refers to the same column as other.
/// Returns true if this column refers to the same column as other.
/// </summary>
bool operator==(const column_t &other) const;
/// <summary>
/// Return true if this column doesn't refer to the same column as other.
/// Returns true if this column doesn't refer to the same column as other.
/// </summary>
bool operator!=(const column_t &other) const;
/// <summary>
/// Return true if this column refers to the same column as other.
/// Returns true if this column refers to the same column as other.
/// </summary>
bool operator==(int other) const;
/// <summary>
/// Return true if this column refers to the same column as other.
/// Returns true if this column refers to the same column as other.
/// </summary>
bool operator==(index_t other) const;
/// <summary>
/// Return true if this column refers to the same column as other.
/// Returns true if this column refers to the same column as other.
/// </summary>
bool operator==(const std::string &other) const;
/// <summary>
/// Return true if this column refers to the same column as other.
/// Returns true if this column refers to the same column as other.
/// </summary>
bool operator==(const char *other) const;
/// <summary>
/// Return true if this column doesn't refer to the same column as other.
/// Returns true if this column doesn't refer to the same column as other.
/// </summary>
bool operator!=(int other) const;
/// <summary>
/// Return true if this column doesn't refer to the same column as other.
/// Returns true if this column doesn't refer to the same column as other.
/// </summary>
bool operator!=(index_t other) const;
/// <summary>
/// Return true if this column doesn't refer to the same column as other.
/// Returns true if this column doesn't refer to the same column as other.
/// </summary>
bool operator!=(const std::string &other) const;
/// <summary>
/// Return true if this column doesn't refer to the same column as other.
/// Returns true if this column doesn't refer to the same column as other.
/// </summary>
bool operator!=(const char *other) const;
/// <summary>
/// Return true if other is to the right of this column.
/// Returns true if other is to the right of this column.
/// </summary>
bool operator>(const column_t &other) const;
/// <summary>
/// Return true if other is to the right of or equal to this column.
/// Returns true if other is to the right of or equal to this column.
/// </summary>
bool operator>=(const column_t &other) const;
/// <summary>
/// Return true if other is to the left of this column.
/// Returns true if other is to the left of this column.
/// </summary>
bool operator<(const column_t &other) const;
/// <summary>
/// Return true if other is to the left of or equal to this column.
/// Returns true if other is to the left of or equal to this column.
/// </summary>
bool operator<=(const column_t &other) const;
/// <summary>
/// Return true if other is to the right of this column.
/// Returns true if other is to the right of this column.
/// </summary>
bool operator>(const column_t::index_t &other) const;
/// <summary>
/// Return true if other is to the right of or equal to this column.
/// Returns true if other is to the right of or equal to this column.
/// </summary>
bool operator>=(const column_t::index_t &other) const;
/// <summary>
/// Return true if other is to the left of this column.
/// Returns true if other is to the left of this column.
/// </summary>
bool operator<(const column_t::index_t &other) const;
/// <summary>
/// Return true if other is to the left of or equal to this column.
/// Returns true if other is to the left of or equal to this column.
/// </summary>
bool operator<=(const column_t::index_t &other) const;
/// <summary>
/// Pre-increment this column, making it point to the column one to the right.
/// Pre-increments this column, making it point to the column one to the right and returning a reference to it.
/// </summary>
column_t &operator++();
/// <summary>
/// Pre-deccrement this column, making it point to the column one to the left.
/// Pre-deccrements this column, making it point to the column one to the left and returning a reference to it.
/// </summary>
column_t &operator--();
/// <summary>
/// Post-increment this column, making it point to the column one to the right and returning the old column.
/// Post-increments this column, making it point to the column one to the right and returning the old column.
/// </summary>
column_t operator++(int);
/// <summary>
/// Post-decrement this column, making it point to the column one to the left and returning the old column.
/// Post-decrements this column, making it point to the column one to the left and returning the old column.
/// </summary>
column_t operator--(int);
/// <summary>
/// Return the result of adding rhs to this column.
/// Returns the result of adding rhs to this column.
/// </summary>
friend XLNT_API column_t operator+(column_t lhs, const column_t &rhs);
/// <summary>
/// Return the result of subtracing lhs by rhs column.
/// Returns the result of subtracing lhs by rhs column.
/// </summary>
friend XLNT_API column_t operator-(column_t lhs, const column_t &rhs);
/// <summary>
/// Return the result of multiply lhs by rhs column.
/// </summary>
friend XLNT_API column_t operator*(column_t lhs, const column_t &rhs);
/// <summary>
/// Return the result of divide lhs by rhs column.
/// </summary>
friend XLNT_API column_t operator/(column_t lhs, const column_t &rhs);
/// <summary>
/// Return the result of mod lhs by rhs column.
/// </summary>
friend XLNT_API column_t operator%(column_t lhs, const column_t &rhs);
/// <summary>
/// Add rhs to this column and return a reference to this column.
/// Adds rhs to this column and returns a reference to this column.
/// </summary>
column_t &operator+=(const column_t &rhs);
/// <summary>
/// Subtrac rhs from this column and return a reference to this column.
/// Subtracts rhs from this column and returns a reference to this column.
/// </summary>
column_t &operator-=(const column_t &rhs);
/// <summary>
/// Multiply this column by rhs and return a reference to this column.
/// </summary>
column_t &operator*=(const column_t &rhs);
/// <summary>
/// Divide this column by rhs and return a reference to this column.
/// </summary>
column_t &operator/=(const column_t &rhs);
/// <summary>
/// Mod this column by rhs and return a reference to this column.
/// </summary>
column_t &operator%=(const column_t &rhs);
/// <summary>
/// Return true if other is to the right of this column.
/// Returns true if other is to the right of this column.
/// </summary>
friend XLNT_API bool operator>(const column_t::index_t &left, const column_t &right);
/// <summary>
/// Return true if other is to the right of or equal to this column.
/// Returns true if other is to the right of or equal to this column.
/// </summary>
friend XLNT_API bool operator>=(const column_t::index_t &left, const column_t &right);
/// <summary>
/// Return true if other is to the left of this column.
/// Returns true if other is to the left of this column.
/// </summary>
friend XLNT_API bool operator<(const column_t::index_t &left, const column_t &right);
/// <summary>
/// Return true if other is to the left of or equal to this column.
/// Returns true if other is to the left of or equal to this column.
/// </summary>
friend XLNT_API bool operator<=(const column_t::index_t &left, const column_t &right);
/// <summary>
/// Swap the columns that left and right refer to.
/// Swaps the columns that left and right refer to.
/// </summary>
friend XLNT_API void swap(column_t &left, column_t &right);
@ -315,12 +285,12 @@ public:
/// <summary>
/// Functor for hashing a column.
/// Allows for use of std::unordered_set<column, column_hash> and similar.
/// Allows for use of std::unordered_set<column_t, column_hash> and similar.
/// </summary>
struct XLNT_API column_hash
{
/// <summary>
///
/// Returns the result of hashing column k.
/// </summary>
std::size_t operator()(const column_t &k) const;
};
@ -336,7 +306,7 @@ template <>
struct hash<xlnt::column_t>
{
/// <summary>
///
/// Returns the result of hashing column k.
/// </summary>
size_t operator()(const xlnt::column_t &k) const
{

View File

@ -39,38 +39,38 @@ class XLNT_API rich_text
{
public:
/// <summary>
///
/// Constructs an empty rich text object with no font and empty text.
/// </summary>
rich_text() = default;
/// <summary>
///
/// Constructs a rich text object with the given text and no font.
/// </summary>
rich_text(const std::string &plain_text);
/// <summary>
///
/// Constructs a rich text object with the given text and font.
/// </summary>
rich_text(const std::string &plain_text, const class font &text_font);
/// <summary>
///
/// Copy constructor.
/// </summary>
rich_text(const rich_text_run &single_run);
/// <summary>
/// Remove all text runs from this text.
/// Removes all text runs from this text.
/// </summary>
void clear();
/// <summary>
/// Clear any runs in this text and add a single run with default formatting and
/// Clears any runs in this text and adds a single run with default formatting and
/// the given string as its textual content.
/// </summary>
void plain_text(const std::string &s);
/// <summary>
/// Combine the textual content of each text run in order and return the result.
/// Combines the textual content of each text run in order and returns the result.
/// </summary>
std::string plain_text() const;
@ -80,12 +80,12 @@ public:
std::vector<rich_text_run> runs() const;
/// <summary>
/// Set the runs of this text all at once.
/// Sets the runs of this text all at once.
/// </summary>
void runs(const std::vector<rich_text_run> &new_runs);
/// <summary>
/// Add a new run to the end of the set of runs.
/// Adds a new run to the end of the set of runs.
/// </summary>
void add_run(const rich_text_run &t);
@ -101,7 +101,7 @@ public:
private:
/// <summary>
///
/// The runs that make up this rich text.
/// </summary>
std::vector<rich_text_run> runs_;
};

View File

@ -143,7 +143,7 @@ public:
};
/// <summary>
/// A vector to the all of the border sides for iteration.
/// Returns a vector containing all of the border sides to be used for iteration.
/// </summary>
static const std::vector<border_side> &all_sides();

View File

@ -37,24 +37,25 @@ namespace xlnt {
class XLNT_API indexed_color
{
public:
//TODO: should this be explicit?
/// <summary>
///
/// Constructs an indexed_color from an index.
/// </summary>
indexed_color(std::size_t index);
/// <summary>
///
/// Returns the index this color points to.
/// </summary>
std::size_t index() const;
/// <summary>
///
/// Sets the index to index.
/// </summary>
void index(std::size_t index);
private:
/// <summary>
///
/// The index of this color
/// </summary>
std::size_t index_;
};
@ -66,23 +67,23 @@ class XLNT_API theme_color
{
public:
/// <summary>
///
/// Constructs a theme_color from an index.
/// </summary>
theme_color(std::size_t index);
/// <summary>
///
/// Returns the index of the color in the theme this points to.
/// </summary>
std::size_t index() const;
/// <summary>
///
/// Sets the index of this color to index.
/// </summary>
void index(std::size_t index);
private:
/// <summary>
///
/// The index of the color
/// </summary>
std::size_t index_;
};

View File

@ -59,7 +59,7 @@ enum class XLNT_API pattern_fill_type
};
/// <summary>
/// Represents a fill which colors the cell based on a foreground and
/// Represents a fill which colors the cell based on a foreground and
/// background color and a pattern.
/// </summary>
class XLNT_API pattern_fill
@ -112,23 +112,23 @@ public:
private:
/// <summary>
///
/// The type of this pattern_fill
/// </summary>
pattern_fill_type type_ = pattern_fill_type::none;
/// <summary>
///
/// The optional foreground color
/// </summary>
optional<color> foreground_;
/// <summary>
///
/// THe optional background color
/// </summary>
optional<color> background_;
};
/// <summary>
///
/// Enumerates the types of gradient fills
/// </summary>
enum class XLNT_API gradient_fill_type
{
@ -174,117 +174,117 @@ public:
// Left
/// <summary>
///
/// Returns the distance from the left where the gradient starts.
/// </summary>
double left() const;
/// <summary>
///
/// Sets the distance from the left where the gradient starts.
/// </summary>
gradient_fill &left(double value);
// Right
/// <summary>
///
/// Returns the distance from the right where the gradient starts.
/// </summary>
double right() const;
/// <summary>
///
/// Sets the distance from the right where the gradient starts.
/// </summary>
gradient_fill &right(double value);
// Top
/// <summary>
///
/// Returns the distance from the top where the gradient starts.
/// </summary>
double top() const;
/// <summary>
///
/// Sets the distance from the top where the gradient starts.
/// </summary>
gradient_fill &top(double value);
// Bottom
/// <summary>
///
/// Returns the distance from the bottom where the gradient starts.
/// </summary>
double bottom() const;
/// <summary>
///
/// Sets the distance from the bottom where the gradient starts.
/// </summary>
gradient_fill &bottom(double value);
// Stops
/// <summary>
///
/// Adds a gradient stop at position with the given color.
/// </summary>
gradient_fill &add_stop(double position, color stop_color);
/// <summary>
///
/// Deletes all stops from the gradient.
/// </summary>
gradient_fill &clear_stops();
/// <summary>
///
/// Returns all of the gradient stops.
/// </summary>
std::unordered_map<double, color> stops() const;
/// <summary>
/// Returns true if left is exactly equal to right.
/// Returns true if the gradient is equivalent to other.
/// </summary>
bool operator==(const gradient_fill &other) const;
/// <summary>
/// Returns true if left is not exactly equal to right.
/// Returns true if the gradient is not equivalent to other.
/// </summary>
bool operator!=(const gradient_fill &right) const;
private:
/// <summary>
///
/// The type of gradient
/// </summary>
gradient_fill_type type_ = gradient_fill_type::linear;
/// <summary>
///
/// The angle of the gradient
/// </summary>
double degree_ = 0;
/// <summary>
///
/// THe left distance
/// </summary>
double left_ = 0;
/// <summary>
///
/// THe right distance
/// </summary>
double right_ = 0;
/// <summary>
///
/// The top distance
/// </summary>
double top_ = 0;
/// <summary>
///
/// The bottom distance
/// </summary>
double bottom_ = 0;
/// <summary>
///
/// The gradient stops and colors
/// </summary>
std::unordered_map<double, color> stops_;
};
/// <summary>
///
/// Enumerates the possible fill types
/// </summary>
enum class XLNT_API fill_type
{

View File

@ -41,7 +41,7 @@ class XLNT_API font
{
public:
/// <summary>
///
/// Text can be underlined in the enumerated ways
/// </summary>
enum class underline_style
{
@ -53,258 +53,257 @@ public:
};
/// <summary>
///
/// Constructs a default font. Calibri, size 12
/// </summary>
font();
/// <summary>
///
/// Sets the bold state of the font to bold and returns a reference to the font.
/// </summary>
font &bold(bool bold);
/// <summary>
///
/// Returns the bold state of the font.
/// </summary>
bool bold() const;
/// <summary>
///
/// Sets the bold state of the font to bold and returns a reference to the font.
/// </summary>
font &superscript(bool superscript);
/// <summary>
///
/// Returns true if this font has a superscript applied.
/// </summary>
bool superscript() const;
/// <summary>
///
/// Sets the bold state of the font to bold and returns a reference to the font.
/// </summary>
font &italic(bool italic);
/// <summary>
///
/// Returns true if this font has italics applied.
/// </summary>
bool italic() const;
/// <summary>
///
/// Sets the bold state of the font to bold and returns a reference to the font.
/// </summary>
font &strikethrough(bool strikethrough);
/// <summary>
///
/// Returns true if this font has a strikethrough applied.
/// </summary>
bool strikethrough() const;
/// <summary>
///
/// Sets the bold state of the font to bold and returns a reference to the font.
/// </summary>
font &outline(bool outline);
/// <summary>
///
/// Returns true if this font has an outline applied.
/// </summary>
bool outline() const;
/// <summary>
///
/// Sets the shadow state of the font to shadow and returns a reference to the font.
/// </summary>
font &shadow(bool shadow);
/// <summary>
///
/// Returns true if this font has a shadow applied.
/// </summary>
bool shadow() const;
/// <summary>
///
/// Sets the underline state of the font to new_underline and returns a reference to the font.
/// </summary>
font &underline(underline_style new_underline);
/// <summary>
///
/// Returns true if this font has any type of underline applied.
/// </summary>
bool underlined() const;
/// <summary>
///
/// Returns the particular style of underline this font has applied.
/// </summary>
underline_style underline() const;
/// <summary>
///
/// Returns true if this font has a defined size.
/// </summary>
bool has_size() const;
/// <summary>
///
/// Sets the size of the font to size and returns a reference to the font.
/// </summary>
font &size(double size);
/// <summary>
///
/// Returns the size of the font.
/// </summary>
double size() const;
/// <summary>
///
/// Returns true if this font has a particular face applied (e.g. "Comic Sans").
/// </summary>
bool has_name() const;
/// <summary>
///
/// Sets the font face to name and returns a reference to the font.
/// </summary>
font &name(const std::string &name);
/// <summary>
///
/// Returns the name of the font face.
/// </summary>
std::string name() const;
/// <summary>
///
/// Returns true if this font has a color applied.
/// </summary>
bool has_color() const;
/// <summary>
///
/// Sets the color of the font to c and returns a reference to the font.
/// </summary>
font &color(const color &c);
/// <summary>
///
/// Returns the color that this font is using.
/// </summary>
xlnt::color color() const;
/// <summary>
///
/// Returns true if this font has a family defined.
/// </summary>
bool has_family() const;
/// <summary>
///
/// Sets the family index of the font to family and returns a reference to the font.
/// </summary>
font &family(std::size_t family);
/// <summary>
///
/// Returns the family index for the font.
/// </summary>
std::size_t family() const;
/// <summary>
///
/// Returns true if this font has a charset defined.
/// </summary>
bool has_charset() const;
// TODO: charset should be an enum, not a number
/// <summary>
///
/// Sets the charset of the font to charset and returns a reference to the font.
/// </summary>
font &charset(std::size_t charset);
/// <summary>
///
/// Returns the charset of the font.
/// </summary>
std::size_t charset() const;
/// <summary>
///
/// Returns true if this font has a scheme.
/// </summary>
bool has_scheme() const;
/// <summary>
///
/// Sets the scheme of the font to scheme and returns a reference to the font.
/// </summary>
font &scheme(const std::string &scheme);
/// <summary>
///
/// Returns the scheme of this font.
/// </summary>
std::string scheme() const;
/// <summary>
/// Returns true if left is exactly equal to right.
/// </summary>
XLNT_API friend bool operator==(const font &left, const font &right);
bool operator==(const font &other) const;
/// <summary>
/// Returns true if left is not exactly equal to right.
/// </summary>
XLNT_API friend bool operator!=(const font &left, const font &right)
{
return !(left == right);
}
bool operator!=(const font &other) const;
private:
friend class style;
/// <summary>
///
/// The name of the font
/// </summary>
optional<std::string> name_;
/// <summary>
///
/// size
/// </summary>
optional<double> size_;
/// <summary>
///
/// bold
/// </summary>
bool bold_ = false;
/// <summary>
///
/// italic
/// </summary>
bool italic_ = false;
/// <summary>
///
/// superscript
/// </summary>
bool superscript_ = false;
/// <summary>
///
/// subscript
/// </summary>
bool subscript_ = false;
/// <summary>
///
/// strikethrough
/// </summary>
bool strikethrough_ = false;
/// <summary>
///
/// outline
/// </summary>
bool outline_ = false;
/// <summary>
///
/// shadow
/// </summary>
bool shadow_ = false;
/// <summary>
///
/// underline style
/// </summary>
underline_style underline_ = underline_style::none;
/// <summary>
///
/// color
/// </summary>
optional<xlnt::color> color_;
/// <summary>
///
/// family
/// </summary>
optional<std::size_t> family_;
/// <summary>
///
/// charset
/// </summary>
optional<std::size_t> charset_;
/// <summary>
///
/// scheme
/// </summary>
optional<std::string> scheme_;
};

View File

@ -53,207 +53,176 @@ class xlsx_producer;
class XLNT_API format
{
public:
// Alignment
/// <summary>
///
/// Returns the alignment of this format.
/// </summary>
class alignment &alignment();
class alignment alignment() const;
/// <summary>
///
/// Sets the alignment of this format to new_alignment. Applied, which defaults
/// to true, determines whether the alignment should be enabled for cells using
/// this format.
/// </summary>
const class alignment &alignment() const;
format alignment(const xlnt::alignment &new_alignment, bool applied = true);
/// <summary>
///
/// </summary>
format alignment(const xlnt::alignment &new_alignment, bool applied);
/// <summary>
///
/// Returns true if the alignment of this format should be applied to cells
/// using it.
/// </summary>
bool alignment_applied() const;
// Border
/// <summary>
///
/// Returns the border of this format.
/// </summary>
class border &border();
class border border() const;
/// <summary>
///
/// Sets the border of this format to new_border. Applied, which defaults
/// to true, determines whether the border should be enabled for cells using
/// this format.
/// </summary>
const class border &border() const;
format border(const xlnt::border &new_border, bool applied = true);
/// <summary>
///
/// </summary>
format border(const xlnt::border &new_border, bool applied);
/// <summary>
///
/// Returns true if the border set for this format should be applied to cells using the format.
/// </summary>
bool border_applied() const;
// Fill
/// <summary>
///
/// Returns the fill of this format.
/// </summary>
class fill &fill();
class fill fill() const;
/// <summary>
///
/// Sets the fill of this format to new_fill. Applied, which defaults
/// to true, determines whether the border should be enabled for cells using
/// this format.
/// </summary>
const class fill &fill() const;
format fill(const xlnt::fill &new_fill, bool applied = true);
/// <summary>
///
/// </summary>
format fill(const xlnt::fill &new_fill, bool applied);
/// <summary>
///
/// Returns true if the fill set for this format should be applied to cells using the format.
/// </summary>
bool fill_applied() const;
// Font
/// <summary>
///
/// Returns the font of this format.
/// </summary>
class font &font();
class font font() const;
/// <summary>
///
/// Sets the font of this format to new_font. Applied, which defaults
/// to true, determines whether the font should be enabled for cells using
/// this format.
/// </summary>
const class font &font() const;
format font(const xlnt::font &new_font, bool applied = true);
/// <summary>
///
/// </summary>
format font(const xlnt::font &new_font, bool applied);
/// <summary>
///
/// Returns true if the font set for this format should be applied to cells using the format.
/// </summary>
bool font_applied() const;
// Number Format
/// <summary>
///
/// Returns the number format of this format.
/// </summary>
class number_format &number_format();
class number_format number_format() const;
/// <summary>
///
/// Sets the number format of this format to new_number_format. Applied, which defaults
/// to true, determines whether the number format should be enabled for cells using
/// this format.
/// </summary>
const class number_format &number_format() const;
format number_format(const xlnt::number_format &new_number_format, bool applied = true);
/// <summary>
///
/// </summary>
format number_format(const xlnt::number_format &new_number_format, bool applied);
/// <summary>
///
/// Returns true if the number_format set for this format should be applied to cells using the format.
/// </summary>
bool number_format_applied() const;
// Protection
/// <summary>
///
/// Returns the protection of this format.
/// </summary>
class protection &protection();
class protection protection() const;
/// <summary>
///
/// </summary>
const class protection &protection() const;
/// <summary>
///
/// </summary>
format protection(const xlnt::protection &new_protection, bool applied);
/// <summary>
///
/// Returns true if the protection set for this format should be applied to cells using the format.
/// </summary>
bool protection_applied() const;
/// <summary>
///
/// Sets the protection of this format to new_protection. Applied, which defaults
/// to true, determines whether the protection should be enabled for cells using
/// this format.
/// </summary>
format protection(const xlnt::protection &new_protection, bool applied = true);
/// <summary>
/// Returns true if the pivot table interface is enabled for this format.
/// </summary>
bool pivot_button() const;
/// <summary>
///
/// If show is true, a pivot table interface will be displayed for cells using
/// this format.
/// </summary>
void pivot_button(bool show);
/// <summary>
///
/// Returns true if this format should add a single-quote prefix for all text values.
/// </summary>
bool quote_prefix() const;
/// <summary>
///
/// If quote is true, enables a single-quote prefix for all text values in cells
/// using this format (e.g. "abc" will appear as "'abc"). The text will also not
/// be stored in sharedStrings when this is enabled.
/// </summary>
void quote_prefix(bool quote);
// Style
/// <summary>
///
/// Returns true if this format has a corresponding style applied.
/// </summary>
bool has_style() const;
/// <summary>
///
/// Removes the style from this format if it exists.
/// </summary>
void clear_style();
/// <summary>
///
/// Sets the style of this format to a style with the given name.
/// </summary>
format style(const std::string &name);
/// <summary>
///
/// Sets the style of this format to new_style.
/// </summary>
format style(const class style &new_style);
/// <summary>
///
/// Returns the style of this format. If it has no style, an invalid_parameter
/// exception will be thrown.
/// </summary>
class style style();
/// <summary>
///
/// </summary>
const class style style() const;
/// <summary>
/// Returns the style of this format. If it has no style, an invalid_parameters
/// exception will be thrown.
/// </summary>
const class style style() const;
private:
friend struct detail::stylesheet;
friend class detail::xlsx_producer;
friend class detail::xlsx_producer;
friend class cell;
/// <summary>
///
/// Constructs a format from an impl pointer.
/// </summary>
format(detail::format_impl *d);
/// <summary>
///
/// </summary>
std::size_t id() const;
/// <summary>
///
/// The internal implementation of this format
/// </summary>
detail::format_impl *d_;
};

View File

@ -28,6 +28,7 @@
#include <string>
#include <xlnt/xlnt_config.hpp>
#include <xlnt/utils/optional.hpp>
namespace xlnt {
@ -40,236 +41,232 @@ class XLNT_API number_format
{
public:
/// <summary>
///
/// Number format "General"
/// </summary>
static const number_format general();
/// <summary>
///
/// Number format "@"
/// </summary>
static const number_format text();
/// <summary>
///
/// Number format "0"
/// </summary>
static const number_format number();
/// <summary>
///
/// Number format "00"
/// </summary>
static const number_format number_00();
/// <summary>
///
/// Number format "#,##0.00"
/// </summary>
static const number_format number_comma_separated1();
/// <summary>
///
/// Number format "0%"
/// </summary>
static const number_format percentage();
/// <summary>
///
/// Number format "0.00%"
/// </summary>
static const number_format percentage_00();
/// <summary>
///
/// Number format "yyyy-mm-dd"
/// </summary>
static const number_format date_yyyymmdd2();
/// <summary>
///
/// Number format "yy-mm-dd"
/// </summary>
static const number_format date_yymmdd();
/// <summary>
///
/// Number format "dd/mm/yy"
/// </summary>
static const number_format date_ddmmyyyy();
/// <summary>
///
/// Number format "d/m/yy"
/// </summary>
static const number_format date_dmyslash();
/// <summary>
///
/// Number format "d-m-yy"
/// </summary>
static const number_format date_dmyminus();
/// <summary>
///
/// Number format "d-m"
/// </summary>
static const number_format date_dmminus();
/// <summary>
///
/// Number format "m-yy"
/// </summary>
static const number_format date_myminus();
/// <summary>
///
/// Number format "mm-dd-yy"
/// </summary>
static const number_format date_xlsx14();
/// <summary>
///
/// Number format "d-mmm-yy"
/// </summary>
static const number_format date_xlsx15();
/// <summary>
///
/// Number format "d-mmm"
/// </summary>
static const number_format date_xlsx16();
/// <summary>
///
/// Number format "mmm-yy"
/// </summary>
static const number_format date_xlsx17();
/// <summary>
///
/// Number format "m/d/yy h:mm"
/// </summary>
static const number_format date_xlsx22();
/// <summary>
///
/// Number format "yyyy-mm-dd h:mm:ss"
/// </summary>
static const number_format date_datetime();
/// <summary>
///
/// Number format "h:mm AM/PM"
/// </summary>
static const number_format date_time1();
/// <summary>
///
/// Number format "h:mm:ss AM/PM"
/// </summary>
static const number_format date_time2();
/// <summary>
///
/// Number format "h:mm"
/// </summary>
static const number_format date_time3();
/// <summary>
///
/// Number format "h:mm:ss"
/// </summary>
static const number_format date_time4();
/// <summary>
///
/// Number format "mm:ss"
/// </summary>
static const number_format date_time5();
/// <summary>
///
/// Number format "h:mm:ss"
/// </summary>
static const number_format date_time6();
/// <summary>
///
/// Returns true if the given format ID corresponds to a known builtin format.
/// </summary>
static bool is_builtin_format(std::size_t builtin_id);
/// <summary>
///
/// Returns the format with the given ID. Thows an invalid_parameter exception
/// if builtin_id is not a valid ID.
/// </summary>
static const number_format &from_builtin_id(std::size_t builtin_id);
/// <summary>
///
/// Constructs a default number_format equivalent to "General"
/// </summary>
number_format();
/// <summary>
///
/// Constructs a number format equivalent to that returned from number_format::from_builtin_id(builtin_id).
/// </summary>
number_format(std::size_t builtin_id);
/// <summary>
///
/// Constructs a number format from a code string. If the string matches a builtin ID,
/// its ID will also be set to match the builtin ID.
/// </summary>
number_format(const std::string &code);
/// <summary>
///
/// Constructs a number format from a code string and custom ID. Custom ID should generally
/// be >= 164.
/// </summary>
number_format(const std::string &code, std::size_t custom_id);
/// <summary>
///
/// Sets the format code of this number format to format_code.
/// </summary>
void format_string(const std::string &format_code);
/// <summary>
///
/// Sets the format code of this number format to format_code and the ID to custom_id.
/// </summary>
void format_string(const std::string &format_code, std::size_t custom_id);
/// <summary>
///
/// Returns the format code this number format uses.
/// </summary>
std::string format_string() const;
/// <summary>
///
/// Returns true if this number format has an ID.
/// </summary>
bool has_id() const;
/// <summary>
///
/// Sets the ID of this number format to id.
/// </summary>
void id(std::size_t id);
/// <summary>
///
/// Returns the ID of this format.
/// </summary>
std::size_t id() const;
/// <summary>
///
/// Returns text formatted according to this number format's format code.
/// </summary>
std::string format(const std::string &text) const;
/// <summary>
///
/// Returns number formatted according to this number format's format code
/// with the given base date.
/// </summary>
std::string format(long double number, calendar base_date) const;
/// <summary>
///
/// Returns true if this format code returns a number formatted as a date.
/// </summary>
bool is_date_format() const;
/// <summary>
/// Returns true if left is exactly equal to right.
/// Returns true if this format is equivalent to other.
/// </summary>
XLNT_API friend bool operator==(const number_format &left, const number_format &right);
bool operator==(const number_format &other) const;
/// <summary>
/// Returns true if left is not exactly equal to right.
/// Returns true if this format is not equivalent to other.
/// </summary>
XLNT_API friend bool operator!=(const number_format &left, const number_format &right)
{
return !(left == right);
}
bool operator!=(const number_format &other) const;
private:
/// <summary>
///
/// The optional ID
/// </summary>
bool id_set_;
optional<std::size_t> id_;
/// <summary>
///
/// </summary>
std::size_t id_;
/// <summary>
///
/// The format code
/// </summary>
std::string format_string_;
};

View File

@ -38,71 +38,68 @@ class XLNT_API protection
{
public:
/// <summary>
///
/// Returns an unlocked and unhidden protection object.
/// </summary>
static protection unlocked_and_visible();
/// <summary>
///
/// Returns a locked and unhidden protection object.
/// </summary>
static protection locked_and_visible();
/// <summary>
///
/// Returns an unlocked and hidden protection object.
/// </summary>
static protection unlocked_and_hidden();
/// <summary>
///
/// Returns a locked and hidden protection object.
/// </summary>
static protection locked_and_hidden();
/// <summary>
///
/// Constructs a default unlocked unhidden protection object.
/// </summary>
protection();
/// <summary>
///
/// Returns true if cells using this protection should be locked.
/// </summary>
bool locked() const;
/// <summary>
///
/// Sets the locked state of the protection to locked and returns a reference to the protection.
/// </summary>
protection &locked(bool locked);
/// <summary>
///
/// Returns true if cells using this protection should be hidden.
/// </summary>
bool hidden() const;
/// <summary>
///
/// Sets the hidden state of the protection to hidden and returns a reference to the protection.
/// </summary>
protection &hidden(bool hidden);
/// <summary>
/// Returns true if left is exactly equal to right.
/// Returns true if this protections is equivalent to right.
/// </summary>
XLNT_API friend bool operator==(const protection &left, const protection &right);
bool operator==(const protection &other) const;
/// <summary>
/// Returns true if left is not exactly equal to right.
/// Returns true if this protection is not equivalent to right.
/// </summary>
XLNT_API friend bool operator!=(const protection &left, const protection &right)
{
return !(left == right);
}
bool operator!=(const protection &other) const;
private:
/// <summary>
///
/// Whether the cell using this protection is locked or not
/// </summary>
bool locked_;
/// <summary>
///
/// Whether the cell using this protection is hidden or not
/// </summary>
bool hidden_;
};

View File

@ -112,91 +112,101 @@ public:
/// </summary>
class alignment alignment() const;
/// <summary>
/// Returns true if the alignment of this style should be applied to cells
/// using it.
/// </summary>
bool alignment_applied() const;
/// <summary>
/// Returns true if the alignment of this style should be applied to cells
/// using it.
/// </summary>
bool alignment_applied() const;
/// <summary>
/// Sets the alignment of this style to new_alignment. Applied, which defaults
/// to true, determines whether the alignment should be enabled for cells using
/// this style.
/// to true, determines whether the alignment should be enabled for cells using
/// this style.
/// </summary>
style alignment(const xlnt::alignment &new_alignment, bool applied = true);
/// <summary>
///
/// Returns the border of this style.
/// </summary>
class border border() const;
/// <summary>
///
/// </summary>
bool border_applied() const;
/// <summary>
/// Returns true if the border set for this style should be applied to cells using the style.
/// </summary>
bool border_applied() const;
/// <summary>
///
/// Sets the border of this style to new_border. Applied, which defaults
/// to true, determines whether the border should be enabled for cells using
/// this style.
/// </summary>
style border(const xlnt::border &new_border, bool applied = true);
/// <summary>
///
/// Returns the fill of this style.
/// </summary>
class fill fill() const;
/// <summary>
///
/// </summary>
bool fill_applied() const;
/// <summary>
/// Returns true if the fill set for this style should be applied to cells using the style.
/// </summary>
bool fill_applied() const;
/// <summary>
///
/// Sets the fill of this style to new_fill. Applied, which defaults
/// to true, determines whether the border should be enabled for cells using
/// this style.
/// </summary>
style fill(const xlnt::fill &new_fill, bool applied = true);
/// <summary>
///
/// Returns the font of this style.
/// </summary>
class font font() const;
/// <summary>
///
/// </summary>
bool font_applied() const;
/// <summary>
/// Returns true if the font set for this style should be applied to cells using the style.
/// </summary>
bool font_applied() const;
/// <summary>
///
/// Sets the font of this style to new_font. Applied, which defaults
/// to true, determines whether the font should be enabled for cells using
/// this style.
/// </summary>
style font(const xlnt::font &new_font, bool applied = true);
/// <summary>
///
/// Returns the number_format of this style.
/// </summary>
class number_format number_format() const;
/// <summary>
///
/// </summary>
bool number_format_applied() const;
/// <summary>
/// Returns true if the number_format set for this style should be applied to cells using the style.
/// </summary>
bool number_format_applied() const;
/// <summary>
///
/// Sets the number format of this style to new_number_format. Applied, which defaults
/// to true, determines whether the number format should be enabled for cells using
/// this style.
/// </summary>
style number_format(const xlnt::number_format &new_number_format, bool applied = true);
/// <summary>
///
/// Returns the protection of this style.
/// </summary>
class protection protection() const;
/// <summary>
///
/// </summary>
bool protection_applied() const;
/// <summary>
/// Returns true if the protection set for this style should be applied to cells using the style.
/// </summary>
bool protection_applied() const;
/// <summary>
///
/// Sets the border of this style to new_protection. Applied, which defaults
/// to true, determines whether the protection should be enabled for cells using
/// this style.
/// </summary>
style protection(const xlnt::protection &new_protection, bool applied = true);
@ -238,12 +248,12 @@ private:
friend class detail::xlsx_consumer;
/// <summary>
///
/// Constructs a style from an impl pointer.
/// </summary>
style(detail::style_impl *d);
/// <summary>
///
/// The internal implementation of this style
/// </summary>
detail::style_impl *d_;
};

View File

@ -49,7 +49,7 @@ struct XLNT_API date
static date from_number(int days_since_base_year, calendar base_date);
/// <summary>
///
/// Constructs a data from a given year, month, and day.
/// </summary>
date(int year_, int month_, int day_);
@ -59,7 +59,8 @@ struct XLNT_API date
int to_number(calendar base_date) const;
/// <summary>
///
/// Calculates and returns the day of the week that this date represents in the range
/// 0 to 6 where 0 represents Sunday.
/// </summary>
int weekday() const;
@ -69,17 +70,17 @@ struct XLNT_API date
bool operator==(const date &comparand) const;
/// <summary>
///
/// The year
/// </summary>
int year;
/// <summary>
///
/// The month
/// </summary>
int month;
/// <summary>
///
/// The day
/// </summary>
int day;
};

View File

@ -39,95 +39,96 @@ struct time;
struct XLNT_API datetime
{
/// <summary>
/// Return the current date and time according to the system time.
/// Returns the current date and time according to the system time.
/// </summary>
static datetime now();
/// <summary>
/// Return the current date and time according to the system time.
/// Returns the current date and time according to the system time.
/// This is equivalent to datetime::now().
/// </summary>
static datetime today();
/// <summary>
/// Return a datetime from number by converting the integer part into
/// Returns a datetime from number by converting the integer part into
/// a date and the fractional part into a time according to date::from_number
/// and time::from_number.
/// </summary>
static datetime from_number(long double number, calendar base_date);
/// <summary>
///
/// Returns a datetime equivalent to the ISO-formatted string iso_string.
/// </summary>
static datetime from_iso_string(const std::string &iso_string);
/// <summary>
///
/// Constructs a datetime from a date and a time.
/// </summary>
datetime(const date &d, const time &t);
/// <summary>
///
/// Constructs a datetime from a year, month, and day plus optional hour, minute, second, and microsecond.
/// </summary>
datetime(int year_, int month_, int day_, int hour_ = 0, int minute_ = 0, int second_ = 0, int microsecond_ = 0);
/// <summary>
///
/// Returns a string represenation of this date and time.
/// </summary>
std::string to_string() const;
/// <summary>
///
/// Returns an ISO-formatted string representation of this date and time.
/// </summary>
std::string to_iso_string() const;
/// <summary>
///
/// Returns this datetime as a number of seconds since 1900 or 1904 (depending on base_date provided).
/// </summary>
long double to_number(calendar base_date) const;
/// <summary>
///
/// Returns true if this datetime is equivalent to comparand.
/// </summary>
bool operator==(const datetime &comparand) const;
/// <summary>
///
/// Calculates and returns the day of the week that this date represents in the range
/// 0 to 6 where 0 represents Sunday.
/// </summary>
int weekday() const;
/// <summary>
///
/// The year
/// </summary>
int year;
/// <summary>
///
/// The month
/// </summary>
int month;
/// <summary>
///
/// The day
/// </summary>
int day;
/// <summary>
///
/// The hour
/// </summary>
int hour;
/// <summary>
///
/// The minute
/// </summary>
int minute;
/// <summary>
///
/// The second
/// </summary>
int second;
/// <summary>
///
/// The microsecond
/// </summary>
int microsecond;
};

View File

@ -39,28 +39,30 @@ class XLNT_API exception : public std::runtime_error
{
public:
/// <summary>
///
/// Constructs an exception with a message. This message will be
/// returned by std::exception::what(), an inherited member of this class.
/// </summary>
exception(const std::string &message);
/// <summary>
///
/// Default copy constructor.
/// </summary>
exception(const exception &) = default;
/// <summary>
///
/// Destructor
/// </summary>
virtual ~exception();
/// <summary>
///
/// Sets the message after the xlnt::exception is constructed. This can show
/// more specific information than std::exception::what().
/// </summary>
void message(const std::string &message);
private:
/// <summary>
///
/// The exception message
/// </summary>
std::string message_;
};
@ -72,17 +74,17 @@ class XLNT_API invalid_parameter : public exception
{
public:
/// <summary>
///
/// Default constructor.
/// </summary>
invalid_parameter();
/// <summary>
///
/// Default copy constructor.
/// </summary>
invalid_parameter(const invalid_parameter &) = default;
/// <summary>
///
/// Destructor
/// </summary>
virtual ~invalid_parameter();
};
@ -94,17 +96,17 @@ class XLNT_API invalid_sheet_title : public exception
{
public:
/// <summary>
///
/// Default constructor.
/// </summary>
invalid_sheet_title(const std::string &title);
/// <summary>
///
/// Default copy constructor.
/// </summary>
invalid_sheet_title(const invalid_sheet_title &) = default;
/// <summary>
///
/// Destructor
/// </summary>
virtual ~invalid_sheet_title();
};
@ -116,12 +118,17 @@ class XLNT_API missing_number_format : public exception
{
public:
/// <summary>
///
/// Default constructor.
/// </summary>
missing_number_format();
/// <summary>
///
/// Default copy constructor.
/// </summary>
missing_number_format(const missing_number_format &) = default;
/// <summary>
/// Destructor
/// </summary>
virtual ~missing_number_format();
};
@ -133,17 +140,18 @@ class XLNT_API invalid_file : public exception
{
public:
/// <summary>
///
/// Constructs an invalid_file exception thrown when attempt to access
/// the given filename.
/// </summary>
invalid_file(const std::string &filename);
/// <summary>
///
/// Default copy constructor.
/// </summary>
invalid_file(const invalid_file &) = default;
/// <summary>
///
/// Destructor
/// </summary>
virtual ~invalid_file();
};
@ -156,17 +164,17 @@ class XLNT_API illegal_character : public exception
{
public:
/// <summary>
///
/// Constructs an illegal_character exception thrown as a result of the given character.
/// </summary>
illegal_character(char c);
/// <summary>
///
/// Default copy constructor.
/// </summary>
illegal_character(const illegal_character &) = default;
/// <summary>
///
/// Destructor
/// </summary>
virtual ~illegal_character();
};
@ -178,41 +186,41 @@ class XLNT_API invalid_data_type : public exception
{
public:
/// <summary>
///
/// Default constructor.
/// </summary>
invalid_data_type();
/// <summary>
///
/// Default copy constructor.
/// </summary>
invalid_data_type(const invalid_data_type &) = default;
/// <summary>
///
/// Destructor
/// </summary>
virtual ~invalid_data_type();
};
/// <summary>
/// Exception for bad column names in A1-style cell references.
/// Exception for bad column indices in A1-style cell references.
/// </summary>
class XLNT_API invalid_column_string_index : public exception
class XLNT_API invalid_column_index : public exception
{
public:
/// <summary>
///
/// Default constructor.
/// </summary>
invalid_column_string_index();
invalid_column_index();
/// <summary>
///
/// Default copy constructor.
/// </summary>
invalid_column_string_index(const invalid_column_string_index &) = default;
invalid_column_index(const invalid_column_index &) = default;
/// <summary>
///
/// Destructor
/// </summary>
virtual ~invalid_column_string_index();
virtual ~invalid_column_index();
};
/// <summary>
@ -222,22 +230,22 @@ class XLNT_API invalid_cell_reference : public exception
{
public:
/// <summary>
///
/// Constructs an invalid_cell_reference exception for the given column and row.
/// </summary>
invalid_cell_reference(column_t column, row_t row);
/// <summary>
///
/// Constructs an invalid_cell_reference exception for the given string.
/// </summary>
invalid_cell_reference(const std::string &reference_string);
/// <summary>
///
/// Default copy constructor.
/// </summary>
invalid_cell_reference(const invalid_cell_reference &) = default;
/// <summary>
///
/// Destructor
/// </summary>
virtual ~invalid_cell_reference();
};
@ -249,17 +257,17 @@ class XLNT_API invalid_attribute : public exception
{
public:
/// <summary>
///
/// Default constructor.
/// </summary>
invalid_attribute();
/// <summary>
///
/// Default copy constructor.
/// </summary>
invalid_attribute(const invalid_attribute &) = default;
/// <summary>
///
/// Destructor
/// </summary>
virtual ~invalid_attribute();
};
@ -271,17 +279,17 @@ class XLNT_API key_not_found : public exception
{
public:
/// <summary>
///
/// Default constructor.
/// </summary>
key_not_found();
/// <summary>
///
/// Default copy constructor.
/// </summary>
key_not_found(const key_not_found &) = default;
/// <summary>
///
/// Destructor
/// </summary>
virtual ~key_not_found();
};
@ -293,17 +301,17 @@ class XLNT_API no_visible_worksheets : public exception
{
public:
/// <summary>
///
/// Default constructor.
/// </summary>
no_visible_worksheets();
/// <summary>
///
/// Default copy constructor.
/// </summary>
no_visible_worksheets(const no_visible_worksheets &) = default;
/// <summary>
///
/// Destructor
/// </summary>
virtual ~no_visible_worksheets();
};
@ -315,17 +323,17 @@ class XLNT_API unhandled_switch_case : public exception
{
public:
/// <summary>
///
/// Default constructor.
/// </summary>
unhandled_switch_case();
/// <summary>
///
/// Default copy constructor.
/// </summary>
unhandled_switch_case(const unhandled_switch_case &) = default;
/// <summary>
///
/// Destructor
/// </summary>
virtual ~unhandled_switch_case();
};
@ -337,17 +345,18 @@ class XLNT_API unsupported : public exception
{
public:
/// <summary>
///
/// Constructs an unsupported exception with a message describing the unsupported
/// feature.
/// </summary>
unsupported(const std::string &message);
/// <summary>
///
/// Default copy constructor.
/// </summary>
unsupported(const unsupported &) = default;
/// <summary>
///
/// Destructor
/// </summary>
virtual ~unsupported();
};

View File

@ -166,7 +166,7 @@ public:
/// <summary>
/// Returns true if left path is equal to right path.
/// </summary>
friend XLNT_API bool operator==(const path &left, const path &right);
bool operator==(const path &other) const;
private:
/// <summary>
@ -196,7 +196,7 @@ template <>
struct hash<xlnt::path>
{
/// <summary>
///
/// Returns a hashed represenation of the given path.
/// </summary>
size_t operator()(const xlnt::path &p) const
{

View File

@ -49,42 +49,43 @@ struct XLNT_API time
static time from_number(long double number);
/// <summary>
///
/// Constructs a time object from an optional hour, minute, second, and microsecond.
/// </summary>
explicit time(int hour_ = 0, int minute_ = 0, int second_ = 0, int microsecond_ = 0);
/// <summary>
///
/// Constructs a time object from a string representing the time.
/// </summary>
explicit time(const std::string &time_string);
/// <summary>
///
/// Returns a numeric representation of the time in the range 0-1 where the value
/// is equal to the fraction of the day elapsed.
/// </summary>
long double to_number() const;
/// <summary>
///
/// Returns true if this time is equivalent to comparand.
/// </summary>
bool operator==(const time &comparand) const;
/// <summary>
///
/// The hour
/// </summary>
int hour;
/// <summary>
///
/// The minute
/// </summary>
int minute;
/// <summary>
///
/// The second
/// </summary>
int second;
/// <summary>
///
/// The microsecond
/// </summary>
int microsecond;
};

View File

@ -31,52 +31,52 @@ namespace xlnt {
/// <summary>
/// Represents a span of time between two datetimes. This is
/// not fully supported yet.
/// not fully supported yet throughout the library.
/// </summary>
struct XLNT_API timedelta
{
/// <summary>
///
/// Returns a timedelta from a number representing the factional number of days elapsed.
/// </summary>
static timedelta from_number(long double number);
/// <summary>
///
/// Constructs a timedelta equal to zero.
/// </summary>
timedelta();
/// <summary>
///
/// Constructs a timedelta from a number of days, hours, minutes, seconds, and microseconds.
/// </summary>
timedelta(int days_, int hours_, int minutes_, int seconds_, int microseconds_);
/// <summary>
///
/// Returns a numeric representation of this timedelta as a fractional number of days.
/// </summary>
long double to_number() const;
/// <summary>
///
/// The days
/// </summary>
int days;
/// <summary>
///
/// The hours
/// </summary>
int hours;
/// <summary>
///
/// The minutes
/// </summary>
int minutes;
/// <summary>
///
/// The seconds
/// </summary>
int seconds;
/// <summary>
///
/// The microseconds
/// </summary>
int microseconds;
};

View File

@ -43,22 +43,23 @@ public:
struct lock_verifier
{
/// <summary>
///
/// The algorithm used to create and verify this lock.
/// </summary>
std::string hash_algorithm;
/// <summary>
///
/// The initial salt combined with the password used to prevent rainbow table attacks
/// </summary>
std::string salt;
/// <summary>
///
/// The actual hash value represented as a string
/// </summary>
std::string hash;
/// <summary>
///
/// The number of times the hash should be applied to the password combined with the salt.
/// This allows the difficulty of the hash to be increased as computing power increases.
/// </summary>
std::size_t spin_count;
};

View File

@ -83,158 +83,160 @@ struct XLNT_API page_setup
{
public:
/// <summary>
///
/// Default constructor.
/// </summary>
page_setup();
/// <summary>
///
/// Returns the page break.
/// </summary>
xlnt::page_break page_break() const;
/// <summary>
///
/// Sets the page break to b.
/// </summary>
void page_break(xlnt::page_break b);
/// <summary>
///
/// Returns the current sheet state of this page setup.
/// </summary>
xlnt::sheet_state sheet_state() const;
/// <summary>
///
/// Sets the sheet state to sheet_state.
/// </summary>
void sheet_state(xlnt::sheet_state sheet_state);
/// <summary>
///
/// Returns the paper size which should be used to print the worksheet using this page setup.
/// </summary>
xlnt::paper_size paper_size() const;
/// <summary>
///
/// Sets the paper size of this page setup.
/// </summary>
void paper_size(xlnt::paper_size paper_size);
/// <summary>
///
/// Returns the orientation of the worksheet using this page setup.
/// </summary>
xlnt::orientation orientation() const;
/// <summary>
///
/// Sets the orientation of the page.
/// </summary>
void orientation(xlnt::orientation orientation);
/// <summary>
///
/// Returns true if this worksheet should be scaled to fit on a single page during printing.
/// </summary>
bool fit_to_page() const;
/// <summary>
///
/// If true, forces the worksheet to be scaled to fit on a single page during printing.
/// </summary>
void fit_to_page(bool fit_to_page);
/// <summary>
///
/// Returns true if the height of this worksheet should be scaled to fit on a printed page.
/// </summary>
bool fit_to_height() const;
/// <summary>
///
/// Sets whether the height of the page should be scaled to fit on a printed page.
/// </summary>
void fit_to_height(bool fit_to_height);
/// <summary>
///
/// Returns true if the width of this worksheet should be scaled to fit on a printed page.
/// </summary>
bool fit_to_width() const;
/// <summary>
///
/// Sets whether the width of the page should be scaled to fit on a printed page.
/// </summary>
void fit_to_width(bool fit_to_width);
/// <summary>
///
/// Sets whether the worksheet should be centered horizontall on the page if it takes
/// up less than a full page.
/// </summary>
void horizontal_centered(bool horizontal_centered);
/// <summary>
///
/// Returns whether horizontal centering has been enabled.
/// </summary>
bool horizontal_centered() const;
/// <summary>
///
/// Sets whether the worksheet should be vertically centered on the page if it takes
/// up less than a full page.
/// </summary>
void vertical_centered(bool vertical_centered);
/// <summary>
///
/// Returns whether vertical centering has been enabled.
/// </summary>
bool vertical_centered() const;
/// <summary>
///
/// Sets the factor by which the page should be scaled during printing.
/// </summary>
void scale(double scale);
/// <summary>
///
/// Returns the factor by which the page should be scaled during printing.
/// </summary>
double scale() const;
private:
/// <summary>
///
/// The break
/// </summary>
xlnt::page_break break_;
/// <summary>
///
/// The sheet state
/// </summary>
xlnt::sheet_state sheet_state_;
/// <summary>
///
/// The paper size
/// </summary>
xlnt::paper_size paper_size_;
/// <summary>
///
/// The orientation
/// </summary>
xlnt::orientation orientation_;
/// <summary>
///
/// Whether or not to fit to page
/// </summary>
bool fit_to_page_;
/// <summary>
///
/// Whether or not to fit to height
/// </summary>
bool fit_to_height_;
/// <summary>
///
/// Whether or not to fit to width
/// </summary>
bool fit_to_width_;
/// <summary>
///
/// Whether or not to center the content horizontally
/// </summary>
bool horizontal_centered_;
/// <summary>
///
/// Whether or not to center the conent vertically
/// </summary>
bool vertical_centered_;
/// <summary>
///
/// The amount to scale the worksheet
/// </summary>
double scale_;
};

View File

@ -31,7 +31,7 @@
namespace xlnt {
/// <summary>
///
/// Enumeration of possible states of a pane
/// </summary>
enum class XLNT_API pane_state
{
@ -41,7 +41,7 @@ enum class XLNT_API pane_state
};
/// <summary>
///
/// Enumeration of the four quadrants of a worksheet
/// </summary>
enum class XLNT_API pane_corner
{
@ -57,27 +57,27 @@ enum class XLNT_API pane_corner
struct XLNT_API pane
{
/// <summary>
///
/// The optional top left cell
/// </summary>
optional<cell_reference> top_left_cell;
/// <summary>
///
/// The state of the pane
/// </summary>
pane_state state = pane_state::split;
/// <summary>
///
/// The pane which contains the active cell
/// </summary>
pane_corner active_pane = pane_corner::top_left;
/// <summary>
///
/// The row where the split should take place
/// </summary>
row_t y_split = 1;
/// <summary>
///
/// The column where the split should take place
/// </summary>
column_t x_split = 1;

View File

@ -48,122 +48,106 @@ class XLNT_API range
{
public:
/// <summary>
///
/// Alias for the iterator type
/// </summary>
using iterator = range_iterator;
/// <summary>
///
/// Alias for the const iterator type
/// </summary>
using const_iterator = const_range_iterator;
/// <summary>
///
/// Alias for the reverse iterator type
/// </summary>
using reverse_iterator = std::reverse_iterator<iterator>;
/// <summary>
///
/// Alias for the const reverse iterator type
/// </summary>
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
/// <summary>
///
/// Constructs a range on the given worksheet.
/// </summary>
range(worksheet ws, const range_reference &reference, major_order order = major_order::row, bool skip_null = false);
range(worksheet ws, const range_reference &reference,
major_order order = major_order::row, bool skip_null = false);
/// <summary>
///
/// Desctructor
/// </summary>
~range();
/// <summary>
///
/// Default copy constructor.
/// </summary>
range(const range &) = default;
/// <summary>
///
/// Returns a vector pointing to the n-th row or column in this range (depending
/// on major order).
/// </summary>
cell_vector operator[](std::size_t vector_index);
cell_vector vector(std::size_t n);
/// <summary>
///
/// Returns a vector pointing to the n-th row or column in this range (depending
/// on major order).
/// </summary>
const cell_vector operator[](std::size_t vector_index) const;
const cell_vector vector(std::size_t n) const;
/// <summary>
///
/// </summary>
bool operator==(const range &comparand) const;
/// <summary>
///
/// </summary>
bool operator!=(const range &comparand) const;
/// <summary>
///
/// </summary>
cell_vector vector(std::size_t vector_index);
/// <summary>
///
/// </summary>
const cell_vector vector(std::size_t vector_index) const;
/// <summary>
///
/// Returns a cell in the range relative to its top left cell.
/// </summary>
class cell cell(const cell_reference &ref);
/// <summary>
///
/// Returns a cell in the range relative to its top left cell.
/// </summary>
const class cell cell(const cell_reference &ref) const;
/// <summary>
///
/// Returns the reference defining the bounds of this range.
/// </summary>
range_reference reference() const;
/// <summary>
///
/// Returns the number of rows or columns in this range (depending on major order).
/// </summary>
std::size_t length() const;
/// <summary>
///
/// Returns true if the given cell exists in the parent worksheet of this range.
/// </summary>
bool contains(const cell_reference &ref);
/// <summary>
///
/// Sets the alignment of all cells in the range to new_alignment and returns the range.
/// </summary>
range alignment(const xlnt::alignment &new_alignment);
/// <summary>
///
/// Sets the border of all cells in the range to new_border and returns the range.
/// </summary>
range border(const xlnt::border &new_border);
/// <summary>
///
/// Sets the fill of all cells in the range to new_fill and returns the range.
/// </summary>
range fill(const xlnt::fill &new_fill);
/// <summary>
///
/// Sets the font of all cells in the range to new_font and returns the range.
/// </summary>
range font(const xlnt::font &new_font);
/// <summary>
///
/// Sets the number format of all cells in the range to new_number_format and
/// returns the range.
/// </summary>
range number_format(const xlnt::number_format &new_number_format);
/// <summary>
///
/// Sets the protection of all cells in the range to new_protection and returns the range.
/// </summary>
range protection(const xlnt::protection &new_protection);
@ -180,108 +164,128 @@ public:
range style(const std::string &style_name);
/// <summary>
///
/// Returns the first row or column in this range.
/// </summary>
cell_vector front();
/// <summary>
///
/// Returns the first row or column in this range.
/// </summary>
const cell_vector front() const;
/// <summary>
///
/// Returns the last row or column in this range.
/// </summary>
cell_vector back();
/// <summary>
///
/// Returns the last row or column in this range.
/// </summary>
const cell_vector back() const;
/// <summary>
///
/// Returns an iterator to the first row or column in this range.
/// </summary>
iterator begin();
/// <summary>
///
/// Returns an iterator to one past the last row or column in this range.
/// </summary>
iterator end();
/// <summary>
///
/// Returns an iterator to the first row or column in this range.
/// </summary>
const_iterator begin() const;
/// <summary>
///
/// Returns an iterator to one past the last row or column in this range.
/// </summary>
const_iterator end() const;
/// <summary>
///
/// Returns an iterator to the first row or column in this range.
/// </summary>
const_iterator cbegin() const;
/// <summary>
///
/// Returns an iterator to one past the last row or column in this range.
/// </summary>
const_iterator cend() const;
/// <summary>
///
/// Returns a reverse iterator to the first row or column in this range.
/// </summary>
reverse_iterator rbegin();
/// <summary>
///
/// Returns a reverse iterator to one past the last row or column in this range.
/// </summary>
reverse_iterator rend();
/// <summary>
///
/// Returns a reverse iterator to the first row or column in this range.
/// </summary>
const_reverse_iterator rbegin() const;
/// <summary>
///
/// Returns a reverse iterator to one past the last row or column in this range.
/// </summary>
const_reverse_iterator rend() const;
/// <summary>
///
/// Returns a reverse iterator to the first row or column in this range.
/// </summary>
const_reverse_iterator crbegin() const;
/// <summary>
///
/// Returns a reverse iterator to one past the last row or column in this range.
/// </summary>
const_reverse_iterator crend() const;
/// <summary>
///
/// Applies function f to all cells in the range
/// </summary>
void apply(std::function<void(class cell)> f);
/// <summary>
/// Returns the n-th row or column in this range.
/// </summary>
cell_vector operator[](std::size_t n);
/// <summary>
/// Returns the n-th row or column in this range.
/// </summary>
const cell_vector operator[](std::size_t n) const;
/// <summary>
/// Returns true if this range is equivalent to comparand.
/// </summary>
bool operator==(const range &comparand) const;
/// <summary>
/// Returns true if this range is not equivalent to comparand.
/// </summary>
bool operator!=(const range &comparand) const;
private:
/// <summary>
///
/// The worksheet this range is within
/// </summary>
worksheet ws_;
/// <summary>
///
/// The reference of this range
/// </summary>
range_reference ref_;
/// <summary>
///
/// Whether this range should be iterated by columns or rows first
/// </summary>
major_order order_;
/// <summary>
///
/// Whether null rows/columns and cells should be skipped during iteration
/// </summary>
bool skip_null_;
};

View File

@ -49,74 +49,75 @@ class XLNT_API range_iterator : public r_iter_type
{
public:
/// <summary>
///
/// Constructs a range iterator on a worksheet, cell pointing to the current
/// row or column, range bounds, an order, and whether or not to skip null column/rows.
/// </summary>
range_iterator(worksheet &ws, const cell_reference &cursor,
const range_reference &bounds, major_order order, bool skip_null);
/// <summary>
///
/// Copy constructor.
/// </summary>
range_iterator(const range_iterator &other);
/// <summary>
///
/// Dereference the iterator to return a column or row.
/// </summary>
cell_vector operator*() const;
/// <summary>
///
/// Default assignment operator.
/// </summary>
range_iterator &operator=(const range_iterator &) = default;
/// <summary>
///
/// Returns true if this iterator is equivalent to other.
/// </summary>
bool operator==(const range_iterator &other) const;
/// <summary>
///
/// Returns true if this iterator is not equivalent to other.
/// </summary>
bool operator!=(const range_iterator &other) const;
/// <summary>
///
/// Pre-decrement the iterator to point to the previous row/column.
/// </summary>
range_iterator &operator--();
/// <summary>
///
/// Post-decrement the iterator to point to the previous row/column.
/// </summary>
range_iterator operator--(int);
/// <summary>
///
/// Pre-increment the iterator to point to the next row/column.
/// </summary>
range_iterator &operator++();
/// <summary>
///
/// Post-increment the iterator to point to the next row/column.
/// </summary>
range_iterator operator++(int);
private:
/// <summary>
///
/// The worksheet
/// </summary>
worksheet ws_;
/// <summary>
///
/// The first cell in the current row/column
/// </summary>
cell_reference cursor_;
/// <summary>
///
/// The bounds of the range
/// </summary>
range_reference bounds_;
/// <summary>
///
/// Whether rows or columns should be iterated over first
/// </summary>
major_order order_;
@ -140,74 +141,75 @@ class XLNT_API const_range_iterator : public cr_iter_type
{
public:
/// <summary>
///
/// Constructs a range iterator on a worksheet, cell pointing to the current
/// row or column, range bounds, an order, and whether or not to skip null column/rows.
/// </summary>
const_range_iterator(const worksheet &ws, const cell_reference &cursor,
const range_reference &bounds, major_order order, bool skip_null);
/// <summary>
///
/// Copy constructor.
/// </summary>
const_range_iterator(const const_range_iterator &other);
/// <summary>
///
/// Dereferennce the iterator to return the current column/row.
/// </summary>
const cell_vector operator*() const;
/// <summary>
///
/// Default assignment operator.
/// </summary>
const_range_iterator &operator=(const const_range_iterator &) = default;
/// <summary>
///
/// Returns true if this iterator is equivalent to other.
/// </summary>
bool operator==(const const_range_iterator &other) const;
/// <summary>
///
/// Returns true if this iterator is not equivalent to other.
/// </summary>
bool operator!=(const const_range_iterator &other) const;
/// <summary>
///
/// Pre-decrement the iterator to point to the next row/column.
/// </summary>
const_range_iterator &operator--();
/// <summary>
///
/// Post-decrement the iterator to point to the next row/column.
/// </summary>
const_range_iterator operator--(int);
/// <summary>
///
/// Pre-increment the iterator to point to the next row/column.
/// </summary>
const_range_iterator &operator++();
/// <summary>
///
/// Post-increment the iterator to point to the next row/column.
/// </summary>
const_range_iterator operator++(int);
private:
/// <summary>
///
/// The implementation of the worksheet this iterator points to
/// </summary>
detail::worksheet_impl *ws_;
/// <summary>
///
/// The first cell in the current row or column this iterator points to
/// </summary>
cell_reference cursor_;
/// <summary>
///
/// The range this iterator starts and ends in
/// </summary>
range_reference bounds_;
/// <summary>
///
/// Determines whether iteration should move through rows or columns first
/// </summary>
major_order order_;

View File

@ -36,165 +36,155 @@ class XLNT_API range_reference
{
public:
/// <summary>
/// Convert a coordinate to an absolute coordinate string (B12 -> $B$12)
/// Converts relative reference coordinates to absolute coordinates (B12 -> $B$12)
/// </summary>
static range_reference make_absolute(const range_reference &relative_reference);
/// <summary>
///
/// Constructs a range reference equal to A1:A1
/// </summary>
range_reference();
/// <summary>
///
/// Constructs a range reference equivalent to the provided range_string in the form
/// <top_left>:<bottom_right>.
/// </summary>
explicit range_reference(const std::string &range_string);
/// <summary>
///
/// Constructs a range reference equivalent to the provided range_string in the form
/// <top_left>:<bottom_right>.
/// </summary>
explicit range_reference(const char *range_string);
/// <summary>
///
/// Constructs a range reference from a pair of cell references.
/// </summary>
explicit range_reference(const std::pair<cell_reference, cell_reference> &reference_pair);
/// <summary>
///
/// Constructs a range reference from cell references indicating top
/// left and bottom right coordinates of the range.
/// </summary>
range_reference(const cell_reference &start, const cell_reference &end);
/// <summary>
///
/// Constructs a range reference from column and row indices.
/// </summary>
range_reference(column_t column_index_start, row_t row_index_start, column_t column_index_end, row_t row_index_end);
range_reference(column_t column_index_start, row_t row_index_start,
column_t column_index_end, row_t row_index_end);
/// <summary>
///
/// Returns true if the range has a width and height of 1 cell.
/// </summary>
bool is_single_cell() const;
/// <summary>
///
/// Returns the number of columns encompassed by this range.
/// </summary>
std::size_t width() const;
/// <summary>
///
/// Returns the number of rows encompassed by this range.
/// </summary>
std::size_t height() const;
/// <summary>
///
/// </summary>
cell_reference top_left();
/// <summary>
///
/// Returns the coordinate of the top left cell of this range.
/// </summary>
cell_reference top_left() const;
/// <summary>
///
/// </summary>
cell_reference top_right();
/// <summary>
///
/// Returns the coordinate of the top right cell of this range.
/// </summary>
cell_reference top_right() const;
/// <summary>
///
/// </summary>
cell_reference bottom_left();
/// <summary>
///
/// Returns the coordinate of the bottom left cell of this range.
/// </summary>
cell_reference bottom_left() const;
/// <summary>
///
/// </summary>
cell_reference bottom_right();
/// <summary>
///
/// Returns the coordinate of the bottom right cell of this range.
/// </summary>
cell_reference bottom_right() const;
/// <summary>
///
/// Returns a new range reference with the same width and height as this
/// range but shifted by the given number of columns and rows.
/// </summary>
range_reference make_offset(int column_offset, int row_offset) const;
/// <summary>
///
/// Returns a string representation of this range.
/// </summary>
std::string to_string() const;
/// <summary>
///
/// Returns true if this range is equivalent to the other range.
/// </summary>
bool operator==(const range_reference &comparand) const;
/// <summary>
///
/// Returns true if this range is equivalent to the string representation
/// of the other range.
/// </summary>
bool operator==(const std::string &reference_string) const;
/// <summary>
///
/// Returns true if this range is equivalent to the string representation
/// of the other range.
/// </summary>
bool operator==(const char *reference_string) const;
/// <summary>
///
/// Returns true if this range is not equivalent to the other range.
/// </summary>
bool operator!=(const range_reference &comparand) const;
/// <summary>
///
/// Returns true if this range is not equivalent to the string representation
/// of the other range.
/// </summary>
bool operator!=(const std::string &reference_string) const;
/// <summary>
///
/// Returns true if this range is not equivalent to the string representation
/// of the other range.
/// </summary>
bool operator!=(const char *reference_string) const;
/// <summary>
///
/// </summary>
XLNT_API friend bool operator==(const std::string &reference_string, const range_reference &ref);
/// <summary>
///
/// </summary>
XLNT_API friend bool operator==(const char *reference_string, const range_reference &ref);
/// <summary>
///
/// </summary>
XLNT_API friend bool operator!=(const std::string &reference_string, const range_reference &ref);
/// <summary>
///
/// </summary>
XLNT_API friend bool operator!=(const char *reference_string, const range_reference &ref);
private:
/// <summary>
///
/// The top left cell in the range
/// </summary>
cell_reference top_left_;
/// <summary>
///
/// The bottom right cell in the range
/// </summary>
cell_reference bottom_right_;
};
/// <summary>
/// Returns true if the string representation of the range is equivalent to ref.
/// </summary>
XLNT_API bool operator==(const std::string &reference_string, const range_reference &ref);
/// <summary>
/// Returns true if the string representation of the range is equivalent to ref.
/// </summary>
XLNT_API bool operator==(const char *reference_string, const range_reference &ref);
/// <summary>
/// Returns true if the string representation of the range is not equivalent to ref.
/// </summary>
XLNT_API bool operator!=(const std::string &reference_string, const range_reference &ref);
/// <summary>
/// Returns true if the string representation of the range is not equivalent to ref.
/// </summary>
XLNT_API bool operator!=(const char *reference_string, const range_reference &ref);
} // namespace xlnt

View File

@ -35,22 +35,22 @@ class XLNT_API row_properties
{
public:
/// <summary>
///
/// Optional height
/// </summary>
optional<double> height;
/// <summary>
///
/// Whether or not the height is different from the default
/// </summary>
bool custom_height = false;
/// <summary>
///
/// Whether or not the row should be hidden
/// </summary>
bool hidden = false;
/// <summary>
///
/// The index to the style used by all cells in this row
/// </summary>
optional<std::size_t> style;
};

View File

@ -37,7 +37,7 @@ class XLNT_API selection
{
public:
/// <summary>
///
/// Returns true if this selection has a defined active cell.
/// </summary>
bool has_active_cell() const
{
@ -45,7 +45,7 @@ public:
}
/// <summary>
///
/// Returns the cell reference of the active cell.
/// </summary>
cell_reference active_cell() const
{
@ -53,7 +53,7 @@ public:
}
/// <summary>
///
/// Sets the active cell to that pointed to by ref.
/// </summary>
void active_cell(const cell_reference &ref)
{
@ -61,7 +61,7 @@ public:
}
/// <summary>
///
/// Returns the range encompassed by this selection.
/// </summary>
range_reference sqref() const
{
@ -69,7 +69,7 @@ public:
}
/// <summary>
///
/// Returns the sheet quadrant of this selection.
/// </summary>
pane_corner pane() const
{
@ -77,7 +77,7 @@ public:
}
/// <summary>
///
/// Sets the sheet quadrant of this selection to corner.
/// </summary>
void pane(pane_corner corner)
{
@ -91,22 +91,23 @@ public:
bool operator==(const selection &rhs) const
{
return active_cell_ == rhs.active_cell_
&& sqref_ == rhs.sqref_ && pane_ == rhs.pane_;
&& sqref_ == rhs.sqref_
&& pane_ == rhs.pane_;
}
private:
/// <summary>
///
/// The active cell
/// </summary>
optional<cell_reference> active_cell_;
/// <summary>
///
/// The range
/// </summary>
range_reference sqref_;
/// <summary>
///
/// The quadrant
/// </summary>
pane_corner pane_;
};

View File

@ -30,6 +30,8 @@
namespace xlnt {
// TOOD: does this really need its own class?
/// <summary>
/// Protection applied to a particular worksheet to prevent it from being modified.
/// </summary>
@ -37,23 +39,23 @@ class XLNT_API sheet_protection
{
public:
/// <summary>
///
/// Calculates and returns the hash of the given protection password.
/// </summary>
static std::string hash_password(const std::string &password);
/// <summary>
///
/// Sets the protection password to password.
/// </summary>
void password(const std::string &password);
/// <summary>
///
/// Returns the hash of the password set for this sheet protection.
/// </summary>
std::string hashed_password() const;
private:
/// <summary>
///
/// The hash of the password.
/// </summary>
std::string hashed_password_;
};

View File

@ -32,7 +32,7 @@
namespace xlnt {
/// <summary>
///
/// Enumeration of possible types of sheet views
/// </summary>
enum class sheet_view_type
{
@ -49,7 +49,7 @@ class XLNT_API sheet_view
{
public:
/// <summary>
///
/// Sets the ID of this view to new_id.
/// </summary>
void id(std::size_t new_id)
{
@ -57,7 +57,7 @@ public:
}
/// <summary>
///
/// Returns the ID of this view.
/// </summary>
std::size_t id() const
{
@ -65,7 +65,7 @@ public:
}
/// <summary>
///
/// Returns true if this view has a pane defined.
/// </summary>
bool has_pane() const
{
@ -73,7 +73,7 @@ public:
}
/// <summary>
///
/// Returns a reference to this view's pane.
/// </summary>
struct pane &pane()
{
@ -81,7 +81,7 @@ public:
}
/// <summary>
///
/// Returns a reference to this view's pane.
/// </summary>
const struct pane &pane() const
{
@ -89,7 +89,7 @@ public:
}
/// <summary>
///
/// Removes the defined pane from this view.
/// </summary>
void clear_pane()
{
@ -97,7 +97,7 @@ public:
}
/// <summary>
///
/// Sets the pane of this view to new_pane.
/// </summary>
void pane(const struct pane &new_pane)
{
@ -105,7 +105,7 @@ public:
}
/// <summary>
///
/// Returns true if this view has any selections.
/// </summary>
bool has_selections() const
{
@ -113,7 +113,7 @@ public:
}
/// <summary>
///
/// Adds the given selection to the collection of selections.
/// </summary>
void add_selection(const class selection &new_selection)
{
@ -121,7 +121,7 @@ public:
}
/// <summary>
///
/// Removes all selections.
/// </summary>
void clear_selections()
{
@ -129,7 +129,7 @@ public:
}
/// <summary>
///
/// Returns the collection of selections as a vector.
/// </summary>
std::vector<xlnt::selection> selections() const
{
@ -137,7 +137,7 @@ public:
}
/// <summary>
///
/// Returns the selection at the given index.
/// </summary>
class xlnt::selection &selection(std::size_t index)
{
@ -145,7 +145,7 @@ public:
}
/// <summary>
///
/// If show is true, grid lines will be shown for sheets using this view.
/// </summary>
void show_grid_lines(bool show)
{
@ -153,7 +153,7 @@ public:
}
/// <summary>
///
/// Returns true if grid lines will be shown for sheets using this view.
/// </summary>
bool show_grid_lines() const
{
@ -161,7 +161,7 @@ public:
}
/// <summary>
///
/// If is_default is true, the default grid color will be used.
/// </summary>
void default_grid_color(bool is_default)
{
@ -169,7 +169,7 @@ public:
}
/// <summary>
///
/// Returns true if the default grid color will be used.
/// </summary>
bool default_grid_color() const
{
@ -205,32 +205,32 @@ public:
private:
/// <summary>
///
/// The id
/// </summary>
std::size_t id_ = 0;
/// <summary>
///
/// Whether or not to show grid lines
/// </summary>
bool show_grid_lines_ = true;
/// <summary>
///
/// Whether or not to use the default grid color
/// </summary>
bool default_grid_color_ = true;
/// <summary>
///
/// The type of this view
/// </summary>
sheet_view_type type_ = sheet_view_type::normal;
/// <summary>
///
/// The optional pane
/// </summary>
optional<xlnt::pane> pane_;
/// <summary>
///
/// The collection of selections
/// </summary>
std::vector<xlnt::selection> selections_;
};

View File

@ -320,17 +320,17 @@ public:
// named range
/// <summary>
///
/// Creates a new named range with the given name encompassing the string representing a range.
/// </summary>
void create_named_range(const std::string &name, const std::string &reference_string);
/// <summary>
///
/// Creates a new named range with the given name encompassing the given range reference.
/// </summary>
void create_named_range(const std::string &name, const range_reference &reference);
/// <summary>
///
/// Returns true if this worksheet contains a named range with the given name.
/// </summary>
bool has_named_range(const std::string &name) const;
@ -354,96 +354,86 @@ public:
// extents
/// <summary>
///
/// Returns the row of the first non-empty cell in the worksheet.
/// </summary>
row_t lowest_row() const;
/// <summary>
///
/// Returns the row of the last non-empty cell in the worksheet.
/// </summary>
row_t highest_row() const;
/// <summary>
///
/// Returns the row directly below the last non-empty cell in the worksheet.
/// </summary>
row_t next_row() const;
/// <summary>
///
/// Returns the column of the first non-empty cell in the worksheet.
/// </summary>
column_t lowest_column() const;
/// <summary>
///
/// Returns the column of the last non-empty cell in the worksheet.
/// </summary>
column_t highest_column() const;
/// <summary>
///
/// Returns a range_reference pointing to the full range of non-empty cells in the worksheet.
/// </summary>
range_reference calculate_dimension() const;
// cell merge
/// <summary>
///
/// Merges the cells within the range represented by the given string.
/// </summary>
void merge_cells(const std::string &reference_string);
/// <summary>
///
/// Merges the cells within the given range.
/// </summary>
void merge_cells(const range_reference &reference);
/// <summary>
///
/// </summary>
void merge_cells(column_t start_column, row_t start_row, column_t end_column, row_t end_row);
/// <summary>
///
/// Removes the merging of the cells in the range represented by the given string.
/// </summary>
void unmerge_cells(const std::string &reference_string);
/// <summary>
///
/// Removes the merging of the cells in the given range.
/// </summary>
void unmerge_cells(const range_reference &reference);
/// <summary>
///
/// </summary>
void unmerge_cells(column_t start_column, row_t start_row, column_t end_column, row_t end_row);
/// <summary>
///
/// Returns a vector of references of all merged ranges in the worksheet.
/// </summary>
std::vector<range_reference> merged_ranges() const;
// operators
/// <summary>
///
/// Returns true if this worksheet refers to the same worksheet as other.
/// </summary>
bool operator==(const worksheet &other) const;
/// <summary>
///
/// Returns true if this worksheet doesn't refer to the same worksheet as other.
/// </summary>
bool operator!=(const worksheet &other) const;
/// <summary>
///
/// Returns true if this worksheet is null.
/// </summary>
bool operator==(std::nullptr_t) const;
/// <summary>
///
/// Returns true if this worksheet is not null.
/// </summary>
bool operator!=(std::nullptr_t) const;
/// <summary>
///
/// Sets the internal pointer of this worksheet object to point to other.
/// </summary>
void operator=(const worksheet &other);

View File

@ -103,9 +103,14 @@ int comment::height() const
return height_;
}
XLNT_API bool operator==(const comment &left, const comment &right)
bool comment::operator==(const comment &other) const
{
return left.text_ == right.text_ && left.author_ == right.author_;
return text_ == other.text_ && author_ == other.author_;
}
bool comment::operator!=(const comment &other) const
{
return !(*this == other);
}
} // namespace xlnt

View File

@ -33,7 +33,7 @@ column_t::index_t column_t::column_index_from_string(const std::string &column_s
{
if (column_string.length() > 3 || column_string.empty())
{
throw invalid_column_string_index();
throw invalid_column_index();
}
column_t::index_t column_index = 0;
@ -43,7 +43,7 @@ column_t::index_t column_t::column_index_from_string(const std::string &column_s
{
if (!std::isalpha(column_string[static_cast<std::size_t>(i)], std::locale::classic()))
{
throw invalid_column_string_index();
throw invalid_column_index();
}
auto char_index = std::toupper(column_string[static_cast<std::size_t>(i)], std::locale::classic()) - 'A';
@ -65,7 +65,7 @@ std::string column_t::column_string_from_index(column_t::index_t column_index)
// columns
if (column_index < constants::min_column() || column_index > constants::max_column())
{
throw invalid_column_string_index();
throw invalid_column_index();
}
int temp = static_cast<int>(column_index);
@ -268,24 +268,6 @@ column_t operator-(column_t lhs, const column_t &rhs)
return lhs;
}
column_t operator*(column_t lhs, const column_t &rhs)
{
lhs *= rhs;
return lhs;
}
column_t operator/(column_t lhs, const column_t &rhs)
{
lhs /= rhs;
return lhs;
}
column_t operator%(column_t lhs, const column_t &rhs)
{
lhs %= rhs;
return lhs;
}
column_t &column_t::operator+=(const column_t &rhs)
{
index += rhs.index;
@ -298,24 +280,6 @@ column_t &column_t::operator-=(const column_t &rhs)
return *this;
}
column_t &column_t::operator*=(const column_t &rhs)
{
index *= rhs.index;
return *this;
}
column_t &column_t::operator/=(const column_t &rhs)
{
index /= rhs.index;
return *this;
}
column_t &column_t::operator%=(const column_t &rhs)
{
index %= rhs.index;
return *this;
}
bool operator>(const column_t::index_t &left, const column_t &right)
{
return column_t(left) > right;

View File

@ -58,7 +58,7 @@ public:
TS_ASSERT(cell.value<xlnt::time>() == xlnt::time(0, 30, 33, 865633));
}
void test_ctor()
void test_constructor()
{
xlnt::workbook wb;
auto ws = wb.active_sheet();
@ -195,6 +195,7 @@ public:
auto cell = ws.cell(xlnt::cell_reference(1, 1));
cell.value(xlnt::datetime(2010, 7, 13, 6, 37, 41));
TS_ASSERT(cell.data_type() == xlnt::cell::type::numeric);
TS_ASSERT(cell.value<long double>() == 40372.27616898148L);
TS_ASSERT(cell.is_date());
@ -270,7 +271,8 @@ public:
auto cell = ws.cell(xlnt::cell_reference(1, 1));
// The bytes 0x00 through 0x1F inclusive must be manually escaped in values.
auto illegal_chrs = {0, 1, 2, 3, 4, 5, 6, 7, 8, 11, 12, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31};
auto illegal_chrs = {0, 1, 2, 3, 4, 5, 6, 7, 8, 11, 12, 14, 15, 16, 17, 18,
19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31};
for(auto i : illegal_chrs)
{

View File

@ -8,25 +8,39 @@
class test_index_types : public CxxTest::TestSuite
{
public:
void test_bad_string()
void test_bad_string_empty()
{
TS_ASSERT_THROWS(xlnt::column_t::column_index_from_string(""), xlnt::invalid_column_string_index);
TS_ASSERT_THROWS(xlnt::column_t::column_index_from_string("ABCD"), xlnt::invalid_column_string_index);
TS_ASSERT_THROWS(xlnt::column_t::column_index_from_string("123"), xlnt::invalid_column_string_index);
TS_ASSERT_THROWS(xlnt::column_t::column_index_from_string(""),
xlnt::invalid_column_index);
}
void test_bad_column()
void test_bad_string_too_long()
{
TS_ASSERT_THROWS(xlnt::column_t::column_string_from_index(0), xlnt::invalid_column_string_index);
TS_ASSERT_THROWS(xlnt::column_t::column_index_from_string("ABCD"),
xlnt::invalid_column_index);
}
void test_bad_string_numbers()
{
TS_ASSERT_THROWS(xlnt::column_t::column_index_from_string("123"),
xlnt::invalid_column_index);
}
void test_bad_index_zero()
{
TS_ASSERT_THROWS(xlnt::column_t::column_string_from_index(0),
xlnt::invalid_column_index);
}
void test_column_operators()
{
xlnt::column_t c1;
auto c1 = xlnt::column_t();
c1 = "B";
xlnt::column_t c2;
std::string d = "D";
auto c2 = xlnt::column_t();
const auto d = std::string("D");
c2 = d;
TS_ASSERT(c1 != c2);
TS_ASSERT(c1 == static_cast<xlnt::column_t::index_t>(2));
TS_ASSERT(c2 == d);
@ -44,18 +58,7 @@ public:
TS_ASSERT_EQUALS(c2, 2);
c2 = 4;
TS_ASSERT_EQUALS(c1 * c2, 8);
TS_ASSERT_EQUALS(c2 / c1, 2);
TS_ASSERT_EQUALS(c2 % c1, 0);
c1 *= c2;
TS_ASSERT_EQUALS(c1, 8);
c1 /= c2;
TS_ASSERT_EQUALS(c1, 2);
c1 = 3;
c1 %= c2;
TS_ASSERT_EQUALS(c1, 3);
TS_ASSERT(c2 <= 4);
TS_ASSERT(!(c2 < 3));

View File

@ -58,11 +58,19 @@ struct format_impl
{
return left.parent == right.parent
&& left.alignment_id == right.alignment_id
&& left.alignment_applied == right.alignment_applied
&& left.border_id == right.border_id
&& left.border_applied == right.border_applied
&& left.fill_id == right.fill_id
&& left.fill_applied == right.fill_applied
&& left.font_id == right.font_id
&& left.font_applied == right.font_applied
&& left.number_format_id == right.number_format_id
&& left.number_format_applied == right.number_format_applied
&& left.protection_id == right.protection_id
&& left.protection_applied == right.protection_applied
&& left.pivot_button_ == right.pivot_button_
&& left.quote_prefix_ == right.quote_prefix_
&& left.style == right.style;
}
};

View File

@ -2181,7 +2181,7 @@ void xlsx_producer::write_worksheet(const relationship &rel)
if (cell.has_format())
{
write_attribute("s", cell.format().id());
write_attribute("s", cell.format().d_->id);
}
if (cell.has_hyperlink())

View File

@ -120,7 +120,7 @@ std::uint8_t rgb_color::alpha() const
std::array<std::uint8_t, 3> rgb_color::rgb() const
{
return { red(), green(), blue() };
return {{red(), green(), blue()}};
}
std::array<std::uint8_t, 4> rgb_color::rgba() const

View File

@ -207,78 +207,78 @@ std::string font::scheme() const
return scheme_.get();
}
XLNT_API bool operator==(const font &left, const font &right)
bool font::operator==(const font &other) const
{
if (left.bold() != right.bold())
if (bold() != other.bold())
{
return false;
}
if (left.has_color() != right.has_color())
if (has_color() != other.has_color())
{
return false;
}
if (left.has_color())
if (has_color())
{
if (left.color() != right.color())
if (color() != other.color())
{
return false;
}
}
if (left.has_family() != right.has_family())
if (has_family() != other.has_family())
{
return false;
}
if (left.has_family())
if (has_family())
{
if (left.family() != right.family())
if (family() != other.family())
{
return false;
}
}
if (left.italic() != right.italic())
if (italic() != other.italic())
{
return false;
}
if (left.name() != right.name())
if (name() != other.name())
{
return false;
}
if (left.has_scheme() != right.has_scheme())
if (has_scheme() != other.has_scheme())
{
return false;
}
if (left.has_scheme())
if (has_scheme())
{
if (left.scheme() != right.scheme())
if (scheme() != other.scheme())
{
return false;
}
}
if (std::fabs(left.size() - right.size()) != 0.0)
if (std::fabs(size() - other.size()) != 0.0)
{
return false;
}
if (left.strikethrough() != right.strikethrough())
if (strikethrough() != other.strikethrough())
{
return false;
}
if (left.superscript() != right.superscript())
if (superscript() != other.superscript())
{
return false;
}
if (left.underline() != right.underline())
if (underline() != other.underline())
{
return false;
}

View File

@ -34,11 +34,6 @@ format::format(detail::format_impl *d)
{
}
std::size_t format::id() const
{
return d_->id;
}
void format::clear_style()
{
d_->style.clear();
@ -81,12 +76,7 @@ const style format::style() const
return d_->parent->style(d_->style.get());
}
xlnt::alignment &format::alignment()
{
return d_->parent->alignments.at(d_->alignment_id.get());
}
const xlnt::alignment &format::alignment() const
xlnt::alignment format::alignment() const
{
return d_->parent->alignments.at(d_->alignment_id.get());
}
@ -97,12 +87,7 @@ format format::alignment(const xlnt::alignment &new_alignment, bool applied)
return format(d_);
}
xlnt::border &format::border()
{
return d_->parent->borders.at(d_->border_id.get());
}
const xlnt::border &format::border() const
xlnt::border format::border() const
{
return d_->parent->borders.at(d_->border_id.get());
}
@ -113,12 +98,7 @@ format format::border(const xlnt::border &new_border, bool applied)
return format(d_);
}
xlnt::fill &format::fill()
{
return d_->parent->fills.at(d_->fill_id.get());
}
const xlnt::fill &format::fill() const
xlnt::fill format::fill() const
{
return d_->parent->fills.at(d_->fill_id.get());
}
@ -129,12 +109,7 @@ format format::fill(const xlnt::fill &new_fill, bool applied)
return format(d_);
}
xlnt::font &format::font()
{
return d_->parent->fonts.at(d_->font_id.get());
}
const xlnt::font &format::font() const
xlnt::font format::font() const
{
return d_->parent->fonts.at(d_->font_id.get());
}
@ -145,12 +120,7 @@ format format::font(const xlnt::font &new_font, bool applied)
return format(d_);
}
xlnt::number_format &format::number_format()
{
return d_->parent->number_formats.at(d_->number_format_id.get());
}
const xlnt::number_format &format::number_format() const
xlnt::number_format format::number_format() const
{
if (number_format::is_builtin_format(d_->number_format_id.get()))
{
@ -175,12 +145,7 @@ format format::number_format(const xlnt::number_format &new_number_format, bool
return format(d_);
}
xlnt::protection &format::protection()
{
return d_->parent->protections.at(d_->protection_id.get());
}
const xlnt::protection &format::protection() const
xlnt::protection format::protection() const
{
return d_->parent->protections.at(d_->protection_id.get());
}

View File

@ -244,15 +244,13 @@ number_format::number_format(std::size_t id)
}
number_format::number_format(const std::string &format_string)
: id_set_(false), id_(0)
: format_string_(format_string)
{
this->format_string(format_string);
}
number_format::number_format(const std::string &format_string, std::size_t id)
: id_set_(false), id_(0)
number_format::number_format(const std::string &format, std::size_t id)
{
this->format_string(format_string, id);
format_string(format, id);
}
bool number_format::is_builtin_format(std::size_t builtin_id)
@ -279,14 +277,12 @@ void number_format::format_string(const std::string &format_string)
{
format_string_ = format_string;
id_ = 0;
id_set_ = false;
for (const auto &pair : builtin_formats())
{
if (pair.second.format_string() == format_string)
{
id_ = pair.first;
id_set_ = true;
break;
}
}
@ -296,28 +292,26 @@ void number_format::format_string(const std::string &format_string, std::size_t
{
format_string_ = format_string;
id_ = id;
id_set_ = true;
}
bool number_format::has_id() const
{
return id_set_;
return id_.is_set();
}
void number_format::id(std::size_t id)
{
id_ = id;
id_set_ = true;
}
std::size_t number_format::id() const
{
if (!id_set_)
if (!has_id())
{
throw invalid_attribute();
}
return id_;
return id_.get();
}
bool number_format::is_date_format() const
@ -355,9 +349,14 @@ std::string number_format::format(long double number, calendar base_date) const
return detail::number_formatter(format_string_, base_date).format_number(number);
}
XLNT_API bool operator==(const number_format &left, const number_format &right)
bool number_format::operator==(const number_format &other) const
{
return left.format_string_ == right.format_string_;
return format_string_ == other.format_string_;
}
bool number_format::operator!=(const number_format &other) const
{
return !(*this == other);
}
} // namespace xlnt

View File

@ -53,9 +53,14 @@ protection &protection::hidden(bool hidden)
return *this;
}
XLNT_API bool operator==(const protection &left, const protection &right)
bool protection::operator==(const protection &other) const
{
return left.locked_ == right.locked_ && left.hidden_ == right.hidden_;
return locked_ == other.locked_ && hidden_ == other.hidden_;
}
bool protection::operator!=(const protection &other) const
{
return !(*this == other);
}
} // namespace xlnt

View File

@ -27,7 +27,7 @@
namespace xlnt {
exception::exception(const std::string &message)
: std::runtime_error("xlnt::error : " + message)
: std::runtime_error("xlnt::exception : " + message)
{
this->message(message);
}
@ -63,12 +63,12 @@ invalid_sheet_title::~invalid_sheet_title()
{
}
invalid_column_string_index::invalid_column_string_index()
invalid_column_index::invalid_column_index()
: exception("column string index error")
{
}
invalid_column_string_index::~invalid_column_string_index()
invalid_column_index::~invalid_column_index()
{
}

View File

@ -315,9 +315,9 @@ path path::relative_to(const path &base_path) const
return result;
}
bool operator==(const path &left, const path &right)
bool path::operator==(const path &other) const
{
return left.internal_ == right.internal_;
return internal_ == other.internal_;
}
} // namespace xlnt

View File

@ -118,41 +118,21 @@ bool range_reference::operator!=(const range_reference &comparand) const
return comparand.top_left_ != top_left_ || comparand.bottom_right_ != bottom_right_;
}
cell_reference range_reference::top_left()
{
return top_left_;
}
cell_reference range_reference::top_left() const
{
return top_left_;
}
cell_reference range_reference::top_right()
{
return cell_reference(bottom_right_.column(), top_left_.row());
}
cell_reference range_reference::top_right() const
{
return cell_reference(bottom_right_.column(), top_left_.row());
}
cell_reference range_reference::bottom_left()
{
return cell_reference(top_left_.column(), bottom_right_.row());
}
cell_reference range_reference::bottom_left() const
{
return cell_reference(top_left_.column(), bottom_right_.row());
}
cell_reference range_reference::bottom_right()
{
return bottom_right_;
}
cell_reference range_reference::bottom_right() const
{
return bottom_right_;

View File

@ -303,15 +303,6 @@ public:
TS_ASSERT(!ws.cell("D4").has_value());
}
void test_merge_coordinate()
{
xlnt::workbook wb;
auto ws = wb.active_sheet();
ws.merge_cells(1, 1, 4, 4);
std::vector<xlnt::range_reference> expected = { xlnt::range_reference("A1:D4") };
TS_ASSERT_EQUALS(ws.merged_ranges(), expected);
}
void test_unmerge_bad()
{
xlnt::workbook wb;
@ -330,16 +321,6 @@ public:
TS_ASSERT_EQUALS(ws.merged_ranges().size(), 0);
}
void test_unmerge_coordinate()
{
xlnt::workbook wb;
auto ws = wb.active_sheet();
ws.merge_cells("A1:D4");
TS_ASSERT_EQUALS(ws.merged_ranges().size(), 1);
ws.unmerge_cells(1, 1, 4, 4);
TS_ASSERT_EQUALS(ws.merged_ranges().size(), 0);
}
void test_print_titles_old()
{
xlnt::workbook wb;

View File

@ -568,11 +568,6 @@ void worksheet::merge_cells(const range_reference &reference)
}
}
void worksheet::merge_cells(column_t start_column, row_t start_row, column_t end_column, row_t end_row)
{
merge_cells(xlnt::range_reference(start_column, start_row, end_column, end_row));
}
void worksheet::unmerge_cells(const range_reference &reference)
{
auto match = std::find(d_->merged_cells_.begin(), d_->merged_cells_.end(), reference);
@ -593,11 +588,6 @@ void worksheet::unmerge_cells(const range_reference &reference)
}
}
void worksheet::unmerge_cells(column_t start_column, row_t start_row, column_t end_column, row_t end_row)
{
unmerge_cells(xlnt::range_reference(start_column, start_row, end_column, end_row));
}
row_t worksheet::next_row() const
{
auto row = highest_row() + 1;