Doxygen
Loading...
Searching...
No Matches
rtfstyle.cpp File Reference
#include <string>
#include <fstream>
#include "rtfstyle.h"
#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 70 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 82 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 51 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 58 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 76 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 239 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 64 of file rtfstyle.cpp.

Function Documentation

◆ loadExtensions()

void loadExtensions ( const DString & name)

Definition at line 363 of file rtfstyle.cpp.

364{
365 std::ifstream file(name.str());
366 if (!file.is_open())
367 {
368 err("Can't open RTF extensions file {}. Using defaults.\n",name);
369 return;
370 }
371 msg("Loading RTF extensions {}...\n",name);
372
373 uint32_t lineNr=1;
374
375 for (std::string line ; getline(file,line) ; ) // for each line
376 {
377 if (line.empty() || line[0]=='#') continue; // skip blanks & comments
378 static const reg::Ex assignment_splitter(R"(\s*=\s*)");
380 if (reg::search(line,match,assignment_splitter))
381 {
382 std::string key = match.prefix().str();
383 std::string value = match.suffix().str();
384 auto it = g_styleMap.find(key);
385 if (it!=g_styleMap.end())
386 {
387 it->second = value;
388 }
389 else
390 {
391 warn(name,lineNr,"Ignoring unknown extension key '{}'...",key);
392 }
393 }
394 else
395 {
396 warn(name,lineNr,"Assignment of style sheet name expected!");
397 }
398 lineNr++;
399 }
400}
const std::string & str() const
Definition dstring.h:649
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:847
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:858
static std::map< std::string, DString & > g_styleMap
Definition rtfstyle.cpp:34

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 321 of file rtfstyle.cpp.

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

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:28
DString rtf_documentId
Definition rtfstyle.cpp:31
DString rtf_comments
Definition rtfstyle.cpp:25
DString rtf_subject
Definition rtfstyle.cpp:24
DString rtf_logoFilename
Definition rtfstyle.cpp:27
DString rtf_manager
Definition rtfstyle.cpp:29
DString rtf_documentType
Definition rtfstyle.cpp:30
DString rtf_title
Definition rtfstyle.cpp:23
DString rtf_company
Definition rtfstyle.cpp:26
DString rtf_keywords
Definition rtfstyle.cpp:32

Definition at line 34 of file rtfstyle.cpp.

Referenced by loadExtensions().

◆ rtf_author

DString rtf_author

Definition at line 28 of file rtfstyle.cpp.

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

◆ rtf_comments

DString rtf_comments

Definition at line 25 of file rtfstyle.cpp.

Referenced by RTFGenerator::startIndexSection().

◆ rtf_company

DString rtf_company

Definition at line 26 of file rtfstyle.cpp.

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

◆ rtf_documentId

DString rtf_documentId

Definition at line 31 of file rtfstyle.cpp.

Referenced by RTFGenerator::endIndexSection().

◆ rtf_documentType

DString rtf_documentType

Definition at line 30 of file rtfstyle.cpp.

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

◆ rtf_keywords

DString rtf_keywords

Definition at line 32 of file rtfstyle.cpp.

Referenced by RTFGenerator::startIndexSection().

◆ rtf_logoFilename

DString rtf_logoFilename

Definition at line 27 of file rtfstyle.cpp.

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

◆ rtf_manager

DString rtf_manager

Definition at line 29 of file rtfstyle.cpp.

Referenced by RTFGenerator::startIndexSection().

◆ rtf_Style

◆ rtf_Style_Default

Rtf_Style_Default rtf_Style_Default[]

Definition at line 88 of file rtfstyle.cpp.

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

◆ rtf_Style_Reset

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

Definition at line 49 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 24 of file rtfstyle.cpp.

Referenced by RTFGenerator::startIndexSection().

◆ rtf_Table_Default

Rtf_Table_Default rtf_Table_Default[]

Definition at line 245 of file rtfstyle.cpp.

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

◆ rtf_title

DString rtf_title

Definition at line 23 of file rtfstyle.cpp.

Referenced by RTFGenerator::endIndexSection().

◆ s_clause

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