1#ifndef OPENXLSX_XLSTYLES_HPP
2#define OPENXLSX_XLSTYLES_HPP
6# pragma warning(disable : 4251)
7# pragma warning(disable : 4275)
15#include <unordered_map>
19#include "OpenXLSX-Exports.hpp"
26 using namespace std::literals::string_view_literals;
238 uint32_t numberFormatId()
const;
244 std::string formatCode()
const;
251 bool setNumberFormatId(uint32_t newNumberFormatId);
252 bool setFormatCode(std::string_view newFormatCode);
258 std::string summary()
const;
261 std::unique_ptr<XMLNode> m_numberFormatNode;
316 size_t count()
const;
345 uint32_t numberFormatIdFromIndex(
XLStyleIndex index)
const;
352 uint32_t createNumberFormat(std::string_view formatCode);
358 uint32_t getFreeNumberFormatId()
const;
369 std::unique_ptr<XMLNode> m_numberFormatsNode;
370 std::vector<XLNumberFormat> m_numberFormats;
428 std::string fontName()
const;
434 size_t fontCharset()
const;
440 size_t fontFamily()
const;
446 size_t fontSize()
const;
470 bool strikethrough()
const;
494 bool outline()
const;
506 bool condense()
const;
519 XLFont& setFontName(std::string_view newName);
520 XLFont& setFontCharset(
size_t newCharset);
521 XLFont& setFontFamily(
size_t newFamily);
522 XLFont& setFontSize(
size_t newSize);
524 XLFont& setBold(
bool set =
true);
525 XLFont& setItalic(
bool set =
true);
526 XLFont& setStrikethrough(
bool set =
true);
530 XLFont& setOutline(
bool set =
true);
531 XLFont& setShadow(
bool set =
true);
532 XLFont& setCondense(
bool set =
true);
533 XLFont& setExtend(
bool set =
true);
539 std::string summary()
const;
542 std::unique_ptr<XMLNode> m_fontNode;
597 size_t count()
const;
629 XLStyleIndex findOrCreate(XLFont copyFrom, std::string_view styleEntriesPrefix = XLDefaultStyleEntriesPrefix);
632 std::unique_ptr<XMLNode> m_fontsNode;
633 std::vector<XLFont> m_fonts;
634 mutable std::unordered_map<std::string, XLStyleIndex> m_fingerprintCache;
702 bool automatic()
const;
703 uint32_t indexed()
const;
704 uint32_t theme()
const;
713 bool setTint(
double newTint);
714 bool setAutomatic(
bool set =
true);
715 bool setIndexed(uint32_t newIndex);
716 bool setTheme(uint32_t newTheme);
722 std::string summary()
const;
725 std::unique_ptr<XMLNode> m_colorNode;
784 double position()
const;
792 bool setPosition(
double newPosition);
798 std::string summary()
const;
801 std::unique_ptr<XMLNode> m_stopNode;
856 size_t count()
const;
880 std::string summary()
const;
883 std::unique_ptr<XMLNode> m_gradientNode;
884 std::vector<XLGradientStop> m_gradientStops;
948 bool setFillType(
XLFillType newFillType,
bool force =
false);
956 void throwOnFillType(
XLFillType typeToThrowOn,
const char* functionName)
const;
965 XMLNode getValidFillDescription(
XLFillType fillTypeIfEmpty,
const char* functionName);
996 bool setDegree(
double newDegree);
997 bool setLeft(
double newLeft);
998 bool setRight(
double newRight);
999 bool setTop(
double newTop);
1000 bool setBottom(
double newBottom);
1015 std::string summary();
1018 std::unique_ptr<XMLNode> m_fillNode;
1073 size_t count()
const;
1095 XLStyleIndex create(
XLFill copyFrom =
XLFill{}, std::string_view styleEntriesPrefix = XLDefaultStyleEntriesPrefix);
1101 XLStyleIndex findOrCreate(XLFill copyFrom, std::string_view styleEntriesPrefix = XLDefaultStyleEntriesPrefix);
1104 std::unique_ptr<XMLNode> m_fillsNode;
1105 std::vector<XLFill> m_fills;
1106 mutable std::unordered_map<std::string, XLStyleIndex> m_fingerprintCache;
1169 explicit operator bool()
const;
1184 std::string summary()
const;
1187 std::unique_ptr<XMLNode> m_lineNode;
1243 bool diagonalUp()
const;
1249 bool diagonalDown()
const;
1255 bool outline()
const;
1297 XLLine horizontal()
const;
1305 XLBorder& setDiagonalUp(
bool set =
true);
1306 XLBorder& setDiagonalDown(
bool set =
true);
1307 XLBorder& setOutline(
bool set =
true);
1321 std::string summary()
const;
1324 std::unique_ptr<XMLNode> m_borderNode;
1325 inline static const std::vector<std::string_view> m_nodeOrder =
1326 {
"left",
"right",
"top",
"bottom",
"diagonal",
"vertical",
"horizontal"};
1381 size_t count()
const;
1409 XLStyleIndex findOrCreate(XLBorder copyFrom, std::string_view styleEntriesPrefix = XLDefaultStyleEntriesPrefix);
1412 std::unique_ptr<XMLNode> m_bordersNode;
1413 std::vector<XLBorder> m_borders;
1414 mutable std::unordered_map<std::string, XLStyleIndex> m_fingerprintCache;
1484 uint16_t textRotation()
const;
1490 bool wrapText()
const;
1496 uint32_t indent()
const;
1503 int32_t relativeIndent()
const;
1509 bool justifyLastLine()
const;
1515 bool shrinkToFit()
const;
1521 uint32_t readingOrder()
const;
1539 bool setTextRotation(uint16_t newRotation);
1540 bool setWrapText(
bool set =
true);
1541 bool setIndent(uint32_t newIndent);
1542 bool setRelativeIndent(int32_t newIndent);
1543 bool setJustifyLastLine(
bool set =
true);
1544 bool setShrinkToFit(
bool set =
true);
1545 bool setReadingOrder(
1546 uint32_t newReadingOrder);
1552 std::string summary()
const;
1555 std::unique_ptr<XMLNode> m_alignmentNode;
1613 uint32_t numberFormatId()
const;
1645 bool applyNumberFormat()
const;
1651 bool applyFont()
const;
1657 bool applyFill()
const;
1663 bool applyBorder()
const;
1669 bool applyAlignment()
const;
1675 bool applyProtection()
const;
1683 bool quotePrefix()
const;
1691 bool pivotButton()
const;
1697 bool locked()
const;
1703 bool hidden()
const;
1710 XLAlignment alignment(
bool createIfMissing =
false)
const;
1746 std::string summary()
const;
1749 std::unique_ptr<XMLNode> m_cellFormatNode;
1750 bool m_permitXfId{
false};
1751 inline static const std::vector<std::string_view> m_nodeOrder = {
"alignment",
"protection"};
1807 size_t count()
const;
1837 XLStyleIndex findOrCreate(XLCellFormat copyFrom, std::string_view styleEntriesPrefix = XLDefaultStyleEntriesPrefix);
1840 std::unique_ptr<XMLNode> m_cellFormatsNode;
1841 std::vector<XLCellFormat> m_cellFormats;
1842 bool m_permitXfId{
false};
1843 mutable std::unordered_map<std::string, XLStyleIndex> m_fingerprintCache;
1908 std::string name()
const;
1921 uint32_t builtinId()
const;
1928 uint32_t outlineStyle()
const;
1934 bool hidden()
const;
1940 bool customBuiltin()
const;
1952 bool setName(std::string_view newName);
1954 bool setBuiltinId(uint32_t newBuiltinId);
1955 bool setOutlineStyle(uint32_t newOutlineStyle);
1956 bool setHidden(
bool set =
true);
1957 bool setCustomBuiltin(
bool set =
true);
1967 std::string summary()
const;
1970 std::unique_ptr<XMLNode> m_cellStyleNode;
2025 size_t count()
const;
2049 std::unique_ptr<XMLNode> m_cellStylesNode;
2050 std::vector<XLCellStyle> m_cellStyles;
2124 bool hasFont()
const;
2125 bool hasNumFmt()
const;
2126 bool hasFill()
const;
2127 bool hasAlignment()
const;
2128 bool hasBorder()
const;
2136 void clearAlignment();
2153 std::string summary()
const;
2161 std::unique_ptr<XMLDocument> m_xmlDocument;
2222 size_t count()
const;
2243 XLStyleIndex create(
XLDxf copyFrom =
XLDxf{}, std::string_view styleEntriesPrefix = XLDefaultStyleEntriesPrefix);
2246 mutable XMLNode m_dxfsNode;
2247 std::vector<XLDxf> m_dxfs;
2276 bool suppressWarnings =
false,
2315 uint32_t createNumberFormat(std::string_view formatCode);
2387 std::optional<XLStyleIndex> fontId = std::nullopt,
2388 std::optional<XLStyleIndex> fillId = std::nullopt,
2389 std::optional<XLStyleIndex> borderId = std::nullopt,
2390 std::optional<XLStyleIndex> numFmtId = std::nullopt);
2413 bool m_suppressWarnings;
2414 std::unique_ptr<XLNumberFormats> m_numberFormats;
2415 std::unique_ptr<XLFonts> m_fonts;
2416 std::unique_ptr<XLFills> m_fills;
2417 std::unique_ptr<XLBorders> m_borders;
2418 std::unique_ptr<XLCellFormats> m_cellStyleFormats;
2419 std::unique_ptr<XLCellFormats> m_cellFormats;
2420 std::unique_ptr<XLCellStyles> m_cellStyles;
2421 std::unique_ptr<XLDxfs> m_dxfs;
2426# pragma warning(pop)
XLXmlData * xmlData
Definition XLDocument.cpp:1422
Definition XLXmlParser.hpp:84
An encapsulation of an alignment item.
Definition XLStyles.hpp:1423
XLAlignment & operator=(XLAlignment &&other) noexcept=default
Move assignment operator.
XLAlignment(XLAlignment &&other) noexcept=default
Move Constructor.
An encapsulation of a border item.
Definition XLStyles.hpp:1194
XLBorder & operator=(XLBorder &&other) noexcept=default
Move assignment operator.
XLBorder(XLBorder &&other) noexcept=default
Move Constructor.
An encapsulation of the XLSX borders.
Definition XLStyles.hpp:1333
XLBorders & operator=(XLBorders &&other) noexcept=default
Move assignment operator.
XLBorder operator[](XLStyleIndex index) const
Operator overload: allow [] as shortcut access to borderByIndex.
Definition XLStyles.hpp:1395
An encapsulation of a cell style item.
Definition XLStyles.hpp:1852
XLUnsupportedElement extLst() const
Unsupported getter.
Definition XLStyles.hpp:1945
XLCellStyle & operator=(XLCellStyle &&other) noexcept=default
Move assignment operator.
XLCellStyle(XLCellStyle &&other) noexcept=default
Move Constructor.
An encapsulation of the XLSX cell styles.
Definition XLStyles.hpp:1977
XLCellStyles & operator=(XLCellStyles &&other) noexcept=default
Move assignment operator.
XLCellStyle operator[](XLStyleIndex index) const
Operator overload: allow [] as shortcut access to cellStyleByIndex.
Definition XLStyles.hpp:2038
Definition XLColor.hpp:22
An encapsulation of an XLSX Data Bar Color (CT_Color) item.
Definition XLStyles.hpp:643
bool set(XLColor newColor)
Definition XLStyles.hpp:712
XLDataBarColor & operator=(XLDataBarColor &&other) noexcept=default
Move assignment operator.
XLDataBarColor(XLDataBarColor &&other) noexcept=default
Move Constructor.
~XLDataBarColor()=default
An encapsulation of a differential cell format item (DXF)
Definition XLStyles.hpp:2059
XLUnsupportedElement extLst() const
Unsupported getter.
Definition XLStyles.hpp:2142
XMLNode node() const
Access the underlying XML node.
Definition XLStyles.hpp:2158
An encapsulation of the XLSX differential cell formats (dxfs)
Definition XLStyles.hpp:2174
XLDxf operator[](XLStyleIndex index) const
Operator overload: allow [] as shortcut access to dxfByIndex.
Definition XLStyles.hpp:2235
An encapsulation of a fill item.
Definition XLStyles.hpp:891
XLFill(XLFill &&other) noexcept=default
Move Constructor.
XLFill & operator=(XLFill &&other) noexcept=default
Move assignment operator.
An encapsulation of the XLSX fills.
Definition XLStyles.hpp:1025
XLFill operator[](XLStyleIndex index) const
Operator overload: allow [] as shortcut access to fillByIndex.
Definition XLStyles.hpp:1087
XLFills & operator=(XLFills &&other) noexcept=default
Move assignment operator.
An encapsulation of a font item.
Definition XLStyles.hpp:379
XLFont(XLFont &&other) noexcept=default
Move Constructor.
XLFont & operator=(XLFont &&other) noexcept=default
Move assignment operator.
An encapsulation of the XLSX fonts.
Definition XLStyles.hpp:549
XLFonts & operator=(XLFonts &&other) noexcept=default
Move assignment operator.
XLFont operator[](XLStyleIndex index) const
Operator overload: allow [] as shortcut access to fontByIndex.
Definition XLStyles.hpp:611
An encapsulation of an fill::gradientFill::stop item.
Definition XLStyles.hpp:734
XLGradientStop & operator=(XLGradientStop &&other) noexcept=default
Move assignment operator.
~XLGradientStop()=default
XLGradientStop(XLGradientStop &&other) noexcept=default
Move Constructor.
An encapsulation of an array of fill::gradientFill::stop items.
Definition XLStyles.hpp:808
XLGradientStops & operator=(XLGradientStops &&other) noexcept=default
Move assignment operator.
XLGradientStop operator[](XLStyleIndex index) const
Operator overload: allow [] as shortcut access to stopByIndex.
Definition XLStyles.hpp:870
An encapsulation of a line item.
Definition XLStyles.hpp:1115
XLLine(XLLine &&other) noexcept=default
Move Constructor.
XLLine & operator=(XLLine &&other) noexcept=default
Move assignment operator.
An encapsulation of the styles file (xl/styles.xml) in an Excel document package.
Definition XLStyles.hpp:2261
XLDxfs & diffCellFormats() const
Backward compatibility alias for dxfs()
Definition XLStyles.hpp:2368
The XLUnsupportedElement class provides a stub implementation that can be used as function parameter ...
Definition XLXmlFile.hpp:28
The XLXmlFile class provides an interface for derived classes to use. It functions as an ancestor to ...
Definition XLXmlFile.hpp:42
Definition IZipArchive.hpp:18
XLFillType
Definition XLStyles.hpp:103
@ XLPatternFill
Definition XLStyles.hpp:105
@ XLGradientFill
Definition XLStyles.hpp:104
@ XLFillTypeInvalid
Definition XLStyles.hpp:106
XLAlignmentStyle
Definition XLStyles.hpp:167
@ XLAlignInvalid
Definition XLStyles.hpp:178
@ XLAlignRight
Definition XLStyles.hpp:170
@ XLAlignBottom
Definition XLStyles.hpp:173
@ XLAlignLeft
Definition XLStyles.hpp:169
@ XLAlignCenterContinuous
Definition XLStyles.hpp:176
@ XLAlignGeneral
Definition XLStyles.hpp:168
@ XLAlignJustify
Definition XLStyles.hpp:175
@ XLAlignFill
Definition XLStyles.hpp:174
@ XLAlignDistributed
Definition XLStyles.hpp:177
@ XLAlignCenter
Definition XLStyles.hpp:171
@ XLAlignTop
Definition XLStyles.hpp:172
XLLineType
Definition XLStyles.hpp:138
@ XLLineLeft
Definition XLStyles.hpp:139
@ XLLineBottom
Definition XLStyles.hpp:142
@ XLLineVertical
Definition XLStyles.hpp:144
@ XLLineDiagonal
Definition XLStyles.hpp:143
@ XLLineRight
Definition XLStyles.hpp:140
@ XLLineHorizontal
Definition XLStyles.hpp:145
@ XLLineInvalid
Definition XLStyles.hpp:146
@ XLLineTop
Definition XLStyles.hpp:141
XLPatternType
Definition XLStyles.hpp:111
@ XLPatternNone
Definition XLStyles.hpp:112
@ XLPatternLightDown
Definition XLStyles.hpp:125
@ XLPatternGray0625
Definition XLStyles.hpp:130
@ XLPatternDarkGray
Definition XLStyles.hpp:115
@ XLPatternTypeInvalid
Definition XLStyles.hpp:131
@ XLPatternLightHorizontal
Definition XLStyles.hpp:123
@ XLPatternDarkDown
Definition XLStyles.hpp:119
@ XLPatternDarkHorizontal
Definition XLStyles.hpp:117
@ XLPatternSolid
Definition XLStyles.hpp:113
@ XLPatternDarkUp
Definition XLStyles.hpp:120
@ XLPatternDarkGrid
Definition XLStyles.hpp:121
@ XLPatternGray125
Definition XLStyles.hpp:129
@ XLPatternLightVertical
Definition XLStyles.hpp:124
@ XLPatternLightUp
Definition XLStyles.hpp:126
@ XLPatternDarkTrellis
Definition XLStyles.hpp:122
@ XLPatternDarkVertical
Definition XLStyles.hpp:118
@ XLPatternLightGray
Definition XLStyles.hpp:116
@ XLPatternLightGrid
Definition XLStyles.hpp:127
@ XLPatternLightTrellis
Definition XLStyles.hpp:128
@ XLPatternMediumGray
Definition XLStyles.hpp:114
XLUnderlineStyle
Definition XLStyles.hpp:80
@ XLUnderlineSingleAccounting
Definition XLStyles.hpp:84
@ XLUnderlineDoubleAccounting
Definition XLStyles.hpp:85
@ XLUnderlineSingle
Definition XLStyles.hpp:82
@ XLUnderlineNone
Definition XLStyles.hpp:81
@ XLUnderlineInvalid
Definition XLStyles.hpp:86
@ XLUnderlineDouble
Definition XLStyles.hpp:83
constexpr const char * XLDefaultPatternBgColor
Definition XLStyles.hpp:136
constexpr const uint32_t XLDefaultFontSize
Definition XLStyles.hpp:54
XLGradientType
Definition XLStyles.hpp:109
@ XLGradientLinear
Definition XLStyles.hpp:109
@ XLGradientTypeInvalid
Definition XLStyles.hpp:109
@ XLGradientPath
Definition XLStyles.hpp:109
constexpr const char * XLDefaultLineStyle
Definition XLStyles.hpp:61
constexpr const XLStyleIndex XLDefaultCellFormat
Definition XLStyles.hpp:49
constexpr const uint32_t XLDefaultFontCharset
Definition XLStyles.hpp:59
constexpr const bool XLCreateIfMissing
Definition XLStyles.hpp:41
constexpr const XLFillType XLDefaultFillType
Definition XLStyles.hpp:133
size_t XLStyleIndex
Definition XLStyles.hpp:31
constexpr const char * XLDefaultPatternFgColor
Definition XLStyles.hpp:135
constexpr const char * XLDefaultStyleEntriesPrefix
Definition XLStyles.hpp:47
constexpr const char * XLDefaultFontColor
Definition XLStyles.hpp:55
constexpr const char * XLDefaultFontName
Definition XLStyles.hpp:57
constexpr const bool XLDoNotCreate
Definition XLStyles.hpp:42
constexpr const char * XLDefaultStylesPrefix
Definition XLStyles.hpp:46
constexpr const uint32_t XLInvalidUInt32
Definition XLStyles.hpp:34
XLFontSchemeStyle
Definition XLStyles.hpp:89
@ XLFontSchemeInvalid
Definition XLStyles.hpp:93
@ XLFontSchemeNone
Definition XLStyles.hpp:90
@ XLFontSchemeMinor
Definition XLStyles.hpp:92
@ XLFontSchemeMajor
Definition XLStyles.hpp:91
XLReadingOrder
Definition XLStyles.hpp:181
@ XLReadingOrderLeftToRight
Definition XLStyles.hpp:181
@ XLReadingOrderContextual
Definition XLStyles.hpp:181
@ XLReadingOrderRightToLeft
Definition XLStyles.hpp:181
constexpr const bool XLForceFillType
Definition XLStyles.hpp:44
XLVerticalAlignRunStyle
Definition XLStyles.hpp:96
@ XLSubscript
Definition XLStyles.hpp:98
@ XLBaseline
Definition XLStyles.hpp:97
@ XLVerticalAlignRunInvalid
Definition XLStyles.hpp:100
@ XLSuperscript
Definition XLStyles.hpp:99
XLLineStyle
Definition XLStyles.hpp:149
@ XLLineStyleNone
Definition XLStyles.hpp:150
@ XLLineStyleMediumDashDotDot
Definition XLStyles.hpp:162
@ XLLineStyleDashDot
Definition XLStyles.hpp:159
@ XLLineStyleMediumDashed
Definition XLStyles.hpp:158
@ XLLineStyleDotted
Definition XLStyles.hpp:154
@ XLLineStyleSlantDashDot
Definition XLStyles.hpp:163
@ XLLineStyleDouble
Definition XLStyles.hpp:156
@ XLLineStyleInvalid
Definition XLStyles.hpp:164
@ XLLineStyleThick
Definition XLStyles.hpp:155
@ XLLineStyleThin
Definition XLStyles.hpp:151
@ XLLineStyleMediumDashDot
Definition XLStyles.hpp:160
@ XLLineStyleDashed
Definition XLStyles.hpp:153
@ XLLineStyleDashDotDot
Definition XLStyles.hpp:161
@ XLLineStyleMedium
Definition XLStyles.hpp:152
@ XLLineStyleHair
Definition XLStyles.hpp:157
constexpr const uint32_t XLInvalidUInt16
Definition XLStyles.hpp:33
constexpr const uint32_t XLDeleteProperty
Definition XLStyles.hpp:35
constexpr const XLStyleIndex XLInvalidStyleIndex
Definition XLStyles.hpp:52
constexpr const XLPatternType XLDefaultPatternType
Definition XLStyles.hpp:134
constexpr const uint32_t XLDefaultFontFamily
Definition XLStyles.hpp:58
constexpr const char * XLDefaultFontColorTheme
Definition XLStyles.hpp:56
constexpr const bool XLPermitXfID
Definition XLStyles.hpp:39
A high-level, human-ergonomic structure representing the styling of a cell or range....
Definition XLStyle.hpp:19