xlnt
xlnt
worksheet
header_footer.hpp
1
// Copyright (c) 2014-2022 Thomas Fussell
2
// Copyright (c) 2010-2015 openpyxl
3
// Copyright (c) 2024 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 <cstdint>
29
#include <string>
30
#include <unordered_map>
31
32
#include <xlnt/xlnt_config.hpp>
33
#include <xlnt/cell/rich_text.hpp>
34
#include <xlnt/utils/scoped_enum_hash.hpp>
35
36
namespace
xlnt
{
37
41
class
XLNT_API
header_footer
42
{
43
public
:
47
enum class
location
48
{
49
left,
50
center,
51
right
52
};
53
54
// General Properties
55
59
bool
has_header()
const
;
60
64
bool
has_footer()
const
;
65
69
bool
align_with_margins()
const
;
70
75
header_footer
&align_with_margins(
bool
align);
76
80
bool
different_odd_even()
const
;
81
85
bool
different_first()
const
;
86
90
bool
scale_with_doc()
const
;
91
95
header_footer
&scale_with_doc(
bool
scale);
96
97
// Normal Header
98
102
bool
has_header(
location
where)
const
;
103
107
void
clear_header();
108
112
void
clear_header(
location
where);
113
117
header_footer
&header(
location
where,
const
std::string &text);
118
122
header_footer
&header(
location
where,
const
rich_text
&text);
123
128
rich_text
header(
location
where)
const
;
129
130
// First Page Header
131
135
bool
has_first_page_header()
const
;
136
140
bool
has_first_page_header(
location
where)
const
;
141
145
void
clear_first_page_header();
146
150
void
clear_first_page_header(
location
where);
151
155
header_footer
&first_page_header(
location
where,
const
rich_text
&text);
156
162
rich_text
first_page_header(
location
where)
const
;
163
164
// Odd/Even Header
165
169
bool
has_odd_even_header()
const
;
170
174
bool
has_odd_even_header(
location
where)
const
;
175
179
void
clear_odd_even_header();
180
184
void
clear_odd_even_header(
location
where);
185
189
header_footer
&odd_even_header(
location
where,
const
rich_text
&odd,
const
rich_text
&even);
190
196
rich_text
odd_header(
location
where)
const
;
197
203
rich_text
even_header(
location
where)
const
;
204
205
// Normal Footer
206
210
bool
has_footer(
location
where)
const
;
211
215
void
clear_footer();
216
220
void
clear_footer(
location
where);
221
225
header_footer
&footer(
location
where,
const
std::string &text);
226
230
header_footer
&footer(
location
where,
const
rich_text
&text);
231
236
rich_text
footer(
location
where)
const
;
237
238
// First Page footer
239
243
bool
has_first_page_footer()
const
;
244
248
bool
has_first_page_footer(
location
where)
const
;
249
253
void
clear_first_page_footer();
254
258
void
clear_first_page_footer(
location
where);
259
263
header_footer
&first_page_footer(
location
where,
const
rich_text
&text);
264
270
rich_text
first_page_footer(
location
where)
const
;
271
272
// Odd/Even Footer
273
277
bool
has_odd_even_footer()
const
;
278
282
bool
has_odd_even_footer(
location
where)
const
;
283
287
void
clear_odd_even_footer();
288
292
void
clear_odd_even_footer(
location
where);
293
297
header_footer
&odd_even_footer(
location
where,
const
rich_text
&odd,
const
rich_text
&even);
298
304
rich_text
odd_footer(
location
where)
const
;
305
311
rich_text
even_footer(
location
where)
const
;
312
313
bool
operator==
(
const
header_footer
&rhs)
const
;
314
315
private
:
316
bool
align_with_margins_ =
false
;
317
bool
different_odd_even_ =
false
;
318
bool
scale_with_doc_ =
false
;
319
320
using
container = std::unordered_map<location, rich_text, scoped_enum_hash<location>>;
321
322
container odd_headers_;
323
container even_headers_;
324
container first_headers_;
325
container odd_footers_;
326
container even_footers_;
327
container first_footers_;
328
};
329
330
}
// namespace xlnt
xlnt::header_footer
Represents the header and footer of a sheet in a workbook.
Definition:
header_footer.hpp:41
xlnt
Enumerates the possible types a cell can be determined by it's current value.
Definition:
cell.hpp:37
xlnt::header_footer::location
location
Enumerates the three possible locations of a header or footer.
Definition:
header_footer.hpp:47
xlnt::operator==
bool operator==(std::nullptr_t, const cell &cell)
Returns true if this cell is uninitialized.
xlnt::rich_text
Encapsulates zero or more formatted text runs where a text run is a string of text with the same defi...
Definition:
rich_text.hpp:41
Generated by
1.8.13