Doxygen
Loading...
Searching...
No Matches
latexdocvisitor.cpp File Reference
#include <algorithm>
#include <array>
#include "htmlattrib.h"
#include "latexdocvisitor.h"
#include "latexgen.h"
#include "docparser.h"
#include "language.h"
#include "doxygen.h"
#include "outputgen.h"
#include "outputlist.h"
#include "dot.h"
#include "util.h"
#include "message.h"
#include "parserintf.h"
#include "msc.h"
#include "dia.h"
#include "cite.h"
#include "filedef.h"
#include "config.h"
#include "htmlentity.h"
#include "emoji.h"
#include "plantuml.h"
#include "mermaid.h"
#include "fileinfo.h"
#include "regex.h"
#include "portable.h"
#include "codefragment.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 1120 of file latexdocvisitor.cpp.

1121{
1122 HtmlAttribList attrs = dl.attribs();
1123 auto it = std::find_if(attrs.begin(),attrs.end(),
1124 [](const auto &att) { return att.name=="class"; });
1125 if (it!=attrs.end() && it->value == "reflist") return true;
1126 return false;
1127}
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 90 of file latexdocvisitor.cpp.

91{
92 // dimensions for latex images can be a percentage, in this case they need some extra
93 // handling as the % symbol is used for comments
94 static const reg::Ex re(R"((\d+)%)");
95 std::string s = dimension.str();
97 if (reg::search(s,match,re))
98 {
99 bool ok = false;
100 double percent = DString(match[1].str()).toInt(&ok);
101 if (ok)
102 {
103 t << percent/100.0 << "\\text" << orientationString;
104 return;
105 }
106 }
107 t << dimension;
108}
A String class for use with Doxygen wrapping std::string and adding some additional functionality off...
Definition dstring.h:88
int toInt(bool *ok=nullptr, int base=10) const
Definition dstring.cpp:187
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
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

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

Referenced by visitPreStart().

◆ listIsNested()

bool listIsNested ( const DocHtmlDescList & dl)
static

Definition at line 1129 of file latexdocvisitor.cpp.

1130{
1131 bool isNested=false;
1132 const DocNodeVariant *n = dl.parent();
1133 while (n && !isNested)
1134 {
1135 if (std::get_if<DocHtmlDescList>(n))
1136 {
1137 isNested = !classEqualsReflist(std::get<DocHtmlDescList>(*n));
1138 }
1139 n = ::parent(n);
1140 }
1141 return isNested;
1142}
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 189 of file latexdocvisitor.cpp.

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

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

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

Referenced by LatexDocVisitor::getSectionName().

◆ g_paragraphLabel

const char* g_paragraphLabel = "doxyparagraph"
static

Definition at line 56 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 46 of file latexdocvisitor.cpp.

Referenced by LatexDocVisitor::getSectionName().

◆ g_subparagraphLabel

const char* g_subparagraphLabel = "doxysubparagraph"
static

Definition at line 57 of file latexdocvisitor.cpp.

Referenced by LatexDocVisitor::getSectionName().