// Copyright (c) 2014-2021 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, 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 #include namespace xlnt { class alignment; class border; class cell; class fill; class font; class number_format; class protection; namespace detail { struct style_impl; struct stylesheet; class xlsx_consumer; } // namespace detail /// /// Describes a style which has a name and can be applied to multiple individual /// formats. In Excel this is a "Cell Style". /// class XLNT_API style { public: /// /// Delete zero-argument constructor /// style() = delete; /// /// Default copy constructor. Constructs a style using the same PIMPL as other. /// style(const style &other) = default; /// /// Returns the name of this style. /// std::string name() const; /// /// Sets the name of this style to name. /// style name(const std::string &name); /// /// Returns true if this style is hidden. /// bool hidden() const; /// /// Sets the hidden state of this style to value. A hidden style will not /// be shown in the list of selectable styles in the UI, but will still /// apply its formatting to cells using it. /// style hidden(bool value); /// /// Returns true if this is a builtin style that has been customized and /// should therefore be persisted in the workbook. /// bool custom_builtin() const; /// /// Returns the index of the builtin style that this style is an instance /// of or is a customized version thereof. If style::builtin() is false, /// this will throw an invalid_attribute exception. /// std::size_t builtin_id() const; /// /// Returns true if this is a builtin style. /// bool builtin() const; // Formatting (xf) components /// /// Returns the alignment of this style. /// class alignment alignment() const; /// /// Returns true if the alignment of this style should be applied to cells /// using it. /// bool alignment_applied() const; /// /// Sets the alignment of this style to new_alignment. Applied, which defaults /// to true, determines whether the alignment should be enabled for cells using /// this style. /// style alignment(const xlnt::alignment &new_alignment, optional applied = {}); /// /// Returns the border of this style. /// class border border() const; /// /// Returns true if the border set for this style should be applied to cells using the style. /// bool border_applied() const; /// /// Sets the border of this style to new_border. Applied, which defaults /// to true, determines whether the border should be enabled for cells using /// this style. /// style border(const xlnt::border &new_border, optional applied = {}); /// /// Returns the fill of this style. /// class fill fill() const; /// /// Returns true if the fill set for this style should be applied to cells using the style. /// bool fill_applied() const; /// /// Sets the fill of this style to new_fill. Applied, which defaults /// to true, determines whether the border should be enabled for cells using /// this style. /// style fill(const xlnt::fill &new_fill, optional applied = {}); /// /// Returns the font of this style. /// class font font() const; /// /// Returns true if the font set for this style should be applied to cells using the style. /// bool font_applied() const; /// /// Sets the font of this style to new_font. Applied, which defaults /// to true, determines whether the font should be enabled for cells using /// this style. /// style font(const xlnt::font &new_font, optional applied = {}); /// /// Returns the number_format of this style. /// class number_format number_format() const; /// /// Returns true if the number_format set for this style should be applied to cells using the style. /// bool number_format_applied() const; /// /// Sets the number format of this style to new_number_format. Applied, which defaults /// to true, determines whether the number format should be enabled for cells using /// this style. /// style number_format(const xlnt::number_format &new_number_format, optional applied = {}); /// /// Returns the protection of this style. /// class protection protection() const; /// /// Returns true if the protection set for this style should be applied to cells using the style. /// bool protection_applied() const; /// /// Sets the border of this style to new_protection. Applied, which defaults /// to true, determines whether the protection should be enabled for cells using /// this style. /// style protection(const xlnt::protection &new_protection, optional applied = {}); /// /// Returns true if the pivot table interface is enabled for this style. /// bool pivot_button() const; /// /// If show is true, a pivot table interface will be displayed for cells using /// this style. /// void pivot_button(bool show); /// /// Returns true if this style 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 style (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 style is equivalent to other. /// bool operator==(const style &other) const; /// /// Returns true if this style is not equivalent to other. /// bool operator!=(const style &other) const; private: friend struct detail::stylesheet; friend class detail::xlsx_consumer; /// /// Constructs a style from an impl pointer. /// style(detail::style_impl *d); /// /// The internal implementation of this style /// detail::style_impl *d_; }; } // namespace xlnt