OpenXLSX 1.9.1
Loading...
Searching...
No Matches
OpenXLSX::XLFonts Class Reference

An encapsulation of the XLSX fonts. More...

#include <XLStyles.hpp>

Public Member Functions

 XLFonts ()
 
 XLFonts (const XMLNode &node)
 Constructor. New items should only be created through an XLStyles object.
 
 XLFonts (const XLFonts &other)
 Copy Constructor.
 
 XLFonts (XLFonts &&other)
 Move Constructor.
 
 ~XLFonts ()
 
XLFontsoperator= (const XLFonts &other)
 Copy assignment operator.
 
XLFontsoperator= (XLFonts &&other) noexcept=default
 Move assignment operator.
 
size_t count () const
 Get the count of fonts.
 
XLFont fontByIndex (XLStyleIndex index) const
 Get the font identified by index.
 
XLFont operator[] (XLStyleIndex index) const
 Operator overload: allow [] as shortcut access to fontByIndex.
 
XLStyleIndex create (XLFont copyFrom=XLFont{}, std::string_view styleEntriesPrefix=XLDefaultStyleEntriesPrefix)
 Append a new XLFont, based on copyFrom, and return its index in fonts node.
 
XLStyleIndex findOrCreate (XLFont copyFrom, std::string_view styleEntriesPrefix=XLDefaultStyleEntriesPrefix)
 Find an existing font matching copyFrom's properties, or create a new one.
 

Detailed Description

An encapsulation of the XLSX fonts.

Constructor & Destructor Documentation

◆ XLFonts() [1/4]

XLFonts::XLFonts ( )

◆ XLFonts() [2/4]

XLFonts::XLFonts ( const XMLNode node)
explicit

Constructor. New items should only be created through an XLStyles object.

Parameters
nodeAn XMLNode object with the styles item. If no input is provided, a null node is used.

◆ XLFonts() [3/4]

XLFonts::XLFonts ( const XLFonts other)

Copy Constructor.

Parameters
otherObject to be copied.

◆ XLFonts() [4/4]

XLFonts::XLFonts ( XLFonts &&  other)

Move Constructor.

Parameters
otherObject to be moved.

◆ ~XLFonts()

XLFonts::~XLFonts ( )

Member Function Documentation

◆ count()

size_t XLFonts::count ( ) const

Get the count of fonts.

Returns
The amount of font entries

◆ create()

XLStyleIndex XLFonts::create ( XLFont  copyFrom = XLFont{},
std::string_view  styleEntriesPrefix = XLDefaultStyleEntriesPrefix 
)

Append a new XLFont, based on copyFrom, and return its index in fonts node.

Parameters
copyFromCan provide an XLFont to use as template for the new style
styleEntriesPrefixPrefix the newly created cell style XMLNode with this pugi::node_pcdata text
Returns
The index of the new style as used by operator[]

◆ findOrCreate()

XLStyleIndex XLFonts::findOrCreate ( XLFont  copyFrom,
std::string_view  styleEntriesPrefix = XLDefaultStyleEntriesPrefix 
)

Find an existing font matching copyFrom's properties, or create a new one.

Uses a canonical XML fingerprint for O(1) cache lookups after the first call. Prevents duplicate font entries when the same style is applied to many cells.

Parameters
copyFromThe font descriptor to match or create.
styleEntriesPrefixXML indentation prefix for newly created nodes.
Returns
The index of the matching or newly created font.

◆ fontByIndex()

XLFont XLFonts::fontByIndex ( XLStyleIndex  index) const

Get the font identified by index.

Parameters
indexThe index within the XML sequence
Returns
An XLFont object

◆ operator=() [1/2]

XLFonts & XLFonts::operator= ( const XLFonts other)

Copy assignment operator.

Parameters
otherRight hand side of assignment operation.
Returns
A reference to the lhs object.

◆ operator=() [2/2]

XLFonts & OpenXLSX::XLFonts::operator= ( XLFonts &&  other)
defaultnoexcept

Move assignment operator.

Parameters
otherRight hand side of assignment operation.
Returns
A reference to lhs object.

◆ operator[]()

XLFont OpenXLSX::XLFonts::operator[] ( XLStyleIndex  index) const
inline

Operator overload: allow [] as shortcut access to fontByIndex.

Parameters
indexThe index within the XML sequence
Returns
An XLFont object

The documentation for this class was generated from the following files: