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

The XLComments class is the base class for worksheet comments. More...

#include <XLComments.hpp>

Inheritance diagram for OpenXLSX::XLComments:
OpenXLSX::XLXmlFile

Public Member Functions

 XLComments ()
 Constructor.
 
 XLComments (XLXmlData *xmlData)
 The constructor.
 
 XLComments (const XLComments &other)=default
 The copy constructor.
 
 XLComments (XLComments &&other) noexcept=default
 
 ~XLComments ()=default
 The destructor.
 
XLCommentsoperator= (XLComments &&other) noexcept=default
 
XLCommentsoperator= (const XLComments &other)=default
 Assignment operator.
 
bool setVmlDrawing (const XLVmlDrawing &vmlDrawing)
 associate the worksheet's VML drawing object with the comments so it can be modified from here
 
uint16_t authorCount () const
 
std::string author (uint16_t index) const
 
bool deleteAuthor (uint16_t index)
 
uint16_t addAuthor (const std::string &authorName)
 
size_t count () const
 get the amount of comments
 
uint16_t authorId (const std::string &cellRef) const
 
bool deleteComment (const std::string &cellRef)
 
XLComment get (size_t index) const
 get a comment by its index in the comment list
 
std::string get (std::string const &cellRef) const
 get the comment (if any) for the referenced cell
 
bool set (std::string const &cellRef, std::string const &comment, uint16_t authorId_=0, uint16_t widthCols=4, uint16_t heightRows=6)
 set the comment for the referenced cell
 
bool set (std::string const &cellRef, std::string const &comment, std::string const &authorName, uint16_t widthCols=4, uint16_t heightRows=6)
 set the comment for the referenced cell, automatically adding the author if not exists
 
bool setRichText (std::string const &cellRef, const XLRichText &richText, uint16_t authorId_=0, uint16_t widthCols=4, uint16_t heightRows=6)
 set the rich text comment for the referenced cell
 
bool setRichText (std::string const &cellRef, const XLRichText &richText, std::string const &authorName, uint16_t widthCols=4, uint16_t heightRows=6)
 set the rich text comment for the referenced cell, automatically adding the author if not exists
 
XLShape shape (std::string const &cellRef)
 get the XLShape object for this comment
 
bool setVisible (std::string const &cellRef, bool visible)
 Set the visibility of the comment shape.
 
void print (std::basic_ostream< char > &ostr) const
 Print the XML contents of this XLComments instance using the underlying XMLNode print function.
 
- Public Member Functions inherited from OpenXLSX::XLXmlFile
 XLXmlFile ()=default
 Default constructor.
 
std::string xmlData (XLXmlSavingDeclaration savingDeclaration=XLXmlSavingDeclaration{}) const
 Method for getting the XML data represented by the object.
 
 XLXmlFile (XLXmlData *xmlData)
 Constructor. Creates an object based on the xmlData input.
 
 XLXmlFile (const XLXmlFile &other)=default
 Copy constructor. Default implementation used.
 
 XLXmlFile (XLXmlFile &&other) noexcept=default
 Move constructor. Default implementation used.
 
 ~XLXmlFile ()=default
 Destructor. Default implementation used.
 
bool valid () const
 check whether class is linked to a valid XML file
 
XLXmlFileoperator= (const XLXmlFile &other)=default
 The copy assignment operator. The default implementation has been used.
 
XLXmlFileoperator= (XLXmlFile &&other) noexcept=default
 The move assignment operator. The default implementation has been used.
 
XLDocumentparentDoc ()
 This function provides access to the parent XLDocument object.
 
const XLDocumentparentDoc () const
 This function provides access to the parent XLDocument object.
 
XMLDocumentxmlDocument ()
 This function provides access to the underlying XMLDocument object.
 
const XMLDocumentxmlDocument () const
 This function provides access to the underlying XMLDocument object.
 
std::string getXmlPath () const
 Retrieve the path of the XML data in the .xlsx zip archive via m_xmlData->getXmlPath.
 

Friends

class XLWorksheet
 

Additional Inherited Members

- Protected Member Functions inherited from OpenXLSX::XLXmlFile
void setXmlData (std::string_view xmlData)
 Provide the XML data represented by the object.
 
std::string relationshipID () const
 This function returns the relationship ID (the ID used in the XLRelationships objects) for the object.
 
- Protected Attributes inherited from OpenXLSX::XLXmlFile
XLXmlDatam_xmlData {nullptr}
 

Detailed Description

The XLComments class is the base class for worksheet comments.

Constructor & Destructor Documentation

◆ XLComments() [1/4]

XLComments::XLComments ( )

Constructor.

◆ XLComments() [2/4]

XLComments::XLComments ( XLXmlData xmlData)
explicit

The constructor.

Parameters
xmlDatathe source XML of the comments file

The constructor creates an instance of the superclass, XLXmlFile

◆ XLComments() [3/4]

OpenXLSX::XLComments::XLComments ( const XLComments other)
default

