Doxygen
Loading...
Searching...
No Matches
latexdocvisitor.cpp File Reference
#include "latexdocvisitor.h"
#include <algorithm>
#include <array>
#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 int g_maxLevels = 7
static const std::array< const char *, g_maxLevelsg_secLabels
static const char * g_paragraphLabel = "doxyparagraph"
static const char * g_subparagraphLabel = "doxysubparagraph"

Function Documentation

◆ classEqualsReflist()

bool classEqualsReflist ( const DocHtmlDescList & dl)
static

Definition at line 1127 of file latexdocvisitor.cpp.

1128{
1129 HtmlAttribList attrs = dl.attribs();
1130 auto it = std::find_if(attrs.begin(),attrs.end(),
1131 [](const auto &att) { return att.name=="class"; });
1132 if (it!=attrs.end() && it->value == "reflist") return true;
1133 return false;
1134}
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 93 of file latexdocvisitor.cpp.

94{
95 // dimensions for latex images can be a percentage, in this case they need some extra
96 // handling as the % symbol is used for comments
97 static const reg::Ex re(R"((\d+)%)");
98 std::string s = dimension.str();
100 if (reg::search(s,match,re))
101 {
102 bool ok = false;
103 double percent = DString(match[1].str()).toInt(&ok);
104 if (ok)
105 {
106 t << percent/100.0 << "\\text" << orientationString;
107 return;
108 }
109 }
110 t << dimension;
111}
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:154
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 1136 of file latexdocvisitor.cpp.

1137{
1138 bool isNested=false;
1139 const DocNodeVariant *n = dl.parent();
1140 while (n && !isNested)
1141 {
1142 if (std::get_if<DocHtmlDescList>(n))
1143 {
1144 isNested = !classEqualsReflist(std::get<DocHtmlDescList>(*n));
1145 }
1146 n = ::parent(n);
1147 }
1148 return isNested;
1149}
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 192 of file latexdocvisitor.cpp.

193{
194 if (inlineImage)
195 {
196 t << "%\n\\end{DoxyInlineImage}\n";
197 }
198 else
199 {
200 t << "}%\n"; // end doxymbox or caption
201 if (hasCaption)
202 {
203 t << "\\end{DoxyImage}\n";
204 }
205 else
206 {
207 t << "\\end{DoxyImageNoCaption}\n";
208 }
209 }
210}

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 113 of file latexdocvisitor.cpp.

114{
115 if (inlineImage)
116 {
117 t << "\n\\begin{DoxyInlineImage}%\n";
118 }
119 else
120 {
121 if (hasCaption)
122 {
123 t << "\n\\begin{DoxyImage}%\n";
124 }
125 else
126 {
127 t << "\n\\begin{DoxyImageNoCaption}%\n"
128 " \\doxymbox{";
129 }
130 }
131
132 t << "\\includegraphics";
133 if (!width.empty() || !height.empty())
134 {
135 t << "[";
136 }
137 if (!width.empty())
138 {
139 t << "width=";
140 insertDimension(t, width, "width");
141 }
142 if (!width.empty() && !height.empty())
143 {
144 t << ",";
145 }
146 if (!height.empty())
147 {
148 t << "height=";
149 insertDimension(t, height, "height");
150 }
151 if (width.empty() && height.empty())
152 {
153 /* default setting */
154 if (inlineImage)
155 {
156 t << "[height=\\baselineskip,keepaspectratio=true]";
157 }
158 else
159 {
160 t << "[width=\\textwidth,height=\\textheight/2,keepaspectratio=true]";
161 }
162 }
163 else
164 {
165 t << "]";
166 }
167
168 t << "{" << name << "}";
169
170 if (hasCaption)
171 {
172 if (!inlineImage)
173 {
174 if (Config_getBool(PDF_HYPERLINKS))
175 {
176 t << "%\n\\doxyfigcaption{";
177 }
178 else
179 {
180 t << "%\n\\doxyfigcaptionnolink{";
181 }
182 }
183 else
184 {
185 t << "%"; // to catch the caption
186 }
187 }
188}
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)

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_maxLevels

const int g_maxLevels = 7
static

Definition at line 48 of file latexdocvisitor.cpp.

Referenced by LatexDocVisitor::getSectionName().

◆ g_paragraphLabel

const char* g_paragraphLabel = "doxyparagraph"
static

Definition at line 59 of file latexdocvisitor.cpp.

Referenced by LatexDocVisitor::getSectionName().

◆ g_secLabels

const std::array<const char *,g_maxLevels> g_secLabels
static
Initial value:
=
{ "doxysection",
"doxysubsection",
"doxysubsubsection",
"doxysubsubsubsection",
"doxysubsubsubsubsection",
"doxysubsubsubsubsubsection",
"doxysubsubsubsubsubsubsection"
}

Definition at line 49 of file latexdocvisitor.cpp.

Referenced by LatexDocVisitor::getSectionName().

◆ g_subparagraphLabel

const char* g_subparagraphLabel = "doxysubparagraph"
static

Definition at line 60 of file latexdocvisitor.cpp.

Referenced by LatexDocVisitor::getSectionName().