xlnt
border.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 <cstddef>
29 #include <functional>
30 #include <unordered_map>
31 #include <vector>
32 
33 #include <xlnt/xlnt_config.hpp>
34 #include <xlnt/styles/color.hpp>
35 #include <xlnt/utils/optional.hpp>
36 
37 namespace xlnt {
38 
42 enum class XLNT_API border_side
43 {
44  start,
45  end,
46  top,
47  bottom,
48  diagonal,
49  vertical,
50  horizontal
51 };
52 
56 enum class XLNT_API border_style
57 {
58  none,
59  dashdot,
60  dashdotdot,
61  dashed,
62  dotted,
63  double_,
64  hair,
65  medium,
66  mediumdashdot,
67  mediumdashdotdot,
68  mediumdashed,
69  slantdashdot,
70  thick,
71  thin
72 };
73 
79 enum class XLNT_API diagonal_direction
80 {
81  neither,
82  up,
83  down,
84  both
85 };
86 
87 } // namespace xlnt
88 
89 namespace xlnt {
90 
94 class XLNT_API border
95 {
96 public:
101  class XLNT_API border_property
102  {
103  public:
108 
112  border_property &color(const xlnt::color &c);
113 
118 
122  border_property &style(border_style style);
123 
127  bool operator==(const border_property &right) const;
128 
132  bool operator!=(const border_property &right) const;
133 
134  private:
138  optional<class color> color_;
139 
143  optional<border_style> style_;
144  };
145 
149  static const std::vector<border_side> &all_sides();
150 
154  border();
155 
160 
164  border &side(border_side s, const border_property &prop);
165 
169  optional<diagonal_direction> diagonal() const;
170 
174  border &diagonal(diagonal_direction dir);
175 
179  bool operator==(const border &right) const;
180 
184  bool operator!=(const border &right) const;
185 
186 private:
191 
196 
201 
206 
210  optional<border_property> vertical_;
211 
215  optional<border_property> horizontal_;
216 
220  optional<border_property> diagonal_;
221 
225  optional<diagonal_direction> diagonal_direction_;
226 };
227 
228 } // namespace xlnt
Enumerates the possible types a cell can be determined by it&#39;s current value.
Definition: cell.hpp:37
Colors can be applied to many parts of a cell&#39;s style.
Definition: color.hpp:165
border_side
Enumerates the sides of a cell to which a border style can be applied.
Definition: border.hpp:42
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.
Each side of a cell can have a border_property applied to it to change how it is displayed.
Definition: border.hpp:101
diagonal_direction
Cells can have borders that go from the top-left to bottom-right or from the top-right to bottom-left...
Definition: border.hpp:79
border_style
Enumerates the pattern of the border lines on a particular side.
Definition: border.hpp:56
Many settings in xlnt are allowed to not have a value set. This class encapsulates a value which may ...
Definition: format.hpp:44
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 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