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 : : #include <xlnt/styles/protection.hpp>
27 : :
28 : : namespace xlnt {
29 : :
30 :CBC 1 : protection protection::unlocked_and_visible()
31 : : {
32 : 1 : return protection();
33 : : }
34 : :
35 : 1 : protection protection::locked_and_visible()
36 : : {
37 : 1 : return protection().locked(true);
38 : : }
39 : :
40 : 1 : protection protection::unlocked_and_hidden()
41 : : {
42 : 1 : return protection().hidden(true);
43 : : }
44 : :
45 : 1 : protection protection::locked_and_hidden()
46 : : {
47 : 1 : return protection().locked(true).hidden(true);
48 : : }
49 : :
50 : 34 : protection::protection()
51 : 34 : : locked_(false), hidden_(false)
52 : : {
53 : 34 : }
54 : :
55 : 5 : bool protection::locked() const
56 : : {
57 : 5 : return locked_;
58 : : }
59 : :
60 : 32 : protection &protection::locked(bool locked)
61 : : {
62 : 32 : locked_ = locked;
63 : 32 : return *this;
64 : : }
65 : :
66 : 5 : bool protection::hidden() const
67 : : {
68 : 5 : return hidden_;
69 : : }
70 : :
71 : 32 : protection &protection::hidden(bool hidden)
72 : : {
73 : 32 : hidden_ = hidden;
74 : 32 : return *this;
75 : : }
76 : :
77 : 13 : bool protection::operator==(const protection &other) const
78 : : {
79 [ + - + - ]: 13 : return locked_ == other.locked_ && hidden_ == other.hidden_;
80 : : }
81 : :
82 :UBC 0 : bool protection::operator!=(const protection &other) const
83 : : {
84 : 0 : return !(*this == other);
85 : : }
86 : :
87 : : } // namespace xlnt
|