11#ifndef OPENXLSX_XLDRAWING_HPP
12#define OPENXLSX_XLDRAWING_HPP
16#include <gsl/pointers>
21#include "OpenXLSX-Exports.hpp"
108 std::string
anchor()
const;
112 uint32_t
row()
const;
121 bool setAnchor(std::string_view newAnchor);
125 bool setRow(uint32_t newRow);
129 mutable XMLNode m_clientDataNode;
130 inline static const std::vector<std::string_view> m_nodeOrder =
131 {
"x:MoveWithCells",
"x:SizeWithCells",
"x:Anchor",
"x:AutoFill",
"x:TextVAlign",
"x:TextHAlign",
"x:Row",
"x:Column"};
149 explicit XLShapeStyle(
const std::string& styleAttribute);
164 int16_t attributeOrderIndex(std::string_view attributeName)
const;
168 XLShapeStyleAttribute getAttribute(std::string_view attributeName, std::string_view valIfNotFound =
"")
const;
169 bool setAttribute(std::string_view attributeName, std::string_view attributeValue);
178 uint16_t
width()
const;
185 std::string
raw()
const {
return m_style; }
190 bool setPosition(std::string_view newPosition);
191 bool setMarginLeft(uint16_t newMarginLeft);
192 bool setMarginTop(uint16_t newMarginTop);
193 bool setWidth(uint16_t newWidth);
194 bool setHeight(uint16_t newHeight);
195 bool setMsoWrapStyle(std::string_view newMsoWrapStyle);
196 bool setVTextAnchor(std::string_view newVTextAnchor);
207 mutable std::string m_style;
209 inline static const std::vector<std::string_view> m_nodeOrder = {
"position",
215 "mso-fit-shape-to-text",
267 std::string
type()
const;
281 bool setType(std::string_view newType);
283 bool setStyle(std::string_view newStyle);
288 inline static const std::vector<std::string_view> m_nodeOrder =
289 {
"v:shadow",
"v:fill",
"v:stroke",
"v:path",
"v:textbox",
"x:ClientData"};
375 std::string
name()
const;
377 uint32_t
row()
const;
378 uint32_t
col()
const;
379 uint32_t
width()
const;
412 explicit XLDrawing(gsl::not_null<XLXmlData*> xmlData);
452 std::string_view name,
453 std::string_view description,
471 void addChartAnchor(std::string_view rId, std::string_view name, uint32_t row, uint32_t col, uint32_t width, uint32_t height);
486 std::string_view name,
487 std::string_view description,
488 std::string_view data,
491 double scalingFactor = 1.0);
516 std::unique_ptr<XLRelationships> m_relationships;
536 explicit XLVmlDrawing(gsl::not_null<XLXmlData*> xmlData);
565 XMLNode firstShapeNode()
const;
567 XMLNode shapeNode(uint32_t index)
const;
575 XMLNode shapeNode(std::string_view cellRef)
const;
589 void print(std::basic_ostream<char>& ostr)
const;
592 uint32_t m_shapeCount{0};
593 uint32_t m_lastAssignedShapeId{0};
594 std::string m_defaultShapeTypeId{};
Definition XLConstants.hpp:42
This class encapsulates the concept of an excel file. It is different from the XLWorkbook,...
Definition XLDocument.hpp:97
Definition XLDrawing.hpp:362
std::string name() const
Definition XLDrawing.cpp:833
uint32_t width() const
Definition XLDrawing.cpp:851
std::vector< uint8_t > imageBinary() const
Extracts the raw binary data of the image from the Excel zip archive.
Definition XLDrawing.cpp:872
uint32_t row() const
Definition XLDrawing.cpp:839
XLDrawingItem()
Definition XLDrawing.cpp:829
XLDrawingItem & operator=(const XLDrawingItem &other)=default
XLDrawingItem(const XLDrawingItem &other)=default
XLDrawingItem & operator=(XLDrawingItem &&other) noexcept=default
XLDrawingItem(XLDrawingItem &&other) noexcept=default
uint32_t height() const
Definition XLDrawing.cpp:860
uint32_t col() const
Definition XLDrawing.cpp:845
std::string relationshipId() const
Definition XLDrawing.cpp:869
std::string description() const
Definition XLDrawing.cpp:836
The XLDrawing class is the base class for worksheet drawings (images, charts, etc....
Definition XLDrawing.hpp:398
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.
Definition XLDrawing.cpp:640
friend class XLWorksheet
Definition XLDrawing.hpp:399
~XLDrawing()=default
The destructor.
XLDrawing()
Constructor.
Definition XLDrawing.hpp:406
void addChartAnchor(std::string_view rId, std::string_view name, uint32_t row, uint32_t col, uint32_t width, uint32_t height)
Definition XLDrawing.cpp:738
XLDrawingItem image(uint32_t index) const
Get an image item by index.
Definition XLDrawing.cpp:929
XLDrawing & operator=(const XLDrawing &other)
Assignment operator.
Definition XLDrawing.cpp:606
friend class XLDocument
Definition XLDrawing.hpp:400
XLDrawing(XLDrawing &&other) noexcept
Move constructor.
void addShape(uint32_t row, uint32_t col, const XLVectorShapeOptions &options=XLVectorShapeOptions())
Add a chart to the drawing.
Definition XLDrawing.cpp:1051
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.
Definition XLDrawing.cpp:797
XLRelationships & relationships()
Get the drawing relationships.
Definition XLDrawing.cpp:820
XLDrawing & operator=(XLDrawing &&other) noexcept
Move assignment operator.
uint32_t imageCount() const
Get the number of images in the drawing.
Definition XLDrawing.cpp:917
Abstract package services port (archive + XML parts + relationships + content types).
Definition XLPackageServices.hpp:56
Definition XLRelationships.hpp:150
An encapsulation of a shape client data element x:ClientData.
Definition XLDrawing.hpp:63
bool setTextHAlign(XLShapeTextHAlign newTextHAlign)
Definition XLDrawing.cpp:170
XLShapeTextVAlign textVAlign() const
Definition XLDrawing.cpp:139
bool setColumn(uint16_t newColumn)
Definition XLDrawing.cpp:180
XLShapeTextHAlign textHAlign() const
Definition XLDrawing.cpp:141
XLShapeClientData(const XLShapeClientData &other)=default
Copy Constructor.
XLShapeClientData()
Definition XLDrawing.cpp:121
XLShapeClientData(XLShapeClientData &&other) noexcept=default
Move Constructor.
bool setAnchor(std::string_view newAnchor)
Definition XLDrawing.cpp:157
bool setTextVAlign(XLShapeTextVAlign newTextVAlign)
Definition XLDrawing.cpp:163
uint32_t row() const
Definition XLDrawing.cpp:143
bool sizeWithCells() const
Definition XLDrawing.cpp:136
bool setMoveWithCells(bool set=true)
Definition XLDrawing.cpp:151
bool autoFill() const
Definition XLDrawing.cpp:138
~XLShapeClientData()=default
bool setObjectType(std::string_view newObjectType)
Component Data Mutators.
Definition XLDrawing.cpp:148
XLShapeClientData & operator=(XLShapeClientData &&other) noexcept=default
Move assignment operator.
bool moveWithCells() const
Definition XLDrawing.cpp:135
XLShapeClientData & operator=(const XLShapeClientData &other)=default
Copy assignment operator.
bool setRow(uint32_t newRow)
Definition XLDrawing.cpp:177
bool setSizeWithCells(bool set=true)
Definition XLDrawing.cpp:154
bool setAutoFill(bool set=true)
Definition XLDrawing.cpp:160
uint16_t column() const
Definition XLDrawing.cpp:145
std::string objectType() const
Component Data Accessors.
Definition XLDrawing.cpp:134
std::string anchor() const
Definition XLDrawing.cpp:137
Definition XLDrawing.hpp:141
uint16_t width() const
Definition XLDrawing.cpp:308
std::string raw() const
Definition XLDrawing.hpp:185
uint16_t marginTop() const
Definition XLDrawing.cpp:301
std::string vTextAnchor() const
Definition XLDrawing.cpp:323
uint16_t marginLeft() const
Definition XLDrawing.cpp:294
uint16_t height() const
Definition XLDrawing.cpp:315
bool hidden() const
Definition XLDrawing.cpp:324
bool setRaw(std::string_view newStyle)
Definition XLDrawing.hpp:200
std::string position() const
Style Attribute Accessors.
Definition XLDrawing.cpp:293
XLShapeStyle()
Definition XLDrawing.cpp:183
bool visible() const
Definition XLDrawing.cpp:325
std::string msoWrapStyle() const
Definition XLDrawing.cpp:322
Definition XLDrawing.hpp:221
bool setFillColor(std::string_view newFillColor)
Setter functions.
Definition XLDrawing.cpp:351
bool stroked() const
Definition XLDrawing.cpp:343
bool setType(std::string_view newType)
Definition XLDrawing.cpp:354
XLShape()
Definition XLDrawing.cpp:337
XLShape(const XLShape &other)=default
Copy Constructor.
std::string fillColor() const
Definition XLDrawing.cpp:342
bool setStroked(bool set)
Definition XLDrawing.cpp:353
friend class XLVmlDrawing
Definition XLDrawing.hpp:222
XLShape & operator=(XLShape &&other) noexcept=default
Move assignment operator.
XLShape & operator=(const XLShape &other)
Copy assignment operator.
friend class XLComments
Definition XLDrawing.hpp:223
bool setStyle(std::string_view newStyle)
Definition XLDrawing.cpp:357
XLShapeStyle style()
Definition XLDrawing.cpp:346
bool allowInCell() const
Definition XLDrawing.cpp:345
bool setAllowInCell(bool set)
Definition XLDrawing.cpp:356
std::string shapeId() const
Component Data Accessors.
Definition XLDrawing.cpp:341
XLShapeClientData clientData()
Definition XLDrawing.cpp:348
XLShape(XLShape &&other) noexcept=default
Move Constructor.
std::string type() const
Definition XLDrawing.cpp:344
The XLVmlDrawing class is the base class for worksheet comments.
Definition XLDrawing.hpp:523
XLVmlDrawing(const XLVmlDrawing &other)=default
The copy constructor.
XLVmlDrawing()
Constructor.
Definition XLDrawing.hpp:530
friend class XLWorksheet
Definition XLDrawing.hpp:524
void print(std::basic_ostream< char > &ostr) const
Print the XML contents of this XLVmlDrawing instance using the underlying XMLNode print function.
Definition XLDrawing.cpp:590
uint32_t shapeCount() const
Definition XLDrawing.cpp:515
XLShape createShape(const XLShape &shapeTemplate=XLShape())
Definition XLDrawing.cpp:543
XLVmlDrawing & operator=(XLVmlDrawing &&other) noexcept=default
~XLVmlDrawing()=default
The destructor.
friend class XLComments
Definition XLDrawing.hpp:525
XLVmlDrawing & operator=(const XLVmlDrawing &)=default
Assignment operator.
bool deleteShape(uint32_t index)
Definition XLDrawing.cpp:519
XLShape shape(uint32_t index) const
Definition XLDrawing.cpp:517
XLVmlDrawing(XLVmlDrawing &&other) noexcept=default
XLXmlFile()=default
Default constructor.
Definition XLXmlParser.hpp:283
Definition IXLCellProvider.hpp:24
XLVectorShapeType
An encapsulation of a drawing item (e.g. an image).
Definition XLDrawing.hpp:296
@ SmileyFace
Definition XLDrawing.hpp:311
@ Arrow
Definition XLDrawing.hpp:302
@ Ellipse
Definition XLDrawing.hpp:298
@ Hexagon
Definition XLDrawing.hpp:305
@ FlowChartData
Definition XLDrawing.hpp:321
@ LightningBolt
Definition XLDrawing.hpp:317
@ Star4
Definition XLDrawing.hpp:306
@ FlowChartDocument
Definition XLDrawing.hpp:320
@ FlowChartDecision
Definition XLDrawing.hpp:319
@ Star16
Definition XLDrawing.hpp:308
@ FlowChartProcess
Definition XLDrawing.hpp:318
@ Donut
Definition XLDrawing.hpp:313
@ Parallelogram
Definition XLDrawing.hpp:304
@ RightTriangle
Definition XLDrawing.hpp:301
@ Cloud
Definition XLDrawing.hpp:312
@ Rectangle
Definition XLDrawing.hpp:297
@ Moon
Definition XLDrawing.hpp:316
@ Star24
Definition XLDrawing.hpp:309
@ Star5
Definition XLDrawing.hpp:307
@ Sun
Definition XLDrawing.hpp:315
@ Ribbon
Definition XLDrawing.hpp:314
@ Heart
Definition XLDrawing.hpp:310
@ Triangle
Definition XLChart.hpp:72
@ Diamond
Definition XLChart.hpp:72
const std::string_view ShapeNodeName
Definition XLDrawing.cpp:29
@ Line
Definition XLChart.hpp:37
constexpr const XLShapeTextHAlign XLDefaultShapeTextHAlign
Definition XLDrawing.hpp:57
OpenXLSX_xml_node XMLNode
Definition XLXmlParser.hpp:64
XLShapeTextVAlign
Definition XLDrawing.hpp:43
@ Center
Definition XLDrawing.hpp:44
@ Top
Definition XLDrawing.hpp:45
const std::string_view ShapeTypeNodeName
Definition XLDrawing.cpp:30
@ Invalid
Definition XLConditionalFormatting.hpp:47
constexpr const XLShapeTextVAlign XLDefaultShapeTextVAlign
Definition XLDrawing.hpp:49
@ Bottom
Definition XLChart.hpp:70
@ Right
Definition XLChart.hpp:70
@ Left
Definition XLChart.hpp:70
@ Top
Definition XLChart.hpp:70
XLShapeTextHAlign
Definition XLDrawing.hpp:51
@ Left
Definition XLDrawing.hpp:52
Options for inserting an image into a worksheet.
Definition XLImageOptions.hpp:33
Definition XLDrawing.hpp:135
std::string value
Definition XLDrawing.hpp:137
std::string name
Definition XLDrawing.hpp:136
Definition XLDrawing.hpp:325
std::optional< uint32_t > endCol
Definition XLDrawing.hpp:340
bool flipV
Definition XLDrawing.hpp:347
int32_t endOffsetY
Definition XLDrawing.hpp:342
XLVectorShapeType type
Definition XLDrawing.hpp:326
std::string arrowStart
Definition XLDrawing.hpp:351
double lineWidth
Definition XLDrawing.hpp:331
bool flipH
Definition XLDrawing.hpp:346
int32_t offsetX
Definition XLDrawing.hpp:335
uint32_t width
Definition XLDrawing.hpp:333
std::string vertAlign
Definition XLDrawing.hpp:357
std::string lineDash
Definition XLDrawing.hpp:350
std::string macro
Definition XLDrawing.hpp:359
std::string fillColor
Definition XLDrawing.hpp:329
int32_t endOffsetX
Definition XLDrawing.hpp:341
std::string lineColor
Definition XLDrawing.hpp:330
std::string name
Definition XLDrawing.hpp:327
uint32_t height
Definition XLDrawing.hpp:334
uint32_t rotation
Definition XLDrawing.hpp:345
std::string arrowEnd
Definition XLDrawing.hpp:352
std::optional< XLRichText > richText
Definition XLDrawing.hpp:355
int32_t offsetY
Definition XLDrawing.hpp:336
std::string horzAlign
Definition XLDrawing.hpp:356
std::optional< uint32_t > endRow
Definition XLDrawing.hpp:339
std::string text
Definition XLDrawing.hpp:328