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 "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, QCString dimension, const char *orientationString)
static void visitPreStart (TextStream &t, bool hasCaption, QCString name, QCString width, QCString height, bool inlineImage=FALSE)
static void visitPostEnd (TextStream &t, bool hasCaption, bool inlineImage=FALSE)
static QCString makeShortName (const QCString &name)
static QCString makeBaseName (const QCString &name)
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 1177 of file latexdocvisitor.cpp.

1178{
1179 HtmlAttribList attrs = dl.attribs();
1180 auto it = std::find_if(attrs.begin(),attrs.end(),
1181 [](const auto &att) { return att.name=="class"; });
1182 if (it!=attrs.end() && it->value == "reflist") return true;
1183 return false;
1184}
const HtmlAttribList & attribs() const
Definition docnode.h:905
Class representing a list of HTML attributes.
Definition htmlattrib.h:33

References DocHtmlDescList::attribs().

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

◆ insertDimension()

void insertDimension ( TextStream & t,
QCString 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 = QCString(match[1].str()).toInt(&ok);
101 if (ok)
102 {
103 t << percent/100.0 << "\\text" << orientationString;
104 return;
105 }
106 }
107 t << dimension;
108}
This is an alternative implementation of QCString.
Definition qcstring.h:101
int toInt(bool *ok=nullptr, int base=10) const
Definition qcstring.cpp:249
const std::string & str() const
Definition qcstring.h:537
Class representing a regular expression.
Definition regex.h:39
Object representing the matching results.
Definition regex.h:153
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:748
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:759

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

Referenced by visitPreStart().

◆ listIsNested()

bool listIsNested ( const DocHtmlDescList & dl)
static

Definition at line 1186 of file latexdocvisitor.cpp.

1187{
1188 bool isNested=false;
1189 const DocNodeVariant *n = dl.parent();
1190 while (n && !isNested)
1191 {
1192 if (std::get_if<DocHtmlDescList>(n))
1193 {
1194 isNested = !classEqualsReflist(std::get<DocHtmlDescList>(*n));
1195 }
1196 n = ::parent(n);
1197 }
1198 return isNested;
1199}
DocNodeVariant * parent()
Definition docnode.h:90
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 > DocNodeVariant
Definition docnode.h:67
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:1330
static bool classEqualsReflist(const DocHtmlDescList &dl)

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

Referenced by LatexDocVisitor::operator()().

◆ makeBaseName()

QCString makeBaseName ( const QCString & name)
static

Definition at line 220 of file latexdocvisitor.cpp.

221{
222 QCString baseName = makeShortName(name);
223 int i=baseName.find('.');
224 if (i!=-1)
225 {
226 baseName=baseName.left(i);
227 }
228 return baseName;
229}
int find(char c, int index=0, bool cs=TRUE) const
Definition qcstring.cpp:43
QCString left(size_t len) const
Definition qcstring.h:214
static QCString makeShortName(const QCString &name)

References QCString::find(), QCString::left(), and makeShortName().

◆ makeShortName()

QCString makeShortName ( const QCString & name)
static

Definition at line 209 of file latexdocvisitor.cpp.

210{
211 QCString shortName = name;
212 int i = shortName.findRev('/');
213 if (i!=-1)
214 {
215 shortName=shortName.mid(i+1);
216 }
217 return shortName;
218}
QCString mid(size_t index, size_t len=static_cast< size_t >(-1)) const
Definition qcstring.h:226
int findRev(char c, int index=-1, bool cs=TRUE) const
Definition qcstring.cpp:91

References QCString::findRev(), and QCString::mid().

Referenced by makeBaseName().

◆ 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 mbox or caption
198 if (hasCaption)
199 {
200 t << "\\end{DoxyImage}\n";
201 }
202 else
203 {
204 t << "\\end{DoxyImageNoCaption}\n";
205 }
206 }
207}

References FALSE.

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

◆ visitPreStart()

void visitPreStart ( TextStream & t,
bool hasCaption,
QCString name,
QCString width,
QCString 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 " \\mbox{";
126 }
127 }
128
129 t << "\\includegraphics";
130 if (!width.isEmpty() || !height.isEmpty())
131 {
132 t << "[";
133 }
134 if (!width.isEmpty())
135 {
136 t << "width=";
137 insertDimension(t, width, "width");
138 }
139 if (!width.isEmpty() && !height.isEmpty())
140 {
141 t << ",";
142 }
143 if (!height.isEmpty())
144 {
145 t << "height=";
146 insertDimension(t, height, "height");
147 }
148 if (width.isEmpty() && height.isEmpty())
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 isEmpty() const
Returns TRUE iff the string is empty.
Definition qcstring.h:150
#define Config_getBool(name)
Definition config.h:33
static void insertDimension(TextStream &t, QCString dimension, const char *orientationString)

References Config_getBool, FALSE, insertDimension(), and QCString::isEmpty().

Referenced by LatexDocVisitor::operator()(), XmlDocVisitor::operator()(), XmlDocVisitor::operator()(), XmlDocVisitor::operator()(), XmlDocVisitor::operator()(), XmlDocVisitor::operator()(), XmlDocVisitor::operator()(), LatexDocVisitor::startDiaFile(), LatexDocVisitor::startDotFile(), LatexDocVisitor::startMscFile(), LatexDocVisitor::startPlantUmlFile(), LatexDocVisitor::writeDiaFile(), 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.

47{ "doxysection",
48 "doxysubsection",
49 "doxysubsubsection",
50 "doxysubsubsubsection",
51 "doxysubsubsubsubsection",
52 "doxysubsubsubsubsubsection",
53 "doxysubsubsubsubsubsubsection"
54};

Referenced by LatexDocVisitor::getSectionName().

◆ g_subparagraphLabel

const char* g_subparagraphLabel = "doxysubparagraph"
static

Definition at line 57 of file latexdocvisitor.cpp.

Referenced by LatexDocVisitor::getSectionName().