Doxygen
Loading...
Searching...
No Matches
latexdocvisitor.cpp File Reference
#include "latexdocvisitor.h"
#include <algorithm>
#include "cite.h"
#include "codefragment.h"
#include "config.h"
#include "dia.h"
#include "docparser.h"
#include "dot.h"
#include "doxygen.h"
#include "emoji.h"
#include "filedef.h"
#include "fileinfo.h"
#include "htmlattrib.h"
#include "htmlentity.h"
#include "language.h"
#include "latexgen.h"
#include "mermaid.h"
#include "message.h"
#include "msc.h"
#include "outputlist.h"
#include "parserintf.h"
#include "plantuml.h"
#include "portable.h"
#include "regex.h"
#include "util.h"
Include dependency graph for latexdocvisitor.cpp:

Go to the source code of this file.

Functions

static void insertDimension (TextStream &t, DString dimension, const char *orientationString)
static void visitPreStart (TextStream &t, bool hasCaption, DString name, DString width, DString height, bool inlineImage=false)
static void visitPostEnd (TextStream &t, bool hasCaption, bool inlineImage=false)
static bool classEqualsReflist (const DocHtmlDescList &dl)
static bool listIsNested (const DocHtmlDescList &dl)

Variables

static const char * g_paragraphLabel = "doxyparagraph"
static const char * g_subparagraphLabel = "doxysubparagraph"

Function Documentation

◆ classEqualsReflist()

bool classEqualsReflist ( const DocHtmlDescList & dl)
static

Definition at line 1111 of file latexdocvisitor.cpp.

1112{
1113 HtmlAttribList attrs = dl.attribs();
1114 auto it = std::find_if(attrs.begin(),attrs.end(),
1115 [](const auto &att) { return att.name=="class"; });
1116 if (it!=attrs.end() && it->value == "reflist") return true;
1117 return false;
1118}
const HtmlAttribList & attribs() const
Definition docnode.h:914
Class representing a list of HTML attributes.
Definition htmlattrib.h:31

References DocHtmlDescList::attribs().

Referenced by listIsNested(), and LatexDocVisitor::operator()().

◆ insertDimension()

void insertDimension ( TextStream & t,
DString dimension,
const char * orientationString )
static

Definition at line 72 of file latexdocvisitor.cpp.

73{
74 // dimensions for latex images can be a percentage, in this case they need some extra
75 // handling as the % symbol is used for comments
76 static const reg::Ex re(R"((\d+)%)");
77 std::string s = dimension.str();
79 if (reg::search(s,match,re))
80 {
81 bool ok = false;
82 double percent = DString(match[1].str()).toInt(&ok);
83 if (ok)
84 {
85 t << percent/100.0 << "\\text" << orientationString;
86 return;
87 }
88 }
89 t << dimension;
90}
A String class for use with Doxygen wrapping std::string and adding some additional functionality off...
Definition dstring.h:84
int toInt(bool *ok=nullptr, int base=10) const
Definition dstring.cpp:191
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:160
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

References reg::search(), DString::str(), and DString::toInt().

Referenced by visitPreStart().

◆ listIsNested()

bool listIsNested ( const DocHtmlDescList & dl)
static

Definition at line 1120 of file latexdocvisitor.cpp.

1121{
1122 bool isNested=false;
1123 const DocNodeVariant *n = dl.parent();
1124 while (n && !isNested)
1125 {
1126 if (std::get_if<DocHtmlDescList>(n))
1127 {
1128 isNested = !classEqualsReflist(std::get<DocHtmlDescList>(*n));
1129 }
1130 n = ::parent(n);
1131 }
1132 return isNested;
1133}
DocNodeVariant * parent()
Definition docnode.h:89
std::variant< DocWord, DocLinkedWord, DocURL, DocLineBreak, DocHorRuler, DocAnchor, DocCite, DocStyleChange, DocSymbol, DocEmoji, DocWhiteSpace, DocSeparator, DocVerbatim, DocInclude, DocIncOperator, DocFormula, DocIndexEntry, DocAutoList, DocAutoListItem, DocTitle, DocXRefItem, DocImage, DocDotFile, DocMscFile, DocDiaFile, DocVhdlFlow, DocLink, DocRef, DocInternalRef, DocHRef, DocHtmlHeader, DocHtmlDescTitle, DocHtmlDescList, DocSection, DocSecRefItem, DocSecRefList, DocInternal, DocParBlock, DocSimpleList, DocHtmlList, DocSimpleSect, DocSimpleSectSep, DocParamSect, DocPara, DocParamList, DocSimpleListItem, DocHtmlListItem, DocHtmlDescData, DocHtmlCell, DocHtmlCaption, DocHtmlRow, DocHtmlTable, DocHtmlBlockQuote, DocText, DocRoot, DocHtmlDetails, DocHtmlSummary, DocPlantUmlFile, DocMermaidFile > DocNodeVariant
Definition docnode.h:66
constexpr DocNodeVariant * parent(DocNodeVariant *n)
returns the parent node of a given node n or nullptr if the node has no parent.
Definition docnode.h:1335
static bool classEqualsReflist(const DocHtmlDescList &dl)

