rename formatted_text to rich_text to match the spec, also text_run to rich_text_run

pull/101/head
Thomas Fussell 2016-12-23 06:51:30 -05:00
parent c978a37ea3
commit 244314d426
22 changed files with 226 additions and 805 deletions

View File

@ -459,6 +459,11 @@ public:
/// </summary>
void comment(const std::string &text, const std::string &author = "Microsoft Office User");
/// <summary>
/// Create a new comment with the given text, formatting, and optional author and apply it to the cell.
/// </summary>
void comment(const std::string &comment_text, const class font &comment_font, const std::string &author = "Microsoft Office User");
/// <summary>
/// Apply the comment provided as the only argument to the cell.
/// </summary>

View File

@ -26,7 +26,7 @@
#include <string>
#include <xlnt/xlnt_config.hpp>
#include <xlnt/cell/formatted_text.hpp>
#include <xlnt/cell/rich_text.hpp>
namespace xlnt {
@ -44,7 +44,7 @@ public:
/// <summary>
/// Constructs a new comment with the given text and author.
/// </summary>
comment(const formatted_text &text, const std::string &author);
comment(const rich_text &text, const std::string &author);
/// <summary>
/// Constructs a new comment with the given unformatted text and author.
@ -54,7 +54,7 @@ public:
/// <summary>
/// Return the text that will be displayed for this comment.
/// </summary>
formatted_text text() const;
rich_text text() const;
/// <summary>
/// Return the plain text that will be displayed for this comment without formatting information.
@ -120,7 +120,7 @@ private:
/// <summary>
/// The formatted textual content in this cell displayed directly after the author.
/// </summary>
formatted_text text_;
rich_text text_;
/// <summary>
/// The name of the person that created this comment.

View File

@ -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 <string>
#include <vector>
#include <xlnt/xlnt_config.hpp>
#include <xlnt/cell/text_run.hpp>
namespace xlnt {
/// <summary>
/// Encapsulates zero or more formatted text runs where a text run
/// is a string of text with the same defined formatting.
/// </summary>
class XLNT_API formatted_text
{
public:
/// <summary>
///
/// </summary>
formatted_text() = default;
/// <summary>
///
/// </summary>
formatted_text(const std::string &plain_text);
/// <summary>
///
/// </summary>
formatted_text(const text_run &single_run);
/// <summary>
/// Remove all text runs from this text.
/// </summary>
void clear();
/// <summary>
/// Clear any runs in this text and add a single run with default formatting and
/// the given string as its textual content.
/// </summary>
void plain_text(const std::string &s);
/// <summary>
/// Combine the textual content of each text run in order and return the result.
/// </summary>
std::string plain_text() const;
/// <summary>
/// Returns a copy of the individual runs that comprise this text.
/// </summary>
std::vector<text_run> runs() const;
/// <summary>
/// Set the runs of this text all at once.
/// </summary>
void runs(const std::vector<text_run> &new_runs);
/// <summary>
/// Add a new run to the end of the set of runs.
/// </summary>
void add_run(const text_run &t);
/// <summary>
/// Returns true if the runs that make up this text are identical to those in rhs.
/// </summary>
bool operator==(const formatted_text &rhs) const;
/// <summary>
/// Returns true if this text has a single unformatted run with text equal to rhs.
/// </summary>
bool operator==(const std::string &rhs) const;
private:
/// <summary>
///
/// </summary>
std::vector<text_run> runs_;
};
} // namespace xlnt

View File

@ -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 <string>
#include <xlnt/xlnt_config.hpp>
#include <xlnt/styles/color.hpp>
#include <xlnt/styles/font.hpp>
#include <xlnt/utils/optional.hpp>
namespace xlnt {
// todo: should this just be a struct?
/// <summary>
/// A formatted string
/// </summary>
class XLNT_API text_run
{
public:
/// <summary>
///
/// </summary>
text_run();
/// <summary>
///
/// </summary>
text_run(const std::string &string);
/// <summary>
///
/// </summary>
bool has_formatting() const;
/// <summary>
///
/// </summary>
std::string string() const;
/// <summary>
///
/// </summary>
text_run &string(const std::string &string);
/// <summary>
///
/// </summary>
bool has_size() const;
/// <summary>
///
/// </summary>
std::size_t size() const;
/// <summary>
///
/// </summary>
text_run &size(std::size_t size);
/// <summary>
///
/// </summary>
bool has_color() const;
/// <summary>
///
/// </summary>
xlnt::color color() const;
/// <summary>
///
/// </summary>
text_run &color(const class color &new_color);
/// <summary>
///
/// </summary>
bool has_font() const;
/// <summary>
///
/// </summary>
std::string font() const;
/// <summary>
///
/// </summary>
text_run &font(const std::string &font);
/// <summary>
///
/// </summary>
bool has_family() const;
/// <summary>
///
/// </summary>
std::size_t family() const;
/// <summary>
///
/// </summary>
text_run &family(std::size_t family);
/// <summary>
///
/// </summary>
bool has_scheme() const;
/// <summary>
///
/// </summary>
std::string scheme() const;
/// <summary>
///
/// </summary>
text_run &scheme(const std::string &scheme);
/// <summary>
///
/// </summary>
bool bold() const;
/// <summary>
///
/// </summary>
text_run &bold(bool bold);
/// <summary>
///
/// </summary>
bool underline_set() const;
/// <summary>
///
/// </summary>
bool underlined() const;
/// <summary>
///
/// </summary>
font::underline_style underline() const;
/// <summary>
///
/// </summary>
text_run &underline(font::underline_style style);
private:
/// <summary>
///
/// </summary>
std::string string_;
/// <summary>
///
/// </summary>
optional<xlnt::font> font_;
};
} // namespace xlnt

View File

@ -120,12 +120,12 @@ public:
/// <summary>
///
/// </summary>
font &size(std::size_t size);
font &size(double size);
/// <summary>
///
/// </summary>
std::size_t size() const;
double size() const;
/// <summary>
///
@ -211,7 +211,7 @@ private:
/// <summary>
///
/// </summary>
optional<std::size_t> size_;
optional<double> size_;
/// <summary>
///

View File

@ -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:
/// <summary>
///
/// </summary>
void add_shared_string(const formatted_text &shared, bool allow_duplicates = false);
void add_shared_string(const rich_text &shared, bool allow_duplicates = false);
/// <summary>
///
/// </summary>
std::vector<formatted_text> &shared_strings();
std::vector<rich_text> &shared_strings();
/// <summary>
///
/// </summary>
const std::vector<formatted_text> &shared_strings() const;
const std::vector<rich_text> &shared_strings() const;
// thumbnail

View File

@ -29,7 +29,7 @@
#include <unordered_map>
#include <xlnt/xlnt_config.hpp>
#include <xlnt/cell/formatted_text.hpp>
#include <xlnt/cell/rich_text.hpp>
#include <xlnt/utils/scoped_enum_hash.hpp>
namespace xlnt {
@ -113,13 +113,13 @@ public:
/// <summary>
/// Add a header at the given location with the given text.
/// </summary>
header_footer &header(location where, const formatted_text &text);
header_footer &header(location where, const rich_text &text);
/// <summary>
/// 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.
/// </summary>
formatted_text header(location where) const;
rich_text header(location where) const;
// First Page Header
@ -146,14 +146,14 @@ public:
/// <summary>
/// Add a header on the first page at the given location with the given text.
/// </summary>
header_footer &first_page_header(location where, const formatted_text &text);
header_footer &first_page_header(location where, const rich_text &text);
/// <summary>
/// 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.
/// </summary>
formatted_text first_page_header(location where) const;
rich_text first_page_header(location where) const;
// Odd/Even Header
@ -181,21 +181,21 @@ public:
/// <summary>
/// Add a header for odd pages at the given location with the given text.
/// </summary>
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);
/// <summary>
/// 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.
/// </summary>
formatted_text odd_header(location where) const;
rich_text odd_header(location where) const;
/// <summary>
/// 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.
/// </summary>
formatted_text even_header(location where) const;
rich_text even_header(location where) const;
// Normal Footer
@ -223,13 +223,13 @@ public:
/// <summary>
/// Add a footer at the given location with the given text.
/// </summary>
header_footer &footer(location where, const formatted_text &text);
header_footer &footer(location where, const rich_text &text);
/// <summary>
/// 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.
/// </summary>
formatted_text footer(location where) const;
rich_text footer(location where) const;
// First Page footer
@ -256,14 +256,14 @@ public:
/// <summary>
/// Add a footer on the first page at the given location with the given text.
/// </summary>
header_footer &first_page_footer(location where, const formatted_text &text);
header_footer &first_page_footer(location where, const rich_text &text);
/// <summary>
/// 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.
/// </summary>
formatted_text first_page_footer(location where) const;
rich_text first_page_footer(location where) const;
// Odd/Even Footer
@ -291,28 +291,28 @@ public:
/// <summary>
/// Add a footer for odd pages at the given location with the given text.
/// </summary>
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);
/// <summary>
/// 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.
/// </summary>
formatted_text odd_footer(location where) const;
rich_text odd_footer(location where) const;
/// <summary>
/// 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.
/// </summary>
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<location, formatted_text, scoped_enum_hash<location>>;
using container = std::unordered_map<location, rich_text, scoped_enum_hash<location>>;
container odd_headers_;
container even_headers_;

