diff --git a/include/xlnt/cell/cell.hpp b/include/xlnt/cell/cell.hpp index 5e33500c..6738984e 100644 --- a/include/xlnt/cell/cell.hpp +++ b/include/xlnt/cell/cell.hpp @@ -459,6 +459,11 @@ public: /// void comment(const std::string &text, const std::string &author = "Microsoft Office User"); + /// + /// Create a new comment with the given text, formatting, and optional author and apply it to the cell. + /// + void comment(const std::string &comment_text, const class font &comment_font, const std::string &author = "Microsoft Office User"); + /// /// Apply the comment provided as the only argument to the cell. /// diff --git a/include/xlnt/cell/comment.hpp b/include/xlnt/cell/comment.hpp index 47a978dc..30f02712 100644 --- a/include/xlnt/cell/comment.hpp +++ b/include/xlnt/cell/comment.hpp @@ -26,7 +26,7 @@ #include #include -#include +#include namespace xlnt { @@ -44,7 +44,7 @@ public: /// /// Constructs a new comment with the given text and author. /// - comment(const formatted_text &text, const std::string &author); + comment(const rich_text &text, const std::string &author); /// /// Constructs a new comment with the given unformatted text and author. @@ -54,7 +54,7 @@ public: /// /// Return the text that will be displayed for this comment. /// - formatted_text text() const; + rich_text text() const; /// /// Return the plain text that will be displayed for this comment without formatting information. @@ -120,7 +120,7 @@ private: /// /// The formatted textual content in this cell displayed directly after the author. /// - formatted_text text_; + rich_text text_; /// /// The name of the person that created this comment. diff --git a/include/xlnt/cell/formatted_text.hpp b/include/xlnt/cell/formatted_text.hpp deleted file mode 100644 index d79d2b4f..00000000 --- a/include/xlnt/cell/formatted_text.hpp +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright (c) 2016 Thomas Fussell -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, WRISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE -// -// @license: http://www.opensource.org/licenses/mit-license.php -// @author: see AUTHORS file - -#pragma once - -#include -#include - -#include -#include - -namespace xlnt { - -/// -/// Encapsulates zero or more formatted text runs where a text run -/// is a string of text with the same defined formatting. -/// -class XLNT_API formatted_text -{ -public: - /// - /// - /// - formatted_text() = default; - - /// - /// - /// - formatted_text(const std::string &plain_text); - - /// - /// - /// - formatted_text(const text_run &single_run); - - /// - /// Remove all text runs from this text. - /// - void clear(); - - /// - /// Clear any runs in this text and add a single run with default formatting and - /// the given string as its textual content. - /// - void plain_text(const std::string &s); - - /// - /// Combine the textual content of each text run in order and return the result. - /// - std::string plain_text() const; - - /// - /// Returns a copy of the individual runs that comprise this text. - /// - std::vector runs() const; - - /// - /// Set the runs of this text all at once. - /// - void runs(const std::vector &new_runs); - - /// - /// Add a new run to the end of the set of runs. - /// - void add_run(const text_run &t); - - /// - /// Returns true if the runs that make up this text are identical to those in rhs. - /// - bool operator==(const formatted_text &rhs) const; - - /// - /// Returns true if this text has a single unformatted run with text equal to rhs. - /// - bool operator==(const std::string &rhs) const; - -private: - /// - /// - /// - std::vector runs_; -}; - -} // namespace xlnt diff --git a/include/xlnt/cell/text_run.hpp b/include/xlnt/cell/text_run.hpp deleted file mode 100644 index 14c7b647..00000000 --- a/include/xlnt/cell/text_run.hpp +++ /dev/null @@ -1,185 +0,0 @@ -// Copyright (c) 2016 Thomas Fussell -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, WRISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE -// -// @license: http://www.opensource.org/licenses/mit-license.php -// @author: see AUTHORS file - -#pragma once - -#include - -#include -#include -#include -#include - -namespace xlnt { - -// todo: should this just be a struct? - -/// -/// A formatted string -/// -class XLNT_API text_run -{ -public: - /// - /// - /// - text_run(); - - /// - /// - /// - text_run(const std::string &string); - - /// - /// - /// - bool has_formatting() const; - - /// - /// - /// - std::string string() const; - - /// - /// - /// - text_run &string(const std::string &string); - - /// - /// - /// - bool has_size() const; - - /// - /// - /// - std::size_t size() const; - - /// - /// - /// - text_run &size(std::size_t size); - - /// - /// - /// - bool has_color() const; - - /// - /// - /// - xlnt::color color() const; - - /// - /// - /// - text_run &color(const class color &new_color); - - /// - /// - /// - bool has_font() const; - - /// - /// - /// - std::string font() const; - - /// - /// - /// - text_run &font(const std::string &font); - - /// - /// - /// - bool has_family() const; - - /// - /// - /// - std::size_t family() const; - - /// - /// - /// - text_run &family(std::size_t family); - - /// - /// - /// - bool has_scheme() const; - - /// - /// - /// - std::string scheme() const; - - /// - /// - /// - text_run &scheme(const std::string &scheme); - - /// - /// - /// - bool bold() const; - - /// - /// - /// - text_run &bold(bool bold); - - /// - /// - /// - bool underline_set() const; - - /// - /// - /// - bool underlined() const; - - /// - /// - /// - font::underline_style underline() const; - - /// - /// - /// - text_run &underline(font::underline_style style); - -private: - /// - /// - /// - std::string string_; - - /// - /// - /// - optional font_; -}; - -} // namespace xlnt diff --git a/include/xlnt/styles/font.hpp b/include/xlnt/styles/font.hpp index 9fea8ab6..6d660d7b 100644 --- a/include/xlnt/styles/font.hpp +++ b/include/xlnt/styles/font.hpp @@ -120,12 +120,12 @@ public: /// /// /// - font &size(std::size_t size); + font &size(double size); /// /// /// - std::size_t size() const; + double size() const; /// /// @@ -211,7 +211,7 @@ private: /// /// /// - optional size_; + optional size_; /// /// diff --git a/include/xlnt/workbook/workbook.hpp b/include/xlnt/workbook/workbook.hpp index 9f7d712d..2193f3ed 100644 --- a/include/xlnt/workbook/workbook.hpp +++ b/include/xlnt/workbook/workbook.hpp @@ -49,7 +49,7 @@ class drawing; class fill; class font; class format; -class formatted_text; +class rich_text; class manifest; class named_range; class number_format; @@ -616,17 +616,17 @@ public: /// /// /// - void add_shared_string(const formatted_text &shared, bool allow_duplicates = false); + void add_shared_string(const rich_text &shared, bool allow_duplicates = false); /// /// /// - std::vector &shared_strings(); + std::vector &shared_strings(); /// /// /// - const std::vector &shared_strings() const; + const std::vector &shared_strings() const; // thumbnail diff --git a/include/xlnt/worksheet/header_footer.hpp b/include/xlnt/worksheet/header_footer.hpp index 8b06fb8c..c109262b 100644 --- a/include/xlnt/worksheet/header_footer.hpp +++ b/include/xlnt/worksheet/header_footer.hpp @@ -29,7 +29,7 @@ #include #include -#include +#include #include namespace xlnt { @@ -113,13 +113,13 @@ public: /// /// Add a header at the given location with the given text. /// - header_footer &header(location where, const formatted_text &text); + header_footer &header(location where, const rich_text &text); /// /// Get the text of the header at the given location. If headers are /// different on odd and even pages, the odd header will be returned. /// - formatted_text header(location where) const; + rich_text header(location where) const; // First Page Header @@ -146,14 +146,14 @@ public: /// /// Add a header on the first page at the given location with the given text. /// - header_footer &first_page_header(location where, const formatted_text &text); + header_footer &first_page_header(location where, const rich_text &text); /// /// Get the text of the first page header at the given location. If no first /// page header has been set, the general header for that location will /// be returned. /// - formatted_text first_page_header(location where) const; + rich_text first_page_header(location where) const; // Odd/Even Header @@ -181,21 +181,21 @@ public: /// /// Add a header for odd pages at the given location with the given text. /// - header_footer &odd_even_header(location where, const formatted_text &odd, const formatted_text &even); + header_footer &odd_even_header(location where, const rich_text &odd, const rich_text &even); /// /// Get the text of the odd page header at the given location. If no odd /// page header has been set, the general header for that location will /// be returned. /// - formatted_text odd_header(location where) const; + rich_text odd_header(location where) const; /// /// Get the text of the even page header at the given location. If no even /// page header has been set, the general header for that location will /// be returned. /// - formatted_text even_header(location where) const; + rich_text even_header(location where) const; // Normal Footer @@ -223,13 +223,13 @@ public: /// /// Add a footer at the given location with the given text. /// - header_footer &footer(location where, const formatted_text &text); + header_footer &footer(location where, const rich_text &text); /// /// Get the text of the footer at the given location. If footers are /// different on odd and even pages, the odd footer will be returned. /// - formatted_text footer(location where) const; + rich_text footer(location where) const; // First Page footer @@ -256,14 +256,14 @@ public: /// /// Add a footer on the first page at the given location with the given text. /// - header_footer &first_page_footer(location where, const formatted_text &text); + header_footer &first_page_footer(location where, const rich_text &text); /// /// Get the text of the first page footer at the given location. If no first /// page footer has been set, the general footer for that location will /// be returned. /// - formatted_text first_page_footer(location where) const; + rich_text first_page_footer(location where) const; // Odd/Even Footer @@ -291,28 +291,28 @@ public: /// /// Add a footer for odd pages at the given location with the given text. /// - header_footer &odd_even_footer(location where, const formatted_text &odd, const formatted_text &even); + header_footer &odd_even_footer(location where, const rich_text &odd, const rich_text &even); /// /// Get the text of the odd page footer at the given location. If no odd /// page footer has been set, the general footer for that location will /// be returned. /// - formatted_text odd_footer(location where) const; + rich_text odd_footer(location where) const; /// /// Get the text of the even page footer at the given location. If no even /// page footer has been set, the general footer for that location will /// be returned. /// - formatted_text even_footer(location where) const; + rich_text even_footer(location where) const; private: bool align_with_margins_ = false; bool different_odd_even_ = false; bool scale_with_doc_ = false; - using container = std::unordered_map>; + using container = std::unordered_map>; container odd_headers_; container even_headers_; diff --git a/include/xlnt/xlnt.hpp b/include/xlnt/xlnt.hpp index b1bc4b8f..eb406687 100644 --- a/include/xlnt/xlnt.hpp +++ b/include/xlnt/xlnt.hpp @@ -30,9 +30,9 @@ #include #include #include -#include +#include #include -#include +#include // packaging #include diff --git a/source/cell/cell.cpp b/source/cell/cell.cpp index a14304c6..03486d39 100644 --- a/source/cell/cell.cpp +++ b/source/cell/cell.cpp @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include #include @@ -339,9 +339,9 @@ XLNT_API void cell::value(std::string s) } template <> -XLNT_API void cell::value(formatted_text text) +XLNT_API void cell::value(rich_text text) { - if (text.runs().size() == 1 && !text.runs().front().has_formatting()) + if (text.runs().size() == 1 && !text.runs().front().second.is_set()) { value(text.plain_text()); } @@ -799,7 +799,7 @@ XLNT_API std::string cell::value() const } template <> -XLNT_API formatted_text cell::value() const +XLNT_API rich_text cell::value() const { return d_->value_text_; } @@ -1018,6 +1018,13 @@ void cell::comment(const std::string &text, const std::string &author) comment(xlnt::comment(text, author)); } +void cell::comment(const std::string &text, const class font &comment_font, const std::string &author) +{ + xlnt::rich_text rich_comment_text(text, comment_font); + comment(xlnt::comment(rich_comment_text, author)); +} + + void cell::comment(const class comment &new_comment) { d_->comment_.set(new_comment); diff --git a/source/cell/comment.cpp b/source/cell/comment.cpp index 3eba5cc5..a656a1dc 100644 --- a/source/cell/comment.cpp +++ b/source/cell/comment.cpp @@ -29,7 +29,7 @@ comment::comment() : comment("", "") { } -comment::comment(const formatted_text &text, const std::string &author) +comment::comment(const rich_text &text, const std::string &author) : text_(text), author_(author) { @@ -42,7 +42,7 @@ comment::comment(const std::string &text, const std::string &author) text_.plain_text(text); } -formatted_text comment::text() const +rich_text comment::text() const { return text_; } diff --git a/source/cell/formatted_text.cpp b/source/cell/formatted_text.cpp deleted file mode 100644 index 032b847d..00000000 --- a/source/cell/formatted_text.cpp +++ /dev/null @@ -1,124 +0,0 @@ -// Copyright (c) 2014-2016 Thomas Fussell -// Copyright (c) 2010-2015 openpyxl -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, WRISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE -// -// @license: http://www.opensource.org/licenses/mit-license.php -// @author: see AUTHORS file -#include - -#include -#include - -namespace xlnt { - -formatted_text::formatted_text(const std::string &plain_text) - : formatted_text(text_run(plain_text)) -{ -} - -formatted_text::formatted_text(const text_run &single_run) -{ - add_run(single_run); -} - -void formatted_text::clear() -{ - runs_.clear(); -} - -void formatted_text::plain_text(const std::string &s) -{ - clear(); - add_run(text_run(s)); -} - -std::string formatted_text::plain_text() const -{ - return std::accumulate(runs_.begin(), runs_.end(), std::string(), - [](const std::string &a, const text_run &run) { return a + run.string(); }); -} - -std::vector formatted_text::runs() const -{ - return runs_; -} - -void formatted_text::add_run(const text_run &t) -{ - runs_.push_back(t); -} - -bool formatted_text::operator==(const formatted_text &rhs) const -{ - if (runs_.size() != rhs.runs_.size()) return false; - - for (std::size_t i = 0; i < runs_.size(); i++) - { - if (runs_[i].string() != rhs.runs_[i].string()) return false; - if (runs_[i].has_formatting() != rhs.runs_[i].has_formatting()) return false; - - if (runs_[i].has_formatting()) - { - if (runs_[i].has_color() != rhs.runs_[i].has_color() - || (runs_[i].has_color() - && runs_[i].color() != rhs.runs_[i].color())) - { - return false; - } - - if (runs_[i].has_family() != rhs.runs_[i].has_family() - || (runs_[i].has_family() - && runs_[i].family() != rhs.runs_[i].family())) - { - return false; - } - - if (runs_[i].has_font() != rhs.runs_[i].has_font() - || (runs_[i].has_font() - && runs_[i].font() != rhs.runs_[i].font())) - { - return false; - } - - if (runs_[i].has_scheme() != rhs.runs_[i].has_scheme() - || (runs_[i].has_scheme() - && runs_[i].scheme() != rhs.runs_[i].scheme())) - { - return false; - } - - if (runs_[i].has_size() != rhs.runs_[i].has_size() - || (runs_[i].has_size() - && runs_[i].size() != rhs.runs_[i].size())) - { - return false; - } - } - } - - return true; -} - -bool formatted_text::operator==(const std::string &rhs) const -{ - return *this == formatted_text(rhs); -} - -} // namespace xlnt diff --git a/source/cell/tests/test_text.hpp b/source/cell/tests/test_text.hpp index 455fc156..a572f4ea 100644 --- a/source/cell/tests/test_text.hpp +++ b/source/cell/tests/test_text.hpp @@ -7,57 +7,69 @@ #include -class test_formatted_text : public CxxTest::TestSuite +class test_rich_text : public CxxTest::TestSuite { public: void test_operators() { - xlnt::formatted_text text1; - xlnt::formatted_text text2; + xlnt::rich_text text1; + xlnt::rich_text text2; TS_ASSERT_EQUALS(text1, text2); - xlnt::text_run run_default; + xlnt::rich_text_run run_default; text1.add_run(run_default); TS_ASSERT_DIFFERS(text1, text2); text2.add_run(run_default); TS_ASSERT_EQUALS(text1, text2); - xlnt::text_run run_formatted; - run_formatted.color(xlnt::color::green()); - run_formatted.font("Cambria"); - run_formatted.scheme("ascheme"); - run_formatted.size(40); - run_formatted.family(17); + xlnt::rich_text_run run_formatted; + xlnt::font run_font; + run_font.color(xlnt::color::green()); + run_font.name("Cambria"); + run_font.scheme("ascheme"); + run_font.size(40); + run_font.family(17); + run_formatted.second = run_font; - xlnt::formatted_text text_formatted; + xlnt::rich_text text_formatted; text_formatted.add_run(run_formatted); - xlnt::text_run run_color_differs = run_formatted; - run_color_differs.color(xlnt::color::red()); - xlnt::formatted_text text_color_differs; + xlnt::rich_text_run run_color_differs = run_formatted; + run_font = xlnt::font(); + run_font.color(xlnt::color::red()); + run_color_differs.second = run_font; + xlnt::rich_text text_color_differs; text_color_differs.add_run(run_color_differs); TS_ASSERT_DIFFERS(text_formatted, text_color_differs); - xlnt::text_run run_font_differs = run_formatted; - run_font_differs.font("Calibri"); - xlnt::formatted_text text_font_differs; + xlnt::rich_text_run run_font_differs = run_formatted; + run_font = xlnt::font(); + run_font.name("Calibri"); + run_font_differs.second = run_font; + xlnt::rich_text text_font_differs; text_font_differs.add_run(run_font_differs); TS_ASSERT_DIFFERS(text_formatted, text_font_differs); - xlnt::text_run run_scheme_differs = run_formatted; - run_scheme_differs.scheme("bscheme"); - xlnt::formatted_text text_scheme_differs; + xlnt::rich_text_run run_scheme_differs = run_formatted; + run_font = xlnt::font(); + run_font.scheme("bscheme"); + run_scheme_differs.second = run_font; + xlnt::rich_text text_scheme_differs; text_scheme_differs.add_run(run_scheme_differs); TS_ASSERT_DIFFERS(text_formatted, text_scheme_differs); - xlnt::text_run run_size_differs = run_formatted; - run_size_differs.size(41); - xlnt::formatted_text text_size_differs; + xlnt::rich_text_run run_size_differs = run_formatted; + run_font = xlnt::font(); + run_font.size(41); + run_size_differs.second = run_font; + xlnt::rich_text text_size_differs; text_size_differs.add_run(run_size_differs); TS_ASSERT_DIFFERS(text_formatted, text_size_differs); - xlnt::text_run run_family_differs = run_formatted; - run_family_differs.family(18); - xlnt::formatted_text text_family_differs; + xlnt::rich_text_run run_family_differs = run_formatted; + run_font = xlnt::font(); + run_font.family(18); + run_family_differs.second = run_font; + xlnt::rich_text text_family_differs; text_family_differs.add_run(run_family_differs); TS_ASSERT_DIFFERS(text_formatted, text_family_differs); } diff --git a/source/cell/text_run.cpp b/source/cell/text_run.cpp deleted file mode 100644 index 4ab77159..00000000 --- a/source/cell/text_run.cpp +++ /dev/null @@ -1,192 +0,0 @@ -// Copyright (c) 2014-2016 Thomas Fussell -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, WRISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE -// -// @license: http://www.opensource.org/licenses/mit-license.php -// @author: see AUTHORS file - -#include -#include - -namespace xlnt { - -text_run::text_run() : text_run("") -{ -} - -text_run::text_run(const std::string &string) : string_(string) -{ -} - -std::string text_run::string() const -{ - return string_; -} - -text_run &text_run::string(const std::string &string) -{ - string_ = string; - return *this; -} - -bool text_run::has_formatting() const -{ - return font_.is_set(); -} - -bool text_run::has_size() const -{ - return font_.is_set() && font_.get().has_size(); -} - -std::size_t text_run::size() const -{ - return font_.get().size(); -} - -text_run &text_run::size(std::size_t size) -{ - if (!font_.is_set()) - { - font_ = xlnt::font(); - } - - font_.get().size(size); - - return *this; -} - -bool text_run::has_color() const -{ - return font_.is_set() && font_.get().has_color(); -} - -color text_run::color() const -{ - return font_.get().color(); -} - -text_run &text_run::color(const class color &new_color) -{ - if (!font_.is_set()) - { - font_ = xlnt::font(); - } - - font_.get().color(new_color); - - return *this; -} - -bool text_run::has_font() const -{ - return font_.is_set() && font_.get().has_name(); -} - -std::string text_run::font() const -{ - return font_.get().name(); -} - -text_run &text_run::font(const std::string &font) -{ - if (!font_.is_set()) - { - font_ = xlnt::font(); - } - - font_.get().name(font); - - return *this; -} - -bool text_run::has_family() const -{ - return font_.is_set() && font_.get().has_family(); -} - -std::size_t text_run::family() const -{ - return font_.get().family(); -} - -text_run &text_run::family(std::size_t family) -{ - if (!font_.is_set()) - { - font_ = xlnt::font(); - } - - font_.get().family(family); - - return *this; -} - -bool text_run::has_scheme() const -{ - return font_.is_set() && font_.get().has_scheme(); -} - -std::string text_run::scheme() const -{ - return font_.get().scheme(); -} - -text_run &text_run::scheme(const std::string &scheme) -{ - if (!font_.is_set()) - { - font_ = xlnt::font(); - } - - font_.get().scheme(scheme); - - return *this; -} - -bool text_run::bold() const -{ - return font_.is_set() && font_.get().bold(); -} - -text_run &text_run::bold(bool bold) -{ - if (!font_.is_set()) - { - font_ = xlnt::font(); - } - - font_.get().bold(bold); - - return *this; -} - -text_run &text_run::underline(font::underline_style style) -{ - if (!font_.is_set()) - { - font_ = xlnt::font(); - } - - font_.get().underline(style); - - return *this; -} - -} // namespace xlnt diff --git a/source/detail/cell_impl.hpp b/source/detail/cell_impl.hpp index 302cfc92..84d378be 100644 --- a/source/detail/cell_impl.hpp +++ b/source/detail/cell_impl.hpp @@ -27,7 +27,7 @@ #include #include -#include +#include #include #include @@ -50,7 +50,7 @@ struct cell_impl bool is_merged_; - formatted_text value_text_; + rich_text value_text_; long double value_numeric_; optional formula_; diff --git a/source/detail/workbook_impl.hpp b/source/detail/workbook_impl.hpp index 3a6c81ef..5c9715bb 100644 --- a/source/detail/workbook_impl.hpp +++ b/source/detail/workbook_impl.hpp @@ -82,7 +82,7 @@ struct workbook_impl optional active_sheet_index_; std::list worksheets_; - std::vector shared_strings_; + std::vector shared_strings_; optional stylesheet_; diff --git a/source/detail/xlsx_consumer.cpp b/source/detail/xlsx_consumer.cpp index 69266e9f..52840015 100644 --- a/source/detail/xlsx_consumer.cpp +++ b/source/detail/xlsx_consumer.cpp @@ -56,9 +56,9 @@ struct hash namespace { -std::array, 3> parse_header_footer(const std::string &hf_string) +std::array, 3> parse_header_footer(const std::string &hf_string) { - std::array, 3> result; + std::array, 3> result; if (hf_string.empty()) { @@ -277,8 +277,8 @@ std::array, 3> parse_header_footer(const st ++end_index; } - xlnt::formatted_text current_text; - xlnt::text_run current_run; + xlnt::rich_text current_text; + xlnt::rich_text_run current_run; // todo: all this nice parsing and the codes are just being turned back into text representations // It would be nice to create an interface for the library to read and write these codes @@ -289,14 +289,14 @@ std::array, 3> parse_header_footer(const st if (current_token.code == hf_code::text) { - current_run.string(current_run.string() + current_token.value); + current_run.first = current_run.first + current_token.value; continue; } - if (!current_run.string().empty()) + if (!current_run.first.empty()) { current_text.add_run(current_run); - current_run = xlnt::text_run(); + current_run = xlnt::rich_text_run(); } switch (current_token.code) @@ -314,21 +314,29 @@ std::array, 3> parse_header_footer(const st break; // used below case hf_code::current_page_number: - current_run.string(current_run.string() + "&P"); + current_run.first = current_run.first + "&P"; break; case hf_code::total_page_number: - current_run.string(current_run.string() + "&N"); + current_run.first = current_run.first + "&N"; break; case hf_code::font_size: - current_run.size(static_cast(std::stoi(current_token.value))); + if (!current_run.second.is_set()) + { + current_run.second = xlnt::font(); + } + current_run.second.get().size(static_cast(std::stoi(current_token.value))); break; case hf_code::text_font_color: if (current_token.value.size() == 6) { - current_run.color(xlnt::rgb_color(current_token.value)); + if (!current_run.second.is_set()) + { + current_run.second = xlnt::font(); + } + current_run.second.get().color(xlnt::rgb_color(current_token.value)); } break; @@ -343,15 +351,15 @@ std::array, 3> parse_header_footer(const st break; case hf_code::date: - current_run.string(current_run.string() + "&D"); + current_run.first = current_run.first + "&D"; break; case hf_code::time: - current_run.string(current_run.string() + "&T"); + current_run.first = current_run.first + "&T"; break; case hf_code::picture_as_background: - current_run.string(current_run.string() + "&G"); + current_run.first = current_run.first + "&G"; break; case hf_code::text_single_underline: @@ -361,15 +369,15 @@ std::array, 3> parse_header_footer(const st break; case hf_code::workbook_file_path: - current_run.string(current_run.string() + "&Z"); + current_run.first = current_run.first + "&Z"; break; case hf_code::workbook_file_name: - current_run.string(current_run.string() + "&F"); + current_run.first = current_run.first + "&F"; break; case hf_code::sheet_tab_name: - current_run.string(current_run.string() + "&A"); + current_run.first = current_run.first + "&A"; break; case hf_code::add_to_page_number: @@ -383,9 +391,14 @@ std::array, 3> parse_header_footer(const st auto comma_index = current_token.value.find(','); auto font_name = current_token.value.substr(0, comma_index); + if (!current_run.second.is_set()) + { + current_run.second = xlnt::font(); + } + if (font_name != "-") { - current_run.font(font_name); + current_run.second.get().name(font_name); } if (comma_index != std::string::npos) @@ -394,14 +407,14 @@ std::array, 3> parse_header_footer(const st if (font_type == "Bold") { - current_run.bold(true); + current_run.second.get().bold(true); } else if (font_type == "Italic") { } else if (font_type == "BoldItalic") { - current_run.bold(true); + current_run.second.get().bold(true); } } } @@ -409,7 +422,11 @@ std::array, 3> parse_header_footer(const st break; case hf_code::bold_font_style: - current_run.bold(true); + if (!current_run.second.is_set()) + { + current_run.second = xlnt::font(); + } + current_run.second.get().bold(true); break; case hf_code::italic_font_style: @@ -423,7 +440,7 @@ std::array, 3> parse_header_footer(const st } } - if (!current_run.string().empty()) + if (!current_run.first.empty()) { current_text.add_run(current_run); } @@ -1092,7 +1109,7 @@ void xlsx_consumer::read_shared_string_table() while (in_element(xml::qname(xmlns, "sst"))) { expect_start_element(xml::qname(xmlns, "si"), xml::content::complex); - strings.push_back(read_formatted_text(xml::qname(xmlns, "si"))); + strings.push_back(read_rich_text(xml::qname(xmlns, "si"))); expect_end_element(xml::qname(xmlns, "si")); } @@ -2262,12 +2279,12 @@ void xlsx_consumer::read_worksheet(const std::string &rel_id) auto different_first = parser().attribute_present("differentFirst") && is_true(parser().attribute("differentFirst")); - optional, 3>> odd_header; - optional, 3>> odd_footer; - optional, 3>> even_header; - optional, 3>> even_footer; - optional, 3>> first_header; - optional, 3>> first_footer; + optional, 3>> odd_header; + optional, 3>> odd_footer; + optional, 3>> even_header; + optional, 3>> even_footer; + optional, 3>> first_header; + optional, 3>> first_footer; while (in_element(current_worksheet_element)) { @@ -2490,7 +2507,7 @@ void xlsx_consumer::read_comments(worksheet ws) expect_start_element(xml::qname(xmlns, "text"), xml::content::complex); - ws.cell(cell_ref).comment(comment(read_formatted_text(xml::qname(xmlns, "text")), authors.at(author_id))); + ws.cell(cell_ref).comment(comment(read_rich_text(xml::qname(xmlns, "text")), authors.at(author_id))); expect_end_element(xml::qname(xmlns, "text")); expect_end_element(xml::qname(xmlns, "comment")); @@ -2660,10 +2677,10 @@ void xlsx_consumer::expect_end_element(const xml::qname &name) stack_.pop_back(); } -formatted_text xlsx_consumer::read_formatted_text(const xml::qname &parent) +rich_text xlsx_consumer::read_rich_text(const xml::qname &parent) { const auto &xmlns = parent.namespace_(); - formatted_text t; + rich_text t; while (in_element(parent)) { @@ -2677,7 +2694,7 @@ formatted_text xlsx_consumer::read_formatted_text(const xml::qname &parent) } else if (text_element == xml::qname(xmlns, "r")) { - text_run run; + rich_text_run run; while (in_element(xml::qname(xmlns, "r"))) { @@ -2690,39 +2707,41 @@ formatted_text xlsx_consumer::read_formatted_text(const xml::qname &parent) { auto current_run_property_element = expect_start_element(xml::content::simple); + run.second = xlnt::font(); + if (current_run_property_element == xml::qname(xmlns, "sz")) { - run.size(parser().attribute("val")); + run.second.get().size(parser().attribute("val")); } else if (current_run_property_element == xml::qname(xmlns, "rFont")) { - run.font(parser().attribute("val")); + run.second.get().name(parser().attribute("val")); } else if (current_run_property_element == xml::qname(xmlns, "color")) { - run.color(read_color()); + run.second.get().color(read_color()); } else if (current_run_property_element == xml::qname(xmlns, "family")) { - run.family(parser().attribute("val")); + run.second.get().family(parser().attribute("val")); } else if (current_run_property_element == xml::qname(xmlns, "scheme")) { - run.scheme(parser().attribute("val")); + run.second.get().scheme(parser().attribute("val")); } else if (current_run_property_element == xml::qname(xmlns, "b")) { - run.bold(parser().attribute_present("val") ? is_true(parser().attribute("val")) : true); + run.second.get().bold(parser().attribute_present("val") ? is_true(parser().attribute("val")) : true); } else if (current_run_property_element == xml::qname(xmlns, "u")) { if (parser().attribute_present("val")) { - run.underline(parser().attribute("val")); + run.second.get().underline(parser().attribute("val")); } else { - run.underline(font::underline_style::single); + run.second.get().underline(font::underline_style::single); } } else @@ -2736,7 +2755,7 @@ formatted_text xlsx_consumer::read_formatted_text(const xml::qname &parent) } else if (run_element == xml::qname(xmlns, "t")) { - run.string(run_text); + run.first = run_text; } else { diff --git a/source/detail/xlsx_consumer.hpp b/source/detail/xlsx_consumer.hpp index d9bf372a..2a4d9310 100644 --- a/source/detail/xlsx_consumer.hpp +++ b/source/detail/xlsx_consumer.hpp @@ -36,7 +36,7 @@ namespace xlnt { class color; -class formatted_text; +class rich_text; class manifest; class path; class relationship; @@ -228,7 +228,7 @@ private: /// /// Read a rich text CT_RElt from the document currently being parsed. /// - formatted_text read_formatted_text(const xml::qname &parent); + rich_text read_rich_text(const xml::qname &parent); /// /// Returns true if the givent document type represents an XLSX file. diff --git a/source/detail/xlsx_producer.cpp b/source/detail/xlsx_producer.cpp index 10cac595..45c880fa 100644 --- a/source/detail/xlsx_producer.cpp +++ b/source/detail/xlsx_producer.cpp @@ -677,7 +677,7 @@ void xlsx_producer::write_shared_string_table(const relationship &/*rel*/) for (const auto &string : source_.shared_strings()) { - if (string.runs().size() == 1 && !string.runs().at(0).has_formatting()) + if (string.runs().size() == 1 && !string.runs().at(0).second.is_set()) { serializer().start_element(xmlns, "si"); serializer().element(xmlns, "t", string.plain_text()); @@ -692,46 +692,46 @@ void xlsx_producer::write_shared_string_table(const relationship &/*rel*/) { serializer().start_element(xmlns, "r"); - if (run.has_formatting()) + if (run.second.is_set()) { serializer().start_element(xmlns, "rPr"); - if (run.has_size()) + if (run.second.get().has_size()) { serializer().start_element(xmlns, "sz"); - serializer().attribute("val", run.size()); + serializer().attribute("val", run.second.get().size()); serializer().end_element(xmlns, "sz"); } - if (run.has_color()) + if (run.second.get().has_color()) { serializer().start_element(xmlns, "color"); - write_color(run.color()); + write_color(run.second.get().color()); serializer().end_element(xmlns, "color"); } - if (run.has_font()) + if (run.second.get().has_name()) { serializer().start_element(xmlns, "rFont"); - serializer().attribute("val", run.font()); + serializer().attribute("val", run.second.get().name()); serializer().end_element(xmlns, "rFont"); } - if (run.has_family()) + if (run.second.get().has_family()) { serializer().start_element(xmlns, "family"); - serializer().attribute("val", run.family()); + serializer().attribute("val", run.second.get().family()); serializer().end_element(xmlns, "family"); } - if (run.has_scheme()) + if (run.second.get().has_scheme()) { serializer().start_element(xmlns, "scheme"); - serializer().attribute("val", run.scheme()); + serializer().attribute("val", run.second.get().scheme()); serializer().end_element(xmlns, "scheme"); } - if (run.bold()) + if (run.second.get().bold()) { serializer().start_element(xmlns, "b"); serializer().end_element(xmlns, "b"); @@ -740,7 +740,7 @@ void xlsx_producer::write_shared_string_table(const relationship &/*rel*/) serializer().end_element(xmlns, "rPr"); } - serializer().element(xmlns, "t", run.string()); + serializer().element(xmlns, "t", run.first); serializer().end_element(xmlns, "r"); } @@ -2059,7 +2059,7 @@ void xlsx_producer::write_worksheet(const relationship &rel) for (std::size_t i = 0; i < shared_strings.size(); i++) { - if (shared_strings[i] == cell.value()) + if (shared_strings[i] == cell.value()) { match_index = static_cast(i); break; @@ -2250,7 +2250,7 @@ void xlsx_producer::write_worksheet(const relationship &rel) auto first_header = std::string(); auto first_footer = std::string(); - const auto encode_text = [](const formatted_text &t, header_footer::location where) + const auto encode_text = [](const rich_text &t, header_footer::location where) { const auto location_code_map = std::unordered_map> { @@ -2263,18 +2263,18 @@ void xlsx_producer::write_worksheet(const relationship &rel) for (const auto &run : t.runs()) { - if (run.string().empty()) continue; + if (run.first.empty()) continue; - if (run.has_formatting()) + if (run.second.is_set()) { - if (run.has_font()) + if (run.second.get().has_name()) { encoded.push_back('&'); encoded.push_back('"'); - encoded.append(run.font()); + encoded.append(run.second.get().name()); encoded.push_back(','); - if (run.bold()) + if (run.second.get().bold()) { encoded.append("Bold"); } @@ -2286,26 +2286,26 @@ void xlsx_producer::write_worksheet(const relationship &rel) encoded.push_back('"'); } - else if (run.bold()) + else if (run.second.get().bold()) { encoded.append("&B"); } - if (run.has_size()) + if (run.second.get().has_size()) { encoded.push_back('&'); - encoded.append(std::to_string(run.size())); + encoded.append(std::to_string(run.second.get().size())); } - if (run.has_color()) + if (run.second.get().has_color()) { encoded.push_back('&'); encoded.push_back('K'); - encoded.append(run.color().rgb().hex_string().substr(2)); + encoded.append(run.second.get().color().rgb().hex_string().substr(2)); } } - encoded.append(run.string()); + encoded.append(run.first); } return encoded; @@ -2578,46 +2578,46 @@ void xlsx_producer::write_comments(const relationship &/*rel*/, worksheet ws, { serializer().start_element(xmlns, "r"); - if (run.has_formatting()) + if (run.second.is_set()) { serializer().start_element(xmlns, "rPr"); - if (run.has_size()) + if (run.second.get().has_size()) { serializer().start_element(xmlns, "sz"); - serializer().attribute("val", run.size()); + serializer().attribute("val", run.second.get().size()); serializer().end_element(xmlns, "sz"); } - if (run.has_color()) + if (run.second.get().has_color()) { serializer().start_element(xmlns, "color"); - write_color(run.color()); + write_color(run.second.get().color()); serializer().end_element(xmlns, "color"); } - if (run.has_font()) + if (run.second.get().has_name()) { serializer().start_element(xmlns, "rFont"); - serializer().attribute("val", run.font()); + serializer().attribute("val", run.second.get().name()); serializer().end_element(xmlns, "rFont"); } - if (run.has_family()) + if (run.second.get().has_family()) { serializer().start_element(xmlns, "family"); - serializer().attribute("val", run.family()); + serializer().attribute("val", run.second.get().family()); serializer().end_element(xmlns, "family"); } - if (run.has_scheme()) + if (run.second.get().has_scheme()) { serializer().start_element(xmlns, "scheme"); - serializer().attribute("val", run.scheme()); + serializer().attribute("val", run.second.get().scheme()); serializer().end_element(xmlns, "scheme"); } - if (run.bold()) + if (run.second.get().bold()) { serializer().start_element(xmlns, "b"); serializer().end_element(xmlns, "b"); @@ -2626,7 +2626,7 @@ void xlsx_producer::write_comments(const relationship &/*rel*/, worksheet ws, serializer().end_element(xmlns, "rPr"); } - serializer().element(xmlns, "t", run.string()); + serializer().element(xmlns, "t", run.first); serializer().end_element(xmlns, "r"); } diff --git a/source/styles/font.cpp b/source/styles/font.cpp index f35d343b..cb383380 100644 --- a/source/styles/font.cpp +++ b/source/styles/font.cpp @@ -22,6 +22,8 @@ // @license: http://www.opensource.org/licenses/mit-license.php // @author: see AUTHORS file +#include + #include namespace xlnt { @@ -29,7 +31,7 @@ namespace xlnt { font::font() : name_("Calibri"), - size_(12), + size_(12.0), bold_(false), italic_(false), superscript_(false), @@ -104,13 +106,13 @@ bool font::has_size() const return size_.is_set(); } -font &font::size(std::size_t size) +font &font::size(double size) { size_ = size; return *this; } -std::size_t font::size() const +double font::size() const { return size_.get(); } @@ -235,7 +237,7 @@ XLNT_API bool operator==(const font &left, const font &right) } } - if (left.size() != right.size()) + if (std::fabs(left.size() - right.size()) != 0.0) { return false; } diff --git a/source/workbook/tests/test_produce_xlsx.hpp b/source/workbook/tests/test_produce_xlsx.hpp index f3a8173a..8f719ae7 100644 --- a/source/workbook/tests/test_produce_xlsx.hpp +++ b/source/workbook/tests/test_produce_xlsx.hpp @@ -148,41 +148,22 @@ public: void test_write_comments() { xlnt::workbook wb; - - xlnt::formatted_text comment_text; - xlnt::text_run formatted_run;; - formatted_run.bold(true); - formatted_run.size(10); - formatted_run.color(xlnt::indexed_color(81)); - formatted_run.font("Calibri"); - auto sheet1 = wb.active_sheet(); + auto comment_font = xlnt::font().bold(true).size(10).color(xlnt::indexed_color(81)).name("Calibri"); sheet1.cell("A1").value("Sheet1!A1"); - formatted_run.string("Sheet1 comment"); - comment_text.add_run(formatted_run); - sheet1.cell("A1").comment(xlnt::comment(comment_text, "Microsoft Office User")); - sheet1.cell("A1").comment("Sheet1 comment"); + sheet1.cell("A1").comment("Sheet1 comment", comment_font, "Microsoft Office User"); sheet1.cell("A2").value("Sheet1!A2"); - formatted_run.string("Sheet1 comment2"); - comment_text.clear(); - comment_text.add_run(formatted_run); - sheet1.cell("A2").comment(xlnt::comment(comment_text, "Microsoft Office User")); + sheet1.cell("A2").comment("Sheet1 comment2", comment_font, "Microsoft Office User"); auto sheet2 = wb.create_sheet(); sheet2.cell("A1").value("Sheet2!A1"); - formatted_run.string("Sheet2 comment"); - comment_text.clear(); - comment_text.add_run(formatted_run); - sheet2.cell("A1").comment(xlnt::comment(comment_text, "Microsoft Office User")); + sheet2.cell("A2").comment("Sheet2 comment", comment_font, "Microsoft Office User"); sheet2.cell("A2").value("Sheet2!A2"); - formatted_run.string("Sheet2 comment2"); - comment_text.clear(); - comment_text.add_run(formatted_run); - sheet2.cell("A2").comment(xlnt::comment(comment_text, "Microsoft Office User")); + sheet2.cell("A2").comment("Sheet2 comment2", comment_font, "Microsoft Office User"); -// TS_ASSERT(workbook_matches_file(wb, xlnt::path("data/18_basic_comments.xlsx"))); + TS_ASSERT(workbook_matches_file(wb, xlnt::path("data/18_basic_comments.xlsx"))); } }; diff --git a/source/workbook/workbook.cpp b/source/workbook/workbook.cpp index bf1152a1..2e0ea80e 100644 --- a/source/workbook/workbook.cpp +++ b/source/workbook/workbook.cpp @@ -295,10 +295,10 @@ workbook workbook::empty_libre_office() ws.page_margins(margins); ws.page_setup(page_setup()); ws.header_footer(xlnt::header_footer() - .header(header_footer::location::center, - formatted_text(text_run("&A").font("Times New Roman").size(12))) - .footer(header_footer::location::center, - formatted_text(text_run("Page &B").font("Times New Roman").size(12)))); + .header(header_footer::location::center, + rich_text(rich_text_run{"&A",font().name("Times New Roman").size(12)})) + .footer(header_footer::location::center, + rich_text(rich_text_run{"Page &B",font().name("Times New Roman").size(12)}))); ws.add_column_properties(1, column_properties()); wb.d_->stylesheet_ = detail::stylesheet(); @@ -1172,17 +1172,17 @@ const manifest &workbook::manifest() const return d_->manifest_; } -std::vector &workbook::shared_strings() +std::vector &workbook::shared_strings() { return d_->shared_strings_; } -const std::vector &workbook::shared_strings() const +const std::vector &workbook::shared_strings() const { return d_->shared_strings_; } -void workbook::add_shared_string(const formatted_text &shared, bool allow_duplicates) +void workbook::add_shared_string(const rich_text &shared, bool allow_duplicates) { register_shared_string_table_in_manifest(); diff --git a/source/worksheet/header_footer.cpp b/source/worksheet/header_footer.cpp index a5b5c838..e1dd01c8 100644 --- a/source/worksheet/header_footer.cpp +++ b/source/worksheet/header_footer.cpp @@ -91,16 +91,16 @@ void header_footer::clear_header(location where) header_footer &header_footer::header(location where, const std::string &text) { - return header(where, formatted_text(text)); + return header(where, rich_text(text)); } -header_footer &header_footer::header(location where, const formatted_text &text) +header_footer &header_footer::header(location where, const rich_text &text) { odd_headers_[where] = text; return *this; } -formatted_text header_footer::header(location where) const +rich_text header_footer::header(location where) const { return odd_headers_.at(where); } @@ -127,13 +127,13 @@ void header_footer::clear_first_page_header(location where) first_headers_.erase(where); } -header_footer &header_footer::first_page_header(location where, const formatted_text &text) +header_footer &header_footer::first_page_header(location where, const rich_text &text) { first_headers_[where] = text; return *this; } -formatted_text header_footer::first_page_header(location where) const +rich_text header_footer::first_page_header(location where) const { return first_headers_.at(where); } @@ -163,7 +163,7 @@ void header_footer::clear_odd_even_header(location where) even_headers_.erase(where); } -header_footer &header_footer::odd_even_header(location where, const formatted_text &odd, const formatted_text &even) +header_footer &header_footer::odd_even_header(location where, const rich_text &odd, const rich_text &even) { odd_headers_[where] = odd; even_headers_[where] = even; @@ -172,12 +172,12 @@ header_footer &header_footer::odd_even_header(location where, const formatted_te return *this; } -formatted_text header_footer::odd_header(location where) const +rich_text header_footer::odd_header(location where) const { return odd_headers_.at(where); } -formatted_text header_footer::even_header(location where) const +rich_text header_footer::even_header(location where) const { return even_headers_.at(where); } @@ -205,16 +205,16 @@ void header_footer::clear_footer(location where) header_footer &header_footer::footer(location where, const std::string &text) { - return footer(where, formatted_text(text)); + return footer(where, rich_text(text)); } -header_footer &header_footer::footer(location where, const formatted_text &text) +header_footer &header_footer::footer(location where, const rich_text &text) { odd_footers_[where] = text; return *this; } -formatted_text header_footer::footer(location where) const +rich_text header_footer::footer(location where) const { return odd_footers_.at(where); } @@ -241,13 +241,13 @@ void header_footer::clear_first_page_footer(location where) first_footers_.erase(where); } -header_footer &header_footer::first_page_footer(location where, const formatted_text &text) +header_footer &header_footer::first_page_footer(location where, const rich_text &text) { first_footers_[where] = text; return *this; } -formatted_text header_footer::first_page_footer(location where) const +rich_text header_footer::first_page_footer(location where) const { return first_footers_.at(where); } @@ -276,7 +276,7 @@ void header_footer::clear_odd_even_footer(location where) even_footers_.erase(where); } -header_footer &header_footer::odd_even_footer(location where, const formatted_text &odd, const formatted_text &even) +header_footer &header_footer::odd_even_footer(location where, const rich_text &odd, const rich_text &even) { odd_footers_[where] = odd; even_footers_[where] = even; @@ -285,12 +285,12 @@ header_footer &header_footer::odd_even_footer(location where, const formatted_te return *this; } -formatted_text header_footer::odd_footer(location where) const +rich_text header_footer::odd_footer(location where) const { return odd_footers_.at(where); } -formatted_text header_footer::even_footer(location where) const +rich_text header_footer::even_footer(location where) const { return even_footers_.at(where); }