umya_spreadsheet/structs/
anchor.rs1#[derive(Default, Debug, Clone)]
2pub struct Anchor {
3 left_column: u32,
4 left_offset: u32,
5 top_row: u32,
6 top_offset: u32,
7 right_column: u32,
8 right_offset: u32,
9 bottom_row: u32,
10 bottom_offset: u32,
11}
12
13impl Anchor {
14 #[inline]
15 #[must_use]
16 pub fn left_column(&self) -> u32 {
17 self.left_column
18 }
19
20 #[inline]
21 #[must_use]
22 #[deprecated(since = "3.0.0", note = "Use left_column()")]
23 pub fn get_left_column(&self) -> u32 {
24 self.left_column()
25 }
26
27 #[inline]
28 pub fn set_left_column(&mut self, value: u32) {
29 self.left_column = value;
30 }
31
32 #[inline]
33 #[must_use]
34 pub fn left_offset(&self) -> u32 {
35 self.left_offset
36 }
37
38 #[inline]
39 #[must_use]
40 #[deprecated(since = "3.0.0", note = "Use left_offset()")]
41 pub fn get_left_offset(&self) -> u32 {
42 self.left_offset()
43 }
44
45 #[inline]
46 pub fn set_left_offset(&mut self, value: u32) {
47 self.left_offset = value;
48 }
49
50 #[inline]
51 #[must_use]
52 pub fn top_row(&self) -> u32 {
53 self.top_row
54 }
55
56 #[inline]
57 #[must_use]
58 #[deprecated(since = "3.0.0", note = "Use top_row()")]
59 pub fn get_top_row(&self) -> u32 {
60 self.top_row()
61 }
62
63 #[inline]
64 pub fn set_top_row(&mut self, value: u32) {
65 self.top_row = value;
66 }
67
68 #[inline]
69 #[must_use]
70 pub fn top_offset(&self) -> u32 {
71 self.top_offset
72 }
73
74 #[inline]
75 #[must_use]
76 #[deprecated(since = "3.0.0", note = "Use top_offset()")]
77 pub fn get_top_offset(&self) -> u32 {
78 self.top_offset()
79 }
80
81 #[inline]
82 pub fn set_top_offset(&mut self, value: u32) {
83 self.top_offset = value;
84 }
85
86 #[inline]
87 #[must_use]
88 pub fn right_column(&self) -> u32 {
89 self.right_column
90 }
91
92 #[inline]
93 #[must_use]
94 #[deprecated(since = "3.0.0", note = "Use right_column()")]
95 pub fn get_right_column(&self) -> u32 {
96 self.right_column()
97 }
98
99 #[inline]
100 pub fn set_right_column(&mut self, value: u32) {
101 self.right_column = value;
102 }
103
104 #[inline]
105 #[must_use]
106 pub fn right_offset(&self) -> u32 {
107 self.right_offset
108 }
109
110 #[inline]
111 #[must_use]
112 #[deprecated(since = "3.0.0", note = "Use right_offset()")]
113 pub fn get_right_offset(&self) -> u32 {
114 self.right_offset()
115 }
116
117 #[inline]
118 pub fn set_right_offset(&mut self, value: u32) {
119 self.right_offset = value;
120 }
121
122 #[inline]
123 #[must_use]
124 pub fn bottom_row(&self) -> u32 {
125 self.bottom_row
126 }
127
128 #[inline]
129 #[must_use]
130 #[deprecated(since = "3.0.0", note = "Use bottom_row()")]
131 pub fn get_bottom_row(&self) -> u32 {
132 self.bottom_row()
133 }
134
135 #[inline]
136 pub fn set_bottom_row(&mut self, value: u32) {
137 self.bottom_row = value;
138 }
139
140 #[inline]
141 #[must_use]
142 pub fn bottom_offset(&self) -> u32 {
143 self.bottom_offset
144 }
145
146 #[inline]
147 #[must_use]
148 #[deprecated(since = "3.0.0", note = "Use bottom_offset()")]
149 pub fn get_bottom_offset(&self) -> u32 {
150 self.bottom_offset()
151 }
152
153 #[inline]
154 pub fn set_bottom_offset(&mut self, value: u32) {
155 self.bottom_offset = value;
156 }
157
158 #[inline]
159 pub(crate) fn adjustment_insert_row(&mut self, num_rows: u32) {
160 self.top_row += num_rows;
161 self.bottom_row += num_rows;
162 }
163
164 #[inline]
165 pub(crate) fn adjustment_insert_column(&mut self, num_cols: u32) {
166 self.left_column += num_cols;
167 self.right_column += num_cols;
168 }
169
170 #[inline]
171 pub(crate) fn adjustment_remove_row(&mut self, num_rows: u32) {
172 self.top_row = self.top_row.saturating_sub(num_rows).max(1);
173 self.bottom_row = self.bottom_row.saturating_sub(num_rows).max(1);
174 }
175
176 #[inline]
177 pub(crate) fn adjustment_remove_column(&mut self, num_cols: u32) {
178 self.left_column = self.left_column.saturating_sub(num_cols).max(1);
179 self.right_column = self.right_column.saturating_sub(num_cols).max(1);
180 }
181}