View File

@ -30,9 +30,9 @@
#include <xlnt/cell/cell_reference.hpp>
#include <xlnt/cell/cell_type.hpp>
#include <xlnt/cell/comment.hpp>
#include <xlnt/cell/formatted_text.hpp>
#include <xlnt/cell/rich_text.hpp>
#include <xlnt/cell/index_types.hpp>
#include <xlnt/cell/text_run.hpp>
#include <xlnt/cell/rich_text_run.hpp>
// packaging
#include <xlnt/packaging/manifest.hpp>

View File

@ -29,7 +29,7 @@
#include <xlnt/cell/cell.hpp>
#include <xlnt/cell/cell_reference.hpp>
#include <xlnt/cell/comment.hpp>
#include <xlnt/cell/formatted_text.hpp>
#include <xlnt/cell/rich_text.hpp>
#include <xlnt/packaging/relationship.hpp>
#include <xlnt/styles/alignment.hpp>
#include <xlnt/styles/border.hpp>
@ -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);

View File

@ -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_;
}

View File

@ -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 <numeric>
#include <xlnt/cell/formatted_text.hpp>
#include <xlnt/cell/text_run.hpp>
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<text_run> 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

View File

@ -7,57 +7,69 @@
#include <xlnt/xlnt.hpp>
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);
}

