xlnt
style.hpp
1 // Copyright (c) 2014-2022 Thomas Fussell
2 // Copyright (c) 2010-2015 openpyxl
3 // Copyright (c) 2024 xlnt-community
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining a copy
6 // of this software and associated documentation files (the "Software"), to deal
7 // in the Software without restriction, including without limitation the rights
8 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 // copies of the Software, and to permit persons to whom the Software is
10 // furnished to do so, subject to the following conditions:
11 //
12 // The above copyright notice and this permission notice shall be included in
13 // all copies or substantial portions of the Software.
14 //
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 // THE SOFTWARE
22 //
23 // @license: http://www.opensource.org/licenses/mit-license.php
24 // @author: see AUTHORS file
25 
26 #pragma once
27 
28 #include <cstdint>
29 #include <string>
30 
31 #include <xlnt/xlnt_config.hpp>
32 #include <xlnt/utils/optional.hpp>
33 
34 namespace xlnt {
35 
36 class alignment;
37 class border;
38 class cell;
39 class fill;
40 class font;
41 class number_format;
42 class protection;
43 
44 namespace detail {
45 
46 struct style_impl;
47 struct stylesheet;
48 class xlsx_consumer;
49 
50 } // namespace detail
51 
56 class XLNT_API style
57 {
58 public:
62  style() = delete;
63 
67  style(const style &other) = default;
68 
72  std::string name() const;
73 
77  style name(const std::string &name);
78 
82  bool hidden() const;
83 
89  style hidden(bool value);
90 
95  bool custom_builtin() const;
96 
102  std::size_t builtin_id() const;
103 
107  bool builtin() const;
108 
109  // Formatting (xf) components
110 
114  class alignment alignment() const;
115 
120  bool alignment_applied() const;
121 
127  style alignment(const xlnt::alignment &new_alignment, optional<bool> applied = {});
128 
132  class border border() const;
133 
137  bool border_applied() const;
138 
144  style border(const xlnt::border &new_border, optional<bool> applied = {});
145 
149  class fill fill() const;
150 
154  bool fill_applied() const;
155 
161  style fill(const xlnt::fill &new_fill, optional<bool> applied = {});
162 
166  class font font() const;
167 
171  bool font_applied() const;
172 
178  style font(const xlnt::font &new_font, optional<bool> applied = {});
179 
183  class number_format number_format() const;
184 
188  bool number_format_applied() const;
189 
195  style number_format(const xlnt::number_format &new_number_format, optional<bool> applied = {});
196 
200  class protection protection() const;
201 
205  bool protection_applied() const;
206 
212  style protection(const xlnt::protection &new_protection, optional<bool> applied = {});
213 
217  bool pivot_button() const;
218 
223  void pivot_button(bool show);
224 
228  bool quote_prefix() const;
229 
235  void quote_prefix(bool quote);
236 
240  bool operator==(const style &other) const;
241 
245  bool operator!=(const style &other) const;
246 
247 private:
248  friend struct detail::stylesheet;
249  friend class detail::xlsx_consumer;
250 
254  style(detail::style_impl *d);
255 
259  detail::style_impl *d_;
260 };
261 
262 } // namespace xlnt
Enumerates the possible types a cell can be determined by it&#39;s current value.
Definition: cell.hpp:37
Describes the font style of a particular cell.
Definition: font.hpp:41
Describes the fill style of a particular cell.
Definition: fill.hpp:299
Describes the border style of a particular cell.
Definition: border.hpp:94
bool operator==(std::nullptr_t, const cell &cell)
Returns true if this cell is uninitialized.
Describes the number formatting applied to text and numbers within a certain cell.
Definition: number_format.hpp:41
Alignment options that determine how text should be displayed within a cell.
Definition: alignment.hpp:63
bool operator!=(const std::string &reference_string, const range_reference &ref)
Returns true if the string representation of the range is not equivalent to ref.
Describes the protection style of a particular cell.
Definition: protection.hpp:38
Describes a style which has a name and can be applied to multiple individual formats. In Excel this is a "Cell Style".
Definition: style.hpp:56