xlnt
alignment.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 <xlnt/xlnt_config.hpp>
29 #include <xlnt/utils/optional.hpp>
30 
31 namespace xlnt {
32 
36 enum class XLNT_API horizontal_alignment
37 {
38  general,
39  left,
40  center,
41  right,
42  fill,
43  justify,
44  center_continuous,
45  distributed
46 };
47 
51 enum class XLNT_API vertical_alignment
52 {
53  top,
54  center,
55  bottom,
56  justify,
57  distributed
58 };
59 
63 class XLNT_API alignment
64 {
65 public:
69  bool shrink() const;
70 
74  alignment &shrink(bool shrink_to_fit);
75 
79  bool wrap() const;
80 
84  alignment &wrap(bool wrap_text);
85 
89  optional<int> indent() const;
90 
95  alignment &indent(int indent_size);
96 
100  optional<int> rotation() const;
101 
105  alignment &rotation(int text_rotation);
106 
110  optional<horizontal_alignment> horizontal() const;
111 
115  alignment &horizontal(horizontal_alignment horizontal);
116 
120  optional<vertical_alignment> vertical() const;
121 
125  alignment &vertical(vertical_alignment vertical);
126 
130  bool operator==(const alignment &other) const;
131 
135  bool operator!=(const alignment &other) const;
136 
137 private:
141  bool shrink_to_fit_ = false;
142 
146  bool wrap_text_ = false;
147 
151  optional<int> indent_;
152 
156  optional<int> text_rotation_;
157 
161  optional<horizontal_alignment> horizontal_;
162 
167 };
168 
169 } // namespace xlnt
horizontal_alignment
Text can be aligned horizontally within a cell in these enumerated ways.
Definition: alignment.hpp:36
vertical_alignment
Text can be aligned vertically within a cell in these enumerated ways.
Definition: alignment.hpp:51
Enumerates the possible types a cell can be determined by it&#39;s current value.
Definition: cell.hpp:37
Describes the fill style of a particular cell.
Definition: fill.hpp:299
bool operator==(std::nullptr_t, const cell &cell)
Returns true if this cell is uninitialized.
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.