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 <cstddef>
27 : :
28 : : #include <xlnt/xlnt_config.hpp>
29 : : #include <xlnt/utils/optional.hpp>
30 : :
31 : : namespace xlnt {
32 : :
33 : : /// <summary>
34 : : /// A workbook can be opened in multiple windows with different views.
35 : : /// This class represents a particular view used by one window.
36 : : /// </summary>
37 : : class XLNT_API workbook_view
38 : : {
39 : : public:
40 : : /// <summary>
41 : : /// If true, dates will be grouped when presenting the user with filtering options.
42 : : /// </summary>
43 : : bool auto_filter_date_grouping = true;
44 : :
45 : : /// <summary>
46 : : /// If true, the view will be minimized.
47 : : /// </summary>
48 : : bool minimized = false;
49 : :
50 : : /// <summary>
51 : : /// If true, the horizontal scroll bar will be displayed.
52 : : /// </summary>
53 : : bool show_horizontal_scroll = true;
54 : :
55 : : /// <summary>
56 : : /// If true, the sheet tabs will be displayed.
57 : : /// </summary>
58 : : bool show_sheet_tabs = true;
59 : :
60 : : /// <summary>
61 : : /// If true, the vertical scroll bar will be displayed.
62 : : /// </summary>
63 : : bool show_vertical_scroll = true;
64 : :
65 : : /// <summary>
66 : : /// If true, the workbook window will be visible.
67 : : /// </summary>
68 : : bool visible = true;
69 : :
70 : : /// <summary>
71 : : /// The optional index to the active sheet in this view.
72 : : /// </summary>
73 : : optional<std::size_t> active_tab;
74 : :
75 : : /// <summary>
76 : : /// The optional index to the first sheet in this view.
77 : : /// </summary>
78 : : optional<std::size_t> first_sheet;
79 : :
80 : : /// <summary>
81 : : /// The optional ratio between the tabs bar and the horizontal scroll bar.
82 : : /// </summary>
83 : : optional<std::size_t> tab_ratio;
84 : :
85 : : /// <summary>
86 : : /// The width of the workbook window in twips.
87 : : /// </summary>
88 : : optional<std::size_t> window_width;
89 : :
90 : : /// <summary>
91 : : /// The height of the workbook window in twips.
92 : : /// </summary>
93 : : optional<std::size_t> window_height;
94 : :
95 : : /// <summary>
96 : : /// The distance of the workbook window from the left side of the screen in twips.
97 : : /// </summary>
98 : : optional<int> x_window;
99 : :
100 : : /// <summary>
101 : : /// The distance of the workbook window from the top of the screen in twips.
102 : : /// </summary>
103 : : optional<int> y_window;
104 : : };
105 : :
106 :CBC 8 : inline bool operator==(const workbook_view &lhs, const workbook_view &rhs)
107 : : {
108 : 8 : return lhs.active_tab == rhs.active_tab
109 [ + - ]: 8 : && lhs.auto_filter_date_grouping == rhs.auto_filter_date_grouping
110 [ + - ]: 8 : && lhs.first_sheet == rhs.first_sheet
111 [ + - ]: 8 : && lhs.minimized == rhs.minimized
112 [ + - ]: 8 : && lhs.show_horizontal_scroll == rhs.show_horizontal_scroll
113 [ + - ]: 8 : && lhs.show_sheet_tabs == rhs.show_sheet_tabs
114 [ + - ]: 8 : && lhs.show_vertical_scroll == rhs.show_vertical_scroll
115 [ + - ]: 8 : && lhs.tab_ratio == rhs.tab_ratio
116 [ + - + - ]: 16 : && lhs.visible == rhs.visible;
117 : : }
118 : :
119 : : inline bool operator!=(const workbook_view &lhs, const workbook_view &rhs)
120 : : {
121 : : return !(lhs == rhs);
122 : : }
123 : :
124 : : } // namespace xlnt
|