The copy constructor.

Parameters
otherThe object to be copied.

◆ XLComments() [4/4]

OpenXLSX::XLComments::XLComments ( XLComments &&  other)
defaultnoexcept
Parameters
other

◆ ~XLComments()

OpenXLSX::XLComments::~XLComments ( )
default

The destructor.

Note
The default destructor is used, since cleanup of pointer data members is not required.

Member Function Documentation

◆ addAuthor()

uint16_t XLComments::addAuthor ( const std::string &  authorName)

insert author and return index

◆ author()

std::string XLComments::author ( uint16_t  index) const

◆ authorCount()

uint16_t XLComments::authorCount ( ) const

◆ authorId()

uint16_t XLComments::authorId ( const std::string &  cellRef) const

◆ count()

size_t XLComments::count ( ) const

get the amount of comments

Returns
the amount of comments for the worksheet

◆ deleteAuthor()

bool XLComments::deleteAuthor ( uint16_t  index)

◆ deleteComment()

bool XLComments::deleteComment ( const std::string &  cellRef)

◆ get() [1/2]

XLComment XLComments::get ( size_t  index) const

get a comment by its index in the comment list

Parameters
indexthe index of the comment as per XML sequence, no guarantee about cell reference being in sequence
Returns
the comment at index - will throw if index is out of bounds (>=count())

◆ get() [2/2]

std::string XLComments::get ( std::string const &  cellRef) const

get the comment (if any) for the referenced cell

Parameters
cellRefthe cell address to check
Returns
the comment for this cell - an empty string if no comment is set

◆ operator=() [1/2]

XLComments & OpenXLSX::XLComments::operator= ( const XLComments other)
default

Assignment operator.

Returns
A reference to the new object.

◆ operator=() [2/2]

XLComments & OpenXLSX::XLComments::operator= ( XLComments &&  other)
defaultnoexcept
Parameters
other
Returns

◆ print()

void XLComments::print ( std::basic_ostream< char > &  ostr) const

Print the XML contents of this XLComments instance using the underlying XMLNode print function.

Print the underlying XML using pugixml::xml_node::print

◆ set() [1/2]

bool XLComments::set ( std::string const &  cellRef,
std::string const &  comment,
std::string const &  authorName,
uint16_t  widthCols = 4,
uint16_t  heightRows = 6 
)

set the comment for the referenced cell, automatically adding the author if not exists

Parameters
cellRefthe cell address to set
commentset this text as comment for the cell
authorNameset this author name
widthColswidth of the comment box in columns
heightRowsheight of the comment box in rows
Returns
true upon success, false on failure

◆ set() [2/2]

bool XLComments::set ( std::string const &  cellRef,
std::string const &  comment,
uint16_t  authorId_ = 0,
uint16_t  widthCols = 4,
uint16_t  heightRows = 6 
)

set the comment for the referenced cell

Parameters
cellRefthe cell address to set
commentset this text as comment for the cell
authorId_set this author (underscore to avoid conflict with function name)
widthColswidth of the comment box in columns
heightRowsheight of the comment box in rows
Returns
true upon success, false on failure

◆ setRichText() [1/2]

bool XLComments::setRichText ( std::string const &  cellRef,
const XLRichText richText,
std::string const &  authorName,
uint16_t  widthCols = 4,
uint16_t  heightRows = 6 
)

set the rich text comment for the referenced cell, automatically adding the author if not exists

Parameters
cellRefthe cell address to set
richTextset this rich text as comment for the cell
authorNameset this author name
widthColswidth of the comment box in columns
heightRowsheight of the comment box in rows
Returns
true upon success, false on failure

◆ setRichText() [2/2]

bool XLComments::setRichText ( std::string const &  cellRef,
const XLRichText richText,
uint16_t  authorId_ = 0,
uint16_t  widthCols = 4,
uint16_t  heightRows = 6 
)

set the rich text comment for the referenced cell

Parameters
cellRefthe cell address to set
richTextset this rich text as comment for the cell
authorId_set this author (underscore to avoid conflict with function name)
widthColswidth of the comment box in columns
heightRowsheight of the comment box in rows
Returns
true upon success, false on failure

◆ setVisible()

bool XLComments::setVisible ( std::string const &  cellRef,
bool  visible 
)

Set the visibility of the comment shape.

Parameters
cellRefthe cell address
visibletrue to show the comment, false to hide
Returns
true upon success

◆ setVmlDrawing()

bool XLComments::setVmlDrawing ( const XLVmlDrawing vmlDrawing)

associate the worksheet's VML drawing object with the comments so it can be modified from here

Parameters
vmlDrawingthe worksheet's previously created XLVmlDrawing object
Returns
true upon success

◆ shape()

XLShape XLComments::shape ( std::string const &  cellRef)

get the XLShape object for this comment

Friends And Related Symbol Documentation

◆ XLWorksheet

friend class XLWorksheet
friend

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