Branch data TLA Line data Source code
1 : : // Copyright (c) 2014-2022 Thomas Fussell
2 : : // Copyright (c) 2010-2015 openpyxl
3 : : // Copyright (c) 2024-2025 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 : :
30 : : #include <xlnt/xlnt_config.hpp>
31 : : #include <xlnt/utils/optional.hpp>
32 : :
33 : : namespace xlnt {
34 : :
35 : : /// <summary>
36 : : /// Properties applied to a column in a worksheet.
37 : : /// Columns can have a size and a style.
38 : : /// </summary>
39 : : class XLNT_API column_properties
40 : : {
41 : : public:
42 : : /// <summary>
43 : : /// The optional width of the column
44 : : /// </summary>
45 : : optional<double> width;
46 : :
47 : : /// <summary>
48 : : /// If true, this is a custom width
49 : : /// </summary>
50 : : bool custom_width = false;
51 : :
52 : : /// <summary>
53 : : /// The style index of this column. This shouldn't be used since style indices
54 : : /// aren't supposed to be used directly in xlnt. (TODO)
55 : : /// </summary>
56 : : optional<std::size_t> style;
57 : :
58 : : /// <summary>
59 : : /// Is this column sized to fit its content as best it can
60 : : /// serialise if true
61 : : /// </summary>
62 : : bool best_fit = false;
63 : :
64 : : /// <summary>
65 : : /// If true, this column will be hidden
66 : : /// </summary>
67 : : bool hidden = false;
68 : : };
69 : :
70 :CBC 6150 : inline bool operator==(const column_properties &lhs, const column_properties &rhs)
71 : : {
72 : 6150 : return lhs.width == rhs.width
73 [ + - ]: 6150 : && lhs.custom_width == rhs.custom_width
74 [ + - ]: 6150 : && lhs.style == rhs.style
75 [ + - ]: 6150 : && lhs.best_fit == rhs.best_fit
76 [ + - + - ]: 12300 : && lhs.hidden == rhs.hidden;
77 : : }
78 : :
79 : : inline bool operator!=(const column_properties &lhs, const column_properties &rhs)
80 : : {
81 : : return !(lhs == rhs);
82 : : }
83 : :
84 : : } // namespace xlnt
|