View File

@ -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 <xlnt/cell/text_run.hpp>
#include <xlnt/styles/color.hpp>
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

View File

@ -27,7 +27,7 @@
#include <xlnt/cell/cell_type.hpp>
#include <xlnt/cell/comment.hpp>
#include <xlnt/cell/formatted_text.hpp>
#include <xlnt/cell/rich_text.hpp>
#include <xlnt/cell/index_types.hpp>
#include <xlnt/utils/optional.hpp>
@ -50,7 +50,7 @@ struct cell_impl
bool is_merged_;
formatted_text value_text_;
rich_text value_text_;
long double value_numeric_;
optional<std::string> formula_;

View File

@ -82,7 +82,7 @@ struct workbook_impl
optional<std::size_t> active_sheet_index_;
std::list<worksheet_impl> worksheets_;
std::vector<formatted_text> shared_strings_;
std::vector<rich_text> shared_strings_;
optional<stylesheet> stylesheet_;

View File

@ -56,9 +56,9 @@ struct hash<xml::qname>
namespace {
std::array<xlnt::optional<xlnt::formatted_text>, 3> parse_header_footer(const std::string &hf_string)
std::array<xlnt::optional<xlnt::rich_text>, 3> parse_header_footer(const std::string &hf_string)
{
std::array<xlnt::optional<xlnt::formatted_text>, 3> result;
std::array<xlnt::optional<xlnt::rich_text>, 3> result;
if (hf_string.empty())
{
@ -277,8 +277,8 @@ std::array<xlnt::optional<xlnt::formatted_text>, 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<xlnt::optional<xlnt::formatted_text>, 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<xlnt::optional<xlnt::formatted_text>, 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::size_t>(std::stoi(current_token.value)));
if (!current_run.second.is_set())
{
current_run.second = xlnt::font();
}
current_run.second.get().size(static_cast<std::size_t>(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<xlnt::optional<xlnt::formatted_text>, 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<xlnt::optional<xlnt::formatted_text>, 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<xlnt::optional<xlnt::formatted_text>, 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<xlnt::optional<xlnt::formatted_text>, 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<xlnt::optional<xlnt::formatted_text>, 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<xlnt::optional<xlnt::formatted_text>, 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<std::array<optional<formatted_text>, 3>> odd_header;
optional<std::array<optional<formatted_text>, 3>> odd_footer;
optional<std::array<optional<formatted_text>, 3>> even_header;
optional<std::array<optional<formatted_text>, 3>> even_footer;
optional<std::array<optional<formatted_text>, 3>> first_header;
optional<std::array<optional<formatted_text>, 3>> first_footer;
optional<std::array<optional<rich_text>, 3>> odd_header;
optional<std::array<optional<rich_text>, 3>> odd_footer;
optional<std::array<optional<rich_text>, 3>> even_header;
optional<std::array<optional<rich_text>, 3>> even_footer;
optional<std::array<optional<rich_text>, 3>> first_header;
optional<std::array<optional<rich_text>, 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<std::size_t>("val"));
run.second.get().size(parser().attribute<std::size_t>("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<std::size_t>("val"));
run.second.get().family(parser().attribute<std::size_t>("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<font::underline_style>("val"));
run.second.get().underline(parser().attribute<font::underline_style>("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
{

View File

@ -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:
/// <summary>
/// Read a rich text CT_RElt from the document currently being parsed.
/// </summary>
formatted_text read_formatted_text(const xml::qname &parent);
rich_text read_rich_text(const xml::qname &parent);
/// <summary>
/// Returns true if the givent document type represents an XLSX file.

View File

@ -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<formatted_text>())
if (shared_strings[i] == cell.value<rich_text>())
{
match_index = static_cast<int>(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<header_footer::location, std::string, scoped_enum_hash<header_footer::location>>
{
@ -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");
}

View File

@ -22,6 +22,8 @@
// @license: http://www.opensource.org/licenses/mit-license.php
// @author: see AUTHORS file
#include <cmath>
#include <xlnt/styles/font.hpp>
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;
}

View File

@ -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")));
}
};

View File

@ -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<formatted_text> &workbook::shared_strings()
std::vector<rich_text> &workbook::shared_strings()
{
return d_->shared_strings_;
}
const std::vector<formatted_text> &workbook::shared_strings() const
const std::vector<rich_text> &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();

View File

@ -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);
}