OpenWord 1.0.0
Modern C++17 library for parsing, manipulating, and saving DOCX files.
Loading...
Searching...
No Matches
Public Member Functions | List of all members
openword::Document Class Reference

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
 
Documentoperator= (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< BlockElementelements () const
 
Section finalSection ()
 
std::vector< Paragraphparagraphs () const
 
std::vector< Tabletables () const
 
std::vector< Chartcharts () 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.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ Document() [1/3]

openword::Document::Document ( )

◆ Document() [2/3]

openword::Document::Document ( const std::string &  templatePath)
explicit

◆ ~Document()

openword::Document::~Document ( )

◆ Document() [3/3]

openword::Document::Document ( const Document )
delete

Member Function Documentation

◆ addChart()

Chart openword::Document::addChart ( ChartType  type,
const std::vector< ChartSeries > &  series,
const ChartOptions options = ChartOptions() 
)

◆ addHtml()

void openword::Document::addHtml ( const std::string &  html)

◆ addParagraph()

Paragraph openword::Document::addParagraph ( const std::string &  text = "")

◆ addStyle()

void openword::Document::addStyle ( gsl::czstring  styleId,
gsl::czstring  name 
)
Parameters
styleIdUnique ID for the style (e.g., "Heading1")
nameHuman-readable name

◆ addTable()

Table openword::Document::addTable ( int  rows,
int  cols 
)

Nests a new table inside this cell.

Parameters
rowsInitial number of rows.
colsInitial number of columns.
Returns
The proxy object to the newly created nested table.

◆ addTableOfContents()

void openword::Document::addTableOfContents ( gsl::czstring  title = "Table of Contents",
int  max_levels = 3,
TOCLeader  leader = TOCLeader::Dot 
)

◆ addWatermark()

void openword::Document::addWatermark ( const std::string &  text)

◆ charts()

std::vector< Chart > openword::Document::charts ( ) const

◆ cloneRowAndSetValues()

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.

Parameters
searchThe placeholder string identifying the target row.
valuesA vector of maps for replacements.
Returns
Number of rows generated.

◆ convertLaTeXToOMML()

std::string openword::Document::convertLaTeXToOMML ( const std::string &  latex) const

◆ convertMathMLToOMML()

std::string openword::Document::convertMathMLToOMML ( const std::string &  mathml) const

◆ createComment()

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.

Parameters
textThe comment text.
authorThe author of the comment (defaults to "Author").
initialsThe initials of the author.
Returns
The unique identifier integer for the created comment, used to anchor it to text.

◆ createEndnote()

int openword::Document::createEndnote ( const std::string &  text)

◆ createFootnote()

int openword::Document::createFootnote ( const std::string &  text)

◆ elements()

std::vector< BlockElement > openword::Document::elements ( ) const

◆ endnotes()

std::map< int, std::string > openword::Document::endnotes ( ) const

Retrieves all endnotes in the document as a map of ID to text.

◆ finalSection()

Section openword::Document::finalSection ( )

◆ footnotes()

std::map< int, std::string > openword::Document::footnotes ( ) const

Retrieves all footnotes in the document as a map of ID to text.

◆ load()

bool openword::Document::load ( gsl::czstring  filepath)

◆ metadata()

Metadata openword::Document::metadata ( ) const

◆ numbering()

NumberingCollection openword::Document::numbering ( )

◆ operator=()

Document & openword::Document::operator= ( const Document )
delete

◆ paragraphs()

std::vector< Paragraph > openword::Document::paragraphs ( ) const

◆ replaceText()

int openword::Document::replaceText ( const std::string &  search,
const std::string &  replace 
)

◆ save()

bool openword::Document::save ( gsl::czstring  filepath)

◆ setEvenAndOddHeaders()

void openword::Document::setEvenAndOddHeaders ( bool  val = true)

◆ setMetadata()

void openword::Document::setMetadata ( const Metadata meta)

◆ styles()

StyleCollection openword::Document::styles ( )

◆ tables()

std::vector< Table > openword::Document::tables ( ) const

◆ validate()

bool openword::Document::validate ( gsl::czstring  partName,
const SchemaValidator validator,
std::string &  outErrors 
) const

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