// Copyright (c) 2014-2021 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, ARISING 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 namespace xlnt { class alignment; class border; class cell; class fill; class font; class number_format; class protection; class style; template class optional; namespace detail { struct format_impl; struct stylesheet; class xlsx_producer; class xlsx_consumer; } // namespace detail /// /// Describes the formatting of a particular cell. /// class XLNT_API format { public: /// /// Returns the alignment of this format. /// class alignment alignment() const; /// /// Sets the alignment of this format to new_alignment. Applied, which defaults /// to true, determines whether the alignment should be enabled for cells using /// this format. /// format alignment(const xlnt::alignment &new_alignment, xlnt::optional applied = {}); /// /// Returns true if the alignment of this format should be applied to cells /// using it. /// bool alignment_applied() const; /// /// Returns the border of this format. /// class border border() const; /// /// Sets the border of this format to new_border. Applied, which defaults /// to true, determines whether the border should be enabled for cells using /// this format. /// format border(const xlnt::border &new_border, xlnt::optional applied = {}); /// /// Returns true if the border set for this format should be applied to cells using the format. /// bool border_applied() const; /// /// Returns the fill of this format. /// class fill fill() const; /// /// Sets the fill of this format to new_fill. Applied, which defaults /// to true, determines whether the border should be enabled for cells using /// this format. /// format fill(const xlnt::fill &new_fill, xlnt::optional applied = {}); /// /// Returns true if the fill set for this format should be applied to cells using the format. /// bool fill_applied() const; /// /// Returns the font of this format. /// class font font() const; /// /// Sets the font of this format to new_font. Applied, which defaults /// to true, determines whether the font should be enabled for cells using /// this format. /// format font(const xlnt::font &new_font, xlnt::optional applied = {}); /// /// Returns true if the font set for this format should be applied to cells using the format. /// bool font_applied() const; /// /// Returns the number format of this format. /// class number_format number_format() const; /// /// Sets the number format of this format to new_number_format. Applied, which defaults /// to true, determines whether the number format should be enabled for cells using /// this format. /// format number_format(const xlnt::number_format &new_number_format, xlnt::optional applied = {}); /// /// Returns true if the number_format set for this format should be applied to cells using the format. /// bool number_format_applied() const; /// /// Returns the protection of this format. /// class protection protection() const; /// /// Returns true if the protection set for this format should be applied to cells using the format. /// bool protection_applied() const; /// /// Sets the protection of this format to new_protection. Applied, which defaults /// to true, determines whether the protection should be enabled for cells using /// this format. /// format protection(const xlnt::protection &new_protection, xlnt::optional applied = {}); /// /// Returns true if the pivot table interface is enabled for this format. /// bool pivot_button() const; /// /// If show is true, a pivot table interface will be displayed for cells using /// this format. /// void pivot_button(bool show); /// /// Returns true if this format should add a single-quote prefix for all text values. /// bool quote_prefix() const; /// /// If quote is true, enables a single-quote prefix for all text values in cells /// using this format (e.g. "abc" will appear as "'abc"). The text will also not /// be stored in sharedStrings when this is enabled. /// void quote_prefix(bool quote); /// /// Returns true if this format has a corresponding style applied. /// bool has_style() const; /// /// Removes the style from this format if it exists. /// void clear_style(); /// /// Sets the style of this format to a style with the given name. /// format style(const std::string &name); /// /// Sets the style of this format to new_style. /// format style(const class style &new_style); /// /// Returns the style of this format. If it has no style, an invalid_parameter /// exception will be thrown. /// class style style(); /// /// Returns the style of this format. If it has no style, an invalid_parameters /// exception will be thrown. /// const class style style() const; private: friend struct detail::stylesheet; friend class detail::xlsx_producer; friend class detail::xlsx_consumer; friend class cell; /// /// Constructs a format from an impl pointer. /// format(detail::format_impl *d); /// /// The internal implementation of this format /// detail::format_impl *d_; }; } // namespace xlnt