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

The XLDrawing class is the base class for worksheet drawings (images, charts, etc.) More...

#include <XLDrawing.hpp>

Inheritance diagram for OpenXLSX::XLDrawing:
OpenXLSX::XLXmlFile

Public Member Functions

 XLDrawing ()
 Constructor.
 
 XLDrawing (gsl::not_null< XLXmlData * > xmlData)
 The constructor.
 
 XLDrawing (const XLDrawing &other)
 The copy constructor.
 
 XLDrawing (XLDrawing &&other) noexcept
 Move constructor.
 
 ~XLDrawing ()=default
 The destructor.
 
XLDrawingoperator= (const XLDrawing &other)
 Assignment operator.
 
XLDrawingoperator= (XLDrawing &&other) noexcept
 Move assignment operator.
 
void addImage (std::string_view rId, std::string_view name, std::string_view description, uint32_t row, uint32_t col, uint32_t width, uint32_t height, const XLImageOptions &options=XLImageOptions())
 Add an image to the drawing.
 
void addShape (uint32_t row, uint32_t col, const XLVectorShapeOptions &options=XLVectorShapeOptions())
 Add a chart to the drawing.
 
void addChartAnchor (std::string_view rId, std::string_view name, uint32_t row, uint32_t col, uint32_t width, uint32_t height)
 
void addChartAnchor (std::string_view rId, std::string_view name, uint32_t row, uint32_t col, XLDistance width, XLDistance height)
 
void addScaledImage (std::string_view rId, std::string_view name, std::string_view description, std::string_view data, uint32_t row, uint32_t col, double scalingFactor=1.0)
 Add an image to the drawing, automatically maintaining aspect ratio.
 
XLRelationshipsrelationships ()
 Get the drawing relationships.
 
uint32_t imageCount () const
 Get the number of images in the drawing.
 
XLDrawingItem image (uint32_t index) const
 Get an image item by index.
 
- 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
 
class XLDocument
 

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 XLDrawing class is the base class for worksheet drawings (images, charts, etc.)

Constructor & Destructor Documentation

◆ XLDrawing() [1/4]

OpenXLSX::XLDrawing::XLDrawing ( )
inline

Constructor.

◆ XLDrawing() [2/4]

XLDrawing::XLDrawing ( gsl::not_null< XLXmlData * >  xmlData)
explicit

The constructor.

Parameters
xmlDatathe source XML of the drawings file

◆ XLDrawing() [3/4]

XLDrawing::XLDrawing ( const XLDrawing other)

The copy constructor.

Parameters
otherThe object to be copied.

◆ XLDrawing() [4/4]

XLDrawing::XLDrawing ( XLDrawing &&  other)
defaultnoexcept

Move constructor.

◆ ~XLDrawing()

OpenXLSX::XLDrawing::~XLDrawing ( )
default

The destructor.

Member Function Documentation

◆ addChartAnchor() [1/2]

void XLDrawing::addChartAnchor ( std::string_view  rId,
std::string_view  name,
uint32_t  row,
uint32_t  col,
uint32_t  width,
uint32_t  height 
)

◆ addChartAnchor() [2/2]

void XLDrawing::addChartAnchor ( std::string_view  rId,
std::string_view  name,
uint32_t  row,
uint32_t  col,
XLDistance  width,
XLDistance  height 
)

◆ addImage()

void XLDrawing::addImage ( std::string_view  rId,
std::string_view  name,
std::string_view  description,
uint32_t  row,
uint32_t  col,
uint32_t  width,
uint32_t  height,
const XLImageOptions options = XLImageOptions() 
)

Add an image to the drawing.

Parameters
rIdthe relationship ID of the image file
namethe name of the image
descriptionthe description of the image
rowthe row where the image should be placed (0-indexed)
colthe column where the image should be placed (0-indexed)
widththe width of the image in pixels
heightthe height of the image in pixels
optionsthe formatting and positioning options

◆ addScaledImage()

void XLDrawing::addScaledImage ( std::string_view  rId,
std::string_view  name,
std::string_view  description,
std::string_view  data,
uint32_t  row,
uint32_t  col,
double  scalingFactor = 1.0 
)

Add an image to the drawing, automatically maintaining aspect ratio.

Parameters
rIdthe relationship ID of the image file
namethe name of the image
descriptionthe description of the image
datathe binary data of the image (used to detect dimensions)
rowthe row where the image should be placed (0-indexed)
colthe column where the image should be placed (0-indexed)
scalingFactorthe factor to scale the image by (1.0 = original size)

◆ addShape()

void XLDrawing::addShape ( uint32_t  row,
uint32_t  col,
const XLVectorShapeOptions options = XLVectorShapeOptions() 
)

Add a chart to the drawing.

Parameters
rIdthe relationship ID of the chart file
namethe name of the chart
rowthe row where the chart should be placed (0-indexed)
colthe column where the chart should be placed (0-indexed)
widththe width of the chart in pixels
heightthe height of the chart in pixels

◆ image()

XLDrawingItem XLDrawing::image ( uint32_t  index) const

Get an image item by index.

Parameters
indexthe index of the image
Returns
an XLDrawingItem object

◆ imageCount()

uint32_t XLDrawing::imageCount ( ) const

Get the number of images in the drawing.

Returns
the number of images

◆ operator=() [1/2]

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

Assignment operator.

◆ operator=() [2/2]

XLDrawing & XLDrawing::operator= ( XLDrawing &&  other)
defaultnoexcept

Move assignment operator.

◆ relationships()

XLRelationships & XLDrawing::relationships ( )

Get the drawing relationships.

Returns
a reference to the XLRelationships object

fetches XLRelationships for the drawing - creates & assigns the class if empty

Friends And Related Symbol Documentation

◆ XLDocument

friend class XLDocument
friend

◆ XLWorksheet

friend class XLWorksheet
friend

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