47#define DBG_RTF(x) do {} while(0)
51 for (
const auto &attr : cell.
attribs())
53 if (attr.name.lower()==
"align")
55 if (attr.value.lower()==
"center")
return "\\qc ";
56 else if (attr.value.lower()==
"right")
return "\\qr ";
64 const DString &langExt,
int hierarchyLevel)
99 err(
"Maximum indent level ({}) exceeded while generating RTF output!\n",
maxIndentLevels-1);
115 DBG_RTF(
"{\\comment RTFDocVisitor::visit(DocWord)}\n");
123 DBG_RTF(
"{\\comment RTFDocVisitor::visit(DocLinkedWord)}\n");
133 DBG_RTF(
"{\\comment RTFDocVisitor::visit(DocWhiteSpace)}\n");
148 DBG_RTF(
"{\\comment RTFDocVisitor::visit(DocSymbol)}\n");
164 DBG_RTF(
"{\\comment RTFDocVisitor::visit(DocEmoji)}\n");
175 case '&':
case '#':
case 'x':
179 val = 0xd800 + ( ( val1 - 0x10000 ) & 0xffc00 ) / 0x400 - 0x10000;
180 m_t <<
"\\u" << val <<
"?";
181 val = 0xdC00 + ( ( val1 - 0x10000 ) & 0x3ff ) - 0x10000 ;
182 m_t <<
"\\u" << val <<
"?";
185 case '0':
case '1':
case '2':
case '3':
case '4':
186 case '5':
case '6':
case '7':
case '8':
case '9':
187 val = val * 16 + *p -
'0';
189 case 'a':
case 'b':
case 'c':
case 'd':
case 'e':
case 'f':
190 val = val * 16 + *p -
'a' + 10;
206 DBG_RTF(
"{\\comment RTFDocVisitor::visit(DocURL)}\n");
236 DBG_RTF(
"{\\comment RTFDocVisitor::visit(DocLineBreak)}\n");
244 DBG_RTF(
"{\\comment RTFDocVisitor::visit(DocHorRuler)}\n");
245 m_t <<
"{\\pard\\widctlpar\\brdrb\\brdrs\\brdrw5\\brsp20 \\adjustright \\par}\n";
253 DBG_RTF(
"{\\comment RTFDocVisitor::visit(DocStyleChange)}\n");
315 DBG_RTF(
"{\\comment RTFDocVisitor::visit(DocVerbatim)}\n");
369 if (!fileName.empty())
382 "msc {"+s.
text()+
"}",
384 if (!fileName.empty())
399 for (
const auto &baseName: baseNameVector)
408 if (
Config_getBool(MERMAID_RENDER_MODE)!=MERMAID_RENDER_MODE_t::CLIENT_SIDE)
428 DBG_RTF(
"{\\comment RTFDocVisitor::visit(DocAnchor)}\n");
451 DBG_RTF(
"{\\comment RTFDocVisitor::visit(DocInclude)}\n");
531 DBG_RTF(
"{\\comment RTFDocVisitor::visit(DocIncOperator)}\n");
551 std::unique_ptr<FileDef> fd =
nullptr;
590 DBG_RTF(
"{\\comment RTFDocVisitor::visit(DocFormula)}\n");
596 m_t <<
"\\pard\\plain";
600 m_t <<
"{ \\field\\flddirty {\\*\\fldinst INCLUDEPICTURE \"" << f.
relPath() << f.
name() <<
".png\" \\\\d \\\\*MERGEFORMAT}{\\fldrslt Image}}";
611 DBG_RTF(
"{\\comment RTFDocVisitor::visit(DocIndexEntry)}\n");
612 m_t <<
"{\\xe \\v " << i.
entry() <<
"}\n";
623 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocCite &)}\n");
636 if (!opt.noPar())
filter(
"[");
638 if (!opt.noPar())
filter(
"]");
651 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocAutoList &)}\n");
668 static int prevLevel = -1;
670 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocAutoListItem &)}\n");
672 if ((level != prevLevel-1) &&
673 (!(level==prevLevel && level != 0 &&
m_listItemInfo[level].isCheck)) &&
709 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocPara &)}\n");
714 std::get_if<DocParamSect>(p.
parent())
726 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocRoot &)}\n");
728 m_t <<
"{" <<
rtf_Style[
"BodyText"].reference() <<
"\n";
739 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocSimpleSect &)}\n");
743 m_t <<
"{" <<
rtf_Style[
"Heading5"].reference() <<
"\n";
789 m_t <<
"{\\s17 \\sa60 \\sb30\n";
795 std::visit(*
this,*s.
title());
815 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocTitle &)}\n");
823 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocSimpleSect &)}\n");
837 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocSimpleListItem &)}\n");
846 DBG_RTF(
"{\\comment RTFDocVisitor::visitPost(DocSimpleListItem)}\n");
852 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocSection &)}\n");
862 heading.
sprintf(
"Heading%d",level);
868 std::visit(*
this,*s.
title());
870 m_t <<
"\n\\par" <<
"}\n";
871 m_t <<
"{\\tc\\tcl" << level <<
" \\v ";
874 std::visit(*
this,*s.
title());
886 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocHtmlList &)}\n");
893 for (
const auto &opt : l.
attribs())
895 if (opt.name==
"type")
899 if (opt.name==
"start")
902 int val = opt.value.toInt(&ok);
908 m_t <<
"\\par" <<
"}\n";
915 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocHtmlListItem &)}\n");
921 for (
const auto &opt : l.
attribs())
923 if (opt.name==
"value")
926 int val = opt.value.toInt(&ok);
963 DBG_RTF(
"{\\comment RTFDocVisitor::visitPost(DocHtmlListItem)}\n");
969 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocHtmlDescList &)}\n");
982 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocHtmlDescTitle &)}\n");
985 m_t <<
"{" <<
rtf_Style[
"Heading5"].reference() <<
"\n";
996 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocHtmlDescData &)}\n");
1009 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocHtmlTable &)}\n");
1015 m_t <<
"\\pard \\qc \\b";
1021 m_t <<
"{Table \\field\\flddirty{\\*\\fldinst { SEQ Table \\\\*Arabic }}{\\fldrslt {\\noproof 1}} ";
1022 std::visit(*
this,*t.
caption());
1025 m_t <<
"\\pard\\plain\n";
1032 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocHtmlCaption &)}\n");
1034 m_t <<
"}\n\\par\n";
1040 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocHtmlRow &)}\n");
1042 m_t <<
"\\trowd \\trgaph108\\trleft-108"
1043 "\\trbrdrt\\brdrs\\brdrw10 "
1044 "\\trbrdrl\\brdrs\\brdrw10 "
1045 "\\trbrdrb\\brdrs\\brdrw10 "
1046 "\\trbrdrr\\brdrs\\brdrw10 "
1047 "\\trbrdrh\\brdrs\\brdrw10 "
1048 "\\trbrdrv\\brdrs\\brdrw10 \n";
1049 for (
size_t i=0;i<r.
numCells();i++)
1053 m_t <<
"\\clcbpat16";
1055 m_t <<
"\\clvertalt\\clbrdrt\\brdrs\\brdrw10 "
1056 "\\clbrdrl\\brdrs\\brdrw10 "
1057 "\\clbrdrb\\brdrs\\brdrw10 "
1058 "\\clbrdrr \\brdrs\\brdrw10 "
1060 "\\cellx" << ((i+1)*columnWidth) <<
"\n";
1062 m_t <<
"\\pard \\widctlpar\\intbl\\adjustright\n";
1066 m_t <<
"\\pard \\widctlpar\\intbl\\adjustright\n";
1067 m_t <<
"{\\row }\n";
1074 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocHtmlCell &)}\n");
1091 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocHRef &)}\n");
1105 "{\\cs37\\ul\\cf2 ";
1111 "{ HYPERLINK \"" << href.
url() <<
"\" "
1115 "{\\cs37\\ul\\cf2 ";
1148 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocHtmlDetails &)}\n");
1153 std::visit(*
this,*summary);
1171 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocHtmlHeader &)}\n");
1176 heading.
sprintf(
"Heading%d",level);
1180 m_t <<
"{\\tc\\tcl" << level <<
" ";
1199 m_t <<
"\\pard \\qc ";
1201 m_t <<
"{ \\field\\flddirty {\\*\\fldinst INCLUDEPICTURE \"";
1203 m_t <<
"\" \\\\d \\\\*MERGEFORMAT}{\\fldrslt Image}}\n";
1209 m_t <<
"\\pard \\qc \\b";
1210 m_t <<
"{Image \\field\\flddirty{\\*\\fldinst { SEQ Image \\\\*Arabic }}{\\fldrslt {\\noproof 1}} ";
1216 if (hasCaption)
m_t <<
"{\\comment ";
1233 if (hasCaption)
m_t <<
" }";
1256 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocImage &)}\n");
1265 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocDotFile &)}\n");
1266 bool exists =
false;
1274 if (!fileName.empty())
1284 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocMscFile &)}\n");
1285 bool exists =
false;
1293 if (!fileName.empty())
1304 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocDiaFile &)}\n");
1305 bool exists =
false;
1313 if (!fileName.empty())
1324 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocPlantUmlFile &)}\n");
1332 for(
const auto &baseName: baseNameVector)
1342 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocMermaidFile &)}\n");
1343 if (
Config_getBool(MERMAID_RENDER_MODE)==MERMAID_RENDER_MODE_t::CLIENT_SIDE)
return;
1351 rtfOutput,
DString(),inBuf,imageFormat,
1361 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocLink &)}\n");
1370 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocRef &)}\n");
1390 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocSecRefItem &)}\n");
1397 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocSecRefList &)}\n");
1413 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocParamSect &)}\n");
1417 m_t <<
"{" <<
rtf_Style[
"Heading5"].reference() <<
"\n";
1459 static int columnPos[4][5] =
1460 { { 2, 25, 100, 100, 100 },
1461 { 3, 14, 35, 100, 100 },
1462 { 3, 25, 50, 100, 100 },
1463 { 4, 14, 35, 55, 100 },
1467 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocParamList &)}\n");
1473 parentType = sect->
type();
1483 m_t <<
"\\trowd \\trgaph108\\trleft426\\tblind426"
1484 "\\trbrdrt\\brdrs\\brdrw10\\brdrcf15 "
1485 "\\trbrdrl\\brdrs\\brdrw10\\brdrcf15 "
1486 "\\trbrdrb\\brdrs\\brdrw10\\brdrcf15 "
1487 "\\trbrdrr\\brdrs\\brdrw10\\brdrcf15 "
1488 "\\trbrdrh\\brdrs\\brdrw10\\brdrcf15 "
1489 "\\trbrdrv\\brdrs\\brdrw10\\brdrcf15 "<<
"\n";
1490 for (
int i=0;i<columnPos[config][0];i++)
1492 m_t <<
"\\clvertalt\\clbrdrt\\brdrs\\brdrw10\\brdrcf15 "
1493 "\\clbrdrl\\brdrs\\brdrw10\\brdrcf15 "
1494 "\\clbrdrb\\brdrs\\brdrw10\\brdrcf15 "
1495 "\\clbrdrr \\brdrs\\brdrw10\\brdrcf15 "
1497 "\\cellx" << (
rtf_pageWidth*columnPos[config][i+1]/100) <<
"\n";
1499 m_t <<
"\\pard \\widctlpar\\intbl\\adjustright\n";
1540 std::visit(*
this,type);
1558 if (!first)
m_t <<
",";
else first=
false;
1559 std::visit(*
this,param);
1571 std::visit(*
this,par);
1576 m_t <<
"\\cell }\n";
1578 m_t <<
"{\\row }\n";
1592 bool anonymousEnum = x.
file()==
"@";
1593 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocXRefItem &)}\n");
1601 m_t <<
"{" <<
rtf_Style[
"Heading5"].reference() <<
"\n";
1624 "{\\cs37\\ul\\cf2 ";
1642 DBG_RTF(
"{\\comment RTFDocVisitor::visitPost(DocXRefItem)}\n");
1652 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocInternalRef &)}\n");
1662 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocText &)}\n");
1669 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocHtmlBlockQuote &)}\n");
1703 const char *p=str.
data();
1709 case '{':
m_t <<
"\\{";
break;
1710 case '}':
m_t <<
"\\}";
break;
1711 case '\\':
m_t <<
"\\\\";
break;
1713 if (!citeEntry) {
m_t << c;
break;}
1720 case '\n':
if (verbatim)
1748 if (!anchor.
empty())
1753 m_t <<
"{\\field {\\*\\fldinst { HYPERLINK \\\\l \"";
1756 m_t <<
"}{\\fldrslt {\\cs37\\ul\\cf2 ";
1779 const DString &srcFile,
int srcLine,
bool newFile)
1789 const DString &srcFile,
int srcLine,
bool newFile)
1798 const DString &srcFile,
int srcLine,
bool newFile)
1816 if (
Config_getBool(MERMAID_RENDER_MODE)==MERMAID_RENDER_MODE_t::CLIENT_SIDE)
return;
static CodeFragmentManager & instance()
void parseCodeFragment(OutputCodeList &codeOutList, const DString &fileName, const DString &blockId, const DString &scopeName, bool showLineNumbers, bool trimLeft, bool stripCodeComments)
virtual void parseCode(OutputCodeList &codeOutList, const DString &scopeName, const DString &input, SrcLangExt lang, bool stripCodeComments, const CodeParserOptions &options)=0
Parses a source file or fragment with the goal to produce highlighted and cross-referenced output.
A String class for use with Doxygen wrapping std::string and adding some additional functionality off...
static DString integerToAlpha(int n, bool upper=true)
DString & setNum(short n)
bool empty() const
Returns true iff the string is empty (std::string compatible alias for isEmpty()).
static DString integerToRoman(int n, bool upper=true)
DString right(size_t len) const
DString & sprintf(const char *format,...)
const std::string & str() const
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string.
bool startsWith(const char *s) const
size_t length() const
Returns the length of the string, not counting the 0-terminator.
Node representing an anchor.
Node representing an auto List.
bool isCheckedList() const
Node representing an item of a auto list.
Node representing a citation of some bibliographic reference.
CiteInfoOption option() const
Node representing a dia file.
Node representing a dot file.
Node representing an emoji.
Node representing a Hypertext reference.
Node representing a horizontal ruler.
Node representing an HTML blockquote.
Node representing a HTML table caption.
Node representing a HTML table cell.
const HtmlAttribList & attribs() const
Node representing a HTML description data.
Node representing a Html description list.
Node representing a Html description item.
const DocNodeVariant * summary() const
Node representing a Html list.
const HtmlAttribList & attribs() const
Node representing a HTML list item.
const HtmlAttribList & attribs() const
Node representing a HTML table row.
Node representing a HTML table.
const DocNodeVariant * caption() const
Node representing an image.
bool isInlineImage() const
Node representing a include/dontinclude operator block.
bool stripCodeComments() const
DString exampleFile() const
DString includeFileName() const
Node representing an included text block from file.
bool stripCodeComments() const
DString exampleFile() const
DString extension() const
Node representing an entry in the index.
Node representing an internal section of documentation.
Node representing an internal reference to some item.
Node representing a line break.
Node representing a link to some item.
Node representing a word that can be linked to something.
Node representing a mermaid file.
Node representing a msc file.
DocNodeVariant * parent()
Node representing an block of paragraphs.
Node representing a paragraph in the documentation tree.
Node representing a parameter list.
const DocNodeList & parameters() const
const DocNodeList & paramTypes() const
DocParamSect::Direction direction() const
const DocNodeList & paragraphs() const
Node representing a parameter section.
bool hasInOutSpecifier() const
bool hasTypeSpecifier() const
Node representing a uml file.
Node representing a reference to some item.
DString targetTitle() const
Root node of documentation tree.
Node representing a reference to a section.
Node representing a list of section references.
Node representing a normal section.
const DocNodeVariant * title() const
Node representing a separator.
Node representing a simple list.
Node representing a simple list item.
const DocNodeVariant * paragraph() const
Node representing a simple section.
const DocNodeVariant * title() const
Node representing a separator between two simple sections of the same type.
Node representing a style change.
Node representing a special symbol.
HtmlEntityMapper::SymType symbol() const
Root node of a text fragment.
Node representing a simple section title.
Node representing a URL (or email address).
Node representing a verbatim, unparsed text fragment.
DString exampleFile() const
Node representing a VHDL flow chart.
void pushHidden(bool hide)
CodeParserInterface & getCodeParser(const DString &langExt)
Node representing some amount of white space.
Node representing a word.
Node representing an item of a cross-referenced list.
const char * unicode(int index) const
Access routine to the unicode sequence for the Emoji entity.
static EmojiEntityMapper & instance()
Returns the one and only instance of the Emoji entity mapper.
Minimal replacement for QFileInfo.
std::string fileName() const
std::string dirPath(bool absPath=true) const
const char * writeHtmlEntity(T &result, const char *s, HtmlEntityMapperFunc &&mapper, const char *fallback)
static HtmlEntityMapper & instance()
Returns the one and only instance of the HTML entity mapper.
const char * rtf(SymType symb) const
Access routine to the RTF code of the HTML entity.
static MermaidManager & instance()
static DString imageExtension(ImageFormat imageFormat)
static ImageFormat convertToImageFormat(OutputFormat outputFormat)
void generateMermaidOutput(const DString &baseName, const DString &outDir, ImageFormat format, bool toIndex)
Register a generated Mermaid image with the index.
DString writeMermaidSource(const DString &outDirArg, const DString &fileName, const DString &content, ImageFormat format, const DString &srcFile, int srcLine)
Write a Mermaid source file and register it for CLI rendering.
Class representing a list of different code generators.
void generatePlantUMLOutput(const DString &baseName, const DString &outDir, OutputFormat format, bool toIndex)
Convert a PlantUML file to an image.
StringVector writePlantUMLSource(const DString &outDirArg, const DString &fileName, const DString &content, OutputFormat format, const DString &engine, const DString &srcFile, int srcLine, bool inlineCode)
Write a PlantUML compatible file.
static PlantumlManager & instance()
void writeDotFile(const DString &fileName, bool hasCaption, const DString &srcFile, int srcLine, bool newFile=true)
RTFDocVisitor(TextStream &t, OutputCodeList &ci, const DString &langExt, int hierarchyLevel=0)
void visitChildren(const T &t)
void writeMscFile(const DString &fileName, bool hasCaption, const DString &srcFile, int srcLine, bool newFile=true)
DString getListTable(const int id)
void writeDiaFile(const DString &fileName, bool hasCaption, const DString &srcFile, int srcLine, bool newFile=true)
void startLink(const DString &ref, const DString &file, const DString &anchor)
void includePicturePostRTF(bool isTypeRTF, bool hasCaption, bool inlineImage=false)
void writeMermaidFile(const DString &fileName, bool hasCaption)
DString getStyle(const DString &name)
void endLink(const DString &ref)
void includePicturePreRTF(const DString &name, bool isTypeRTF, bool hasCaption, bool inlineImage=false)
static const int maxIndentLevels
void writePlantUMLFile(const DString &fileName, bool hasCaption)
void filter(const DString &str, bool verbatim=false, const bool citeEntry=false)
RTFListItemInfo m_listItemInfo[maxIndentLevels]
void operator()(const DocWord &)
static constexpr int MaxLevel
static constexpr int MinLevel
Text streaming class that buffers data.
virtual DString trExceptions()=0
virtual DString trReturns()=0
virtual DString trParameters()=0
virtual DString trCopyright()=0
virtual DString trWarning()=0
virtual DString trSince()=0
virtual DString trNote()=0
virtual DString trAuthor(bool first_capital, bool singular)=0
virtual DString trReturnValues()=0
virtual DString trVersion()=0
virtual DString trTemplateParameters()=0
virtual DString trImportant()=0
virtual DString trPrecondition()=0
virtual DString trAttention()=0
virtual DString trInvariant()=0
virtual DString trRemarks()=0
virtual DString trDate()=0
virtual DString trSeeAlso()=0
virtual DString trPostcondition()=0
#define Config_getBool(name)
#define Config_getString(name)
void writeDiaGraphFromFile(const DString &inFile, const DString &outDir, const DString &outFile, DiaOutputFormat format, const DString &srcFile, int srcLine, bool toIndex)
void writeDotGraphFromFile(const DString &inFile, const DString &outDir, const DString &outFile, GraphOutputFormat format, const DString &srcFile, int srcLine, bool toIndex)
std::unique_ptr< FileDef > createFileDef(const DString &p, const DString &n, const DString &ref, const DString &dn)
Translator * theTranslator
void writeMscGraphFromFile(const DString &inFile, const DString &outDir, const DString &outFile, MscOutputFormat format, const DString &srcFile, int srcLine, bool toIndex)
Portable versions of functions that are platform dependent.
static DString align(const DocHtmlCell &cell)
DString rtfFormatBmkStr(const DString &name)
Rtf_Table_Default rtf_Table_Default[]
Options to configure the code parser.
CodeParserOptions & setStartLine(int lineNr)
CodeParserOptions & setInlineFragment(bool enable)
CodeParserOptions & setShowLineNumbers(bool enable)
CodeParserOptions & setFileDef(const FileDef *fd)
DString reference() const
DString writeInlineGraph(const DString &baseName, const DString &extension, const DString &content, bool &exists)
DString getFileNameExtension(const DString &fn)
bool readInputFile(const DString &fileName, std::string &contents, bool filter, bool isSourceCode)
read a file name fileName and optionally filter and transcode it
SrcLangExt getLanguageFromFileName(const DString &fileName, SrcLangExt defLang)
bool copyFile(const DString &src, const DString &dest)
Copies the contents of file with name src to the newly created file with name dest.
DString getDotImageExtension()
DString makeBaseName(const DString &name, const DString &ext)
DString stripPath(const DString &s)
SrcLangExt getLanguageFromCodeLang(DString &fileName)
Routine to handle the language attribute of the \code command.
A bunch of utility functions.