References classEqualsReflist(), DocNode::parent(), and parent().

Referenced by LatexDocVisitor::operator()().

◆ visitPostEnd()

void visitPostEnd ( TextStream & t,
bool hasCaption,
bool inlineImage = false )
static

Definition at line 171 of file latexdocvisitor.cpp.

172{
173 if (inlineImage)
174 {
175 t << "%\n\\end{DoxyInlineImage}\n";
176 }
177 else
178 {
179 t << "}%\n"; // end doxymbox or caption
180 if (hasCaption)
181 {
182 t << "\\end{DoxyImage}\n";
183 }
184 else
185 {
186 t << "\\end{DoxyImageNoCaption}\n";
187 }
188 }
189}

Referenced by LatexDocVisitor::endDiaFile(), LatexDocVisitor::endDotFile(), LatexDocVisitor::endMermaidFile(), LatexDocVisitor::endMscFile(), LatexDocVisitor::endPlantUmlFile(), LatexDocVisitor::operator()(), LatexDocVisitor::writeMermaidFile(), LatexDocVisitor::writeMscFile(), and LatexDocVisitor::writePlantUMLFile().

◆ visitPreStart()

void visitPreStart ( TextStream & t,
bool hasCaption,
DString name,
DString width,
DString height,
bool inlineImage = false )
static

Definition at line 92 of file latexdocvisitor.cpp.

93{
94 if (inlineImage)
95 {
96 t << "\n\\begin{DoxyInlineImage}%\n";
97 }
98 else
99 {
100 if (hasCaption)
101 {
102 t << "\n\\begin{DoxyImage}%\n";
103 }
104 else
105 {
106 t << "\n\\begin{DoxyImageNoCaption}%\n"
107 " \\doxymbox{";
108 }
109 }
110
111 t << "\\includegraphics";
112 if (!width.empty() || !height.empty())
113 {
114 t << "[";
115 }
116 if (!width.empty())
117 {
118 t << "width=";
119 insertDimension(t, width, "width");
120 }
121 if (!width.empty() && !height.empty())
122 {
123 t << ",";
124 }
125 if (!height.empty())
126 {
127 t << "height=";
128 insertDimension(t, height, "height");
129 }
130 if (width.empty() && height.empty())
131 {
132 /* default setting */
133 if (inlineImage)
134 {
135 t << "[height=\\baselineskip,keepaspectratio=true]";
136 }
137 else
138 {
139 t << "[width=\\textwidth,height=\\textheight/2,keepaspectratio=true]";
140 }
141 }
142 else
143 {
144 t << "]";
145 }
146
147 t << "{" << name << "}";
148
149 if (hasCaption)
150 {
151 if (!inlineImage)
152 {
153 if (Config_getBool(PDF_HYPERLINKS))
154 {
155 t << "%\n\\doxyfigcaption{";
156 }
157 else
158 {
159 t << "%\n\\doxyfigcaptionnolink{";
160 }
161 }
162 else
163 {
164 t << "%"; // to catch the caption
165 }
166 }
167}
bool empty() const
Returns true iff the string is empty (std::string compatible alias for isEmpty()).
Definition dstring.h:148
#define Config_getBool(name)
Definition config.h:33
static void insertDimension(TextStream &t, DString dimension, const char *orientationString)
const char * name(int level)
Definition latexgen.h:368

References Config_getBool, DString::empty(), and insertDimension().

Referenced by LatexDocVisitor::operator()(), LatexDocVisitor::startDiaFile(), LatexDocVisitor::startDotFile(), LatexDocVisitor::startMermaidFile(), LatexDocVisitor::startMscFile(), LatexDocVisitor::startPlantUmlFile(), LatexDocVisitor::writeMermaidFile(), LatexDocVisitor::writeMscFile(), and LatexDocVisitor::writePlantUMLFile().

Variable Documentation

◆ g_paragraphLabel

const char* g_paragraphLabel = "doxyparagraph"
static

Definition at line 47 of file latexdocvisitor.cpp.

Referenced by LatexDocVisitor::getSectionName().

◆ g_subparagraphLabel

const char* g_subparagraphLabel = "doxysubparagraph"
static

Definition at line 48 of file latexdocvisitor.cpp.

Referenced by LatexDocVisitor::getSectionName().