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)
 
static bool tableIsNested (const DocNodeVariant *n)
 
static void writeStartTableCommand (TextStream &t, const DocNodeVariant *n, size_t cols)
 
static void writeEndTableCommand (TextStream &t, const DocNodeVariant *n)
 

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()

static bool classEqualsReflist ( const DocHtmlDescList & dl)
static

Definition at line 1122 of file latexdocvisitor.cpp.

1123{
1124 HtmlAttribList attrs = dl.attribs();
1125 auto it = std::find_if(attrs.begin(),attrs.end(),
1126 [](const auto &att) { return att.name=="class"; });
1127 if (it!=attrs.end() && it->value == "reflist") return true;
1128 return false;
1129}
const HtmlAttribList & attribs() const
Definition docnode.h:885
Class representing a list of HTML attributes.
Definition htmlattrib.h:31

References DocHtmlDescList::attribs().

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

◆ insertDimension()

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

Definition at line 89 of file latexdocvisitor.cpp.

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

static bool listIsNested ( const DocHtmlDescList & dl)
static

Definition at line 1131 of file latexdocvisitor.cpp.

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

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

Referenced by LatexDocVisitor::operator()().

◆ makeBaseName()

static QCString makeBaseName ( const QCString & name)
static

Definition at line 219 of file latexdocvisitor.cpp.

220{
221 QCString baseName = makeShortName(name);
222 int i=baseName.find('.');
223 if (i!=-1)
224 {
225 baseName=baseName.left(i);
226 }
227 return baseName;
228}
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()

static QCString makeShortName ( const QCString & name)
static

Definition at line 208 of file latexdocvisitor.cpp.

209{
210 QCString shortName = name;
211 int i = shortName.findRev('/');
212 if (i!=-1)
213 {
214 shortName=shortName.mid(i+1);
215 }
216 return shortName;
217}
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().

◆ tableIsNested()

static bool tableIsNested ( const DocNodeVariant * n)
static

Definition at line 1189 of file latexdocvisitor.cpp.

1190{
1191 bool isNested=FALSE;
1192 while (n && !isNested)
1193 {
1195 n = ::parent(n);
1196 }
1197 return isNested;
1198}
constexpr bool holds_one_of_alternatives(const DocNodeVariant &v)
returns true iff v holds one of types passed as template parameters
Definition docnode.h:1346
#define FALSE
Definition qcstring.h:34

References FALSE, holds_one_of_alternatives(), and parent().

Referenced by LatexDocVisitor::operator()(), LatexDocVisitor::operator()(), writeEndTableCommand(), and writeStartTableCommand().

◆ visitPostEnd()

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

Definition at line 188 of file latexdocvisitor.cpp.

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

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()

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

Definition at line 109 of file latexdocvisitor.cpp.

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

◆ writeEndTableCommand()

static void writeEndTableCommand ( TextStream & t,
const DocNodeVariant * n )
static

Definition at line 1213 of file latexdocvisitor.cpp.

1214{
1215 if (tableIsNested(n))
1216 {
1217 t << "\\end{tabularx}}\n";
1218 }
1219 else
1220 {
1221 t << "\\end{longtabu}\n";
1222 }
1223 //return isNested ? "TabularNC" : "TabularC";
1224}
static bool tableIsNested(const DocNodeVariant *n)

References tableIsNested().

Referenced by LatexDocVisitor::operator()().

◆ writeStartTableCommand()

static void writeStartTableCommand ( TextStream & t,
const DocNodeVariant * n,
size_t cols )
static

Definition at line 1200 of file latexdocvisitor.cpp.

1201{
1202 if (tableIsNested(n))
1203 {
1204 t << "{\\begin{tabularx}{\\linewidth}{|*{" << cols << "}{>{\\raggedright\\arraybackslash}X|}}";
1205 }
1206 else
1207 {
1208 t << "\\tabulinesep=1mm\n\\begin{longtabu}spread 0pt [c]{*{" << cols << "}{|X[-1]}|}\n";
1209 }
1210 //return isNested ? "TabularNC" : "TabularC";
1211}

References tableIsNested().

Referenced by LatexDocVisitor::operator()().

Variable Documentation

◆ g_maxLevels

const int g_maxLevels = 7
static

Definition at line 44 of file latexdocvisitor.cpp.

Referenced by LatexDocVisitor::getSectionName().

◆ g_paragraphLabel

const char* g_paragraphLabel = "doxyparagraph"
static

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

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

Referenced by LatexDocVisitor::getSectionName().

◆ g_subparagraphLabel

const char* g_subparagraphLabel = "doxysubparagraph"
static

Definition at line 56 of file latexdocvisitor.cpp.

Referenced by LatexDocVisitor::getSectionName().