// Copyright (c) 2016-2018 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 rich_text { public: /// /// Constructs an empty rich text object with no font and empty text. /// rich_text() = default; /// /// Constructs a rich text object with the given text and no font. /// rich_text(const std::string &plain_text); /// /// Constructs a rich text object with the given text and font. /// rich_text(const std::string &plain_text, const class font &text_font); /// /// Copy constructor. /// rich_text(const rich_text_run &single_run); /// /// Removes all text runs from this text. /// void clear(); /// /// Clears any runs in this text and adds a single run with default formatting and /// the given string as its textual content. /// void plain_text(const std::string &s); /// /// Combines the textual content of each text run in order and returns the result. /// std::string plain_text() const; /// /// Returns a copy of the individual runs that comprise this text. /// std::vector runs() const; /// /// Sets the runs of this text all at once. /// void runs(const std::vector &new_runs); /// /// Adds a new run to the end of the set of runs. /// void add_run(const rich_text_run &t); /// /// Returns true if the runs that make up this text are identical to those in rhs. /// bool operator==(const rich_text &rhs) const; /// /// Returns true if the runs that make up this text are identical to those in rhs. /// bool operator!=(const rich_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; /// /// Returns true if this text has a single unformatted run with text equal to rhs. /// bool operator!=(const std::string &rhs) const; private: /// /// The runs that make up this rich text. /// std::vector runs_; }; } // namespace xlnt