diff --git a/.clang-format b/.clang-format index dc03d380..1621af7b 100644 --- a/.clang-format +++ b/.clang-format @@ -1,51 +1,45 @@ --- -Language: Cpp -AccessModifierOffset: -4 -ConstructorInitializerIndentWidth: 4 -AlignEscapedNewlinesLeft: false -AlignTrailingComments: false -AllowAllParametersOfDeclarationOnNextLine: true -AllowShortIfStatementsOnASingleLine: false +BasedOnStyle: LLVM +AllowShortBlocksOnASingleLine: false +AllowShortFunctionsOnASingleLine: None +AllowShortIfStatementsOnASingleLine: true AllowShortLoopsOnASingleLine: false -AllowShortFunctionsOnASingleLine: true -AlwaysBreakTemplateDeclarations: false -AlwaysBreakBeforeMultilineStrings: false -BreakBeforeBinaryOperators: false -BreakBeforeTernaryOperators: true -BreakConstructorInitializersBeforeComma: false -BinPackParameters: true -ColumnLimit: 0 +AlwaysBreakBeforeMultilineStrings: true +AlwaysBreakTemplateDeclarations: true +BraceWrapping: + AfterClass: true + AfterControlStatement: true + AfterEnum: true + AfterFunction: true + AfterNamespace: false + AfterObjCDeclaration: true + AfterStruct: true + AfterUnion: true + BeforeCatch: true + BeforeElse: true +BreakBeforeBraces: Custom +ColumnLimit: 120 ConstructorInitializerAllOnOneLineOrOnePerLine: true -DerivePointerBinding: false -ExperimentalAutoDetectBinPacking: false +Cpp11BracedListStyle: false +DerivePointerAlignment: false +DisableFormat: false IndentCaseLabels: false -MaxEmptyLinesToKeep: 1 +IndentWidth: 4 +KeepEmptyLinesAtTheStartOfBlocks: false +Language: Cpp NamespaceIndentation: None -ObjCSpaceAfterProperty: false -ObjCSpaceBeforeProtocolList: true -PenaltyBreakBeforeFirstCallParameter: 19 -PenaltyBreakComment: 300 -PenaltyBreakString: 1000 -PenaltyBreakFirstLessLess: 120 -PenaltyExcessCharacter: 1000000 -PenaltyReturnTypeOnItsOwnLine: 60 -PointerBindsToType: false -SpacesBeforeTrailingComments: 1 -Cpp11BracedListStyle: true -Standard: Cpp11 -IndentWidth: 4 -TabWidth: 8 -UseTab: Never -BreakBeforeBraces: Allman -IndentFunctionDeclarationAfterType: false -SpacesInParentheses: false -SpacesInAngles: false +MaxEmptyLinesToKeep: 1 +PointerAlignment: Right +SpaceAfterCStyleCast: false +SpaceBeforeParens: ControlStatements SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: false SpacesInCStyleCastParentheses: false SpacesInContainerLiterals: true -SpaceBeforeAssignmentOperators: true -ContinuationIndentWidth: 4 -CommentPragmas: '^ IWYU pragma:' -SpaceBeforeParens: Never -... +SpacesInParentheses: false +SpacesInSquareBrackets: false +Standard: Cpp11 +UseTab: Never +... diff --git a/include/xlnt/cell/cell.hpp b/include/xlnt/cell/cell.hpp index 0f678161..0f5e12e5 100644 --- a/include/xlnt/cell/cell.hpp +++ b/include/xlnt/cell/cell.hpp @@ -30,7 +30,7 @@ #include namespace xlnt { - + enum class calendar; class alignment; @@ -50,9 +50,9 @@ struct time; struct timedelta; namespace detail { - + struct cell_impl; - + } // namespace detail /// @@ -66,7 +66,7 @@ struct cell_impl; /// class cell { -public: + public: /// /// Enumerates the possible types a cell can be determined by it's current value. /// @@ -79,77 +79,77 @@ public: error, boolean }; - + /// /// Return a map of error strings such as #DIV/0! and their associated indices. /// static const std::unordered_map error_codes(); - - //TODO: Should it be possible to construct and use a cell without a parent worksheet? + + // TODO: Should it be possible to construct and use a cell without a parent worksheet? //(cont'd) If so, it would need to be responsible for allocating and deleting its PIMPL. - + /// /// Construct a null cell without a parent. /// Most methods will throw an exception if this cell is not further initialized. /// cell(); - + /// /// Construct a cell in worksheet, sheet, at the given reference location (e.g. A1). /// cell(worksheet sheet, const cell_reference &reference); - + /// /// This constructor, provided for convenience, is equivalent to calling: /// cell c(sheet, reference); /// c.set_value(initial_value); /// - template + template cell(worksheet sheet, const cell_reference &reference, const T &initial_value); // value - + /// /// Return true if value has been set and has not been cleared using cell::clear_value(). /// bool has_value() const; - - template + + template T get_value() const; - + void clear_value(); - - template + + template void set_value(T value); - + type get_data_type() const; void set_data_type(type t); - + // properties - + /// /// There's no reason to keep a cell which has no value and is not a placeholder. /// Return true if this cell has no value, style, isn't merged, etc. /// bool garbage_collectible() const; - + /// /// Return true iff this cell's number format matches a date format. /// bool is_date() const; - + // position cell_reference get_reference() const; std::string get_column() const; column_t get_column_index() const; row_t get_row() const; std::pair get_anchor() const; - + // hyperlink relationship get_hyperlink() const; void set_hyperlink(const std::string &value); bool has_hyperlink() const; - + // style bool has_style() const; std::size_t get_style_id() const; @@ -170,13 +170,13 @@ public: bool pivot_button() const; void set_quote_prefix(bool b); bool quote_prefix() const; - + // comment comment get_comment(); void set_comment(const comment &comment); void clear_comment(); bool has_comment() const; - + // formula std::string get_formula() const; void set_formula(const std::string &formula); @@ -184,47 +184,47 @@ public: bool has_formula() const; // printing - + /// /// Returns a string describing this cell like . /// std::string to_repr() const; - + /// /// Returns a string representing the value of this cell. If the data type is not a string, /// it will be converted according to the number format. /// std::string to_string() const; - + // merging bool is_merged() const; void set_merged(bool merged); std::string get_error() const; void set_error(const std::string &error); - + cell offset(row_t row, column_t column); - + worksheet get_parent(); const worksheet get_parent() const; - + calendar get_base_date() const; - + // operators cell &operator=(const cell &rhs); - + bool operator==(const cell &comparand) const; bool operator==(std::nullptr_t) const; // friend operators, so we can put cell on either side of comparisons with other types friend bool operator==(std::nullptr_t, const cell &cell); friend bool operator<(cell left, cell right); - -private: + + private: friend class worksheet; friend struct detail::cell_impl; friend class style; - + cell(detail::cell_impl *d); detail::cell_impl *d_; }; @@ -237,5 +237,5 @@ inline std::ostream &operator<<(std::ostream &stream, const xlnt::cell &cell) { return stream << cell.to_string(); } - + } // namespace xlnt diff --git a/include/xlnt/cell/cell_reference.hpp b/include/xlnt/cell/cell_reference.hpp index 99fbecfd..78e86d72 100644 --- a/include/xlnt/cell/cell_reference.hpp +++ b/include/xlnt/cell/cell_reference.hpp @@ -29,23 +29,23 @@ #include "../common/types.hpp" namespace xlnt { - + class cell_reference; class range_reference; - + struct cell_reference_hash { std::size_t operator()(const cell_reference &k) const; }; - + class cell_reference { -public: + public: /// /// Convert a coordinate to an absolute coordinate string (B12 -> $B$12) /// static cell_reference make_absolute(const cell_reference &relative_reference); - + /// /// Convert a column letter into a column number (e.g. B -> 2) /// @@ -54,7 +54,7 @@ public: /// restrict our column names to 1 - 3 characters, each in the range A - Z. /// static column_t column_index_from_string(const std::string &column_string); - + /// /// Convert a column number into a column letter (3 -> 'C') /// @@ -64,13 +64,13 @@ public: /// ordinals by adding 64. /// static std::string column_string_from_index(column_t column_index); - + /// /// Split a coordinate string like "A1" into an equivalent pair like {"A", 1}. /// - static std::pair split_reference(const std::string &reference_string, - bool &absolute_column, bool &absolute_row); - + static std::pair split_reference(const std::string &reference_string, bool &absolute_column, + bool &absolute_row); + // constructors /// /// Default constructor makes a reference to the top-left-most cell, "A1". @@ -80,21 +80,45 @@ public: cell_reference(const std::string &reference_string); cell_reference(const std::string &column, row_t row, bool absolute = false); cell_reference(column_t column, row_t row, bool absolute = false); - + // absoluateness - bool is_absolute() const { return absolute_; } - void set_absolute(bool absolute) { absolute_ = absolute; } - + bool is_absolute() const + { + return absolute_; + } + void set_absolute(bool absolute) + { + absolute_ = absolute; + } + // getters/setters - std::string get_column() const { return column_string_from_index(column_); } - void set_column(const std::string &column_string) { column_ = column_index_from_string(column_string); } - - column_t get_column_index() const { return column_; } - void set_column_index(column_t column) { column_ = column; } - - row_t get_row() const { return row_ ; } - void set_row(row_t row) { row_ = row; } - + std::string get_column() const + { + return column_string_from_index(column_); + } + void set_column(const std::string &column_string) + { + column_ = column_index_from_string(column_string); + } + + column_t get_column_index() const + { + return column_; + } + void set_column_index(column_t column) + { + column_ = column; + } + + row_t get_row() const + { + return row_; + } + void set_row(row_t row) + { + row_ = row; + } + /// /// Return a cell_reference offset from this cell_reference by /// the number of columns and rows specified by the parameters. @@ -102,54 +126,69 @@ public: /// in a reference above or left of this cell_reference, respectively. /// cell_reference make_offset(int column_offset, int row_offset) const; - + /// /// Return a string like "A1" for cell_reference(1, 1). /// std::string to_string() const; - + /// /// Return a range_reference containing only this cell_reference. /// range_reference to_range() const; - + // operators /// /// I've always wanted to overload the comma operator. /// cell_reference("A", 1), cell_reference("B", 1) will return /// range_reference(cell_reference("A", 1), cell_reference("B", 1)) /// - range_reference operator,(const cell_reference &other) const; - + range_reference operator, (const cell_reference &other) const; + bool operator==(const cell_reference &comparand) const; - bool operator==(const std::string &reference_string) const { return *this == cell_reference(reference_string); } - bool operator==(const char *reference_string) const { return *this == std::string(reference_string); } - bool operator!=(const cell_reference &comparand) const { return !(*this == comparand); } - bool operator!=(const std::string &reference_string) const { return *this != cell_reference(reference_string); } - bool operator!=(const char *reference_string) const { return *this != std::string(reference_string); } + bool operator==(const std::string &reference_string) const + { + return *this == cell_reference(reference_string); + } + bool operator==(const char *reference_string) const + { + return *this == std::string(reference_string); + } + bool operator!=(const cell_reference &comparand) const + { + return !(*this == comparand); + } + bool operator!=(const std::string &reference_string) const + { + return *this != cell_reference(reference_string); + } + bool operator!=(const char *reference_string) const + { + return *this != std::string(reference_string); + } bool operator<(const cell_reference &other); bool operator>(const cell_reference &other); bool operator<=(const cell_reference &other); bool operator>=(const cell_reference &other); -private: + private: /// /// Index of the column. Important: this is one-indexed to conform /// with Excel. Column "A", the first column, would have an index of 1. /// column_t column_; - + /// /// Index of the column. Important: this is one-indexed to conform /// with Excel. Column "A", the first column, would have an index of 1. /// row_t row_; - + /// /// True if the reference is absolute. This looks like "$A$1" in Excel. /// bool absolute_; }; - + } // namespace xlnt diff --git a/include/xlnt/cell/comment.hpp b/include/xlnt/cell/comment.hpp index 9dd09ac2..e25f00a4 100644 --- a/include/xlnt/cell/comment.hpp +++ b/include/xlnt/cell/comment.hpp @@ -3,11 +3,11 @@ #include namespace xlnt { - + class cell; - + namespace detail { - + struct comment_impl; } // namespace detail @@ -17,17 +17,17 @@ struct comment_impl; /// class comment { -public: + public: /// /// The default constructor makes an invalid comment without a parent cell. /// comment(); comment(cell parent, const std::string &text, const std::string &auth); ~comment(); - + std::string get_text() const; std::string get_author() const; - + /// /// True if the comments point to the same sell. /// Note that a cell can only have one comment and a comment @@ -35,7 +35,7 @@ public: /// bool operator==(const comment &other) const; -private: + private: friend class cell; comment(detail::comment_impl *d); detail::comment_impl *d_; diff --git a/include/xlnt/common/datetime.hpp b/include/xlnt/common/datetime.hpp index 6918ce8a..ff19f188 100644 --- a/include/xlnt/common/datetime.hpp +++ b/include/xlnt/common/datetime.hpp @@ -47,15 +47,14 @@ struct date /// Return the current date according to the system time. /// static date today(); - + /// /// Return a date by adding days_since_base_year to base_date. /// This includes leap years. /// static date from_number(int days_since_base_year, calendar base_date); - date(int year_, int month_, int day_) - : year(year_), month(month_), day(day_) + date(int year_, int month_, int day_) : year(year_), month(month_), day(day_) { } @@ -63,7 +62,7 @@ struct date /// Return the number of days between this date and base_date. /// int to_number(calendar base_date) const; - + /// /// Return true if this date is equal to comparand. /// @@ -85,7 +84,7 @@ struct time /// Return the current time according to the system time. /// static time now(); - + /// /// Return a time from a number representing a fraction of a day. /// The integer part of number will be ignored. @@ -114,13 +113,16 @@ struct datetime /// Return the current date and time according to the system time. /// static datetime now(); - + /// /// Return the current date and time according to the system time. /// This is equivalent to datetime::now(). /// - static datetime today() { return now(); } - + static datetime today() + { + return now(); + } + /// /// Return a datetime from number by converting the integer part into /// a date and the fractional part into a time according to date::from_number @@ -129,7 +131,13 @@ struct datetime static datetime from_number(long double number, calendar base_date); datetime(int year_, int month_, int day_, int hour_ = 0, int minute_ = 0, int second_ = 0, int microsecond_ = 0) - : year(year_), month(month_), day(day_), hour(hour_), minute(minute_), second(second_), microsecond(microsecond_) + : year(year_), + month(month_), + day(day_), + hour(hour_), + minute(minute_), + second(second_), + microsecond(microsecond_) { } @@ -145,7 +153,7 @@ struct datetime int second; int microsecond; }; - + /// /// Represents a span of time between two datetimes. This is /// not fully supported yet. @@ -153,18 +161,14 @@ struct datetime struct timedelta { static timedelta from_number(long double number); - + timedelta(int days_, int hours_, int minutes_ = 0, int seconds_ = 0, int microseconds_ = 0) - : days(days_), - hours(hours_), - minutes(minutes_), - seconds(seconds_), - microseconds(microseconds_) + : days(days_), hours(hours_), minutes(minutes_), seconds(seconds_), microseconds(microseconds_) { } - + double to_number() const; - + int days; int hours; int minutes; diff --git a/include/xlnt/common/exceptions.hpp b/include/xlnt/common/exceptions.hpp index 4408c4e0..1c2e6bb2 100644 --- a/include/xlnt/common/exceptions.hpp +++ b/include/xlnt/common/exceptions.hpp @@ -34,7 +34,7 @@ namespace xlnt { /// class cell_coordinates_exception : public std::runtime_error { -public: + public: cell_coordinates_exception(row_t row, column_t column); cell_coordinates_exception(const std::string &coord_string); }; @@ -45,7 +45,7 @@ public: /// class illegal_character_error : public std::runtime_error { -public: + public: illegal_character_error(char c); }; @@ -54,7 +54,7 @@ public: /// class column_string_index_exception : public std::runtime_error { -public: + public: column_string_index_exception(); }; @@ -63,7 +63,7 @@ public: /// class data_type_exception : public std::runtime_error { -public: + public: data_type_exception(); }; @@ -72,7 +72,7 @@ public: /// class named_range_exception : public std::runtime_error { -public: + public: named_range_exception(); }; @@ -81,7 +81,7 @@ public: /// class sheet_title_exception : public std::runtime_error { -public: + public: sheet_title_exception(const std::string &title); }; @@ -90,7 +90,7 @@ public: /// class invalid_file_exception : public std::runtime_error { -public: + public: invalid_file_exception(const std::string &filename); }; @@ -99,7 +99,7 @@ public: /// class read_only_workbook_exception : public std::runtime_error { -public: + public: read_only_workbook_exception(); }; @@ -108,7 +108,7 @@ public: /// class missing_number_format : public std::runtime_error { -public: + public: missing_number_format(); }; @@ -117,13 +117,13 @@ public: /// class attribute_error : public std::runtime_error { -public: + public: attribute_error(); }; class value_error : public std::runtime_error { -public: + public: value_error() : std::runtime_error("") { } diff --git a/include/xlnt/common/hash_combine.hpp b/include/xlnt/common/hash_combine.hpp index 882a270a..7c672e56 100644 --- a/include/xlnt/common/hash_combine.hpp +++ b/include/xlnt/common/hash_combine.hpp @@ -3,13 +3,13 @@ #include namespace xlnt { - -//TODO: Can this be in source->detail, or must it be in a header? + +// TODO: Can this be in source->detail, or must it be in a header? template -inline void hash_combine(std::size_t& seed, const T& v) +inline void hash_combine(std::size_t &seed, const T &v) { std::hash hasher; - seed ^= hasher(v) + 0x9e3779b9 + (seed<<6) + (seed>>2); + seed ^= hasher(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2); } - + } // namespace xlnt \ No newline at end of file diff --git a/include/xlnt/common/relationship.hpp b/include/xlnt/common/relationship.hpp index 324ed4a1..3e45fe77 100644 --- a/include/xlnt/common/relationship.hpp +++ b/include/xlnt/common/relationship.hpp @@ -26,7 +26,7 @@ #include namespace xlnt { - + /// /// Specifies whether the target of a relationship is inside or outside the Package. /// @@ -43,11 +43,12 @@ enum class target_mode }; /// -/// Represents an association between a source Package or part, and a target object which can be a part or external resource. +/// Represents an association between a source Package or part, and a target object which can be a part or external +/// resource. /// class relationship { -public: + public: enum class type { invalid, @@ -63,113 +64,142 @@ public: office_document, custom_xml }; - + static type type_from_string(const std::string &type_string) { - if(type_string == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties") + if (type_string == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties") { return type::extended_properties; } - else if(type_string == "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties") + else if (type_string == "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties") { return type::core_properties; } - else if(type_string == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument") + else if (type_string == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument") { return type::office_document; } - else if(type_string == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet") + else if (type_string == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet") { return type::worksheet; } - else if(type_string == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings") + else if (type_string == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings") { return type::shared_strings; } - else if(type_string == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles") + else if (type_string == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles") { return type::styles; } - else if(type_string == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme") + else if (type_string == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme") { return type::theme; } - else if(type_string == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink") + else if (type_string == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink") { return type::hyperlink; } - else if(type_string == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chartsheet") + else if (type_string == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chartsheet") { return type::chartsheet; } - else if(type_string == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml") + else if (type_string == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml") { return type::custom_xml; } - + return type::invalid; } - + static std::string type_to_string(type t) { - switch(t) + switch (t) { - case type::extended_properties: return "http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties"; - case type::core_properties: return "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties"; - case type::office_document: return "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument"; - case type::worksheet: return "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet"; - case type::shared_strings: return "http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings"; - case type::styles: return "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles"; - case type::theme: return "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme"; - case type::hyperlink: return "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink"; - case type::chartsheet: return "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chartsheet"; - case type::custom_xml: return "http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml"; - default: return "??"; + case type::extended_properties: + return "http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties"; + case type::core_properties: + return "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties"; + case type::office_document: + return "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument"; + case type::worksheet: + return "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet"; + case type::shared_strings: + return "http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings"; + case type::styles: + return "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles"; + case type::theme: + return "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme"; + case type::hyperlink: + return "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink"; + case type::chartsheet: + return "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chartsheet"; + case type::custom_xml: + return "http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml"; + default: + return "??"; } } - + relationship(); - relationship(const std::string &t, const std::string &r_id = "", const std::string &target_uri = "") : relationship(type_from_string(t), r_id, target_uri) {} + relationship(const std::string &t, const std::string &r_id = "", const std::string &target_uri = "") + : relationship(type_from_string(t), r_id, target_uri) + { + } relationship(type t, const std::string &r_id = "", const std::string &target_uri = ""); - + /// /// gets a string that identifies the relationship. /// - std::string get_id() const { return id_; } - + std::string get_id() const + { + return id_; + } + /// /// gets the URI of the package or part that owns the relationship. /// - std::string get_source_uri() const { return source_uri_; } - + std::string get_source_uri() const + { + return source_uri_; + } + /// /// gets a value that indicates whether the target of the relationship is or External to the Package. /// - target_mode get_target_mode() const { return target_mode_; } - + target_mode get_target_mode() const + { + return target_mode_; + } + /// /// gets the URI of the target resource of the relationship. /// - std::string get_target_uri() const { return target_uri_; } - - type get_type() const { return type_; } - std::string get_type_string() const { return type_to_string(type_); } + std::string get_target_uri() const + { + return target_uri_; + } + + type get_type() const + { + return type_; + } + std::string get_type_string() const + { + return type_to_string(type_); + } friend bool operator==(const relationship &left, const relationship &right) { - return left.type_ == right.type_ - && left.id_ == right.id_ - && left.source_uri_ == right.source_uri_ - && left.target_uri_ == right.target_uri_ - && left.target_mode_ == right.target_mode_; + return left.type_ == right.type_ && left.id_ == right.id_ && left.source_uri_ == right.source_uri_ && + left.target_uri_ == right.target_uri_ && left.target_mode_ == right.target_mode_; } - -private: + + private: type type_; std::string id_; std::string source_uri_; std::string target_uri_; target_mode target_mode_; }; - + } // namespace xlnt diff --git a/include/xlnt/common/zip_file.hpp b/include/xlnt/common/zip_file.hpp index e79dbe61..7a3fab89 100644 --- a/include/xlnt/common/zip_file.hpp +++ b/include/xlnt/common/zip_file.hpp @@ -24,9 +24,9 @@ struct zip_info int minutes; int seconds; }; - + zip_info(); - + date_time_t date_time; std::string filename; std::string comment; @@ -46,70 +46,73 @@ struct zip_info class zip_file { -public: + public: zip_file(); zip_file(const std::string &filename); zip_file(const std::vector &bytes); zip_file(std::istream &stream); ~zip_file(); - + // to/from file void load(const std::string &filename); void save(const std::string &filename); - + // to/from byte vector void load(const std::vector &bytes); void save(std::vector &bytes); - + // to/from iostream void load(std::istream &stream); void save(std::ostream &stream); - + void reset(); bool has_file(const std::string &name); bool has_file(const zip_info &name); - + zip_info getinfo(const std::string &name); - + std::vector infolist(); std::vector namelist(); std::ostream &open(const std::string &name); std::ostream &open(const zip_info &name); - + void extract(const std::string &name); void extract(const std::string &name, const std::string &path); void extract(const zip_info &name); void extract(const zip_info &name, const std::string &path); - + void extractall(); void extractall(const std::string &path); void extractall(const std::string &path, const std::vector &members); void extractall(const std::string &path, const std::vector &members); - + void printdir(); void printdir(std::ostream &stream); - + std::string read(const std::string &name); std::string read(const zip_info &name); - + std::pair testzip(); - + void write(const std::string &filename); void write(const std::string &filename, const std::string &arcname); - + void writestr(const std::string &arcname, const std::string &bytes); void writestr(const zip_info &arcname, const std::string &bytes); - - std::string get_filename() const { return filename_; } - + + std::string get_filename() const + { + return filename_; + } + std::string comment; - -private: + + private: void start_read(); void start_write(); - + void append_comment(); void remove_comment(); diff --git a/include/xlnt/config.hpp b/include/xlnt/config.hpp index 1d4995e4..966180d1 100644 --- a/include/xlnt/config.hpp +++ b/include/xlnt/config.hpp @@ -35,8 +35,8 @@ namespace xlnt { enum class limit_style { openpyxl, /// limit style using in openpyxl - excel, /// limits according to Excel - maximum /// limits based on system + excel, /// limits according to Excel + maximum /// limits based on system }; /// @@ -44,5 +44,4 @@ enum class limit_style /// See limit_style for more information. /// const limit_style LimitStyle = limit_style::openpyxl; - } diff --git a/include/xlnt/drawing/drawing.hpp b/include/xlnt/drawing/drawing.hpp index 73a791f4..a4857d47 100644 --- a/include/xlnt/drawing/drawing.hpp +++ b/include/xlnt/drawing/drawing.hpp @@ -27,13 +27,13 @@ namespace xlnt { class worksheet; struct drawing_struct; - + class drawing { -public: + public: drawing(); - -private: + + private: friend class worksheet; drawing(drawing_struct *root); drawing_struct *root_; diff --git a/include/xlnt/formula/tokenizer.hpp b/include/xlnt/formula/tokenizer.hpp index 957fd157..a911b550 100644 --- a/include/xlnt/formula/tokenizer.hpp +++ b/include/xlnt/formula/tokenizer.hpp @@ -1,7 +1,7 @@ namespace xlnt { -class tokenizer { - +class tokenizer +{ }; - + } // namespace xlnt diff --git a/include/xlnt/formula/translator.hpp b/include/xlnt/formula/translator.hpp index 78e40614..cc015cbf 100644 --- a/include/xlnt/formula/translator.hpp +++ b/include/xlnt/formula/translator.hpp @@ -9,22 +9,22 @@ class tokenizer; class translator { translator(const std::string &formula, const cell_reference &ref); - + std::vector get_tokens(); - + static std::string translate_row(const std::string &row_str, int row_delta); static std::string translate_col(const std::string &col_str, col_delta); - + std::pair strip_ws_name(const std::string &range_str); - + void translate_range(const range_reference &range_ref); void translate_formula(const cell_reference &dest); - -private: + + private: const std::string ROW_RANGE_RE; const std::string COL_RANGE_RE; const std::string CELL_REF_RE; - + std::string formula_; cell_reference reference_; tokenizer tokenizer_; diff --git a/include/xlnt/s11n/comment_serializer.hpp b/include/xlnt/s11n/comment_serializer.hpp index 42066175..51f44767 100644 --- a/include/xlnt/s11n/comment_serializer.hpp +++ b/include/xlnt/s11n/comment_serializer.hpp @@ -31,18 +31,18 @@ namespace xlnt { class xml_document; - + class comment_serializer { comment_serializer(worksheet sheet); - + void read_comments(const xml_document &xml); void read_comments_vml(const xml_document &xml); - + xml_document write_comments() const; xml_document write_comments_vml() const; - -private: + + private: worksheet sheet_; }; diff --git a/include/xlnt/s11n/excel_serializer.hpp b/include/xlnt/s11n/excel_serializer.hpp index b4dddb6d..cd7d36bc 100644 --- a/include/xlnt/s11n/excel_serializer.hpp +++ b/include/xlnt/s11n/excel_serializer.hpp @@ -31,7 +31,7 @@ #include namespace xlnt { - + class workbook; /// @@ -40,48 +40,47 @@ class workbook; /// class excel_serializer { -public: + public: /// /// /// static const std::string central_directory_signature(); - + /// /// /// static std::string repair_central_directory(const std::string &original); - + /// /// Construct an excel_serializer which operates on wb. /// excel_serializer(workbook &wb); - + /// /// Create a ZIP file in memory, load archive from filename, then populate workbook /// with data from archive. /// bool load_workbook(const std::string &filename, bool guess_types = false, bool data_only = false); - - + /// /// Create a ZIP file in memory, load archive from stream, then populate workbook /// with data from archive. /// bool load_stream_workbook(std::istream &stream, bool guess_types = false, bool data_only = false); - - + /// /// Create a ZIP file in memory, load archive from bytes, then populate workbook /// with data from archive. /// - bool load_virtual_workbook(const std::vector &bytes, bool guess_types = false, bool data_only = false); + bool load_virtual_workbook(const std::vector &bytes, bool guess_types = false, + bool data_only = false); /// /// Create a ZIP file in memory, save workbook to this archive, then save archive /// to filename. /// bool save_workbook(const std::string &filename, bool as_template = false); - + /// /// Create a ZIP file in memory, save workbook to this archive, then assign ZIP file /// binary data to bytes. @@ -93,75 +92,75 @@ public: /// binary data to stream. /// bool save_stream_workbook(std::ostream &stream, bool as_template = false); - -private: + + private: /// /// Reads all files in archive and populates workbook with associated data /// using other appropriate serializers such as workbook_serializer. /// void read_data(bool guess_types, bool data_only); - + /// /// Read xl/sharedStrings.xml from internal archive and add shared strings to workbook. /// void read_shared_strings(); - + /// /// /// void read_images(); - + /// /// /// void read_charts(); - + /// /// /// void read_chartsheets(); - + /// /// /// void read_worksheets(); - + /// /// /// void read_external_links(); - + /// /// Write all files needed to create a valid XLSX file which represents all /// data contained in workbook. /// void write_data(bool as_template); - + /// /// Write xl/sharedStrings.xml to internal archive based on shared strings in workbook. /// void write_shared_strings(); - + /// /// /// void write_images(); - + /// /// /// void write_charts(); - + /// /// /// void write_chartsheets(); - + /// /// /// void write_worksheets(); - + /// /// /// diff --git a/include/xlnt/s11n/manifest_serializer.hpp b/include/xlnt/s11n/manifest_serializer.hpp index 638eb60a..81e6e5b0 100644 --- a/include/xlnt/s11n/manifest_serializer.hpp +++ b/include/xlnt/s11n/manifest_serializer.hpp @@ -3,22 +3,22 @@ #include namespace xlnt { - + class manifest; class xml_document; class manifest_serializer { -public: + public: manifest_serializer(manifest &m); - + void read_manifest(const xml_document &xml); xml_document write_manifest() const; - + std::string determine_document_type() const; - -private: + + private: manifest &manifest_; }; - + }; // namespace xlnt diff --git a/include/xlnt/s11n/relationship_serializer.hpp b/include/xlnt/s11n/relationship_serializer.hpp index 0dc1222f..011fcf85 100644 --- a/include/xlnt/s11n/relationship_serializer.hpp +++ b/include/xlnt/s11n/relationship_serializer.hpp @@ -4,15 +4,16 @@ #include namespace xlnt { - + class relationship; class zip_file; class relationship_serializer { -public: + public: static std::vector read_relationships(zip_file &archive, const std::string &target); - static bool write_relationships(const std::vector &relationships, const std::string &target, zip_file &archive); + static bool write_relationships(const std::vector &relationships, const std::string &target, + zip_file &archive); }; - + } // namespace xlnt diff --git a/include/xlnt/s11n/shared_strings_serializer.hpp b/include/xlnt/s11n/shared_strings_serializer.hpp index c9c56fb0..bf0a10b1 100644 --- a/include/xlnt/s11n/shared_strings_serializer.hpp +++ b/include/xlnt/s11n/shared_strings_serializer.hpp @@ -27,12 +27,12 @@ #include namespace xlnt { - + class xml_document; class shared_strings_serializer { -public: + public: static bool read_shared_strings(const xml_document &xml, std::vector &strings); static xml_document write_shared_strings(const std::vector &strings); }; diff --git a/include/xlnt/s11n/style_serializer.hpp b/include/xlnt/s11n/style_serializer.hpp index 20b4db82..1b498193 100644 --- a/include/xlnt/s11n/style_serializer.hpp +++ b/include/xlnt/s11n/style_serializer.hpp @@ -44,180 +44,180 @@ class side; class style; class xml_document; class xml_node; - + /// /// Reads and writes xl/styles.xml from/to an associated workbook. /// class style_serializer { -public: + public: /// /// Construct a style_serializer which can write styles.xml based on wb or populate wb /// with styles from an existing styles.xml. style_serializer(workbook &wb); - + // // Primary methods // - + /// /// Load all styles from xml_document into workbook given in constructor. /// bool read_stylesheet(const xml_document &xml); - + /// /// Populate parameter xml with an XML tree representing the styles contained in the workbook /// given in the constructor. /// xml_document write_stylesheet() const; - -//TODO: These need to be public for unit tests. Could also make test class a friend? -//private: - + + // TODO: These need to be public for unit tests. Could also make test class a friend? + // private: + // // Static element readers (i.e. readers that don't use internal state) // - + /// /// Read and return an alignment from alignment_node. /// static alignment read_alignment(const xml_node &alignment_node); - + /// /// Read and return a border side from side_node. /// static side read_side(const xml_node &side_node); - + /// /// Read and return a border from border_node. /// static border read_border(const xml_node &border_node); - + /// /// Read and return a fill from fill_node. /// static fill read_fill(const xml_node &fill_node); - + /// /// Read and return a font from font_node. /// static font read_font(const xml_node &font_node); - + /// /// Read and return a number format from number_format_node. /// static number_format read_number_format(const xml_node &number_format_node); - + /// /// Read and return a protection from protection_node. /// static protection read_protection(const xml_node &protection_node); - + /// /// Read and return all indexed colors from indexed_colors_node. /// static std::vector read_indexed_colors(const xml_node &indexed_colors_node); - + /// /// Read and return a color from color_node. /// static color read_color(const xml_node &color_node); - + /// /// Read and return a conditional format, dxf, from conditional_format_node. /// static conditional_format read_conditional_format(const xml_node &conditional_formats_node); - + /// /// Read and return a pair containing a name and corresponding style from named_style_node. /// static std::pair read_named_style(const xml_node &named_style_node); - + // // Static element writers (i.e. writers that don't use internal state) // - + /// /// Build and return an xml tree representing alignment_. /// static xml_node write_alignment(const alignment &alignment_); - + /// /// Build and return an xml tree representing border_. /// static xml_node write_border(const border &border_); - + /// /// Build and return an xml tree representing conditional_format_. /// static xml_node write_conditional_format(const conditional_format &conditional_format_); - + /// /// Build and return an xml tree representing fill_. /// static xml_node write_fill(const fill &fill_); - + /// /// Build and return an xml tree representing font_. /// static xml_node write_font(const font &font_); - + /// /// Build and return two xml trees, first=cell style and second=named style, representing named_style_. /// static std::pair write_named_style(const named_style &named_style_); - + /// /// Build an xml tree representing all named styles in workbook into named_styles_node and cell_styles_node. /// Returns true on success. /// static std::pair write_named_styles(); - + /// /// Build and return an xml tree representing number_format_. /// static xml_node write_number_format(const number_format &number_format_); - + // // Non-static element readers (i.e. readers that modify internal state) // - + /// /// Read all borders from borders_node and add them to workbook. /// Return true on success. /// bool read_borders(const xml_node &borders_node); - + /// /// Read all fills from fills_node and add them to workbook. /// Return true on success. /// bool read_fills(const xml_node &fills_node); - + /// /// Read all fonts from fonts_node and add them to workbook. /// Return true on success. /// bool read_fonts(const xml_node &fonts_node); - + /// /// Read all colors from colors_node and add them to workbook. /// Return true on success. /// bool read_colors(const xml_node &colors_node); - + /// /// Read all named styles from named_style_node and cell_styles_node and add them to workbook. /// Return true on success. /// bool read_named_styles(const xml_node &named_styles_node); - + /// /// Read all borders from number_formats_node and add them to workbook. /// Return true on success. /// bool read_number_formats(const xml_node &number_formats_node); - + /// /// Read a single style from the given node. In styles.xml, this is an "xf" element. /// A style has an optional border id, fill id, font id, and number format id where @@ -227,48 +227,48 @@ public: /// "applyFont=0" will not use the font in formatting. /// style read_style(const xml_node &style_node); - + // // Non-static element writers (i.e. writers that modify internal workbook) // - + /// /// Build an xml tree representing all borders in workbook into borders_node. /// Returns true on success. /// bool write_borders(xml_node &borders_node) const; - + /// /// Build an xml tree representing all conditional formats in workbook into conditional_formats_node. /// Returns true on success. /// bool write_conditional_formats(xml_node &conditional_formats_node) const; - + /// /// Build an xml tree representing all fills in workbook into fills_node. /// Returns true on success. /// bool write_fills(xml_node &fills_node) const; - + /// /// Build an xml tree representing all fonts in workbook into fonts_node. /// Returns true on success. /// bool write_fonts(xml_node &fonts_node) const; - + /// /// Build an xml tree representing all number formats in workbook into number_formats_node. /// Returns true on success. /// bool write_number_formats(xml_node fonts_node) const; - + /// /// Build an xml tree representing the given style into style_node. /// Returns true on success. /// bool write_style(const style &style_, xml_node &style_node) const; - -private: + + private: /// /// Set in the constructor, this workbook is used as the source or target for all writing or reading, respectively. /// diff --git a/include/xlnt/s11n/theme_serializer.hpp b/include/xlnt/s11n/theme_serializer.hpp index cde79541..b8caa463 100644 --- a/include/xlnt/s11n/theme_serializer.hpp +++ b/include/xlnt/s11n/theme_serializer.hpp @@ -26,17 +26,17 @@ #include namespace xlnt { - + class theme; class xml_document; class theme_serializer { -public: + public: bool read_theme(const xml_document &xml, theme &t); xml_document write_theme(const theme &t) const; - -private: + + private: }; } // namespace xlnt diff --git a/include/xlnt/s11n/workbook_serializer.hpp b/include/xlnt/s11n/workbook_serializer.hpp index d97c26b9..c8fbb19f 100644 --- a/include/xlnt/s11n/workbook_serializer.hpp +++ b/include/xlnt/s11n/workbook_serializer.hpp @@ -36,28 +36,28 @@ class workbook; class zip_file; class xml_document; class xml_node; - + class workbook_serializer { -public: + public: using string_pair = std::pair; - + workbook_serializer(workbook &wb); - + void read_workbook(const xml_document &xml); void read_properties_app(const xml_document &xml); void read_properties_core(const xml_document &xml); - + xml_document write_workbook() const; xml_document write_properties_app() const; xml_document write_properties_core() const; - + std::vector read_sheets(); std::vector detect_worksheets(); - + xml_node write_named_ranges() const; - -private: + + private: workbook &workbook_; }; diff --git a/include/xlnt/s11n/worksheet_serializer.hpp b/include/xlnt/s11n/worksheet_serializer.hpp index 0a7ebdda..5181912c 100644 --- a/include/xlnt/s11n/worksheet_serializer.hpp +++ b/include/xlnt/s11n/worksheet_serializer.hpp @@ -29,7 +29,7 @@ #include namespace xlnt { - + class relationship; class workbook; class worksheet; @@ -37,13 +37,13 @@ class xml_document; class worksheet_serializer { -public: + public: worksheet_serializer(worksheet sheet); - + bool read_worksheet(const xml_document &xml); xml_document write_worksheet() const; - -private: + + private: worksheet sheet_; }; diff --git a/include/xlnt/s11n/xml_document.hpp b/include/xlnt/s11n/xml_document.hpp index 974e88ba..f093d81a 100644 --- a/include/xlnt/s11n/xml_document.hpp +++ b/include/xlnt/s11n/xml_document.hpp @@ -8,39 +8,39 @@ namespace xlnt { namespace detail { struct xml_document_impl; } // namespace detail - + class xml_node; class xml_serializer; class xml_document { -public: + public: using string_pair = std::pair; - + xml_document(); xml_document(const xml_document &other); xml_document(xml_document &&other); ~xml_document(); - + xml_document &operator=(const xml_document &other); xml_document &operator=(xml_document &&other); - + void set_encoding(const std::string &encoding); void add_namespace(const std::string &id, const std::string &uri); - + xml_node add_child(const xml_node &child); xml_node add_child(const std::string &child_name); - + xml_node get_root(); const xml_node get_root() const; - + xml_node get_child(const std::string &child_name); const xml_node get_child(const std::string &child_name) const; - + std::string to_string() const; xml_document &from_string(const std::string &xml_string); - -private: + + private: friend class xml_serializer; std::unique_ptr d_; }; diff --git a/include/xlnt/s11n/xml_node.hpp b/include/xlnt/s11n/xml_node.hpp index 9b1b2c83..baaa743a 100644 --- a/include/xlnt/s11n/xml_node.hpp +++ b/include/xlnt/s11n/xml_node.hpp @@ -8,42 +8,42 @@ namespace xlnt { namespace detail { struct xml_node_impl; } // namespace detail - + class xml_document; - + class xml_node { -public: + public: using string_pair = std::pair; - + xml_node(); xml_node(const xml_node &other); ~xml_node(); - + xml_node &operator=(const xml_node &other); - + std::string get_name() const; void set_name(const std::string &name); - + bool has_text() const; std::string get_text() const; void set_text(const std::string &text); - + const std::vector get_children() const; bool has_child(const std::string &child_name) const; xml_node get_child(const std::string &child_name); const xml_node get_child(const std::string &child_name) const; xml_node add_child(const xml_node &child); xml_node add_child(const std::string &child_name); - + const std::vector get_attributes() const; bool has_attribute(const std::string &attribute_name) const; std::string get_attribute(const std::string &attribute_name) const; void add_attribute(const std::string &name, const std::string &value); - + std::string to_string() const; - -private: + + private: friend class xml_document; friend class xml_serializer; xml_node(const detail::xml_node_impl &d); diff --git a/include/xlnt/s11n/xml_serializer.hpp b/include/xlnt/s11n/xml_serializer.hpp index c5d79664..4ec7fa23 100644 --- a/include/xlnt/s11n/xml_serializer.hpp +++ b/include/xlnt/s11n/xml_serializer.hpp @@ -9,7 +9,7 @@ class xml_node; class xml_serializer { -public: + public: static std::string serialize(const xml_document &xml); static xml_document deserialize(const std::string &xml_string); diff --git a/include/xlnt/styles/alignment.hpp b/include/xlnt/styles/alignment.hpp index 9dfa5b11..0f14d368 100644 --- a/include/xlnt/styles/alignment.hpp +++ b/include/xlnt/styles/alignment.hpp @@ -32,7 +32,7 @@ namespace xlnt { /// class alignment { -public: + public: enum class horizontal_alignment { none, @@ -43,7 +43,7 @@ public: center_continuous, justify }; - + enum class vertical_alignment { none, @@ -52,52 +52,52 @@ public: center, justify }; - + bool get_wrap_text() const { return wrap_text_; } - + void set_wrap_text(bool wrap_text) { wrap_text_ = wrap_text; } - + bool has_horizontal() const { return horizontal_ != horizontal_alignment::none; } - + horizontal_alignment get_horizontal() const { return horizontal_; } - + void set_horizontal(horizontal_alignment horizontal) { horizontal_ = horizontal; } - + bool has_vertical() const { return vertical_ != vertical_alignment::none; } - + vertical_alignment get_vertical() const { return vertical_; } - + void set_vertical(vertical_alignment vertical) { vertical_ = vertical; } - + bool operator==(const alignment &other) const { return hash() == other.hash(); } - + std::size_t hash() const { std::size_t seed = 0; @@ -109,8 +109,8 @@ public: hash_combine(seed, indent_); return seed; } - -private: + + private: horizontal_alignment horizontal_ = horizontal_alignment::none; vertical_alignment vertical_ = vertical_alignment::none; int text_rotation_ = 0; diff --git a/include/xlnt/styles/border.hpp b/include/xlnt/styles/border.hpp index c59a6980..db354738 100644 --- a/include/xlnt/styles/border.hpp +++ b/include/xlnt/styles/border.hpp @@ -30,7 +30,7 @@ #include "../common/hash_combine.hpp" namespace xlnt { - + enum class diagonal_direction { none, @@ -38,12 +38,12 @@ enum class diagonal_direction down, both }; - + class border { -public: + public: static border default_border(); - + bool start_assigned = false; side start; bool end_assigned = false; @@ -66,36 +66,36 @@ public: bool outline = false; bool diagonal_up = false; bool diagonal_down = false; - + diagonal_direction diagonal_direction_ = diagonal_direction::none; - + bool operator==(const border &other) const { return hash() == other.hash(); } - + std::size_t hash() const { std::size_t seed = 0; - + hash_combine(seed, start_assigned); - if(start_assigned) hash_combine(seed, start.hash()); + if (start_assigned) hash_combine(seed, start.hash()); hash_combine(seed, end_assigned); - if(end_assigned) hash_combine(seed, end.hash()); + if (end_assigned) hash_combine(seed, end.hash()); hash_combine(seed, left_assigned); - if(left_assigned) hash_combine(seed, left.hash()); + if (left_assigned) hash_combine(seed, left.hash()); hash_combine(seed, right_assigned); - if(right_assigned) hash_combine(seed, right.hash()); + if (right_assigned) hash_combine(seed, right.hash()); hash_combine(seed, top_assigned); - if(top_assigned) hash_combine(seed, top.hash()); + if (top_assigned) hash_combine(seed, top.hash()); hash_combine(seed, bottom_assigned); - if(bottom_assigned) hash_combine(seed, bottom.hash()); + if (bottom_assigned) hash_combine(seed, bottom.hash()); hash_combine(seed, diagonal_assigned); - if(diagonal_assigned) hash_combine(seed, diagonal.hash()); + if (diagonal_assigned) hash_combine(seed, diagonal.hash()); hash_combine(seed, vertical_assigned); - if(vertical_assigned) hash_combine(seed, vertical.hash()); + if (vertical_assigned) hash_combine(seed, vertical.hash()); hash_combine(seed, horizontal_assigned); - if(horizontal_assigned) hash_combine(seed, horizontal.hash()); + if (horizontal_assigned) hash_combine(seed, horizontal.hash()); return seed; } diff --git a/include/xlnt/styles/color.hpp b/include/xlnt/styles/color.hpp index 9fb7a099..4606e510 100644 --- a/include/xlnt/styles/color.hpp +++ b/include/xlnt/styles/color.hpp @@ -31,7 +31,7 @@ namespace xlnt { class color { -public: + public: enum class type { indexed, @@ -39,7 +39,7 @@ public: auto_, rgb }; - + static const color black; static const color white; static const color red; @@ -50,85 +50,87 @@ public: static const color darkgreen; static const color yellow; static const color darkyellow; - - color() {} - + + color() + { + } + color(type t, std::size_t v) : type_(t), index_(v) { } - + color(type t, const std::string &v) : type_(t), rgb_string_(v) { } - + void set_auto(int auto_index) { type_ = type::auto_; index_ = auto_index; } - + void set_index(int index) { type_ = type::indexed; index_ = index; } - + void set_theme(int theme) { type_ = type::theme; index_ = theme; } - + type get_type() const { return type_; } - + int get_auto() const { - if(type_ != type::auto_) + if (type_ != type::auto_) { throw std::runtime_error("not auto color"); } - + return index_; } - + int get_index() const { - if(type_ != type::indexed) + if (type_ != type::indexed) { throw std::runtime_error("not indexed color"); } - + return index_; } - + int get_theme() const { - if(type_ != type::theme) + if (type_ != type::theme) { throw std::runtime_error("not theme color"); } - + return index_; } - + std::string get_rgb_string() const { - if(type_ != type::rgb) + if (type_ != type::rgb) { throw std::runtime_error("not rgb color"); } - + return rgb_string_; } - + std::size_t hash() const { auto seed = static_cast(type_); - - if(type_ != type::rgb) + + if (type_ != type::rgb) { hash_combine(seed, index_); } @@ -136,16 +138,16 @@ public: { hash_combine(seed, rgb_string_); } - + return seed; } - + bool operator==(const color &other) const { return hash() == other.hash(); } - -private: + + private: type type_ = type::indexed; int index_ = 0; std::string rgb_string_; diff --git a/include/xlnt/styles/fill.hpp b/include/xlnt/styles/fill.hpp index 70b2b26e..bd8804ef 100644 --- a/include/xlnt/styles/fill.hpp +++ b/include/xlnt/styles/fill.hpp @@ -30,7 +30,7 @@ namespace xlnt { class fill { -public: + public: enum class type { none, @@ -38,13 +38,13 @@ public: gradient, pattern }; - + enum class gradient_type { linear, path }; - + enum class pattern_type { none, @@ -67,147 +67,176 @@ public: lightvertical, mediumgray, }; - - type get_type() const { return type_; } - void set_type(type t) { type_ = t; } - + + type get_type() const + { + return type_; + } + void set_type(type t) + { + type_ = t; + } + std::string get_pattern_type_string() const { - if(type_ != type::pattern) + if (type_ != type::pattern) { throw std::runtime_error("not pattern fill"); } - - switch(pattern_type_) + + switch (pattern_type_) { - case pattern_type::none: return "none"; - case pattern_type::solid: return "solid"; - case pattern_type::darkdown: return "darkdown"; - case pattern_type::darkgray: return "darkgray"; - case pattern_type::darkgrid: return "darkgrid"; - case pattern_type::darkhorizontal: return "darkhorizontal"; - case pattern_type::darktrellis: return "darktrellis"; - case pattern_type::darkup: return "darkup"; - case pattern_type::darkvertical: return "darkvertical"; - case pattern_type::gray0625: return "gray0625"; - case pattern_type::gray125: return "gray125"; - case pattern_type::lightdown: return "lightdown"; - case pattern_type::lightgray: return "lightgray"; - case pattern_type::lightgrid: return "lightgrid"; - case pattern_type::lighthorizontal: return "lighthorizontal"; - case pattern_type::lighttrellis: return "lighttrellis"; - case pattern_type::lightup: return "lightup"; - case pattern_type::lightvertical: return "lightvertical"; - case pattern_type::mediumgray: return "mediumgray"; - default: throw std::runtime_error("invalid type"); + case pattern_type::none: + return "none"; + case pattern_type::solid: + return "solid"; + case pattern_type::darkdown: + return "darkdown"; + case pattern_type::darkgray: + return "darkgray"; + case pattern_type::darkgrid: + return "darkgrid"; + case pattern_type::darkhorizontal: + return "darkhorizontal"; + case pattern_type::darktrellis: + return "darktrellis"; + case pattern_type::darkup: + return "darkup"; + case pattern_type::darkvertical: + return "darkvertical"; + case pattern_type::gray0625: + return "gray0625"; + case pattern_type::gray125: + return "gray125"; + case pattern_type::lightdown: + return "lightdown"; + case pattern_type::lightgray: + return "lightgray"; + case pattern_type::lightgrid: + return "lightgrid"; + case pattern_type::lighthorizontal: + return "lighthorizontal"; + case pattern_type::lighttrellis: + return "lighttrellis"; + case pattern_type::lightup: + return "lightup"; + case pattern_type::lightvertical: + return "lightvertical"; + case pattern_type::mediumgray: + return "mediumgray"; + default: + throw std::runtime_error("invalid type"); } } - + std::string get_gradient_type_string() const { - if(type_ != type::gradient) + if (type_ != type::gradient) { throw std::runtime_error("not gradient fill"); } - - switch(gradient_type_) + + switch (gradient_type_) { - case gradient_type::linear: return "linear"; - case gradient_type::path: return "path"; - default: throw std::runtime_error("invalid type"); + case gradient_type::linear: + return "linear"; + case gradient_type::path: + return "path"; + default: + throw std::runtime_error("invalid type"); } } - + pattern_type get_pattern_type() const { return pattern_type_; } - + void set_pattern_type(pattern_type t) { type_ = type::pattern; pattern_type_ = t; } - + void set_gradient_type(gradient_type t) { type_ = type::gradient; gradient_type_ = t; } - + void set_start_color(const color &c) { start_color_ = c; start_color_assigned_ = true; } - + void set_end_color(const color &c) { end_color_ = c; end_color_assigned_ = true; } - + void set_foreground_color(const color &c) { foreground_color_ = c; foreground_color_assigned_ = true; } - + void set_background_color(const color &c) { background_color_ = c; background_color_assigned_ = true; } - + color get_foreground_color() const { return foreground_color_; } - + color get_background_color() const { return background_color_; } - + bool has_foreground_color() const { return foreground_color_assigned_; } - + bool has_background_color() const { return background_color_assigned_; } - + bool operator==(const fill &other) const { return hash() == other.hash(); } - + void set_rotation(double rotation) { rotation_ = rotation; } - + double get_rotation() const { return rotation_; } - + std::size_t hash() const { auto seed = static_cast(type_); - - if(type_ == type::pattern) + + if (type_ == type::pattern) { hash_combine(seed, static_cast(pattern_type_)); hash_combine(seed, foreground_color_assigned_); - - if(foreground_color_assigned_) + + if (foreground_color_assigned_) { hash_combine(seed, static_cast(foreground_color_.get_type())); - - switch(foreground_color_.get_type()) + + switch (foreground_color_.get_type()) { case color::type::auto_: hash_combine(seed, static_cast(foreground_color_.get_auto())); @@ -222,59 +251,71 @@ public: break; } } - + hash_combine(seed, background_color_assigned_); - - if(background_color_assigned_) + + if (background_color_assigned_) { hash_combine(seed, static_cast(background_color_.get_type())); - - switch(foreground_color_.get_type()) + + switch (foreground_color_.get_type()) { - case color::type::auto_: - hash_combine(seed, static_cast(background_color_.get_auto())); - break; - case color::type::indexed: - hash_combine(seed, static_cast(background_color_.get_index())); - break; - case color::type::theme: - hash_combine(seed, static_cast(background_color_.get_theme())); - break; - case color::type::rgb: - break; + case color::type::auto_: + hash_combine(seed, static_cast(background_color_.get_auto())); + break; + case color::type::indexed: + hash_combine(seed, static_cast(background_color_.get_index())); + break; + case color::type::theme: + hash_combine(seed, static_cast(background_color_.get_theme())); + break; + case color::type::rgb: + break; } } } - else if(type_ == type::gradient) + else if (type_ == type::gradient) { hash_combine(seed, static_cast(gradient_type_)); - - if(gradient_type_ == gradient_type::path) + + if (gradient_type_ == gradient_type::path) { hash_combine(seed, gradient_path_left_); hash_combine(seed, gradient_path_right_); hash_combine(seed, gradient_path_top_); hash_combine(seed, gradient_path_bottom_); } - else if(gradient_type_ == gradient_type::linear) + else if (gradient_type_ == gradient_type::linear) { hash_combine(seed, rotation_); } } - else if(type_ == type::solid) + else if (type_ == type::solid) { -// hash_combine(seed, static_cast()); + // hash_combine(seed, static_cast()); } - + return seed; } - - double get_gradient_left() const { return gradient_path_left_; } - double get_gradient_right() const { return gradient_path_right_; } - double get_gradient_top() const { return gradient_path_top_; } - double get_gradient_bottom() const { return gradient_path_bottom_; } - -private: + + double get_gradient_left() const + { + return gradient_path_left_; + } + double get_gradient_right() const + { + return gradient_path_right_; + } + double get_gradient_top() const + { + return gradient_path_top_; + } + double get_gradient_bottom() const + { + return gradient_path_bottom_; + } + + private: type type_ = type::none; pattern_type pattern_type_; gradient_type gradient_type_; diff --git a/include/xlnt/styles/font.hpp b/include/xlnt/styles/font.hpp index bf64c683..b4f154fc 100644 --- a/include/xlnt/styles/font.hpp +++ b/include/xlnt/styles/font.hpp @@ -29,12 +29,12 @@ #include namespace xlnt { - + class style; class font { -public: + public: enum class underline_style { none, @@ -43,37 +43,99 @@ public: single, single_accounting }; - - void set_bold(bool bold) { bold_ = bold; } - bool is_bold() const { return bold_; } - - void set_italic(bool italic) { italic_ = italic; } - bool is_italic() const { return italic_; } - - void set_strikethrough(bool strikethrough) { strikethrough_ = strikethrough; } - bool is_strikethrough() const { return strikethrough_; } - - void set_underline(underline_style new_underline) { underline_ = new_underline; } - bool is_underline() const { return underline_ != underline_style::none; } - underline_style get_underline() const { return underline_; } - - void set_size(int size) { size_ = size; } - int get_size() const { return size_; } - - void set_name(const std::string &name) { name_ = name; } - std::string get_name() const { return name_; } - - void set_color(color c) { color_ = c; } - void set_family(int family) { has_family_ = true; family_ = family; } - void set_scheme(const std::string &scheme) { has_scheme_ = true; scheme_ = scheme; } - - color get_color() const { return color_; } - - bool has_family() const { return has_family_; } - int get_family() const { return family_; } - - bool has_scheme() const { return has_scheme_; } - + + void set_bold(bool bold) + { + bold_ = bold; + } + bool is_bold() const + { + return bold_; + } + + void set_italic(bool italic) + { + italic_ = italic; + } + bool is_italic() const + { + return italic_; + } + + void set_strikethrough(bool strikethrough) + { + strikethrough_ = strikethrough; + } + bool is_strikethrough() const + { + return strikethrough_; + } + + void set_underline(underline_style new_underline) + { + underline_ = new_underline; + } + bool is_underline() const + { + return underline_ != underline_style::none; + } + underline_style get_underline() const + { + return underline_; + } + + void set_size(int size) + { + size_ = size; + } + int get_size() const + { + return size_; + } + + void set_name(const std::string &name) + { + name_ = name; + } + std::string get_name() const + { + return name_; + } + + void set_color(color c) + { + color_ = c; + } + void set_family(int family) + { + has_family_ = true; + family_ = family; + } + void set_scheme(const std::string &scheme) + { + has_scheme_ = true; + scheme_ = scheme; + } + + color get_color() const + { + return color_; + } + + bool has_family() const + { + return has_family_; + } + int get_family() const + { + return family_; + } + + bool has_scheme() const + { + return has_scheme_; + } + std::size_t hash() const { std::size_t seed = bold_; @@ -85,39 +147,44 @@ public: hash_combine(seed, size_); hash_combine(seed, static_cast(underline_)); hash_combine(seed, static_cast(color_.get_type())); - switch(color_.get_type()) + switch (color_.get_type()) { - case color::type::indexed: hash_combine(seed, color_.get_index()); break; - case color::type::theme: hash_combine(seed, color_.get_theme()); break; - default: break; + case color::type::indexed: + hash_combine(seed, color_.get_index()); + break; + case color::type::theme: + hash_combine(seed, color_.get_theme()); + break; + default: + break; } hash_combine(seed, family_); hash_combine(seed, scheme_); - + return seed; } - + bool operator==(const font &other) const { return hash() == other.hash(); } - -private: + + private: friend class style; - - std::string name_ = "Calibri"; - int size_ = 11; - bool bold_ = false; - bool italic_ = false; - bool superscript_ = false; - bool subscript_ = false; - underline_style underline_ = underline_style::none; - bool strikethrough_ = false; - color color_; - bool has_family_ = false; - int family_; - bool has_scheme_ = false; - std::string scheme_; + + std::string name_ = "Calibri"; + int size_ = 11; + bool bold_ = false; + bool italic_ = false; + bool superscript_ = false; + bool subscript_ = false; + underline_style underline_ = underline_style::none; + bool strikethrough_ = false; + color color_; + bool has_family_ = false; + int family_; + bool has_scheme_ = false; + std::string scheme_; }; } // namespace xlnt diff --git a/include/xlnt/styles/named_style.hpp b/include/xlnt/styles/named_style.hpp index 56e0da11..352d46e4 100644 --- a/include/xlnt/styles/named_style.hpp +++ b/include/xlnt/styles/named_style.hpp @@ -29,17 +29,17 @@ namespace xlnt { class named_style { -public: + public: named_style(); - + std::size_t hash() const; - + bool operator==(const named_style &other) const { return style_.hash() == other.style_.hash(); } - -private: + + private: std::string name_; style style_; }; diff --git a/include/xlnt/styles/number_format.hpp b/include/xlnt/styles/number_format.hpp index 0cb53ff4..f342816e 100644 --- a/include/xlnt/styles/number_format.hpp +++ b/include/xlnt/styles/number_format.hpp @@ -31,7 +31,7 @@ namespace xlnt { class number_format { -public: + public: static const number_format general(); static const number_format text(); static const number_format number(); @@ -68,25 +68,31 @@ public: static const number_format currency_eur_simple(); static number_format from_builtin_id(int builtin_id); - + number_format(); number_format(int builtin_id); number_format(const std::string &code, int custom_id = -1); - + void set_format_string(const std::string &format_code, int id = -1); std::string get_format_string() const; - void set_id(int id) { id_ = id; } - int get_id() const { return id_; } - + void set_id(int id) + { + id_ = id; + } + int get_id() const + { + return id_; + } + std::size_t hash() const; - + bool operator==(const number_format &other) const { return hash() == other.hash(); } -private: + private: int id_; std::string format_string_; }; diff --git a/include/xlnt/styles/protection.hpp b/include/xlnt/styles/protection.hpp index a64315cd..42286c6d 100644 --- a/include/xlnt/styles/protection.hpp +++ b/include/xlnt/styles/protection.hpp @@ -31,41 +31,41 @@ namespace xlnt { class protection { -public: + public: enum class type { inherit, protected_, unprotected }; - + protection(); protection(type locked); - + void set_locked(type locked_type) { locked_ = locked_type; } - + void set_hidden(type hidden_type) { hidden_ = hidden_type; } - + bool operator==(const protection &other) const { return hash() == other.hash(); } - + std::size_t hash() const { std::size_t seed = static_cast(locked_); hash_combine(seed, static_cast(hidden_)); - + return seed; } - -private: + + private: type locked_; type hidden_; }; diff --git a/include/xlnt/styles/side.hpp b/include/xlnt/styles/side.hpp index 4939b8d8..fd536d39 100644 --- a/include/xlnt/styles/side.hpp +++ b/include/xlnt/styles/side.hpp @@ -49,72 +49,72 @@ enum class border_style class side { -public: + public: side(); - + std::size_t hash() const { std::size_t seed = 0; - + hash_combine(seed, style_assigned_); - - if(style_assigned_) + + if (style_assigned_) { hash_combine(seed, static_cast(style_)); } - + hash_combine(seed, color_assigned_); - - if(color_assigned_) + + if (color_assigned_) { hash_combine(seed, color_.hash()); } - + return seed; } - + border_style get_style() const { return style_; } - + color get_color() const { return color_; } - + bool is_style_assigned() const { return style_assigned_; } - + bool is_color_assigned() const { return color_assigned_; } - + bool operator==(const side &other) const { return other.style_ == style_ && color_ == other.color_; } - + void set_border_style(border_style bs) { style_assigned_ = true; style_ = bs; } - + void set_color(color new_color) { color_assigned_ = true; color_ = new_color; } - -private: + + private: bool style_assigned_ = false; border_style style_ = border_style::none; bool color_assigned_ = false; color color_ = color::black; }; - + } // namespace xlnt diff --git a/include/xlnt/styles/style.hpp b/include/xlnt/styles/style.hpp index b84202a7..680f0b88 100644 --- a/include/xlnt/styles/style.hpp +++ b/include/xlnt/styles/style.hpp @@ -36,13 +36,13 @@ class workbook; class style { -public: + public: style(); style(const style &other); style &operator=(const style &other); - + std::size_t hash() const; - + const alignment get_alignment() const; const border get_border() const; const fill get_fill() const; @@ -51,54 +51,87 @@ public: const protection get_protection() const; bool pivot_button() const; bool quote_prefix() const; - - std::size_t get_id() const { return id_; } - - std::size_t get_fill_id() const { return fill_id_; } - std::size_t get_font_id() const { return font_id_; } - std::size_t get_border_id() const { return border_id_; } - std::size_t get_number_format_id() const { return number_format_id_; } - - void apply_alignment(bool apply) { alignment_apply_ = apply; } - void apply_border(bool apply) { border_apply_ = apply; } - void apply_fill(bool apply) { fill_apply_ = apply; } - void apply_font(bool apply) { font_apply_ = apply; } - void apply_number_format(bool apply) { number_format_apply_ = apply; } - void apply_protection(bool apply) { protection_apply_ = apply; } - + + std::size_t get_id() const + { + return id_; + } + + std::size_t get_fill_id() const + { + return fill_id_; + } + std::size_t get_font_id() const + { + return font_id_; + } + std::size_t get_border_id() const + { + return border_id_; + } + std::size_t get_number_format_id() const + { + return number_format_id_; + } + + void apply_alignment(bool apply) + { + alignment_apply_ = apply; + } + void apply_border(bool apply) + { + border_apply_ = apply; + } + void apply_fill(bool apply) + { + fill_apply_ = apply; + } + void apply_font(bool apply) + { + font_apply_ = apply; + } + void apply_number_format(bool apply) + { + number_format_apply_ = apply; + } + void apply_protection(bool apply) + { + protection_apply_ = apply; + } + bool operator==(const style &other) const { return hash() == other.hash(); } - -private: + + private: friend class style_serializer; friend class workbook; - + std::size_t id_; - + bool alignment_apply_; alignment alignment_; - + bool border_apply_; std::size_t border_id_; border border_; - + bool fill_apply_; std::size_t fill_id_; fill fill_; - + bool font_apply_; std::size_t font_id_; font font_; - + bool number_format_apply_; std::size_t number_format_id_; number_format number_format_; - + bool protection_apply_; protection protection_; - + bool pivot_button_; bool quote_prefix_; }; diff --git a/include/xlnt/workbook/document_properties.hpp b/include/xlnt/workbook/document_properties.hpp index 46196fb8..e277b375 100644 --- a/include/xlnt/workbook/document_properties.hpp +++ b/include/xlnt/workbook/document_properties.hpp @@ -34,9 +34,9 @@ namespace xlnt { /// class document_properties { -public: + public: document_properties(); - + std::string creator; std::string last_modified_by; datetime created; diff --git a/include/xlnt/workbook/document_security.hpp b/include/xlnt/workbook/document_security.hpp index 59df1e09..0b11ff1d 100644 --- a/include/xlnt/workbook/document_security.hpp +++ b/include/xlnt/workbook/document_security.hpp @@ -26,20 +26,20 @@ #include namespace xlnt { - + /// /// Security information about the document. /// class document_security { -public: + public: document_security(); - + bool lock_revision; bool lock_structure; bool lock_windows; std::string revision_password; std::string workbook_password; }; - + } // namespace xlnt diff --git a/include/xlnt/workbook/external_book.hpp b/include/xlnt/workbook/external_book.hpp index 59c1143f..ad5add95 100644 --- a/include/xlnt/workbook/external_book.hpp +++ b/include/xlnt/workbook/external_book.hpp @@ -2,8 +2,7 @@ namespace xlnt { -class external_book { - +class external_book +{ }; - } diff --git a/include/xlnt/workbook/manifest.hpp b/include/xlnt/workbook/manifest.hpp index 061ad655..73a2cf0d 100644 --- a/include/xlnt/workbook/manifest.hpp +++ b/include/xlnt/workbook/manifest.hpp @@ -4,57 +4,75 @@ #include namespace xlnt { - + class default_type { -public: + public: default_type(); default_type(const std::string &extension, const std::string &content_type); default_type(const default_type &other); default_type &operator=(const default_type &other); - - std::string get_extension() const { return extension_; } - std::string get_content_type() const { return content_type_; } - -private: + + std::string get_extension() const + { + return extension_; + } + std::string get_content_type() const + { + return content_type_; + } + + private: std::string extension_; std::string content_type_; }; class override_type { -public: + public: override_type(); override_type(const std::string &extension, const std::string &content_type); override_type(const override_type &other); override_type &operator=(const override_type &other); - - std::string get_part_name() const { return part_name_; } - std::string get_content_type() const { return content_type_; } - -private: + + std::string get_part_name() const + { + return part_name_; + } + std::string get_content_type() const + { + return content_type_; + } + + private: std::string part_name_; std::string content_type_; }; class manifest { -public: + public: void add_default_type(const std::string &extension, const std::string &content_type); void add_override_type(const std::string &part_name, const std::string &content_type); - - const std::vector &get_default_types() const { return default_types_; } - const std::vector &get_override_types() const { return override_types_; } - + + const std::vector &get_default_types() const + { + return default_types_; + } + const std::vector &get_override_types() const + { + return override_types_; + } + bool has_default_type(const std::string &extension) const; bool has_override_type(const std::string &part_name) const; - + std::string get_default_type(const std::string &extension) const; std::string get_override_type(const std::string &part_name) const; - -private: + + private: std::vector default_types_; std::vector override_types_; }; - + } // namespace xlnt \ No newline at end of file diff --git a/include/xlnt/workbook/named_range.hpp b/include/xlnt/workbook/named_range.hpp index c7e3c546..e08a19b9 100644 --- a/include/xlnt/workbook/named_range.hpp +++ b/include/xlnt/workbook/named_range.hpp @@ -7,26 +7,31 @@ namespace xlnt { class range_reference; class worksheet; - + std::vector> split_named_range(const std::string &named_range_string); - + class named_range { -public: + public: using target = std::pair; - + named_range(); named_range(const named_range &other); named_range(const std::string &name, const std::vector &targets); - - std::string get_name() const { return name_; } - const std::vector &get_targets() const { return targets_; } - + + std::string get_name() const + { + return name_; + } + const std::vector &get_targets() const + { + return targets_; + } + named_range &operator=(const named_range &other); - -private: + + private: std::string name_; std::vector targets_; }; - } diff --git a/include/xlnt/workbook/theme.hpp b/include/xlnt/workbook/theme.hpp index 2025fe31..4fef7a22 100644 --- a/include/xlnt/workbook/theme.hpp +++ b/include/xlnt/workbook/theme.hpp @@ -4,7 +4,6 @@ namespace xlnt { class theme { - }; - + } // namespace xlnt diff --git a/include/xlnt/workbook/workbook.hpp b/include/xlnt/workbook/workbook.hpp index a9334a1f..5d097642 100644 --- a/include/xlnt/workbook/workbook.hpp +++ b/include/xlnt/workbook/workbook.hpp @@ -52,11 +52,11 @@ class style; class theme; class worksheet; class zip_file; - + enum class encoding; -namespace detail { - struct workbook_impl; +namespace detail { +struct workbook_impl; } // namespace detail /// @@ -64,51 +64,57 @@ namespace detail { /// class workbook { -public: + public: class iterator { - public: + public: iterator(workbook &wb, std::size_t index); iterator(const iterator &); iterator &operator=(const iterator &); worksheet operator*(); bool operator==(const iterator &comparand) const; - bool operator!=(const iterator &comparand) const { return !(*this == comparand); } + bool operator!=(const iterator &comparand) const + { + return !(*this == comparand); + } iterator operator++(int); iterator &operator++(); - private: + private: workbook &wb_; std::size_t index_; }; class const_iterator { - public: + public: const_iterator(const workbook &wb, std::size_t index); const_iterator(const const_iterator &); const_iterator &operator=(const const_iterator &); const worksheet operator*(); bool operator==(const const_iterator &comparand) const; - bool operator!=(const const_iterator &comparand) const { return !(*this == comparand); } + bool operator!=(const const_iterator &comparand) const + { + return !(*this == comparand); + } const_iterator operator++(int); const_iterator &operator++(); - private: + private: const workbook &wb_; std::size_t index_; }; - + static std::size_t index_from_ws_filename(const std::string &filename); - //constructors + // constructors workbook(); workbook(encoding e); - + workbook &operator=(workbook other); workbook(workbook &&other); workbook(const workbook &other); - + friend void swap(workbook &left, workbook &right); worksheet get_active_sheet(); @@ -118,80 +124,86 @@ public: bool get_data_only() const; void set_data_only(bool data_only); - - //create + + // create worksheet create_sheet(); worksheet create_sheet(std::size_t index); worksheet create_sheet(const std::string &title); worksheet create_sheet(std::size_t index, const std::string &title); - worksheet create_sheet(const std::string &title, const relationship &rel); - - //add + worksheet create_sheet(const std::string &title, const relationship &rel); + + // add void add_sheet(worksheet worksheet); void add_sheet(worksheet worksheet, std::size_t index); - - //remove + + // remove void remove_sheet(worksheet worksheet); void clear(); - - //container operations + + // container operations worksheet get_sheet_by_name(const std::string &sheet_name); const worksheet get_sheet_by_name(const std::string &sheet_name) const; worksheet get_sheet_by_index(std::size_t index); const worksheet get_sheet_by_index(std::size_t index) const; bool contains(const std::string &key) const; int get_index(worksheet worksheet); - + worksheet operator[](const std::string &name); worksheet operator[](std::size_t index); - + iterator begin(); iterator end(); - - const_iterator begin() const { return cbegin(); } - const_iterator end() const { return cend(); } - + + const_iterator begin() const + { + return cbegin(); + } + const_iterator end() const + { + return cend(); + } + const_iterator cbegin() const; const_iterator cend() const; - + std::vector get_sheet_names() const; - + document_properties &get_properties(); const document_properties &get_properties() const; - - //named ranges + + // named ranges std::vector get_named_ranges() const; void create_named_range(const std::string &name, worksheet worksheet, const range_reference &reference); bool has_named_range(const std::string &name) const; range get_named_range(const std::string &name); void remove_named_range(const std::string &name); - - //serialization + + // serialization bool save(std::vector &data); bool save(const std::string &filename); bool load(const std::vector &data); bool load(const std::string &filename); bool load(std::istream &stream); bool load(zip_file &archive); - + bool operator==(const workbook &rhs) const; - + bool operator!=(const workbook &rhs) const { return !(*this == rhs); } - + bool operator==(std::nullptr_t) const; - + bool operator!=(std::nullptr_t) const { return !(*this == std::nullptr_t{}); } - - void create_relationship(const std::string &id, const std::string &target, relationship::type type); - relationship get_relationship(const std::string &id) const; + + void create_relationship(const std::string &id, const std::string &target, relationship::type type); + relationship get_relationship(const std::string &id) const; const std::vector &get_relationships() const; - + void add_alignment(const alignment &a); void add_border(const border &b); void add_fill(const fill &f); @@ -199,18 +211,18 @@ public: void add_color(const color &c); void add_number_format(const number_format &format); void add_protection(const protection &p); - + std::vector