From f9a45313a06dab0e75a9a7636fa973f5e0ab4d66 Mon Sep 17 00:00:00 2001 From: Thomas Fussell Date: Thu, 18 Aug 2016 07:34:18 -0400 Subject: [PATCH] improve styles --- include/xlnt/cell/cell.hpp | 23 +- include/xlnt/styles/alignment.hpp | 4 +- include/xlnt/styles/base_format.hpp | 82 +-- include/xlnt/styles/format.hpp | 36 +- include/xlnt/styles/style.hpp | 18 +- source/cell/cell.cpp | 160 ++++- source/cell/comment.cpp | 4 +- source/cell/tests/test_cell.hpp | 70 +- source/detail/format_impl.hpp | 16 +- source/detail/style_impl.hpp | 4 +- source/detail/stylesheet.hpp | 46 +- source/detail/workbook_impl.hpp | 10 +- source/detail/xlsx_consumer.cpp | 233 +++---- source/detail/xlsx_producer.cpp | 716 +++++++++++--------- source/detail/xlsx_producer.hpp | 9 + source/styles/alignment.cpp | 26 + source/styles/base_format.cpp | 153 +---- source/styles/border.cpp | 29 +- source/styles/font.cpp | 9 + source/styles/format.cpp | 76 ++- source/styles/number_format.cpp | 9 +- source/styles/protection.cpp | 6 + source/styles/style.cpp | 31 +- source/styles/tests/test_alignment.hpp | 23 +- source/workbook/tests/test_produce_xlsx.hpp | 81 +++ source/workbook/tests/test_workbook.hpp | 7 +- source/workbook/workbook.cpp | 167 +++-- source/worksheet/worksheet.cpp | 2 +- 28 files changed, 1212 insertions(+), 838 deletions(-) diff --git a/include/xlnt/cell/cell.hpp b/include/xlnt/cell/cell.hpp index 89fedffc..bb1225c5 100644 --- a/include/xlnt/cell/cell.hpp +++ b/include/xlnt/cell/cell.hpp @@ -36,6 +36,7 @@ namespace xlnt { enum class calendar; class alignment; +class base_format; class border; class cell_reference; class comment; @@ -107,6 +108,7 @@ public: /// Set the value of this cell to the given value. /// Overloads exist for most C++ fundamental types like bool, int, etc. as well /// as for std::string and xlnt datetime types: date, time, datetime, and timedelta. + /// template void set_value(T value); @@ -181,7 +183,7 @@ public: /// or else the default value. This is used to retreive the formatting of the cell /// as it will be displayed in an editing application. /// - format get_computed_format() const; + base_format get_computed_format() const; /// /// Returns the result of get_computed_format().get_alignment(). @@ -241,7 +243,7 @@ public: /// /// Returns the number format of this cell. /// - const number_format &get_number_format() const; + number_format get_number_format() const; /// /// Creates a new format in the workbook, sets its number_format @@ -252,7 +254,7 @@ public: /// /// Returns the font applied to the text in this cell. /// - const font &get_font() const; + font get_font() const; /// /// Creates a new format in the workbook, sets its font @@ -263,7 +265,7 @@ public: /// /// Returns the fill applied to this cell. /// - const fill &get_fill() const; + fill get_fill() const; /// /// Creates a new format in the workbook, sets its fill @@ -274,7 +276,7 @@ public: /// /// Returns the border of this cell. /// - const border &get_border() const; + border get_border() const; /// /// Creates a new format in the workbook, sets its border @@ -285,7 +287,7 @@ public: /// /// Returns the alignment of the text in this cell. /// - const alignment &get_alignment() const; + alignment get_alignment() const; /// /// Creates a new format in the workbook, sets its alignment @@ -296,7 +298,7 @@ public: /// /// Returns the protection of this cell. /// - const protection &get_protection() const; + protection get_protection() const; /// /// Creates a new format in the workbook, sets its protection @@ -316,11 +318,6 @@ public: /// style get_style() const; - /// - /// Returns the name of the style applied to this cell. - /// - std::string get_style_name() const; - /// /// Equivalent to set_style(new_style.name()) /// @@ -487,7 +484,7 @@ private: /// Returns a non-const reference to the format of this cell. /// This is for internal use only. /// - format &get_format(); + format &get_format_internal(); /// /// Private constructor to create a cell from its implementation. diff --git a/include/xlnt/styles/alignment.hpp b/include/xlnt/styles/alignment.hpp index d82be6f1..99a9a2c6 100644 --- a/include/xlnt/styles/alignment.hpp +++ b/include/xlnt/styles/alignment.hpp @@ -70,8 +70,8 @@ private: optional wrap_text_; optional indent_; optional text_rotation_; - optional horizontal_; - optional vertical_; + optional horizontal_ = horizontal_alignment::general; + optional vertical_ = vertical_alignment::bottom; }; } // namespace xlnt diff --git a/include/xlnt/styles/base_format.hpp b/include/xlnt/styles/base_format.hpp index e53eaf9e..881a1bce 100644 --- a/include/xlnt/styles/base_format.hpp +++ b/include/xlnt/styles/base_format.hpp @@ -36,79 +36,59 @@ namespace xlnt { /// /// Describes the formatting of a particular cell. /// -class XLNT_CLASS base_format : public hashable +class XLNT_CLASS base_format { public: - base_format(); - base_format(const base_format &other); - base_format &operator=(const base_format &other); - - void reset(); - // Alignment - alignment &get_alignment(); - const alignment &get_alignment() const; - void set_alignment(const alignment &new_alignment); - void remove_alignment(); + xlnt::alignment &alignment(); + const xlnt::alignment &alignment() const; + void alignment(const xlnt::alignment &new_alignment, bool applied); bool alignment_applied() const; - void alignment_applied(bool applied); // Border - border &get_border(); - const border &get_border() const; - void set_border(const border &new_border); - void remove_border(); + xlnt::border &border(); + const xlnt::border &border() const; + void border(const xlnt::border &new_border, bool applied); bool border_applied() const; - void border_applied(bool applied); // Fill - fill &get_fill(); - const fill &get_fill() const; - void set_fill(const fill &new_fill); - void remove_fill(); + xlnt::fill &fill(); + const xlnt::fill &fill() const; + void fill(const xlnt::fill &new_fill, bool applied); bool fill_applied() const; - void fill_applied(bool applied); // Font - font &get_font(); - const font &get_font() const; - void set_font(const font &new_font); - void remove_font(); + xlnt::font &font(); + const xlnt::font &font() const; + void font(const xlnt::font &new_font, bool applied); bool font_applied() const; - void font_applied(bool applied); // Number Format - number_format &get_number_format(); - const number_format &get_number_format() const; - void set_number_format(const number_format &new_number_format); - void remove_number_format(); + virtual xlnt::number_format &number_format(); + virtual const xlnt::number_format &number_format() const; + virtual void number_format(const xlnt::number_format &new_number_format, bool applied); bool number_format_applied() const; - void number_format_applied(bool applied); // Protection - protection &get_protection(); - const protection &get_protection() const; - void set_protection(const protection &new_protection); - void remove_protection(); + xlnt::protection &protection(); + const xlnt::protection &protection() const; + void protection(const xlnt::protection &new_protection, bool applied); bool protection_applied() const; - void protection_applied(bool applied); protected: - std::string to_hash_string() const override; - - alignment alignment_; - border border_; - fill fill_; - font font_; - number_format number_format_; - protection protection_; + xlnt::alignment alignment_; + xlnt::border border_; + xlnt::fill fill_; + xlnt::font font_; + xlnt::number_format number_format_; + xlnt::protection protection_; - bool apply_alignment_; - bool apply_border_; - bool apply_fill_; - bool apply_font_; - bool apply_number_format_; - bool apply_protection_; + bool apply_alignment_ = false; + bool apply_border_ = false; + bool apply_fill_ = false; + bool apply_font_ = false; + bool apply_number_format_ = false; + bool apply_protection_ = false; }; } // namespace xlnt diff --git a/include/xlnt/styles/format.hpp b/include/xlnt/styles/format.hpp index 2ecd285c..1afe4a1e 100644 --- a/include/xlnt/styles/format.hpp +++ b/include/xlnt/styles/format.hpp @@ -26,6 +26,7 @@ #include #include +#include namespace xlnt { @@ -44,31 +45,26 @@ struct stylesheet; /// /// Describes the formatting of a particular cell. /// -class XLNT_CLASS format +class XLNT_CLASS format : public base_format { public: - std::size_t get_id() const; + std::size_t id() const; - alignment get_alignment() const; - void set_alignment(const alignment &new_alignment); + bool has_style() const; + void style(const std::string &name); + void style(const xlnt::style &new_style); + const xlnt::style &style() const; - border get_border() const; - void set_border(const border &new_border); + virtual xlnt::number_format &number_format(); + virtual const xlnt::number_format &number_format() const; + void number_format(const xlnt::number_format &new_number_format, bool applied) override; - fill get_fill() const; - void set_fill(const fill &new_fill); - - font get_font() const; - void set_font(const font &new_font); - - number_format get_number_format() const; - void set_number_format(const number_format &new_number_format); - - protection get_protection() const; - void set_protection(const protection &new_protection); - - void set_style(const std::string &name); - std::string get_name() const; + format &alignment_id(std::size_t id); + format &border_id(std::size_t id); + format &fill_id(std::size_t id); + format &font_id(std::size_t id); + format &number_format_id(std::size_t id); + format &protection_id(std::size_t id); private: friend struct detail::stylesheet; diff --git a/include/xlnt/styles/style.hpp b/include/xlnt/styles/style.hpp index 9a5bd840..278da7a5 100644 --- a/include/xlnt/styles/style.hpp +++ b/include/xlnt/styles/style.hpp @@ -26,6 +26,7 @@ #include #include +#include #include namespace xlnt { @@ -39,7 +40,7 @@ struct stylesheet; /// Describes a style which has a name and can be applied to multiple individual /// formats. In Excel this is a "Cell Style". /// -class XLNT_CLASS style +class XLNT_CLASS style : public base_format { public: std::string name() const; @@ -48,11 +49,20 @@ public: bool hidden() const; style &hidden(bool value); - bool custom() const; + optional custom() const; style &custom(bool value); - std::size_t built_in_id() const; - style &built_in_id(std::size_t builtin_id); + optional builtin_id() const; + style &builtin_id(std::size_t builtin_id); + + style &alignment_id(std::size_t id); + style &border_id(std::size_t id); + style &fill_id(std::size_t id); + style &font_id(std::size_t id); + style &number_format_id(std::size_t id); + style &protection_id(std::size_t id); + + bool operator==(const style &other); private: friend struct detail::stylesheet; diff --git a/source/cell/cell.cpp b/source/cell/cell.cpp index 34da6fd8..6dc1f3f1 100644 --- a/source/cell/cell.cpp +++ b/source/cell/cell.cpp @@ -185,6 +185,12 @@ bool cell::garbage_collectible() const return !(get_data_type() != type::null || is_merged() || has_formula() || has_format()); } +template <> +XLNT_FUNCTION void cell::set_value(nullptr_t) +{ + d_->type_ = type::null; +} + template <> XLNT_FUNCTION void cell::set_value(bool b) { @@ -411,7 +417,9 @@ bool cell::is_merged() const bool cell::is_date() const { - return get_data_type() == type::numeric && get_number_format().is_date_format(); + return get_data_type() == type::numeric + && has_format() + && get_number_format().is_date_format(); } cell_reference cell::get_reference() const @@ -605,32 +613,32 @@ void cell::set_data_type(type t) number_format cell::get_computed_number_format() const { - return get_computed_format().get_number_format(); + return get_computed_format().number_format(); } font cell::get_computed_font() const { - return get_computed_format().get_font(); + return get_computed_format().font(); } fill cell::get_computed_fill() const { - return get_computed_format().get_fill(); + return get_computed_format().fill(); } border cell::get_computed_border() const { - return get_computed_format().get_border(); + return get_computed_format().border(); } alignment cell::get_computed_alignment() const { - return get_computed_format().get_alignment(); + return get_computed_format().alignment(); } protection cell::get_computed_protection() const { - return get_computed_format().get_protection(); + return get_computed_format().protection(); } void cell::clear_value() @@ -753,32 +761,44 @@ XLNT_FUNCTION timedelta cell::get_value() const void cell::set_border(const xlnt::border &border_) { - get_format().set_border(border_); + auto &format = get_workbook().create_format(); + format.border(border_, true); + d_->format_id_ = format.id(); } void cell::set_fill(const xlnt::fill &fill_) { - get_format().set_fill(fill_); + auto &format = get_workbook().create_format(); + format.fill(fill_, true); + d_->format_id_ = format.id(); } void cell::set_font(const font &font_) { - get_format().set_font(font_); + auto &format = get_workbook().create_format(); + format.font(font_, true); + d_->format_id_ = format.id(); } void cell::set_number_format(const number_format &number_format_) { - get_format().set_number_format(number_format_); + auto &format = get_workbook().create_format(); + format.number_format(number_format_, true); + d_->format_id_ = format.id(); } void cell::set_alignment(const xlnt::alignment &alignment_) { - get_format().set_alignment(alignment_); + auto &format = get_workbook().create_format(); + format.alignment(alignment_, true); + d_->format_id_ = format.id(); } void cell::set_protection(const xlnt::protection &protection_) { - get_format().set_protection(protection_); + auto &format = get_workbook().create_format(); + format.protection(protection_, true); + d_->format_id_ = format.id(); } template <> @@ -800,18 +820,18 @@ bool cell::has_value() const std::string cell::to_string() const { - auto nf = get_number_format(); + auto nf = get_computed_number_format(); switch (get_data_type()) { case cell::type::null: return ""; case cell::type::numeric: - return get_number_format().format(get_value(), get_base_date()); + return nf.format(get_value(), get_base_date()); case cell::type::string: case cell::type::formula: case cell::type::error: - return get_number_format().format(get_value()); + return nf.format(get_value()); case cell::type::boolean: return get_value() == 0 ? "FALSE" : "TRUE"; default: @@ -819,11 +839,6 @@ std::string cell::to_string() const } } -format &cell::get_format() -{ - return get_workbook().get_format(d_->format_id_); -} - bool cell::has_format() const { return d_->format_id_.is_set(); @@ -831,7 +846,7 @@ bool cell::has_format() const void cell::set_format(const format &new_format) { - d_->format_id_ = get_workbook().create_format().get_id(); + d_->format_id_ = get_workbook().create_format().id(); } calendar cell::get_base_date() const @@ -894,7 +909,7 @@ void cell::set_style(const style &new_style) void cell::set_style(const std::string &style_name) { - d_->style_name_ = style_name; + d_->style_name_ = get_workbook().get_style(style_name).name(); } style cell::get_style() const @@ -912,4 +927,103 @@ bool cell::has_style() const return d_->style_name_; } +base_format cell::get_computed_format() const +{ + base_format result; + + // Check style first + + if (has_style()) + { + style cell_style = get_style(); + + if (cell_style.alignment_applied()) result.alignment(cell_style.alignment(), true); + if (cell_style.border_applied()) result.border(cell_style.border(), true); + if (cell_style.fill_applied()) result.fill(cell_style.fill(), true); + if (cell_style.font_applied()) result.font(cell_style.font(), true); + if (cell_style.number_format_applied()) result.number_format(cell_style.number_format(), true); + if (cell_style.protection_applied()) result.protection(cell_style.protection(), true); + } + + // Cell format overrides style + + if (has_format()) + { + format cell_format = get_format(); + + if (cell_format.alignment_applied()) result.alignment(cell_format.alignment(), true); + if (cell_format.border_applied()) result.border(cell_format.border(), true); + if (cell_format.fill_applied()) result.fill(cell_format.fill(), true); + if (cell_format.font_applied()) result.font(cell_format.font(), true); + if (cell_format.number_format_applied()) result.number_format(cell_format.number_format(), true); + if (cell_format.protection_applied()) result.protection(cell_format.protection(), true); + } + + // Use defaults for any remaining non-applied components + + if (!result.alignment_applied()) result.alignment(alignment(), true); + if (!result.border_applied()) result.border(border(), true); + if (!result.fill_applied()) result.fill(fill(), true); + if (!result.font_applied()) result.font(font(), true); + if (!result.number_format_applied()) result.number_format(number_format(), true); + if (!result.protection_applied()) result.protection(protection(), true); + + return result; +} + +format &cell::get_format_internal() +{ + if (!d_->format_id_) + { + throw invalid_attribute(); + } + + return get_workbook().get_format(*d_->format_id_); +} + +format cell::get_format() const +{ + if (!d_->format_id_) + { + throw invalid_attribute(); + } + + return get_workbook().get_format(*d_->format_id_); +} + +alignment cell::get_alignment() const +{ + return get_format().alignment(); +} + +border cell::get_border() const +{ + return get_format().border(); +} + +fill cell::get_fill() const +{ + return get_format().fill(); +} + +font cell::get_font() const +{ + return get_format().font(); +} + +number_format cell::get_number_format() const +{ + return get_format().number_format(); +} + +protection cell::get_protection() const +{ + return get_format().protection(); +} + +bool cell::has_hyperlink() const +{ + return d_->hyperlink_; +} + } // namespace xlnt diff --git a/source/cell/comment.cpp b/source/cell/comment.cpp index 206a975f..f98e8fdd 100644 --- a/source/cell/comment.cpp +++ b/source/cell/comment.cpp @@ -34,8 +34,8 @@ comment::comment(detail::comment_impl *d) : d_(d) comment::comment(cell parent, const std::string &text, const std::string &author) : d_(nullptr) { - d_->text_ = text; - d_->author_ = author; + /*d_->text_ = text; + d_->author_ = author;*/ } comment::comment() : d_(nullptr) diff --git a/source/cell/tests/test_cell.hpp b/source/cell/tests/test_cell.hpp index 029fe523..14f89bff 100644 --- a/source/cell/tests/test_cell.hpp +++ b/source/cell/tests/test_cell.hpp @@ -73,7 +73,6 @@ public: TS_ASSERT(cell.get_row() == 1); TS_ASSERT(cell.get_reference() == "A1"); TS_ASSERT(!cell.has_value()); - TS_ASSERT(!cell.has_comment()); } void test_null() @@ -297,37 +296,6 @@ public: TS_ASSERT(cell.to_repr() == ""); } - void test_comment_assignment() - { - auto ws = wb.create_sheet(); - auto cell = ws.get_cell(xlnt::cell_reference(1, 1)); - - TS_ASSERT(!cell.has_comment()); - xlnt::comment comm(cell, "text", "author"); - TS_ASSERT(cell.get_comment() == comm); - cell.set_comment(comm); - } - - void test_only_one_cell_per_comment() - { - auto ws = wb.create_sheet(); - auto cell = ws.get_cell(xlnt::cell_reference(1, 1)); - xlnt::comment comm(cell, "text", "author"); - - auto c2 = ws.get_cell(xlnt::cell_reference(1, 2)); - TS_ASSERT_THROWS(c2.set_comment(comm), xlnt::invalid_attribute); - } - - void test_remove_comment() - { - auto ws = wb.create_sheet(); - auto cell = ws.get_cell(xlnt::cell_reference(1, 1)); - - xlnt::comment comm(cell, "text", "author"); - cell.clear_comment(); - TS_ASSERT(!cell.has_comment()); - } - void test_cell_offset() { auto ws = wb.create_sheet(); @@ -340,8 +308,7 @@ public: auto ws = wb.create_sheet(); auto cell = ws.get_cell("A1"); - xlnt::font font; - font.set_bold(true); + auto font = xlnt::font().bold(true); cell.set_font(font); @@ -398,7 +365,7 @@ public: auto cell = ws.get_cell("A1"); xlnt::alignment align; - align.set_wrap_text(true); + align.wrap(true); cell.set_alignment(align); @@ -414,11 +381,12 @@ public: TS_ASSERT(!cell.has_format()); - cell.set_protection(xlnt::protection(false, true)); + auto protection = xlnt::protection().locked(false).hidden(true); + cell.set_protection(protection); TS_ASSERT(cell.has_format()); TS_ASSERT(cell.get_format().protection_applied()); - TS_ASSERT_EQUALS(cell.get_protection(), xlnt::protection(false, true)); + TS_ASSERT_EQUALS(cell.get_protection(), protection); TS_ASSERT(cell.has_format()); cell.clear_format(); @@ -433,25 +401,25 @@ public: TS_ASSERT(!cell.has_style()); auto &test_style = wb.create_style("test_style"); - test_style.set_number_format(xlnt::number_format::date_ddmmyyyy()); + test_style.number_format(xlnt::number_format::date_ddmmyyyy(), true); cell.set_style(test_style); TS_ASSERT(cell.has_style()); - TS_ASSERT_EQUALS(cell.get_style().get_number_format(), xlnt::number_format::date_ddmmyyyy()); + TS_ASSERT_EQUALS(cell.get_style().number_format(), xlnt::number_format::date_ddmmyyyy()); TS_ASSERT_EQUALS(cell.get_style(), test_style); auto &other_style = wb.create_style("other_style"); - other_style.set_number_format(xlnt::number_format::date_time2()); + other_style.number_format(xlnt::number_format::date_time2(), true); cell.set_style("other_style"); - TS_ASSERT_EQUALS(cell.get_style().get_number_format(), xlnt::number_format::date_time2()); + TS_ASSERT_EQUALS(cell.get_style().number_format(), xlnt::number_format::date_time2()); TS_ASSERT_EQUALS(cell.get_style(), other_style); - xlnt::style last_style; - last_style.set_number_format(xlnt::number_format::percentage()); + auto &last_style = wb.create_style("last_style"); + last_style.number_format(xlnt::number_format::percentage(), true); cell.set_style(last_style); - TS_ASSERT_EQUALS(cell.get_style().get_number_format(), xlnt::number_format::percentage()); + TS_ASSERT_EQUALS(cell.get_style().number_format(), xlnt::number_format::percentage()); TS_ASSERT_EQUALS(cell.get_style(), last_style); TS_ASSERT_THROWS(cell.set_style("doesn't exist"), xlnt::key_not_found); @@ -604,20 +572,6 @@ public: TS_ASSERT_EQUALS(cell.get_value(), std::string(32'767, 'a')); } - void test_comment() - { - xlnt::workbook wb; - auto cell_a1 = wb.get_active_sheet().get_cell("A1"); - xlnt::comment comment(cell_a1, "text", "author"); - auto cell_a2 = wb.get_active_sheet().get_cell("A2"); - cell_a2 = cell_a1; - TS_ASSERT(cell_a2.has_comment()); - TS_ASSERT_EQUALS(cell_a2.get_comment().get_text(), "text"); - TS_ASSERT_EQUALS(cell_a2.get_comment().get_author(), "author"); - xlnt::comment null; - TS_ASSERT_DIFFERS(null, comment); - } - void test_reference() { xlnt::cell_reference_hash hash; diff --git a/source/detail/format_impl.hpp b/source/detail/format_impl.hpp index a7047c02..c65c76d0 100644 --- a/source/detail/format_impl.hpp +++ b/source/detail/format_impl.hpp @@ -27,14 +27,16 @@ struct format_impl { stylesheet *parent; - std::size_t formatting_record_id; + std::size_t id; - optional alignment; - optional border; - optional fill; - optional font; - optional number_format; - optional protection; + optional alignment; + optional border; + optional fill; + optional font; + optional number_format; + optional protection; + + optional style; }; } // namespace detail diff --git a/source/detail/style_impl.hpp b/source/detail/style_impl.hpp index fb5cf31c..41732baf 100644 --- a/source/detail/style_impl.hpp +++ b/source/detail/style_impl.hpp @@ -25,10 +25,10 @@ struct style_impl std::string name; std::size_t formatting_record_id; - bool custom_built_in; + optional custom_builtin; bool hidden_style; - optional built_in_style_id; + optional builtin_id; optional outline_style; optional alignment; diff --git a/source/detail/stylesheet.hpp b/source/detail/stylesheet.hpp index d55cbb73..27be5471 100644 --- a/source/detail/stylesheet.hpp +++ b/source/detail/stylesheet.hpp @@ -23,6 +23,7 @@ // @author: see AUTHORS file #pragma once +#include #include #include @@ -43,28 +44,35 @@ struct stylesheet format &create_format() { - formats.push_back(format_impl()); - return format(&formats.back()); + format_impls.push_back(format_impl()); + auto &impl = format_impls.back(); + impl.parent = this; + impl.id = format_impls.size() - 1; + formats.push_back(format(&impl)); + return formats.back(); } format &get_format(std::size_t index) { - return format(&formats.at(index)); + return formats.at(index); } style &create_style() { - styles.push_back(style_impl()); - return style(&styles.back()); + style_impls.push_back(style_impl()); + auto &impl = style_impls.back(); + impl.parent = this; + styles.push_back(style(&impl)); + return styles.back(); } style &get_style(const std::string &name) { for (auto &s : styles) { - if (s.name == name) + if (s.name() == name) { - return style(&s); + return s; } } @@ -75,7 +83,7 @@ struct stylesheet { for (auto &s : styles) { - if (s.name == name) + if (s.name() == name) { return true; } @@ -84,8 +92,26 @@ struct stylesheet return false; } - std::vector formats; - std::vector styles; + std::size_t next_custom_number_format_id() const + { + std::size_t id = 164; + + for (const auto &nf : number_formats) + { + if (nf.get_id() > id) + { + id = nf.get_id() + 1; + } + } + + return id; + } + + std::list format_impls; + std::vector formats; + + std::list style_impls; + std::vector