43#define DBG_RTF(x) do {} while(0)
47 for (
const auto &attr : cell.
attribs())
49 if (attr.name.lower()==
"align")
51 if (attr.value.lower()==
"center")
return "\\qc ";
52 else if (attr.value.lower()==
"right")
return "\\qr ";
60 const DString &langExt,
int hierarchyLevel)
95 err(
"Maximum indent level ({}) exceeded while generating RTF output!\n",
maxIndentLevels-1);
111 DBG_RTF(
"{\\comment RTFDocVisitor::visit(DocWord)}\n");
119 DBG_RTF(
"{\\comment RTFDocVisitor::visit(DocLinkedWord)}\n");
129 DBG_RTF(
"{\\comment RTFDocVisitor::visit(DocWhiteSpace)}\n");
144 DBG_RTF(
"{\\comment RTFDocVisitor::visit(DocSymbol)}\n");
160 DBG_RTF(
"{\\comment RTFDocVisitor::visit(DocEmoji)}\n");
171 case '&':
case '#':
case 'x':
175 val = 0xd800 + ( ( val1 - 0x10000 ) & 0xffc00 ) / 0x400 - 0x10000;
176 m_t <<
"\\u" << val <<
"?";
177 val = 0xdC00 + ( ( val1 - 0x10000 ) & 0x3ff ) - 0x10000 ;
178 m_t <<
"\\u" << val <<
"?";
181 case '0':
case '1':
case '2':
case '3':
case '4':
182 case '5':
case '6':
case '7':
case '8':
case '9':
183 val = val * 16 + *p -
'0';
185 case 'a':
case 'b':
case 'c':
case 'd':
case 'e':
case 'f':
186 val = val * 16 + *p -
'a' + 10;
202 DBG_RTF(
"{\\comment RTFDocVisitor::visit(DocURL)}\n");
232 DBG_RTF(
"{\\comment RTFDocVisitor::visit(DocLineBreak)}\n");
240 DBG_RTF(
"{\\comment RTFDocVisitor::visit(DocHorRuler)}\n");
241 m_t <<
"{\\pard\\widctlpar\\brdrb\\brdrs\\brdrw5\\brsp20 \\adjustright \\par}\n";
249 DBG_RTF(
"{\\comment RTFDocVisitor::visit(DocStyleChange)}\n");
311 DBG_RTF(
"{\\comment RTFDocVisitor::visit(DocVerbatim)}\n");
365 if (!fileName.empty())
378 "msc {"+s.
text()+
"}",
380 if (!fileName.empty())
395 for (
const auto &baseName: baseNameVector)
404 if (
Config_getBool(MERMAID_RENDER_MODE)!=MERMAID_RENDER_MODE_t::CLIENT_SIDE)
424 DBG_RTF(
"{\\comment RTFDocVisitor::visit(DocAnchor)}\n");
447 DBG_RTF(
"{\\comment RTFDocVisitor::visit(DocInclude)}\n");
527 DBG_RTF(
"{\\comment RTFDocVisitor::visit(DocIncOperator)}\n");
547 std::unique_ptr<FileDef> fd =
nullptr;
586 DBG_RTF(
"{\\comment RTFDocVisitor::visit(DocFormula)}\n");
592 m_t <<
"\\pard\\plain";
596 m_t <<
"{ \\field\\flddirty {\\*\\fldinst INCLUDEPICTURE \"" << f.
relPath() << f.
name() <<
".png\" \\\\d \\\\*MERGEFORMAT}{\\fldrslt Image}}";
607 DBG_RTF(
"{\\comment RTFDocVisitor::visit(DocIndexEntry)}\n");
608 m_t <<
"{\\xe \\v " << i.
entry() <<
"}\n";
619 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocCite &)}\n");
632 if (!opt.noPar())
filter(
"[");
634 if (!opt.noPar())
filter(
"]");
647 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocAutoList &)}\n");
664 static int prevLevel = -1;
666 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocAutoListItem &)}\n");
668 if ((level != prevLevel-1) &&
669 (!(level==prevLevel && level != 0 &&
m_listItemInfo[level].isCheck)) &&
705 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocPara &)}\n");
710 std::get_if<DocParamSect>(p.
parent())
722 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocRoot &)}\n");
724 m_t <<
"{" <<
rtf_Style[
"BodyText"].reference() <<
"\n";
735 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocSimpleSect &)}\n");
739 m_t <<
"{" <<
rtf_Style[
"Heading5"].reference() <<
"\n";
785 m_t <<
"{\\s17 \\sa60 \\sb30\n";
791 std::visit(*
this,*s.
title());
811 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocTitle &)}\n");
819 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocSimpleSect &)}\n");
833 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocSimpleListItem &)}\n");
842 DBG_RTF(
"{\\comment RTFDocVisitor::visitPost(DocSimpleListItem)}\n");
848 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocSection &)}\n");
858 heading.
sprintf(
"Heading%d",level);
864 std::visit(*
this,*s.
title());
866 m_t <<
"\n\\par" <<
"}\n";
867 m_t <<
"{\\tc\\tcl" << level <<
" \\v ";
870 std::visit(*
this,*s.
title());
882 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocHtmlList &)}\n");
889 for (
const auto &opt : l.
attribs())
891 if (opt.name==
"type")
895 if (opt.name==
"start")
898 int val = opt.value.toInt(&ok);
904 m_t <<
"\\par" <<
"}\n";
911 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocHtmlListItem &)}\n");
917 for (
const auto &opt : l.
attribs())
919 if (opt.name==
"value")
922 int val = opt.value.toInt(&ok);
959 DBG_RTF(
"{\\comment RTFDocVisitor::visitPost(DocHtmlListItem)}\n");
965 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocHtmlDescList &)}\n");
978 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocHtmlDescTitle &)}\n");
981 m_t <<
"{" <<
rtf_Style[
"Heading5"].reference() <<
"\n";
992 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocHtmlDescData &)}\n");
1005 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocHtmlTable &)}\n");
1011 m_t <<
"\\pard \\qc \\b";
1017 m_t <<
"{Table \\field\\flddirty{\\*\\fldinst { SEQ Table \\\\*Arabic }}{\\fldrslt {\\noproof 1}} ";
1018 std::visit(*
this,*t.
caption());
1021 m_t <<
"\\pard\\plain\n";
1028 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocHtmlCaption &)}\n");
1030 m_t <<
"}\n\\par\n";
1036 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocHtmlRow &)}\n");
1038 m_t <<
"\\trowd \\trgaph108\\trleft-108"
1039 "\\trbrdrt\\brdrs\\brdrw10 "
1040 "\\trbrdrl\\brdrs\\brdrw10 "
1041 "\\trbrdrb\\brdrs\\brdrw10 "
1042 "\\trbrdrr\\brdrs\\brdrw10 "
1043 "\\trbrdrh\\brdrs\\brdrw10 "
1044 "\\trbrdrv\\brdrs\\brdrw10 \n";
1045 for (
size_t i=0;i<r.
numCells();i++)
1049 m_t <<
"\\clcbpat16";
1051 m_t <<
"\\clvertalt\\clbrdrt\\brdrs\\brdrw10 "
1052 "\\clbrdrl\\brdrs\\brdrw10 "
1053 "\\clbrdrb\\brdrs\\brdrw10 "
1054 "\\clbrdrr \\brdrs\\brdrw10 "
1056 "\\cellx" << ((i+1)*columnWidth) <<
"\n";
1058 m_t <<
"\\pard \\widctlpar\\intbl\\adjustright\n";
1062 m_t <<
"\\pard \\widctlpar\\intbl\\adjustright\n";
1063 m_t <<
"{\\row }\n";
1070 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocHtmlCell &)}\n");
1087 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocHRef &)}\n");
1101 "{\\cs37\\ul\\cf2 ";
1107 "{ HYPERLINK \"" << href.
url() <<
"\" "
1111 "{\\cs37\\ul\\cf2 ";
1144 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocHtmlDetails &)}\n");
1149 std::visit(*
this,*summary);
1167 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocHtmlHeader &)}\n");
1172 heading.
sprintf(
"Heading%d",level);
1176 m_t <<
"{\\tc\\tcl" << level <<
" ";
1195 m_t <<
"\\pard \\qc ";
1197 m_t <<
"{ \\field\\flddirty {\\*\\fldinst INCLUDEPICTURE \"";
1199 m_t <<
"\" \\\\d \\\\*MERGEFORMAT}{\\fldrslt Image}}\n";
1205 m_t <<
"\\pard \\qc \\b";
1206 m_t <<
"{Image \\field\\flddirty{\\*\\fldinst { SEQ Image \\\\*Arabic }}{\\fldrslt {\\noproof 1}} ";
1212 if (hasCaption)
m_t <<
"{\\comment ";
1229 if (hasCaption)
m_t <<
" }";
1252 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocImage &)}\n");
1261 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocDotFile &)}\n");
1262 bool exists =
false;
1270 if (!fileName.empty())
1280 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocMscFile &)}\n");
1281 bool exists =
false;
1289 if (!fileName.empty())
1300 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocDiaFile &)}\n");
1301 bool exists =
false;
1309 if (!fileName.empty())
1320 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocPlantUmlFile &)}\n");
1328 for(
const auto &baseName: baseNameVector)
1338 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocMermaidFile &)}\n");
1339 if (
Config_getBool(MERMAID_RENDER_MODE)==MERMAID_RENDER_MODE_t::CLIENT_SIDE)
return;
1347 rtfOutput,
DString(),inBuf,imageFormat,
1357 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocLink &)}\n");
1366 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocRef &)}\n");
1386 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocSecRefItem &)}\n");
1393 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocSecRefList &)}\n");
1409 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocParamSect &)}\n");
1413 m_t <<
"{" <<
rtf_Style[
"Heading5"].reference() <<
"\n";
1455 static int columnPos[4][5] =
1456 { { 2, 25, 100, 100, 100 },
1457 { 3, 14, 35, 100, 100 },
1458 { 3, 25, 50, 100, 100 },
1459 { 4, 14, 35, 55, 100 },
1463 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocParamList &)}\n");
1469 parentType = sect->
type();
1479 m_t <<
"\\trowd \\trgaph108\\trleft426\\tblind426"
1480 "\\trbrdrt\\brdrs\\brdrw10\\brdrcf15 "
1481 "\\trbrdrl\\brdrs\\brdrw10\\brdrcf15 "
1482 "\\trbrdrb\\brdrs\\brdrw10\\brdrcf15 "
1483 "\\trbrdrr\\brdrs\\brdrw10\\brdrcf15 "
1484 "\\trbrdrh\\brdrs\\brdrw10\\brdrcf15 "
1485 "\\trbrdrv\\brdrs\\brdrw10\\brdrcf15 "<<
"\n";
1486 for (
int i=0;i<columnPos[config][0];i++)
1488 m_t <<
"\\clvertalt\\clbrdrt\\brdrs\\brdrw10\\brdrcf15 "
1489 "\\clbrdrl\\brdrs\\brdrw10\\brdrcf15 "
1490 "\\clbrdrb\\brdrs\\brdrw10\\brdrcf15 "
1491 "\\clbrdrr \\brdrs\\brdrw10\\brdrcf15 "
1493 "\\cellx" << (
rtf_pageWidth*columnPos[config][i+1]/100) <<
"\n";
1495 m_t <<
"\\pard \\widctlpar\\intbl\\adjustright\n";
1536 std::visit(*
this,type);
1554 if (!first)
m_t <<
",";
else first=
false;
1555 std::visit(*
this,param);
1567 std::visit(*
this,par);
1572 m_t <<
"\\cell }\n";
1574 m_t <<
"{\\row }\n";
1588 bool anonymousEnum = x.
file()==
"@";
1589 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocXRefItem &)}\n");
1597 m_t <<
"{" <<
rtf_Style[
"Heading5"].reference() <<
"\n";
1620 "{\\cs37\\ul\\cf2 ";
1638 DBG_RTF(
"{\\comment RTFDocVisitor::visitPost(DocXRefItem)}\n");
1648 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocInternalRef &)}\n");
1658 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocText &)}\n");
1665 DBG_RTF(
"{\\comment RTFDocVisitor::operator()(const DocHtmlBlockQuote &)}\n");
1699 const char *p=str.
data();
1705 case '{':
m_t <<
"\\{";
break;
1706 case '}':
m_t <<
"\\}";
break;
1707 case '\\':
m_t <<
"\\\\";
break;
1709 if (!citeEntry) {
m_t << c;
break;}
1712 case '\n':
if (verbatim)
1740 if (!anchor.
empty())
1745 m_t <<
"{\\field {\\*\\fldinst { HYPERLINK \\\\l \"";
1748 m_t <<
"}{\\fldrslt {\\cs37\\ul\\cf2 ";
1771 const DString &srcFile,
int srcLine,
bool newFile)
1781 const DString &srcFile,
int srcLine,
bool newFile)
1790 const DString &srcFile,
int srcLine,
bool newFile)
1808 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...
DString & setNum(short n)
bool empty() const
Returns true iff the string is empty (std::string compatible alias for isEmpty()).
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
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 integerToRoman(int n, bool upper)
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)
const char * writeHtmlEntity(T &result, const char *s, HtmlEntityMapperFunc &&mapper, const char *fallback)
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 integerToAlpha(int n, bool upper)
DString getDotImageExtension()
DString makeBaseName(const DString &name, const DString &ext)
DString stripPath(const DString &s)
DString writeFileContents(const DString &baseName, const DString &extension, const DString &content, bool &exists)
Thread-safe function to write a string to a file.
SrcLangExt getLanguageFromCodeLang(DString &fileName)
Routine to handle the language attribute of the \code command.
A bunch of utility functions.