Doxygen
Loading...
Searching...
No Matches
rtfstyle.cpp File Reference
#include "rtfstyle.h"
#include <string>
#include <fstream>
#include <map>
#include "message.h"
#include "regex.h"
Include dependency graph for rtfstyle.cpp:

Go to the source code of this file.

Macros

#define RTF_LatexToc(lvl, nest, nxt, pos, twps)
#define RTF_ListBullet(lvl, nest, nxt, pos, lvl2)
#define RTF_ListEnum(lvl, nest, nxt, pos)
#define RTF_CodeExample(lvl, nest, nxt, pos)
#define RTF_ListContinue(lvl, nest, nxt, pos)
#define RTF_DescContinue(lvl, nest, nxt, pos)
#define RTF_ListElement(id, lvl, pos, chr)

Functions

void loadStylesheet (const DString &name, StyleDataMap &map)
void loadExtensions (const DString &name)

Variables

DString rtf_title
DString rtf_subject
DString rtf_comments
DString rtf_company
DString rtf_logoFilename
DString rtf_author
DString rtf_manager
DString rtf_documentType
DString rtf_documentId
DString rtf_keywords
static std::map< std::string, DString & > g_styleMap
char rtf_Style_Reset [] = "\\pard\\plain "
Rtf_Style_Default rtf_Style_Default []
Rtf_Table_Default rtf_Table_Default []
static const reg::Ex s_clause (R"(\\s(\d+)\s*)")
StyleDataMap rtf_Style

Macro Definition Documentation

◆ RTF_CodeExample

#define RTF_CodeExample ( lvl,
nest,
nxt,
pos )
Value:
{ "CodeExample"#lvl, \
"\\s"#nest"\\li"#pos"\\widctlpar\\adjustright \\shading1000\\cbpat8 \\f2\\fs16\\cgrid ", \
"\\sbasedon0 \\snext"#nxt" Code Example "#lvl \
}

Definition at line 75 of file rtfstyle.cpp.

◆ RTF_DescContinue

#define RTF_DescContinue ( lvl,
nest,
nxt,
pos )
Value:
{ "DescContinue"#lvl, \
"\\s"#nest"\\li"#pos"\\widctlpar\\ql\\adjustright \\fs20\\cgrid ", \
"\\sbasedon0 \\snext"#nxt" DescContinue "#lvl \
}

Definition at line 87 of file rtfstyle.cpp.

◆ RTF_LatexToc

#define RTF_LatexToc ( lvl,
nest,
nxt,
pos,
twps )
Value:
\
{ "LatexTOC"#lvl, \
"\\s"#nest"\\li"#pos"\\sa"#twps"\\sb"#twps"\\widctlpar\\tqr\\tldot\\tx8640\\adjustright \\fs20\\cgrid ",\
"\\sbasedon0 \\snext"#nxt" LatexTOC "#lvl \
}

Definition at line 56 of file rtfstyle.cpp.

◆ RTF_ListBullet

#define RTF_ListBullet ( lvl,
nest,
nxt,
pos,
lvl2 )
Value:
{ "ListBullet"#lvl, \
"\\s"#nest"\\fi-360\\li"#pos"\\widctlpar\\jclisttab\\tx"#pos"{\\*\\pn \\pnlvlbody\\ilvl0\\ls"#lvl2"\\pnrnot0\\pndec }\\ls1\\adjustright \\fs20\\cgrid ", \
"\\sbasedon0 \\snext"#nxt" \\sautoupd List Bullet "#lvl \
}

Definition at line 63 of file rtfstyle.cpp.

◆ RTF_ListContinue

#define RTF_ListContinue ( lvl,
nest,
nxt,
pos )
Value:
{ "ListContinue"#lvl, \
"\\s"#nest"\\li"#pos"\\sa60\\sb30\\qj\\widctlpar\\qj\\adjustright \\fs20\\cgrid ", \
"\\sbasedon0 \\snext"#nxt" List Continue "#lvl \
}

Definition at line 81 of file rtfstyle.cpp.

◆ RTF_ListElement

#define RTF_ListElement ( id,
lvl,
pos,
chr )
Value:
{ id, lvl, \
"\\listlevel\\levelnfc23\\leveljc0\\levelstartat1\\levelfollow0{\\leveltext \\'01\\u"#chr" ?;}{\\levelnumbers;}\\f8\\dbch\\af3\\fi-360\\li"#pos, \
"{\\*\\hyphen2\\hyphlead2\\hyphtrail2\\hyphmax0}\\nowidctlpar\\cf0\\hich\\af0\\langfe2052\\dbch\\af0\\afs24\\lang1081\\loch\\f0\\fs24\\lang1033{\\listtext\\pard\\plain \\hich\\af3\\dbch\\af3\\loch\\f8 \\'01\\u"#chr"\\tab}\\ilvl"#lvl"\\ls"#id" \\li0\\ri0\\lin0\\rin0\\fi-360\\tx"#pos"\\li"#pos"\\ri0\\lin"#pos"\\rin0\\fi-360\\kerning1\\hich\\af4\\dbch\\af5\\rtlch \\ltrch\\loch\\fs20" \
}

