Branch data TLA Line data Source code
1 : : // Copyright (c) 2014-2022 Thomas Fussell
2 : : // Copyright (c) 2024-2025 xlnt-community
3 : : //
4 : : // Permission is hereby granted, free of charge, to any person obtaining a copy
5 : : // of this software and associated documentation files (the "Software"), to deal
6 : : // in the Software without restriction, including without limitation the rights
7 : : // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 : : // copies of the Software, and to permit persons to whom the Software is
9 : : // furnished to do so, subject to the following conditions:
10 : : //
11 : : // The above copyright notice and this permission notice shall be included in
12 : : // all copies or substantial portions of the Software.
13 : : //
14 : : // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 : : // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 : : // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 : : // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 : : // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 : : // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 : : // THE SOFTWARE
21 : : //
22 : : // @license: http://www.opensource.org/licenses/mit-license.php
23 : : // @author: see AUTHORS file
24 : : #pragma once
25 : :
26 : : #include <memory>
27 : : #include <string>
28 : :
29 : : #include <xlnt/cell/cell_type.hpp>
30 : : #include <xlnt/cell/comment.hpp>
31 : : #include <xlnt/cell/index_types.hpp>
32 : : #include <xlnt/cell/rich_text.hpp>
33 : : #include <xlnt/packaging/relationship.hpp>
34 : : #include <xlnt/utils/optional.hpp>
35 : : #include <detail/implementations/format_impl.hpp>
36 : : #include <detail/implementations/hyperlink_impl.hpp>
37 : :
38 : : namespace xlnt {
39 : : namespace detail {
40 : :
41 : : struct worksheet_impl;
42 : :
43 : : struct cell_impl
44 : : {
45 : : cell_type type_ = cell_type::empty;
46 : :
47 : : worksheet_impl *parent_ = nullptr;
48 : :
49 : : column_t column_ = 1;
50 : : row_t row_ = 1;
51 : :
52 : : bool is_merged_ = false;
53 : : bool phonetics_visible_ = false;
54 : :
55 : : rich_text value_text_;
56 : : double value_numeric_ = 0.0;
57 : :
58 : : optional<std::string> formula_;
59 : : optional<hyperlink_impl> hyperlink_;
60 : : format_impl_ptr format_;
61 : : optional<comment *> comment_;
62 : :
63 :CBC 2736 : bool is_garbage_collectible() const
64 : : {
65 [ + + + + : 2736 : return !(type_ != cell_type::empty || is_merged_ || phonetics_visible_ || formula_.is_set() || format_.is_set() || hyperlink_.is_set());
+ - + + +
+ + - ]
66 : : }
67 : : };
68 : :
69 : 8 : inline bool operator==(const cell_impl &lhs, const cell_impl &rhs)
70 : : {
71 : : // not comparing parent, row, column
72 : 8 : return lhs.type_ == rhs.type_
73 [ + - ]: 8 : && lhs.is_merged_ == rhs.is_merged_
74 [ + - ]: 8 : && lhs.phonetics_visible_ == rhs.phonetics_visible_
75 [ + - ]: 8 : && lhs.value_text_ == rhs.value_text_
76 [ + + ]: 8 : && float_equals(lhs.value_numeric_, rhs.value_numeric_)
77 [ + - ]: 7 : && lhs.formula_ == rhs.formula_
78 [ + - ]: 7 : && lhs.hyperlink_ == rhs.hyperlink_
79 [ + - + + : 7 : && (lhs.format_.is_set() == rhs.format_.is_set() && (!lhs.format_.is_set() || *lhs.format_.get() == *rhs.format_.get()))
+ - ]
80 [ + - + - : 16 : && (lhs.comment_.is_set() == rhs.comment_.is_set() && (!lhs.comment_.is_set() || *lhs.comment_.get() == *rhs.comment_.get()));
- + - - ]
81 : : }
82 : :
83 : : inline bool operator!=(const cell_impl &lhs, const cell_impl &rhs)
84 : : {
85 : : return !(lhs == rhs);
86 : : }
87 : :
88 : : } // namespace detail
89 : : } // namespace xlnt
|