|
OpenWord 1.0.0
Modern C++17 library for parsing, manipulating, and saving DOCX files.
|
Represents the main Office Open XML Word document (.docx). More...
#include <Document.h>
Public Member Functions | |
| Document () | |
| Document (const std::string &templatePath) | |
| ~Document () | |
| Document (const Document &)=delete | |
| Document & | operator= (const Document &)=delete |
| bool | save (gsl::czstring filepath) |
| bool | load (gsl::czstring filepath) |
| bool | validate (gsl::czstring partName, const SchemaValidator &validator, std::string &outErrors) const |
| void | setEvenAndOddHeaders (bool val=true) |
| Paragraph | addParagraph (const std::string &text="") |
| void | addHtml (const std::string &html) |
| Table | addTable (int rows, int cols) |
| Nests a new table inside this cell. | |
| std::vector< BlockElement > | elements () const |
| Section | finalSection () |
| std::vector< Paragraph > | paragraphs () const |
| std::vector< Table > | tables () const |
| std::vector< Chart > | charts () const |
| std::map< int, std::string > | footnotes () const |
| Retrieves all footnotes in the document as a map of ID to text. | |
| std::map< int, std::string > | endnotes () const |
| Retrieves all endnotes in the document as a map of ID to text. | |
| void | setMetadata (const Metadata &meta) |
| Metadata | metadata () const |
| void | addTableOfContents (gsl::czstring title="Table of Contents", int max_levels=3, TOCLeader leader=TOCLeader::Dot) |
| void | addWatermark (const std::string &text) |
| Chart | addChart (ChartType type, const std::vector< ChartSeries > &series, const ChartOptions &options=ChartOptions()) |
| int | createFootnote (const std::string &text) |
| int | createComment (const std::string &text, const std::string &author="Author", const std::string &initials="") |
| Creates a new comment in the document's global comments registry. | |
| int | createEndnote (const std::string &text) |
| StyleCollection | styles () |
| NumberingCollection | numbering () |
| void | addStyle (gsl::czstring styleId, gsl::czstring name) |
| std::string | convertMathMLToOMML (const std::string &mathml) const |
| std::string | convertLaTeXToOMML (const std::string &latex) const |
| int | replaceText (const std::string &search, const std::string &replace) |
| int | cloneRowAndSetValues (const std::string &search, const std::vector< std::map< std::string, std::string > > &values) |
Template Engine: Clones a table row containing the search string. Generates a new row for each element in the values array, replacing placeholders with the map values. The original row is removed. | |
Represents the main Office Open XML Word document (.docx).
This class serves as the main entry point for creating, parsing, and manipulating DOCX files. It manages the core lifecycle, resources, relationships, and global configurations.
| openword::Document::Document | ( | ) |
|
explicit |
| openword::Document::~Document | ( | ) |
|
delete |
| Chart openword::Document::addChart | ( | ChartType | type, |
| const std::vector< ChartSeries > & | series, | ||
| const ChartOptions & | options = ChartOptions() |
||
| ) |
| void openword::Document::addHtml | ( | const std::string & | html | ) |
| Paragraph openword::Document::addParagraph | ( | const std::string & | text = "" | ) |
| void openword::Document::addStyle | ( | gsl::czstring | styleId, |
| gsl::czstring | name | ||
| ) |
| styleId | Unique ID for the style (e.g., "Heading1") |
| name | Human-readable name |
| Table openword::Document::addTable | ( | int | rows, |
| int | cols | ||
| ) |
Nests a new table inside this cell.
| rows | Initial number of rows. |
| cols | Initial number of columns. |
| void openword::Document::addTableOfContents | ( | gsl::czstring | title = "Table of Contents", |
| int | max_levels = 3, |
||
| TOCLeader | leader = TOCLeader::Dot |
||
| ) |
| void openword::Document::addWatermark | ( | const std::string & | text | ) |
| std::vector< Chart > openword::Document::charts | ( | ) | const |
| int openword::Document::cloneRowAndSetValues | ( | const std::string & | search, |
| const std::vector< std::map< std::string, std::string > > & | values | ||
| ) |
Template Engine: Clones a table row containing the search string. Generates a new row for each element in the values array, replacing placeholders with the map values. The original row is removed.
| search | The placeholder string identifying the target row. |
| values | A vector of maps for replacements. |
| std::string openword::Document::convertLaTeXToOMML | ( | const std::string & | latex | ) | const |
| std::string openword::Document::convertMathMLToOMML | ( | const std::string & | mathml | ) | const |
| int openword::Document::createComment | ( | const std::string & | text, |
| const std::string & | author = "Author", |
||
| const std::string & | initials = "" |
||
| ) |
Creates a new comment in the document's global comments registry.
| text | The comment text. |
| author | The author of the comment (defaults to "Author"). |
| initials | The initials of the author. |
| int openword::Document::createEndnote | ( | const std::string & | text | ) |
| int openword::Document::createFootnote | ( | const std::string & | text | ) |
| std::vector< BlockElement > openword::Document::elements | ( | ) | const |
| std::map< int, std::string > openword::Document::endnotes | ( | ) | const |
Retrieves all endnotes in the document as a map of ID to text.
| Section openword::Document::finalSection | ( | ) |
| std::map< int, std::string > openword::Document::footnotes | ( | ) | const |
Retrieves all footnotes in the document as a map of ID to text.
| bool openword::Document::load | ( | gsl::czstring | filepath | ) |
| Metadata openword::Document::metadata | ( | ) | const |
| NumberingCollection openword::Document::numbering | ( | ) |
| std::vector< Paragraph > openword::Document::paragraphs | ( | ) | const |
| int openword::Document::replaceText | ( | const std::string & | search, |
| const std::string & | replace | ||
| ) |
| bool openword::Document::save | ( | gsl::czstring | filepath | ) |
| void openword::Document::setEvenAndOddHeaders | ( | bool | val = true | ) |
| void openword::Document::setMetadata | ( | const Metadata & | meta | ) |
| StyleCollection openword::Document::styles | ( | ) |
| std::vector< Table > openword::Document::tables | ( | ) | const |
| bool openword::Document::validate | ( | gsl::czstring | partName, |
| const SchemaValidator & | validator, | ||
| std::string & | outErrors | ||
| ) | const |