Definition at line 244 of file rtfstyle.cpp.

◆ RTF_ListEnum

#define RTF_ListEnum ( lvl,
nest,
nxt,
pos )
Value:
{ "ListEnum"#lvl, \
"\\s"#nest"\\fi-360\\li"#pos"\\widctlpar\\fs20\\cgrid ", \
"\\sbasedon0 \\snext"#nxt" \\sautoupd List Enum "#lvl \
}

Definition at line 69 of file rtfstyle.cpp.

Function Documentation

◆ loadExtensions()

void loadExtensions ( const DString & name)

Definition at line 368 of file rtfstyle.cpp.

369{
370 std::ifstream file(name.str());
371 if (!file.is_open())
372 {
373 err("Can't open RTF extensions file {}. Using defaults.\n",name);
374 return;
375 }
376 msg("Loading RTF extensions {}...\n",name);
377
378 uint32_t lineNr=1;
379
380 for (std::string line ; getline(file,line) ; ) // for each line
381 {
382 if (line.empty() || line[0]=='#') continue; // skip blanks & comments
383 static const reg::Ex assignment_splitter(R"(\s*=\s*)");
385 if (reg::search(line,match,assignment_splitter))
386 {
387 std::string key = match.prefix().str();
388 std::string value = match.suffix().str();
389 auto it = g_styleMap.find(key);
390 if (it!=g_styleMap.end())
391 {
392 it->second = value;
393 }
394 else
395 {
396 warn(name,lineNr,"Ignoring unknown extension key '{}'...",key);
397 }
398 }
399 else
400 {
401 warn(name,lineNr,"Assignment of style sheet name expected!");
402 }
403 lineNr++;
404 }
405}
const std::string & str() const
Definition dstring.h:645
Class representing a regular expression.
Definition regex.h:39
Object representing the matching results.
Definition regex.h:154
#define warn(file, line, fmt,...)
Definition message.h:97
#define msg(fmt,...)
Definition message.h:94
#define err(fmt,...)
Definition message.h:127
bool search(std::string_view str, Match &match, const Ex &re, size_t pos)
Search in a given string str starting at position pos for a match against regular expression re.
Definition regex.cpp:850
bool match(std::string_view str, Match &match, const Ex &re)
Matches a given string str for a match against regular expression re.
Definition regex.cpp:861
static std::map< std::string, DString & > g_styleMap
Definition rtfstyle.cpp:39

References err, g_styleMap, msg, reg::search(), DString::str(), and warn.

Referenced by RTFGenerator::init().

◆ loadStylesheet()

void loadStylesheet ( const DString & name,
StyleDataMap & map )

Definition at line 326 of file rtfstyle.cpp.

327{
328 std::ifstream file(name.str());
329 if (!file.is_open())
330 {
331 err("Can't open RTF style sheet file {}. Using defaults.\n",name);
332 return;
333 }
334 msg("Loading RTF style sheet {}...\n",name);
335
336 uint32_t lineNr=1;
337
338 for (std::string line ; getline(file,line) ; ) // for each line
339 {
340 if (line.empty() || line[0]=='#') continue; // skip blanks & comments
341 static const reg::Ex assignment_splitter(R"(\s*=\s*)");
343 if (reg::search(line,match,assignment_splitter))
344 {
345 DString key = match.prefix().str();
346 DString value = match.suffix().str();
347 auto it = map.find(key.str());
348 if (it!=map.end())
349 {
350 StyleData& styleData = it->second;
351 styleData.setStyle(value,key);
352 }
353 else
354 {
355 warn(name,lineNr,"Unknown style sheet name {} ignored.",key);
356 }
357 }
358 else
359 {
360 warn(name,lineNr,"Assignment of style sheet name expected line='{}'!",line);
361 }
362 lineNr++;
363 }
364}
A String class for use with Doxygen wrapping std::string and adding some additional functionality off...
Definition dstring.h:84
bool setStyle(const DString &command, const DString &styleName)
Definition rtfstyle.cpp:306

References err, msg, reg::search(), StyleData::setStyle(), DString::str(), and warn.

Referenced by RTFGenerator::init().

Variable Documentation

◆ g_styleMap

std::map<std::string,DString &> g_styleMap
static
Initial value:
=
{
{ "Title", rtf_title },
{ "Subject", rtf_subject },
{ "Comments", rtf_comments },
{ "Company", rtf_company },
{ "LogoFilename", rtf_logoFilename },
{ "Author", rtf_author },
{ "Manager", rtf_manager },
{ "DocumentType", rtf_documentType },
{ "DocumentId", rtf_documentId },
{ "Keywords", rtf_keywords }
}
DString rtf_author
Definition rtfstyle.cpp:33
DString rtf_documentId
Definition rtfstyle.cpp:36
DString rtf_comments
Definition rtfstyle.cpp:30
DString rtf_subject
Definition rtfstyle.cpp:29
DString rtf_logoFilename
Definition rtfstyle.cpp:32
DString rtf_manager
Definition rtfstyle.cpp:34
DString rtf_documentType
Definition rtfstyle.cpp:35
DString rtf_title
Definition rtfstyle.cpp:28
DString rtf_company
Definition rtfstyle.cpp:31
DString rtf_keywords
Definition rtfstyle.cpp:37

