OpenXLSX 1.12.1
Modern C++ Excel Library (Fork of OpenXLSX by Kenneth Troldal Balslev)
Loading...
Searching...
No Matches
XLPackagePartFactory.hpp
Go to the documentation of this file.
1/*
2 * OpenXLSX-NX - Modern High-Performance C++ Excel Library
3 *
4 * Original work Copyright (c) 2018-2025, Kenneth Troldal Balslev and OpenXLSX contributors
5 * Modified work Copyright (c) 2026, Curry Tang and OpenXLSX-NX contributors
6 *
7 * Distributed under the BSD 3-Clause License.
8 * See LICENSE.md in the project root or https://opensource.org/licenses/BSD-3-Clause
9 */
10
11#ifndef OPENXLSX_XLPACKAGEPARTFACTORY_HPP
12#define OPENXLSX_XLPACKAGEPARTFACTORY_HPP
13
14#ifdef _MSC_VER
15# pragma warning(push)
16# pragma warning(disable : 4251)
17# pragma warning(disable : 4275)
18#endif
19
31
32#include "OpenXLSX-Exports.hpp"
33#include "XLChart.hpp"
34#include "XLComments.hpp"
35#include "XLDrawing.hpp"
36#include "XLRelationships.hpp"
37#include "XLTables.hpp"
39
40#include <cstdint>
41#include <gsl/span>
42#include <string>
43#include <string_view>
44
45namespace OpenXLSX
46{
52 class OPENXLSX_EXPORT XLPackagePartFactory
53 {
54 public:
55 virtual ~XLPackagePartFactory() = default;
56
57 // ----- Sheet accessory presence -----
58
59 [[nodiscard]] virtual bool hasSheetRelationships(uint16_t sheetXmlNo, bool isChartsheet = false) const = 0;
60 [[nodiscard]] virtual bool hasSheetVmlDrawing(uint16_t sheetXmlNo) const = 0;
61 [[nodiscard]] virtual bool hasSheetComments(uint16_t sheetXmlNo) const = 0;
62 [[nodiscard]] virtual bool hasSheetThreadedComments(uint16_t sheetXmlNo) const = 0;
63 [[nodiscard]] virtual bool hasSheetDrawing(uint16_t sheetXmlNo) const = 0;
64 [[nodiscard]] virtual bool hasSheetTables(uint16_t sheetXmlNo) const = 0;
65
66 // ----- Sheet accessory access / creation -----
67
68 [[nodiscard]] virtual XLRelationships sheetRelationships(uint16_t sheetXmlNo, bool isChartsheet = false) = 0;
69 [[nodiscard]] virtual XLDrawing sheetDrawing(uint16_t sheetXmlNo) = 0;
70 [[nodiscard]] virtual XLDrawing createDrawing() = 0;
71 [[nodiscard]] virtual XLDrawing drawing(std::string_view path) = 0;
72 [[nodiscard]] virtual XLVmlDrawing sheetVmlDrawing(uint16_t sheetXmlNo) = 0;
73 [[nodiscard]] virtual XLComments sheetComments(uint16_t sheetXmlNo) = 0;
74 [[nodiscard]] virtual XLThreadedComments sheetThreadedComments(uint16_t sheetXmlNo) = 0;
75 [[nodiscard]] virtual XLTables sheetTables(uint16_t sheetXmlNo) = 0;
76
77 // ----- Charts & media -----
78
79 [[nodiscard]] virtual XLChart createChart(XLChartType type = XLChartType::Bar) = 0;
80 [[nodiscard]] virtual std::string addImage(std::string_view name, std::string_view data) = 0;
81 [[nodiscard]] virtual std::string addImage(std::string_view name, gsl::span<const uint8_t> data) = 0;
82 [[nodiscard]] virtual std::string getImage(std::string_view path) const = 0;
83
84 // ----- Tables / slicers -----
85
86 [[nodiscard]] virtual uint32_t nextTableId() const = 0;
87
88 [[nodiscard]] virtual std::string createTableSlicerCache(uint32_t tableId,
89 uint32_t tableColumnId,
90 std::string_view name,
91 std::string_view sourceName) = 0;
92 [[nodiscard]] virtual std::string findOrCreateTableSlicerCache(uint32_t tableId,
93 uint32_t tableColumnId,
94 std::string_view name,
95 std::string_view sourceName) = 0;
96
97 [[nodiscard]] virtual std::string createPivotSlicerCache(uint32_t pivotCacheId,
98 uint32_t sheetId,
99 std::string_view pivotTableName,
100 std::string_view name,
101 std::string_view sourceName) = 0;
102 [[nodiscard]] virtual std::string findOrCreatePivotSlicerCache(uint32_t pivotCacheId,
103 uint32_t sheetId,
104 std::string_view pivotTableName,
105 std::string_view name,
106 std::string_view sourceName) = 0;
107
108 [[nodiscard]] virtual std::string createSlicer(std::string_view name,
109 std::string_view cacheName,
110 std::string_view caption,
111 std::string_view existingSlicerFile = {}) = 0;
112
113 virtual void deleteSlicerFileAndOrphanCache(const std::string& name) = 0;
114 };
115
116} // namespace OpenXLSX
117
118#ifdef _MSC_VER
119# pragma warning(pop)
120#endif
121
122#endif // OPENXLSX_XLPACKAGEPARTFACTORY_HPP
Definition XLChart.hpp:261
The XLComments class is the base class for worksheet comments.
Definition XLComments.hpp:98
The XLDrawing class is the base class for worksheet drawings (images, charts, etc....
Definition XLDrawing.hpp:398
Abstract factory for worksheet-facing package parts.
Definition XLPackagePartFactory.hpp:53
virtual std::string getImage(std::string_view path) const =0
virtual XLChart createChart(XLChartType type=XLChartType::Bar)=0
virtual bool hasSheetRelationships(uint16_t sheetXmlNo, bool isChartsheet=false) const =0
virtual XLDrawing createDrawing()=0
virtual std::string addImage(std::string_view name, std::string_view data)=0
virtual std::string findOrCreatePivotSlicerCache(uint32_t pivotCacheId, uint32_t sheetId, std::string_view pivotTableName, std::string_view name, std::string_view sourceName)=0
virtual uint32_t nextTableId() const =0
virtual std::string createPivotSlicerCache(uint32_t pivotCacheId, uint32_t sheetId, std::string_view pivotTableName, std::string_view name, std::string_view sourceName)=0
virtual bool hasSheetDrawing(uint16_t sheetXmlNo) const =0
virtual std::string createTableSlicerCache(uint32_t tableId, uint32_t tableColumnId, std::string_view name, std::string_view sourceName)=0
virtual bool hasSheetVmlDrawing(uint16_t sheetXmlNo) const =0
virtual ~XLPackagePartFactory()=default
virtual XLVmlDrawing sheetVmlDrawing(uint16_t sheetXmlNo)=0
virtual XLDrawing drawing(std::string_view path)=0
virtual bool hasSheetComments(uint16_t sheetXmlNo) const =0
virtual XLRelationships sheetRelationships(uint16_t sheetXmlNo, bool isChartsheet=false)=0
virtual XLTables sheetTables(uint16_t sheetXmlNo)=0
virtual bool hasSheetTables(uint16_t sheetXmlNo) const =0
virtual std::string addImage(std::string_view name, gsl::span< const uint8_t > data)=0
virtual XLDrawing sheetDrawing(uint16_t sheetXmlNo)=0
virtual XLComments sheetComments(uint16_t sheetXmlNo)=0
virtual bool hasSheetThreadedComments(uint16_t sheetXmlNo) const =0
virtual std::string findOrCreateTableSlicerCache(uint32_t tableId, uint32_t tableColumnId, std::string_view name, std::string_view sourceName)=0
virtual std::string createSlicer(std::string_view name, std::string_view cacheName, std::string_view caption, std::string_view existingSlicerFile={})=0
virtual XLThreadedComments sheetThreadedComments(uint16_t sheetXmlNo)=0
virtual void deleteSlicerFileAndOrphanCache(const std::string &name)=0
Definition XLRelationships.hpp:150
A class encapsulating modern Excel threaded comments (ThreadedComments.xml).
Definition XLThreadedComments.hpp:66
The XLVmlDrawing class is the base class for worksheet comments.
Definition XLDrawing.hpp:523
Definition IXLCellProvider.hpp:24
XLChartType
Definition XLChart.hpp:24
@ Bar
Definition XLChart.hpp:25
XLTableCollection XLTables
Definition XLTables.hpp:379