OpenXLSX 1.9.1
Loading...
Searching...
No Matches
XLConstants.hpp
Go to the documentation of this file.
1#ifndef OPENXLSX_XLCONSTANTS_HPP
2#define OPENXLSX_XLCONSTANTS_HPP
3
4#include <cstdint>
5
6namespace OpenXLSX
7{
8 inline constexpr uint16_t MAX_COLS = 16'384;
9 inline constexpr uint32_t MAX_ROWS = 1'048'576;
10
12 {
13 uint32_t val;
14 explicit XLRowIndex(uint32_t v) : val(v) {}
15 operator uint32_t() const { return val; }
16 };
17
19 {
20 uint16_t val;
21 explicit XLColIndex(uint16_t v) : val(v) {}
22 operator uint16_t() const { return val; }
23 };
24
25 inline namespace IndexLiterals
26 {
27 inline XLRowIndex operator""_row(unsigned long long v) { return XLRowIndex(static_cast<uint32_t>(v)); }
28 inline XLColIndex operator""_col(unsigned long long v) { return XLColIndex(static_cast<uint16_t>(v)); }
29 } // namespace IndexLiterals
30
32 {
33 public:
34 XLDistance() = default;
35 static XLDistance Pixels(uint32_t px) { return XLDistance(static_cast<uint64_t>(px) * 9525); }
36 static XLDistance Centimeters(double cm) { return XLDistance(static_cast<uint64_t>(cm * 360000.0)); }
37 static XLDistance Inches(double inch) { return XLDistance(static_cast<uint64_t>(inch * 914400.0)); }
38
39 static XLDistance Points(double pt) { return XLDistance(static_cast<uint64_t>(pt * 12700.0)); }
40 static XLDistance EMU(uint64_t emu) { return XLDistance(emu); }
41
42 [[nodiscard]] uint64_t getEMU() const { return m_emu; }
43 [[nodiscard]] uint32_t getPixels() const { return static_cast<uint32_t>(m_emu / 9525); }
44 [[nodiscard]] double getInches() const { return static_cast<double>(m_emu) / 914400.0; }
45
46 private:
47 explicit XLDistance(uint64_t emu) : m_emu(emu) {}
48 uint64_t m_emu{0};
49 };
50
51 inline namespace DistanceLiterals
52 {
53 inline XLDistance operator""_px(unsigned long long px) { return XLDistance::Pixels(static_cast<uint32_t>(px)); }
54 inline XLDistance operator""_cm(long double cm) { return XLDistance::Centimeters(static_cast<double>(cm)); }
55 inline XLDistance operator""_cm(unsigned long long cm) { return XLDistance::Centimeters(static_cast<double>(cm)); }
56
57 inline XLDistance operator""_inch(long double inch) { return XLDistance::Inches(static_cast<double>(inch)); }
58 inline XLDistance operator""_inch(unsigned long long inch) { return XLDistance::Inches(static_cast<double>(inch)); }
59
60 inline XLDistance operator""_pt(long double pt) { return XLDistance::Points(static_cast<double>(pt)); }
61 inline XLDistance operator""_pt(unsigned long long pt) { return XLDistance::Points(static_cast<double>(pt)); }
62
63 } // namespace DistanceLiterals
64
65 // anchoring a comment shape below these values was not possible in LibreOffice - TBC with MS Office
66 inline constexpr uint16_t MAX_SHAPE_ANCHOR_COLUMN = 13067; // column "SHO"
67 inline constexpr uint32_t MAX_SHAPE_ANCHOR_ROW = 852177;
68} // namespace OpenXLSX
69
70#endif // OPENXLSX_XLCONSTANTS_HPP
Definition XLConstants.hpp:32
static XLDistance Inches(double inch)
Definition XLConstants.hpp:37
static XLDistance EMU(uint64_t emu)
Definition XLConstants.hpp:40
double getInches() const
Definition XLConstants.hpp:44
static XLDistance Centimeters(double cm)
Definition XLConstants.hpp:36
static XLDistance Points(double pt)
Definition XLConstants.hpp:39
uint32_t getPixels() const
Definition XLConstants.hpp:43
uint64_t getEMU() const
Definition XLConstants.hpp:42
static XLDistance Pixels(uint32_t px)
Definition XLConstants.hpp:35
Definition IZipArchive.hpp:18
constexpr uint32_t MAX_ROWS
Definition XLConstants.hpp:9
constexpr uint16_t MAX_SHAPE_ANCHOR_COLUMN
Definition XLConstants.hpp:66
constexpr uint32_t MAX_SHAPE_ANCHOR_ROW
Definition XLConstants.hpp:67
constexpr uint16_t MAX_COLS
Definition XLConstants.hpp:8
Definition XLConstants.hpp:19
uint16_t val
Definition XLConstants.hpp:20
XLColIndex(uint16_t v)
Definition XLConstants.hpp:21
Definition XLConstants.hpp:12
uint32_t val
Definition XLConstants.hpp:13
XLRowIndex(uint32_t v)
Definition XLConstants.hpp:14