Definition at line 39 of file rtfstyle.cpp.

Referenced by loadExtensions().

◆ rtf_author

DString rtf_author

Definition at line 33 of file rtfstyle.cpp.

Referenced by RTFGenerator::endIndexSection(), and RTFGenerator::startIndexSection().

◆ rtf_comments

DString rtf_comments

Definition at line 30 of file rtfstyle.cpp.

Referenced by RTFGenerator::startIndexSection().

◆ rtf_company

DString rtf_company

Definition at line 31 of file rtfstyle.cpp.

Referenced by RTFGenerator::endIndexSection(), and RTFGenerator::startIndexSection().

◆ rtf_documentId

DString rtf_documentId

Definition at line 36 of file rtfstyle.cpp.

Referenced by RTFGenerator::endIndexSection().

◆ rtf_documentType

DString rtf_documentType

Definition at line 35 of file rtfstyle.cpp.

Referenced by RTFGenerator::endIndexSection(), and RTFGenerator::startIndexSection().

◆ rtf_keywords

DString rtf_keywords

Definition at line 37 of file rtfstyle.cpp.

Referenced by RTFGenerator::startIndexSection().

◆ rtf_logoFilename

DString rtf_logoFilename

Definition at line 32 of file rtfstyle.cpp.

Referenced by RTFGenerator::endIndexSection(), and RTFGenerator::init().

◆ rtf_manager

DString rtf_manager

Definition at line 34 of file rtfstyle.cpp.

Referenced by RTFGenerator::startIndexSection().

◆ rtf_Style

◆ rtf_Style_Default

Rtf_Style_Default rtf_Style_Default[]

Definition at line 93 of file rtfstyle.cpp.

Referenced by RTFGenerator::init(), and RTFGenerator::writeStyleSheetFile().

◆ rtf_Style_Reset

char rtf_Style_Reset[] = "\\pard\\plain "

Definition at line 54 of file rtfstyle.cpp.

Referenced by RTFGenerator::beginRTFChapter(), RTFGenerator::beginRTFSection(), RTFGenerator::endCallGraph(), RTFGenerator::endClassDiagram(), RTFGenerator::endDirDepGraph(), RTFGenerator::endDotGraph(), RTFGenerator::endGroupHeader(), RTFGenerator::endInclDepGraph(), RTFGenerator::endIndexSection(), RTFGenerator::endMemberGroupHeader(), RTFGenerator::endTitleHead(), RTFDocVisitor::includePicturePreRTF(), RTFDocVisitor::operator()(), RTFDocVisitor::operator()(), RTFDocVisitor::operator()(), RTFDocVisitor::operator()(), RTFDocVisitor::operator()(), RTFDocVisitor::operator()(), RTFDocVisitor::operator()(), RTFDocVisitor::operator()(), RTFDocVisitor::operator()(), RTFDocVisitor::operator()(), RTFDocVisitor::operator()(), RTFDocVisitor::operator()(), RTFDocVisitor::operator()(), RTFDocVisitor::operator()(), RTFDocVisitor::operator()(), RTFDocVisitor::operator()(), RTFCodeGenerator::startCodeFragment(), RTFGenerator::startCompoundTemplateParams(), RTFGenerator::startConstraintList(), RTFGenerator::startDescTable(), RTFGenerator::startExamples(), RTFGenerator::startGroupHeader(), RTFGenerator::startIndent(), RTFGenerator::startIndexList(), RTFGenerator::startInlineHeader(), RTFGenerator::startItemListItem(), RTFGenerator::startMemberDescription(), RTFGenerator::startMemberDoc(), RTFGenerator::startMemberDocSimple(), RTFGenerator::startMemberGroup(), RTFGenerator::startMemberGroupHeader(), RTFGenerator::startMemberItem(), RTFGenerator::startMemberSubtitle(), RTFGenerator::startSection(), RTFGenerator::startTextBlock(), RTFGenerator::startTitleHead(), RTFGenerator::writeInheritedSectionTitle(), and RTFGenerator::writePageLink().

◆ rtf_subject

DString rtf_subject

Definition at line 29 of file rtfstyle.cpp.

Referenced by RTFGenerator::startIndexSection().

◆ rtf_Table_Default

Rtf_Table_Default rtf_Table_Default[]

Definition at line 250 of file rtfstyle.cpp.

Referenced by RTFGenerator::beginRTFDocument(), and RTFDocVisitor::getListTable().

◆ rtf_title

DString rtf_title

Definition at line 28 of file rtfstyle.cpp.

Referenced by RTFGenerator::endIndexSection().

◆ s_clause

const reg::Ex s_clause(R"(\\s(\d+)\s*)") ( R"(\\s(\d+)\s*)" )
static